gavl.h

Go to the documentation of this file.
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_UNKNOWN = -1, 
02039     GAVL_INTERLACE_NONE = 0,     
02040     GAVL_INTERLACE_TOP_FIRST,    
02041     GAVL_INTERLACE_BOTTOM_FIRST, 
02042     GAVL_INTERLACE_MIXED,        
02043     GAVL_INTERLACE_MIXED_TOP,    
02044     GAVL_INTERLACE_MIXED_BOTTOM, 
02045   } gavl_interlace_mode_t;
02046 
02053 GAVL_PUBLIC
02054 const char * gavl_interlace_mode_to_string(gavl_interlace_mode_t mode);
02055   
02056   
02057 /* Video format structure */
02058   
02063 struct gavl_video_format_s
02064   {
02065   int frame_width;
02066   int frame_height;
02068   int image_width;
02069   int image_height;
02071   /* Support for nonsquare pixels */
02072     
02073   int pixel_width;
02074   int pixel_height;
02076   gavl_pixelformat_t pixelformat;
02078   int frame_duration;
02080   int timescale;
02082   gavl_framerate_mode_t   framerate_mode;
02083   gavl_chroma_placement_t chroma_placement;
02085   gavl_interlace_mode_t   interlace_mode;
02087   gavl_timecode_format_t  timecode_format;
02088   };
02089 
02097 GAVL_PUBLIC
02098 void gavl_video_format_copy(gavl_video_format_t * dst,
02099                             const gavl_video_format_t * src);
02100 
02109 GAVL_PUBLIC
02110 int gavl_video_formats_equal(const gavl_video_format_t * format_1,
02111                              const gavl_video_format_t * format_2);
02112 
02113   
02124 GAVL_PUBLIC
02125 void gavl_video_format_get_chroma_offset(const gavl_video_format_t * format, int field, int plane,
02126                                          float * off_x, float * off_y);
02127   
02128  
02129 
02142 GAVL_PUBLIC
02143 void gavl_video_format_fit_to_source(gavl_video_format_t * dst,
02144                                      const gavl_video_format_t * src);
02145 
02153 GAVL_PUBLIC
02154 int gavl_video_format_get_image_size(const gavl_video_format_t * format);
02155 
02171 GAVL_PUBLIC
02172 int gavl_get_color_channel_format(const gavl_video_format_t * frame_format,
02173                                   gavl_video_format_t * channel_format,
02174                                   gavl_color_channel_t ch);
02175   
02176   
02183 GAVL_PUBLIC
02184 void gavl_video_format_dump(const gavl_video_format_t * format);
02185 
02186   
02209 typedef struct
02210   {
02211   uint8_t * planes[GAVL_MAX_PLANES]; 
02212   int strides[GAVL_MAX_PLANES];      
02214   void * user_data;    
02215   int64_t timestamp; 
02216   int64_t duration; 
02217   gavl_interlace_mode_t   interlace_mode;
02218   gavl_timecode_t timecode; 
02219   } gavl_video_frame_t;
02220 
02221 
02233 GAVL_PUBLIC
02234 gavl_video_frame_t * gavl_video_frame_create(const gavl_video_format_t*format);
02235 
02246 GAVL_PUBLIC
02247 gavl_video_frame_t * gavl_video_frame_create_nopad(const gavl_video_format_t*format);
02248 
02249   
02250 
02260 GAVL_PUBLIC
02261 void gavl_video_frame_destroy(gavl_video_frame_t*frame);
02262 
02274 GAVL_PUBLIC
02275 void gavl_video_frame_null(gavl_video_frame_t*frame);
02276   
02285 GAVL_PUBLIC
02286 void gavl_video_frame_clear(gavl_video_frame_t * frame,
02287                             const gavl_video_format_t * format);
02288 
02298 GAVL_PUBLIC
02299 void gavl_video_frame_fill(gavl_video_frame_t * frame,
02300                            const gavl_video_format_t * format,
02301                            const float * color);
02302 
02315 GAVL_PUBLIC
02316 void gavl_video_frame_absdiff(gavl_video_frame_t * dst,
02317                               const gavl_video_frame_t * src1,
02318                               const gavl_video_frame_t * src2,
02319                               const gavl_video_format_t * format);
02320 
02333 GAVL_PUBLIC
02334 void gavl_video_frame_psnr(double * psnr,
02335                            const gavl_video_frame_t * src1,
02336                            const gavl_video_frame_t * src2,
02337                            const gavl_video_format_t * format);
02338 
02365 GAVL_PUBLIC
02366 int gavl_video_frame_ssim(const gavl_video_frame_t * src1,
02367                           const gavl_video_frame_t * src2,
02368                           gavl_video_frame_t * dst,
02369                           const gavl_video_format_t * format);
02370 
02384 GAVL_PUBLIC
02385 void gavl_video_frame_copy(const gavl_video_format_t * format,
02386                            gavl_video_frame_t * dst,
02387                            const gavl_video_frame_t * src);
02388 
02401 GAVL_PUBLIC
02402 void gavl_video_frame_copy_plane(const gavl_video_format_t * format,
02403                                  gavl_video_frame_t * dst,
02404                                  const gavl_video_frame_t * src, int plane);
02405 
02417 GAVL_PUBLIC
02418 void gavl_video_frame_copy_flip_x(const gavl_video_format_t * format,
02419                                   gavl_video_frame_t * dst,
02420                                   const gavl_video_frame_t * src);
02421 
02433 GAVL_PUBLIC
02434 void gavl_video_frame_copy_flip_y(const gavl_video_format_t * format,
02435                                   gavl_video_frame_t * dst,
02436                                   const gavl_video_frame_t * src);
02437 
02449 GAVL_PUBLIC
02450 void gavl_video_frame_copy_flip_xy(const gavl_video_format_t * format,
02451                                    gavl_video_frame_t * dst,
02452                                   const gavl_video_frame_t * src);
02453 
02466 GAVL_PUBLIC
02467 void gavl_video_frame_copy_metadata(gavl_video_frame_t * dst,
02468                                     const gavl_video_frame_t * src);
02469 
02470   
02488 GAVL_PUBLIC
02489 void gavl_video_frame_get_subframe(gavl_pixelformat_t pixelformat,
02490                                    const gavl_video_frame_t * src,
02491                                    gavl_video_frame_t * dst,
02492                                    gavl_rectangle_i_t * src_rect);
02493 
02509 GAVL_PUBLIC
02510 void gavl_video_frame_get_field(gavl_pixelformat_t pixelformat,
02511                                 const gavl_video_frame_t * src,
02512                                 gavl_video_frame_t * dst,
02513                                 int field);
02514 
02515   
02516 
02529 GAVL_PUBLIC
02530 void gavl_video_frame_dump(gavl_video_frame_t * frame,
02531                            const gavl_video_format_t * format,
02532                            const char * namebase);
02533 
02544 GAVL_PUBLIC
02545 void gavl_video_frame_set_strides(gavl_video_frame_t * frame,
02546                                   const gavl_video_format_t * format);
02547 
02560 GAVL_PUBLIC
02561 void gavl_video_frame_set_planes(gavl_video_frame_t * frame,
02562                                  const gavl_video_format_t * format,
02563                                  uint8_t * buffer);
02564 
02579 GAVL_PUBLIC
02580 int gavl_video_frame_extract_channel(const gavl_video_format_t * format,
02581                                      gavl_color_channel_t ch,
02582                                      const gavl_video_frame_t * src,
02583                                      gavl_video_frame_t * dst);
02584 
02600 GAVL_PUBLIC
02601 int gavl_video_frame_insert_channel(const gavl_video_format_t * format,
02602                                     gavl_color_channel_t ch,
02603                                     const gavl_video_frame_t * src,
02604                                     gavl_video_frame_t * dst);
02605   
02606   
02607 
02608   
02609 /*****************************
02610  Conversion options
02611 ******************************/
02612 
02628 #define GAVL_FORCE_DEINTERLACE (1<<0)
02629 
02634 #define GAVL_CONVOLVE_CHROMA   (1<<1)
02635 
02640 #define GAVL_CONVOLVE_NORMALIZE (1<<2)
02641 
02649 #define GAVL_RESAMPLE_CHROMA    (1<<3)
02650   
02658 typedef enum
02659   {
02660     GAVL_ALPHA_IGNORE      = 0, 
02661     GAVL_ALPHA_BLEND_COLOR      
02662   } gavl_alpha_mode_t;
02663 
02670 typedef enum
02671   {
02672     GAVL_DEINTERLACE_NONE      = 0, 
02673     GAVL_DEINTERLACE_COPY      = 1, 
02674     GAVL_DEINTERLACE_SCALE     = 2, 
02675     GAVL_DEINTERLACE_BLEND     = 3  
02676   } gavl_deinterlace_mode_t;
02677 
02684 typedef enum
02685   {
02686     GAVL_DEINTERLACE_DROP_TOP,    
02687     GAVL_DEINTERLACE_DROP_BOTTOM, 
02688   } gavl_deinterlace_drop_mode_t;
02689   
02694 typedef enum
02695   {
02696     GAVL_SCALE_AUTO,          
02697     GAVL_SCALE_NEAREST,       
02698     GAVL_SCALE_BILINEAR,      
02699     GAVL_SCALE_QUADRATIC,     
02700     GAVL_SCALE_CUBIC_BSPLINE, 
02701     GAVL_SCALE_CUBIC_MITCHELL,
02702     GAVL_SCALE_CUBIC_CATMULL, 
02703     GAVL_SCALE_SINC_LANCZOS,  
02704     GAVL_SCALE_NONE,          
02705   } gavl_scale_mode_t;
02706 
02716 typedef enum
02717   {
02718     GAVL_DOWNSCALE_FILTER_AUTO = 0, 
02719     GAVL_DOWNSCALE_FILTER_NONE, 
02720     GAVL_DOWNSCALE_FILTER_WIDE, 
02721     GAVL_DOWNSCALE_FILTER_GAUSS, 
02722   } gavl_downscale_filter_t;
02723   
02730 typedef struct gavl_video_options_s gavl_video_options_t;
02731 
02732 /* Default Options */
02733 
02739 GAVL_PUBLIC
02740 void gavl_video_options_set_defaults(gavl_video_options_t * opt);
02741 
02751 GAVL_PUBLIC
02752 gavl_video_options_t * gavl_video_options_create();
02753 
02760 GAVL_PUBLIC
02761 void gavl_video_options_copy(gavl_video_options_t * dst,
02762                              const gavl_video_options_t * src);
02763 
02769 GAVL_PUBLIC
02770 void gavl_video_options_destroy(gavl_video_options_t * opt);
02771   
02772   
02787 GAVL_PUBLIC
02788 void gavl_video_options_set_rectangles(gavl_video_options_t * opt,
02789                                        const gavl_rectangle_f_t * src_rect,
02790                                        const gavl_rectangle_i_t * dst_rect);
02791 
02799 GAVL_PUBLIC
02800 void gavl_video_options_get_rectangles(gavl_video_options_t * opt,
02801                                        gavl_rectangle_f_t * src_rect,
02802                                        gavl_rectangle_i_t * dst_rect);
02803   
02810 GAVL_PUBLIC
02811 void gavl_video_options_set_quality(gavl_video_options_t * opt, int quality);
02812 
02819 GAVL_PUBLIC
02820 int gavl_video_options_get_quality(gavl_video_options_t * opt);
02821 
02822   
02829 GAVL_PUBLIC
02830 void gavl_video_options_set_conversion_flags(gavl_video_options_t * opt,
02831                                              int conversion_flags);
02832 
02839 GAVL_PUBLIC
02840 int gavl_video_options_get_conversion_flags(gavl_video_options_t * opt);
02841   
02848 GAVL_PUBLIC
02849 void gavl_video_options_set_alpha_mode(gavl_video_options_t * opt,
02850                                        gavl_alpha_mode_t alpha_mode);
02851 
02858 GAVL_PUBLIC gavl_alpha_mode_t
02859 gavl_video_options_get_alpha_mode(gavl_video_options_t * opt);
02860 
02861   
02868 GAVL_PUBLIC
02869 void gavl_video_options_set_scale_mode(gavl_video_options_t * opt,
02870                                        gavl_scale_mode_t scale_mode);
02871 
02878 GAVL_PUBLIC gavl_scale_mode_t
02879 gavl_video_options_get_scale_mode(gavl_video_options_t * opt);
02880 
02881   
02888 GAVL_PUBLIC
02889 void gavl_video_options_set_scale_order(gavl_video_options_t * opt,
02890                                         int order);
02891 
02898 GAVL_PUBLIC
02899 int gavl_video_options_get_scale_order(gavl_video_options_t * opt);
02900 
02901   
02908 GAVL_PUBLIC
02909 void gavl_video_options_set_background_color(gavl_video_options_t * opt,
02910                                              const float * color);
02911 
02918 GAVL_PUBLIC
02919 void gavl_video_options_get_background_color(gavl_video_options_t * opt,
02920                                              float * color);
02921   
02928 GAVL_PUBLIC
02929 void gavl_video_options_set_deinterlace_mode(gavl_video_options_t * opt,
02930                                              gavl_deinterlace_mode_t deinterlace_mode);
02931 
02938 GAVL_PUBLIC gavl_deinterlace_mode_t
02939 gavl_video_options_get_deinterlace_mode(gavl_video_options_t * opt);
02940 
02947 GAVL_PUBLIC
02948 void gavl_video_options_set_deinterlace_drop_mode(gavl_video_options_t * opt,
02949                                                   gavl_deinterlace_drop_mode_t deinterlace_drop_mode);
02950 
02957 GAVL_PUBLIC gavl_deinterlace_drop_mode_t
02958 gavl_video_options_get_deinterlace_drop_mode(gavl_video_options_t * opt);
02959 
02968 GAVL_PUBLIC
02969 void gavl_video_options_set_downscale_filter(gavl_video_options_t * opt,
02970                                              gavl_downscale_filter_t f);
02971   
02972 
02981 GAVL_PUBLIC gavl_downscale_filter_t
02982 gavl_video_options_get_downscale_filter(gavl_video_options_t * opt);
02983 
03001 GAVL_PUBLIC
03002 void gavl_video_options_set_downscale_blur(gavl_video_options_t * opt,
03003                                            float f);
03004 
03013 GAVL_PUBLIC
03014 float gavl_video_options_get_downscale_blur(gavl_video_options_t * opt);
03015 
03024 GAVL_PUBLIC
03025 void gavl_video_options_set_num_threads(gavl_video_options_t * opt, int n);
03026 
03027   
03036 GAVL_PUBLIC
03037 int gavl_video_options_get_num_threads(gavl_video_options_t * opt);
03038 
03048 GAVL_PUBLIC
03049 void gavl_video_options_set_run_func(gavl_video_options_t * opt,
03050                                      gavl_video_run_func func,
03051                                      void * client_data);
03052 
03062 GAVL_PUBLIC
03063 gavl_video_run_func gavl_video_options_get_run_func(gavl_video_options_t * opt,
03064                                                     void ** client_data);
03065 
03075 GAVL_PUBLIC
03076 void gavl_video_options_set_stop_func(gavl_video_options_t * opt,
03077                                       gavl_video_stop_func func, 
03078                                       void * client_data);
03079 
03089 GAVL_PUBLIC
03090 gavl_video_stop_func gavl_video_options_get_stop_func(gavl_video_options_t * opt,
03091                                                       void ** client_data);
03092 
03093   
03094 /***************************************************
03095  * Create and destroy video converters
03096  ***************************************************/
03097   
03130 typedef struct gavl_video_converter_s gavl_video_converter_t;
03131 
03137 GAVL_PUBLIC
03138 gavl_video_converter_t * gavl_video_converter_create();
03139 
03145 GAVL_PUBLIC
03146 void gavl_video_converter_destroy(gavl_video_converter_t*cnv);
03147 
03148 /**************************************************
03149  * Get options. Change the options with the gavl_video_options_set_*
03150  * functions above
03151  **************************************************/
03152 
03161 GAVL_PUBLIC gavl_video_options_t *
03162 gavl_video_converter_get_options(gavl_video_converter_t*cnv);
03163 
03164 
03178 GAVL_PUBLIC
03179 int gavl_video_converter_init(gavl_video_converter_t* cnv,
03180                               const gavl_video_format_t * input_format,
03181                               const gavl_video_format_t * output_format);
03182 
03195 GAVL_PUBLIC
03196 int gavl_video_converter_reinit(gavl_video_converter_t* cnv);
03197  
03198   
03199 /***************************************************
03200  * Convert a frame
03201  ***************************************************/
03202 
03210 GAVL_PUBLIC
03211 void gavl_video_convert(gavl_video_converter_t * cnv,
03212                         const gavl_video_frame_t * input_frame,
03213                         gavl_video_frame_t * output_frame);
03214 
03246 typedef struct gavl_video_scaler_s gavl_video_scaler_t;
03247 
03253 GAVL_PUBLIC
03254 gavl_video_scaler_t * gavl_video_scaler_create();
03255 
03261 GAVL_PUBLIC
03262 void gavl_video_scaler_destroy(gavl_video_scaler_t * scaler);
03263 
03272 GAVL_PUBLIC gavl_video_options_t *
03273 gavl_video_scaler_get_options(gavl_video_scaler_t * scaler);
03274 
03287 GAVL_PUBLIC
03288 int gavl_video_scaler_init(gavl_video_scaler_t * scaler,
03289                            const gavl_video_format_t * src_format,
03290                            const gavl_video_format_t * dst_format);
03291 
03313 GAVL_PUBLIC
03314 int gavl_video_scaler_init_convolve(gavl_video_scaler_t * scaler,
03315                                     const gavl_video_format_t * format,
03316                                     int h_radius, const float * h_coeffs,
03317                                     int v_radius, const float * v_coeffs);
03318   
03326 GAVL_PUBLIC
03327 void gavl_video_scaler_scale(gavl_video_scaler_t * scaler,
03328                              const gavl_video_frame_t * input_frame,
03329                              gavl_video_frame_t * output_frame);
03330 
03346 typedef struct gavl_video_deinterlacer_s gavl_video_deinterlacer_t;
03347 
03353 GAVL_PUBLIC
03354 gavl_video_deinterlacer_t * gavl_video_deinterlacer_create();
03355 
03361 GAVL_PUBLIC
03362 void gavl_video_deinterlacer_destroy(gavl_video_deinterlacer_t * deinterlacer);
03363 
03372 GAVL_PUBLIC gavl_video_options_t *
03373 gavl_video_deinterlacer_get_options(gavl_video_deinterlacer_t * deinterlacer);
03374 
03385 GAVL_PUBLIC
03386 int gavl_video_deinterlacer_init(gavl_video_deinterlacer_t * deinterlacer,
03387                                  const gavl_video_format_t * src_format);
03388 
03389   
03397 GAVL_PUBLIC
03398 void gavl_video_deinterlacer_deinterlace(gavl_video_deinterlacer_t * deinterlacer,
03399                                          const gavl_video_frame_t * input_frame,
03400                                          gavl_video_frame_t * output_frame);
03401 
03402   
03403   
03404 /**************************************************
03405  * Transparent overlays 
03406  **************************************************/
03407 
03408 /* Overlay struct */
03409 
03437 typedef struct
03438   {
03439   gavl_video_frame_t * frame;    
03440   gavl_rectangle_i_t ovl_rect;   
03441   int dst_x;                     
03442   int dst_y;                     
03443   } gavl_overlay_t;
03444 
03451 typedef struct gavl_overlay_blend_context_s gavl_overlay_blend_context_t;
03452 
03458 GAVL_PUBLIC
03459 gavl_overlay_blend_context_t * gavl_overlay_blend_context_create();
03460 
03466 GAVL_PUBLIC
03467 void gavl_overlay_blend_context_destroy(gavl_overlay_blend_context_t * ctx);
03468 
03475 GAVL_PUBLIC gavl_video_options_t *
03476 gavl_overlay_blend_context_get_options(gavl_overlay_blend_context_t * ctx);
03477 
03493 GAVL_PUBLIC
03494 int gavl_overlay_blend_context_init(gavl_overlay_blend_context_t * ctx,
03495                                     const gavl_video_format_t * frame_format,
03496                                     gavl_video_format_t * overlay_format);
03497 
03507 GAVL_PUBLIC
03508 void gavl_overlay_blend_context_set_overlay(gavl_overlay_blend_context_t * ctx,
03509                                             gavl_overlay_t * ovl);
03510 
03517 GAVL_PUBLIC
03518 void gavl_overlay_blend(gavl_overlay_blend_context_t * ctx,
03519                         gavl_video_frame_t * dst_frame);
03520   
03542 typedef struct gavl_image_transform_s gavl_image_transform_t;
03543 
03557 typedef void (*gavl_image_transform_func)(void * priv,
03558                                           double xdst,
03559                                           double ydst,
03560                                           double * xsrc,
03561                                           double * ysrc);
03562 
03563 
03570 GAVL_PUBLIC
03571 gavl_image_transform_t * gavl_image_transform_create();
03572 
03578 GAVL_PUBLIC
03579 void gavl_image_transform_destroy(gavl_image_transform_t * t);
03580 
03599 GAVL_PUBLIC
03600 int gavl_image_transform_init(gavl_image_transform_t * t,
03601                               gavl_video_format_t * format,
03602                               gavl_image_transform_func func, void * priv);
03603 
03611 GAVL_PUBLIC
03612 void gavl_image_transform_transform(gavl_image_transform_t * t,
03613                                     gavl_video_frame_t * in_frame,
03614                                     gavl_video_frame_t * out_frame);
03615 
03626 GAVL_PUBLIC gavl_video_options_t *
03627 gavl_image_transform_get_options(gavl_image_transform_t * t);
03628   
03651 typedef struct
03652   {
03653   int64_t offset; 
03654   /* Primary */
03655   int64_t num_entries; 
03656   int64_t entries_alloc; 
03657   
03658   struct
03659     {
03660     int64_t num_frames; 
03661     int64_t duration;   
03662     } * entries;        
03663   
03664   int num_timecodes; 
03665   int timecodes_alloc; 
03666 
03667   struct
03668     {
03669     int64_t pts;          
03670     gavl_timecode_t tc;   
03671     } * timecodes;        
03672   
03673   /* Secondary */
03674   
03675   } gavl_frame_table_t;
03676 
03682 GAVL_PUBLIC gavl_frame_table_t * gavl_frame_table_create();
03683 
03694 GAVL_PUBLIC gavl_frame_table_t *
03695 gavl_frame_table_create_audio(int samplerate, int64_t offset, int64_t duration,
03696                               gavl_timecode_format_t * fmt_ret);
03697 
03709 GAVL_PUBLIC gavl_frame_table_t *
03710 gavl_frame_table_create_cfr(int64_t offset, int64_t frame_duration,
03711                             int64_t num_frames,
03712                             gavl_timecode_t start_timecode);
03713   
03721 GAVL_PUBLIC gavl_frame_table_t *
03722 gavl_frame_table_copy(const gavl_frame_table_t * tab);
03723 
03724 
03725   
03732 GAVL_PUBLIC void gavl_frame_table_destroy(gavl_frame_table_t * t);
03733 
03741 GAVL_PUBLIC void gavl_frame_table_append_entry(gavl_frame_table_t * t, int64_t duration);
03742 
03751 GAVL_PUBLIC void
03752 gavl_frame_table_append_timecode(gavl_frame_table_t * t,
03753                                  int64_t pts, gavl_timecode_t tc);
03754 
03765 GAVL_PUBLIC int64_t
03766 gavl_frame_table_frame_to_time(const gavl_frame_table_t * t,
03767                                int64_t frame, int * duration);
03768 
03779 GAVL_PUBLIC int64_t
03780 gavl_frame_table_time_to_frame(const gavl_frame_table_t * t,
03781                                int64_t time,
03782                                int64_t * start_time);
03783 
03794 GAVL_PUBLIC gavl_timecode_t
03795 gavl_frame_table_time_to_timecode(const gavl_frame_table_t * t,
03796                                   int64_t time,
03797                                   int64_t * start_time,
03798                                   const gavl_timecode_format_t * fmt);
03799 
03809 GAVL_PUBLIC int64_t
03810 gavl_frame_table_timecode_to_time(const gavl_frame_table_t * t,
03811                                   gavl_timecode_t tc,
03812                                   const gavl_timecode_format_t * fmt);
03813 
03814 
03825 GAVL_PUBLIC gavl_timecode_t
03826 gavl_frame_table_frame_to_timecode(const gavl_frame_table_t * t,
03827                                    int64_t frame,
03828                                    int64_t * start_time,
03829                                    const gavl_timecode_format_t * fmt);
03830 
03831   
03832   
03840 GAVL_PUBLIC int64_t
03841 gavl_frame_table_num_frames(const gavl_frame_table_t * t);
03842 
03850 GAVL_PUBLIC int64_t
03851 gavl_frame_table_duration(const gavl_frame_table_t * t);
03852 
03860 GAVL_PUBLIC int64_t
03861 gavl_frame_table_end_time(const gavl_frame_table_t * t);
03862   
03871 GAVL_PUBLIC
03872 int gavl_frame_table_save(const gavl_frame_table_t * tab,
03873                           const char * filename);
03874 
03882 GAVL_PUBLIC
03883 gavl_frame_table_t * gavl_frame_table_load(const char * filename);
03884   
03891 GAVL_PUBLIC void
03892 gavl_frame_table_dump(const gavl_frame_table_t * t);
03893 
03894 
03895   
03896 
03897   
03898   
03904 #ifdef __cplusplus
03905 }
03906 #endif
03907 
03908 #endif /* GAVL_H_INCLUDED */
Generated on Tue Sep 14 14:39:15 2010 for gavl by  doxygen 1.6.3