gavl
|
00001 /***************************************************************** 00002 * gavl - a general purpose audio/video processing library 00003 * 00004 * Copyright (c) 2001 - 2010 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 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 /* Quality levels */ 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 /* Sample formats: all multibyte numbers are native endian */ 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 /* Audio format -> string conversions */ 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 00691 #define GAVL_AUDIO_FRONT_TO_REAR_COPY (1<<0) 00696 #define GAVL_AUDIO_FRONT_TO_REAR_MUTE (1<<1) 00701 #define GAVL_AUDIO_FRONT_TO_REAR_DIFF (1<<2) 00706 #define GAVL_AUDIO_FRONT_TO_REAR_MASK \ 00707 (GAVL_AUDIO_FRONT_TO_REAR_COPY | \ 00708 GAVL_AUDIO_FRONT_TO_REAR_MUTE | \ 00709 GAVL_AUDIO_FRONT_TO_REAR_DIFF) 00711 /* Options for mixing stereo to mono */ 00712 00715 #define GAVL_AUDIO_STEREO_TO_MONO_LEFT (1<<3) 00718 #define GAVL_AUDIO_STEREO_TO_MONO_RIGHT (1<<4) 00721 #define GAVL_AUDIO_STEREO_TO_MONO_MIX (1<<5) 00725 #define GAVL_AUDIO_STEREO_TO_MONO_MASK \ 00726 (GAVL_AUDIO_STEREO_TO_MONO_LEFT | \ 00727 GAVL_AUDIO_STEREO_TO_MONO_RIGHT | \ 00728 GAVL_AUDIO_STEREO_TO_MONO_MIX) 00733 #define GAVL_AUDIO_NORMALIZE_MIX_MATRIX (1<<6) 00740 typedef enum 00741 { 00742 GAVL_AUDIO_DITHER_NONE = 0, 00743 GAVL_AUDIO_DITHER_AUTO = 1, 00744 GAVL_AUDIO_DITHER_RECT = 2, 00745 GAVL_AUDIO_DITHER_TRI = 3, 00746 GAVL_AUDIO_DITHER_SHAPED = 4, 00747 } gavl_audio_dither_mode_t; 00748 00753 typedef enum 00754 { 00755 GAVL_RESAMPLE_AUTO = 0, 00756 GAVL_RESAMPLE_ZOH = 1, 00757 GAVL_RESAMPLE_LINEAR = 2, 00758 GAVL_RESAMPLE_SINC_FAST = 3, 00759 GAVL_RESAMPLE_SINC_MEDIUM = 4, 00760 GAVL_RESAMPLE_SINC_BEST = 5 00761 } gavl_resample_mode_t; 00762 00769 typedef struct gavl_audio_options_s gavl_audio_options_t; 00770 00777 GAVL_PUBLIC 00778 void gavl_audio_options_set_quality(gavl_audio_options_t * opt, int quality); 00779 00786 GAVL_PUBLIC 00787 int gavl_audio_options_get_quality(gavl_audio_options_t * opt); 00788 00795 GAVL_PUBLIC 00796 void gavl_audio_options_set_dither_mode(gavl_audio_options_t * opt, gavl_audio_dither_mode_t mode); 00797 00804 GAVL_PUBLIC 00805 gavl_audio_dither_mode_t gavl_audio_options_get_dither_mode(gavl_audio_options_t * opt); 00806 00807 00814 GAVL_PUBLIC 00815 void gavl_audio_options_set_resample_mode(gavl_audio_options_t * opt, gavl_resample_mode_t mode); 00816 00823 GAVL_PUBLIC 00824 gavl_resample_mode_t gavl_audio_options_get_resample_mode(gavl_audio_options_t * opt); 00825 00832 GAVL_PUBLIC 00833 void gavl_audio_options_set_conversion_flags(gavl_audio_options_t * opt, 00834 int flags); 00835 00842 GAVL_PUBLIC 00843 int gavl_audio_options_get_conversion_flags(gavl_audio_options_t * opt); 00844 00850 GAVL_PUBLIC 00851 void gavl_audio_options_set_defaults(gavl_audio_options_t * opt); 00852 00869 GAVL_PUBLIC 00870 void gavl_audio_options_set_mix_matrix(gavl_audio_options_t * opt, 00871 const double ** matrix); 00872 00881 GAVL_PUBLIC 00882 const double ** gavl_audio_options_get_mix_matrix(gavl_audio_options_t * opt); 00883 00893 GAVL_PUBLIC 00894 gavl_audio_options_t * gavl_audio_options_create(); 00895 00902 GAVL_PUBLIC 00903 void gavl_audio_options_copy(gavl_audio_options_t * dst, 00904 const gavl_audio_options_t * src); 00905 00911 GAVL_PUBLIC 00912 void gavl_audio_options_destroy(gavl_audio_options_t * opt); 00913 00914 00915 00916 /* Audio converter */ 00917 00951 typedef struct gavl_audio_converter_s gavl_audio_converter_t; 00952 00958 GAVL_PUBLIC 00959 gavl_audio_converter_t * gavl_audio_converter_create(); 00960 00966 GAVL_PUBLIC 00967 void gavl_audio_converter_destroy(gavl_audio_converter_t* cnv); 00968 00977 GAVL_PUBLIC 00978 gavl_audio_options_t * gavl_audio_converter_get_options(gavl_audio_converter_t*cnv); 00979 00980 00995 GAVL_PUBLIC 00996 int gavl_audio_converter_init(gavl_audio_converter_t* cnv, 00997 const gavl_audio_format_t * input_format, 00998 const gavl_audio_format_t * output_format); 00999 01014 GAVL_PUBLIC 01015 int gavl_audio_converter_init_resample(gavl_audio_converter_t * cnv, 01016 const gavl_audio_format_t * format); 01017 01032 GAVL_PUBLIC 01033 int gavl_audio_converter_reinit(gavl_audio_converter_t* cnv); 01034 01035 01049 GAVL_PUBLIC 01050 void gavl_audio_convert(gavl_audio_converter_t * cnv, 01051 const gavl_audio_frame_t * input_frame, 01052 gavl_audio_frame_t * output_frame); 01053 01054 01073 GAVL_PUBLIC 01074 int gavl_audio_converter_set_resample_ratio(gavl_audio_converter_t * cnv, 01075 double ratio ) ; 01076 01077 01093 GAVL_PUBLIC 01094 void gavl_audio_converter_resample(gavl_audio_converter_t * cnv, 01095 gavl_audio_frame_t * input_frame, 01096 gavl_audio_frame_t * output_frame, 01097 double ratio); 01098 01099 01113 typedef struct gavl_volume_control_s gavl_volume_control_t; 01114 01115 /* Create / destroy */ 01116 01122 GAVL_PUBLIC 01123 gavl_volume_control_t * gavl_volume_control_create(); 01124 01130 GAVL_PUBLIC 01131 void gavl_volume_control_destroy(gavl_volume_control_t *ctrl); 01132 01140 GAVL_PUBLIC 01141 void gavl_volume_control_set_format(gavl_volume_control_t *ctrl, 01142 const gavl_audio_format_t * format); 01143 01150 GAVL_PUBLIC 01151 void gavl_volume_control_set_volume(gavl_volume_control_t * ctrl, 01152 float volume); 01153 01160 GAVL_PUBLIC 01161 void gavl_volume_control_apply(gavl_volume_control_t *ctrl, 01162 gavl_audio_frame_t * frame); 01163 01179 typedef struct gavl_peak_detector_s gavl_peak_detector_t; 01180 01181 /* Create / destroy */ 01182 01188 GAVL_PUBLIC 01189 gavl_peak_detector_t * gavl_peak_detector_create(); 01190 01196 GAVL_PUBLIC 01197 void gavl_peak_detector_destroy(gavl_peak_detector_t *pd); 01198 01208 GAVL_PUBLIC 01209 void gavl_peak_detector_set_format(gavl_peak_detector_t *pd, 01210 const gavl_audio_format_t * format); 01211 01218 GAVL_PUBLIC 01219 void gavl_peak_detector_update(gavl_peak_detector_t *pd, 01220 gavl_audio_frame_t * frame); 01221 01234 GAVL_PUBLIC 01235 void gavl_peak_detector_get_peak(gavl_peak_detector_t * pd, 01236 double * min, double * max, 01237 double * abs); 01238 01251 GAVL_PUBLIC 01252 void gavl_peak_detector_get_peaks(gavl_peak_detector_t * pd, 01253 double * min, double * max, 01254 double * abs); 01255 01261 GAVL_PUBLIC 01262 void gavl_peak_detector_reset(gavl_peak_detector_t * pd); 01263 01273 #define GAVL_MAX_PLANES 4 01285 typedef struct 01286 { 01287 int x; 01288 int y; 01289 int w; 01290 int h; 01291 } gavl_rectangle_i_t; 01292 01297 typedef struct 01298 { 01299 double x; 01300 double y; 01301 double w; 01302 double h; 01303 } gavl_rectangle_f_t; 01304 01311 GAVL_PUBLIC 01312 void gavl_rectangle_i_crop_to_format(gavl_rectangle_i_t * r, 01313 const gavl_video_format_t * format); 01314 01321 GAVL_PUBLIC 01322 void gavl_rectangle_f_crop_to_format(gavl_rectangle_f_t * r, 01323 const gavl_video_format_t * format); 01324 01339 GAVL_PUBLIC 01340 void gavl_rectangle_crop_to_format_noscale(gavl_rectangle_i_t * src_rect, 01341 gavl_rectangle_i_t * dst_rect, 01342 const gavl_video_format_t * src_format, 01343 const gavl_video_format_t * dst_format); 01344 01356 GAVL_PUBLIC 01357 void gavl_rectangle_crop_to_format_scale(gavl_rectangle_f_t * src_rect, 01358 gavl_rectangle_i_t * dst_rect, 01359 const gavl_video_format_t * src_format, 01360 const gavl_video_format_t * dst_format); 01361 01362 01363 01370 GAVL_PUBLIC 01371 void gavl_rectangle_i_set_all(gavl_rectangle_i_t * r, const gavl_video_format_t * format); 01372 01379 GAVL_PUBLIC 01380 void gavl_rectangle_f_set_all(gavl_rectangle_f_t * r, const gavl_video_format_t * format); 01381 01388 GAVL_PUBLIC 01389 void gavl_rectangle_i_crop_left(gavl_rectangle_i_t * r, int num_pixels); 01390 01397 GAVL_PUBLIC 01398 void gavl_rectangle_i_crop_right(gavl_rectangle_i_t * r, int num_pixels); 01399 01406 GAVL_PUBLIC 01407 void gavl_rectangle_i_crop_top(gavl_rectangle_i_t * r, int num_pixels); 01408 01415 GAVL_PUBLIC 01416 void gavl_rectangle_i_crop_bottom(gavl_rectangle_i_t * r, int num_pixels); 01417 01424 GAVL_PUBLIC 01425 void gavl_rectangle_f_crop_left(gavl_rectangle_f_t * r, double num_pixels); 01426 01433 GAVL_PUBLIC 01434 void gavl_rectangle_f_crop_right(gavl_rectangle_f_t * r, double num_pixels); 01435 01442 GAVL_PUBLIC 01443 void gavl_rectangle_f_crop_top(gavl_rectangle_f_t * r, double num_pixels); 01444 01451 GAVL_PUBLIC 01452 void gavl_rectangle_f_crop_bottom(gavl_rectangle_f_t * r, double num_pixels); 01453 01467 GAVL_PUBLIC 01468 void gavl_rectangle_i_align(gavl_rectangle_i_t * r, int h_align, int v_align); 01469 01479 GAVL_PUBLIC 01480 void gavl_rectangle_i_align_to_format(gavl_rectangle_i_t * r, 01481 const gavl_video_format_t * format); 01482 01483 01490 GAVL_PUBLIC 01491 void gavl_rectangle_i_copy(gavl_rectangle_i_t * dst, const gavl_rectangle_i_t * src); 01492 01499 GAVL_PUBLIC 01500 void gavl_rectangle_f_copy(gavl_rectangle_f_t * dst, const gavl_rectangle_f_t * src); 01501 01502 01503 01510 GAVL_PUBLIC 01511 void gavl_rectangle_i_to_f(gavl_rectangle_f_t * dst, const gavl_rectangle_i_t * src); 01512 01519 GAVL_PUBLIC 01520 void gavl_rectangle_f_to_i(gavl_rectangle_i_t * dst, const gavl_rectangle_f_t * src); 01521 01530 GAVL_PUBLIC 01531 int gavl_rectangle_i_is_empty(const gavl_rectangle_i_t * r); 01532 01541 GAVL_PUBLIC 01542 int gavl_rectangle_f_is_empty(const gavl_rectangle_f_t * r); 01543 01571 GAVL_PUBLIC 01572 void gavl_rectangle_fit_aspect(gavl_rectangle_i_t * dst_rect, 01573 const gavl_video_format_t * src_format, 01574 const gavl_rectangle_f_t * src_rect, 01575 const gavl_video_format_t * dst_format, 01576 float zoom, float squeeze); 01577 01582 GAVL_PUBLIC 01583 void gavl_rectangle_i_dump(const gavl_rectangle_i_t * r); 01584 01589 GAVL_PUBLIC 01590 void gavl_rectangle_f_dump(const gavl_rectangle_f_t * r); 01591 01592 01602 #define GAVL_PIXFMT_PLANAR (1<<8) 01603 01607 #define GAVL_PIXFMT_RGB (1<<9) 01608 01612 #define GAVL_PIXFMT_YUV (1<<10) 01613 01617 #define GAVL_PIXFMT_YUVJ (1<<11) 01618 01622 #define GAVL_PIXFMT_ALPHA (1<<12) 01623 01627 #define GAVL_PIXFMT_GRAY (1<<13) 01628 01633 typedef enum 01634 { 01637 GAVL_PIXELFORMAT_NONE = 0, 01638 01641 GAVL_GRAY_8 = 1 | GAVL_PIXFMT_GRAY, 01642 01645 GAVL_GRAY_16 = 2 | GAVL_PIXFMT_GRAY, 01646 01649 GAVL_GRAY_FLOAT = 3 | GAVL_PIXFMT_GRAY, 01650 01653 GAVL_GRAYA_16 = 1 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA, 01654 01657 GAVL_GRAYA_32 = 2 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA, 01658 01661 GAVL_GRAYA_FLOAT = 3 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA, 01662 01666 GAVL_RGB_15 = 1 | GAVL_PIXFMT_RGB, 01670 GAVL_BGR_15 = 2 | GAVL_PIXFMT_RGB, 01674 GAVL_RGB_16 = 3 | GAVL_PIXFMT_RGB, 01678 GAVL_BGR_16 = 4 | GAVL_PIXFMT_RGB, 01681 GAVL_RGB_24 = 5 | GAVL_PIXFMT_RGB, 01684 GAVL_BGR_24 = 6 | GAVL_PIXFMT_RGB, 01687 GAVL_RGB_32 = 7 | GAVL_PIXFMT_RGB, 01690 GAVL_BGR_32 = 8 | GAVL_PIXFMT_RGB, 01693 GAVL_RGBA_32 = 9 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA, 01694 01697 GAVL_RGB_48 = 10 | GAVL_PIXFMT_RGB, 01700 GAVL_RGBA_64 = 11 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA, 01701 01704 GAVL_RGB_FLOAT = 12 | GAVL_PIXFMT_RGB, 01707 GAVL_RGBA_FLOAT = 13 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA, 01708 01711 GAVL_YUY2 = 1 | GAVL_PIXFMT_YUV, 01714 GAVL_UYVY = 2 | GAVL_PIXFMT_YUV, 01717 GAVL_YUVA_32 = 3 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA, 01720 GAVL_YUVA_64 = 4 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA, 01723 GAVL_YUV_FLOAT = 5 | GAVL_PIXFMT_YUV, 01724 01727 GAVL_YUVA_FLOAT = 6 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA, 01728 01732 GAVL_YUV_420_P = 1 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, 01735 GAVL_YUV_422_P = 2 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, 01738 GAVL_YUV_444_P = 3 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, 01741 GAVL_YUV_411_P = 4 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, 01744 GAVL_YUV_410_P = 5 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, 01745 01748 GAVL_YUVJ_420_P = 6 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ, 01751 GAVL_YUVJ_422_P = 7 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ, 01754 GAVL_YUVJ_444_P = 8 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ, 01755 01758 GAVL_YUV_444_P_16 = 9 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, 01761 GAVL_YUV_422_P_16 = 10 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, 01762 01763 } gavl_pixelformat_t; 01764 01767 #define GAVL_PIXELFORMAT_1D_8 GAVL_GRAY_8 01768 01770 #define GAVL_PIXELFORMAT_2D_8 GAVL_GRAYA_16 01771 01773 #define GAVL_PIXELFORMAT_3D_8 GAVL_RGB_24 01774 01776 #define GAVL_PIXELFORMAT_4D_8 GAVL_RGBA_32 01777 01780 #define GAVL_PIXELFORMAT_1D_16 GAVL_GRAY_16 01781 01783 #define GAVL_PIXELFORMAT_2D_16 GAVL_GRAYA_32 01784 01786 #define GAVL_PIXELFORMAT_3D_16 GAVL_RGB_48 01787 01789 #define GAVL_PIXELFORMAT_4D_16 GAVL_RGBA_64 01790 01793 #define GAVL_PIXELFORMAT_1D_FLOAT GAVL_GRAY_FLOAT 01794 01796 #define GAVL_PIXELFORMAT_2D_FLOAT GAVL_GRAYA_FLOAT 01797 01799 #define GAVL_PIXELFORMAT_3D_FLOAT GAVL_RGB_FLOAT 01800 01802 #define GAVL_PIXELFORMAT_4D_FLOAT GAVL_RGBA_FLOAT 01803 01810 typedef enum 01811 { 01812 GAVL_CCH_RED, 01813 GAVL_CCH_GREEN, 01814 GAVL_CCH_BLUE, 01815 GAVL_CCH_Y, 01816 GAVL_CCH_CB, 01817 GAVL_CCH_CR, 01818 GAVL_CCH_ALPHA, 01819 } gavl_color_channel_t; 01820 01821 /* 01822 * Colormodel related functions 01823 */ 01824 01831 #define gavl_pixelformat_is_gray(fmt) ((fmt) & GAVL_PIXFMT_GRAY) 01832 01833 01840 #define gavl_pixelformat_is_rgb(fmt) ((fmt) & GAVL_PIXFMT_RGB) 01841 01848 #define gavl_pixelformat_is_yuv(fmt) ((fmt) & GAVL_PIXFMT_YUV) 01849 01856 #define gavl_pixelformat_is_jpeg_scaled(fmt) ((fmt) & GAVL_PIXFMT_YUVJ) 01857 01864 #define gavl_pixelformat_has_alpha(fmt) ((fmt) & GAVL_PIXFMT_ALPHA) 01865 01872 #define gavl_pixelformat_is_planar(fmt) ((fmt) & GAVL_PIXFMT_PLANAR) 01873 01880 GAVL_PUBLIC 01881 int gavl_pixelformat_num_planes(gavl_pixelformat_t pixelformat); 01882 01892 GAVL_PUBLIC 01893 void gavl_pixelformat_chroma_sub(gavl_pixelformat_t pixelformat, int * sub_h, int * sub_v); 01894 01901 GAVL_PUBLIC 01902 int gavl_pixelformat_bytes_per_component(gavl_pixelformat_t pixelformat); 01903 01910 GAVL_PUBLIC 01911 int gavl_pixelformat_bytes_per_pixel(gavl_pixelformat_t pixelformat); 01912 01919 GAVL_PUBLIC 01920 int gavl_pixelformat_bits_per_pixel(gavl_pixelformat_t pixelformat); 01921 01936 GAVL_PUBLIC 01937 int gavl_pixelformat_conversion_penalty(gavl_pixelformat_t src, 01938 gavl_pixelformat_t dst); 01939 01953 GAVL_PUBLIC gavl_pixelformat_t 01954 gavl_pixelformat_get_best(gavl_pixelformat_t src, 01955 const gavl_pixelformat_t * dst_supported, 01956 int * penalty); 01957 01958 01959 01966 GAVL_PUBLIC 01967 const char * gavl_pixelformat_to_string(gavl_pixelformat_t pixelformat); 01968 01975 GAVL_PUBLIC 01976 gavl_pixelformat_t gavl_string_to_pixelformat(const char * name); 01977 01983 GAVL_PUBLIC 01984 int gavl_num_pixelformats(); 01985 01992 GAVL_PUBLIC 01993 gavl_pixelformat_t gavl_get_pixelformat(int index); 01994 01995 /* */ 01996 02005 typedef enum 02006 { 02007 GAVL_CHROMA_PLACEMENT_DEFAULT = 0, 02008 GAVL_CHROMA_PLACEMENT_MPEG2, 02009 GAVL_CHROMA_PLACEMENT_DVPAL 02010 } gavl_chroma_placement_t; 02011 02018 GAVL_PUBLIC 02019 const char * gavl_chroma_placement_to_string(gavl_chroma_placement_t mode); 02020 02025 typedef enum 02026 { 02027 GAVL_FRAMERATE_CONSTANT = 0, 02028 GAVL_FRAMERATE_VARIABLE = 1, 02029 GAVL_FRAMERATE_STILL = 2, 02030 } gavl_framerate_mode_t; 02031 02036 typedef enum 02037 { 02038 GAVL_INTERLACE_NONE = 0, 02039 GAVL_INTERLACE_TOP_FIRST, 02040 GAVL_INTERLACE_BOTTOM_FIRST, 02041 GAVL_INTERLACE_MIXED 02042 } gavl_interlace_mode_t; 02043 02050 GAVL_PUBLIC 02051 const char * gavl_interlace_mode_to_string(gavl_interlace_mode_t mode); 02052 02053 02054 /* Video format structure */ 02055 02060 struct gavl_video_format_s 02061 { 02062 int frame_width; 02063 int frame_height; 02065 int image_width; 02066 int image_height; 02068 /* Support for nonsquare pixels */ 02069 02070 int pixel_width; 02071 int pixel_height; 02073 gavl_pixelformat_t pixelformat; 02075 int frame_duration; 02077 int timescale; 02079 gavl_framerate_mode_t framerate_mode; 02080 gavl_chroma_placement_t chroma_placement; 02082 gavl_interlace_mode_t interlace_mode; 02084 gavl_timecode_format_t timecode_format; 02085 }; 02086 02094 GAVL_PUBLIC 02095 void gavl_video_format_copy(gavl_video_format_t * dst, 02096 const gavl_video_format_t * src); 02097 02106 GAVL_PUBLIC 02107 int gavl_video_formats_equal(const gavl_video_format_t * format_1, 02108 const gavl_video_format_t * format_2); 02109 02110 02121 GAVL_PUBLIC 02122 void gavl_video_format_get_chroma_offset(const gavl_video_format_t * format, int field, int plane, 02123 float * off_x, float * off_y); 02124 02125 02126 02139 GAVL_PUBLIC 02140 void gavl_video_format_fit_to_source(gavl_video_format_t * dst, 02141 const gavl_video_format_t * src); 02142 02150 GAVL_PUBLIC 02151 int gavl_video_format_get_image_size(const gavl_video_format_t * format); 02152 02168 GAVL_PUBLIC 02169 int gavl_get_color_channel_format(const gavl_video_format_t * frame_format, 02170 gavl_video_format_t * channel_format, 02171 gavl_color_channel_t ch); 02172 02173 02180 GAVL_PUBLIC 02181 void gavl_video_format_dump(const gavl_video_format_t * format); 02182 02183 02206 typedef struct 02207 { 02208 uint8_t * planes[GAVL_MAX_PLANES]; 02209 int strides[GAVL_MAX_PLANES]; 02211 void * user_data; 02212 int64_t timestamp; 02213 int64_t duration; 02214 gavl_interlace_mode_t interlace_mode; 02215 gavl_timecode_t timecode; 02216 } gavl_video_frame_t; 02217 02218 02230 GAVL_PUBLIC 02231 gavl_video_frame_t * gavl_video_frame_create(const gavl_video_format_t*format); 02232 02243 GAVL_PUBLIC 02244 gavl_video_frame_t * gavl_video_frame_create_nopad(const gavl_video_format_t*format); 02245 02246 02247 02257 GAVL_PUBLIC 02258 void gavl_video_frame_destroy(gavl_video_frame_t*frame); 02259 02271 GAVL_PUBLIC 02272 void gavl_video_frame_null(gavl_video_frame_t*frame); 02273 02282 GAVL_PUBLIC 02283 void gavl_video_frame_clear(gavl_video_frame_t * frame, 02284 const gavl_video_format_t * format); 02285 02295 GAVL_PUBLIC 02296 void gavl_video_frame_fill(gavl_video_frame_t * frame, 02297 const gavl_video_format_t * format, 02298 const float * color); 02299 02312 GAVL_PUBLIC 02313 void gavl_video_frame_absdiff(gavl_video_frame_t * dst, 02314 const gavl_video_frame_t * src1, 02315 const gavl_video_frame_t * src2, 02316 const gavl_video_format_t * format); 02317 02330 GAVL_PUBLIC 02331 void gavl_video_frame_psnr(double * psnr, 02332 const gavl_video_frame_t * src1, 02333 const gavl_video_frame_t * src2, 02334 const gavl_video_format_t * format); 02335 02362 GAVL_PUBLIC 02363 int gavl_video_frame_ssim(const gavl_video_frame_t * src1, 02364 const gavl_video_frame_t * src2, 02365 gavl_video_frame_t * dst, 02366 const gavl_video_format_t * format); 02367 02381 GAVL_PUBLIC 02382 void gavl_video_frame_copy(const gavl_video_format_t * format, 02383 gavl_video_frame_t * dst, 02384 const gavl_video_frame_t * src); 02385 02398 GAVL_PUBLIC 02399 void gavl_video_frame_copy_plane(const gavl_video_format_t * format, 02400 gavl_video_frame_t * dst, 02401 const gavl_video_frame_t * src, int plane); 02402 02414 GAVL_PUBLIC 02415 void gavl_video_frame_copy_flip_x(const gavl_video_format_t * format, 02416 gavl_video_frame_t * dst, 02417 const gavl_video_frame_t * src); 02418 02430 GAVL_PUBLIC 02431 void gavl_video_frame_copy_flip_y(const gavl_video_format_t * format, 02432 gavl_video_frame_t * dst, 02433 const gavl_video_frame_t * src); 02434 02446 GAVL_PUBLIC 02447 void gavl_video_frame_copy_flip_xy(const gavl_video_format_t * format, 02448 gavl_video_frame_t * dst, 02449 const gavl_video_frame_t * src); 02450 02463 GAVL_PUBLIC 02464 void gavl_video_frame_copy_metadata(gavl_video_frame_t * dst, 02465 const gavl_video_frame_t * src); 02466 02467 02485 GAVL_PUBLIC 02486 void gavl_video_frame_get_subframe(gavl_pixelformat_t pixelformat, 02487 const gavl_video_frame_t * src, 02488 gavl_video_frame_t * dst, 02489 gavl_rectangle_i_t * src_rect); 02490 02506 GAVL_PUBLIC 02507 void gavl_video_frame_get_field(gavl_pixelformat_t pixelformat, 02508 const gavl_video_frame_t * src, 02509 gavl_video_frame_t * dst, 02510 int field); 02511 02512 02513 02526 GAVL_PUBLIC 02527 void gavl_video_frame_dump(gavl_video_frame_t * frame, 02528 const gavl_video_format_t * format, 02529 const char * namebase); 02530 02541 GAVL_PUBLIC 02542 void gavl_video_frame_set_strides(gavl_video_frame_t * frame, 02543 const gavl_video_format_t * format); 02544 02557 GAVL_PUBLIC 02558 void gavl_video_frame_set_planes(gavl_video_frame_t * frame, 02559 const gavl_video_format_t * format, 02560 uint8_t * buffer); 02561 02576 GAVL_PUBLIC 02577 int gavl_video_frame_extract_channel(const gavl_video_format_t * format, 02578 gavl_color_channel_t ch, 02579 const gavl_video_frame_t * src, 02580 gavl_video_frame_t * dst); 02581 02597 GAVL_PUBLIC 02598 int gavl_video_frame_insert_channel(const gavl_video_format_t * format, 02599 gavl_color_channel_t ch, 02600 const gavl_video_frame_t * src, 02601 gavl_video_frame_t * dst); 02602 02603 02604 02605 02606 /***************************** 02607 Conversion options 02608 ******************************/ 02609 02625 #define GAVL_FORCE_DEINTERLACE (1<<0) 02626 02631 #define GAVL_CONVOLVE_CHROMA (1<<1) 02632 02637 #define GAVL_CONVOLVE_NORMALIZE (1<<2) 02638 02646 #define GAVL_RESAMPLE_CHROMA (1<<3) 02647 02655 typedef enum 02656 { 02657 GAVL_ALPHA_IGNORE = 0, 02658 GAVL_ALPHA_BLEND_COLOR 02659 } gavl_alpha_mode_t; 02660 02667 typedef enum 02668 { 02669 GAVL_DEINTERLACE_NONE = 0, 02670 GAVL_DEINTERLACE_COPY = 1, 02671 GAVL_DEINTERLACE_SCALE = 2, 02672 GAVL_DEINTERLACE_BLEND = 3 02673 } gavl_deinterlace_mode_t; 02674 02681 typedef enum 02682 { 02683 GAVL_DEINTERLACE_DROP_TOP, 02684 GAVL_DEINTERLACE_DROP_BOTTOM, 02685 } gavl_deinterlace_drop_mode_t; 02686 02691 typedef enum 02692 { 02693 GAVL_SCALE_AUTO, 02694 GAVL_SCALE_NEAREST, 02695 GAVL_SCALE_BILINEAR, 02696 GAVL_SCALE_QUADRATIC, 02697 GAVL_SCALE_CUBIC_BSPLINE, 02698 GAVL_SCALE_CUBIC_MITCHELL, 02699 GAVL_SCALE_CUBIC_CATMULL, 02700 GAVL_SCALE_SINC_LANCZOS, 02701 GAVL_SCALE_NONE, 02702 } gavl_scale_mode_t; 02703 02713 typedef enum 02714 { 02715 GAVL_DOWNSCALE_FILTER_AUTO = 0, 02716 GAVL_DOWNSCALE_FILTER_NONE, 02717 GAVL_DOWNSCALE_FILTER_WIDE, 02718 GAVL_DOWNSCALE_FILTER_GAUSS, 02719 } gavl_downscale_filter_t; 02720 02727 typedef struct gavl_video_options_s gavl_video_options_t; 02728 02729 /* Default Options */ 02730 02736 GAVL_PUBLIC 02737 void gavl_video_options_set_defaults(gavl_video_options_t * opt); 02738 02748 GAVL_PUBLIC 02749 gavl_video_options_t * gavl_video_options_create(); 02750 02757 GAVL_PUBLIC 02758 void gavl_video_options_copy(gavl_video_options_t * dst, 02759 const gavl_video_options_t * src); 02760 02766 GAVL_PUBLIC 02767 void gavl_video_options_destroy(gavl_video_options_t * opt); 02768 02769 02784 GAVL_PUBLIC 02785 void gavl_video_options_set_rectangles(gavl_video_options_t * opt, 02786 const gavl_rectangle_f_t * src_rect, 02787 const gavl_rectangle_i_t * dst_rect); 02788 02796 GAVL_PUBLIC 02797 void gavl_video_options_get_rectangles(gavl_video_options_t * opt, 02798 gavl_rectangle_f_t * src_rect, 02799 gavl_rectangle_i_t * dst_rect); 02800 02807 GAVL_PUBLIC 02808 void gavl_video_options_set_quality(gavl_video_options_t * opt, int quality); 02809 02816 GAVL_PUBLIC 02817 int gavl_video_options_get_quality(gavl_video_options_t * opt); 02818 02819 02826 GAVL_PUBLIC 02827 void gavl_video_options_set_conversion_flags(gavl_video_options_t * opt, 02828 int conversion_flags); 02829 02836 GAVL_PUBLIC 02837 int gavl_video_options_get_conversion_flags(gavl_video_options_t * opt); 02838 02845 GAVL_PUBLIC 02846 void gavl_video_options_set_alpha_mode(gavl_video_options_t * opt, 02847 gavl_alpha_mode_t alpha_mode); 02848 02855 GAVL_PUBLIC gavl_alpha_mode_t 02856 gavl_video_options_get_alpha_mode(gavl_video_options_t * opt); 02857 02858 02865 GAVL_PUBLIC 02866 void gavl_video_options_set_scale_mode(gavl_video_options_t * opt, 02867 gavl_scale_mode_t scale_mode); 02868 02875 GAVL_PUBLIC gavl_scale_mode_t 02876 gavl_video_options_get_scale_mode(gavl_video_options_t * opt); 02877 02878 02885 GAVL_PUBLIC 02886 void gavl_video_options_set_scale_order(gavl_video_options_t * opt, 02887 int order); 02888 02895 GAVL_PUBLIC 02896 int gavl_video_options_get_scale_order(gavl_video_options_t * opt); 02897 02898 02905 GAVL_PUBLIC 02906 void gavl_video_options_set_background_color(gavl_video_options_t * opt, 02907 const float * color); 02908 02915 GAVL_PUBLIC 02916 void gavl_video_options_get_background_color(gavl_video_options_t * opt, 02917 float * color); 02918 02925 GAVL_PUBLIC 02926 void gavl_video_options_set_deinterlace_mode(gavl_video_options_t * opt, 02927 gavl_deinterlace_mode_t deinterlace_mode); 02928 02935 GAVL_PUBLIC gavl_deinterlace_mode_t 02936 gavl_video_options_get_deinterlace_mode(gavl_video_options_t * opt); 02937 02944 GAVL_PUBLIC 02945 void gavl_video_options_set_deinterlace_drop_mode(gavl_video_options_t * opt, 02946 gavl_deinterlace_drop_mode_t deinterlace_drop_mode); 02947 02954 GAVL_PUBLIC gavl_deinterlace_drop_mode_t 02955 gavl_video_options_get_deinterlace_drop_mode(gavl_video_options_t * opt); 02956 02965 GAVL_PUBLIC 02966 void gavl_video_options_set_downscale_filter(gavl_video_options_t * opt, 02967 gavl_downscale_filter_t f); 02968 02969 02978 GAVL_PUBLIC gavl_downscale_filter_t 02979 gavl_video_options_get_downscale_filter(gavl_video_options_t * opt); 02980 02998 GAVL_PUBLIC 02999 void gavl_video_options_set_downscale_blur(gavl_video_options_t * opt, 03000 float f); 03001 03010 GAVL_PUBLIC 03011 float gavl_video_options_get_downscale_blur(gavl_video_options_t * opt); 03012 03021 GAVL_PUBLIC 03022 void gavl_video_options_set_num_threads(gavl_video_options_t * opt, int n); 03023 03024 03033 GAVL_PUBLIC 03034 int gavl_video_options_get_num_threads(gavl_video_options_t * opt); 03035 03045 GAVL_PUBLIC 03046 void gavl_video_options_set_run_func(gavl_video_options_t * opt, 03047 gavl_video_run_func func, 03048 void * client_data); 03049 03059 GAVL_PUBLIC 03060 gavl_video_run_func gavl_video_options_get_run_func(gavl_video_options_t * opt, 03061 void ** client_data); 03062 03072 GAVL_PUBLIC 03073 void gavl_video_options_set_stop_func(gavl_video_options_t * opt, 03074 gavl_video_stop_func func, 03075 void * client_data); 03076 03086 GAVL_PUBLIC 03087 gavl_video_stop_func gavl_video_options_get_stop_func(gavl_video_options_t * opt, 03088 void ** client_data); 03089 03090 03091 /*************************************************** 03092 * Create and destroy video converters 03093 ***************************************************/ 03094 03127 typedef struct gavl_video_converter_s gavl_video_converter_t; 03128 03134 GAVL_PUBLIC 03135 gavl_video_converter_t * gavl_video_converter_create(); 03136 03142 GAVL_PUBLIC 03143 void gavl_video_converter_destroy(gavl_video_converter_t*cnv); 03144 03145 /************************************************** 03146 * Get options. Change the options with the gavl_video_options_set_* 03147 * functions above 03148 **************************************************/ 03149 03158 GAVL_PUBLIC gavl_video_options_t * 03159 gavl_video_converter_get_options(gavl_video_converter_t*cnv); 03160 03161 03175 GAVL_PUBLIC 03176 int gavl_video_converter_init(gavl_video_converter_t* cnv, 03177 const gavl_video_format_t * input_format, 03178 const gavl_video_format_t * output_format); 03179 03192 GAVL_PUBLIC 03193 int gavl_video_converter_reinit(gavl_video_converter_t* cnv); 03194 03195 03196 /*************************************************** 03197 * Convert a frame 03198 ***************************************************/ 03199 03207 GAVL_PUBLIC 03208 void gavl_video_convert(gavl_video_converter_t * cnv, 03209 const gavl_video_frame_t * input_frame, 03210 gavl_video_frame_t * output_frame); 03211 03243 typedef struct gavl_video_scaler_s gavl_video_scaler_t; 03244 03250 GAVL_PUBLIC 03251 gavl_video_scaler_t * gavl_video_scaler_create(); 03252 03258 GAVL_PUBLIC 03259 void gavl_video_scaler_destroy(gavl_video_scaler_t * scaler); 03260 03269 GAVL_PUBLIC gavl_video_options_t * 03270 gavl_video_scaler_get_options(gavl_video_scaler_t * scaler); 03271 03284 GAVL_PUBLIC 03285 int gavl_video_scaler_init(gavl_video_scaler_t * scaler, 03286 const gavl_video_format_t * src_format, 03287 const gavl_video_format_t * dst_format); 03288 03310 GAVL_PUBLIC 03311 int gavl_video_scaler_init_convolve(gavl_video_scaler_t * scaler, 03312 const gavl_video_format_t * format, 03313 int h_radius, const float * h_coeffs, 03314 int v_radius, const float * v_coeffs); 03315 03323 GAVL_PUBLIC 03324 void gavl_video_scaler_scale(gavl_video_scaler_t * scaler, 03325 const gavl_video_frame_t * input_frame, 03326 gavl_video_frame_t * output_frame); 03327 03343 typedef struct gavl_video_deinterlacer_s gavl_video_deinterlacer_t; 03344 03350 GAVL_PUBLIC 03351 gavl_video_deinterlacer_t * gavl_video_deinterlacer_create(); 03352 03358 GAVL_PUBLIC 03359 void gavl_video_deinterlacer_destroy(gavl_video_deinterlacer_t * deinterlacer); 03360 03369 GAVL_PUBLIC gavl_video_options_t * 03370 gavl_video_deinterlacer_get_options(gavl_video_deinterlacer_t * deinterlacer); 03371 03382 GAVL_PUBLIC 03383 int gavl_video_deinterlacer_init(gavl_video_deinterlacer_t * deinterlacer, 03384 const gavl_video_format_t * src_format); 03385 03386 03394 GAVL_PUBLIC 03395 void gavl_video_deinterlacer_deinterlace(gavl_video_deinterlacer_t * deinterlacer, 03396 const gavl_video_frame_t * input_frame, 03397 gavl_video_frame_t * output_frame); 03398 03399 03400 03401 /************************************************** 03402 * Transparent overlays 03403 **************************************************/ 03404 03405 /* Overlay struct */ 03406 03434 typedef struct 03435 { 03436 gavl_video_frame_t * frame; 03437 gavl_rectangle_i_t ovl_rect; 03438 int dst_x; 03439 int dst_y; 03440 } gavl_overlay_t; 03441 03448 typedef struct gavl_overlay_blend_context_s gavl_overlay_blend_context_t; 03449 03455 GAVL_PUBLIC 03456 gavl_overlay_blend_context_t * gavl_overlay_blend_context_create(); 03457 03463 GAVL_PUBLIC 03464 void gavl_overlay_blend_context_destroy(gavl_overlay_blend_context_t * ctx); 03465 03472 GAVL_PUBLIC gavl_video_options_t * 03473 gavl_overlay_blend_context_get_options(gavl_overlay_blend_context_t * ctx); 03474 03490 GAVL_PUBLIC 03491 int gavl_overlay_blend_context_init(gavl_overlay_blend_context_t * ctx, 03492 const gavl_video_format_t * frame_format, 03493 gavl_video_format_t * overlay_format); 03494 03504 GAVL_PUBLIC 03505 void gavl_overlay_blend_context_set_overlay(gavl_overlay_blend_context_t * ctx, 03506 gavl_overlay_t * ovl); 03507 03514 GAVL_PUBLIC 03515 void gavl_overlay_blend(gavl_overlay_blend_context_t * ctx, 03516 gavl_video_frame_t * dst_frame); 03517 03539 typedef struct gavl_image_transform_s gavl_image_transform_t; 03540 03554 typedef void (*gavl_image_transform_func)(void * priv, 03555 double xdst, 03556 double ydst, 03557 double * xsrc, 03558 double * ysrc); 03559 03560 03567 GAVL_PUBLIC 03568 gavl_image_transform_t * gavl_image_transform_create(); 03569 03575 GAVL_PUBLIC 03576 void gavl_image_transform_destroy(gavl_image_transform_t * t); 03577 03596 GAVL_PUBLIC 03597 int gavl_image_transform_init(gavl_image_transform_t * t, 03598 gavl_video_format_t * format, 03599 gavl_image_transform_func func, void * priv); 03600 03608 GAVL_PUBLIC 03609 void gavl_image_transform_transform(gavl_image_transform_t * t, 03610 gavl_video_frame_t * in_frame, 03611 gavl_video_frame_t * out_frame); 03612 03623 GAVL_PUBLIC gavl_video_options_t * 03624 gavl_image_transform_get_options(gavl_image_transform_t * t); 03625 03648 typedef struct 03649 { 03650 int64_t offset; 03651 /* Primary */ 03652 int64_t num_entries; 03653 int64_t entries_alloc; 03654 03655 struct 03656 { 03657 int64_t num_frames; 03658 int64_t duration; 03659 } * entries; 03660 03661 int num_timecodes; 03662 int timecodes_alloc; 03663 03664 struct 03665 { 03666 int64_t pts; 03667 gavl_timecode_t tc; 03668 } * timecodes; 03669 03670 /* Secondary */ 03671 03672 } gavl_frame_table_t; 03673 03679 GAVL_PUBLIC gavl_frame_table_t * gavl_frame_table_create(); 03680 03691 GAVL_PUBLIC gavl_frame_table_t * 03692 gavl_frame_table_create_audio(int samplerate, int64_t offset, int64_t duration, 03693 gavl_timecode_format_t * fmt_ret); 03694 03706 GAVL_PUBLIC gavl_frame_table_t * 03707 gavl_frame_table_create_cfr(int64_t offset, int64_t frame_duration, 03708 int64_t num_frames, 03709 gavl_timecode_t start_timecode); 03710 03718 GAVL_PUBLIC gavl_frame_table_t * 03719 gavl_frame_table_copy(const gavl_frame_table_t * tab); 03720 03721 03722 03729 GAVL_PUBLIC void gavl_frame_table_destroy(gavl_frame_table_t * t); 03730 03738 GAVL_PUBLIC void gavl_frame_table_append_entry(gavl_frame_table_t * t, int64_t duration); 03739 03748 GAVL_PUBLIC void 03749 gavl_frame_table_append_timecode(gavl_frame_table_t * t, 03750 int64_t pts, gavl_timecode_t tc); 03751 03762 GAVL_PUBLIC int64_t 03763 gavl_frame_table_frame_to_time(const gavl_frame_table_t * t, 03764 int64_t frame, int * duration); 03765 03776 GAVL_PUBLIC int64_t 03777 gavl_frame_table_time_to_frame(const gavl_frame_table_t * t, 03778 int64_t time, 03779 int64_t * start_time); 03780 03791 GAVL_PUBLIC gavl_timecode_t 03792 gavl_frame_table_time_to_timecode(const gavl_frame_table_t * t, 03793 int64_t time, 03794 int64_t * start_time, 03795 const gavl_timecode_format_t * fmt); 03796 03806 GAVL_PUBLIC int64_t 03807 gavl_frame_table_timecode_to_time(const gavl_frame_table_t * t, 03808 gavl_timecode_t tc, 03809 const gavl_timecode_format_t * fmt); 03810 03811 03822 GAVL_PUBLIC gavl_timecode_t 03823 gavl_frame_table_frame_to_timecode(const gavl_frame_table_t * t, 03824 int64_t frame, 03825 int64_t * start_time, 03826 const gavl_timecode_format_t * fmt); 03827 03828 03829 03837 GAVL_PUBLIC int64_t 03838 gavl_frame_table_num_frames(const gavl_frame_table_t * t); 03839 03847 GAVL_PUBLIC int64_t 03848 gavl_frame_table_duration(const gavl_frame_table_t * t); 03849 03857 GAVL_PUBLIC int64_t 03858 gavl_frame_table_end_time(const gavl_frame_table_t * t); 03859 03868 GAVL_PUBLIC 03869 int gavl_frame_table_save(const gavl_frame_table_t * tab, 03870 const char * filename); 03871 03879 GAVL_PUBLIC 03880 gavl_frame_table_t * gavl_frame_table_load(const char * filename); 03881 03888 GAVL_PUBLIC void 03889 gavl_frame_table_dump(const gavl_frame_table_t * t); 03890 03891 03892 03893 03894 03895 03901 #ifdef __cplusplus 03902 } 03903 #endif 03904 03905 #endif /* GAVL_H_INCLUDED */