gavl.h

Go to the documentation of this file.
00001 /*****************************************************************
00002  * gavl - a general purpose audio/video processing library
00003  *
00004  * Copyright (c) 2001 - 2008 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 #ifdef HAVE_GAVLCONFIG_H
00032 #include <gavlconfig.h>
00033 #endif
00034 
00035 #include "gavltime.h"
00036 
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040 
00045 typedef struct gavl_video_format_s gavl_video_format_t;
00046 
00047 /* Quality levels */
00048   
00072 #define GAVL_QUALITY_FASTEST 1
00073 
00080 #define GAVL_QUALITY_BEST    5 
00081 
00088 #define GAVL_QUALITY_DEFAULT 2 
00089 
00101 #define GAVL_ACCEL_MMX      (1<<0) 
00102 #define GAVL_ACCEL_MMXEXT   (1<<1) 
00103 #define GAVL_ACCEL_SSE      (1<<2) 
00104 #define GAVL_ACCEL_SSE2     (1<<3) 
00105 #define GAVL_ACCEL_SSE3     (1<<4) 
00106 #define GAVL_ACCEL_3DNOW    (1<<5) 
00107 #define GAVL_ACCEL_3DNOWEXT (1<<6) 
00108 #define GAVL_ACCEL_SSSE3    (1<<7) 
00109 
00110 
00114 int gavl_accel_supported();
00115 
00124 /* Sample formats: all multibyte numbers are native endian */
00125 
00138 #define GAVL_MAX_CHANNELS 128
00139   
00146 typedef enum
00147   {
00148     GAVL_SAMPLE_NONE   = 0, 
00149     GAVL_SAMPLE_U8     = 1, 
00150     GAVL_SAMPLE_S8     = 2, 
00151     GAVL_SAMPLE_U16    = 3, 
00152     GAVL_SAMPLE_S16    = 4, 
00153     GAVL_SAMPLE_S32    = 5, 
00154     GAVL_SAMPLE_FLOAT  = 6,  
00155     GAVL_SAMPLE_DOUBLE = 7  
00156   } gavl_sample_format_t;
00157 
00163 typedef enum
00164   {
00165     GAVL_INTERLEAVE_NONE = 0, 
00166     GAVL_INTERLEAVE_2    = 1, 
00167     GAVL_INTERLEAVE_ALL  = 2  
00168   } gavl_interleave_mode_t;
00169 
00177 typedef enum
00178   {
00179     GAVL_CHID_NONE         = 0,   
00180     GAVL_CHID_FRONT_CENTER,       
00181     GAVL_CHID_FRONT_LEFT,         
00182     GAVL_CHID_FRONT_RIGHT,        
00183     GAVL_CHID_FRONT_CENTER_LEFT,  
00184     GAVL_CHID_FRONT_CENTER_RIGHT, 
00185     GAVL_CHID_REAR_LEFT,          
00186     GAVL_CHID_REAR_RIGHT,         
00187     GAVL_CHID_REAR_CENTER,        
00188     GAVL_CHID_SIDE_LEFT,          
00189     GAVL_CHID_SIDE_RIGHT,         
00190     GAVL_CHID_LFE,                
00191     GAVL_CHID_AUX,                
00192   } gavl_channel_id_t;
00193 
00202 typedef struct 
00203   {
00204   int samples_per_frame;  
00205   int samplerate;         
00206   int num_channels;         
00207   gavl_sample_format_t   sample_format; 
00208   gavl_interleave_mode_t interleave_mode; 
00210   float center_level; 
00211   float rear_level;   
00213   gavl_channel_id_t channel_locations[GAVL_MAX_CHANNELS];   
00215   } gavl_audio_format_t;
00216 
00217   
00218 /* Audio format -> string conversions */
00219 
00227 const char * gavl_sample_format_to_string(gavl_sample_format_t format);
00228 
00237 gavl_sample_format_t gavl_string_to_sample_format(const char * str);
00238 
00244 int gavl_num_sample_formats();
00245 
00252 gavl_sample_format_t gavl_get_sample_format(int index);
00253   
00260 const char * gavl_channel_id_to_string(gavl_channel_id_t id);
00261 
00262 
00269 const char * gavl_interleave_mode_to_string(gavl_interleave_mode_t mode);
00270 
00277 void gavl_audio_format_dump(const gavl_audio_format_t * format);
00278 
00287 int gavl_channel_index(const gavl_audio_format_t * format, gavl_channel_id_t id);
00288 
00295 int gavl_front_channels(const gavl_audio_format_t * format);
00296 
00303 int gavl_rear_channels(const gavl_audio_format_t * format);
00304 
00311 int gavl_side_channels(const gavl_audio_format_t * format);
00312 
00319 int gavl_aux_channels(const gavl_audio_format_t * format);
00320 
00321   
00322   
00329 int gavl_lfe_channels(const gavl_audio_format_t * format);
00330 
00338 void gavl_audio_format_copy(gavl_audio_format_t * dst,
00339                             const gavl_audio_format_t * src);
00340 
00349 int gavl_audio_formats_equal(const gavl_audio_format_t * format_1,
00350                               const gavl_audio_format_t * format_2);
00351 
00363 void gavl_set_channel_setup(gavl_audio_format_t * format);
00364 
00371 int gavl_bytes_per_sample(gavl_sample_format_t format);
00372 
00387 typedef union 
00388   {
00389   uint8_t * u_8; 
00390   int8_t *  s_8; 
00392   uint16_t * u_16; 
00393   int16_t  * s_16; 
00395   uint32_t * u_32; 
00396   int32_t  * s_32; 
00398   float * f; 
00399   double * d; 
00400   } gavl_audio_samples_t;
00401 
00407 typedef union
00408   {
00409   uint8_t * u_8[GAVL_MAX_CHANNELS];
00410   int8_t *  s_8[GAVL_MAX_CHANNELS];
00412   uint16_t * u_16[GAVL_MAX_CHANNELS];
00413   int16_t  * s_16[GAVL_MAX_CHANNELS];
00415   uint32_t * u_32[GAVL_MAX_CHANNELS];
00416   int32_t  * s_32[GAVL_MAX_CHANNELS];
00418   float * f[GAVL_MAX_CHANNELS];
00419   double * d[GAVL_MAX_CHANNELS];
00421   } gavl_audio_channels_t;
00422 
00439 typedef struct 
00440   {
00441   gavl_audio_samples_t  samples; 
00442   gavl_audio_channels_t channels;
00443   int valid_samples;             
00444   int64_t timestamp;             
00445   int channel_stride;            
00446   } gavl_audio_frame_t;
00447 
00459 gavl_audio_frame_t * gavl_audio_frame_create(const gavl_audio_format_t* format);
00460 
00472 void gavl_audio_frame_null(gavl_audio_frame_t * frame);
00473 
00483 void gavl_audio_frame_destroy(gavl_audio_frame_t * frame);
00484 
00494 void gavl_audio_frame_mute(gavl_audio_frame_t * frame,
00495                            const gavl_audio_format_t * format);
00496 
00507 void gavl_audio_frame_mute_samples(gavl_audio_frame_t * frame,
00508                                    const gavl_audio_format_t * format,
00509                                    int num_samples);
00510 
00511   
00512   
00523 void gavl_audio_frame_mute_channel(gavl_audio_frame_t * frame,
00524                                    const gavl_audio_format_t * format,
00525                                    int channel);
00526   
00547 int gavl_audio_frame_copy(const gavl_audio_format_t * format,
00548                           gavl_audio_frame_t * dst,
00549                           const gavl_audio_frame_t * src,
00550                           int dst_pos,
00551                           int src_pos,
00552                           int dst_size,
00553                           int src_size);
00554 
00569 #define GAVL_AUDIO_FRONT_TO_REAR_COPY (1<<0) 
00574 #define GAVL_AUDIO_FRONT_TO_REAR_MUTE (1<<1) 
00579 #define GAVL_AUDIO_FRONT_TO_REAR_DIFF (1<<2) 
00584 #define GAVL_AUDIO_FRONT_TO_REAR_MASK           \
00585 (GAVL_AUDIO_FRONT_TO_REAR_COPY | \
00586 GAVL_AUDIO_FRONT_TO_REAR_MUTE | \
00587  GAVL_AUDIO_FRONT_TO_REAR_DIFF) 
00589 /* Options for mixing stereo to mono */
00590   
00593 #define GAVL_AUDIO_STEREO_TO_MONO_LEFT  (1<<3) 
00596 #define GAVL_AUDIO_STEREO_TO_MONO_RIGHT (1<<4) 
00599 #define GAVL_AUDIO_STEREO_TO_MONO_MIX   (1<<5) 
00603 #define GAVL_AUDIO_STEREO_TO_MONO_MASK \
00604 (GAVL_AUDIO_STEREO_TO_MONO_LEFT | \
00605 GAVL_AUDIO_STEREO_TO_MONO_RIGHT | \
00606 GAVL_AUDIO_STEREO_TO_MONO_MIX) 
00612 typedef enum
00613   {
00614     GAVL_AUDIO_DITHER_NONE   = 0,
00615     GAVL_AUDIO_DITHER_AUTO   = 1,
00616     GAVL_AUDIO_DITHER_RECT   = 2,
00617     GAVL_AUDIO_DITHER_TRI    = 3,
00618     GAVL_AUDIO_DITHER_SHAPED = 4,
00619   } gavl_audio_dither_mode_t;
00620 
00625 typedef enum
00626   {
00627     GAVL_RESAMPLE_AUTO        = 0, 
00628     GAVL_RESAMPLE_ZOH         = 1, 
00629     GAVL_RESAMPLE_LINEAR      = 2, 
00630     GAVL_RESAMPLE_SINC_FAST   = 3, 
00631     GAVL_RESAMPLE_SINC_MEDIUM = 4, 
00632     GAVL_RESAMPLE_SINC_BEST   = 5  
00633   } gavl_resample_mode_t;
00634   
00641 typedef struct gavl_audio_options_s gavl_audio_options_t;
00642 
00649 void gavl_audio_options_set_quality(gavl_audio_options_t * opt, int quality);
00650 
00657 int gavl_audio_options_get_quality(gavl_audio_options_t * opt);
00658   
00665 void gavl_audio_options_set_dither_mode(gavl_audio_options_t * opt, gavl_audio_dither_mode_t mode);
00666 
00673 gavl_audio_dither_mode_t gavl_audio_options_get_dither_mode(gavl_audio_options_t * opt);
00674 
00675   
00682 void gavl_audio_options_set_resample_mode(gavl_audio_options_t * opt, gavl_resample_mode_t mode);
00683 
00690 gavl_resample_mode_t gavl_audio_options_get_resample_mode(gavl_audio_options_t * opt);
00691   
00698 void gavl_audio_options_set_conversion_flags(gavl_audio_options_t * opt,
00699                                              int flags);
00700   
00707 int gavl_audio_options_get_conversion_flags(gavl_audio_options_t * opt);
00708 
00714 void gavl_audio_options_set_defaults(gavl_audio_options_t * opt);
00715 
00725 gavl_audio_options_t * gavl_audio_options_create();
00726 
00733 void gavl_audio_options_copy(gavl_audio_options_t * dst,
00734                              const gavl_audio_options_t * src);
00735 
00741 void gavl_audio_options_destroy(gavl_audio_options_t * opt);
00742   
00743   
00744   
00745 /* Audio converter */
00746 
00780 typedef struct gavl_audio_converter_s gavl_audio_converter_t;
00781   
00787 gavl_audio_converter_t * gavl_audio_converter_create();
00788 
00794 void gavl_audio_converter_destroy(gavl_audio_converter_t* cnv);
00795 
00804 gavl_audio_options_t * gavl_audio_converter_get_options(gavl_audio_converter_t*cnv);
00805 
00806 
00820 int gavl_audio_converter_init(gavl_audio_converter_t* cnv,
00821                               const gavl_audio_format_t * input_format,
00822                               const gavl_audio_format_t * output_format);
00823 
00837 int gavl_audio_converter_reinit(gavl_audio_converter_t* cnv);
00838 
00839   
00853 void gavl_audio_convert(gavl_audio_converter_t * cnv,
00854                         const gavl_audio_frame_t * input_frame,
00855                         gavl_audio_frame_t * output_frame);
00856 
00857 
00858 
00859 
00873 typedef struct gavl_volume_control_s gavl_volume_control_t;
00874   
00875 /* Create / destroy */
00876 
00882 gavl_volume_control_t * gavl_volume_control_create();
00883 
00889 void gavl_volume_control_destroy(gavl_volume_control_t *ctrl);
00890 
00898 void gavl_volume_control_set_format(gavl_volume_control_t *ctrl,
00899                                     const gavl_audio_format_t * format);
00900 
00907 void gavl_volume_control_set_volume(gavl_volume_control_t * ctrl,
00908                                     float volume);
00909 
00916 void gavl_volume_control_apply(gavl_volume_control_t *ctrl,
00917                                gavl_audio_frame_t * frame);
00918 
00934 typedef struct gavl_peak_detector_s gavl_peak_detector_t;
00935   
00936 /* Create / destroy */
00937 
00943 gavl_peak_detector_t * gavl_peak_detector_create();
00944 
00950 void gavl_peak_detector_destroy(gavl_peak_detector_t *pd);
00951 
00961 void gavl_peak_detector_set_format(gavl_peak_detector_t *pd,
00962                                    const gavl_audio_format_t * format);
00963 
00970 void gavl_peak_detector_update(gavl_peak_detector_t *pd,
00971                               gavl_audio_frame_t * frame);
00972   
00985 void gavl_peak_detector_get_peak(gavl_peak_detector_t * pd,
00986                                  double * min, double * max,
00987                                  double * abs);
00988 
01001 void gavl_peak_detector_get_peaks(gavl_peak_detector_t * pd,
01002                                   double * min, double * max,
01003                                   double * abs);
01004   
01010 void gavl_peak_detector_reset(gavl_peak_detector_t * pd);
01011   
01021 #define GAVL_MAX_PLANES 4 
01033 typedef struct
01034   {
01035   int x; 
01036   int y; 
01037   int w; 
01038   int h; 
01039   } gavl_rectangle_i_t;
01040 
01045 typedef struct
01046   {
01047   double x; 
01048   double y; 
01049   double w; 
01050   double h; 
01051   } gavl_rectangle_f_t;
01052 
01059 void gavl_rectangle_i_crop_to_format(gavl_rectangle_i_t * r,
01060                                    const gavl_video_format_t * format);
01061 
01068 void gavl_rectangle_f_crop_to_format(gavl_rectangle_f_t * r,
01069                                      const gavl_video_format_t * format);
01070 
01085 void gavl_rectangle_crop_to_format_noscale(gavl_rectangle_i_t * src_rect,
01086                                            gavl_rectangle_i_t * dst_rect,
01087                                            const gavl_video_format_t * src_format,
01088                                            const gavl_video_format_t * dst_format);
01089 
01101 void gavl_rectangle_crop_to_format_scale(gavl_rectangle_f_t * src_rect,
01102                                          gavl_rectangle_i_t * dst_rect,
01103                                          const gavl_video_format_t * src_format,
01104                                          const gavl_video_format_t * dst_format);
01105 
01106   
01107 
01114 void gavl_rectangle_i_set_all(gavl_rectangle_i_t * r, const gavl_video_format_t * format);
01115 
01122 void gavl_rectangle_f_set_all(gavl_rectangle_f_t * r, const gavl_video_format_t * format);
01123 
01130 void gavl_rectangle_i_crop_left(gavl_rectangle_i_t * r,   int num_pixels);
01131 
01138 void gavl_rectangle_i_crop_right(gavl_rectangle_i_t * r,  int num_pixels);
01139 
01146 void gavl_rectangle_i_crop_top(gavl_rectangle_i_t * r,    int num_pixels);
01147 
01154 void gavl_rectangle_i_crop_bottom(gavl_rectangle_i_t * r, int num_pixels);
01155 
01162 void gavl_rectangle_f_crop_left(gavl_rectangle_f_t * r,   double num_pixels);
01163 
01170 void gavl_rectangle_f_crop_right(gavl_rectangle_f_t * r,  double num_pixels);
01171 
01178 void gavl_rectangle_f_crop_top(gavl_rectangle_f_t * r,    double num_pixels);
01179 
01186 void gavl_rectangle_f_crop_bottom(gavl_rectangle_f_t * r, double num_pixels);
01187 
01201 void gavl_rectangle_i_align(gavl_rectangle_i_t * r, int h_align, int v_align);
01202 
01212 void gavl_rectangle_i_align_to_format(gavl_rectangle_i_t * r,
01213                                       const gavl_video_format_t * format);
01214 
01215   
01222 void gavl_rectangle_i_copy(gavl_rectangle_i_t * dst, const gavl_rectangle_i_t * src);
01223 
01230 void gavl_rectangle_f_copy(gavl_rectangle_f_t * dst, const gavl_rectangle_f_t * src);
01231 
01232 
01233 
01240 void gavl_rectangle_i_to_f(gavl_rectangle_f_t * dst, const gavl_rectangle_i_t * src);
01241 
01248 void gavl_rectangle_f_to_i(gavl_rectangle_i_t * dst, const gavl_rectangle_f_t * src);
01249   
01258 int gavl_rectangle_i_is_empty(const gavl_rectangle_i_t * r);
01259 
01268 int gavl_rectangle_f_is_empty(const gavl_rectangle_f_t * r);
01269 
01297 void gavl_rectangle_fit_aspect(gavl_rectangle_i_t * dst_rect,
01298                                const gavl_video_format_t * src_format,
01299                                const gavl_rectangle_f_t * src_rect,
01300                                const gavl_video_format_t * dst_format,
01301                                float zoom, float squeeze);
01302 
01307 void gavl_rectangle_i_dump(const gavl_rectangle_i_t * r);
01308 
01313 void gavl_rectangle_f_dump(const gavl_rectangle_f_t * r);
01314 
01315   
01325 #define GAVL_PIXFMT_PLANAR (1<<8)
01326 
01330 #define GAVL_PIXFMT_RGB    (1<<9)
01331 
01335 #define GAVL_PIXFMT_YUV    (1<<10)
01336 
01340 #define GAVL_PIXFMT_YUVJ   (1<<11)
01341 
01345 #define GAVL_PIXFMT_ALPHA  (1<<12)
01346 
01350 #define GAVL_PIXFMT_GRAY   (1<<13)
01351   
01356 typedef enum 
01357   {
01360     GAVL_PIXELFORMAT_NONE =  0, 
01361 
01364     GAVL_GRAY_8          =  1 | GAVL_PIXFMT_GRAY,
01365 
01368     GAVL_GRAY_16          =  2 | GAVL_PIXFMT_GRAY,
01369     
01372     GAVL_GRAY_FLOAT       =  3 | GAVL_PIXFMT_GRAY,
01373     
01376     GAVL_GRAYA_16          =  1 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
01377 
01380     GAVL_GRAYA_32          =  2 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
01381     
01384     GAVL_GRAYA_FLOAT       =  3 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
01385     
01389     GAVL_RGB_15          =  1 | GAVL_PIXFMT_RGB,
01393     GAVL_BGR_15          =  2 | GAVL_PIXFMT_RGB,
01397     GAVL_RGB_16          =  3 | GAVL_PIXFMT_RGB,
01401     GAVL_BGR_16          =  4 | GAVL_PIXFMT_RGB,
01404     GAVL_RGB_24          =  5 | GAVL_PIXFMT_RGB,
01407     GAVL_BGR_24          =  6 | GAVL_PIXFMT_RGB,
01410     GAVL_RGB_32          =  7 | GAVL_PIXFMT_RGB,
01413     GAVL_BGR_32          =  8 | GAVL_PIXFMT_RGB,
01416     GAVL_RGBA_32         =  9 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA,
01417 
01420     GAVL_RGB_48       = 10 | GAVL_PIXFMT_RGB,
01423     GAVL_RGBA_64      = 11 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA,
01424         
01427     GAVL_RGB_FLOAT    = 12 | GAVL_PIXFMT_RGB,
01430     GAVL_RGBA_FLOAT   = 13 | GAVL_PIXFMT_RGB  | GAVL_PIXFMT_ALPHA,
01431 
01434     GAVL_YUY2            = 1 | GAVL_PIXFMT_YUV,
01437     GAVL_UYVY            = 2 | GAVL_PIXFMT_YUV,
01440     GAVL_YUVA_32         = 3 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
01443     GAVL_YUVA_64         = 4 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
01446     GAVL_YUV_FLOAT       = 5 | GAVL_PIXFMT_YUV,
01447 
01450     GAVL_YUVA_FLOAT       = 6 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
01451     
01455     GAVL_YUV_420_P       = 1 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01458     GAVL_YUV_422_P       = 2 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01461     GAVL_YUV_444_P       = 3 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01464     GAVL_YUV_411_P       = 4 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01467     GAVL_YUV_410_P       = 5 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01468     
01471     GAVL_YUVJ_420_P      = 6 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
01474     GAVL_YUVJ_422_P      = 7 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
01477     GAVL_YUVJ_444_P      = 8 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
01478 
01481     GAVL_YUV_444_P_16 = 9 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01484     GAVL_YUV_422_P_16 = 10 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01485     
01486   } gavl_pixelformat_t;
01487 
01490 #define GAVL_PIXELFORMAT_1D_8 GAVL_GRAY_8
01491 
01493 #define GAVL_PIXELFORMAT_2D_8 GAVL_GRAYA_16
01494 
01496 #define GAVL_PIXELFORMAT_3D_8 GAVL_RGB_24
01497 
01499 #define GAVL_PIXELFORMAT_4D_8 GAVL_RGBA_32
01500 
01503 #define GAVL_PIXELFORMAT_1D_16 GAVL_GRAY_16
01504 
01506 #define GAVL_PIXELFORMAT_2D_16 GAVL_GRAYA_32
01507 
01509 #define GAVL_PIXELFORMAT_3D_16 GAVL_RGB_48
01510 
01512 #define GAVL_PIXELFORMAT_4D_16 GAVL_RGBA_64
01513 
01516 #define GAVL_PIXELFORMAT_1D_FLOAT GAVL_GRAY_FLOAT
01517 
01519 #define GAVL_PIXELFORMAT_2D_FLOAT GAVL_GRAYA_FLOAT
01520 
01522 #define GAVL_PIXELFORMAT_3D_FLOAT GAVL_RGB_FLOAT
01523 
01525 #define GAVL_PIXELFORMAT_4D_FLOAT GAVL_RGBA_FLOAT
01526 
01527   
01528 /*
01529  *  Colormodel related functions
01530  */
01531 
01538 #define gavl_pixelformat_is_gray(fmt) ((fmt) & GAVL_PIXFMT_GRAY)
01539 
01540   
01547 #define gavl_pixelformat_is_rgb(fmt) ((fmt) & GAVL_PIXFMT_RGB)
01548 
01555 #define gavl_pixelformat_is_yuv(fmt) ((fmt) & GAVL_PIXFMT_YUV)
01556 
01563 #define gavl_pixelformat_is_jpeg_scaled(fmt) ((fmt) & GAVL_PIXFMT_YUVJ)
01564 
01571 #define gavl_pixelformat_has_alpha(fmt) ((fmt) & GAVL_PIXFMT_ALPHA)
01572 
01579 #define  gavl_pixelformat_is_planar(fmt) ((fmt) & GAVL_PIXFMT_PLANAR)
01580 
01587 int gavl_pixelformat_num_planes(gavl_pixelformat_t pixelformat);
01588 
01598 void gavl_pixelformat_chroma_sub(gavl_pixelformat_t pixelformat, int * sub_h, int * sub_v);
01599 
01606 int gavl_pixelformat_bytes_per_component(gavl_pixelformat_t pixelformat);
01607 
01614 int gavl_pixelformat_bytes_per_pixel(gavl_pixelformat_t pixelformat);
01615   
01622 int gavl_pixelformat_bits_per_pixel(gavl_pixelformat_t pixelformat);
01623 
01638 int gavl_pixelformat_conversion_penalty(gavl_pixelformat_t src,
01639                                         gavl_pixelformat_t dst);
01640 
01654 gavl_pixelformat_t 
01655 gavl_pixelformat_get_best(gavl_pixelformat_t src,
01656                           const gavl_pixelformat_t * dst_supported,
01657                           int * penalty);
01658   
01659 
01660 
01667 const char * gavl_pixelformat_to_string(gavl_pixelformat_t pixelformat);
01668 
01675 gavl_pixelformat_t gavl_string_to_pixelformat(const char * name);
01676 
01682 int gavl_num_pixelformats();
01683 
01690 gavl_pixelformat_t gavl_get_pixelformat(int index);
01691 
01692 /*  */
01693 
01702 typedef enum
01703   {
01704     GAVL_CHROMA_PLACEMENT_DEFAULT = 0, 
01705     GAVL_CHROMA_PLACEMENT_MPEG2,       
01706     GAVL_CHROMA_PLACEMENT_DVPAL        
01707   } gavl_chroma_placement_t;
01708 
01715 const char * gavl_chroma_placement_to_string(gavl_chroma_placement_t mode);
01716   
01721 typedef enum
01722   {
01723     GAVL_FRAMERATE_CONSTANT    = 0, 
01724     GAVL_FRAMERATE_VARIABLE    = 1, 
01725     GAVL_FRAMERATE_STILL       = 2, 
01726   } gavl_framerate_mode_t;
01727 
01732 typedef enum
01733   {
01734     GAVL_INTERLACE_NONE = 0,    
01735     GAVL_INTERLACE_TOP_FIRST,   
01736     GAVL_INTERLACE_BOTTOM_FIRST,
01737     GAVL_INTERLACE_MIXED        
01738   } gavl_interlace_mode_t;
01739 
01746 const char * gavl_interlace_mode_to_string(gavl_interlace_mode_t mode);
01747   
01748   
01749 /* Video format structure */
01750   
01755 struct gavl_video_format_s
01756   {
01757   int frame_width;
01758   int frame_height;
01760   int image_width;
01761   int image_height;
01763   /* Support for nonsquare pixels */
01764     
01765   int pixel_width;
01766   int pixel_height;
01768   gavl_pixelformat_t pixelformat;
01770   int frame_duration;
01772   int timescale;
01774   gavl_framerate_mode_t   framerate_mode;
01775   gavl_chroma_placement_t chroma_placement;
01777   gavl_interlace_mode_t   interlace_mode;
01778   };
01779 
01787 void gavl_video_format_copy(gavl_video_format_t * dst,
01788                             const gavl_video_format_t * src);
01789 
01798 int gavl_video_formats_equal(const gavl_video_format_t * format_1,
01799                              const gavl_video_format_t * format_2);
01800 
01801   
01812 void gavl_video_format_get_chroma_offset(const gavl_video_format_t * format, int field, int plane,
01813                                          float * off_x, float * off_y);
01814   
01815 
01816   
01823 void gavl_video_format_dump(const gavl_video_format_t * format);
01824 
01837 void gavl_video_format_fit_to_source(gavl_video_format_t * dst,
01838                                      const gavl_video_format_t * src);
01839 
01840   
01863 typedef struct
01864   {
01865   uint8_t * planes[GAVL_MAX_PLANES]; 
01866   int strides[GAVL_MAX_PLANES];      
01868   void * user_data;    
01869   int64_t timestamp; 
01870   int64_t duration; 
01871   gavl_interlace_mode_t   interlace_mode;
01872   } gavl_video_frame_t;
01873 
01874 
01886 gavl_video_frame_t * gavl_video_frame_create(const gavl_video_format_t*format);
01887 
01898 gavl_video_frame_t * gavl_video_frame_create_nopad(const gavl_video_format_t*format);
01899 
01900   
01901 
01911 void gavl_video_frame_destroy(gavl_video_frame_t*frame);
01912 
01924 void gavl_video_frame_null(gavl_video_frame_t*frame);
01925   
01934 void gavl_video_frame_clear(gavl_video_frame_t * frame,
01935                             const gavl_video_format_t * format);
01936 
01946 void gavl_video_frame_fill(gavl_video_frame_t * frame,
01947                            const gavl_video_format_t * format,
01948                            float * color);
01949 
01950   
01963 void gavl_video_frame_copy(const gavl_video_format_t * format,
01964                            gavl_video_frame_t * dst,
01965                            const gavl_video_frame_t * src);
01966 
01979 void gavl_video_frame_copy_plane(const gavl_video_format_t * format,
01980                                  gavl_video_frame_t * dst,
01981                                  const gavl_video_frame_t * src, int plane);
01982 
01994 void gavl_video_frame_copy_flip_x(const gavl_video_format_t * format,
01995                                   gavl_video_frame_t * dst,
01996                                   const gavl_video_frame_t * src);
01997 
02009 void gavl_video_frame_copy_flip_y(const gavl_video_format_t * format,
02010                                   gavl_video_frame_t * dst,
02011                                   const gavl_video_frame_t * src);
02012 
02024 void gavl_video_frame_copy_flip_xy(const gavl_video_format_t * format,
02025                                    gavl_video_frame_t * dst,
02026                                   const gavl_video_frame_t * src);
02027 
02045 void gavl_video_frame_get_subframe(gavl_pixelformat_t pixelformat,
02046                                    const gavl_video_frame_t * src,
02047                                    gavl_video_frame_t * dst,
02048                                    gavl_rectangle_i_t * src_rect);
02049 
02065 void gavl_video_frame_get_field(gavl_pixelformat_t pixelformat,
02066                                 const gavl_video_frame_t * src,
02067                                 gavl_video_frame_t * dst,
02068                                 int field);
02069 
02070   
02071 
02084 void gavl_video_frame_dump(gavl_video_frame_t * frame,
02085                            const gavl_video_format_t * format,
02086                            const char * namebase);
02087   
02088 /*****************************
02089  Conversion options
02090 ******************************/
02091 
02107 #define GAVL_FORCE_DEINTERLACE (1<<0)
02108 
02113 #define GAVL_CONVOLVE_CHROMA   (1<<1)
02114 
02119 #define GAVL_CONVOLVE_NORMALIZE (1<<2)
02120 
02128 #define GAVL_RESAMPLE_CHROMA    (1<<3)
02129   
02137 typedef enum
02138   {
02139     GAVL_ALPHA_IGNORE      = 0, 
02140     GAVL_ALPHA_BLEND_COLOR      
02141   } gavl_alpha_mode_t;
02142 
02149 typedef enum
02150   {
02151     GAVL_DEINTERLACE_NONE      = 0, 
02152     GAVL_DEINTERLACE_COPY      = 1, 
02153     GAVL_DEINTERLACE_SCALE     = 2, 
02154     GAVL_DEINTERLACE_BLEND     = 3  
02155   } gavl_deinterlace_mode_t;
02156 
02163 typedef enum
02164   {
02165     GAVL_DEINTERLACE_DROP_TOP,    
02166     GAVL_DEINTERLACE_DROP_BOTTOM, 
02167   } gavl_deinterlace_drop_mode_t;
02168   
02173 typedef enum
02174   {
02175     GAVL_SCALE_AUTO,          
02176     GAVL_SCALE_NEAREST,       
02177     GAVL_SCALE_BILINEAR,      
02178     GAVL_SCALE_QUADRATIC,     
02179     GAVL_SCALE_CUBIC_BSPLINE, 
02180     GAVL_SCALE_CUBIC_MITCHELL,
02181     GAVL_SCALE_CUBIC_CATMULL, 
02182     GAVL_SCALE_SINC_LANCZOS,  
02183     GAVL_SCALE_NONE,          
02184   } gavl_scale_mode_t;
02185 
02192 typedef struct gavl_video_options_s gavl_video_options_t;
02193 
02194 /* Default Options */
02195 
02201 void gavl_video_options_set_defaults(gavl_video_options_t * opt);
02202 
02212 gavl_video_options_t * gavl_video_options_create();
02213 
02220 void gavl_video_options_copy(gavl_video_options_t * dst,
02221                              const gavl_video_options_t * src);
02222 
02228 void gavl_video_options_destroy(gavl_video_options_t * opt);
02229   
02230   
02245 void gavl_video_options_set_rectangles(gavl_video_options_t * opt,
02246                                        const gavl_rectangle_f_t * src_rect,
02247                                        const gavl_rectangle_i_t * dst_rect);
02248 
02255 void gavl_video_options_get_rectangles(gavl_video_options_t * opt,
02256                                        gavl_rectangle_f_t * src_rect,
02257                                        gavl_rectangle_i_t * dst_rect);
02258   
02265 void gavl_video_options_set_quality(gavl_video_options_t * opt, int quality);
02266 
02273 int gavl_video_options_get_quality(gavl_video_options_t * opt);
02274 
02275   
02282 void gavl_video_options_set_conversion_flags(gavl_video_options_t * opt,
02283                                              int conversion_flags);
02284 
02291 int gavl_video_options_get_conversion_flags(gavl_video_options_t * opt);
02292   
02299 void gavl_video_options_set_alpha_mode(gavl_video_options_t * opt,
02300                                        gavl_alpha_mode_t alpha_mode);
02301 
02308 gavl_alpha_mode_t
02309 gavl_video_options_get_alpha_mode(gavl_video_options_t * opt);
02310 
02311   
02318 void gavl_video_options_set_scale_mode(gavl_video_options_t * opt,
02319                                        gavl_scale_mode_t scale_mode);
02320 
02327 gavl_scale_mode_t
02328 gavl_video_options_get_scale_mode(gavl_video_options_t * opt);
02329 
02330   
02337 void gavl_video_options_set_scale_order(gavl_video_options_t * opt,
02338                                         int order);
02339 
02346 int gavl_video_options_get_scale_order(gavl_video_options_t * opt);
02347 
02348   
02355 void gavl_video_options_set_background_color(gavl_video_options_t * opt,
02356                                              const float * color);
02357 
02364 void gavl_video_options_get_background_color(gavl_video_options_t * opt,
02365                                              float * color);
02366   
02373 void gavl_video_options_set_deinterlace_mode(gavl_video_options_t * opt,
02374                                              gavl_deinterlace_mode_t deinterlace_mode);
02375 
02382 gavl_deinterlace_mode_t
02383 gavl_video_options_get_deinterlace_mode(gavl_video_options_t * opt);
02384 
02391 void gavl_video_options_set_deinterlace_drop_mode(gavl_video_options_t * opt,
02392                                                   gavl_deinterlace_drop_mode_t deinterlace_drop_mode);
02393 
02400 gavl_deinterlace_drop_mode_t
02401 gavl_video_options_get_deinterlace_drop_mode(gavl_video_options_t * opt);
02402  
02403   
02404 /***************************************************
02405  * Create and destroy video converters
02406  ***************************************************/
02407   
02440 typedef struct gavl_video_converter_s gavl_video_converter_t;
02441 
02447 gavl_video_converter_t * gavl_video_converter_create();
02448 
02454 void gavl_video_converter_destroy(gavl_video_converter_t*cnv);
02455 
02456 /**************************************************
02457  * Get options. Change the options with the gavl_video_options_set_*
02458  * functions above
02459  **************************************************/
02460 
02469 gavl_video_options_t *
02470 gavl_video_converter_get_options(gavl_video_converter_t*cnv);
02471 
02472 
02486 int gavl_video_converter_init(gavl_video_converter_t* cnv,
02487                               const gavl_video_format_t * input_format,
02488                               const gavl_video_format_t * output_format);
02489 
02502 int gavl_video_converter_reinit(gavl_video_converter_t* cnv);
02503  
02504   
02505 /***************************************************
02506  * Convert a frame
02507  ***************************************************/
02508 
02516 void gavl_video_convert(gavl_video_converter_t * cnv,
02517                         const gavl_video_frame_t * input_frame,
02518                         gavl_video_frame_t * output_frame);
02519 
02551 typedef struct gavl_video_scaler_s gavl_video_scaler_t;
02552 
02558 gavl_video_scaler_t * gavl_video_scaler_create();
02559 
02565 void gavl_video_scaler_destroy(gavl_video_scaler_t * scaler);
02566 
02575 gavl_video_options_t *
02576 gavl_video_scaler_get_options(gavl_video_scaler_t * scaler);
02577 
02590 int gavl_video_scaler_init(gavl_video_scaler_t * scaler,
02591                            const gavl_video_format_t * src_format,
02592                            const gavl_video_format_t * dst_format);
02593 
02615 int gavl_video_scaler_init_convolve(gavl_video_scaler_t * scaler,
02616                                     const gavl_video_format_t * format,
02617                                     int h_radius, float * h_coeffs,
02618                                     int v_radius, float * v_coeffs);
02619   
02627 void gavl_video_scaler_scale(gavl_video_scaler_t * scaler,
02628                              const gavl_video_frame_t * input_frame,
02629                              gavl_video_frame_t * output_frame);
02630 
02646 typedef struct gavl_video_deinterlacer_s gavl_video_deinterlacer_t;
02647 
02653 gavl_video_deinterlacer_t * gavl_video_deinterlacer_create();
02654 
02660 void gavl_video_deinterlacer_destroy(gavl_video_deinterlacer_t * deinterlacer);
02661 
02670 gavl_video_options_t *
02671 gavl_video_deinterlacer_get_options(gavl_video_deinterlacer_t * deinterlacer);
02672 
02683 int gavl_video_deinterlacer_init(gavl_video_deinterlacer_t * deinterlacer,
02684                                  const gavl_video_format_t * src_format);
02685 
02686   
02694 void gavl_video_deinterlacer_deinterlace(gavl_video_deinterlacer_t * deinterlacer,
02695                                          const gavl_video_frame_t * input_frame,
02696                                          gavl_video_frame_t * output_frame);
02697 
02698   
02699   
02700 /**************************************************
02701  * Transparent overlays 
02702  **************************************************/
02703 
02704 /* Overlay struct */
02705 
02733 typedef struct
02734   {
02735   gavl_video_frame_t * frame;    
02736   gavl_rectangle_i_t ovl_rect;   
02737   int dst_x;                     
02738   int dst_y;                     
02739   } gavl_overlay_t;
02740 
02747 typedef struct gavl_overlay_blend_context_s gavl_overlay_blend_context_t;
02748 
02754 gavl_overlay_blend_context_t * gavl_overlay_blend_context_create();
02755 
02761 void gavl_overlay_blend_context_destroy(gavl_overlay_blend_context_t * ctx);
02762 
02769 gavl_video_options_t *
02770 gavl_overlay_blend_context_get_options(gavl_overlay_blend_context_t * ctx);
02771 
02787 int gavl_overlay_blend_context_init(gavl_overlay_blend_context_t * ctx,
02788                                     const gavl_video_format_t * frame_format,
02789                                     gavl_video_format_t * overlay_format);
02790 
02800 void gavl_overlay_blend_context_set_overlay(gavl_overlay_blend_context_t * ctx,
02801                                             gavl_overlay_t * ovl);
02802 
02809 void gavl_overlay_blend(gavl_overlay_blend_context_t * ctx,
02810                         gavl_video_frame_t * dst_frame);
02811   
02812 #ifdef __cplusplus
02813 }
02814 #endif
02815 
02816 #endif /* GAVL_H_INCLUDED */

Generated on Tue Jul 22 09:25:27 2008 for gavl by  doxygen 1.5.6