00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038
00039 #include <gavl/timecode.h>
00040
00041
00064 typedef void (*gavl_video_process_func)(void * data, int start, int end);
00065
00079 typedef void (*gavl_video_run_func)(gavl_video_process_func func,
00080 void * gavl_data,
00081 int start, int end,
00082 void * client_data, int thread);
00083
00092 typedef void (*gavl_video_stop_func)(void * client_data, int thread);
00093
00102 typedef struct gavl_video_format_s gavl_video_format_t;
00103
00104
00105
00106
00130 #define GAVL_QUALITY_FASTEST 1
00131
00138 #define GAVL_QUALITY_BEST 5
00139
00146 #define GAVL_QUALITY_DEFAULT 2
00147
00159 #define GAVL_ACCEL_MMX (1<<0) //!< MMX
00160 #define GAVL_ACCEL_MMXEXT (1<<1) //!< Extended MMX (a.k.a MMX2)
00161 #define GAVL_ACCEL_SSE (1<<2) //!< Intel SSE
00162 #define GAVL_ACCEL_SSE2 (1<<3) //!< Intel SSE2
00163 #define GAVL_ACCEL_SSE3 (1<<4) //!< Intel SSE3
00164 #define GAVL_ACCEL_3DNOW (1<<5) //!< AMD 3Dnow
00165 #define GAVL_ACCEL_3DNOWEXT (1<<6) //!< AMD 3Dnow ext
00166 #define GAVL_ACCEL_SSSE3 (1<<7) //!< Intel SSSE3
00167
00172 GAVL_PUBLIC int gavl_accel_supported();
00173
00182
00183
00196 #define GAVL_MAX_CHANNELS 128
00197
00204 typedef enum
00205 {
00206 GAVL_SAMPLE_NONE = 0,
00207 GAVL_SAMPLE_U8 = 1,
00208 GAVL_SAMPLE_S8 = 2,
00209 GAVL_SAMPLE_U16 = 3,
00210 GAVL_SAMPLE_S16 = 4,
00211 GAVL_SAMPLE_S32 = 5,
00212 GAVL_SAMPLE_FLOAT = 6,
00213 GAVL_SAMPLE_DOUBLE = 7
00214 } gavl_sample_format_t;
00215
00221 typedef enum
00222 {
00223 GAVL_INTERLEAVE_NONE = 0,
00224 GAVL_INTERLEAVE_2 = 1,
00225 GAVL_INTERLEAVE_ALL = 2
00226 } gavl_interleave_mode_t;
00227
00235 typedef enum
00236 {
00237 GAVL_CHID_NONE = 0,
00238 GAVL_CHID_FRONT_CENTER,
00239 GAVL_CHID_FRONT_LEFT,
00240 GAVL_CHID_FRONT_RIGHT,
00241 GAVL_CHID_FRONT_CENTER_LEFT,
00242 GAVL_CHID_FRONT_CENTER_RIGHT,
00243 GAVL_CHID_REAR_LEFT,
00244 GAVL_CHID_REAR_RIGHT,
00245 GAVL_CHID_REAR_CENTER,
00246 GAVL_CHID_SIDE_LEFT,
00247 GAVL_CHID_SIDE_RIGHT,
00248 GAVL_CHID_LFE,
00249 GAVL_CHID_AUX,
00250 } gavl_channel_id_t;
00251
00260 typedef struct
00261 {
00262 int samples_per_frame;
00263 int samplerate;
00264 int num_channels;
00265 gavl_sample_format_t sample_format;
00266 gavl_interleave_mode_t interleave_mode;
00268 float center_level;
00269 float rear_level;
00271 gavl_channel_id_t channel_locations[GAVL_MAX_CHANNELS];
00273 } gavl_audio_format_t;
00274
00275
00276
00277
00285 GAVL_PUBLIC
00286 const char * gavl_sample_format_to_string(gavl_sample_format_t format);
00287
00296 GAVL_PUBLIC
00297 gavl_sample_format_t gavl_string_to_sample_format(const char * str);
00298
00304 GAVL_PUBLIC
00305 int gavl_num_sample_formats();
00306
00313 GAVL_PUBLIC
00314 gavl_sample_format_t gavl_get_sample_format(int index);
00315
00322 GAVL_PUBLIC
00323 const char * gavl_channel_id_to_string(gavl_channel_id_t id);
00324
00325
00332 GAVL_PUBLIC
00333 const char * gavl_interleave_mode_to_string(gavl_interleave_mode_t mode);
00334
00341 GAVL_PUBLIC
00342 void gavl_audio_format_dump(const gavl_audio_format_t * format);
00343
00352 GAVL_PUBLIC
00353 int gavl_channel_index(const gavl_audio_format_t * format, gavl_channel_id_t id);
00354
00361 GAVL_PUBLIC
00362 int gavl_front_channels(const gavl_audio_format_t * format);
00363
00370 GAVL_PUBLIC
00371 int gavl_rear_channels(const gavl_audio_format_t * format);
00372
00379 GAVL_PUBLIC
00380 int gavl_side_channels(const gavl_audio_format_t * format);
00381
00388 GAVL_PUBLIC
00389 int gavl_aux_channels(const gavl_audio_format_t * format);
00390
00391
00392
00399 GAVL_PUBLIC
00400 int gavl_lfe_channels(const gavl_audio_format_t * format);
00401
00409 GAVL_PUBLIC
00410 void gavl_audio_format_copy(gavl_audio_format_t * dst,
00411 const gavl_audio_format_t * src);
00412
00421 GAVL_PUBLIC
00422 int gavl_audio_formats_equal(const gavl_audio_format_t * format_1,
00423 const gavl_audio_format_t * format_2);
00424
00436 GAVL_PUBLIC
00437 void gavl_set_channel_setup(gavl_audio_format_t * format);
00438
00445 GAVL_PUBLIC
00446 int gavl_bytes_per_sample(gavl_sample_format_t format);
00447
00462 typedef union
00463 {
00464 uint8_t * u_8;
00465 int8_t * s_8;
00467 uint16_t * u_16;
00468 int16_t * s_16;
00470 uint32_t * u_32;
00471 int32_t * s_32;
00473 float * f;
00474 double * d;
00475 } gavl_audio_samples_t;
00476
00482 typedef union
00483 {
00484 uint8_t * u_8[GAVL_MAX_CHANNELS];
00485 int8_t * s_8[GAVL_MAX_CHANNELS];
00487 uint16_t * u_16[GAVL_MAX_CHANNELS];
00488 int16_t * s_16[GAVL_MAX_CHANNELS];
00490 uint32_t * u_32[GAVL_MAX_CHANNELS];
00491 int32_t * s_32[GAVL_MAX_CHANNELS];
00493 float * f[GAVL_MAX_CHANNELS];
00494 double * d[GAVL_MAX_CHANNELS];
00496 } gavl_audio_channels_t;
00497
00514 typedef struct
00515 {
00516 gavl_audio_samples_t samples;
00517 gavl_audio_channels_t channels;
00518 int valid_samples;
00519 int64_t timestamp;
00520 int channel_stride;
00521 } gavl_audio_frame_t;
00522
00534 GAVL_PUBLIC
00535 gavl_audio_frame_t * gavl_audio_frame_create(const gavl_audio_format_t* format);
00536
00548 GAVL_PUBLIC
00549 void gavl_audio_frame_null(gavl_audio_frame_t * frame);
00550
00560 GAVL_PUBLIC
00561 void gavl_audio_frame_destroy(gavl_audio_frame_t * frame);
00562
00572 GAVL_PUBLIC
00573 void gavl_audio_frame_mute(gavl_audio_frame_t * frame,
00574 const gavl_audio_format_t * format);
00575
00586 GAVL_PUBLIC
00587 void gavl_audio_frame_mute_samples(gavl_audio_frame_t * frame,
00588 const gavl_audio_format_t * format,
00589 int num_samples);
00590
00591
00592
00603 GAVL_PUBLIC
00604 void gavl_audio_frame_mute_channel(gavl_audio_frame_t * frame,
00605 const gavl_audio_format_t * format,
00606 int channel);
00607
00628 GAVL_PUBLIC
00629 int gavl_audio_frame_copy(const gavl_audio_format_t * format,
00630 gavl_audio_frame_t * dst,
00631 const gavl_audio_frame_t * src,
00632 int dst_pos,
00633 int src_pos,
00634 int dst_size,
00635 int src_size);
00636
00649 GAVL_PUBLIC
00650 void gavl_audio_frame_copy_ptrs(const gavl_audio_format_t * format,
00651 gavl_audio_frame_t * dst,
00652 const gavl_audio_frame_t * src);
00653
00671 GAVL_PUBLIC
00672 void gavl_audio_frame_get_subframe(const gavl_audio_format_t * format,
00673 gavl_audio_frame_t * src,
00674 gavl_audio_frame_t * dst,
00675 int start, int len);
00676
00689 GAVL_PUBLIC
00690 int gavl_audio_frames_equal(const gavl_audio_format_t * format,
00691 const gavl_audio_frame_t * f1,
00692 const gavl_audio_frame_t * f2);
00693
00713 GAVL_PUBLIC
00714 int gavl_audio_frame_plot(const gavl_audio_format_t * format,
00715 const gavl_audio_frame_t * frame,
00716 const char * name_base);
00717
00718
00733 #define GAVL_AUDIO_FRONT_TO_REAR_COPY (1<<0)
00738 #define GAVL_AUDIO_FRONT_TO_REAR_MUTE (1<<1)
00743 #define GAVL_AUDIO_FRONT_TO_REAR_DIFF (1<<2)
00748 #define GAVL_AUDIO_FRONT_TO_REAR_MASK \
00749 (GAVL_AUDIO_FRONT_TO_REAR_COPY | \
00750 GAVL_AUDIO_FRONT_TO_REAR_MUTE | \
00751 GAVL_AUDIO_FRONT_TO_REAR_DIFF)
00753
00754
00757 #define GAVL_AUDIO_STEREO_TO_MONO_LEFT (1<<3)
00760 #define GAVL_AUDIO_STEREO_TO_MONO_RIGHT (1<<4)
00763 #define GAVL_AUDIO_STEREO_TO_MONO_MIX (1<<5)
00767 #define GAVL_AUDIO_STEREO_TO_MONO_MASK \
00768 (GAVL_AUDIO_STEREO_TO_MONO_LEFT | \
00769 GAVL_AUDIO_STEREO_TO_MONO_RIGHT | \
00770 GAVL_AUDIO_STEREO_TO_MONO_MIX)
00775 #define GAVL_AUDIO_NORMALIZE_MIX_MATRIX (1<<6)
00782 typedef enum
00783 {
00784 GAVL_AUDIO_DITHER_NONE = 0,
00785 GAVL_AUDIO_DITHER_AUTO = 1,
00786 GAVL_AUDIO_DITHER_RECT = 2,
00787 GAVL_AUDIO_DITHER_TRI = 3,
00788 GAVL_AUDIO_DITHER_SHAPED = 4,
00789 } gavl_audio_dither_mode_t;
00790
00795 typedef enum
00796 {
00797 GAVL_RESAMPLE_AUTO = 0,
00798 GAVL_RESAMPLE_ZOH = 1,
00799 GAVL_RESAMPLE_LINEAR = 2,
00800 GAVL_RESAMPLE_SINC_FAST = 3,
00801 GAVL_RESAMPLE_SINC_MEDIUM = 4,
00802 GAVL_RESAMPLE_SINC_BEST = 5
00803 } gavl_resample_mode_t;
00804
00811 typedef struct gavl_audio_options_s gavl_audio_options_t;
00812
00819 GAVL_PUBLIC
00820 void gavl_audio_options_set_quality(gavl_audio_options_t * opt, int quality);
00821
00828 GAVL_PUBLIC
00829 int gavl_audio_options_get_quality(gavl_audio_options_t * opt);
00830
00837 GAVL_PUBLIC
00838 void gavl_audio_options_set_dither_mode(gavl_audio_options_t * opt, gavl_audio_dither_mode_t mode);
00839
00846 GAVL_PUBLIC
00847 gavl_audio_dither_mode_t gavl_audio_options_get_dither_mode(gavl_audio_options_t * opt);
00848
00849
00856 GAVL_PUBLIC
00857 void gavl_audio_options_set_resample_mode(gavl_audio_options_t * opt, gavl_resample_mode_t mode);
00858
00865 GAVL_PUBLIC
00866 gavl_resample_mode_t gavl_audio_options_get_resample_mode(gavl_audio_options_t * opt);
00867
00874 GAVL_PUBLIC
00875 void gavl_audio_options_set_conversion_flags(gavl_audio_options_t * opt,
00876 int flags);
00877
00884 GAVL_PUBLIC
00885 int gavl_audio_options_get_conversion_flags(gavl_audio_options_t * opt);
00886
00892 GAVL_PUBLIC
00893 void gavl_audio_options_set_defaults(gavl_audio_options_t * opt);
00894
00911 GAVL_PUBLIC
00912 void gavl_audio_options_set_mix_matrix(gavl_audio_options_t * opt,
00913 const double ** matrix);
00914
00923 GAVL_PUBLIC
00924 const double ** gavl_audio_options_get_mix_matrix(gavl_audio_options_t * opt);
00925
00935 GAVL_PUBLIC
00936 gavl_audio_options_t * gavl_audio_options_create();
00937
00944 GAVL_PUBLIC
00945 void gavl_audio_options_copy(gavl_audio_options_t * dst,
00946 const gavl_audio_options_t * src);
00947
00953 GAVL_PUBLIC
00954 void gavl_audio_options_destroy(gavl_audio_options_t * opt);
00955
00956
00957
00958
00959
00993 typedef struct gavl_audio_converter_s gavl_audio_converter_t;
00994
01000 GAVL_PUBLIC
01001 gavl_audio_converter_t * gavl_audio_converter_create();
01002
01008 GAVL_PUBLIC
01009 void gavl_audio_converter_destroy(gavl_audio_converter_t* cnv);
01010
01019 GAVL_PUBLIC
01020 gavl_audio_options_t * gavl_audio_converter_get_options(gavl_audio_converter_t*cnv);
01021
01022
01037 GAVL_PUBLIC
01038 int gavl_audio_converter_init(gavl_audio_converter_t* cnv,
01039 const gavl_audio_format_t * input_format,
01040 const gavl_audio_format_t * output_format);
01041
01056 GAVL_PUBLIC
01057 int gavl_audio_converter_init_resample(gavl_audio_converter_t * cnv,
01058 const gavl_audio_format_t * format);
01059
01074 GAVL_PUBLIC
01075 int gavl_audio_converter_reinit(gavl_audio_converter_t* cnv);
01076
01077
01091 GAVL_PUBLIC
01092 void gavl_audio_convert(gavl_audio_converter_t * cnv,
01093 const gavl_audio_frame_t * input_frame,
01094 gavl_audio_frame_t * output_frame);
01095
01096
01115 GAVL_PUBLIC
01116 int gavl_audio_converter_set_resample_ratio(gavl_audio_converter_t * cnv,
01117 double ratio ) ;
01118
01119
01135 GAVL_PUBLIC
01136 void gavl_audio_converter_resample(gavl_audio_converter_t * cnv,
01137 gavl_audio_frame_t * input_frame,
01138 gavl_audio_frame_t * output_frame,
01139 double ratio);
01140
01141
01155 typedef struct gavl_volume_control_s gavl_volume_control_t;
01156
01157
01158
01164 GAVL_PUBLIC
01165 gavl_volume_control_t * gavl_volume_control_create();
01166
01172 GAVL_PUBLIC
01173 void gavl_volume_control_destroy(gavl_volume_control_t *ctrl);
01174
01182 GAVL_PUBLIC
01183 void gavl_volume_control_set_format(gavl_volume_control_t *ctrl,
01184 const gavl_audio_format_t * format);
01185
01192 GAVL_PUBLIC
01193 void gavl_volume_control_set_volume(gavl_volume_control_t * ctrl,
01194 float volume);
01195
01202 GAVL_PUBLIC
01203 void gavl_volume_control_apply(gavl_volume_control_t *ctrl,
01204 gavl_audio_frame_t * frame);
01205
01221 typedef struct gavl_peak_detector_s gavl_peak_detector_t;
01222
01223
01224
01230 GAVL_PUBLIC
01231 gavl_peak_detector_t * gavl_peak_detector_create();
01232
01238 GAVL_PUBLIC
01239 void gavl_peak_detector_destroy(gavl_peak_detector_t *pd);
01240
01250 GAVL_PUBLIC
01251 void gavl_peak_detector_set_format(gavl_peak_detector_t *pd,
01252 const gavl_audio_format_t * format);
01253
01260 GAVL_PUBLIC
01261 void gavl_peak_detector_update(gavl_peak_detector_t *pd,
01262 gavl_audio_frame_t * frame);
01263
01276 GAVL_PUBLIC
01277 void gavl_peak_detector_get_peak(gavl_peak_detector_t * pd,
01278 double * min, double * max,
01279 double * abs);
01280
01293 GAVL_PUBLIC
01294 void gavl_peak_detector_get_peaks(gavl_peak_detector_t * pd,
01295 double * min, double * max,
01296 double * abs);
01297
01303 GAVL_PUBLIC
01304 void gavl_peak_detector_reset(gavl_peak_detector_t * pd);
01305
01315 #define GAVL_MAX_PLANES 4
01327 typedef struct
01328 {
01329 int x;
01330 int y;
01331 int w;
01332 int h;
01333 } gavl_rectangle_i_t;
01334
01339 typedef struct
01340 {
01341 double x;
01342 double y;
01343 double w;
01344 double h;
01345 } gavl_rectangle_f_t;
01346
01353 GAVL_PUBLIC
01354 void gavl_rectangle_i_crop_to_format(gavl_rectangle_i_t * r,
01355 const gavl_video_format_t * format);
01356
01363 GAVL_PUBLIC
01364 void gavl_rectangle_f_crop_to_format(gavl_rectangle_f_t * r,
01365 const gavl_video_format_t * format);
01366
01381 GAVL_PUBLIC
01382 void gavl_rectangle_crop_to_format_noscale(gavl_rectangle_i_t * src_rect,
01383 gavl_rectangle_i_t * dst_rect,
01384 const gavl_video_format_t * src_format,
01385 const gavl_video_format_t * dst_format);
01386
01398 GAVL_PUBLIC
01399 void gavl_rectangle_crop_to_format_scale(gavl_rectangle_f_t * src_rect,
01400 gavl_rectangle_i_t * dst_rect,
01401 const gavl_video_format_t * src_format,
01402 const gavl_video_format_t * dst_format);
01403
01404
01405
01412 GAVL_PUBLIC
01413 void gavl_rectangle_i_set_all(gavl_rectangle_i_t * r, const gavl_video_format_t * format);
01414
01421 GAVL_PUBLIC
01422 void gavl_rectangle_f_set_all(gavl_rectangle_f_t * r, const gavl_video_format_t * format);
01423
01430 GAVL_PUBLIC
01431 void gavl_rectangle_i_crop_left(gavl_rectangle_i_t * r, int num_pixels);
01432
01439 GAVL_PUBLIC
01440 void gavl_rectangle_i_crop_right(gavl_rectangle_i_t * r, int num_pixels);
01441
01448 GAVL_PUBLIC
01449 void gavl_rectangle_i_crop_top(gavl_rectangle_i_t * r, int num_pixels);
01450
01457 GAVL_PUBLIC
01458 void gavl_rectangle_i_crop_bottom(gavl_rectangle_i_t * r, int num_pixels);
01459
01466 GAVL_PUBLIC
01467 void gavl_rectangle_f_crop_left(gavl_rectangle_f_t * r, double num_pixels);
01468
01475 GAVL_PUBLIC
01476 void gavl_rectangle_f_crop_right(gavl_rectangle_f_t * r, double num_pixels);
01477
01484 GAVL_PUBLIC
01485 void gavl_rectangle_f_crop_top(gavl_rectangle_f_t * r, double num_pixels);
01486
01493 GAVL_PUBLIC
01494 void gavl_rectangle_f_crop_bottom(gavl_rectangle_f_t * r, double num_pixels);
01495
01509 GAVL_PUBLIC
01510 void gavl_rectangle_i_align(gavl_rectangle_i_t * r, int h_align, int v_align);
01511
01521 GAVL_PUBLIC
01522 void gavl_rectangle_i_align_to_format(gavl_rectangle_i_t * r,
01523 const gavl_video_format_t * format);
01524
01525
01532 GAVL_PUBLIC
01533 void gavl_rectangle_i_copy(gavl_rectangle_i_t * dst, const gavl_rectangle_i_t * src);
01534
01541 GAVL_PUBLIC
01542 void gavl_rectangle_f_copy(gavl_rectangle_f_t * dst, const gavl_rectangle_f_t * src);
01543
01544
01545
01552 GAVL_PUBLIC
01553 void gavl_rectangle_i_to_f(gavl_rectangle_f_t * dst, const gavl_rectangle_i_t * src);
01554
01561 GAVL_PUBLIC
01562 void gavl_rectangle_f_to_i(gavl_rectangle_i_t * dst, const gavl_rectangle_f_t * src);
01563
01572 GAVL_PUBLIC
01573 int gavl_rectangle_i_is_empty(const gavl_rectangle_i_t * r);
01574
01583 GAVL_PUBLIC
01584 int gavl_rectangle_f_is_empty(const gavl_rectangle_f_t * r);
01585
01613 GAVL_PUBLIC
01614 void gavl_rectangle_fit_aspect(gavl_rectangle_i_t * dst_rect,
01615 const gavl_video_format_t * src_format,
01616 const gavl_rectangle_f_t * src_rect,
01617 const gavl_video_format_t * dst_format,
01618 float zoom, float squeeze);
01619
01624 GAVL_PUBLIC
01625 void gavl_rectangle_i_dump(const gavl_rectangle_i_t * r);
01626
01631 GAVL_PUBLIC
01632 void gavl_rectangle_f_dump(const gavl_rectangle_f_t * r);
01633
01634
01644 #define GAVL_PIXFMT_PLANAR (1<<8)
01645
01649 #define GAVL_PIXFMT_RGB (1<<9)
01650
01654 #define GAVL_PIXFMT_YUV (1<<10)
01655
01659 #define GAVL_PIXFMT_YUVJ (1<<11)
01660
01664 #define GAVL_PIXFMT_ALPHA (1<<12)
01665
01669 #define GAVL_PIXFMT_GRAY (1<<13)
01670
01675 typedef enum
01676 {
01679 GAVL_PIXELFORMAT_NONE = 0,
01680
01683 GAVL_GRAY_8 = 1 | GAVL_PIXFMT_GRAY,
01684
01687 GAVL_GRAY_16 = 2 | GAVL_PIXFMT_GRAY,
01688
01691 GAVL_GRAY_FLOAT = 3 | GAVL_PIXFMT_GRAY,
01692
01695 GAVL_GRAYA_16 = 1 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
01696
01699 GAVL_GRAYA_32 = 2 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
01700
01703 GAVL_GRAYA_FLOAT = 3 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
01704
01708 GAVL_RGB_15 = 1 | GAVL_PIXFMT_RGB,
01712 GAVL_BGR_15 = 2 | GAVL_PIXFMT_RGB,
01716 GAVL_RGB_16 = 3 | GAVL_PIXFMT_RGB,
01720 GAVL_BGR_16 = 4 | GAVL_PIXFMT_RGB,
01723 GAVL_RGB_24 = 5 | GAVL_PIXFMT_RGB,
01726 GAVL_BGR_24 = 6 | GAVL_PIXFMT_RGB,
01729 GAVL_RGB_32 = 7 | GAVL_PIXFMT_RGB,
01732 GAVL_BGR_32 = 8 | GAVL_PIXFMT_RGB,
01735 GAVL_RGBA_32 = 9 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA,
01736
01739 GAVL_RGB_48 = 10 | GAVL_PIXFMT_RGB,
01742 GAVL_RGBA_64 = 11 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA,
01743
01746 GAVL_RGB_FLOAT = 12 | GAVL_PIXFMT_RGB,
01749 GAVL_RGBA_FLOAT = 13 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA,
01750
01753 GAVL_YUY2 = 1 | GAVL_PIXFMT_YUV,
01756 GAVL_UYVY = 2 | GAVL_PIXFMT_YUV,
01759 GAVL_YUVA_32 = 3 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
01762 GAVL_YUVA_64 = 4 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
01765 GAVL_YUV_FLOAT = 5 | GAVL_PIXFMT_YUV,
01766
01769 GAVL_YUVA_FLOAT = 6 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
01770
01774 GAVL_YUV_420_P = 1 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01777 GAVL_YUV_422_P = 2 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01780 GAVL_YUV_444_P = 3 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01783 GAVL_YUV_411_P = 4 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01786 GAVL_YUV_410_P = 5 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01787
01790 GAVL_YUVJ_420_P = 6 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
01793 GAVL_YUVJ_422_P = 7 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
01796 GAVL_YUVJ_444_P = 8 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
01797
01800 GAVL_YUV_444_P_16 = 9 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01803 GAVL_YUV_422_P_16 = 10 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01804
01805 } gavl_pixelformat_t;
01806
01809 #define GAVL_PIXELFORMAT_1D_8 GAVL_GRAY_8
01810
01812 #define GAVL_PIXELFORMAT_2D_8 GAVL_GRAYA_16
01813
01815 #define GAVL_PIXELFORMAT_3D_8 GAVL_RGB_24
01816
01818 #define GAVL_PIXELFORMAT_4D_8 GAVL_RGBA_32
01819
01822 #define GAVL_PIXELFORMAT_1D_16 GAVL_GRAY_16
01823
01825 #define GAVL_PIXELFORMAT_2D_16 GAVL_GRAYA_32
01826
01828 #define GAVL_PIXELFORMAT_3D_16 GAVL_RGB_48
01829
01831 #define GAVL_PIXELFORMAT_4D_16 GAVL_RGBA_64
01832
01835 #define GAVL_PIXELFORMAT_1D_FLOAT GAVL_GRAY_FLOAT
01836
01838 #define GAVL_PIXELFORMAT_2D_FLOAT GAVL_GRAYA_FLOAT
01839
01841 #define GAVL_PIXELFORMAT_3D_FLOAT GAVL_RGB_FLOAT
01842
01844 #define GAVL_PIXELFORMAT_4D_FLOAT GAVL_RGBA_FLOAT
01845
01852 typedef enum
01853 {
01854 GAVL_CCH_RED,
01855 GAVL_CCH_GREEN,
01856 GAVL_CCH_BLUE,
01857 GAVL_CCH_Y,
01858 GAVL_CCH_CB,
01859 GAVL_CCH_CR,
01860 GAVL_CCH_ALPHA,
01861 } gavl_color_channel_t;
01862
01863
01864
01865
01866
01873 #define gavl_pixelformat_is_gray(fmt) ((fmt) & GAVL_PIXFMT_GRAY)
01874
01875
01882 #define gavl_pixelformat_is_rgb(fmt) ((fmt) & GAVL_PIXFMT_RGB)
01883
01890 #define gavl_pixelformat_is_yuv(fmt) ((fmt) & GAVL_PIXFMT_YUV)
01891
01898 #define gavl_pixelformat_is_jpeg_scaled(fmt) ((fmt) & GAVL_PIXFMT_YUVJ)
01899
01906 #define gavl_pixelformat_has_alpha(fmt) ((fmt) & GAVL_PIXFMT_ALPHA)
01907
01914 #define gavl_pixelformat_is_planar(fmt) ((fmt) & GAVL_PIXFMT_PLANAR)
01915
01922 GAVL_PUBLIC
01923 int gavl_pixelformat_num_planes(gavl_pixelformat_t pixelformat);
01924
01934 GAVL_PUBLIC
01935 void gavl_pixelformat_chroma_sub(gavl_pixelformat_t pixelformat, int * sub_h, int * sub_v);
01936
01943 GAVL_PUBLIC
01944 int gavl_pixelformat_bytes_per_component(gavl_pixelformat_t pixelformat);
01945
01952 GAVL_PUBLIC
01953 int gavl_pixelformat_bytes_per_pixel(gavl_pixelformat_t pixelformat);
01954
01961 GAVL_PUBLIC
01962 int gavl_pixelformat_bits_per_pixel(gavl_pixelformat_t pixelformat);
01963
01978 GAVL_PUBLIC
01979 int gavl_pixelformat_conversion_penalty(gavl_pixelformat_t src,
01980 gavl_pixelformat_t dst);
01981
01995 GAVL_PUBLIC gavl_pixelformat_t
01996 gavl_pixelformat_get_best(gavl_pixelformat_t src,
01997 const gavl_pixelformat_t * dst_supported,
01998 int * penalty);
01999
02000
02001
02008 GAVL_PUBLIC
02009 const char * gavl_pixelformat_to_string(gavl_pixelformat_t pixelformat);
02010
02017 GAVL_PUBLIC
02018 gavl_pixelformat_t gavl_string_to_pixelformat(const char * name);
02019
02025 GAVL_PUBLIC
02026 int gavl_num_pixelformats();
02027
02034 GAVL_PUBLIC
02035 gavl_pixelformat_t gavl_get_pixelformat(int index);
02036
02037
02038
02047 typedef enum
02048 {
02049 GAVL_CHROMA_PLACEMENT_DEFAULT = 0,
02050 GAVL_CHROMA_PLACEMENT_MPEG2,
02051 GAVL_CHROMA_PLACEMENT_DVPAL
02052 } gavl_chroma_placement_t;
02053
02060 GAVL_PUBLIC
02061 const char * gavl_chroma_placement_to_string(gavl_chroma_placement_t mode);
02062
02067
02068
02069 typedef enum
02070 {
02071 GAVL_FRAMERATE_UNKNOWN = -1,
02072 GAVL_FRAMERATE_CONSTANT = 0,
02073 GAVL_FRAMERATE_VARIABLE = 1,
02074 GAVL_FRAMERATE_STILL = 2,
02075 } gavl_framerate_mode_t;
02076
02083 GAVL_PUBLIC
02084 const char * gavl_framerate_mode_to_string(gavl_framerate_mode_t mode);
02085
02090
02091
02092 typedef enum
02093 {
02094 GAVL_INTERLACE_UNKNOWN = -1,
02095 GAVL_INTERLACE_NONE = 0,
02096 GAVL_INTERLACE_TOP_FIRST = 1,
02097 GAVL_INTERLACE_BOTTOM_FIRST = 2,
02098 GAVL_INTERLACE_MIXED = 3,
02099 GAVL_INTERLACE_MIXED_TOP = 4,
02100 GAVL_INTERLACE_MIXED_BOTTOM = 5,
02101 } gavl_interlace_mode_t;
02102
02109 GAVL_PUBLIC
02110 const char * gavl_interlace_mode_to_string(gavl_interlace_mode_t mode);
02111
02112
02113
02114
02119 struct gavl_video_format_s
02120 {
02121 int frame_width;
02122 int frame_height;
02124 int image_width;
02125 int image_height;
02127
02128
02129 int pixel_width;
02130 int pixel_height;
02132 gavl_pixelformat_t pixelformat;
02134 int frame_duration;
02136 int timescale;
02138 gavl_framerate_mode_t framerate_mode;
02139 gavl_chroma_placement_t chroma_placement;
02141 gavl_interlace_mode_t interlace_mode;
02143 gavl_timecode_format_t timecode_format;
02144 };
02145
02153 GAVL_PUBLIC
02154 void gavl_video_format_copy(gavl_video_format_t * dst,
02155 const gavl_video_format_t * src);
02156
02165 GAVL_PUBLIC
02166 int gavl_video_formats_equal(const gavl_video_format_t * format_1,
02167 const gavl_video_format_t * format_2);
02168
02169
02180 GAVL_PUBLIC
02181 void gavl_video_format_get_chroma_offset(const gavl_video_format_t * format, int field, int plane,
02182 float * off_x, float * off_y);
02183
02184
02185
02198 GAVL_PUBLIC
02199 void gavl_video_format_fit_to_source(gavl_video_format_t * dst,
02200 const gavl_video_format_t * src);
02201
02209 GAVL_PUBLIC
02210 int gavl_video_format_get_image_size(const gavl_video_format_t * format);
02211
02227 GAVL_PUBLIC
02228 int gavl_get_color_channel_format(const gavl_video_format_t * frame_format,
02229 gavl_video_format_t * channel_format,
02230 gavl_color_channel_t ch);
02231
02232
02246 GAVL_PUBLIC
02247 void gavl_get_field_format(const gavl_video_format_t * frame_format,
02248 gavl_video_format_t * field_format,
02249 int field);
02250
02251
02258 GAVL_PUBLIC
02259 void gavl_video_format_dump(const gavl_video_format_t * format);
02260
02261
02284 typedef struct
02285 {
02286 uint8_t * planes[GAVL_MAX_PLANES];
02287 int strides[GAVL_MAX_PLANES];
02289 void * user_data;
02290 int64_t timestamp;
02291 int64_t duration;
02292 gavl_interlace_mode_t interlace_mode;
02293 gavl_timecode_t timecode;
02294 } gavl_video_frame_t;
02295
02296
02308 GAVL_PUBLIC
02309 gavl_video_frame_t * gavl_video_frame_create(const gavl_video_format_t*format);
02310
02321 GAVL_PUBLIC
02322 gavl_video_frame_t * gavl_video_frame_create_nopad(const gavl_video_format_t*format);
02323
02324
02325
02335 GAVL_PUBLIC
02336 void gavl_video_frame_destroy(gavl_video_frame_t*frame);
02337
02349 GAVL_PUBLIC
02350 void gavl_video_frame_null(gavl_video_frame_t*frame);
02351
02360 GAVL_PUBLIC
02361 void gavl_video_frame_clear(gavl_video_frame_t * frame,
02362 const gavl_video_format_t * format);
02363
02373 GAVL_PUBLIC
02374 void gavl_video_frame_fill(gavl_video_frame_t * frame,
02375 const gavl_video_format_t * format,
02376 const float * color);
02377
02390 GAVL_PUBLIC
02391 void gavl_video_frame_absdiff(gavl_video_frame_t * dst,
02392 const gavl_video_frame_t * src1,
02393 const gavl_video_frame_t * src2,
02394 const gavl_video_format_t * format);
02395
02408 GAVL_PUBLIC
02409 void gavl_video_frame_psnr(double * psnr,
02410 const gavl_video_frame_t * src1,
02411 const gavl_video_frame_t * src2,
02412 const gavl_video_format_t * format);
02413
02440 GAVL_PUBLIC
02441 int gavl_video_frame_ssim(const gavl_video_frame_t * src1,
02442 const gavl_video_frame_t * src2,
02443 gavl_video_frame_t * dst,
02444 const gavl_video_format_t * format);
02445
02459 GAVL_PUBLIC
02460 void gavl_video_frame_copy(const gavl_video_format_t * format,
02461 gavl_video_frame_t * dst,
02462 const gavl_video_frame_t * src);
02463
02476 GAVL_PUBLIC
02477 void gavl_video_frame_copy_plane(const gavl_video_format_t * format,
02478 gavl_video_frame_t * dst,
02479 const gavl_video_frame_t * src, int plane);
02480
02492 GAVL_PUBLIC
02493 void gavl_video_frame_copy_flip_x(const gavl_video_format_t * format,
02494 gavl_video_frame_t * dst,
02495 const gavl_video_frame_t * src);
02496
02508 GAVL_PUBLIC
02509 void gavl_video_frame_copy_flip_y(const gavl_video_format_t * format,
02510 gavl_video_frame_t * dst,
02511 const gavl_video_frame_t * src);
02512
02524 GAVL_PUBLIC
02525 void gavl_video_frame_copy_flip_xy(const gavl_video_format_t * format,
02526 gavl_video_frame_t * dst,
02527 const gavl_video_frame_t * src);
02528
02541 GAVL_PUBLIC
02542 void gavl_video_frame_copy_metadata(gavl_video_frame_t * dst,
02543 const gavl_video_frame_t * src);
02544
02545
02563 GAVL_PUBLIC
02564 void gavl_video_frame_get_subframe(gavl_pixelformat_t pixelformat,
02565 const gavl_video_frame_t * src,
02566 gavl_video_frame_t * dst,
02567 gavl_rectangle_i_t * src_rect);
02568
02584 GAVL_PUBLIC
02585 void gavl_video_frame_get_field(gavl_pixelformat_t pixelformat,
02586 const gavl_video_frame_t * src,
02587 gavl_video_frame_t * dst,
02588 int field);
02589
02590
02591
02604 GAVL_PUBLIC
02605 void gavl_video_frame_dump(gavl_video_frame_t * frame,
02606 const gavl_video_format_t * format,
02607 const char * namebase);
02608
02619 GAVL_PUBLIC
02620 void gavl_video_frame_set_strides(gavl_video_frame_t * frame,
02621 const gavl_video_format_t * format);
02622
02635 GAVL_PUBLIC
02636 void gavl_video_frame_set_planes(gavl_video_frame_t * frame,
02637 const gavl_video_format_t * format,
02638 uint8_t * buffer);
02639
02654 GAVL_PUBLIC
02655 int gavl_video_frame_extract_channel(const gavl_video_format_t * format,
02656 gavl_color_channel_t ch,
02657 const gavl_video_frame_t * src,
02658 gavl_video_frame_t * dst);
02659
02675 GAVL_PUBLIC
02676 int gavl_video_frame_insert_channel(const gavl_video_format_t * format,
02677 gavl_color_channel_t ch,
02678 const gavl_video_frame_t * src,
02679 gavl_video_frame_t * dst);
02680
02681
02693 GAVL_PUBLIC
02694 int gavl_video_frames_equal(const gavl_video_format_t * format,
02695 const gavl_video_frame_t * f1,
02696 const gavl_video_frame_t * f2);
02697
02698
02699
02700
02701
02702
02718 #define GAVL_FORCE_DEINTERLACE (1<<0)
02719
02724 #define GAVL_CONVOLVE_CHROMA (1<<1)
02725
02730 #define GAVL_CONVOLVE_NORMALIZE (1<<2)
02731
02739 #define GAVL_RESAMPLE_CHROMA (1<<3)
02740
02748 typedef enum
02749 {
02750 GAVL_ALPHA_IGNORE = 0,
02751 GAVL_ALPHA_BLEND_COLOR
02752 } gavl_alpha_mode_t;
02753
02760 typedef enum
02761 {
02762 GAVL_DEINTERLACE_NONE = 0,
02763 GAVL_DEINTERLACE_COPY = 1,
02764 GAVL_DEINTERLACE_SCALE = 2,
02765 GAVL_DEINTERLACE_BLEND = 3
02766 } gavl_deinterlace_mode_t;
02767
02774 typedef enum
02775 {
02776 GAVL_DEINTERLACE_DROP_TOP,
02777 GAVL_DEINTERLACE_DROP_BOTTOM,
02778 } gavl_deinterlace_drop_mode_t;
02779
02784 typedef enum
02785 {
02786 GAVL_SCALE_AUTO,
02787 GAVL_SCALE_NEAREST,
02788 GAVL_SCALE_BILINEAR,
02789 GAVL_SCALE_QUADRATIC,
02790 GAVL_SCALE_CUBIC_BSPLINE,
02791 GAVL_SCALE_CUBIC_MITCHELL,
02792 GAVL_SCALE_CUBIC_CATMULL,
02793 GAVL_SCALE_SINC_LANCZOS,
02794 GAVL_SCALE_NONE,
02795 } gavl_scale_mode_t;
02796
02806 typedef enum
02807 {
02808 GAVL_DOWNSCALE_FILTER_AUTO = 0,
02809 GAVL_DOWNSCALE_FILTER_NONE,
02810 GAVL_DOWNSCALE_FILTER_WIDE,
02811 GAVL_DOWNSCALE_FILTER_GAUSS,
02812 } gavl_downscale_filter_t;
02813
02820 typedef struct gavl_video_options_s gavl_video_options_t;
02821
02822
02823
02829 GAVL_PUBLIC
02830 void gavl_video_options_set_defaults(gavl_video_options_t * opt);
02831
02841 GAVL_PUBLIC
02842 gavl_video_options_t * gavl_video_options_create();
02843
02850 GAVL_PUBLIC
02851 void gavl_video_options_copy(gavl_video_options_t * dst,
02852 const gavl_video_options_t * src);
02853
02859 GAVL_PUBLIC
02860 void gavl_video_options_destroy(gavl_video_options_t * opt);
02861
02862
02877 GAVL_PUBLIC
02878 void gavl_video_options_set_rectangles(gavl_video_options_t * opt,
02879 const gavl_rectangle_f_t * src_rect,
02880 const gavl_rectangle_i_t * dst_rect);
02881
02889 GAVL_PUBLIC
02890 void gavl_video_options_get_rectangles(gavl_video_options_t * opt,
02891 gavl_rectangle_f_t * src_rect,
02892 gavl_rectangle_i_t * dst_rect);
02893
02900 GAVL_PUBLIC
02901 void gavl_video_options_set_quality(gavl_video_options_t * opt, int quality);
02902
02909 GAVL_PUBLIC
02910 int gavl_video_options_get_quality(gavl_video_options_t * opt);
02911
02912
02919 GAVL_PUBLIC
02920 void gavl_video_options_set_conversion_flags(gavl_video_options_t * opt,
02921 int conversion_flags);
02922
02929 GAVL_PUBLIC
02930 int gavl_video_options_get_conversion_flags(gavl_video_options_t * opt);
02931
02938 GAVL_PUBLIC
02939 void gavl_video_options_set_alpha_mode(gavl_video_options_t * opt,
02940 gavl_alpha_mode_t alpha_mode);
02941
02948 GAVL_PUBLIC gavl_alpha_mode_t
02949 gavl_video_options_get_alpha_mode(gavl_video_options_t * opt);
02950
02951
02958 GAVL_PUBLIC
02959 void gavl_video_options_set_scale_mode(gavl_video_options_t * opt,
02960 gavl_scale_mode_t scale_mode);
02961
02968 GAVL_PUBLIC gavl_scale_mode_t
02969 gavl_video_options_get_scale_mode(gavl_video_options_t * opt);
02970
02971
02978 GAVL_PUBLIC
02979 void gavl_video_options_set_scale_order(gavl_video_options_t * opt,
02980 int order);
02981
02988 GAVL_PUBLIC
02989 int gavl_video_options_get_scale_order(gavl_video_options_t * opt);
02990
02991
02998 GAVL_PUBLIC
02999 void gavl_video_options_set_background_color(gavl_video_options_t * opt,
03000 const float * color);
03001
03008 GAVL_PUBLIC
03009 void gavl_video_options_get_background_color(gavl_video_options_t * opt,
03010 float * color);
03011
03018 GAVL_PUBLIC
03019 void gavl_video_options_set_deinterlace_mode(gavl_video_options_t * opt,
03020 gavl_deinterlace_mode_t deinterlace_mode);
03021
03028 GAVL_PUBLIC gavl_deinterlace_mode_t
03029 gavl_video_options_get_deinterlace_mode(gavl_video_options_t * opt);
03030
03037 GAVL_PUBLIC
03038 void gavl_video_options_set_deinterlace_drop_mode(gavl_video_options_t * opt,
03039 gavl_deinterlace_drop_mode_t deinterlace_drop_mode);
03040
03047 GAVL_PUBLIC gavl_deinterlace_drop_mode_t
03048 gavl_video_options_get_deinterlace_drop_mode(gavl_video_options_t * opt);
03049
03058 GAVL_PUBLIC
03059 void gavl_video_options_set_downscale_filter(gavl_video_options_t * opt,
03060 gavl_downscale_filter_t f);
03061
03062
03071 GAVL_PUBLIC gavl_downscale_filter_t
03072 gavl_video_options_get_downscale_filter(gavl_video_options_t * opt);
03073
03091 GAVL_PUBLIC
03092 void gavl_video_options_set_downscale_blur(gavl_video_options_t * opt,
03093 float f);
03094
03103 GAVL_PUBLIC
03104 float gavl_video_options_get_downscale_blur(gavl_video_options_t * opt);
03105
03114 GAVL_PUBLIC
03115 void gavl_video_options_set_num_threads(gavl_video_options_t * opt, int n);
03116
03117
03126 GAVL_PUBLIC
03127 int gavl_video_options_get_num_threads(gavl_video_options_t * opt);
03128
03138 GAVL_PUBLIC
03139 void gavl_video_options_set_run_func(gavl_video_options_t * opt,
03140 gavl_video_run_func func,
03141 void * client_data);
03142
03152 GAVL_PUBLIC
03153 gavl_video_run_func gavl_video_options_get_run_func(gavl_video_options_t * opt,
03154 void ** client_data);
03155
03165 GAVL_PUBLIC
03166 void gavl_video_options_set_stop_func(gavl_video_options_t * opt,
03167 gavl_video_stop_func func,
03168 void * client_data);
03169
03179 GAVL_PUBLIC
03180 gavl_video_stop_func gavl_video_options_get_stop_func(gavl_video_options_t * opt,
03181 void ** client_data);
03182
03183
03184
03185
03186
03187
03220 typedef struct gavl_video_converter_s gavl_video_converter_t;
03221
03227 GAVL_PUBLIC
03228 gavl_video_converter_t * gavl_video_converter_create();
03229
03235 GAVL_PUBLIC
03236 void gavl_video_converter_destroy(gavl_video_converter_t*cnv);
03237
03238
03239
03240
03241
03242
03251 GAVL_PUBLIC gavl_video_options_t *
03252 gavl_video_converter_get_options(gavl_video_converter_t*cnv);
03253
03254
03268 GAVL_PUBLIC
03269 int gavl_video_converter_init(gavl_video_converter_t* cnv,
03270 const gavl_video_format_t * input_format,
03271 const gavl_video_format_t * output_format);
03272
03285 GAVL_PUBLIC
03286 int gavl_video_converter_reinit(gavl_video_converter_t* cnv);
03287
03288
03289
03290
03291
03292
03300 GAVL_PUBLIC
03301 void gavl_video_convert(gavl_video_converter_t * cnv,
03302 const gavl_video_frame_t * input_frame,
03303 gavl_video_frame_t * output_frame);
03304
03336 typedef struct gavl_video_scaler_s gavl_video_scaler_t;
03337
03343 GAVL_PUBLIC
03344 gavl_video_scaler_t * gavl_video_scaler_create();
03345
03351 GAVL_PUBLIC
03352 void gavl_video_scaler_destroy(gavl_video_scaler_t * scaler);
03353
03362 GAVL_PUBLIC gavl_video_options_t *
03363 gavl_video_scaler_get_options(gavl_video_scaler_t * scaler);
03364
03377 GAVL_PUBLIC
03378 int gavl_video_scaler_init(gavl_video_scaler_t * scaler,
03379 const gavl_video_format_t * src_format,
03380 const gavl_video_format_t * dst_format);
03381
03403 GAVL_PUBLIC
03404 int gavl_video_scaler_init_convolve(gavl_video_scaler_t * scaler,
03405 const gavl_video_format_t * format,
03406 int h_radius, const float * h_coeffs,
03407 int v_radius, const float * v_coeffs);
03408
03416 GAVL_PUBLIC
03417 void gavl_video_scaler_scale(gavl_video_scaler_t * scaler,
03418 const gavl_video_frame_t * input_frame,
03419 gavl_video_frame_t * output_frame);
03420
03436 typedef struct gavl_video_deinterlacer_s gavl_video_deinterlacer_t;
03437
03443 GAVL_PUBLIC
03444 gavl_video_deinterlacer_t * gavl_video_deinterlacer_create();
03445
03451 GAVL_PUBLIC
03452 void gavl_video_deinterlacer_destroy(gavl_video_deinterlacer_t * deinterlacer);
03453
03462 GAVL_PUBLIC gavl_video_options_t *
03463 gavl_video_deinterlacer_get_options(gavl_video_deinterlacer_t * deinterlacer);
03464
03475 GAVL_PUBLIC
03476 int gavl_video_deinterlacer_init(gavl_video_deinterlacer_t * deinterlacer,
03477 const gavl_video_format_t * src_format);
03478
03479
03487 GAVL_PUBLIC
03488 void gavl_video_deinterlacer_deinterlace(gavl_video_deinterlacer_t * deinterlacer,
03489 const gavl_video_frame_t * input_frame,
03490 gavl_video_frame_t * output_frame);
03491
03492
03493
03494
03495
03496
03497
03498
03499
03527 typedef struct
03528 {
03529 gavl_video_frame_t * frame;
03530 gavl_rectangle_i_t ovl_rect;
03531 int dst_x;
03532 int dst_y;
03533 } gavl_overlay_t;
03534
03541 typedef struct gavl_overlay_blend_context_s gavl_overlay_blend_context_t;
03542
03548 GAVL_PUBLIC
03549 gavl_overlay_blend_context_t * gavl_overlay_blend_context_create();
03550
03556 GAVL_PUBLIC
03557 void gavl_overlay_blend_context_destroy(gavl_overlay_blend_context_t * ctx);
03558
03565 GAVL_PUBLIC gavl_video_options_t *
03566 gavl_overlay_blend_context_get_options(gavl_overlay_blend_context_t * ctx);
03567
03583 GAVL_PUBLIC
03584 int gavl_overlay_blend_context_init(gavl_overlay_blend_context_t * ctx,
03585 const gavl_video_format_t * frame_format,
03586 gavl_video_format_t * overlay_format);
03587
03597 GAVL_PUBLIC
03598 void gavl_overlay_blend_context_set_overlay(gavl_overlay_blend_context_t * ctx,
03599 gavl_overlay_t * ovl);
03600
03607 GAVL_PUBLIC
03608 void gavl_overlay_blend(gavl_overlay_blend_context_t * ctx,
03609 gavl_video_frame_t * dst_frame);
03610
03632 typedef struct gavl_image_transform_s gavl_image_transform_t;
03633
03647 typedef void (*gavl_image_transform_func)(void * priv,
03648 double xdst,
03649 double ydst,
03650 double * xsrc,
03651 double * ysrc);
03652
03653
03660 GAVL_PUBLIC
03661 gavl_image_transform_t * gavl_image_transform_create();
03662
03668 GAVL_PUBLIC
03669 void gavl_image_transform_destroy(gavl_image_transform_t * t);
03670
03689 GAVL_PUBLIC
03690 int gavl_image_transform_init(gavl_image_transform_t * t,
03691 gavl_video_format_t * format,
03692 gavl_image_transform_func func, void * priv);
03693
03701 GAVL_PUBLIC
03702 void gavl_image_transform_transform(gavl_image_transform_t * t,
03703 gavl_video_frame_t * in_frame,
03704 gavl_video_frame_t * out_frame);
03705
03716 GAVL_PUBLIC gavl_video_options_t *
03717 gavl_image_transform_get_options(gavl_image_transform_t * t);
03718
03741 typedef struct
03742 {
03743 int64_t offset;
03744
03745 int64_t num_entries;
03746 int64_t entries_alloc;
03747
03748 struct
03749 {
03750 int64_t num_frames;
03751 int64_t duration;
03752 } * entries;
03753
03754 int num_timecodes;
03755 int timecodes_alloc;
03756
03757 struct
03758 {
03759 int64_t pts;
03760 gavl_timecode_t tc;
03761 } * timecodes;
03762
03763
03764
03765 } gavl_frame_table_t;
03766
03772 GAVL_PUBLIC gavl_frame_table_t * gavl_frame_table_create();
03773
03784 GAVL_PUBLIC gavl_frame_table_t *
03785 gavl_frame_table_create_audio(int samplerate, int64_t offset, int64_t duration,
03786 gavl_timecode_format_t * fmt_ret);
03787
03798 GAVL_PUBLIC gavl_frame_table_t *
03799 gavl_frame_table_create_cfr(int64_t offset, int64_t frame_duration,
03800 int64_t num_frames,
03801 gavl_timecode_t start_timecode);
03802
03810 GAVL_PUBLIC gavl_frame_table_t *
03811 gavl_frame_table_copy(const gavl_frame_table_t * tab);
03812
03813
03814
03821 GAVL_PUBLIC void gavl_frame_table_destroy(gavl_frame_table_t * t);
03822
03830 GAVL_PUBLIC void gavl_frame_table_append_entry(gavl_frame_table_t * t, int64_t duration);
03831
03840 GAVL_PUBLIC void
03841 gavl_frame_table_append_timecode(gavl_frame_table_t * t,
03842 int64_t pts, gavl_timecode_t tc);
03843
03854 GAVL_PUBLIC int64_t
03855 gavl_frame_table_frame_to_time(const gavl_frame_table_t * t,
03856 int64_t frame, int * duration);
03857
03868 GAVL_PUBLIC int64_t
03869 gavl_frame_table_time_to_frame(const gavl_frame_table_t * t,
03870 int64_t time,
03871 int64_t * start_time);
03872
03883 GAVL_PUBLIC gavl_timecode_t
03884 gavl_frame_table_time_to_timecode(const gavl_frame_table_t * t,
03885 int64_t time,
03886 int64_t * start_time,
03887 const gavl_timecode_format_t * fmt);
03888
03898 GAVL_PUBLIC int64_t
03899 gavl_frame_table_timecode_to_time(const gavl_frame_table_t * t,
03900 gavl_timecode_t tc,
03901 const gavl_timecode_format_t * fmt);
03902
03903
03914 GAVL_PUBLIC gavl_timecode_t
03915 gavl_frame_table_frame_to_timecode(const gavl_frame_table_t * t,
03916 int64_t frame,
03917 int64_t * start_time,
03918 const gavl_timecode_format_t * fmt);
03919
03920
03921
03929 GAVL_PUBLIC int64_t
03930 gavl_frame_table_num_frames(const gavl_frame_table_t * t);
03931
03939 GAVL_PUBLIC int64_t
03940 gavl_frame_table_duration(const gavl_frame_table_t * t);
03941
03949 GAVL_PUBLIC int64_t
03950 gavl_frame_table_end_time(const gavl_frame_table_t * t);
03951
03960 GAVL_PUBLIC
03961 int gavl_frame_table_save(const gavl_frame_table_t * t,
03962 const char * filename);
03963
03971 GAVL_PUBLIC
03972 gavl_frame_table_t * gavl_frame_table_load(const char * filename);
03973
03980 GAVL_PUBLIC void
03981 gavl_frame_table_dump(const gavl_frame_table_t * t);
03982
03983
03984
03985
03986
03987
03993 #ifdef __cplusplus
03994 }
03995 #endif
03996
03997 #endif