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 
00032 #include "gavltime.h"
00033 
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037 
00042 typedef struct gavl_video_format_s gavl_video_format_t;
00043 
00044 #include "timecode.h"
00045   
00046 /* Quality levels */
00047   
00071 #define GAVL_QUALITY_FASTEST 1
00072 
00079 #define GAVL_QUALITY_BEST    5 
00080 
00087 #define GAVL_QUALITY_DEFAULT 2 
00088 
00100 #define GAVL_ACCEL_MMX      (1<<0) 
00101 #define GAVL_ACCEL_MMXEXT   (1<<1) 
00102 #define GAVL_ACCEL_SSE      (1<<2) 
00103 #define GAVL_ACCEL_SSE2     (1<<3) 
00104 #define GAVL_ACCEL_SSE3     (1<<4) 
00105 #define GAVL_ACCEL_3DNOW    (1<<5) 
00106 #define GAVL_ACCEL_3DNOWEXT (1<<6) 
00107 #define GAVL_ACCEL_SSSE3    (1<<7) 
00108 
00109 
00113 int gavl_accel_supported();
00114 
00123 /* Sample formats: all multibyte numbers are native endian */
00124 
00137 #define GAVL_MAX_CHANNELS 128
00138   
00145 typedef enum
00146   {
00147     GAVL_SAMPLE_NONE   = 0, 
00148     GAVL_SAMPLE_U8     = 1, 
00149     GAVL_SAMPLE_S8     = 2, 
00150     GAVL_SAMPLE_U16    = 3, 
00151     GAVL_SAMPLE_S16    = 4, 
00152     GAVL_SAMPLE_S32    = 5, 
00153     GAVL_SAMPLE_FLOAT  = 6,  
00154     GAVL_SAMPLE_DOUBLE = 7  
00155   } gavl_sample_format_t;
00156 
00162 typedef enum
00163   {
00164     GAVL_INTERLEAVE_NONE = 0, 
00165     GAVL_INTERLEAVE_2    = 1, 
00166     GAVL_INTERLEAVE_ALL  = 2  
00167   } gavl_interleave_mode_t;
00168 
00176 typedef enum
00177   {
00178     GAVL_CHID_NONE         = 0,   
00179     GAVL_CHID_FRONT_CENTER,       
00180     GAVL_CHID_FRONT_LEFT,         
00181     GAVL_CHID_FRONT_RIGHT,        
00182     GAVL_CHID_FRONT_CENTER_LEFT,  
00183     GAVL_CHID_FRONT_CENTER_RIGHT, 
00184     GAVL_CHID_REAR_LEFT,          
00185     GAVL_CHID_REAR_RIGHT,         
00186     GAVL_CHID_REAR_CENTER,        
00187     GAVL_CHID_SIDE_LEFT,          
00188     GAVL_CHID_SIDE_RIGHT,         
00189     GAVL_CHID_LFE,                
00190     GAVL_CHID_AUX,                
00191   } gavl_channel_id_t;
00192 
00201 typedef struct 
00202   {
00203   int samples_per_frame;  
00204   int samplerate;         
00205   int num_channels;         
00206   gavl_sample_format_t   sample_format; 
00207   gavl_interleave_mode_t interleave_mode; 
00209   float center_level; 
00210   float rear_level;   
00212   gavl_channel_id_t channel_locations[GAVL_MAX_CHANNELS];   
00214   } gavl_audio_format_t;
00215 
00216   
00217 /* Audio format -> string conversions */
00218 
00226 const char * gavl_sample_format_to_string(gavl_sample_format_t format);
00227 
00236 gavl_sample_format_t gavl_string_to_sample_format(const char * str);
00237 
00243 int gavl_num_sample_formats();
00244 
00251 gavl_sample_format_t gavl_get_sample_format(int index);
00252   
00259 const char * gavl_channel_id_to_string(gavl_channel_id_t id);
00260 
00261 
00268 const char * gavl_interleave_mode_to_string(gavl_interleave_mode_t mode);
00269 
00276 void gavl_audio_format_dump(const gavl_audio_format_t * format);
00277 
00286 int gavl_channel_index(const gavl_audio_format_t * format, gavl_channel_id_t id);
00287 
00294 int gavl_front_channels(const gavl_audio_format_t * format);
00295 
00302 int gavl_rear_channels(const gavl_audio_format_t * format);
00303 
00310 int gavl_side_channels(const gavl_audio_format_t * format);
00311 
00318 int gavl_aux_channels(const gavl_audio_format_t * format);
00319 
00320   
00321   
00328 int gavl_lfe_channels(const gavl_audio_format_t * format);
00329 
00337 void gavl_audio_format_copy(gavl_audio_format_t * dst,
00338                             const gavl_audio_format_t * src);
00339 
00348 int gavl_audio_formats_equal(const gavl_audio_format_t * format_1,
00349                               const gavl_audio_format_t * format_2);
00350 
00362 void gavl_set_channel_setup(gavl_audio_format_t * format);
00363 
00370 int gavl_bytes_per_sample(gavl_sample_format_t format);
00371 
00386 typedef union 
00387   {
00388   uint8_t * u_8; 
00389   int8_t *  s_8; 
00391   uint16_t * u_16; 
00392   int16_t  * s_16; 
00394   uint32_t * u_32; 
00395   int32_t  * s_32; 
00397   float * f; 
00398   double * d; 
00399   } gavl_audio_samples_t;
00400 
00406 typedef union
00407   {
00408   uint8_t * u_8[GAVL_MAX_CHANNELS];
00409   int8_t *  s_8[GAVL_MAX_CHANNELS];
00411   uint16_t * u_16[GAVL_MAX_CHANNELS];
00412   int16_t  * s_16[GAVL_MAX_CHANNELS];
00414   uint32_t * u_32[GAVL_MAX_CHANNELS];
00415   int32_t  * s_32[GAVL_MAX_CHANNELS];
00417   float * f[GAVL_MAX_CHANNELS];
00418   double * d[GAVL_MAX_CHANNELS];
00420   } gavl_audio_channels_t;
00421 
00438 typedef struct 
00439   {
00440   gavl_audio_samples_t  samples; 
00441   gavl_audio_channels_t channels;
00442   int valid_samples;             
00443   int64_t timestamp;             
00444   int channel_stride;            
00445   } gavl_audio_frame_t;
00446 
00458 gavl_audio_frame_t * gavl_audio_frame_create(const gavl_audio_format_t* format);
00459 
00471 void gavl_audio_frame_null(gavl_audio_frame_t * frame);
00472 
00482 void gavl_audio_frame_destroy(gavl_audio_frame_t * frame);
00483 
00493 void gavl_audio_frame_mute(gavl_audio_frame_t * frame,
00494                            const gavl_audio_format_t * format);
00495 
00506 void gavl_audio_frame_mute_samples(gavl_audio_frame_t * frame,
00507                                    const gavl_audio_format_t * format,
00508                                    int num_samples);
00509 
00510   
00511   
00522 void gavl_audio_frame_mute_channel(gavl_audio_frame_t * frame,
00523                                    const gavl_audio_format_t * format,
00524                                    int channel);
00525   
00546 int gavl_audio_frame_copy(const gavl_audio_format_t * format,
00547                           gavl_audio_frame_t * dst,
00548                           const gavl_audio_frame_t * src,
00549                           int dst_pos,
00550                           int src_pos,
00551                           int dst_size,
00552                           int src_size);
00553 
00568 #define GAVL_AUDIO_FRONT_TO_REAR_COPY (1<<0) 
00573 #define GAVL_AUDIO_FRONT_TO_REAR_MUTE (1<<1) 
00578 #define GAVL_AUDIO_FRONT_TO_REAR_DIFF (1<<2) 
00583 #define GAVL_AUDIO_FRONT_TO_REAR_MASK           \
00584 (GAVL_AUDIO_FRONT_TO_REAR_COPY | \
00585 GAVL_AUDIO_FRONT_TO_REAR_MUTE | \
00586  GAVL_AUDIO_FRONT_TO_REAR_DIFF) 
00588 /* Options for mixing stereo to mono */
00589   
00592 #define GAVL_AUDIO_STEREO_TO_MONO_LEFT  (1<<3) 
00595 #define GAVL_AUDIO_STEREO_TO_MONO_RIGHT (1<<4) 
00598 #define GAVL_AUDIO_STEREO_TO_MONO_MIX   (1<<5) 
00602 #define GAVL_AUDIO_STEREO_TO_MONO_MASK \
00603 (GAVL_AUDIO_STEREO_TO_MONO_LEFT | \
00604 GAVL_AUDIO_STEREO_TO_MONO_RIGHT | \
00605 GAVL_AUDIO_STEREO_TO_MONO_MIX) 
00611 typedef enum
00612   {
00613     GAVL_AUDIO_DITHER_NONE   = 0,
00614     GAVL_AUDIO_DITHER_AUTO   = 1,
00615     GAVL_AUDIO_DITHER_RECT   = 2,
00616     GAVL_AUDIO_DITHER_TRI    = 3,
00617     GAVL_AUDIO_DITHER_SHAPED = 4,
00618   } gavl_audio_dither_mode_t;
00619 
00624 typedef enum
00625   {
00626     GAVL_RESAMPLE_AUTO        = 0, 
00627     GAVL_RESAMPLE_ZOH         = 1, 
00628     GAVL_RESAMPLE_LINEAR      = 2, 
00629     GAVL_RESAMPLE_SINC_FAST   = 3, 
00630     GAVL_RESAMPLE_SINC_MEDIUM = 4, 
00631     GAVL_RESAMPLE_SINC_BEST   = 5  
00632   } gavl_resample_mode_t;
00633   
00640 typedef struct gavl_audio_options_s gavl_audio_options_t;
00641 
00648 void gavl_audio_options_set_quality(gavl_audio_options_t * opt, int quality);
00649 
00656 int gavl_audio_options_get_quality(gavl_audio_options_t * opt);
00657   
00664 void gavl_audio_options_set_dither_mode(gavl_audio_options_t * opt, gavl_audio_dither_mode_t mode);
00665 
00672 gavl_audio_dither_mode_t gavl_audio_options_get_dither_mode(gavl_audio_options_t * opt);
00673 
00674   
00681 void gavl_audio_options_set_resample_mode(gavl_audio_options_t * opt, gavl_resample_mode_t mode);
00682 
00689 gavl_resample_mode_t gavl_audio_options_get_resample_mode(gavl_audio_options_t * opt);
00690   
00697 void gavl_audio_options_set_conversion_flags(gavl_audio_options_t * opt,
00698                                              int flags);
00699   
00706 int gavl_audio_options_get_conversion_flags(gavl_audio_options_t * opt);
00707 
00713 void gavl_audio_options_set_defaults(gavl_audio_options_t * opt);
00714 
00724 gavl_audio_options_t * gavl_audio_options_create();
00725 
00732 void gavl_audio_options_copy(gavl_audio_options_t * dst,
00733                              const gavl_audio_options_t * src);
00734 
00740 void gavl_audio_options_destroy(gavl_audio_options_t * opt);
00741   
00742   
00743   
00744 /* Audio converter */
00745 
00779 typedef struct gavl_audio_converter_s gavl_audio_converter_t;
00780   
00786 gavl_audio_converter_t * gavl_audio_converter_create();
00787 
00793 void gavl_audio_converter_destroy(gavl_audio_converter_t* cnv);
00794 
00803 gavl_audio_options_t * gavl_audio_converter_get_options(gavl_audio_converter_t*cnv);
00804 
00805 
00819 int gavl_audio_converter_init(gavl_audio_converter_t* cnv,
00820                               const gavl_audio_format_t * input_format,
00821                               const gavl_audio_format_t * output_format);
00822 
00836 int gavl_audio_converter_reinit(gavl_audio_converter_t* cnv);
00837 
00838   
00852 void gavl_audio_convert(gavl_audio_converter_t * cnv,
00853                         const gavl_audio_frame_t * input_frame,
00854                         gavl_audio_frame_t * output_frame);
00855 
00856 
00857 
00858 
00872 typedef struct gavl_volume_control_s gavl_volume_control_t;
00873   
00874 /* Create / destroy */
00875 
00881 gavl_volume_control_t * gavl_volume_control_create();
00882 
00888 void gavl_volume_control_destroy(gavl_volume_control_t *ctrl);
00889 
00897 void gavl_volume_control_set_format(gavl_volume_control_t *ctrl,
00898                                     const gavl_audio_format_t * format);
00899 
00906 void gavl_volume_control_set_volume(gavl_volume_control_t * ctrl,
00907                                     float volume);
00908 
00915 void gavl_volume_control_apply(gavl_volume_control_t *ctrl,
00916                                gavl_audio_frame_t * frame);
00917 
00933 typedef struct gavl_peak_detector_s gavl_peak_detector_t;
00934   
00935 /* Create / destroy */
00936 
00942 gavl_peak_detector_t * gavl_peak_detector_create();
00943 
00949 void gavl_peak_detector_destroy(gavl_peak_detector_t *pd);
00950 
00960 void gavl_peak_detector_set_format(gavl_peak_detector_t *pd,
00961                                    const gavl_audio_format_t * format);
00962 
00969 void gavl_peak_detector_update(gavl_peak_detector_t *pd,
00970                               gavl_audio_frame_t * frame);
00971   
00984 void gavl_peak_detector_get_peak(gavl_peak_detector_t * pd,
00985                                  double * min, double * max,
00986                                  double * abs);
00987 
01000 void gavl_peak_detector_get_peaks(gavl_peak_detector_t * pd,
01001                                   double * min, double * max,
01002                                   double * abs);
01003   
01009 void gavl_peak_detector_reset(gavl_peak_detector_t * pd);
01010   
01020 #define GAVL_MAX_PLANES 4 
01032 typedef struct
01033   {
01034   int x; 
01035   int y; 
01036   int w; 
01037   int h; 
01038   } gavl_rectangle_i_t;
01039 
01044 typedef struct
01045   {
01046   double x; 
01047   double y; 
01048   double w; 
01049   double h; 
01050   } gavl_rectangle_f_t;
01051 
01058 void gavl_rectangle_i_crop_to_format(gavl_rectangle_i_t * r,
01059                                    const gavl_video_format_t * format);
01060 
01067 void gavl_rectangle_f_crop_to_format(gavl_rectangle_f_t * r,
01068                                      const gavl_video_format_t * format);
01069 
01084 void gavl_rectangle_crop_to_format_noscale(gavl_rectangle_i_t * src_rect,
01085                                            gavl_rectangle_i_t * dst_rect,
01086                                            const gavl_video_format_t * src_format,
01087                                            const gavl_video_format_t * dst_format);
01088 
01100 void gavl_rectangle_crop_to_format_scale(gavl_rectangle_f_t * src_rect,
01101                                          gavl_rectangle_i_t * dst_rect,
01102                                          const gavl_video_format_t * src_format,
01103                                          const gavl_video_format_t * dst_format);
01104 
01105   
01106 
01113 void gavl_rectangle_i_set_all(gavl_rectangle_i_t * r, const gavl_video_format_t * format);
01114 
01121 void gavl_rectangle_f_set_all(gavl_rectangle_f_t * r, const gavl_video_format_t * format);
01122 
01129 void gavl_rectangle_i_crop_left(gavl_rectangle_i_t * r,   int num_pixels);
01130 
01137 void gavl_rectangle_i_crop_right(gavl_rectangle_i_t * r,  int num_pixels);
01138 
01145 void gavl_rectangle_i_crop_top(gavl_rectangle_i_t * r,    int num_pixels);
01146 
01153 void gavl_rectangle_i_crop_bottom(gavl_rectangle_i_t * r, int num_pixels);
01154 
01161 void gavl_rectangle_f_crop_left(gavl_rectangle_f_t * r,   double num_pixels);
01162 
01169 void gavl_rectangle_f_crop_right(gavl_rectangle_f_t * r,  double num_pixels);
01170 
01177 void gavl_rectangle_f_crop_top(gavl_rectangle_f_t * r,    double num_pixels);
01178 
01185 void gavl_rectangle_f_crop_bottom(gavl_rectangle_f_t * r, double num_pixels);
01186 
01200 void gavl_rectangle_i_align(gavl_rectangle_i_t * r, int h_align, int v_align);
01201 
01211 void gavl_rectangle_i_align_to_format(gavl_rectangle_i_t * r,
01212                                       const gavl_video_format_t * format);
01213 
01214   
01221 void gavl_rectangle_i_copy(gavl_rectangle_i_t * dst, const gavl_rectangle_i_t * src);
01222 
01229 void gavl_rectangle_f_copy(gavl_rectangle_f_t * dst, const gavl_rectangle_f_t * src);
01230 
01231 
01232 
01239 void gavl_rectangle_i_to_f(gavl_rectangle_f_t * dst, const gavl_rectangle_i_t * src);
01240 
01247 void gavl_rectangle_f_to_i(gavl_rectangle_i_t * dst, const gavl_rectangle_f_t * src);
01248   
01257 int gavl_rectangle_i_is_empty(const gavl_rectangle_i_t * r);
01258 
01267 int gavl_rectangle_f_is_empty(const gavl_rectangle_f_t * r);
01268 
01296 void gavl_rectangle_fit_aspect(gavl_rectangle_i_t * dst_rect,
01297                                const gavl_video_format_t * src_format,
01298                                const gavl_rectangle_f_t * src_rect,
01299                                const gavl_video_format_t * dst_format,
01300                                float zoom, float squeeze);
01301 
01306 void gavl_rectangle_i_dump(const gavl_rectangle_i_t * r);
01307 
01312 void gavl_rectangle_f_dump(const gavl_rectangle_f_t * r);
01313 
01314   
01324 #define GAVL_PIXFMT_PLANAR (1<<8)
01325 
01329 #define GAVL_PIXFMT_RGB    (1<<9)
01330 
01334 #define GAVL_PIXFMT_YUV    (1<<10)
01335 
01339 #define GAVL_PIXFMT_YUVJ   (1<<11)
01340 
01344 #define GAVL_PIXFMT_ALPHA  (1<<12)
01345 
01349 #define GAVL_PIXFMT_GRAY   (1<<13)
01350   
01355 typedef enum 
01356   {
01359     GAVL_PIXELFORMAT_NONE =  0, 
01360 
01363     GAVL_GRAY_8          =  1 | GAVL_PIXFMT_GRAY,
01364 
01367     GAVL_GRAY_16          =  2 | GAVL_PIXFMT_GRAY,
01368     
01371     GAVL_GRAY_FLOAT       =  3 | GAVL_PIXFMT_GRAY,
01372     
01375     GAVL_GRAYA_16          =  1 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
01376 
01379     GAVL_GRAYA_32          =  2 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
01380     
01383     GAVL_GRAYA_FLOAT       =  3 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
01384     
01388     GAVL_RGB_15          =  1 | GAVL_PIXFMT_RGB,
01392     GAVL_BGR_15          =  2 | GAVL_PIXFMT_RGB,
01396     GAVL_RGB_16          =  3 | GAVL_PIXFMT_RGB,
01400     GAVL_BGR_16          =  4 | GAVL_PIXFMT_RGB,
01403     GAVL_RGB_24          =  5 | GAVL_PIXFMT_RGB,
01406     GAVL_BGR_24          =  6 | GAVL_PIXFMT_RGB,
01409     GAVL_RGB_32          =  7 | GAVL_PIXFMT_RGB,
01412     GAVL_BGR_32          =  8 | GAVL_PIXFMT_RGB,
01415     GAVL_RGBA_32         =  9 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA,
01416 
01419     GAVL_RGB_48       = 10 | GAVL_PIXFMT_RGB,
01422     GAVL_RGBA_64      = 11 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA,
01423         
01426     GAVL_RGB_FLOAT    = 12 | GAVL_PIXFMT_RGB,
01429     GAVL_RGBA_FLOAT   = 13 | GAVL_PIXFMT_RGB  | GAVL_PIXFMT_ALPHA,
01430 
01433     GAVL_YUY2            = 1 | GAVL_PIXFMT_YUV,
01436     GAVL_UYVY            = 2 | GAVL_PIXFMT_YUV,
01439     GAVL_YUVA_32         = 3 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
01442     GAVL_YUVA_64         = 4 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
01445     GAVL_YUV_FLOAT       = 5 | GAVL_PIXFMT_YUV,
01446 
01449     GAVL_YUVA_FLOAT       = 6 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
01450     
01454     GAVL_YUV_420_P       = 1 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01457     GAVL_YUV_422_P       = 2 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01460     GAVL_YUV_444_P       = 3 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01463     GAVL_YUV_411_P       = 4 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01466     GAVL_YUV_410_P       = 5 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01467     
01470     GAVL_YUVJ_420_P      = 6 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
01473     GAVL_YUVJ_422_P      = 7 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
01476     GAVL_YUVJ_444_P      = 8 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
01477 
01480     GAVL_YUV_444_P_16 = 9 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01483     GAVL_YUV_422_P_16 = 10 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01484     
01485   } gavl_pixelformat_t;
01486 
01489 #define GAVL_PIXELFORMAT_1D_8 GAVL_GRAY_8
01490 
01492 #define GAVL_PIXELFORMAT_2D_8 GAVL_GRAYA_16
01493 
01495 #define GAVL_PIXELFORMAT_3D_8 GAVL_RGB_24
01496 
01498 #define GAVL_PIXELFORMAT_4D_8 GAVL_RGBA_32
01499 
01502 #define GAVL_PIXELFORMAT_1D_16 GAVL_GRAY_16
01503 
01505 #define GAVL_PIXELFORMAT_2D_16 GAVL_GRAYA_32
01506 
01508 #define GAVL_PIXELFORMAT_3D_16 GAVL_RGB_48
01509 
01511 #define GAVL_PIXELFORMAT_4D_16 GAVL_RGBA_64
01512 
01515 #define GAVL_PIXELFORMAT_1D_FLOAT GAVL_GRAY_FLOAT
01516 
01518 #define GAVL_PIXELFORMAT_2D_FLOAT GAVL_GRAYA_FLOAT
01519 
01521 #define GAVL_PIXELFORMAT_3D_FLOAT GAVL_RGB_FLOAT
01522 
01524 #define GAVL_PIXELFORMAT_4D_FLOAT GAVL_RGBA_FLOAT
01525 
01526   
01527 /*
01528  *  Colormodel related functions
01529  */
01530 
01537 #define gavl_pixelformat_is_gray(fmt) ((fmt) & GAVL_PIXFMT_GRAY)
01538 
01539   
01546 #define gavl_pixelformat_is_rgb(fmt) ((fmt) & GAVL_PIXFMT_RGB)
01547 
01554 #define gavl_pixelformat_is_yuv(fmt) ((fmt) & GAVL_PIXFMT_YUV)
01555 
01562 #define gavl_pixelformat_is_jpeg_scaled(fmt) ((fmt) & GAVL_PIXFMT_YUVJ)
01563 
01570 #define gavl_pixelformat_has_alpha(fmt) ((fmt) & GAVL_PIXFMT_ALPHA)
01571 
01578 #define  gavl_pixelformat_is_planar(fmt) ((fmt) & GAVL_PIXFMT_PLANAR)
01579 
01586 int gavl_pixelformat_num_planes(gavl_pixelformat_t pixelformat);
01587 
01597 void gavl_pixelformat_chroma_sub(gavl_pixelformat_t pixelformat, int * sub_h, int * sub_v);
01598 
01605 int gavl_pixelformat_bytes_per_component(gavl_pixelformat_t pixelformat);
01606 
01613 int gavl_pixelformat_bytes_per_pixel(gavl_pixelformat_t pixelformat);
01614   
01621 int gavl_pixelformat_bits_per_pixel(gavl_pixelformat_t pixelformat);
01622 
01637 int gavl_pixelformat_conversion_penalty(gavl_pixelformat_t src,
01638                                         gavl_pixelformat_t dst);
01639 
01653 gavl_pixelformat_t 
01654 gavl_pixelformat_get_best(gavl_pixelformat_t src,
01655                           const gavl_pixelformat_t * dst_supported,
01656                           int * penalty);
01657   
01658 
01659 
01666 const char * gavl_pixelformat_to_string(gavl_pixelformat_t pixelformat);
01667 
01674 gavl_pixelformat_t gavl_string_to_pixelformat(const char * name);
01675 
01681 int gavl_num_pixelformats();
01682 
01689 gavl_pixelformat_t gavl_get_pixelformat(int index);
01690 
01691 /*  */
01692 
01701 typedef enum
01702   {
01703     GAVL_CHROMA_PLACEMENT_DEFAULT = 0, 
01704     GAVL_CHROMA_PLACEMENT_MPEG2,       
01705     GAVL_CHROMA_PLACEMENT_DVPAL        
01706   } gavl_chroma_placement_t;
01707 
01714 const char * gavl_chroma_placement_to_string(gavl_chroma_placement_t mode);
01715   
01720 typedef enum
01721   {
01722     GAVL_FRAMERATE_CONSTANT    = 0, 
01723     GAVL_FRAMERATE_VARIABLE    = 1, 
01724     GAVL_FRAMERATE_STILL       = 2, 
01725   } gavl_framerate_mode_t;
01726 
01731 typedef enum
01732   {
01733     GAVL_INTERLACE_NONE = 0,    
01734     GAVL_INTERLACE_TOP_FIRST,   
01735     GAVL_INTERLACE_BOTTOM_FIRST,
01736     GAVL_INTERLACE_MIXED        
01737   } gavl_interlace_mode_t;
01738 
01745 const char * gavl_interlace_mode_to_string(gavl_interlace_mode_t mode);
01746   
01747   
01748 /* Video format structure */
01749   
01754 struct gavl_video_format_s
01755   {
01756   int frame_width;
01757   int frame_height;
01759   int image_width;
01760   int image_height;
01762   /* Support for nonsquare pixels */
01763     
01764   int pixel_width;
01765   int pixel_height;
01767   gavl_pixelformat_t pixelformat;
01769   int frame_duration;
01771   int timescale;
01773   gavl_framerate_mode_t   framerate_mode;
01774   gavl_chroma_placement_t chroma_placement;
01776   gavl_interlace_mode_t   interlace_mode;
01778   gavl_timecode_format_t  timecode_format;
01779   };
01780 
01788 void gavl_video_format_copy(gavl_video_format_t * dst,
01789                             const gavl_video_format_t * src);
01790 
01799 int gavl_video_formats_equal(const gavl_video_format_t * format_1,
01800                              const gavl_video_format_t * format_2);
01801 
01802   
01813 void gavl_video_format_get_chroma_offset(const gavl_video_format_t * format, int field, int plane,
01814                                          float * off_x, float * off_y);
01815   
01816 
01817   
01824 void gavl_video_format_dump(const gavl_video_format_t * format);
01825 
01838 void gavl_video_format_fit_to_source(gavl_video_format_t * dst,
01839                                      const gavl_video_format_t * src);
01840 
01841   
01864 typedef struct
01865   {
01866   uint8_t * planes[GAVL_MAX_PLANES]; 
01867   int strides[GAVL_MAX_PLANES];      
01869   void * user_data;    
01870   int64_t timestamp; 
01871   int64_t duration; 
01872   gavl_interlace_mode_t   interlace_mode;
01873   gavl_timecode_t timecode; 
01874   } gavl_video_frame_t;
01875 
01876 
01888 gavl_video_frame_t * gavl_video_frame_create(const gavl_video_format_t*format);
01889 
01900 gavl_video_frame_t * gavl_video_frame_create_nopad(const gavl_video_format_t*format);
01901 
01902   
01903 
01913 void gavl_video_frame_destroy(gavl_video_frame_t*frame);
01914 
01926 void gavl_video_frame_null(gavl_video_frame_t*frame);
01927   
01936 void gavl_video_frame_clear(gavl_video_frame_t * frame,
01937                             const gavl_video_format_t * format);
01938 
01948 void gavl_video_frame_fill(gavl_video_frame_t * frame,
01949                            const gavl_video_format_t * format,
01950                            float * color);
01951 
01952   
01966 void gavl_video_frame_copy(const gavl_video_format_t * format,
01967                            gavl_video_frame_t * dst,
01968                            const gavl_video_frame_t * src);
01969 
01982 void gavl_video_frame_copy_plane(const gavl_video_format_t * format,
01983                                  gavl_video_frame_t * dst,
01984                                  const gavl_video_frame_t * src, int plane);
01985 
01997 void gavl_video_frame_copy_flip_x(const gavl_video_format_t * format,
01998                                   gavl_video_frame_t * dst,
01999                                   const gavl_video_frame_t * src);
02000 
02012 void gavl_video_frame_copy_flip_y(const gavl_video_format_t * format,
02013                                   gavl_video_frame_t * dst,
02014                                   const gavl_video_frame_t * src);
02015 
02027 void gavl_video_frame_copy_flip_xy(const gavl_video_format_t * format,
02028                                    gavl_video_frame_t * dst,
02029                                   const gavl_video_frame_t * src);
02030 
02043 void gavl_video_frame_copy_metadata(gavl_video_frame_t * dst,
02044                                     const gavl_video_frame_t * src);
02045 
02046   
02064 void gavl_video_frame_get_subframe(gavl_pixelformat_t pixelformat,
02065                                    const gavl_video_frame_t * src,
02066                                    gavl_video_frame_t * dst,
02067                                    gavl_rectangle_i_t * src_rect);
02068 
02084 void gavl_video_frame_get_field(gavl_pixelformat_t pixelformat,
02085                                 const gavl_video_frame_t * src,
02086                                 gavl_video_frame_t * dst,
02087                                 int field);
02088 
02089   
02090 
02103 void gavl_video_frame_dump(gavl_video_frame_t * frame,
02104                            const gavl_video_format_t * format,
02105                            const char * namebase);
02106   
02107 /*****************************
02108  Conversion options
02109 ******************************/
02110 
02126 #define GAVL_FORCE_DEINTERLACE (1<<0)
02127 
02132 #define GAVL_CONVOLVE_CHROMA   (1<<1)
02133 
02138 #define GAVL_CONVOLVE_NORMALIZE (1<<2)
02139 
02147 #define GAVL_RESAMPLE_CHROMA    (1<<3)
02148   
02156 typedef enum
02157   {
02158     GAVL_ALPHA_IGNORE      = 0, 
02159     GAVL_ALPHA_BLEND_COLOR      
02160   } gavl_alpha_mode_t;
02161 
02168 typedef enum
02169   {
02170     GAVL_DEINTERLACE_NONE      = 0, 
02171     GAVL_DEINTERLACE_COPY      = 1, 
02172     GAVL_DEINTERLACE_SCALE     = 2, 
02173     GAVL_DEINTERLACE_BLEND     = 3  
02174   } gavl_deinterlace_mode_t;
02175 
02182 typedef enum
02183   {
02184     GAVL_DEINTERLACE_DROP_TOP,    
02185     GAVL_DEINTERLACE_DROP_BOTTOM, 
02186   } gavl_deinterlace_drop_mode_t;
02187   
02192 typedef enum
02193   {
02194     GAVL_SCALE_AUTO,          
02195     GAVL_SCALE_NEAREST,       
02196     GAVL_SCALE_BILINEAR,      
02197     GAVL_SCALE_QUADRATIC,     
02198     GAVL_SCALE_CUBIC_BSPLINE, 
02199     GAVL_SCALE_CUBIC_MITCHELL,
02200     GAVL_SCALE_CUBIC_CATMULL, 
02201     GAVL_SCALE_SINC_LANCZOS,  
02202     GAVL_SCALE_NONE,          
02203   } gavl_scale_mode_t;
02204 
02211 typedef struct gavl_video_options_s gavl_video_options_t;
02212 
02213 /* Default Options */
02214 
02220 void gavl_video_options_set_defaults(gavl_video_options_t * opt);
02221 
02231 gavl_video_options_t * gavl_video_options_create();
02232 
02239 void gavl_video_options_copy(gavl_video_options_t * dst,
02240                              const gavl_video_options_t * src);
02241 
02247 void gavl_video_options_destroy(gavl_video_options_t * opt);
02248   
02249   
02264 void gavl_video_options_set_rectangles(gavl_video_options_t * opt,
02265                                        const gavl_rectangle_f_t * src_rect,
02266                                        const gavl_rectangle_i_t * dst_rect);
02267 
02274 void gavl_video_options_get_rectangles(gavl_video_options_t * opt,
02275                                        gavl_rectangle_f_t * src_rect,
02276                                        gavl_rectangle_i_t * dst_rect);
02277   
02284 void gavl_video_options_set_quality(gavl_video_options_t * opt, int quality);
02285 
02292 int gavl_video_options_get_quality(gavl_video_options_t * opt);
02293 
02294   
02301 void gavl_video_options_set_conversion_flags(gavl_video_options_t * opt,
02302                                              int conversion_flags);
02303 
02310 int gavl_video_options_get_conversion_flags(gavl_video_options_t * opt);
02311   
02318 void gavl_video_options_set_alpha_mode(gavl_video_options_t * opt,
02319                                        gavl_alpha_mode_t alpha_mode);
02320 
02327 gavl_alpha_mode_t
02328 gavl_video_options_get_alpha_mode(gavl_video_options_t * opt);
02329 
02330   
02337 void gavl_video_options_set_scale_mode(gavl_video_options_t * opt,
02338                                        gavl_scale_mode_t scale_mode);
02339 
02346 gavl_scale_mode_t
02347 gavl_video_options_get_scale_mode(gavl_video_options_t * opt);
02348 
02349   
02356 void gavl_video_options_set_scale_order(gavl_video_options_t * opt,
02357                                         int order);
02358 
02365 int gavl_video_options_get_scale_order(gavl_video_options_t * opt);
02366 
02367   
02374 void gavl_video_options_set_background_color(gavl_video_options_t * opt,
02375                                              const float * color);
02376 
02383 void gavl_video_options_get_background_color(gavl_video_options_t * opt,
02384                                              float * color);
02385   
02392 void gavl_video_options_set_deinterlace_mode(gavl_video_options_t * opt,
02393                                              gavl_deinterlace_mode_t deinterlace_mode);
02394 
02401 gavl_deinterlace_mode_t
02402 gavl_video_options_get_deinterlace_mode(gavl_video_options_t * opt);
02403 
02410 void gavl_video_options_set_deinterlace_drop_mode(gavl_video_options_t * opt,
02411                                                   gavl_deinterlace_drop_mode_t deinterlace_drop_mode);
02412 
02419 gavl_deinterlace_drop_mode_t
02420 gavl_video_options_get_deinterlace_drop_mode(gavl_video_options_t * opt);
02421  
02422   
02423 /***************************************************
02424  * Create and destroy video converters
02425  ***************************************************/
02426   
02459 typedef struct gavl_video_converter_s gavl_video_converter_t;
02460 
02466 gavl_video_converter_t * gavl_video_converter_create();
02467 
02473 void gavl_video_converter_destroy(gavl_video_converter_t*cnv);
02474 
02475 /**************************************************
02476  * Get options. Change the options with the gavl_video_options_set_*
02477  * functions above
02478  **************************************************/
02479 
02488 gavl_video_options_t *
02489 gavl_video_converter_get_options(gavl_video_converter_t*cnv);
02490 
02491 
02505 int gavl_video_converter_init(gavl_video_converter_t* cnv,
02506                               const gavl_video_format_t * input_format,
02507                               const gavl_video_format_t * output_format);
02508 
02521 int gavl_video_converter_reinit(gavl_video_converter_t* cnv);
02522  
02523   
02524 /***************************************************
02525  * Convert a frame
02526  ***************************************************/
02527 
02535 void gavl_video_convert(gavl_video_converter_t * cnv,
02536                         const gavl_video_frame_t * input_frame,
02537                         gavl_video_frame_t * output_frame);
02538 
02570 typedef struct gavl_video_scaler_s gavl_video_scaler_t;
02571 
02577 gavl_video_scaler_t * gavl_video_scaler_create();
02578 
02584 void gavl_video_scaler_destroy(gavl_video_scaler_t * scaler);
02585 
02594 gavl_video_options_t *
02595 gavl_video_scaler_get_options(gavl_video_scaler_t * scaler);
02596 
02609 int gavl_video_scaler_init(gavl_video_scaler_t * scaler,
02610                            const gavl_video_format_t * src_format,
02611                            const gavl_video_format_t * dst_format);
02612 
02634 int gavl_video_scaler_init_convolve(gavl_video_scaler_t * scaler,
02635                                     const gavl_video_format_t * format,
02636                                     int h_radius, float * h_coeffs,
02637                                     int v_radius, float * v_coeffs);
02638   
02646 void gavl_video_scaler_scale(gavl_video_scaler_t * scaler,
02647                              const gavl_video_frame_t * input_frame,
02648                              gavl_video_frame_t * output_frame);
02649 
02665 typedef struct gavl_video_deinterlacer_s gavl_video_deinterlacer_t;
02666 
02672 gavl_video_deinterlacer_t * gavl_video_deinterlacer_create();
02673 
02679 void gavl_video_deinterlacer_destroy(gavl_video_deinterlacer_t * deinterlacer);
02680 
02689 gavl_video_options_t *
02690 gavl_video_deinterlacer_get_options(gavl_video_deinterlacer_t * deinterlacer);
02691 
02702 int gavl_video_deinterlacer_init(gavl_video_deinterlacer_t * deinterlacer,
02703                                  const gavl_video_format_t * src_format);
02704 
02705   
02713 void gavl_video_deinterlacer_deinterlace(gavl_video_deinterlacer_t * deinterlacer,
02714                                          const gavl_video_frame_t * input_frame,
02715                                          gavl_video_frame_t * output_frame);
02716 
02717   
02718   
02719 /**************************************************
02720  * Transparent overlays 
02721  **************************************************/
02722 
02723 /* Overlay struct */
02724 
02752 typedef struct
02753   {
02754   gavl_video_frame_t * frame;    
02755   gavl_rectangle_i_t ovl_rect;   
02756   int dst_x;                     
02757   int dst_y;                     
02758   } gavl_overlay_t;
02759 
02766 typedef struct gavl_overlay_blend_context_s gavl_overlay_blend_context_t;
02767 
02773 gavl_overlay_blend_context_t * gavl_overlay_blend_context_create();
02774 
02780 void gavl_overlay_blend_context_destroy(gavl_overlay_blend_context_t * ctx);
02781 
02788 gavl_video_options_t *
02789 gavl_overlay_blend_context_get_options(gavl_overlay_blend_context_t * ctx);
02790 
02806 int gavl_overlay_blend_context_init(gavl_overlay_blend_context_t * ctx,
02807                                     const gavl_video_format_t * frame_format,
02808                                     gavl_video_format_t * overlay_format);
02809 
02819 void gavl_overlay_blend_context_set_overlay(gavl_overlay_blend_context_t * ctx,
02820                                             gavl_overlay_t * ovl);
02821 
02828 void gavl_overlay_blend(gavl_overlay_blend_context_t * ctx,
02829                         gavl_video_frame_t * dst_frame);
02830   
02831 #ifdef __cplusplus
02832 }
02833 #endif
02834 
02835 #endif /* GAVL_H_INCLUDED */

Generated on Fri Aug 1 20:44:13 2008 for gavl by  doxygen 1.5.5