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 #include <gavlconfig.h>
00032
00033 #include "gavltime.h"
00034
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038
00043 typedef struct gavl_video_format_s gavl_video_format_t;
00044
00045
00046
00070 #define GAVL_QUALITY_FASTEST 1
00071
00078 #define GAVL_QUALITY_BEST 5
00079
00086 #define GAVL_QUALITY_DEFAULT 2
00087
00099 #define GAVL_ACCEL_MMX (1<<0)
00100 #define GAVL_ACCEL_MMXEXT (1<<1)
00101 #define GAVL_ACCEL_SSE (1<<2)
00102 #define GAVL_ACCEL_SSE2 (1<<3)
00103 #define GAVL_ACCEL_SSE3 (1<<4)
00104 #define GAVL_ACCEL_3DNOW (1<<5)
00105 #define GAVL_ACCEL_3DNOWEXT (1<<6)
00106 #define GAVL_ACCEL_SSSE3 (1<<7)
00107
00108
00112 int gavl_accel_supported();
00113
00122
00123
00136 #define GAVL_MAX_CHANNELS 128
00137
00144 typedef enum
00145 {
00146 GAVL_SAMPLE_NONE = 0,
00147 GAVL_SAMPLE_U8 = 1,
00148 GAVL_SAMPLE_S8 = 2,
00149 GAVL_SAMPLE_U16 = 3,
00150 GAVL_SAMPLE_S16 = 4,
00151 GAVL_SAMPLE_S32 = 5,
00152 GAVL_SAMPLE_FLOAT = 6,
00153 GAVL_SAMPLE_DOUBLE = 7
00154 } gavl_sample_format_t;
00155
00161 typedef enum
00162 {
00163 GAVL_INTERLEAVE_NONE = 0,
00164 GAVL_INTERLEAVE_2 = 1,
00165 GAVL_INTERLEAVE_ALL = 2
00166 } gavl_interleave_mode_t;
00167
00175 typedef enum
00176 {
00177 GAVL_CHID_NONE = 0,
00178 GAVL_CHID_FRONT_CENTER,
00179 GAVL_CHID_FRONT_LEFT,
00180 GAVL_CHID_FRONT_RIGHT,
00181 GAVL_CHID_FRONT_CENTER_LEFT,
00182 GAVL_CHID_FRONT_CENTER_RIGHT,
00183 GAVL_CHID_REAR_LEFT,
00184 GAVL_CHID_REAR_RIGHT,
00185 GAVL_CHID_REAR_CENTER,
00186 GAVL_CHID_SIDE_LEFT,
00187 GAVL_CHID_SIDE_RIGHT,
00188 GAVL_CHID_LFE,
00189 GAVL_CHID_AUX,
00190 } gavl_channel_id_t;
00191
00200 typedef struct
00201 {
00202 int samples_per_frame;
00203 int samplerate;
00204 int num_channels;
00205 gavl_sample_format_t sample_format;
00206 gavl_interleave_mode_t interleave_mode;
00208 float center_level;
00209 float rear_level;
00211 gavl_channel_id_t channel_locations[GAVL_MAX_CHANNELS];
00213 } gavl_audio_format_t;
00214
00215
00216
00217
00225 const char * gavl_sample_format_to_string(gavl_sample_format_t format);
00226
00235 gavl_sample_format_t gavl_string_to_sample_format(const char * str);
00236
00242 int gavl_num_sample_formats();
00243
00250 gavl_sample_format_t gavl_get_sample_format(int index);
00251
00258 const char * gavl_channel_id_to_string(gavl_channel_id_t id);
00259
00260
00267 const char * gavl_interleave_mode_to_string(gavl_interleave_mode_t mode);
00268
00275 void gavl_audio_format_dump(const gavl_audio_format_t * format);
00276
00285 int gavl_channel_index(const gavl_audio_format_t * format, gavl_channel_id_t id);
00286
00293 int gavl_front_channels(const gavl_audio_format_t * format);
00294
00301 int gavl_rear_channels(const gavl_audio_format_t * format);
00302
00309 int gavl_side_channels(const gavl_audio_format_t * format);
00310
00317 int gavl_aux_channels(const gavl_audio_format_t * format);
00318
00319
00320
00327 int gavl_lfe_channels(const gavl_audio_format_t * format);
00328
00336 void gavl_audio_format_copy(gavl_audio_format_t * dst,
00337 const gavl_audio_format_t * src);
00338
00347 int gavl_audio_formats_equal(const gavl_audio_format_t * format_1,
00348 const gavl_audio_format_t * format_2);
00349
00361 void gavl_set_channel_setup(gavl_audio_format_t * format);
00362
00369 int gavl_bytes_per_sample(gavl_sample_format_t format);
00370
00385 typedef union
00386 {
00387 uint8_t * u_8;
00388 int8_t * s_8;
00390 uint16_t * u_16;
00391 int16_t * s_16;
00393 uint32_t * u_32;
00394 int32_t * s_32;
00396 float * f;
00397 double * d;
00398 } gavl_audio_samples_t;
00399
00405 typedef union
00406 {
00407 uint8_t * u_8[GAVL_MAX_CHANNELS];
00408 int8_t * s_8[GAVL_MAX_CHANNELS];
00410 uint16_t * u_16[GAVL_MAX_CHANNELS];
00411 int16_t * s_16[GAVL_MAX_CHANNELS];
00413 uint32_t * u_32[GAVL_MAX_CHANNELS];
00414 int32_t * s_32[GAVL_MAX_CHANNELS];
00416 float * f[GAVL_MAX_CHANNELS];
00417 double * d[GAVL_MAX_CHANNELS];
00419 } gavl_audio_channels_t;
00420
00437 typedef struct
00438 {
00439 gavl_audio_samples_t samples;
00440 gavl_audio_channels_t channels;
00441 int valid_samples;
00442 int64_t timestamp;
00443 int channel_stride;
00444 } gavl_audio_frame_t;
00445
00457 gavl_audio_frame_t * gavl_audio_frame_create(const gavl_audio_format_t* format);
00458
00470 void gavl_audio_frame_null(gavl_audio_frame_t * frame);
00471
00481 void gavl_audio_frame_destroy(gavl_audio_frame_t * frame);
00482
00492 void gavl_audio_frame_mute(gavl_audio_frame_t * frame,
00493 const gavl_audio_format_t * format);
00494
00505 void gavl_audio_frame_mute_samples(gavl_audio_frame_t * frame,
00506 const gavl_audio_format_t * format,
00507 int num_samples);
00508
00509
00510
00521 void gavl_audio_frame_mute_channel(gavl_audio_frame_t * frame,
00522 const gavl_audio_format_t * format,
00523 int channel);
00524
00545 int gavl_audio_frame_copy(const gavl_audio_format_t * format,
00546 gavl_audio_frame_t * dst,
00547 const gavl_audio_frame_t * src,
00548 int dst_pos,
00549 int src_pos,
00550 int dst_size,
00551 int src_size);
00552
00567 #define GAVL_AUDIO_FRONT_TO_REAR_COPY (1<<0)
00572 #define GAVL_AUDIO_FRONT_TO_REAR_MUTE (1<<1)
00577 #define GAVL_AUDIO_FRONT_TO_REAR_DIFF (1<<2)
00582 #define GAVL_AUDIO_FRONT_TO_REAR_MASK \
00583 (GAVL_AUDIO_FRONT_TO_REAR_COPY | \
00584 GAVL_AUDIO_FRONT_TO_REAR_MUTE | \
00585 GAVL_AUDIO_FRONT_TO_REAR_DIFF)
00587
00588
00591 #define GAVL_AUDIO_STEREO_TO_MONO_LEFT (1<<3)
00594 #define GAVL_AUDIO_STEREO_TO_MONO_RIGHT (1<<4)
00597 #define GAVL_AUDIO_STEREO_TO_MONO_MIX (1<<5)
00601 #define GAVL_AUDIO_STEREO_TO_MONO_MASK \
00602 (GAVL_AUDIO_STEREO_TO_MONO_LEFT | \
00603 GAVL_AUDIO_STEREO_TO_MONO_RIGHT | \
00604 GAVL_AUDIO_STEREO_TO_MONO_MIX)
00610 typedef enum
00611 {
00612 GAVL_AUDIO_DITHER_NONE = 0,
00613 GAVL_AUDIO_DITHER_AUTO = 1,
00614 GAVL_AUDIO_DITHER_RECT = 2,
00615 GAVL_AUDIO_DITHER_TRI = 3,
00616 GAVL_AUDIO_DITHER_SHAPED = 4,
00617 } gavl_audio_dither_mode_t;
00618
00623 typedef enum
00624 {
00625 GAVL_RESAMPLE_AUTO = 0,
00626 GAVL_RESAMPLE_ZOH = 1,
00627 GAVL_RESAMPLE_LINEAR = 2,
00628 GAVL_RESAMPLE_SINC_FAST = 3,
00629 GAVL_RESAMPLE_SINC_MEDIUM = 4,
00630 GAVL_RESAMPLE_SINC_BEST = 5
00631 } gavl_resample_mode_t;
00632
00639 typedef struct gavl_audio_options_s gavl_audio_options_t;
00640
00647 void gavl_audio_options_set_quality(gavl_audio_options_t * opt, int quality);
00648
00655 int gavl_audio_options_get_quality(gavl_audio_options_t * opt);
00656
00663 void gavl_audio_options_set_dither_mode(gavl_audio_options_t * opt, gavl_audio_dither_mode_t mode);
00664
00671 gavl_audio_dither_mode_t gavl_audio_options_get_dither_mode(gavl_audio_options_t * opt);
00672
00673
00680 void gavl_audio_options_set_resample_mode(gavl_audio_options_t * opt, gavl_resample_mode_t mode);
00681
00688 gavl_resample_mode_t gavl_audio_options_get_resample_mode(gavl_audio_options_t * opt);
00689
00696 void gavl_audio_options_set_conversion_flags(gavl_audio_options_t * opt,
00697 int flags);
00698
00705 int gavl_audio_options_get_conversion_flags(gavl_audio_options_t * opt);
00706
00712 void gavl_audio_options_set_defaults(gavl_audio_options_t * opt);
00713
00723 gavl_audio_options_t * gavl_audio_options_create();
00724
00731 void gavl_audio_options_copy(gavl_audio_options_t * dst,
00732 const gavl_audio_options_t * src);
00733
00739 void gavl_audio_options_destroy(gavl_audio_options_t * opt);
00740
00741
00742
00743
00744
00778 typedef struct gavl_audio_converter_s gavl_audio_converter_t;
00779
00785 gavl_audio_converter_t * gavl_audio_converter_create();
00786
00792 void gavl_audio_converter_destroy(gavl_audio_converter_t* cnv);
00793
00802 gavl_audio_options_t * gavl_audio_converter_get_options(gavl_audio_converter_t*cnv);
00803
00804
00818 int gavl_audio_converter_init(gavl_audio_converter_t* cnv,
00819 const gavl_audio_format_t * input_format,
00820 const gavl_audio_format_t * output_format);
00821
00835 int gavl_audio_converter_reinit(gavl_audio_converter_t* cnv);
00836
00837
00851 void gavl_audio_convert(gavl_audio_converter_t * cnv,
00852 const gavl_audio_frame_t * input_frame,
00853 gavl_audio_frame_t * output_frame);
00854
00855
00856
00857
00871 typedef struct gavl_volume_control_s gavl_volume_control_t;
00872
00873
00874
00880 gavl_volume_control_t * gavl_volume_control_create();
00881
00887 void gavl_volume_control_destroy(gavl_volume_control_t *ctrl);
00888
00896 void gavl_volume_control_set_format(gavl_volume_control_t *ctrl,
00897 const gavl_audio_format_t * format);
00898
00905 void gavl_volume_control_set_volume(gavl_volume_control_t * ctrl,
00906 float volume);
00907
00914 void gavl_volume_control_apply(gavl_volume_control_t *ctrl,
00915 gavl_audio_frame_t * frame);
00916
00932 typedef struct gavl_peak_detector_s gavl_peak_detector_t;
00933
00934
00935
00941 gavl_peak_detector_t * gavl_peak_detector_create();
00942
00948 void gavl_peak_detector_destroy(gavl_peak_detector_t *pd);
00949
00959 void gavl_peak_detector_set_format(gavl_peak_detector_t *pd,
00960 const gavl_audio_format_t * format);
00961
00968 void gavl_peak_detector_update(gavl_peak_detector_t *pd,
00969 gavl_audio_frame_t * frame);
00970
00983 void gavl_peak_detector_get_peak(gavl_peak_detector_t * pd,
00984 double * min, double * max,
00985 double * abs);
00986
00999 void gavl_peak_detector_get_peaks(gavl_peak_detector_t * pd,
01000 double * min, double * max,
01001 double * abs);
01002
01008 void gavl_peak_detector_reset(gavl_peak_detector_t * pd);
01009
01019 #define GAVL_MAX_PLANES 4
01031 typedef struct
01032 {
01033 int x;
01034 int y;
01035 int w;
01036 int h;
01037 } gavl_rectangle_i_t;
01038
01043 typedef struct
01044 {
01045 double x;
01046 double y;
01047 double w;
01048 double h;
01049 } gavl_rectangle_f_t;
01050
01057 void gavl_rectangle_i_crop_to_format(gavl_rectangle_i_t * r,
01058 const gavl_video_format_t * format);
01059
01066 void gavl_rectangle_f_crop_to_format(gavl_rectangle_f_t * r,
01067 const gavl_video_format_t * format);
01068
01083 void gavl_rectangle_crop_to_format_noscale(gavl_rectangle_i_t * src_rect,
01084 gavl_rectangle_i_t * dst_rect,
01085 const gavl_video_format_t * src_format,
01086 const gavl_video_format_t * dst_format);
01087
01099 void gavl_rectangle_crop_to_format_scale(gavl_rectangle_f_t * src_rect,
01100 gavl_rectangle_i_t * dst_rect,
01101 const gavl_video_format_t * src_format,
01102 const gavl_video_format_t * dst_format);
01103
01104
01105
01112 void gavl_rectangle_i_set_all(gavl_rectangle_i_t * r, const gavl_video_format_t * format);
01113
01120 void gavl_rectangle_f_set_all(gavl_rectangle_f_t * r, const gavl_video_format_t * format);
01121
01128 void gavl_rectangle_i_crop_left(gavl_rectangle_i_t * r, int num_pixels);
01129
01136 void gavl_rectangle_i_crop_right(gavl_rectangle_i_t * r, int num_pixels);
01137
01144 void gavl_rectangle_i_crop_top(gavl_rectangle_i_t * r, int num_pixels);
01145
01152 void gavl_rectangle_i_crop_bottom(gavl_rectangle_i_t * r, int num_pixels);
01153
01160 void gavl_rectangle_f_crop_left(gavl_rectangle_f_t * r, double num_pixels);
01161
01168 void gavl_rectangle_f_crop_right(gavl_rectangle_f_t * r, double num_pixels);
01169
01176 void gavl_rectangle_f_crop_top(gavl_rectangle_f_t * r, double num_pixels);
01177
01184 void gavl_rectangle_f_crop_bottom(gavl_rectangle_f_t * r, double num_pixels);
01185
01199 void gavl_rectangle_i_align(gavl_rectangle_i_t * r, int h_align, int v_align);
01200
01210 void gavl_rectangle_i_align_to_format(gavl_rectangle_i_t * r,
01211 const gavl_video_format_t * format);
01212
01213
01220 void gavl_rectangle_i_copy(gavl_rectangle_i_t * dst, const gavl_rectangle_i_t * src);
01221
01228 void gavl_rectangle_f_copy(gavl_rectangle_f_t * dst, const gavl_rectangle_f_t * src);
01229
01230
01231
01238 void gavl_rectangle_i_to_f(gavl_rectangle_f_t * dst, const gavl_rectangle_i_t * src);
01239
01246 void gavl_rectangle_f_to_i(gavl_rectangle_i_t * dst, const gavl_rectangle_f_t * src);
01247
01256 int gavl_rectangle_i_is_empty(const gavl_rectangle_i_t * r);
01257
01266 int gavl_rectangle_f_is_empty(const gavl_rectangle_f_t * r);
01267
01295 void gavl_rectangle_fit_aspect(gavl_rectangle_i_t * dst_rect,
01296 const gavl_video_format_t * src_format,
01297 const gavl_rectangle_f_t * src_rect,
01298 const gavl_video_format_t * dst_format,
01299 float zoom, float squeeze);
01300
01305 void gavl_rectangle_i_dump(const gavl_rectangle_i_t * r);
01306
01311 void gavl_rectangle_f_dump(const gavl_rectangle_f_t * r);
01312
01313
01323 #define GAVL_PIXFMT_PLANAR (1<<8)
01324
01328 #define GAVL_PIXFMT_RGB (1<<9)
01329
01333 #define GAVL_PIXFMT_YUV (1<<10)
01334
01338 #define GAVL_PIXFMT_YUVJ (1<<11)
01339
01343 #define GAVL_PIXFMT_ALPHA (1<<12)
01344
01348 #define GAVL_PIXFMT_GRAY (1<<13)
01349
01354 typedef enum
01355 {
01358 GAVL_PIXELFORMAT_NONE = 0,
01359
01362 GAVL_GRAY_8 = 1 | GAVL_PIXFMT_GRAY,
01363
01366 GAVL_GRAY_16 = 2 | GAVL_PIXFMT_GRAY,
01367
01370 GAVL_GRAY_FLOAT = 3 | GAVL_PIXFMT_GRAY,
01371
01374 GAVL_GRAYA_16 = 1 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
01375
01378 GAVL_GRAYA_32 = 2 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
01379
01382 GAVL_GRAYA_FLOAT = 3 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
01383
01387 GAVL_RGB_15 = 1 | GAVL_PIXFMT_RGB,
01391 GAVL_BGR_15 = 2 | GAVL_PIXFMT_RGB,
01395 GAVL_RGB_16 = 3 | GAVL_PIXFMT_RGB,
01399 GAVL_BGR_16 = 4 | GAVL_PIXFMT_RGB,
01402 GAVL_RGB_24 = 5 | GAVL_PIXFMT_RGB,
01405 GAVL_BGR_24 = 6 | GAVL_PIXFMT_RGB,
01408 GAVL_RGB_32 = 7 | GAVL_PIXFMT_RGB,
01411 GAVL_BGR_32 = 8 | GAVL_PIXFMT_RGB,
01414 GAVL_RGBA_32 = 9 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA,
01415
01418 GAVL_RGB_48 = 10 | GAVL_PIXFMT_RGB,
01421 GAVL_RGBA_64 = 11 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA,
01422
01425 GAVL_RGB_FLOAT = 12 | GAVL_PIXFMT_RGB,
01428 GAVL_RGBA_FLOAT = 13 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA,
01429
01432 GAVL_YUY2 = 1 | GAVL_PIXFMT_YUV,
01435 GAVL_UYVY = 2 | GAVL_PIXFMT_YUV,
01438 GAVL_YUVA_32 = 3 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
01441 GAVL_YUVA_64 = 4 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
01444 GAVL_YUV_FLOAT = 5 | GAVL_PIXFMT_YUV,
01445
01448 GAVL_YUVA_FLOAT = 6 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
01449
01453 GAVL_YUV_420_P = 1 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01456 GAVL_YUV_422_P = 2 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01459 GAVL_YUV_444_P = 3 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01462 GAVL_YUV_411_P = 4 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01465 GAVL_YUV_410_P = 5 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01466
01469 GAVL_YUVJ_420_P = 6 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
01472 GAVL_YUVJ_422_P = 7 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
01475 GAVL_YUVJ_444_P = 8 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
01476
01479 GAVL_YUV_444_P_16 = 9 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01482 GAVL_YUV_422_P_16 = 10 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01483
01484 } gavl_pixelformat_t;
01485
01488 #define GAVL_PIXELFORMAT_1D_8 GAVL_GRAY_8
01489
01491 #define GAVL_PIXELFORMAT_2D_8 GAVL_GRAYA_16
01492
01494 #define GAVL_PIXELFORMAT_3D_8 GAVL_RGB_24
01495
01497 #define GAVL_PIXELFORMAT_4D_8 GAVL_RGBA_32
01498
01501 #define GAVL_PIXELFORMAT_1D_16 GAVL_GRAY_16
01502
01504 #define GAVL_PIXELFORMAT_2D_16 GAVL_GRAYA_32
01505
01507 #define GAVL_PIXELFORMAT_3D_16 GAVL_RGB_48
01508
01510 #define GAVL_PIXELFORMAT_4D_16 GAVL_RGBA_64
01511
01514 #define GAVL_PIXELFORMAT_1D_FLOAT GAVL_GRAY_FLOAT
01515
01517 #define GAVL_PIXELFORMAT_2D_FLOAT GAVL_GRAYA_FLOAT
01518
01520 #define GAVL_PIXELFORMAT_3D_FLOAT GAVL_RGB_FLOAT
01521
01523 #define GAVL_PIXELFORMAT_4D_FLOAT GAVL_RGBA_FLOAT
01524
01525
01526
01527
01528
01529
01536 #define gavl_pixelformat_is_gray(fmt) ((fmt) & GAVL_PIXFMT_GRAY)
01537
01538
01545 #define gavl_pixelformat_is_rgb(fmt) ((fmt) & GAVL_PIXFMT_RGB)
01546
01553 #define gavl_pixelformat_is_yuv(fmt) ((fmt) & GAVL_PIXFMT_YUV)
01554
01561 #define gavl_pixelformat_is_jpeg_scaled(fmt) ((fmt) & GAVL_PIXFMT_YUVJ)
01562
01569 #define gavl_pixelformat_has_alpha(fmt) ((fmt) & GAVL_PIXFMT_ALPHA)
01570
01577 #define gavl_pixelformat_is_planar(fmt) ((fmt) & GAVL_PIXFMT_PLANAR)
01578
01585 int gavl_pixelformat_num_planes(gavl_pixelformat_t pixelformat);
01586
01596 void gavl_pixelformat_chroma_sub(gavl_pixelformat_t pixelformat, int * sub_h, int * sub_v);
01597
01604 int gavl_pixelformat_bytes_per_component(gavl_pixelformat_t pixelformat);
01605
01612 int gavl_pixelformat_bytes_per_pixel(gavl_pixelformat_t pixelformat);
01613
01620 int gavl_pixelformat_bits_per_pixel(gavl_pixelformat_t pixelformat);
01621
01636 int gavl_pixelformat_conversion_penalty(gavl_pixelformat_t src,
01637 gavl_pixelformat_t dst);
01638
01652 gavl_pixelformat_t
01653 gavl_pixelformat_get_best(gavl_pixelformat_t src,
01654 const gavl_pixelformat_t * dst_supported,
01655 int * penalty);
01656
01657
01658
01665 const char * gavl_pixelformat_to_string(gavl_pixelformat_t pixelformat);
01666
01673 gavl_pixelformat_t gavl_string_to_pixelformat(const char * name);
01674
01680 int gavl_num_pixelformats();
01681
01688 gavl_pixelformat_t gavl_get_pixelformat(int index);
01689
01690
01691
01700 typedef enum
01701 {
01702 GAVL_CHROMA_PLACEMENT_DEFAULT = 0,
01703 GAVL_CHROMA_PLACEMENT_MPEG2,
01704 GAVL_CHROMA_PLACEMENT_DVPAL
01705 } gavl_chroma_placement_t;
01706
01713 const char * gavl_chroma_placement_to_string(gavl_chroma_placement_t mode);
01714
01719 typedef enum
01720 {
01721 GAVL_FRAMERATE_CONSTANT = 0,
01722 GAVL_FRAMERATE_VARIABLE = 1,
01723 GAVL_FRAMERATE_STILL = 2,
01724 } gavl_framerate_mode_t;
01725
01730 typedef enum
01731 {
01732 GAVL_INTERLACE_NONE = 0,
01733 GAVL_INTERLACE_TOP_FIRST,
01734 GAVL_INTERLACE_BOTTOM_FIRST,
01735 GAVL_INTERLACE_MIXED
01736 } gavl_interlace_mode_t;
01737
01744 const char * gavl_interlace_mode_to_string(gavl_interlace_mode_t mode);
01745
01746
01747
01748
01753 struct gavl_video_format_s
01754 {
01755 int frame_width;
01756 int frame_height;
01758 int image_width;
01759 int image_height;
01761
01762
01763 int pixel_width;
01764 int pixel_height;
01766 gavl_pixelformat_t pixelformat;
01768 int frame_duration;
01770 int timescale;
01772 gavl_framerate_mode_t framerate_mode;
01773 gavl_chroma_placement_t chroma_placement;
01775 gavl_interlace_mode_t interlace_mode;
01776 };
01777
01785 void gavl_video_format_copy(gavl_video_format_t * dst,
01786 const gavl_video_format_t * src);
01787
01796 int gavl_video_formats_equal(const gavl_video_format_t * format_1,
01797 const gavl_video_format_t * format_2);
01798
01799
01810 void gavl_video_format_get_chroma_offset(const gavl_video_format_t * format, int field, int plane,
01811 float * off_x, float * off_y);
01812
01813
01814
01821 void gavl_video_format_dump(const gavl_video_format_t * format);
01822
01835 void gavl_video_format_fit_to_source(gavl_video_format_t * dst,
01836 const gavl_video_format_t * src);
01837
01838
01861 typedef struct
01862 {
01863 uint8_t * planes[GAVL_MAX_PLANES];
01864 int strides[GAVL_MAX_PLANES];
01866 void * user_data;
01867 int64_t timestamp;
01868 int64_t duration;
01869 gavl_interlace_mode_t interlace_mode;
01870 } gavl_video_frame_t;
01871
01872
01884 gavl_video_frame_t * gavl_video_frame_create(const gavl_video_format_t*format);
01885
01896 gavl_video_frame_t * gavl_video_frame_create_nopad(const gavl_video_format_t*format);
01897
01898
01899
01909 void gavl_video_frame_destroy(gavl_video_frame_t*frame);
01910
01922 void gavl_video_frame_null(gavl_video_frame_t*frame);
01923
01932 void gavl_video_frame_clear(gavl_video_frame_t * frame,
01933 const gavl_video_format_t * format);
01934
01944 void gavl_video_frame_fill(gavl_video_frame_t * frame,
01945 const gavl_video_format_t * format,
01946 float * color);
01947
01948
01961 void gavl_video_frame_copy(const gavl_video_format_t * format,
01962 gavl_video_frame_t * dst,
01963 const gavl_video_frame_t * src);
01964
01977 void gavl_video_frame_copy_plane(const gavl_video_format_t * format,
01978 gavl_video_frame_t * dst,
01979 const gavl_video_frame_t * src, int plane);
01980
01992 void gavl_video_frame_copy_flip_x(const gavl_video_format_t * format,
01993 gavl_video_frame_t * dst,
01994 const gavl_video_frame_t * src);
01995
02007 void gavl_video_frame_copy_flip_y(const gavl_video_format_t * format,
02008 gavl_video_frame_t * dst,
02009 const gavl_video_frame_t * src);
02010
02022 void gavl_video_frame_copy_flip_xy(const gavl_video_format_t * format,
02023 gavl_video_frame_t * dst,
02024 const gavl_video_frame_t * src);
02025
02043 void gavl_video_frame_get_subframe(gavl_pixelformat_t pixelformat,
02044 const gavl_video_frame_t * src,
02045 gavl_video_frame_t * dst,
02046 gavl_rectangle_i_t * src_rect);
02047
02063 void gavl_video_frame_get_field(gavl_pixelformat_t pixelformat,
02064 const gavl_video_frame_t * src,
02065 gavl_video_frame_t * dst,
02066 int field);
02067
02068
02069
02082 void gavl_video_frame_dump(gavl_video_frame_t * frame,
02083 const gavl_video_format_t * format,
02084 const char * namebase);
02085
02086
02087
02088
02089
02105 #define GAVL_FORCE_DEINTERLACE (1<<0)
02106
02111 #define GAVL_CONVOLVE_CHROMA (1<<1)
02112
02117 #define GAVL_CONVOLVE_NORMALIZE (1<<2)
02118
02126 #define GAVL_RESAMPLE_CHROMA (1<<3)
02127
02135 typedef enum
02136 {
02137 GAVL_ALPHA_IGNORE = 0,
02138 GAVL_ALPHA_BLEND_COLOR
02139 } gavl_alpha_mode_t;
02140
02147 typedef enum
02148 {
02149 GAVL_DEINTERLACE_NONE = 0,
02150 GAVL_DEINTERLACE_COPY = 1,
02151 GAVL_DEINTERLACE_SCALE = 2,
02152 GAVL_DEINTERLACE_BLEND = 3
02153 } gavl_deinterlace_mode_t;
02154
02161 typedef enum
02162 {
02163 GAVL_DEINTERLACE_DROP_TOP,
02164 GAVL_DEINTERLACE_DROP_BOTTOM,
02165 } gavl_deinterlace_drop_mode_t;
02166
02171 typedef enum
02172 {
02173 GAVL_SCALE_AUTO,
02174 GAVL_SCALE_NEAREST,
02175 GAVL_SCALE_BILINEAR,
02176 GAVL_SCALE_QUADRATIC,
02177 GAVL_SCALE_CUBIC_BSPLINE,
02178 GAVL_SCALE_CUBIC_MITCHELL,
02179 GAVL_SCALE_CUBIC_CATMULL,
02180 GAVL_SCALE_SINC_LANCZOS,
02181 GAVL_SCALE_NONE,
02182 } gavl_scale_mode_t;
02183
02190 typedef struct gavl_video_options_s gavl_video_options_t;
02191
02192
02193
02199 void gavl_video_options_set_defaults(gavl_video_options_t * opt);
02200
02210 gavl_video_options_t * gavl_video_options_create();
02211
02218 void gavl_video_options_copy(gavl_video_options_t * dst,
02219 const gavl_video_options_t * src);
02220
02226 void gavl_video_options_destroy(gavl_video_options_t * opt);
02227
02228
02243 void gavl_video_options_set_rectangles(gavl_video_options_t * opt,
02244 const gavl_rectangle_f_t * src_rect,
02245 const gavl_rectangle_i_t * dst_rect);
02246
02253 void gavl_video_options_get_rectangles(gavl_video_options_t * opt,
02254 gavl_rectangle_f_t * src_rect,
02255 gavl_rectangle_i_t * dst_rect);
02256
02263 void gavl_video_options_set_quality(gavl_video_options_t * opt, int quality);
02264
02271 int gavl_video_options_get_quality(gavl_video_options_t * opt);
02272
02273
02280 void gavl_video_options_set_conversion_flags(gavl_video_options_t * opt,
02281 int conversion_flags);
02282
02289 int gavl_video_options_get_conversion_flags(gavl_video_options_t * opt);
02290
02297 void gavl_video_options_set_alpha_mode(gavl_video_options_t * opt,
02298 gavl_alpha_mode_t alpha_mode);
02299
02306 gavl_alpha_mode_t
02307 gavl_video_options_get_alpha_mode(gavl_video_options_t * opt);
02308
02309
02316 void gavl_video_options_set_scale_mode(gavl_video_options_t * opt,
02317 gavl_scale_mode_t scale_mode);
02318
02325 gavl_scale_mode_t
02326 gavl_video_options_get_scale_mode(gavl_video_options_t * opt);
02327
02328
02335 void gavl_video_options_set_scale_order(gavl_video_options_t * opt,
02336 int order);
02337
02344 int gavl_video_options_get_scale_order(gavl_video_options_t * opt);
02345
02346
02353 void gavl_video_options_set_background_color(gavl_video_options_t * opt,
02354 const float * color);
02355
02362 void gavl_video_options_get_background_color(gavl_video_options_t * opt,
02363 float * color);
02364
02371 void gavl_video_options_set_deinterlace_mode(gavl_video_options_t * opt,
02372 gavl_deinterlace_mode_t deinterlace_mode);
02373
02380 gavl_deinterlace_mode_t
02381 gavl_video_options_get_deinterlace_mode(gavl_video_options_t * opt);
02382
02389 void gavl_video_options_set_deinterlace_drop_mode(gavl_video_options_t * opt,
02390 gavl_deinterlace_drop_mode_t deinterlace_drop_mode);
02391
02398 gavl_deinterlace_drop_mode_t
02399 gavl_video_options_get_deinterlace_drop_mode(gavl_video_options_t * opt);
02400
02401
02402
02403
02404
02405
02438 typedef struct gavl_video_converter_s gavl_video_converter_t;
02439
02445 gavl_video_converter_t * gavl_video_converter_create();
02446
02452 void gavl_video_converter_destroy(gavl_video_converter_t*cnv);
02453
02454
02455
02456
02457
02458
02467 gavl_video_options_t *
02468 gavl_video_converter_get_options(gavl_video_converter_t*cnv);
02469
02470
02484 int gavl_video_converter_init(gavl_video_converter_t* cnv,
02485 const gavl_video_format_t * input_format,
02486 const gavl_video_format_t * output_format);
02487
02500 int gavl_video_converter_reinit(gavl_video_converter_t* cnv);
02501
02502
02503
02504
02505
02506
02514 void gavl_video_convert(gavl_video_converter_t * cnv,
02515 const gavl_video_frame_t * input_frame,
02516 gavl_video_frame_t * output_frame);
02517
02549 typedef struct gavl_video_scaler_s gavl_video_scaler_t;
02550
02556 gavl_video_scaler_t * gavl_video_scaler_create();
02557
02563 void gavl_video_scaler_destroy(gavl_video_scaler_t * scaler);
02564
02573 gavl_video_options_t *
02574 gavl_video_scaler_get_options(gavl_video_scaler_t * scaler);
02575
02588 int gavl_video_scaler_init(gavl_video_scaler_t * scaler,
02589 const gavl_video_format_t * src_format,
02590 const gavl_video_format_t * dst_format);
02591
02613 int gavl_video_scaler_init_convolve(gavl_video_scaler_t * scaler,
02614 const gavl_video_format_t * format,
02615 int h_radius, float * h_coeffs,
02616 int v_radius, float * v_coeffs);
02617
02625 void gavl_video_scaler_scale(gavl_video_scaler_t * scaler,
02626 const gavl_video_frame_t * input_frame,
02627 gavl_video_frame_t * output_frame);
02628
02644 typedef struct gavl_video_deinterlacer_s gavl_video_deinterlacer_t;
02645
02651 gavl_video_deinterlacer_t * gavl_video_deinterlacer_create();
02652
02658 void gavl_video_deinterlacer_destroy(gavl_video_deinterlacer_t * deinterlacer);
02659
02668 gavl_video_options_t *
02669 gavl_video_deinterlacer_get_options(gavl_video_deinterlacer_t * deinterlacer);
02670
02681 int gavl_video_deinterlacer_init(gavl_video_deinterlacer_t * deinterlacer,
02682 const gavl_video_format_t * src_format);
02683
02684
02692 void gavl_video_deinterlacer_deinterlace(gavl_video_deinterlacer_t * deinterlacer,
02693 const gavl_video_frame_t * input_frame,
02694 gavl_video_frame_t * output_frame);
02695
02696
02697
02698
02699
02700
02701
02702
02703
02731 typedef struct
02732 {
02733 gavl_video_frame_t * frame;
02734 gavl_rectangle_i_t ovl_rect;
02735 int dst_x;
02736 int dst_y;
02737 } gavl_overlay_t;
02738
02745 typedef struct gavl_overlay_blend_context_s gavl_overlay_blend_context_t;
02746
02752 gavl_overlay_blend_context_t * gavl_overlay_blend_context_create();
02753
02759 void gavl_overlay_blend_context_destroy(gavl_overlay_blend_context_t * ctx);
02760
02767 gavl_video_options_t *
02768 gavl_overlay_blend_context_get_options(gavl_overlay_blend_context_t * ctx);
02769
02785 int gavl_overlay_blend_context_init(gavl_overlay_blend_context_t * ctx,
02786 const gavl_video_format_t * frame_format,
02787 gavl_video_format_t * overlay_format);
02788
02798 void gavl_overlay_blend_context_set_overlay(gavl_overlay_blend_context_t * ctx,
02799 gavl_overlay_t * ovl);
02800
02807 void gavl_overlay_blend(gavl_overlay_blend_context_t * ctx,
02808 gavl_video_frame_t * dst_frame);
02809
02810 #ifdef __cplusplus
02811 }
02812 #endif
02813
02814 #endif