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 #include <gavlconfig.h>
00032 
00033 #include "gavltime.h"
00034 
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038 
00043 typedef struct gavl_video_format_s gavl_video_format_t;
00044 
00045 /* Quality levels */
00046   
00070 #define GAVL_QUALITY_FASTEST 1
00071 
00078 #define GAVL_QUALITY_BEST    5 
00079 
00086 #define GAVL_QUALITY_DEFAULT 2 
00087 
00099 #define GAVL_ACCEL_MMX      (1<<0) 
00100 #define GAVL_ACCEL_MMXEXT   (1<<1) 
00101 #define GAVL_ACCEL_SSE      (1<<2) 
00102 #define GAVL_ACCEL_SSE2     (1<<3) 
00103 #define GAVL_ACCEL_SSE3     (1<<4) 
00104 #define GAVL_ACCEL_3DNOW    (1<<5) 
00105 #define GAVL_ACCEL_3DNOWEXT (1<<6) 
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   
00142 typedef enum
00143   {
00144     GAVL_SAMPLE_NONE  = 0, 
00145     GAVL_SAMPLE_U8    = 1, 
00146     GAVL_SAMPLE_S8    = 2, 
00147     GAVL_SAMPLE_U16   = 3, 
00148     GAVL_SAMPLE_S16   = 4, 
00149     GAVL_SAMPLE_S32   = 5, 
00150     GAVL_SAMPLE_FLOAT = 6  
00151   } gavl_sample_format_t;
00152 
00157 typedef enum
00158   {
00159     GAVL_INTERLEAVE_NONE = 0, 
00160     GAVL_INTERLEAVE_2    = 1, 
00161     GAVL_INTERLEAVE_ALL  = 2  
00162   } gavl_interleave_mode_t;
00163 
00170 typedef enum
00171   {
00172     GAVL_CHID_NONE         = 0,   
00173     GAVL_CHID_FRONT_CENTER,       
00174     GAVL_CHID_FRONT_LEFT,         
00175     GAVL_CHID_FRONT_RIGHT,        
00176     GAVL_CHID_FRONT_CENTER_LEFT,  
00177     GAVL_CHID_FRONT_CENTER_RIGHT, 
00178     GAVL_CHID_REAR_LEFT,          
00179     GAVL_CHID_REAR_RIGHT,         
00180     GAVL_CHID_REAR_CENTER,        
00181     GAVL_CHID_SIDE_LEFT,          
00182     GAVL_CHID_SIDE_RIGHT,         
00183     GAVL_CHID_LFE,                
00184     GAVL_CHID_AUX,                
00185   } gavl_channel_id_t;
00186 
00195 typedef struct gavl_audio_format_s
00196   {
00197   int samples_per_frame;  
00198   int samplerate;         
00199   int num_channels;         
00200   gavl_sample_format_t   sample_format; 
00201   gavl_interleave_mode_t interleave_mode; 
00203   float center_level; 
00204   float rear_level;   
00206   gavl_channel_id_t channel_locations[GAVL_MAX_CHANNELS];   
00207   int reserved[8];      
00209   } gavl_audio_format_t;
00210 
00211   
00212 /* Audio format -> string conversions */
00213 
00220 const char * gavl_sample_format_to_string(gavl_sample_format_t format);
00221 
00228 const char * gavl_channel_id_to_string(gavl_channel_id_t id);
00229 
00230 
00237 const char * gavl_interleave_mode_to_string(gavl_interleave_mode_t mode);
00238 
00245 void gavl_audio_format_dump(const gavl_audio_format_t * format);
00246 
00255 int gavl_channel_index(const gavl_audio_format_t * format, gavl_channel_id_t id);
00256 
00263 int gavl_front_channels(const gavl_audio_format_t * format);
00264 
00271 int gavl_rear_channels(const gavl_audio_format_t * format);
00272 
00279 int gavl_side_channels(const gavl_audio_format_t * format);
00280 
00287 int gavl_aux_channels(const gavl_audio_format_t * format);
00288 
00289   
00290   
00297 int gavl_lfe_channels(const gavl_audio_format_t * format);
00298 
00306 void gavl_audio_format_copy(gavl_audio_format_t * dst,
00307                             const gavl_audio_format_t * src);
00308 
00317 int gavl_audio_formats_equal(const gavl_audio_format_t * format_1,
00318                               const gavl_audio_format_t * format_2);
00319 
00331 void gavl_set_channel_setup(gavl_audio_format_t * format);
00332 
00339 int gavl_bytes_per_sample(gavl_sample_format_t format);
00340 
00355 typedef union gavl_audio_samples_u
00356   {
00357   uint8_t * u_8; 
00358   int8_t *  s_8; 
00360   uint16_t * u_16; 
00361   int16_t  * s_16; 
00363   uint32_t * u_32; 
00364   int32_t  * s_32; 
00366   float * f; 
00367   } gavl_audio_samples_t;
00368 
00369 
00375 typedef union gavl_audio_channels_u
00376   {
00377   uint8_t * u_8[GAVL_MAX_CHANNELS];
00378   int8_t *  s_8[GAVL_MAX_CHANNELS];
00380   uint16_t * u_16[GAVL_MAX_CHANNELS];
00381   int16_t  * s_16[GAVL_MAX_CHANNELS];
00383   uint32_t * u_32[GAVL_MAX_CHANNELS];
00384   int32_t  * s_32[GAVL_MAX_CHANNELS];
00386   float * f[GAVL_MAX_CHANNELS];
00388   } gavl_audio_channels_t;
00389 
00406 typedef struct gavl_audio_frame_s
00407   {
00408   gavl_audio_samples_t  samples; 
00409   gavl_audio_channels_t channels;
00410   int valid_samples;             
00411   int64_t timestamp;             
00412   int channel_stride;            
00413   int reserved[8];               
00414   } gavl_audio_frame_t;
00415 
00427 gavl_audio_frame_t * gavl_audio_frame_create(const gavl_audio_format_t* format);
00428 
00440 void gavl_audio_frame_null(gavl_audio_frame_t * frame);
00441 
00451 void gavl_audio_frame_destroy(gavl_audio_frame_t * frame);
00452 
00462 void gavl_audio_frame_mute(gavl_audio_frame_t * frame,
00463                            const gavl_audio_format_t * format);
00464 
00472 void gavl_audio_frame_swap_endian(gavl_audio_frame_t * frame,
00473                                   const gavl_audio_format_t * format);
00474   
00475   
00486 void gavl_audio_frame_mute_channel(gavl_audio_frame_t * frame,
00487                                    const gavl_audio_format_t * format,
00488                                    int channel);
00489   
00510 int gavl_audio_frame_copy(const gavl_audio_format_t * format,
00511                           gavl_audio_frame_t * dst,
00512                           const gavl_audio_frame_t * src,
00513                           int dst_pos,
00514                           int src_pos,
00515                           int dst_size,
00516                           int src_size);
00517 
00532 #define GAVL_AUDIO_FRONT_TO_REAR_COPY (1<<0) 
00537 #define GAVL_AUDIO_FRONT_TO_REAR_MUTE (1<<1) 
00542 #define GAVL_AUDIO_FRONT_TO_REAR_DIFF (1<<2) 
00547 #define GAVL_AUDIO_FRONT_TO_REAR_MASK           \
00548 (GAVL_AUDIO_FRONT_TO_REAR_COPY | \
00549 GAVL_AUDIO_FRONT_TO_REAR_MUTE | \
00550  GAVL_AUDIO_FRONT_TO_REAR_DIFF) 
00552 /* Options for mixing stereo to mono */
00553   
00556 #define GAVL_AUDIO_STEREO_TO_MONO_LEFT  (1<<3) 
00559 #define GAVL_AUDIO_STEREO_TO_MONO_RIGHT (1<<4) 
00562 #define GAVL_AUDIO_STEREO_TO_MONO_MIX   (1<<5) 
00566 #define GAVL_AUDIO_STEREO_TO_MONO_MASK \
00567 (GAVL_AUDIO_STEREO_TO_MONO_LEFT | \
00568 GAVL_AUDIO_STEREO_TO_MONO_RIGHT | \
00569 GAVL_AUDIO_STEREO_TO_MONO_MIX) 
00575 typedef enum
00576   {
00577     GAVL_AUDIO_DITHER_NONE   = 0,
00578     GAVL_AUDIO_DITHER_AUTO   = 1,
00579     GAVL_AUDIO_DITHER_RECT   = 2,
00580     GAVL_AUDIO_DITHER_TRI    = 3,
00581     GAVL_AUDIO_DITHER_SHAPED = 4,
00582   } gavl_audio_dither_mode_t;
00583 
00588 typedef enum
00589   {
00590     GAVL_RESAMPLE_AUTO        = 0, 
00591     GAVL_RESAMPLE_ZOH         = 1, 
00592     GAVL_RESAMPLE_LINEAR      = 2, 
00593     GAVL_RESAMPLE_SINC_FAST   = 3, 
00594     GAVL_RESAMPLE_SINC_MEDIUM = 4, 
00595     GAVL_RESAMPLE_SINC_BEST   = 5  
00596   } gavl_resample_mode_t;
00597   
00604 typedef struct gavl_audio_options_s gavl_audio_options_t;
00605 
00612 void gavl_audio_options_set_quality(gavl_audio_options_t * opt, int quality);
00613 
00620 int gavl_audio_options_get_quality(gavl_audio_options_t * opt);
00621   
00628 void gavl_audio_options_set_dither_mode(gavl_audio_options_t * opt, gavl_audio_dither_mode_t mode);
00629 
00636 gavl_audio_dither_mode_t gavl_audio_options_get_dither_mode(gavl_audio_options_t * opt);
00637 
00638   
00645 void gavl_audio_options_set_resample_mode(gavl_audio_options_t * opt, gavl_resample_mode_t mode);
00646 
00653 gavl_resample_mode_t gavl_audio_options_get_resample_mode(gavl_audio_options_t * opt);
00654   
00661 void gavl_audio_options_set_conversion_flags(gavl_audio_options_t * opt,
00662                                              int flags);
00663   
00670 int gavl_audio_options_get_conversion_flags(gavl_audio_options_t * opt);
00671 
00677 void gavl_audio_options_set_defaults(gavl_audio_options_t * opt);
00678 
00688 gavl_audio_options_t * gavl_audio_options_create();
00689 
00696 void gavl_audio_options_copy(gavl_audio_options_t * dst,
00697                              const gavl_audio_options_t * src);
00698 
00704 void gavl_audio_options_destroy(gavl_audio_options_t * opt);
00705   
00706   
00707   
00708 /* Audio converter */
00709 
00743 typedef struct gavl_audio_converter_s gavl_audio_converter_t;
00744   
00750 gavl_audio_converter_t * gavl_audio_converter_create();
00751 
00757 void gavl_audio_converter_destroy(gavl_audio_converter_t* cnv);
00758 
00767 gavl_audio_options_t * gavl_audio_converter_get_options(gavl_audio_converter_t*cnv);
00768 
00769 
00783 int gavl_audio_converter_init(gavl_audio_converter_t* cnv,
00784                               const gavl_audio_format_t * input_format,
00785                               const gavl_audio_format_t * output_format);
00786 
00800 int gavl_audio_converter_reinit(gavl_audio_converter_t* cnv);
00801 
00802   
00816 void gavl_audio_convert(gavl_audio_converter_t * cnv,
00817                         const gavl_audio_frame_t * input_frame,
00818                         gavl_audio_frame_t * output_frame);
00819 
00820 
00821 
00822 
00836 typedef struct gavl_volume_control_s gavl_volume_control_t;
00837   
00838 /* Create / destroy */
00839 
00845 gavl_volume_control_t * gavl_volume_control_create();
00846 
00852 void gavl_volume_control_destroy(gavl_volume_control_t *ctrl);
00853 
00861 void gavl_volume_control_set_format(gavl_volume_control_t *ctrl,
00862                                     const gavl_audio_format_t * format);
00863 
00870 void gavl_volume_control_set_volume(gavl_volume_control_t * ctrl,
00871                                     float volume);
00872 
00879 void gavl_volume_control_apply(gavl_volume_control_t *ctrl,
00880                                gavl_audio_frame_t * frame);
00881 
00897 typedef struct gavl_peak_detector_s gavl_peak_detector_t;
00898   
00899 /* Create / destroy */
00900 
00906 gavl_peak_detector_t * gavl_peak_detector_create();
00907 
00913 void gavl_peak_detector_destroy(gavl_peak_detector_t *pd);
00914 
00924 void gavl_peak_detector_set_format(gavl_peak_detector_t *pd,
00925                                    const gavl_audio_format_t * format);
00926 
00933 void gavl_peak_detector_update(gavl_peak_detector_t *pd,
00934                               gavl_audio_frame_t * frame);
00935   
00948 void gavl_peak_detector_get_peak(gavl_peak_detector_t * pd,
00949                                  double * min, double * max,
00950                                  double * abs);
00951 
00964 void gavl_peak_detector_get_peaks(gavl_peak_detector_t * pd,
00965                                   double * min, double * max,
00966                                   double * abs);
00967   
00973 void gavl_peak_detector_reset(gavl_peak_detector_t * pd);
00974   
00984 #define GAVL_MAX_PLANES 4 
00996 typedef struct
00997   {
00998   int x; 
00999   int y; 
01000   int w; 
01001   int h; 
01002   } gavl_rectangle_i_t;
01003 
01008 typedef struct
01009   {
01010   double x; 
01011   double y; 
01012   double w; 
01013   double h; 
01014   } gavl_rectangle_f_t;
01015 
01022 void gavl_rectangle_i_crop_to_format(gavl_rectangle_i_t * r,
01023                                    const gavl_video_format_t * format);
01024 
01031 void gavl_rectangle_f_crop_to_format(gavl_rectangle_f_t * r,
01032                                      const gavl_video_format_t * format);
01033 
01048 void gavl_rectangle_crop_to_format_noscale(gavl_rectangle_i_t * src_rect,
01049                                            gavl_rectangle_i_t * dst_rect,
01050                                            const gavl_video_format_t * src_format,
01051                                            const gavl_video_format_t * dst_format);
01052 
01064 void gavl_rectangle_crop_to_format_scale(gavl_rectangle_f_t * src_rect,
01065                                          gavl_rectangle_i_t * dst_rect,
01066                                          const gavl_video_format_t * src_format,
01067                                          const gavl_video_format_t * dst_format);
01068 
01069   
01070 
01077 void gavl_rectangle_i_set_all(gavl_rectangle_i_t * r, const gavl_video_format_t * format);
01078 
01085 void gavl_rectangle_f_set_all(gavl_rectangle_f_t * r, const gavl_video_format_t * format);
01086 
01093 void gavl_rectangle_i_crop_left(gavl_rectangle_i_t * r,   int num_pixels);
01094 
01101 void gavl_rectangle_i_crop_right(gavl_rectangle_i_t * r,  int num_pixels);
01102 
01109 void gavl_rectangle_i_crop_top(gavl_rectangle_i_t * r,    int num_pixels);
01110 
01117 void gavl_rectangle_i_crop_bottom(gavl_rectangle_i_t * r, int num_pixels);
01118 
01125 void gavl_rectangle_f_crop_left(gavl_rectangle_f_t * r,   double num_pixels);
01126 
01133 void gavl_rectangle_f_crop_right(gavl_rectangle_f_t * r,  double num_pixels);
01134 
01141 void gavl_rectangle_f_crop_top(gavl_rectangle_f_t * r,    double num_pixels);
01142 
01149 void gavl_rectangle_f_crop_bottom(gavl_rectangle_f_t * r, double num_pixels);
01150 
01164 void gavl_rectangle_i_align(gavl_rectangle_i_t * r, int h_align, int v_align);
01165 
01175 void gavl_rectangle_i_align_to_format(gavl_rectangle_i_t * r,
01176                                       const gavl_video_format_t * format);
01177 
01178   
01185 void gavl_rectangle_i_copy(gavl_rectangle_i_t * dst, const gavl_rectangle_i_t * src);
01186 
01193 void gavl_rectangle_f_copy(gavl_rectangle_f_t * dst, const gavl_rectangle_f_t * src);
01194 
01195 
01196 
01203 void gavl_rectangle_i_to_f(gavl_rectangle_f_t * dst, const gavl_rectangle_i_t * src);
01204 
01211 void gavl_rectangle_f_to_i(gavl_rectangle_i_t * dst, const gavl_rectangle_f_t * src);
01212   
01221 int gavl_rectangle_i_is_empty(const gavl_rectangle_i_t * r);
01222 
01231 int gavl_rectangle_f_is_empty(const gavl_rectangle_f_t * r);
01232 
01260 void gavl_rectangle_fit_aspect(gavl_rectangle_i_t * dst_rect,
01261                                const gavl_video_format_t * src_format,
01262                                const gavl_rectangle_f_t * src_rect,
01263                                const gavl_video_format_t * dst_format,
01264                                float zoom, float squeeze);
01265 
01270 void gavl_rectangle_i_dump(const gavl_rectangle_i_t * r);
01271 
01276 void gavl_rectangle_f_dump(const gavl_rectangle_f_t * r);
01277 
01278   
01288 #define GAVL_PIXFMT_PLANAR (1<<8)
01289 
01293 #define GAVL_PIXFMT_RGB    (1<<9)
01294 
01298 #define GAVL_PIXFMT_YUV    (1<<10)
01299 
01303 #define GAVL_PIXFMT_YUVJ   (1<<11)
01304 
01308 #define GAVL_PIXFMT_ALPHA  (1<<12)
01309   
01310   
01315 typedef enum 
01316   {
01319     GAVL_PIXELFORMAT_NONE =  0, 
01320 
01324     GAVL_RGB_15          =  1 | GAVL_PIXFMT_RGB,
01328     GAVL_BGR_15          =  2 | GAVL_PIXFMT_RGB,
01332     GAVL_RGB_16          =  3 | GAVL_PIXFMT_RGB,
01336     GAVL_BGR_16          =  4 | GAVL_PIXFMT_RGB,
01339     GAVL_RGB_24          =  5 | GAVL_PIXFMT_RGB,
01342     GAVL_BGR_24          =  6 | GAVL_PIXFMT_RGB,
01345     GAVL_RGB_32          =  7 | GAVL_PIXFMT_RGB,
01348     GAVL_BGR_32          =  8 | GAVL_PIXFMT_RGB,
01351     GAVL_RGBA_32         =  9 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA,
01354     GAVL_YUY2            = 10 | GAVL_PIXFMT_YUV,
01357     GAVL_UYVY            = 11 | GAVL_PIXFMT_YUV,
01360     GAVL_YUVA_32         = 26 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
01363     GAVL_YUV_420_P       = 12 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01366     GAVL_YUV_422_P       = 13 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01369     GAVL_YUV_444_P       = 14 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01372     GAVL_YUV_411_P       = 15 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01375     GAVL_YUV_410_P       = 16 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01376     
01379     GAVL_YUVJ_420_P      = 17 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
01382     GAVL_YUVJ_422_P      = 18 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
01385     GAVL_YUVJ_444_P      = 19 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
01386 
01389     GAVL_YUV_444_P_16 = 20 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01392     GAVL_YUV_422_P_16 = 21 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
01393 
01396     GAVL_RGB_48       = 22 | GAVL_PIXFMT_RGB,
01399     GAVL_RGBA_64      = 23 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA,
01400         
01403     GAVL_RGB_FLOAT    = 24 | GAVL_PIXFMT_RGB,
01406     GAVL_RGBA_FLOAT   = 25 | GAVL_PIXFMT_RGB  | GAVL_PIXFMT_ALPHA
01407     
01408   } gavl_pixelformat_t;
01409 
01410 /*
01411  *  Colormodel related functions
01412  */
01413 
01420 #define gavl_pixelformat_is_rgb(fmt) ((fmt) & GAVL_PIXFMT_RGB)
01421 
01428 #define gavl_pixelformat_is_yuv(fmt) ((fmt) & GAVL_PIXFMT_YUV)
01429 
01436 #define gavl_pixelformat_is_jpeg_scaled(fmt) ((fmt) & GAVL_PIXFMT_YUVJ)
01437 
01444 #define gavl_pixelformat_has_alpha(fmt) ((fmt) & GAVL_PIXFMT_ALPHA)
01445 
01452 #define  gavl_pixelformat_is_planar(fmt) ((fmt) & GAVL_PIXFMT_PLANAR)
01453 
01460 int gavl_pixelformat_num_planes(gavl_pixelformat_t pixelformat);
01461 
01471 void gavl_pixelformat_chroma_sub(gavl_pixelformat_t pixelformat, int * sub_h, int * sub_v);
01472 
01479 int gavl_pixelformat_bytes_per_component(gavl_pixelformat_t pixelformat);
01480 
01487 int gavl_pixelformat_bytes_per_pixel(gavl_pixelformat_t pixelformat);
01488   
01495 int gavl_pixelformat_bits_per_pixel(gavl_pixelformat_t pixelformat);
01496 
01511 int gavl_pixelformat_conversion_penalty(gavl_pixelformat_t src,
01512                                         gavl_pixelformat_t dst);
01513 
01527 gavl_pixelformat_t 
01528 gavl_pixelformat_get_best(gavl_pixelformat_t src,
01529                           gavl_pixelformat_t * dst_supported,
01530                           int * penalty);
01531   
01532 
01533 
01540 const char * gavl_pixelformat_to_string(gavl_pixelformat_t pixelformat);
01541 
01548 gavl_pixelformat_t gavl_string_to_pixelformat(const char * name);
01549 
01555 int gavl_num_pixelformats();
01556 
01563 gavl_pixelformat_t gavl_get_pixelformat(int index);
01564 
01565 /*  */
01566 
01575 typedef enum
01576   {
01577     GAVL_CHROMA_PLACEMENT_DEFAULT = 0, 
01578     GAVL_CHROMA_PLACEMENT_MPEG2,       
01579     GAVL_CHROMA_PLACEMENT_DVPAL        
01580   } gavl_chroma_placement_t;
01581 
01588 const char * gavl_chroma_placement_to_string(gavl_chroma_placement_t mode);
01589   
01594 typedef enum
01595   {
01596     GAVL_FRAMERATE_CONSTANT    = 0, 
01597     GAVL_FRAMERATE_VARIABLE    = 1, 
01598     GAVL_FRAMERATE_STILL       = 2, 
01599   } gavl_framerate_mode_t;
01600 
01605 typedef enum
01606   {
01607     GAVL_INTERLACE_NONE = 0,    
01608     GAVL_INTERLACE_TOP_FIRST,   
01609     GAVL_INTERLACE_BOTTOM_FIRST,
01610     GAVL_INTERLACE_MIXED        
01611   } gavl_interlace_mode_t;
01612 
01619 const char * gavl_interlace_mode_to_string(gavl_interlace_mode_t mode);
01620   
01621   
01622 /* Video format structure */
01623   
01628 struct gavl_video_format_s
01629   {
01630   int frame_width;
01631   int frame_height;
01633   int image_width;
01634   int image_height;
01636   /* Support for nonsquare pixels */
01637     
01638   int pixel_width;
01639   int pixel_height;
01641   gavl_pixelformat_t pixelformat;
01643   int frame_duration;
01645   int timescale;
01647   gavl_framerate_mode_t   framerate_mode;
01648   gavl_chroma_placement_t chroma_placement;
01650   gavl_interlace_mode_t   interlace_mode;
01651   int reserved[8];      
01652   };
01653 
01661 void gavl_video_format_copy(gavl_video_format_t * dst,
01662                             const gavl_video_format_t * src);
01663 
01672 int gavl_video_formats_equal(const gavl_video_format_t * format_1,
01673                              const gavl_video_format_t * format_2);
01674 
01675   
01686 void gavl_video_format_get_chroma_offset(const gavl_video_format_t * format, int field, int plane,
01687                                          float * off_x, float * off_y);
01688   
01689 
01690   
01697 void gavl_video_format_dump(const gavl_video_format_t * format);
01698 
01711 void gavl_video_format_fit_to_source(gavl_video_format_t * dst,
01712                                      const gavl_video_format_t * src);
01713 
01714   
01737 typedef struct gavl_video_frame_s
01738   {
01739   uint8_t * planes[GAVL_MAX_PLANES]; 
01740   int strides[GAVL_MAX_PLANES];      
01742   void * user_data;    
01743   int64_t timestamp; 
01744   int64_t duration; 
01745   gavl_interlace_mode_t   interlace_mode;
01746   int reserved[8];      
01747   } gavl_video_frame_t;
01748 
01749 
01761 gavl_video_frame_t * gavl_video_frame_create(const gavl_video_format_t*format);
01762 
01773 gavl_video_frame_t * gavl_video_frame_create_nopad(const gavl_video_format_t*format);
01774 
01775   
01776 
01786 void gavl_video_frame_destroy(gavl_video_frame_t*frame);
01787 
01799 void gavl_video_frame_null(gavl_video_frame_t*frame);
01800   
01809 void gavl_video_frame_clear(gavl_video_frame_t * frame,
01810                             const gavl_video_format_t * format);
01811 
01821 void gavl_video_frame_fill(gavl_video_frame_t * frame,
01822                            const gavl_video_format_t * format,
01823                            float * color);
01824 
01825   
01838 void gavl_video_frame_copy(const gavl_video_format_t * format,
01839                            gavl_video_frame_t * dst,
01840                            const gavl_video_frame_t * src);
01841 
01854 void gavl_video_frame_copy_plane(const gavl_video_format_t * format,
01855                                  gavl_video_frame_t * dst,
01856                                  const gavl_video_frame_t * src, int plane);
01857 
01869 void gavl_video_frame_copy_flip_x(const gavl_video_format_t * format,
01870                                   gavl_video_frame_t * dst,
01871                                   const gavl_video_frame_t * src);
01872 
01884 void gavl_video_frame_copy_flip_y(const gavl_video_format_t * format,
01885                                   gavl_video_frame_t * dst,
01886                                   const gavl_video_frame_t * src);
01887 
01899 void gavl_video_frame_copy_flip_xy(const gavl_video_format_t * format,
01900                                    gavl_video_frame_t * dst,
01901                                   const gavl_video_frame_t * src);
01902 
01920 void gavl_video_frame_get_subframe(gavl_pixelformat_t pixelformat,
01921                                    const gavl_video_frame_t * src,
01922                                    gavl_video_frame_t * dst,
01923                                    gavl_rectangle_i_t * src_rect);
01924 
01940 void gavl_video_frame_get_field(gavl_pixelformat_t pixelformat,
01941                                 const gavl_video_frame_t * src,
01942                                 gavl_video_frame_t * dst,
01943                                 int field);
01944 
01945   
01946 
01959 void gavl_video_frame_dump(gavl_video_frame_t * frame,
01960                            const gavl_video_format_t * format,
01961                            const char * namebase);
01962   
01963 /*****************************
01964  Conversion options
01965 ******************************/
01966 
01982 #define GAVL_FORCE_DEINTERLACE (1<<0)
01983 
01988 #define GAVL_CONVOLVE_CHROMA   (1<<1)
01989 
01994 #define GAVL_CONVOLVE_NORMALIZE (1<<2)
01995 
02003 #define GAVL_RESAMPLE_CHROMA    (1<<3)
02004   
02012 typedef enum
02013   {
02014     GAVL_ALPHA_IGNORE      = 0, 
02015     GAVL_ALPHA_BLEND_COLOR      
02016   } gavl_alpha_mode_t;
02017 
02024 typedef enum
02025   {
02026     GAVL_DEINTERLACE_NONE      = 0, 
02027     GAVL_DEINTERLACE_COPY      = 1, 
02028     GAVL_DEINTERLACE_SCALE     = 2, 
02029     GAVL_DEINTERLACE_BLEND     = 3  
02030   } gavl_deinterlace_mode_t;
02031 
02038 typedef enum
02039   {
02040     GAVL_DEINTERLACE_DROP_TOP,    
02041     GAVL_DEINTERLACE_DROP_BOTTOM, 
02042   } gavl_deinterlace_drop_mode_t;
02043   
02048 typedef enum
02049   {
02050     GAVL_SCALE_AUTO,          
02051     GAVL_SCALE_NEAREST,       
02052     GAVL_SCALE_BILINEAR,      
02053     GAVL_SCALE_QUADRATIC,     
02054     GAVL_SCALE_CUBIC_BSPLINE, 
02055     GAVL_SCALE_CUBIC_MITCHELL,
02056     GAVL_SCALE_CUBIC_CATMULL, 
02057     GAVL_SCALE_SINC_LANCZOS,  
02058     GAVL_SCALE_NONE,          
02059   } gavl_scale_mode_t;
02060 
02067 typedef struct gavl_video_options_s gavl_video_options_t;
02068 
02069 /* Default Options */
02070 
02076 void gavl_video_options_set_defaults(gavl_video_options_t * opt);
02077 
02087 gavl_video_options_t * gavl_video_options_create();
02088 
02095 void gavl_video_options_copy(gavl_video_options_t * dst,
02096                              const gavl_video_options_t * src);
02097 
02103 void gavl_video_options_destroy(gavl_video_options_t * opt);
02104   
02105   
02120 void gavl_video_options_set_rectangles(gavl_video_options_t * opt,
02121                                        const gavl_rectangle_f_t * src_rect,
02122                                        const gavl_rectangle_i_t * dst_rect);
02123 
02130 void gavl_video_options_get_rectangles(gavl_video_options_t * opt,
02131                                        gavl_rectangle_f_t * src_rect,
02132                                        gavl_rectangle_i_t * dst_rect);
02133   
02140 void gavl_video_options_set_quality(gavl_video_options_t * opt, int quality);
02141 
02148 int gavl_video_options_get_quality(gavl_video_options_t * opt);
02149 
02150   
02157 void gavl_video_options_set_conversion_flags(gavl_video_options_t * opt,
02158                                              int conversion_flags);
02159 
02166 int gavl_video_options_get_conversion_flags(gavl_video_options_t * opt);
02167   
02174 void gavl_video_options_set_alpha_mode(gavl_video_options_t * opt,
02175                                        gavl_alpha_mode_t alpha_mode);
02176 
02183 gavl_alpha_mode_t
02184 gavl_video_options_get_alpha_mode(gavl_video_options_t * opt);
02185 
02186   
02193 void gavl_video_options_set_scale_mode(gavl_video_options_t * opt,
02194                                        gavl_scale_mode_t scale_mode);
02195 
02202 gavl_scale_mode_t
02203 gavl_video_options_get_scale_mode(gavl_video_options_t * opt);
02204 
02205   
02212 void gavl_video_options_set_scale_order(gavl_video_options_t * opt,
02213                                         int order);
02214 
02221 int gavl_video_options_get_scale_order(gavl_video_options_t * opt);
02222 
02223   
02230 void gavl_video_options_set_background_color(gavl_video_options_t * opt,
02231                                              const float * color);
02232 
02239 void gavl_video_options_get_background_color(gavl_video_options_t * opt,
02240                                              float * color);
02241   
02248 void gavl_video_options_set_deinterlace_mode(gavl_video_options_t * opt,
02249                                              gavl_deinterlace_mode_t deinterlace_mode);
02250 
02257 gavl_deinterlace_mode_t
02258 gavl_video_options_get_deinterlace_mode(gavl_video_options_t * opt);
02259 
02266 void gavl_video_options_set_deinterlace_drop_mode(gavl_video_options_t * opt,
02267                                                   gavl_deinterlace_drop_mode_t deinterlace_drop_mode);
02268 
02275 gavl_deinterlace_drop_mode_t
02276 gavl_video_options_get_deinterlace_drop_mode(gavl_video_options_t * opt);
02277  
02278   
02279 /***************************************************
02280  * Create and destroy video converters
02281  ***************************************************/
02282   
02315 typedef struct gavl_video_converter_s gavl_video_converter_t;
02316 
02322 gavl_video_converter_t * gavl_video_converter_create();
02323 
02329 void gavl_video_converter_destroy(gavl_video_converter_t*cnv);
02330 
02331 /**************************************************
02332  * Get options. Change the options with the gavl_video_options_set_*
02333  * functions above
02334  **************************************************/
02335 
02344 gavl_video_options_t *
02345 gavl_video_converter_get_options(gavl_video_converter_t*cnv);
02346 
02347 
02361 int gavl_video_converter_init(gavl_video_converter_t* cnv,
02362                               const gavl_video_format_t * input_format,
02363                               const gavl_video_format_t * output_format);
02364 
02377 int gavl_video_converter_reinit(gavl_video_converter_t* cnv);
02378  
02379   
02380 /***************************************************
02381  * Convert a frame
02382  ***************************************************/
02383 
02391 void gavl_video_convert(gavl_video_converter_t * cnv,
02392                         const gavl_video_frame_t * input_frame,
02393                         gavl_video_frame_t * output_frame);
02394 
02426 typedef struct gavl_video_scaler_s gavl_video_scaler_t;
02427 
02433 gavl_video_scaler_t * gavl_video_scaler_create();
02434 
02440 void gavl_video_scaler_destroy(gavl_video_scaler_t * scaler);
02441 
02450 gavl_video_options_t *
02451 gavl_video_scaler_get_options(gavl_video_scaler_t * scaler);
02452 
02465 int gavl_video_scaler_init(gavl_video_scaler_t * scaler,
02466                            const gavl_video_format_t * src_format,
02467                            const gavl_video_format_t * dst_format);
02468 
02490 int gavl_video_scaler_init_convolve(gavl_video_scaler_t * scaler,
02491                                     const gavl_video_format_t * format,
02492                                     int h_radius, float * h_coeffs,
02493                                     int v_radius, float * v_coeffs);
02494   
02502 void gavl_video_scaler_scale(gavl_video_scaler_t * scaler,
02503                              const gavl_video_frame_t * input_frame,
02504                              gavl_video_frame_t * output_frame);
02505 
02521 typedef struct gavl_video_deinterlacer_s gavl_video_deinterlacer_t;
02522 
02528 gavl_video_deinterlacer_t * gavl_video_deinterlacer_create();
02529 
02535 void gavl_video_deinterlacer_destroy(gavl_video_deinterlacer_t * deinterlacer);
02536 
02545 gavl_video_options_t *
02546 gavl_video_deinterlacer_get_options(gavl_video_deinterlacer_t * deinterlacer);
02547 
02558 int gavl_video_deinterlacer_init(gavl_video_deinterlacer_t * deinterlacer,
02559                                  const gavl_video_format_t * src_format);
02560 
02561   
02569 void gavl_video_deinterlacer_deinterlace(gavl_video_deinterlacer_t * deinterlacer,
02570                                          const gavl_video_frame_t * input_frame,
02571                                          gavl_video_frame_t * output_frame);
02572 
02573   
02574   
02575 /**************************************************
02576  * Transparent overlays 
02577  **************************************************/
02578 
02579 /* Overlay struct */
02580 
02608 typedef struct
02609   {
02610   gavl_video_frame_t * frame;    
02611   gavl_rectangle_i_t ovl_rect;   
02612   int dst_x;                     
02613   int dst_y;                     
02614   } gavl_overlay_t;
02615 
02622 typedef struct gavl_overlay_blend_context_s gavl_overlay_blend_context_t;
02623 
02629 gavl_overlay_blend_context_t * gavl_overlay_blend_context_create();
02630 
02636 void gavl_overlay_blend_context_destroy(gavl_overlay_blend_context_t * ctx);
02637 
02644 gavl_video_options_t *
02645 gavl_overlay_blend_context_get_options(gavl_overlay_blend_context_t * ctx);
02646 
02662 int gavl_overlay_blend_context_init(gavl_overlay_blend_context_t * ctx,
02663                                     const gavl_video_format_t * frame_format,
02664                                     gavl_video_format_t * overlay_format);
02665 
02675 void gavl_overlay_blend_context_set_overlay(gavl_overlay_blend_context_t * ctx,
02676                                             gavl_overlay_t * ovl);
02677 
02684 void gavl_overlay_blend(gavl_overlay_blend_context_t * ctx,
02685                         gavl_video_frame_t * dst_frame);
02686   
02687 #ifdef __cplusplus
02688 }
02689 #endif
02690 
02691 #endif /* GAVL_H_INCLUDED */

Generated on Wed Jan 9 19:32:28 2008 for gavl by  doxygen 1.5.3