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 /* Quality levels */
00045   
00069 #define GAVL_QUALITY_FASTEST 1
00070 
00077 #define GAVL_QUALITY_BEST    5 
00078 
00085 #define GAVL_QUALITY_DEFAULT 2 
00086 
00098 #define GAVL_ACCEL_MMX      (1<<0) 
00099 #define GAVL_ACCEL_MMXEXT   (1<<1) 
00100 #define GAVL_ACCEL_SSE      (1<<2) 
00101 #define GAVL_ACCEL_SSE2     (1<<3) 
00102 #define GAVL_ACCEL_SSE3     (1<<4) 
00103 #define GAVL_ACCEL_3DNOW    (1<<5) 
00104 #define GAVL_ACCEL_3DNOWEXT (1<<6) 
00105 #define GAVL_ACCEL_SSSE3    (1<<7) 
00106 
00107 
00111 int gavl_accel_supported();
00112 
00121 /* Sample formats: all multibyte numbers are native endian */
00122 
00135 #define GAVL_MAX_CHANNELS 128
00136   
00143 typedef enum
00144   {
00145     GAVL_SAMPLE_NONE   = 0, 
00146     GAVL_SAMPLE_U8     = 1, 
00147     GAVL_SAMPLE_S8     = 2, 
00148     GAVL_SAMPLE_U16    = 3, 
00149     GAVL_SAMPLE_S16    = 4, 
00150     GAVL_SAMPLE_S32    = 5, 
00151     GAVL_SAMPLE_FLOAT  = 6,  
00152     GAVL_SAMPLE_DOUBLE = 7  
00153   } gavl_sample_format_t;
00154 
00160 typedef enum
00161   {
00162     GAVL_INTERLEAVE_NONE = 0, 
00163     GAVL_INTERLEAVE_2    = 1, 
00164     GAVL_INTERLEAVE_ALL  = 2  
00165   } gavl_interleave_mode_t;
00166 
00174 typedef enum
00175   {
00176     GAVL_CHID_NONE         = 0,   
00177     GAVL_CHID_FRONT_CENTER,       
00178     GAVL_CHID_FRONT_LEFT,         
00179     GAVL_CHID_FRONT_RIGHT,        
00180     GAVL_CHID_FRONT_CENTER_LEFT,  
00181     GAVL_CHID_FRONT_CENTER_RIGHT, 
00182     GAVL_CHID_REAR_LEFT,          
00183     GAVL_CHID_REAR_RIGHT,         
00184     GAVL_CHID_REAR_CENTER,        
00185     GAVL_CHID_SIDE_LEFT,          
00186     GAVL_CHID_SIDE_RIGHT,         
00187     GAVL_CHID_LFE,                
00188     GAVL_CHID_AUX,                
00189   } gavl_channel_id_t;
00190 
00199 typedef struct 
00200   {
00201   int samples_per_frame;  
00202   int samplerate;         
00203   int num_channels;         
00204   gavl_sample_format_t   sample_format; 
00205   gavl_interleave_mode_t interleave_mode; 
00207   float center_level; 
00208   float rear_level;   
00210   gavl_channel_id_t channel_locations[GAVL_MAX_CHANNELS];   
00212   } gavl_audio_format_t;
00213 
00214   
00215 /* Audio format -> string conversions */
00216 
00224 const char * gavl_sample_format_to_string(gavl_sample_format_t format);
00225 
00234 gavl_sample_format_t gavl_string_to_sample_format(const char * str);
00235 
00241 int gavl_num_sample_formats();
00242 
00249 gavl_sample_format_t gavl_get_sample_format(int index);
00250   
00257 const char * gavl_channel_id_to_string(gavl_channel_id_t id);
00258 
00259 
00266 const char * gavl_interleave_mode_to_string(gavl_interleave_mode_t mode);
00267 
00274 void gavl_audio_format_dump(const gavl_audio_format_t * format);
00275 
00284 int gavl_channel_index(const gavl_audio_format_t * format, gavl_channel_id_t id);
00285 
00292 int gavl_front_channels(const gavl_audio_format_t * format);
00293 
00300 int gavl_rear_channels(const gavl_audio_format_t * format);
00301 
00308 int gavl_side_channels(const gavl_audio_format_t * format);
00309 
00316 int gavl_aux_channels(const gavl_audio_format_t * format);
00317 
00318   
00319   
00326 int gavl_lfe_channels(const gavl_audio_format_t * format);
00327 
00335 void gavl_audio_format_copy(gavl_audio_format_t * dst,
00336                             const gavl_audio_format_t * src);
00337 
00346 int gavl_audio_formats_equal(const gavl_audio_format_t * format_1,
00347                               const gavl_audio_format_t * format_2);
00348 
00360 void gavl_set_channel_setup(gavl_audio_format_t * format);
00361 
00368 int gavl_bytes_per_sample(gavl_sample_format_t format);
00369 
00384 typedef union 
00385   {
00386   uint8_t * u_8; 
00387   int8_t *  s_8; 
00389   uint16_t * u_16; 
00390   int16_t  * s_16; 
00392   uint32_t * u_32; 
00393   int32_t  * s_32; 
00395   float * f; 
00396   double * d; 
00397   } gavl_audio_samples_t;
00398 
00404 typedef union
00405   {
00406   uint8_t * u_8[GAVL_MAX_CHANNELS];
00407   int8_t *  s_8[GAVL_MAX_CHANNELS];
00409   uint16_t * u_16[GAVL_MAX_CHANNELS];
00410   int16_t  * s_16[GAVL_MAX_CHANNELS];
00412   uint32_t * u_32[GAVL_MAX_CHANNELS];
00413   int32_t  * s_32[GAVL_MAX_CHANNELS];
00415   float * f[GAVL_MAX_CHANNELS];
00416   double * d[GAVL_MAX_CHANNELS];
00418   } gavl_audio_channels_t;
00419 
00436 typedef struct 
00437   {
00438   gavl_audio_samples_t  samples; 
00439   gavl_audio_channels_t channels;
00440   int valid_samples;             
00441   int64_t timestamp;             
00442   int channel_stride;            
00443   } gavl_audio_frame_t;
00444 
00456 gavl_audio_frame_t * gavl_audio_frame_create(const gavl_audio_format_t* format);
00457 
00469 void gavl_audio_frame_null(gavl_audio_frame_t * frame);
00470 
00480 void gavl_audio_frame_destroy(gavl_audio_frame_t * frame);
00481 
00491 void gavl_audio_frame_mute(gavl_audio_frame_t * frame,
00492                            const gavl_audio_format_t * format);
00493 
00504 void gavl_audio_frame_mute_samples(gavl_audio_frame_t * frame,
00505                                    const gavl_audio_format_t * format,
00506                                    int num_samples);
00507 
00508   
00509   
00520 void gavl_audio_frame_mute_channel(gavl_audio_frame_t * frame,
00521                                    const gavl_audio_format_t * format,
00522                                    int channel);
00523   
00544 int gavl_audio_frame_copy(const gavl_audio_format_t * format,
00545                           gavl_audio_frame_t * dst,
00546                           const gavl_audio_frame_t * src,
00547                           int dst_pos,
00548                           int src_pos,
00549                           int dst_size,
00550                           int src_size);
00551 
00566 #define GAVL_AUDIO_FRONT_TO_REAR_COPY (1<<0) 
00571 #define GAVL_AUDIO_FRONT_TO_REAR_MUTE (1<<1) 
00576 #define GAVL_AUDIO_FRONT_TO_REAR_DIFF (1<<2) 
00581 #define GAVL_AUDIO_FRONT_TO_REAR_MASK           \
00582 (GAVL_AUDIO_FRONT_TO_REAR_COPY | \
00583 GAVL_AUDIO_FRONT_TO_REAR_MUTE | \
00584  GAVL_AUDIO_FRONT_TO_REAR_DIFF) 
00586 /* Options for mixing stereo to mono */
00587   
00590 #define GAVL_AUDIO_STEREO_TO_MONO_LEFT  (1<<3) 
00593 #define GAVL_AUDIO_STEREO_TO_MONO_RIGHT (1<<4) 
00596 #define GAVL_AUDIO_STEREO_TO_MONO_MIX   (1<<5) 
00600 #define GAVL_AUDIO_STEREO_TO_MONO_MASK \
00601 (GAVL_AUDIO_STEREO_TO_MONO_LEFT | \
00602 GAVL_AUDIO_STEREO_TO_MONO_RIGHT | \
00603 GAVL_AUDIO_STEREO_TO_MONO_MIX) 
00609 typedef enum
00610   {
00611     GAVL_AUDIO_DITHER_NONE   = 0,
00612     GAVL_AUDIO_DITHER_AUTO   = 1,
00613     GAVL_AUDIO_DITHER_RECT   = 2,
00614     GAVL_AUDIO_DITHER_TRI    = 3,
00615     GAVL_AUDIO_DITHER_SHAPED = 4,
00616   } gavl_audio_dither_mode_t;
00617 
00622 typedef enum
00623   {
00624     GAVL_RESAMPLE_AUTO        = 0, 
00625     GAVL_RESAMPLE_ZOH         = 1, 
00626     GAVL_RESAMPLE_LINEAR      = 2, 
00627     GAVL_RESAMPLE_SINC_FAST   = 3, 
00628     GAVL_RESAMPLE_SINC_MEDIUM = 4, 
00629     GAVL_RESAMPLE_SINC_BEST   = 5  
00630   } gavl_resample_mode_t;
00631   
00638 typedef struct gavl_audio_options_s gavl_audio_options_t;
00639 
00646 void gavl_audio_options_set_quality(gavl_audio_options_t * opt, int quality);
00647 
00654 int gavl_audio_options_get_quality(gavl_audio_options_t * opt);
00655   
00662 void gavl_audio_options_set_dither_mode(gavl_audio_options_t * opt, gavl_audio_dither_mode_t mode);
00663 
00670 gavl_audio_dither_mode_t gavl_audio_options_get_dither_mode(gavl_audio_options_t * opt);
00671 
00672   
00679 void gavl_audio_options_set_resample_mode(gavl_audio_options_t * opt, gavl_resample_mode_t mode);
00680 
00687 gavl_resample_mode_t gavl_audio_options_get_resample_mode(gavl_audio_options_t * opt);
00688   
00695 void gavl_audio_options_set_conversion_flags(gavl_audio_options_t * opt,
00696                                              int flags);
00697   
00704 int gavl_audio_options_get_conversion_flags(gavl_audio_options_t * opt);
00705 
00711 void gavl_audio_options_set_defaults(gavl_audio_options_t * opt);
00712 
00722 gavl_audio_options_t * gavl_audio_options_create();
00723 
00730 void gavl_audio_options_copy(gavl_audio_options_t * dst,
00731                              const gavl_audio_options_t * src);
00732 
00738 void gavl_audio_options_destroy(gavl_audio_options_t * opt);
00739   
00740   
00741   
00742 /* Audio converter */
00743 
00777 typedef struct gavl_audio_converter_s gavl_audio_converter_t;
00778   
00784 gavl_audio_converter_t * gavl_audio_converter_create();
00785 
00791 void gavl_audio_converter_destroy(gavl_audio_converter_t* cnv);
00792 
00801 gavl_audio_options_t * gavl_audio_converter_get_options(gavl_audio_converter_t*cnv);
00802 
00803 
00817 int gavl_audio_converter_init(gavl_audio_converter_t* cnv,
00818                               const gavl_audio_format_t * input_format,
00819                               const gavl_audio_format_t * output_format);
00820 
00834 int gavl_audio_converter_reinit(gavl_audio_converter_t* cnv);
00835 
00836   
00850 void gavl_audio_convert(gavl_audio_converter_t * cnv,
00851                         const gavl_audio_frame_t * input_frame,
00852                         gavl_audio_frame_t * output_frame);
00853 
00854 
00855 
00856 
00870 typedef struct gavl_volume_control_s gavl_volume_control_t;
00871   
00872 /* Create / destroy */
00873 
00879 gavl_volume_control_t * gavl_volume_control_create();
00880 
00886 void gavl_volume_control_destroy(gavl_volume_control_t *ctrl);
00887 
00895 void gavl_volume_control_set_format(gavl_volume_control_t *ctrl,
00896                                     const gavl_audio_format_t * format);
00897 
00904 void gavl_volume_control_set_volume(gavl_volume_control_t * ctrl,
00905                                     float volume);
00906 
00913 void gavl_volume_control_apply(gavl_volume_control_t *ctrl,
00914                                gavl_audio_frame_t * frame);
00915 
00931 typedef struct gavl_peak_detector_s gavl_peak_detector_t;
00932   
00933 /* Create / destroy */
00934 
00940 gavl_peak_detector_t * gavl_peak_detector_create();
00941 
00947 void gavl_peak_detector_destroy(gavl_peak_detector_t *pd);
00948 
00958 void gavl_peak_detector_set_format(gavl_peak_detector_t *pd,
00959                                    const gavl_audio_format_t * format);
00960 
00967 void gavl_peak_detector_update(gavl_peak_detector_t *pd,
00968                               gavl_audio_frame_t * frame);
00969   
00982 void gavl_peak_detector_get_peak(gavl_peak_detector_t * pd,
00983                                  double * min, double * max,
00984                                  double * abs);
00985 
00998 void gavl_peak_detector_get_peaks(gavl_peak_detector_t * pd,
00999                                   double * min, double * max,
01000                                   double * abs);
01001   
01007 void gavl_peak_detector_reset(gavl_peak_detector_t * pd);
01008   
01018 #define GAVL_MAX_PLANES 4 
01030 typedef struct
01031   {
01032   int x; 
01033   int y; 
01034   int w; 
01035   int h; 
01036   } gavl_rectangle_i_t;
01037 
01042 typedef struct
01043   {
01044   double x; 
01045   double y; 
01046   double w; 
01047   double h; 
01048   } gavl_rectangle_f_t;
01049 
01056 void gavl_rectangle_i_crop_to_format(gavl_rectangle_i_t * r,
01057                                    const gavl_video_format_t * format);
01058 
01065 void gavl_rectangle_f_crop_to_format(gavl_rectangle_f_t * r,
01066                                      const gavl_video_format_t * format);
01067 
01082 void gavl_rectangle_crop_to_format_noscale(gavl_rectangle_i_t * src_rect,
01083                                            gavl_rectangle_i_t * dst_rect,
01084                                            const gavl_video_format_t * src_format,
01085                                            const gavl_video_format_t * dst_format);
01086 
01098 void gavl_rectangle_crop_to_format_scale(gavl_rectangle_f_t * src_rect,
01099                                          gavl_rectangle_i_t * dst_rect,
01100                                          const gavl_video_format_t * src_format,
01101                                          const gavl_video_format_t * dst_format);
01102 
01103   
01104 
01111 void gavl_rectangle_i_set_all(gavl_rectangle_i_t * r, const gavl_video_format_t * format);
01112 
01119 void gavl_rectangle_f_set_all(gavl_rectangle_f_t * r, const gavl_video_format_t * format);
01120 
01127 void gavl_rectangle_i_crop_left(gavl_rectangle_i_t * r,   int num_pixels);
01128 
01135 void gavl_rectangle_i_crop_right(gavl_rectangle_i_t * r,  int num_pixels);
01136 
01143 void gavl_rectangle_i_crop_top(gavl_rectangle_i_t * r,    int num_pixels);
01144 
01151 void gavl_rectangle_i_crop_bottom(gavl_rectangle_i_t * r, int num_pixels);
01152 
01159 void gavl_rectangle_f_crop_left(gavl_rectangle_f_t * r,   double num_pixels);
01160 
01167 void gavl_rectangle_f_crop_right(gavl_rectangle_f_t * r,  double num_pixels);
01168 
01175 void gavl_rectangle_f_crop_top(gavl_rectangle_f_t * r,    double num_pixels);
01176 
01183 void gavl_rectangle_f_crop_bottom(gavl_rectangle_f_t * r, double num_pixels);
01184 
01198 void gavl_rectangle_i_align(gavl_rectangle_i_t * r, int h_align, int v_align);
01199 
01209 void gavl_rectangle_i_align_to_format(gavl_rectangle_i_t * r,
01210                                       const gavl_video_format_t * format);
01211 
01212   
01219 void gavl_rectangle_i_copy(gavl_rectangle_i_t * dst, const gavl_rectangle_i_t * src);
01220 
01227 void gavl_rectangle_f_copy(gavl_rectangle_f_t * dst, const gavl_rectangle_f_t * src);
01228 
01229 
01230 
01237 void gavl_rectangle_i_to_f(gavl_rectangle_f_t * dst, const gavl_rectangle_i_t * src);
01238 
01245 void gavl_rectangle_f_to_i(gavl_rectangle_i_t * dst, const gavl_rectangle_f_t * src);
01246   
01255 int gavl_rectangle_i_is_empty(const gavl_rectangle_i_t * r);
01256 
01265 int gavl_rectangle_f_is_empty(const gavl_rectangle_f_t * r);
01266 
01294 void gavl_rectangle_fit_aspect(gavl_rectangle_i_t * dst_rect,
01295                                const gavl_video_format_t * src_format,
01296                                const gavl_rectangle_f_t * src_rect,
01297                                const gavl_video_format_t * dst_format,
01298                                float zoom, float squeeze);
01299 
01304 void gavl_rectangle_i_dump(const gavl_rectangle_i_t * r);
01305 
01310 void gavl_rectangle_f_dump(const gavl_rectangle_f_t * r);
01311 
01312   
01322 #define GAVL_PIXFMT_PLANAR (1<<8)
01323 
01327 #define GAVL_PIXFMT_RGB    (1<<9)
01328 
01332 #define GAVL_PIXFMT_YUV    (1<<10)
01333 
01337 #define GAVL_PIXFMT_YUVJ   (1<<11)
01338 
01342 #define GAVL_PIXFMT_ALPHA  (1<<12)
01343 
01347 #define GAVL_PIXFMT_GRAY   (1<<13)
01348   
01353 typedef enum 
01354   {
01357     GAVL_PIXELFORMAT_NONE =  0, 
01358 
01361     GAVL_GRAY_8          =  1 | GAVL_PIXFMT_GRAY,
01362 
01365     GAVL_GRAY_16          =  2 | GAVL_PIXFMT_GRAY,
01366     
01369     GAVL_GRAY_FLOAT       =  3 | GAVL_PIXFMT_GRAY,
01370     
01373     GAVL_GRAYA_16          =  1 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
01374 
01377     GAVL_GRAYA_32          =  2 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
01378     
01381     GAVL_GRAYA_FLOAT       =  3 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
01382     
01386     GAVL_RGB_15          =  1 | GAVL_PIXFMT_RGB,
01390     GAVL_BGR_15          =  2 | GAVL_PIXFMT_RGB,
01394     GAVL_RGB_16          =  3 | GAVL_PIXFMT_RGB,
01398     GAVL_BGR_16          =  4 | GAVL_PIXFMT_RGB,
01401     GAVL_RGB_24          =  5 | GAVL_PIXFMT_RGB,
01404     GAVL_BGR_24          =  6 | GAVL_PIXFMT_RGB,
01407     GAVL_RGB_32          =  7 | GAVL_PIXFMT_RGB,
01410     GAVL_BGR_32          =  8 | GAVL_PIXFMT_RGB,
01413     GAVL_RGBA_32         =  9 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA,
01414 
01417     GAVL_RGB_48       = 10 | GAVL_PIXFMT_RGB,
01420     GAVL_RGBA_64      = 11 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA,
01421         
01424     GAVL_RGB_FLOAT    = 12 | GAVL_PIXFMT_RGB,
01427     GAVL_RGBA_FLOAT   = 13 | GAVL_PIXFMT_RGB  | GAVL_PIXFMT_ALPHA,
01428 
01431     GAVL_YUY2            = 1 | GAVL_PIXFMT_YUV,
01434     GAVL_UYVY            = 2 | GAVL_PIXFMT_YUV,
01437     GAVL_YUVA_32         = 3 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
01440     GAVL_YUVA_64         = 4 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
01443     GAVL_YUV_FLOAT       = 5 | GAVL_PIXFMT_YUV,
01444 
01447     GAVL_YUVA_FLOAT       = 6 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
01448     
01452     GAVL_YUV_420_P       = 1 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01455     GAVL_YUV_422_P       = 2 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01458     GAVL_YUV_444_P       = 3 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01461     GAVL_YUV_411_P       = 4 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01464     GAVL_YUV_410_P       = 5 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01465     
01468     GAVL_YUVJ_420_P      = 6 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
01471     GAVL_YUVJ_422_P      = 7 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
01474     GAVL_YUVJ_444_P      = 8 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
01475 
01478     GAVL_YUV_444_P_16 = 9 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01481     GAVL_YUV_422_P_16 = 10 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01482     
01483   } gavl_pixelformat_t;
01484 
01487 #define GAVL_PIXELFORMAT_1D_8 GAVL_GRAY_8
01488 
01490 #define GAVL_PIXELFORMAT_2D_8 GAVL_GRAYA_16
01491 
01493 #define GAVL_PIXELFORMAT_3D_8 GAVL_RGB_24
01494 
01496 #define GAVL_PIXELFORMAT_4D_8 GAVL_RGBA_32
01497 
01500 #define GAVL_PIXELFORMAT_1D_16 GAVL_GRAY_16
01501 
01503 #define GAVL_PIXELFORMAT_2D_16 GAVL_GRAYA_32
01504 
01506 #define GAVL_PIXELFORMAT_3D_16 GAVL_RGB_48
01507 
01509 #define GAVL_PIXELFORMAT_4D_16 GAVL_RGBA_64
01510 
01513 #define GAVL_PIXELFORMAT_1D_FLOAT GAVL_GRAY_FLOAT
01514 
01516 #define GAVL_PIXELFORMAT_2D_FLOAT GAVL_GRAYA_FLOAT
01517 
01519 #define GAVL_PIXELFORMAT_3D_FLOAT GAVL_RGB_FLOAT
01520 
01522 #define GAVL_PIXELFORMAT_4D_FLOAT GAVL_RGBA_FLOAT
01523 
01524   
01525 /*
01526  *  Colormodel related functions
01527  */
01528 
01535 #define gavl_pixelformat_is_gray(fmt) ((fmt) & GAVL_PIXFMT_GRAY)
01536 
01537   
01544 #define gavl_pixelformat_is_rgb(fmt) ((fmt) & GAVL_PIXFMT_RGB)
01545 
01552 #define gavl_pixelformat_is_yuv(fmt) ((fmt) & GAVL_PIXFMT_YUV)
01553 
01560 #define gavl_pixelformat_is_jpeg_scaled(fmt) ((fmt) & GAVL_PIXFMT_YUVJ)
01561 
01568 #define gavl_pixelformat_has_alpha(fmt) ((fmt) & GAVL_PIXFMT_ALPHA)
01569 
01576 #define  gavl_pixelformat_is_planar(fmt) ((fmt) & GAVL_PIXFMT_PLANAR)
01577 
01584 int gavl_pixelformat_num_planes(gavl_pixelformat_t pixelformat);
01585 
01595 void gavl_pixelformat_chroma_sub(gavl_pixelformat_t pixelformat, int * sub_h, int * sub_v);
01596 
01603 int gavl_pixelformat_bytes_per_component(gavl_pixelformat_t pixelformat);
01604 
01611 int gavl_pixelformat_bytes_per_pixel(gavl_pixelformat_t pixelformat);
01612   
01619 int gavl_pixelformat_bits_per_pixel(gavl_pixelformat_t pixelformat);
01620 
01635 int gavl_pixelformat_conversion_penalty(gavl_pixelformat_t src,
01636                                         gavl_pixelformat_t dst);
01637 
01651 gavl_pixelformat_t 
01652 gavl_pixelformat_get_best(gavl_pixelformat_t src,
01653                           const gavl_pixelformat_t * dst_supported,
01654                           int * penalty);
01655   
01656 
01657 
01664 const char * gavl_pixelformat_to_string(gavl_pixelformat_t pixelformat);
01665 
01672 gavl_pixelformat_t gavl_string_to_pixelformat(const char * name);
01673 
01679 int gavl_num_pixelformats();
01680 
01687 gavl_pixelformat_t gavl_get_pixelformat(int index);
01688 
01689 /*  */
01690 
01699 typedef enum
01700   {
01701     GAVL_CHROMA_PLACEMENT_DEFAULT = 0, 
01702     GAVL_CHROMA_PLACEMENT_MPEG2,       
01703     GAVL_CHROMA_PLACEMENT_DVPAL        
01704   } gavl_chroma_placement_t;
01705 
01712 const char * gavl_chroma_placement_to_string(gavl_chroma_placement_t mode);
01713   
01718 typedef enum
01719   {
01720     GAVL_FRAMERATE_CONSTANT    = 0, 
01721     GAVL_FRAMERATE_VARIABLE    = 1, 
01722     GAVL_FRAMERATE_STILL       = 2, 
01723   } gavl_framerate_mode_t;
01724 
01729 typedef enum
01730   {
01731     GAVL_INTERLACE_NONE = 0,    
01732     GAVL_INTERLACE_TOP_FIRST,   
01733     GAVL_INTERLACE_BOTTOM_FIRST,
01734     GAVL_INTERLACE_MIXED        
01735   } gavl_interlace_mode_t;
01736 
01743 const char * gavl_interlace_mode_to_string(gavl_interlace_mode_t mode);
01744   
01745   
01746 /* Video format structure */
01747   
01752 struct gavl_video_format_s
01753   {
01754   int frame_width;
01755   int frame_height;
01757   int image_width;
01758   int image_height;
01760   /* Support for nonsquare pixels */
01761     
01762   int pixel_width;
01763   int pixel_height;
01765   gavl_pixelformat_t pixelformat;
01767   int frame_duration;
01769   int timescale;
01771   gavl_framerate_mode_t   framerate_mode;
01772   gavl_chroma_placement_t chroma_placement;
01774   gavl_interlace_mode_t   interlace_mode;
01775   };
01776 
01784 void gavl_video_format_copy(gavl_video_format_t * dst,
01785                             const gavl_video_format_t * src);
01786 
01795 int gavl_video_formats_equal(const gavl_video_format_t * format_1,
01796                              const gavl_video_format_t * format_2);
01797 
01798   
01809 void gavl_video_format_get_chroma_offset(const gavl_video_format_t * format, int field, int plane,
01810                                          float * off_x, float * off_y);
01811   
01812 
01813   
01820 void gavl_video_format_dump(const gavl_video_format_t * format);
01821 
01834 void gavl_video_format_fit_to_source(gavl_video_format_t * dst,
01835                                      const gavl_video_format_t * src);
01836 
01837   
01860 typedef struct
01861   {
01862   uint8_t * planes[GAVL_MAX_PLANES]; 
01863   int strides[GAVL_MAX_PLANES];      
01865   void * user_data;    
01866   int64_t timestamp; 
01867   int64_t duration; 
01868   gavl_interlace_mode_t   interlace_mode;
01869   } gavl_video_frame_t;
01870 
01871 
01883 gavl_video_frame_t * gavl_video_frame_create(const gavl_video_format_t*format);
01884 
01895 gavl_video_frame_t * gavl_video_frame_create_nopad(const gavl_video_format_t*format);
01896 
01897   
01898 
01908 void gavl_video_frame_destroy(gavl_video_frame_t*frame);
01909 
01921 void gavl_video_frame_null(gavl_video_frame_t*frame);
01922   
01931 void gavl_video_frame_clear(gavl_video_frame_t * frame,
01932                             const gavl_video_format_t * format);
01933 
01943 void gavl_video_frame_fill(gavl_video_frame_t * frame,
01944                            const gavl_video_format_t * format,
01945                            float * color);
01946 
01947   
01960 void gavl_video_frame_copy(const gavl_video_format_t * format,
01961                            gavl_video_frame_t * dst,
01962                            const gavl_video_frame_t * src);
01963 
01976 void gavl_video_frame_copy_plane(const gavl_video_format_t * format,
01977                                  gavl_video_frame_t * dst,
01978                                  const gavl_video_frame_t * src, int plane);
01979 
01991 void gavl_video_frame_copy_flip_x(const gavl_video_format_t * format,
01992                                   gavl_video_frame_t * dst,
01993                                   const gavl_video_frame_t * src);
01994 
02006 void gavl_video_frame_copy_flip_y(const gavl_video_format_t * format,
02007                                   gavl_video_frame_t * dst,
02008                                   const gavl_video_frame_t * src);
02009 
02021 void gavl_video_frame_copy_flip_xy(const gavl_video_format_t * format,
02022                                    gavl_video_frame_t * dst,
02023                                   const gavl_video_frame_t * src);
02024 
02042 void gavl_video_frame_get_subframe(gavl_pixelformat_t pixelformat,
02043                                    const gavl_video_frame_t * src,
02044                                    gavl_video_frame_t * dst,
02045                                    gavl_rectangle_i_t * src_rect);
02046 
02062 void gavl_video_frame_get_field(gavl_pixelformat_t pixelformat,
02063                                 const gavl_video_frame_t * src,
02064                                 gavl_video_frame_t * dst,
02065                                 int field);
02066 
02067   
02068 
02081 void gavl_video_frame_dump(gavl_video_frame_t * frame,
02082                            const gavl_video_format_t * format,
02083                            const char * namebase);
02084   
02085 /*****************************
02086  Conversion options
02087 ******************************/
02088 
02104 #define GAVL_FORCE_DEINTERLACE (1<<0)
02105 
02110 #define GAVL_CONVOLVE_CHROMA   (1<<1)
02111 
02116 #define GAVL_CONVOLVE_NORMALIZE (1<<2)
02117 
02125 #define GAVL_RESAMPLE_CHROMA    (1<<3)
02126   
02134 typedef enum
02135   {
02136     GAVL_ALPHA_IGNORE      = 0, 
02137     GAVL_ALPHA_BLEND_COLOR      
02138   } gavl_alpha_mode_t;
02139 
02146 typedef enum
02147   {
02148     GAVL_DEINTERLACE_NONE      = 0, 
02149     GAVL_DEINTERLACE_COPY      = 1, 
02150     GAVL_DEINTERLACE_SCALE     = 2, 
02151     GAVL_DEINTERLACE_BLEND     = 3  
02152   } gavl_deinterlace_mode_t;
02153 
02160 typedef enum
02161   {
02162     GAVL_DEINTERLACE_DROP_TOP,    
02163     GAVL_DEINTERLACE_DROP_BOTTOM, 
02164   } gavl_deinterlace_drop_mode_t;
02165   
02170 typedef enum
02171   {
02172     GAVL_SCALE_AUTO,          
02173     GAVL_SCALE_NEAREST,       
02174     GAVL_SCALE_BILINEAR,      
02175     GAVL_SCALE_QUADRATIC,     
02176     GAVL_SCALE_CUBIC_BSPLINE, 
02177     GAVL_SCALE_CUBIC_MITCHELL,
02178     GAVL_SCALE_CUBIC_CATMULL, 
02179     GAVL_SCALE_SINC_LANCZOS,  
02180     GAVL_SCALE_NONE,          
02181   } gavl_scale_mode_t;
02182 
02189 typedef struct gavl_video_options_s gavl_video_options_t;
02190 
02191 /* Default Options */
02192 
02198 void gavl_video_options_set_defaults(gavl_video_options_t * opt);
02199 
02209 gavl_video_options_t * gavl_video_options_create();
02210 
02217 void gavl_video_options_copy(gavl_video_options_t * dst,
02218                              const gavl_video_options_t * src);
02219 
02225 void gavl_video_options_destroy(gavl_video_options_t * opt);
02226   
02227   
02242 void gavl_video_options_set_rectangles(gavl_video_options_t * opt,
02243                                        const gavl_rectangle_f_t * src_rect,
02244                                        const gavl_rectangle_i_t * dst_rect);
02245 
02252 void gavl_video_options_get_rectangles(gavl_video_options_t * opt,
02253                                        gavl_rectangle_f_t * src_rect,
02254                                        gavl_rectangle_i_t * dst_rect);
02255   
02262 void gavl_video_options_set_quality(gavl_video_options_t * opt, int quality);
02263 
02270 int gavl_video_options_get_quality(gavl_video_options_t * opt);
02271 
02272   
02279 void gavl_video_options_set_conversion_flags(gavl_video_options_t * opt,
02280                                              int conversion_flags);
02281 
02288 int gavl_video_options_get_conversion_flags(gavl_video_options_t * opt);
02289   
02296 void gavl_video_options_set_alpha_mode(gavl_video_options_t * opt,
02297                                        gavl_alpha_mode_t alpha_mode);
02298 
02305 gavl_alpha_mode_t
02306 gavl_video_options_get_alpha_mode(gavl_video_options_t * opt);
02307 
02308   
02315 void gavl_video_options_set_scale_mode(gavl_video_options_t * opt,
02316                                        gavl_scale_mode_t scale_mode);
02317 
02324 gavl_scale_mode_t
02325 gavl_video_options_get_scale_mode(gavl_video_options_t * opt);
02326 
02327   
02334 void gavl_video_options_set_scale_order(gavl_video_options_t * opt,
02335                                         int order);
02336 
02343 int gavl_video_options_get_scale_order(gavl_video_options_t * opt);
02344 
02345   
02352 void gavl_video_options_set_background_color(gavl_video_options_t * opt,
02353                                              const float * color);
02354 
02361 void gavl_video_options_get_background_color(gavl_video_options_t * opt,
02362                                              float * color);
02363   
02370 void gavl_video_options_set_deinterlace_mode(gavl_video_options_t * opt,
02371                                              gavl_deinterlace_mode_t deinterlace_mode);
02372 
02379 gavl_deinterlace_mode_t
02380 gavl_video_options_get_deinterlace_mode(gavl_video_options_t * opt);
02381 
02388 void gavl_video_options_set_deinterlace_drop_mode(gavl_video_options_t * opt,
02389                                                   gavl_deinterlace_drop_mode_t deinterlace_drop_mode);
02390 
02397 gavl_deinterlace_drop_mode_t
02398 gavl_video_options_get_deinterlace_drop_mode(gavl_video_options_t * opt);
02399  
02400   
02401 /***************************************************
02402  * Create and destroy video converters
02403  ***************************************************/
02404   
02437 typedef struct gavl_video_converter_s gavl_video_converter_t;
02438 
02444 gavl_video_converter_t * gavl_video_converter_create();
02445 
02451 void gavl_video_converter_destroy(gavl_video_converter_t*cnv);
02452 
02453 /**************************************************
02454  * Get options. Change the options with the gavl_video_options_set_*
02455  * functions above
02456  **************************************************/
02457 
02466 gavl_video_options_t *
02467 gavl_video_converter_get_options(gavl_video_converter_t*cnv);
02468 
02469 
02483 int gavl_video_converter_init(gavl_video_converter_t* cnv,
02484                               const gavl_video_format_t * input_format,
02485                               const gavl_video_format_t * output_format);
02486 
02499 int gavl_video_converter_reinit(gavl_video_converter_t* cnv);
02500  
02501   
02502 /***************************************************
02503  * Convert a frame
02504  ***************************************************/
02505 
02513 void gavl_video_convert(gavl_video_converter_t * cnv,
02514                         const gavl_video_frame_t * input_frame,
02515                         gavl_video_frame_t * output_frame);
02516 
02548 typedef struct gavl_video_scaler_s gavl_video_scaler_t;
02549 
02555 gavl_video_scaler_t * gavl_video_scaler_create();
02556 
02562 void gavl_video_scaler_destroy(gavl_video_scaler_t * scaler);
02563 
02572 gavl_video_options_t *
02573 gavl_video_scaler_get_options(gavl_video_scaler_t * scaler);
02574 
02587 int gavl_video_scaler_init(gavl_video_scaler_t * scaler,
02588                            const gavl_video_format_t * src_format,
02589                            const gavl_video_format_t * dst_format);
02590 
02612 int gavl_video_scaler_init_convolve(gavl_video_scaler_t * scaler,
02613                                     const gavl_video_format_t * format,
02614                                     int h_radius, float * h_coeffs,
02615                                     int v_radius, float * v_coeffs);
02616   
02624 void gavl_video_scaler_scale(gavl_video_scaler_t * scaler,
02625                              const gavl_video_frame_t * input_frame,
02626                              gavl_video_frame_t * output_frame);
02627 
02643 typedef struct gavl_video_deinterlacer_s gavl_video_deinterlacer_t;
02644 
02650 gavl_video_deinterlacer_t * gavl_video_deinterlacer_create();
02651 
02657 void gavl_video_deinterlacer_destroy(gavl_video_deinterlacer_t * deinterlacer);
02658 
02667 gavl_video_options_t *
02668 gavl_video_deinterlacer_get_options(gavl_video_deinterlacer_t * deinterlacer);
02669 
02680 int gavl_video_deinterlacer_init(gavl_video_deinterlacer_t * deinterlacer,
02681                                  const gavl_video_format_t * src_format);
02682 
02683   
02691 void gavl_video_deinterlacer_deinterlace(gavl_video_deinterlacer_t * deinterlacer,
02692                                          const gavl_video_frame_t * input_frame,
02693                                          gavl_video_frame_t * output_frame);
02694 
02695   
02696   
02697 /**************************************************
02698  * Transparent overlays 
02699  **************************************************/
02700 
02701 /* Overlay struct */
02702 
02730 typedef struct
02731   {
02732   gavl_video_frame_t * frame;    
02733   gavl_rectangle_i_t ovl_rect;   
02734   int dst_x;                     
02735   int dst_y;                     
02736   } gavl_overlay_t;
02737 
02744 typedef struct gavl_overlay_blend_context_s gavl_overlay_blend_context_t;
02745 
02751 gavl_overlay_blend_context_t * gavl_overlay_blend_context_create();
02752 
02758 void gavl_overlay_blend_context_destroy(gavl_overlay_blend_context_t * ctx);
02759 
02766 gavl_video_options_t *
02767 gavl_overlay_blend_context_get_options(gavl_overlay_blend_context_t * ctx);
02768 
02784 int gavl_overlay_blend_context_init(gavl_overlay_blend_context_t * ctx,
02785                                     const gavl_video_format_t * frame_format,
02786                                     gavl_video_format_t * overlay_format);
02787 
02797 void gavl_overlay_blend_context_set_overlay(gavl_overlay_blend_context_t * ctx,
02798                                             gavl_overlay_t * ovl);
02799 
02806 void gavl_overlay_blend(gavl_overlay_blend_context_t * ctx,
02807                         gavl_video_frame_t * dst_frame);
02808   
02809 #ifdef __cplusplus
02810 }
02811 #endif
02812 
02813 #endif /* GAVL_H_INCLUDED */

Generated on Thu Oct 16 11:05:54 2008 for gavl by  doxygen 1.5.7.1