gavl
|
00001 /***************************************************************** 00002 * gavl - a general purpose audio/video processing library 00003 * 00004 * Copyright (c) 2001 - 2012 Members of the Gmerlin project 00005 * gmerlin-general@lists.sourceforge.net 00006 * http://gmerlin.sourceforge.net 00007 * 00008 * This program is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation, either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 * *****************************************************************/ 00021 00027 #ifndef GAVL_H_INCLUDED 00028 #define GAVL_H_INCLUDED 00029 00030 #include <inttypes.h> 00031 00032 #include <gavl/gavldefs.h> 00033 #include <gavl/gavltime.h> 00034 #include <gavl/timecode.h> 00035 00036 #ifdef __cplusplus 00037 extern "C" { 00038 #endif 00039 00040 /* Forward declarations */ 00041 00048 typedef struct gavl_video_source_s gavl_video_source_t; 00049 00056 typedef struct gavl_audio_source_s gavl_audio_source_t; 00057 00064 typedef struct gavl_packet_source_s gavl_packet_source_t; 00065 00072 typedef struct 00073 gavl_audio_sink_s gavl_audio_sink_t; 00074 00081 typedef struct 00082 gavl_video_sink_s gavl_video_sink_t; 00083 00090 typedef struct 00091 gavl_packet_sink_s gavl_packet_sink_t; 00092 00115 typedef void (*gavl_video_process_func)(void * data, int start, int end); 00116 00130 typedef void (*gavl_video_run_func)(gavl_video_process_func func, 00131 void * gavl_data, 00132 int start, int end, 00133 void * client_data, int thread); 00134 00143 typedef void (*gavl_video_stop_func)(void * client_data, int thread); 00144 00153 typedef struct gavl_video_format_s gavl_video_format_t; 00154 00155 00156 /* Quality levels */ 00157 00181 #define GAVL_QUALITY_FASTEST 1 00182 00189 #define GAVL_QUALITY_BEST 5 00190 00197 #define GAVL_QUALITY_DEFAULT 2 00198 00210 #define GAVL_ACCEL_MMX (1<<0) //!< MMX 00211 #define GAVL_ACCEL_MMXEXT (1<<1) //!< Extended MMX (a.k.a MMX2) 00212 #define GAVL_ACCEL_SSE (1<<2) //!< Intel SSE 00213 #define GAVL_ACCEL_SSE2 (1<<3) //!< Intel SSE2 00214 #define GAVL_ACCEL_SSE3 (1<<4) //!< Intel SSE3 00215 #define GAVL_ACCEL_3DNOW (1<<5) //!< AMD 3Dnow 00216 #define GAVL_ACCEL_3DNOWEXT (1<<6) //!< AMD 3Dnow ext 00217 #define GAVL_ACCEL_SSSE3 (1<<7) //!< Intel SSSE3 00218 00223 GAVL_PUBLIC int gavl_accel_supported(); 00224 00233 /* Sample formats: all multibyte numbers are native endian */ 00234 00247 #define GAVL_MAX_CHANNELS 128 00248 00255 typedef enum 00256 { 00257 GAVL_SAMPLE_NONE = 0, 00258 GAVL_SAMPLE_U8 = 1, 00259 GAVL_SAMPLE_S8 = 2, 00260 GAVL_SAMPLE_U16 = 3, 00261 GAVL_SAMPLE_S16 = 4, 00262 GAVL_SAMPLE_S32 = 5, 00263 GAVL_SAMPLE_FLOAT = 6, 00264 GAVL_SAMPLE_DOUBLE = 7 00265 } gavl_sample_format_t; 00266 00272 typedef enum 00273 { 00274 GAVL_INTERLEAVE_NONE = 0, 00275 GAVL_INTERLEAVE_2 = 1, 00276 GAVL_INTERLEAVE_ALL = 2 00277 } gavl_interleave_mode_t; 00278 00286 typedef enum 00287 { 00288 GAVL_CHID_NONE = 0, 00289 GAVL_CHID_FRONT_CENTER, 00290 GAVL_CHID_FRONT_LEFT, 00291 GAVL_CHID_FRONT_RIGHT, 00292 GAVL_CHID_FRONT_CENTER_LEFT, 00293 GAVL_CHID_FRONT_CENTER_RIGHT, 00294 GAVL_CHID_REAR_LEFT, 00295 GAVL_CHID_REAR_RIGHT, 00296 GAVL_CHID_REAR_CENTER, 00297 GAVL_CHID_SIDE_LEFT, 00298 GAVL_CHID_SIDE_RIGHT, 00299 GAVL_CHID_LFE, 00300 GAVL_CHID_AUX, 00301 } gavl_channel_id_t; 00302 00311 typedef struct 00312 { 00313 uint32_t samples_per_frame; 00314 uint32_t samplerate; 00315 uint32_t num_channels; 00316 gavl_sample_format_t sample_format; 00317 gavl_interleave_mode_t interleave_mode; 00319 float center_level; 00320 float rear_level; 00322 gavl_channel_id_t channel_locations[GAVL_MAX_CHANNELS]; 00324 } gavl_audio_format_t; 00325 00326 00327 /* Audio format -> string conversions */ 00328 00336 GAVL_PUBLIC 00337 const char * gavl_sample_format_to_string(gavl_sample_format_t format); 00338 00347 GAVL_PUBLIC 00348 gavl_sample_format_t gavl_string_to_sample_format(const char * str); 00349 00355 GAVL_PUBLIC 00356 int gavl_num_sample_formats(); 00357 00364 GAVL_PUBLIC 00365 gavl_sample_format_t gavl_get_sample_format(int index); 00366 00373 GAVL_PUBLIC 00374 const char * gavl_channel_id_to_string(gavl_channel_id_t id); 00375 00376 00383 GAVL_PUBLIC 00384 const char * gavl_interleave_mode_to_string(gavl_interleave_mode_t mode); 00385 00392 GAVL_PUBLIC 00393 void gavl_audio_format_dump(const gavl_audio_format_t * format); 00394 00407 GAVL_PUBLIC 00408 void gavl_audio_format_dumpi(const gavl_audio_format_t * format, int indent); 00409 00418 GAVL_PUBLIC 00419 int gavl_channel_index(const gavl_audio_format_t * format, gavl_channel_id_t id); 00420 00427 GAVL_PUBLIC 00428 int gavl_front_channels(const gavl_audio_format_t * format); 00429 00436 GAVL_PUBLIC 00437 int gavl_rear_channels(const gavl_audio_format_t * format); 00438 00445 GAVL_PUBLIC 00446 int gavl_side_channels(const gavl_audio_format_t * format); 00447 00454 GAVL_PUBLIC 00455 int gavl_aux_channels(const gavl_audio_format_t * format); 00456 00457 00458 00465 GAVL_PUBLIC 00466 int gavl_lfe_channels(const gavl_audio_format_t * format); 00467 00475 GAVL_PUBLIC 00476 void gavl_audio_format_copy(gavl_audio_format_t * dst, 00477 const gavl_audio_format_t * src); 00478 00487 GAVL_PUBLIC 00488 int gavl_audio_formats_equal(const gavl_audio_format_t * format_1, 00489 const gavl_audio_format_t * format_2); 00490 00502 GAVL_PUBLIC 00503 void gavl_set_channel_setup(gavl_audio_format_t * format); 00504 00511 GAVL_PUBLIC 00512 int gavl_bytes_per_sample(gavl_sample_format_t format); 00513 00524 GAVL_PUBLIC 00525 int gavl_nearest_samplerate(int in_rate, const int * supported); 00526 00527 00542 typedef union 00543 { 00544 uint8_t * u_8; 00545 int8_t * s_8; 00547 uint16_t * u_16; 00548 int16_t * s_16; 00550 uint32_t * u_32; 00551 int32_t * s_32; 00553 float * f; 00554 double * d; 00555 } gavl_audio_samples_t; 00556 00562 typedef union 00563 { 00564 uint8_t * u_8[GAVL_MAX_CHANNELS]; 00565 int8_t * s_8[GAVL_MAX_CHANNELS]; 00567 uint16_t * u_16[GAVL_MAX_CHANNELS]; 00568 int16_t * s_16[GAVL_MAX_CHANNELS]; 00570 uint32_t * u_32[GAVL_MAX_CHANNELS]; 00571 int32_t * s_32[GAVL_MAX_CHANNELS]; 00573 float * f[GAVL_MAX_CHANNELS]; 00574 double * d[GAVL_MAX_CHANNELS]; 00576 } gavl_audio_channels_t; 00577 00594 typedef struct 00595 { 00596 gavl_audio_samples_t samples; 00597 gavl_audio_channels_t channels; 00598 int valid_samples; 00599 int64_t timestamp; 00600 int channel_stride; 00601 } gavl_audio_frame_t; 00602 00614 GAVL_PUBLIC 00615 gavl_audio_frame_t * gavl_audio_frame_create(const gavl_audio_format_t* format); 00616 00628 GAVL_PUBLIC 00629 void gavl_audio_frame_null(gavl_audio_frame_t * frame); 00630 00640 GAVL_PUBLIC 00641 void gavl_audio_frame_destroy(gavl_audio_frame_t * frame); 00642 00652 GAVL_PUBLIC 00653 void gavl_audio_frame_mute(gavl_audio_frame_t * frame, 00654 const gavl_audio_format_t * format); 00655 00666 GAVL_PUBLIC 00667 void gavl_audio_frame_mute_samples(gavl_audio_frame_t * frame, 00668 const gavl_audio_format_t * format, 00669 int num_samples); 00670 00671 00672 00683 GAVL_PUBLIC 00684 void gavl_audio_frame_mute_channel(gavl_audio_frame_t * frame, 00685 const gavl_audio_format_t * format, 00686 int channel); 00687 00708 GAVL_PUBLIC 00709 int gavl_audio_frame_copy(const gavl_audio_format_t * format, 00710 gavl_audio_frame_t * dst, 00711 const gavl_audio_frame_t * src, 00712 int dst_pos, 00713 int src_pos, 00714 int dst_size, 00715 int src_size); 00716 00729 GAVL_PUBLIC 00730 void gavl_audio_frame_copy_ptrs(const gavl_audio_format_t * format, 00731 gavl_audio_frame_t * dst, 00732 const gavl_audio_frame_t * src); 00733 00751 GAVL_PUBLIC 00752 void gavl_audio_frame_get_subframe(const gavl_audio_format_t * format, 00753 gavl_audio_frame_t * src, 00754 gavl_audio_frame_t * dst, 00755 int start, int len); 00756 00769 GAVL_PUBLIC 00770 int gavl_audio_frames_equal(const gavl_audio_format_t * format, 00771 const gavl_audio_frame_t * f1, 00772 const gavl_audio_frame_t * f2); 00773 00785 GAVL_PUBLIC 00786 int gavl_audio_frame_continuous(const gavl_audio_format_t * format, 00787 const gavl_audio_frame_t * f); 00788 00789 00800 GAVL_PUBLIC 00801 void gavl_audio_frame_set_channels(gavl_audio_frame_t * f, 00802 const gavl_audio_format_t * format, 00803 uint8_t * data); 00804 00823 GAVL_PUBLIC 00824 int gavl_audio_frame_skip(const gavl_audio_format_t * format, 00825 gavl_audio_frame_t * f, int num_samples); 00826 00827 00847 GAVL_PUBLIC 00848 int gavl_audio_frame_plot(const gavl_audio_format_t * format, 00849 const gavl_audio_frame_t * frame, 00850 const char * name_base); 00851 00852 00867 #define GAVL_AUDIO_FRONT_TO_REAR_COPY (1<<0) 00872 #define GAVL_AUDIO_FRONT_TO_REAR_MUTE (1<<1) 00877 #define GAVL_AUDIO_FRONT_TO_REAR_DIFF (1<<2) 00882 #define GAVL_AUDIO_FRONT_TO_REAR_MASK \ 00883 (GAVL_AUDIO_FRONT_TO_REAR_COPY | \ 00884 GAVL_AUDIO_FRONT_TO_REAR_MUTE | \ 00885 GAVL_AUDIO_FRONT_TO_REAR_DIFF) 00887 /* Options for mixing stereo to mono */ 00888 00891 #define GAVL_AUDIO_STEREO_TO_MONO_LEFT (1<<3) 00894 #define GAVL_AUDIO_STEREO_TO_MONO_RIGHT (1<<4) 00897 #define GAVL_AUDIO_STEREO_TO_MONO_MIX (1<<5) 00901 #define GAVL_AUDIO_STEREO_TO_MONO_MASK \ 00902 (GAVL_AUDIO_STEREO_TO_MONO_LEFT | \ 00903 GAVL_AUDIO_STEREO_TO_MONO_RIGHT | \ 00904 GAVL_AUDIO_STEREO_TO_MONO_MIX) 00909 #define GAVL_AUDIO_NORMALIZE_MIX_MATRIX (1<<6) 00916 typedef enum 00917 { 00918 GAVL_AUDIO_DITHER_NONE = 0, 00919 GAVL_AUDIO_DITHER_AUTO = 1, 00920 GAVL_AUDIO_DITHER_RECT = 2, 00921 GAVL_AUDIO_DITHER_TRI = 3, 00922 GAVL_AUDIO_DITHER_SHAPED = 4, 00923 } gavl_audio_dither_mode_t; 00924 00929 typedef enum 00930 { 00931 GAVL_RESAMPLE_AUTO = 0, 00932 GAVL_RESAMPLE_ZOH = 1, 00933 GAVL_RESAMPLE_LINEAR = 2, 00934 GAVL_RESAMPLE_SINC_FAST = 3, 00935 GAVL_RESAMPLE_SINC_MEDIUM = 4, 00936 GAVL_RESAMPLE_SINC_BEST = 5 00937 } gavl_resample_mode_t; 00938 00945 typedef struct gavl_audio_options_s gavl_audio_options_t; 00946 00953 GAVL_PUBLIC 00954 void gavl_audio_options_set_quality(gavl_audio_options_t * opt, int quality); 00955 00962 GAVL_PUBLIC 00963 int gavl_audio_options_get_quality(const gavl_audio_options_t * opt); 00964 00971 GAVL_PUBLIC 00972 void gavl_audio_options_set_dither_mode(gavl_audio_options_t * opt, gavl_audio_dither_mode_t mode); 00973 00980 GAVL_PUBLIC 00981 gavl_audio_dither_mode_t 00982 gavl_audio_options_get_dither_mode(const gavl_audio_options_t * opt); 00983 00984 00991 GAVL_PUBLIC 00992 void gavl_audio_options_set_resample_mode(gavl_audio_options_t * opt, gavl_resample_mode_t mode); 00993 01000 GAVL_PUBLIC 01001 gavl_resample_mode_t 01002 gavl_audio_options_get_resample_mode(const gavl_audio_options_t * opt); 01003 01010 GAVL_PUBLIC 01011 void gavl_audio_options_set_conversion_flags(gavl_audio_options_t * opt, 01012 int flags); 01013 01020 GAVL_PUBLIC 01021 int gavl_audio_options_get_conversion_flags(const gavl_audio_options_t * opt); 01022 01028 GAVL_PUBLIC 01029 void gavl_audio_options_set_defaults(gavl_audio_options_t * opt); 01030 01047 GAVL_PUBLIC 01048 void gavl_audio_options_set_mix_matrix(gavl_audio_options_t * opt, 01049 const double ** matrix); 01050 01059 GAVL_PUBLIC 01060 const double ** 01061 gavl_audio_options_get_mix_matrix(const gavl_audio_options_t * opt); 01062 01072 GAVL_PUBLIC 01073 gavl_audio_options_t * gavl_audio_options_create(); 01074 01081 GAVL_PUBLIC 01082 void gavl_audio_options_copy(gavl_audio_options_t * dst, 01083 const gavl_audio_options_t * src); 01084 01090 GAVL_PUBLIC 01091 void gavl_audio_options_destroy(gavl_audio_options_t * opt); 01092 01093 01094 01095 /* Audio converter */ 01096 01130 typedef struct gavl_audio_converter_s gavl_audio_converter_t; 01131 01137 GAVL_PUBLIC 01138 gavl_audio_converter_t * gavl_audio_converter_create(); 01139 01145 GAVL_PUBLIC 01146 void gavl_audio_converter_destroy(gavl_audio_converter_t* cnv); 01147 01156 GAVL_PUBLIC 01157 gavl_audio_options_t * gavl_audio_converter_get_options(gavl_audio_converter_t*cnv); 01158 01159 01174 GAVL_PUBLIC 01175 int gavl_audio_converter_init(gavl_audio_converter_t* cnv, 01176 const gavl_audio_format_t * input_format, 01177 const gavl_audio_format_t * output_format); 01178 01193 GAVL_PUBLIC 01194 int gavl_audio_converter_init_resample(gavl_audio_converter_t * cnv, 01195 const gavl_audio_format_t * format); 01196 01211 GAVL_PUBLIC 01212 int gavl_audio_converter_reinit(gavl_audio_converter_t* cnv); 01213 01214 01228 GAVL_PUBLIC 01229 void gavl_audio_convert(gavl_audio_converter_t * cnv, 01230 const gavl_audio_frame_t * input_frame, 01231 gavl_audio_frame_t * output_frame); 01232 01233 01252 GAVL_PUBLIC 01253 int gavl_audio_converter_set_resample_ratio(gavl_audio_converter_t * cnv, 01254 double ratio ) ; 01255 01256 01272 GAVL_PUBLIC 01273 void gavl_audio_converter_resample(gavl_audio_converter_t * cnv, 01274 gavl_audio_frame_t * input_frame, 01275 gavl_audio_frame_t * output_frame, 01276 double ratio); 01277 01278 01292 typedef struct gavl_volume_control_s gavl_volume_control_t; 01293 01294 /* Create / destroy */ 01295 01301 GAVL_PUBLIC 01302 gavl_volume_control_t * gavl_volume_control_create(); 01303 01309 GAVL_PUBLIC 01310 void gavl_volume_control_destroy(gavl_volume_control_t *ctrl); 01311 01319 GAVL_PUBLIC 01320 void gavl_volume_control_set_format(gavl_volume_control_t *ctrl, 01321 const gavl_audio_format_t * format); 01322 01329 GAVL_PUBLIC 01330 void gavl_volume_control_set_volume(gavl_volume_control_t * ctrl, 01331 float volume); 01332 01339 GAVL_PUBLIC 01340 void gavl_volume_control_apply(gavl_volume_control_t *ctrl, 01341 gavl_audio_frame_t * frame); 01342 01343 01353 #define GAVL_MAX_PLANES 4 01365 typedef struct 01366 { 01367 int32_t x; 01368 int32_t y; 01369 int32_t w; 01370 int32_t h; 01371 } gavl_rectangle_i_t; 01372 01377 typedef struct 01378 { 01379 double x; 01380 double y; 01381 double w; 01382 double h; 01383 } gavl_rectangle_f_t; 01384 01391 GAVL_PUBLIC 01392 void gavl_rectangle_i_crop_to_format(gavl_rectangle_i_t * r, 01393 const gavl_video_format_t * format); 01394 01401 GAVL_PUBLIC 01402 void gavl_rectangle_f_crop_to_format(gavl_rectangle_f_t * r, 01403 const gavl_video_format_t * format); 01404 01419 GAVL_PUBLIC 01420 void gavl_rectangle_crop_to_format_noscale(gavl_rectangle_i_t * src_rect, 01421 gavl_rectangle_i_t * dst_rect, 01422 const gavl_video_format_t * src_format, 01423 const gavl_video_format_t * dst_format); 01424 01436 GAVL_PUBLIC 01437 void gavl_rectangle_crop_to_format_scale(gavl_rectangle_f_t * src_rect, 01438 gavl_rectangle_i_t * dst_rect, 01439 const gavl_video_format_t * src_format, 01440 const gavl_video_format_t * dst_format); 01441 01442 01443 01450 GAVL_PUBLIC 01451 void gavl_rectangle_i_set_all(gavl_rectangle_i_t * r, const gavl_video_format_t * format); 01452 01459 GAVL_PUBLIC 01460 void gavl_rectangle_f_set_all(gavl_rectangle_f_t * r, const gavl_video_format_t * format); 01461 01468 GAVL_PUBLIC 01469 void gavl_rectangle_i_crop_left(gavl_rectangle_i_t * r, int num_pixels); 01470 01477 GAVL_PUBLIC 01478 void gavl_rectangle_i_crop_right(gavl_rectangle_i_t * r, int num_pixels); 01479 01486 GAVL_PUBLIC 01487 void gavl_rectangle_i_crop_top(gavl_rectangle_i_t * r, int num_pixels); 01488 01495 GAVL_PUBLIC 01496 void gavl_rectangle_i_crop_bottom(gavl_rectangle_i_t * r, int num_pixels); 01497 01504 GAVL_PUBLIC 01505 void gavl_rectangle_f_crop_left(gavl_rectangle_f_t * r, double num_pixels); 01506 01513 GAVL_PUBLIC 01514 void gavl_rectangle_f_crop_right(gavl_rectangle_f_t * r, double num_pixels); 01515 01522 GAVL_PUBLIC 01523 void gavl_rectangle_f_crop_top(gavl_rectangle_f_t * r, double num_pixels); 01524 01531 GAVL_PUBLIC 01532 void gavl_rectangle_f_crop_bottom(gavl_rectangle_f_t * r, double num_pixels); 01533 01547 GAVL_PUBLIC 01548 void gavl_rectangle_i_align(gavl_rectangle_i_t * r, int h_align, int v_align); 01549 01559 GAVL_PUBLIC 01560 void gavl_rectangle_i_align_to_format(gavl_rectangle_i_t * r, 01561 const gavl_video_format_t * format); 01562 01563 01570 GAVL_PUBLIC 01571 void gavl_rectangle_i_copy(gavl_rectangle_i_t * dst, const gavl_rectangle_i_t * src); 01572 01579 GAVL_PUBLIC 01580 void gavl_rectangle_f_copy(gavl_rectangle_f_t * dst, const gavl_rectangle_f_t * src); 01581 01582 01583 01590 GAVL_PUBLIC 01591 void gavl_rectangle_i_to_f(gavl_rectangle_f_t * dst, const gavl_rectangle_i_t * src); 01592 01599 GAVL_PUBLIC 01600 void gavl_rectangle_f_to_i(gavl_rectangle_i_t * dst, const gavl_rectangle_f_t * src); 01601 01610 GAVL_PUBLIC 01611 int gavl_rectangle_i_is_empty(const gavl_rectangle_i_t * r); 01612 01621 GAVL_PUBLIC 01622 int gavl_rectangle_f_is_empty(const gavl_rectangle_f_t * r); 01623 01651 GAVL_PUBLIC 01652 void gavl_rectangle_fit_aspect(gavl_rectangle_i_t * dst_rect, 01653 const gavl_video_format_t * src_format, 01654 const gavl_rectangle_f_t * src_rect, 01655 const gavl_video_format_t * dst_format, 01656 float zoom, float squeeze); 01657 01662 GAVL_PUBLIC 01663 void gavl_rectangle_i_dump(const gavl_rectangle_i_t * r); 01664 01669 GAVL_PUBLIC 01670 void gavl_rectangle_f_dump(const gavl_rectangle_f_t * r); 01671 01672 01682 #define GAVL_PIXFMT_PLANAR (1<<8) 01683 01687 #define GAVL_PIXFMT_RGB (1<<9) 01688 01692 #define GAVL_PIXFMT_YUV (1<<10) 01693 01697 #define GAVL_PIXFMT_YUVJ (1<<11) 01698 01702 #define GAVL_PIXFMT_ALPHA (1<<12) 01703 01707 #define GAVL_PIXFMT_GRAY (1<<13) 01708 01713 typedef enum 01714 { 01717 GAVL_PIXELFORMAT_NONE = 0, 01718 01721 GAVL_GRAY_8 = 1 | GAVL_PIXFMT_GRAY, 01722 01725 GAVL_GRAY_16 = 2 | GAVL_PIXFMT_GRAY, 01726 01729 GAVL_GRAY_FLOAT = 3 | GAVL_PIXFMT_GRAY, 01730 01733 GAVL_GRAYA_16 = 1 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA, 01734 01737 GAVL_GRAYA_32 = 2 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA, 01738 01741 GAVL_GRAYA_FLOAT = 3 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA, 01742 01746 GAVL_RGB_15 = 1 | GAVL_PIXFMT_RGB, 01750 GAVL_BGR_15 = 2 | GAVL_PIXFMT_RGB, 01754 GAVL_RGB_16 = 3 | GAVL_PIXFMT_RGB, 01758 GAVL_BGR_16 = 4 | GAVL_PIXFMT_RGB, 01761 GAVL_RGB_24 = 5 | GAVL_PIXFMT_RGB, 01764 GAVL_BGR_24 = 6 | GAVL_PIXFMT_RGB, 01767 GAVL_RGB_32 = 7 | GAVL_PIXFMT_RGB, 01770 GAVL_BGR_32 = 8 | GAVL_PIXFMT_RGB, 01773 GAVL_RGBA_32 = 9 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA, 01774 01777 GAVL_RGB_48 = 10 | GAVL_PIXFMT_RGB, 01780 GAVL_RGBA_64 = 11 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA, 01781 01784 GAVL_RGB_FLOAT = 12 | GAVL_PIXFMT_RGB, 01787 GAVL_RGBA_FLOAT = 13 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA, 01788 01791 GAVL_YUY2 = 1 | GAVL_PIXFMT_YUV, 01794 GAVL_UYVY = 2 | GAVL_PIXFMT_YUV, 01797 GAVL_YUVA_32 = 3 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA, 01800 GAVL_YUVA_64 = 4 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA, 01803 GAVL_YUV_FLOAT = 5 | GAVL_PIXFMT_YUV, 01804 01807 GAVL_YUVA_FLOAT = 6 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA, 01808 01812 GAVL_YUV_420_P = 1 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, 01815 GAVL_YUV_422_P = 2 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, 01818 GAVL_YUV_444_P = 3 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, 01821 GAVL_YUV_411_P = 4 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, 01824 GAVL_YUV_410_P = 5 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, 01825 01828 GAVL_YUVJ_420_P = 6 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ, 01831 GAVL_YUVJ_422_P = 7 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ, 01834 GAVL_YUVJ_444_P = 8 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ, 01835 01838 GAVL_YUV_444_P_16 = 9 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, 01841 GAVL_YUV_422_P_16 = 10 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, 01842 01843 } gavl_pixelformat_t; 01844 01847 #define GAVL_PIXELFORMAT_1D_8 GAVL_GRAY_8 01848 01850 #define GAVL_PIXELFORMAT_2D_8 GAVL_GRAYA_16 01851 01853 #define GAVL_PIXELFORMAT_3D_8 GAVL_RGB_24 01854 01856 #define GAVL_PIXELFORMAT_4D_8 GAVL_RGBA_32 01857 01860 #define GAVL_PIXELFORMAT_1D_16 GAVL_GRAY_16 01861 01863 #define GAVL_PIXELFORMAT_2D_16 GAVL_GRAYA_32 01864 01866 #define GAVL_PIXELFORMAT_3D_16 GAVL_RGB_48 01867 01869 #define GAVL_PIXELFORMAT_4D_16 GAVL_RGBA_64 01870 01873 #define GAVL_PIXELFORMAT_1D_FLOAT GAVL_GRAY_FLOAT 01874 01876 #define GAVL_PIXELFORMAT_2D_FLOAT GAVL_GRAYA_FLOAT 01877 01879 #define GAVL_PIXELFORMAT_3D_FLOAT GAVL_RGB_FLOAT 01880 01882 #define GAVL_PIXELFORMAT_4D_FLOAT GAVL_RGBA_FLOAT 01883 01890 typedef enum 01891 { 01892 GAVL_CCH_NONE = 0, 01893 GAVL_CCH_RED, 01894 GAVL_CCH_GREEN, 01895 GAVL_CCH_BLUE, 01896 GAVL_CCH_Y, 01897 GAVL_CCH_CB, 01898 GAVL_CCH_CR, 01899 GAVL_CCH_ALPHA, 01900 } gavl_color_channel_t; 01901 01902 /* 01903 * Colormodel related functions 01904 */ 01905 01912 #define gavl_pixelformat_is_gray(fmt) ((fmt) & GAVL_PIXFMT_GRAY) 01913 01914 01921 #define gavl_pixelformat_is_rgb(fmt) ((fmt) & GAVL_PIXFMT_RGB) 01922 01929 #define gavl_pixelformat_is_yuv(fmt) ((fmt) & GAVL_PIXFMT_YUV) 01930 01937 #define gavl_pixelformat_is_jpeg_scaled(fmt) ((fmt) & GAVL_PIXFMT_YUVJ) 01938 01945 #define gavl_pixelformat_has_alpha(fmt) ((fmt) & GAVL_PIXFMT_ALPHA) 01946 01953 #define gavl_pixelformat_is_planar(fmt) ((fmt) & GAVL_PIXFMT_PLANAR) 01954 01955 01962 GAVL_PUBLIC 01963 int gavl_pixelformat_num_channels(gavl_pixelformat_t pixelformat); 01964 01972 GAVL_PUBLIC gavl_color_channel_t 01973 gavl_pixelformat_get_channel(gavl_pixelformat_t pixelformat, int index); 01974 01975 01982 GAVL_PUBLIC 01983 int gavl_pixelformat_num_planes(gavl_pixelformat_t pixelformat); 01984 01994 GAVL_PUBLIC 01995 void gavl_pixelformat_chroma_sub(gavl_pixelformat_t pixelformat, int * sub_h, int * sub_v); 01996 02003 GAVL_PUBLIC 02004 int gavl_pixelformat_bytes_per_component(gavl_pixelformat_t pixelformat); 02005 02012 GAVL_PUBLIC 02013 int gavl_pixelformat_bytes_per_pixel(gavl_pixelformat_t pixelformat); 02014 02021 GAVL_PUBLIC 02022 int gavl_pixelformat_bits_per_pixel(gavl_pixelformat_t pixelformat); 02023 02038 GAVL_PUBLIC 02039 int gavl_pixelformat_conversion_penalty(gavl_pixelformat_t src, 02040 gavl_pixelformat_t dst); 02041 02055 GAVL_PUBLIC gavl_pixelformat_t 02056 gavl_pixelformat_get_best(gavl_pixelformat_t src, 02057 const gavl_pixelformat_t * dst_supported, 02058 int * penalty); 02059 02060 02061 02068 GAVL_PUBLIC 02069 const char * gavl_pixelformat_to_string(gavl_pixelformat_t pixelformat); 02070 02080 GAVL_PUBLIC 02081 const char * gavl_pixelformat_to_short_string(gavl_pixelformat_t pixelformat); 02082 02083 02090 GAVL_PUBLIC 02091 gavl_pixelformat_t gavl_string_to_pixelformat(const char * name); 02092 02099 GAVL_PUBLIC 02100 gavl_pixelformat_t gavl_short_string_to_pixelformat(const char * name); 02101 02102 02108 GAVL_PUBLIC 02109 int gavl_num_pixelformats(); 02110 02117 GAVL_PUBLIC 02118 gavl_pixelformat_t gavl_get_pixelformat(int index); 02119 02120 /* */ 02121 02130 typedef enum 02131 { 02132 GAVL_CHROMA_PLACEMENT_DEFAULT = 0, 02133 GAVL_CHROMA_PLACEMENT_MPEG2, 02134 GAVL_CHROMA_PLACEMENT_DVPAL 02135 } gavl_chroma_placement_t; 02136 02143 GAVL_PUBLIC 02144 const char * gavl_chroma_placement_to_string(gavl_chroma_placement_t mode); 02145 02150 /* Changing the values alters the gmerlin-avdecoder index format */ 02151 02152 typedef enum 02153 { 02154 GAVL_FRAMERATE_UNKNOWN = -1, 02155 GAVL_FRAMERATE_CONSTANT = 0, 02156 GAVL_FRAMERATE_VARIABLE = 1, 02157 GAVL_FRAMERATE_STILL = 2, 02158 } gavl_framerate_mode_t; 02159 02166 GAVL_PUBLIC 02167 const char * gavl_framerate_mode_to_string(gavl_framerate_mode_t mode); 02168 02173 /* Changing the values alters the gmerlin-avdecoder index format */ 02174 02175 typedef enum 02176 { 02177 GAVL_INTERLACE_UNKNOWN = -1, 02178 GAVL_INTERLACE_NONE = 0, 02179 GAVL_INTERLACE_TOP_FIRST = 1, 02180 GAVL_INTERLACE_BOTTOM_FIRST = 2, 02181 GAVL_INTERLACE_MIXED = (0x10 | 1), 02182 GAVL_INTERLACE_MIXED_TOP = (0x10 | 2), 02183 GAVL_INTERLACE_MIXED_BOTTOM = (0x10 | 3), 02184 } gavl_interlace_mode_t; 02185 02192 GAVL_PUBLIC 02193 const char * gavl_interlace_mode_to_string(gavl_interlace_mode_t mode); 02194 02203 GAVL_PUBLIC 02204 int gavl_interlace_mode_is_mixed(gavl_interlace_mode_t mode); 02205 02206 /* Video format structure */ 02207 02212 struct gavl_video_format_s 02213 { 02214 uint32_t frame_width; 02215 uint32_t frame_height; 02217 uint32_t image_width; 02218 uint32_t image_height; 02220 /* Support for nonsquare pixels */ 02221 02222 uint32_t pixel_width; 02223 uint32_t pixel_height; 02225 gavl_pixelformat_t pixelformat; 02227 uint32_t frame_duration; 02229 uint32_t timescale; 02231 gavl_framerate_mode_t framerate_mode; 02232 gavl_chroma_placement_t chroma_placement; 02234 gavl_interlace_mode_t interlace_mode; 02236 gavl_timecode_format_t timecode_format; 02237 }; 02238 02246 GAVL_PUBLIC 02247 void gavl_video_format_copy(gavl_video_format_t * dst, 02248 const gavl_video_format_t * src); 02249 02258 GAVL_PUBLIC 02259 int gavl_video_formats_equal(const gavl_video_format_t * format_1, 02260 const gavl_video_format_t * format_2); 02261 02262 02273 GAVL_PUBLIC 02274 void gavl_video_format_get_chroma_offset(const gavl_video_format_t * format, int field, int plane, 02275 float * off_x, float * off_y); 02276 02277 02278 02291 GAVL_PUBLIC 02292 void gavl_video_format_fit_to_source(gavl_video_format_t * dst, 02293 const gavl_video_format_t * src); 02294 02302 GAVL_PUBLIC 02303 int gavl_video_format_get_image_size(const gavl_video_format_t * format); 02304 02321 GAVL_PUBLIC 02322 void gavl_video_format_set_frame_size(gavl_video_format_t * format, 02323 int pad_h, int pad_v); 02324 02325 02341 GAVL_PUBLIC 02342 int gavl_get_color_channel_format(const gavl_video_format_t * frame_format, 02343 gavl_video_format_t * channel_format, 02344 gavl_color_channel_t ch); 02345 02346 02360 GAVL_PUBLIC 02361 void gavl_get_field_format(const gavl_video_format_t * frame_format, 02362 gavl_video_format_t * field_format, 02363 int field); 02364 02365 02372 GAVL_PUBLIC 02373 void gavl_video_format_dump(const gavl_video_format_t * format); 02374 02387 GAVL_PUBLIC 02388 void gavl_video_format_dumpi(const gavl_video_format_t * format, int indent); 02389 02390 02413 typedef struct gavl_video_frame_s 02414 { 02415 uint8_t * planes[GAVL_MAX_PLANES]; 02416 int strides[GAVL_MAX_PLANES]; 02418 void * user_data; 02419 int64_t timestamp; 02420 int64_t duration; 02421 gavl_interlace_mode_t interlace_mode; 02422 gavl_timecode_t timecode; 02424 int refcount; 02425 void (*destroy)(struct gavl_video_frame_s*, void*priv); 02426 void * destroy_priv; 02428 gavl_rectangle_i_t src_rect; 02429 int32_t dst_x; 02430 int32_t dst_y; 02431 02432 } gavl_video_frame_t; 02433 02434 02446 GAVL_PUBLIC 02447 gavl_video_frame_t * gavl_video_frame_create(const gavl_video_format_t*format); 02448 02459 GAVL_PUBLIC 02460 gavl_video_frame_t * gavl_video_frame_create_nopad(const gavl_video_format_t*format); 02461 02462 02463 02473 GAVL_PUBLIC 02474 void gavl_video_frame_destroy(gavl_video_frame_t*frame); 02475 02487 GAVL_PUBLIC 02488 void gavl_video_frame_null(gavl_video_frame_t*frame); 02489 02498 GAVL_PUBLIC 02499 void gavl_video_frame_clear(gavl_video_frame_t * frame, 02500 const gavl_video_format_t * format); 02501 02511 GAVL_PUBLIC 02512 void gavl_video_frame_fill(gavl_video_frame_t * frame, 02513 const gavl_video_format_t * format, 02514 const float * color); 02515 02528 GAVL_PUBLIC 02529 void gavl_video_frame_absdiff(gavl_video_frame_t * dst, 02530 const gavl_video_frame_t * src1, 02531 const gavl_video_frame_t * src2, 02532 const gavl_video_format_t * format); 02533 02546 GAVL_PUBLIC 02547 void gavl_video_frame_psnr(double * psnr, 02548 const gavl_video_frame_t * src1, 02549 const gavl_video_frame_t * src2, 02550 const gavl_video_format_t * format); 02551 02578 GAVL_PUBLIC 02579 int gavl_video_frame_ssim(const gavl_video_frame_t * src1, 02580 const gavl_video_frame_t * src2, 02581 gavl_video_frame_t * dst, 02582 const gavl_video_format_t * format); 02583 02597 GAVL_PUBLIC 02598 void gavl_video_frame_copy(const gavl_video_format_t * format, 02599 gavl_video_frame_t * dst, 02600 const gavl_video_frame_t * src); 02601 02614 GAVL_PUBLIC 02615 void gavl_video_frame_copy_plane(const gavl_video_format_t * format, 02616 gavl_video_frame_t * dst, 02617 const gavl_video_frame_t * src, int plane); 02618 02630 GAVL_PUBLIC 02631 void gavl_video_frame_copy_flip_x(const gavl_video_format_t * format, 02632 gavl_video_frame_t * dst, 02633 const gavl_video_frame_t * src); 02634 02646 GAVL_PUBLIC 02647 void gavl_video_frame_copy_flip_y(const gavl_video_format_t * format, 02648 gavl_video_frame_t * dst, 02649 const gavl_video_frame_t * src); 02650 02662 GAVL_PUBLIC 02663 void gavl_video_frame_copy_flip_xy(const gavl_video_format_t * format, 02664 gavl_video_frame_t * dst, 02665 const gavl_video_frame_t * src); 02666 02679 GAVL_PUBLIC 02680 void gavl_video_frame_copy_metadata(gavl_video_frame_t * dst, 02681 const gavl_video_frame_t * src); 02682 02683 02701 GAVL_PUBLIC 02702 void gavl_video_frame_get_subframe(gavl_pixelformat_t pixelformat, 02703 const gavl_video_frame_t * src, 02704 gavl_video_frame_t * dst, 02705 const gavl_rectangle_i_t * src_rect); 02706 02722 GAVL_PUBLIC 02723 void gavl_video_frame_get_field(gavl_pixelformat_t pixelformat, 02724 const gavl_video_frame_t * src, 02725 gavl_video_frame_t * dst, 02726 int field); 02727 02728 02729 02742 GAVL_PUBLIC 02743 void gavl_video_frame_dump(gavl_video_frame_t * frame, 02744 const gavl_video_format_t * format, 02745 const char * namebase); 02746 02757 GAVL_PUBLIC 02758 void gavl_video_frame_dump_metadata(const gavl_video_format_t * format, 02759 const gavl_video_frame_t * frame); 02760 02771 GAVL_PUBLIC 02772 void gavl_video_frame_set_strides(gavl_video_frame_t * frame, 02773 const gavl_video_format_t * format); 02774 02787 GAVL_PUBLIC 02788 void gavl_video_frame_set_planes(gavl_video_frame_t * frame, 02789 const gavl_video_format_t * format, 02790 uint8_t * buffer); 02791 02803 GAVL_PUBLIC 02804 int gavl_video_frame_continuous(const gavl_video_format_t * format, 02805 const gavl_video_frame_t * frame); 02806 02807 02822 GAVL_PUBLIC 02823 int gavl_video_frame_extract_channel(const gavl_video_format_t * format, 02824 gavl_color_channel_t ch, 02825 const gavl_video_frame_t * src, 02826 gavl_video_frame_t * dst); 02827 02843 GAVL_PUBLIC 02844 int gavl_video_frame_insert_channel(const gavl_video_format_t * format, 02845 gavl_color_channel_t ch, 02846 const gavl_video_frame_t * src, 02847 gavl_video_frame_t * dst); 02848 02849 02861 GAVL_PUBLIC 02862 int gavl_video_frames_equal(const gavl_video_format_t * format, 02863 const gavl_video_frame_t * f1, 02864 const gavl_video_frame_t * f2); 02865 02866 02867 /***************************** 02868 Conversion options 02869 ******************************/ 02870 02886 #define GAVL_FORCE_DEINTERLACE (1<<0) 02887 02892 #define GAVL_CONVOLVE_CHROMA (1<<1) 02893 02898 #define GAVL_CONVOLVE_NORMALIZE (1<<2) 02899 02907 #define GAVL_RESAMPLE_CHROMA (1<<3) 02908 02916 typedef enum 02917 { 02918 GAVL_ALPHA_IGNORE = 0, 02919 GAVL_ALPHA_BLEND_COLOR 02920 } gavl_alpha_mode_t; 02921 02928 typedef enum 02929 { 02930 GAVL_DEINTERLACE_NONE = 0, 02931 GAVL_DEINTERLACE_COPY = 1, 02932 GAVL_DEINTERLACE_SCALE = 2, 02933 GAVL_DEINTERLACE_BLEND = 3 02934 } gavl_deinterlace_mode_t; 02935 02942 typedef enum 02943 { 02944 GAVL_DEINTERLACE_DROP_TOP, 02945 GAVL_DEINTERLACE_DROP_BOTTOM, 02946 } gavl_deinterlace_drop_mode_t; 02947 02952 typedef enum 02953 { 02954 GAVL_SCALE_AUTO, 02955 GAVL_SCALE_NEAREST, 02956 GAVL_SCALE_BILINEAR, 02957 GAVL_SCALE_QUADRATIC, 02958 GAVL_SCALE_CUBIC_BSPLINE, 02959 GAVL_SCALE_CUBIC_MITCHELL, 02960 GAVL_SCALE_CUBIC_CATMULL, 02961 GAVL_SCALE_SINC_LANCZOS, 02962 GAVL_SCALE_NONE, 02963 } gavl_scale_mode_t; 02964 02974 typedef enum 02975 { 02976 GAVL_DOWNSCALE_FILTER_AUTO = 0, 02977 GAVL_DOWNSCALE_FILTER_NONE, 02978 GAVL_DOWNSCALE_FILTER_WIDE, 02979 GAVL_DOWNSCALE_FILTER_GAUSS, 02980 } gavl_downscale_filter_t; 02981 02988 typedef struct gavl_video_options_s gavl_video_options_t; 02989 02990 /* Default Options */ 02991 02997 GAVL_PUBLIC 02998 void gavl_video_options_set_defaults(gavl_video_options_t * opt); 02999 03009 GAVL_PUBLIC 03010 gavl_video_options_t * gavl_video_options_create(); 03011 03018 GAVL_PUBLIC 03019 void gavl_video_options_copy(gavl_video_options_t * dst, 03020 const gavl_video_options_t * src); 03021 03027 GAVL_PUBLIC 03028 void gavl_video_options_destroy(gavl_video_options_t * opt); 03029 03030 03045 GAVL_PUBLIC 03046 void gavl_video_options_set_rectangles(gavl_video_options_t * opt, 03047 const gavl_rectangle_f_t * src_rect, 03048 const gavl_rectangle_i_t * dst_rect); 03049 03057 GAVL_PUBLIC 03058 void gavl_video_options_get_rectangles(const gavl_video_options_t * opt, 03059 gavl_rectangle_f_t * src_rect, 03060 gavl_rectangle_i_t * dst_rect); 03061 03068 GAVL_PUBLIC 03069 void gavl_video_options_set_quality(gavl_video_options_t * opt, int quality); 03070 03077 GAVL_PUBLIC 03078 int gavl_video_options_get_quality(const gavl_video_options_t * opt); 03079 03080 03087 GAVL_PUBLIC 03088 void gavl_video_options_set_conversion_flags(gavl_video_options_t * opt, 03089 int conversion_flags); 03090 03097 GAVL_PUBLIC 03098 int gavl_video_options_get_conversion_flags(const gavl_video_options_t * opt); 03099 03106 GAVL_PUBLIC 03107 void gavl_video_options_set_alpha_mode(gavl_video_options_t * opt, 03108 gavl_alpha_mode_t alpha_mode); 03109 03116 GAVL_PUBLIC gavl_alpha_mode_t 03117 gavl_video_options_get_alpha_mode(const gavl_video_options_t * opt); 03118 03119 03126 GAVL_PUBLIC 03127 void gavl_video_options_set_scale_mode(gavl_video_options_t * opt, 03128 gavl_scale_mode_t scale_mode); 03129 03136 GAVL_PUBLIC gavl_scale_mode_t 03137 gavl_video_options_get_scale_mode(const gavl_video_options_t * opt); 03138 03139 03146 GAVL_PUBLIC 03147 void gavl_video_options_set_scale_order(gavl_video_options_t * opt, 03148 int order); 03149 03156 GAVL_PUBLIC 03157 int gavl_video_options_get_scale_order(const gavl_video_options_t * opt); 03158 03159 03166 GAVL_PUBLIC 03167 void gavl_video_options_set_background_color(gavl_video_options_t * opt, 03168 const float * color); 03169 03176 GAVL_PUBLIC 03177 void gavl_video_options_get_background_color(const gavl_video_options_t * opt, 03178 float * color); 03179 03186 GAVL_PUBLIC 03187 void gavl_video_options_set_deinterlace_mode(gavl_video_options_t * opt, 03188 gavl_deinterlace_mode_t deinterlace_mode); 03189 03196 GAVL_PUBLIC gavl_deinterlace_mode_t 03197 gavl_video_options_get_deinterlace_mode(const gavl_video_options_t * opt); 03198 03205 GAVL_PUBLIC 03206 void gavl_video_options_set_deinterlace_drop_mode(gavl_video_options_t * opt, 03207 gavl_deinterlace_drop_mode_t deinterlace_drop_mode); 03208 03215 GAVL_PUBLIC gavl_deinterlace_drop_mode_t 03216 gavl_video_options_get_deinterlace_drop_mode(const gavl_video_options_t * opt); 03217 03226 GAVL_PUBLIC 03227 void gavl_video_options_set_downscale_filter(gavl_video_options_t * opt, 03228 gavl_downscale_filter_t f); 03229 03230 03239 GAVL_PUBLIC gavl_downscale_filter_t 03240 gavl_video_options_get_downscale_filter(const gavl_video_options_t * opt); 03241 03259 GAVL_PUBLIC 03260 void gavl_video_options_set_downscale_blur(gavl_video_options_t * opt, 03261 float f); 03262 03271 GAVL_PUBLIC 03272 float gavl_video_options_get_downscale_blur(const gavl_video_options_t * opt); 03273 03282 GAVL_PUBLIC 03283 void gavl_video_options_set_num_threads(gavl_video_options_t * opt, int n); 03284 03285 03294 GAVL_PUBLIC 03295 int gavl_video_options_get_num_threads(const gavl_video_options_t * opt); 03296 03306 GAVL_PUBLIC 03307 void gavl_video_options_set_run_func(gavl_video_options_t * opt, 03308 gavl_video_run_func func, 03309 void * client_data); 03310 03320 GAVL_PUBLIC 03321 gavl_video_run_func 03322 gavl_video_options_get_run_func(const gavl_video_options_t * opt, 03323 void ** client_data); 03324 03334 GAVL_PUBLIC 03335 void gavl_video_options_set_stop_func(gavl_video_options_t * opt, 03336 gavl_video_stop_func func, 03337 void * client_data); 03338 03348 GAVL_PUBLIC 03349 gavl_video_stop_func 03350 gavl_video_options_get_stop_func(const gavl_video_options_t * opt, 03351 void ** client_data); 03352 03353 03354 /*************************************************** 03355 * Create and destroy video converters 03356 ***************************************************/ 03357 03390 typedef struct gavl_video_converter_s gavl_video_converter_t; 03391 03397 GAVL_PUBLIC 03398 gavl_video_converter_t * gavl_video_converter_create(); 03399 03405 GAVL_PUBLIC 03406 void gavl_video_converter_destroy(gavl_video_converter_t*cnv); 03407 03408 /************************************************** 03409 * Get options. Change the options with the gavl_video_options_set_* 03410 * functions above 03411 **************************************************/ 03412 03421 GAVL_PUBLIC gavl_video_options_t * 03422 gavl_video_converter_get_options(gavl_video_converter_t*cnv); 03423 03424 03438 GAVL_PUBLIC 03439 int gavl_video_converter_init(gavl_video_converter_t* cnv, 03440 const gavl_video_format_t * input_format, 03441 const gavl_video_format_t * output_format); 03442 03455 GAVL_PUBLIC 03456 int gavl_video_converter_reinit(gavl_video_converter_t* cnv); 03457 03458 03459 /*************************************************** 03460 * Convert a frame 03461 ***************************************************/ 03462 03470 GAVL_PUBLIC 03471 void gavl_video_convert(gavl_video_converter_t * cnv, 03472 const gavl_video_frame_t * input_frame, 03473 gavl_video_frame_t * output_frame); 03474 03506 typedef struct gavl_video_scaler_s gavl_video_scaler_t; 03507 03513 GAVL_PUBLIC 03514 gavl_video_scaler_t * gavl_video_scaler_create(); 03515 03521 GAVL_PUBLIC 03522 void gavl_video_scaler_destroy(gavl_video_scaler_t * scaler); 03523 03532 GAVL_PUBLIC gavl_video_options_t * 03533 gavl_video_scaler_get_options(gavl_video_scaler_t * scaler); 03534 03547 GAVL_PUBLIC 03548 int gavl_video_scaler_init(gavl_video_scaler_t * scaler, 03549 const gavl_video_format_t * src_format, 03550 const gavl_video_format_t * dst_format); 03551 03573 GAVL_PUBLIC 03574 int gavl_video_scaler_init_convolve(gavl_video_scaler_t * scaler, 03575 const gavl_video_format_t * format, 03576 int h_radius, const float * h_coeffs, 03577 int v_radius, const float * v_coeffs); 03578 03586 GAVL_PUBLIC 03587 void gavl_video_scaler_scale(gavl_video_scaler_t * scaler, 03588 const gavl_video_frame_t * input_frame, 03589 gavl_video_frame_t * output_frame); 03590 03606 typedef struct gavl_video_deinterlacer_s gavl_video_deinterlacer_t; 03607 03613 GAVL_PUBLIC 03614 gavl_video_deinterlacer_t * gavl_video_deinterlacer_create(); 03615 03621 GAVL_PUBLIC 03622 void gavl_video_deinterlacer_destroy(gavl_video_deinterlacer_t * deinterlacer); 03623 03632 GAVL_PUBLIC gavl_video_options_t * 03633 gavl_video_deinterlacer_get_options(gavl_video_deinterlacer_t * deinterlacer); 03634 03645 GAVL_PUBLIC 03646 int gavl_video_deinterlacer_init(gavl_video_deinterlacer_t * deinterlacer, 03647 const gavl_video_format_t * src_format); 03648 03649 03657 GAVL_PUBLIC 03658 void gavl_video_deinterlacer_deinterlace(gavl_video_deinterlacer_t * deinterlacer, 03659 const gavl_video_frame_t * input_frame, 03660 gavl_video_frame_t * output_frame); 03661 03662 03663 03664 /************************************************** 03665 * Transparent overlays 03666 **************************************************/ 03667 03668 /* Overlay struct */ 03669 03697 typedef gavl_video_frame_t gavl_overlay_t; 03698 03705 typedef struct gavl_overlay_blend_context_s gavl_overlay_blend_context_t; 03706 03712 GAVL_PUBLIC 03713 gavl_overlay_blend_context_t * gavl_overlay_blend_context_create(); 03714 03720 GAVL_PUBLIC 03721 void gavl_overlay_blend_context_destroy(gavl_overlay_blend_context_t * ctx); 03722 03729 GAVL_PUBLIC gavl_video_options_t * 03730 gavl_overlay_blend_context_get_options(gavl_overlay_blend_context_t * ctx); 03731 03747 GAVL_PUBLIC 03748 int gavl_overlay_blend_context_init(gavl_overlay_blend_context_t * ctx, 03749 const gavl_video_format_t * frame_format, 03750 gavl_video_format_t * overlay_format); 03751 03761 GAVL_PUBLIC 03762 void gavl_overlay_blend_context_set_overlay(gavl_overlay_blend_context_t * ctx, 03763 gavl_overlay_t * ovl); 03764 03771 GAVL_PUBLIC 03772 void gavl_overlay_blend(gavl_overlay_blend_context_t * ctx, 03773 gavl_video_frame_t * dst_frame); 03774 03781 GAVL_PUBLIC gavl_video_sink_t * 03782 gavl_overlay_blend_context_get_sink(gavl_overlay_blend_context_t * ctx); 03783 03805 typedef struct gavl_image_transform_s gavl_image_transform_t; 03806 03820 typedef void (*gavl_image_transform_func)(void * priv, 03821 double xdst, 03822 double ydst, 03823 double * xsrc, 03824 double * ysrc); 03825 03826 03833 GAVL_PUBLIC 03834 gavl_image_transform_t * gavl_image_transform_create(); 03835 03841 GAVL_PUBLIC 03842 void gavl_image_transform_destroy(gavl_image_transform_t * t); 03843 03862 GAVL_PUBLIC 03863 int gavl_image_transform_init(gavl_image_transform_t * t, 03864 gavl_video_format_t * format, 03865 gavl_image_transform_func func, void * priv); 03866 03874 GAVL_PUBLIC 03875 void gavl_image_transform_transform(gavl_image_transform_t * t, 03876 gavl_video_frame_t * in_frame, 03877 gavl_video_frame_t * out_frame); 03878 03889 GAVL_PUBLIC gavl_video_options_t * 03890 gavl_image_transform_get_options(gavl_image_transform_t * t); 03891 03914 typedef struct 03915 { 03916 int64_t offset; 03917 /* Primary */ 03918 int64_t num_entries; 03919 int64_t entries_alloc; 03920 03921 struct 03922 { 03923 int64_t num_frames; 03924 int64_t duration; 03925 } * entries; 03926 03927 int num_timecodes; 03928 int timecodes_alloc; 03929 03930 struct 03931 { 03932 int64_t pts; 03933 gavl_timecode_t tc; 03934 } * timecodes; 03935 03936 /* Secondary */ 03937 03938 } gavl_frame_table_t; 03939 03945 GAVL_PUBLIC gavl_frame_table_t * gavl_frame_table_create(); 03946 03957 GAVL_PUBLIC gavl_frame_table_t * 03958 gavl_frame_table_create_audio(int samplerate, int64_t offset, int64_t duration, 03959 gavl_timecode_format_t * fmt_ret); 03960 03971 GAVL_PUBLIC gavl_frame_table_t * 03972 gavl_frame_table_create_cfr(int64_t offset, int64_t frame_duration, 03973 int64_t num_frames, 03974 gavl_timecode_t start_timecode); 03975 03983 GAVL_PUBLIC gavl_frame_table_t * 03984 gavl_frame_table_copy(const gavl_frame_table_t * tab); 03985 03986 03987 03994 GAVL_PUBLIC void gavl_frame_table_destroy(gavl_frame_table_t * t); 03995 04003 GAVL_PUBLIC void gavl_frame_table_append_entry(gavl_frame_table_t * t, int64_t duration); 04004 04013 GAVL_PUBLIC void 04014 gavl_frame_table_append_timecode(gavl_frame_table_t * t, 04015 int64_t pts, gavl_timecode_t tc); 04016 04027 GAVL_PUBLIC int64_t 04028 gavl_frame_table_frame_to_time(const gavl_frame_table_t * t, 04029 int64_t frame, int * duration); 04030 04041 GAVL_PUBLIC int64_t 04042 gavl_frame_table_time_to_frame(const gavl_frame_table_t * t, 04043 int64_t time, 04044 int64_t * start_time); 04045 04056 GAVL_PUBLIC gavl_timecode_t 04057 gavl_frame_table_time_to_timecode(const gavl_frame_table_t * t, 04058 int64_t time, 04059 int64_t * start_time, 04060 const gavl_timecode_format_t * fmt); 04061 04071 GAVL_PUBLIC int64_t 04072 gavl_frame_table_timecode_to_time(const gavl_frame_table_t * t, 04073 gavl_timecode_t tc, 04074 const gavl_timecode_format_t * fmt); 04075 04076 04087 GAVL_PUBLIC gavl_timecode_t 04088 gavl_frame_table_frame_to_timecode(const gavl_frame_table_t * t, 04089 int64_t frame, 04090 int64_t * start_time, 04091 const gavl_timecode_format_t * fmt); 04092 04093 04094 04102 GAVL_PUBLIC int64_t 04103 gavl_frame_table_num_frames(const gavl_frame_table_t * t); 04104 04112 GAVL_PUBLIC int64_t 04113 gavl_frame_table_duration(const gavl_frame_table_t * t); 04114 04122 GAVL_PUBLIC int64_t 04123 gavl_frame_table_end_time(const gavl_frame_table_t * t); 04124 04133 GAVL_PUBLIC 04134 int gavl_frame_table_save(const gavl_frame_table_t * t, 04135 const char * filename); 04136 04144 GAVL_PUBLIC 04145 gavl_frame_table_t * gavl_frame_table_load(const char * filename); 04146 04153 GAVL_PUBLIC void 04154 gavl_frame_table_dump(const gavl_frame_table_t * t); 04155 04183 typedef struct gavl_video_frame_pool_s gavl_video_frame_pool_t; 04184 04191 GAVL_PUBLIC 04192 gavl_video_frame_pool_t * 04193 gavl_video_frame_pool_create(gavl_video_frame_t * (*create_frame)(void * priv), 04194 void * priv); 04195 04201 GAVL_PUBLIC 04202 gavl_video_frame_t * gavl_video_frame_pool_get(gavl_video_frame_pool_t *p); 04203 04211 GAVL_PUBLIC 04212 void gavl_video_frame_pool_destroy(gavl_video_frame_pool_t *p); 04213 04221 GAVL_PUBLIC 04222 void gavl_video_frame_pool_reset(gavl_video_frame_pool_t *p); 04223 04229 #ifdef __cplusplus 04230 } 04231 #endif 04232 04233 #endif /* GAVL_H_INCLUDED */