• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavcodec/ivi_common.h

Go to the documentation of this file.
00001 /*
00002  * common functions for Indeo Video Interactive codecs (Indeo4 and Indeo5)
00003  *
00004  * Copyright (c) 2009 Maxim Poliakovski
00005  *
00006  * This file is part of FFmpeg.
00007  *
00008  * FFmpeg is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * FFmpeg 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 GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with FFmpeg; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00021  */
00022 
00029 #ifndef AVCODEC_IVI_COMMON_H
00030 #define AVCODEC_IVI_COMMON_H
00031 
00032 #include "avcodec.h"
00033 #include "get_bits.h"
00034 #include <stdint.h>
00035 
00036 #define IVI_DEBUG 0
00037 
00038 #define IVI_VLC_BITS 13 ///< max number of bits of the ivi's huffman codes
00039 
00043 typedef struct {
00044     int32_t     num_rows;
00045     uint8_t     xbits[16];
00046 } IVIHuffDesc;
00047 
00051 typedef struct {
00052     int32_t     tab_sel;    
00053 
00054     VLC         *tab;       
00055 
00057     IVIHuffDesc cust_desc;  
00058     VLC         cust_tab;   
00059 } IVIHuffTab;
00060 
00061 enum {
00062     IVI_MB_HUFF   = 0,      
00063     IVI_BLK_HUFF  = 1       
00064 };
00065 
00066 extern VLC ff_ivi_mb_vlc_tabs [8]; 
00067 extern VLC ff_ivi_blk_vlc_tabs[8]; 
00068 
00069 
00073 typedef struct {
00074     uint8_t     eob_sym; 
00075     uint8_t     esc_sym; 
00076     uint8_t     runtab[256];
00077     int8_t      valtab[256];
00078 } RVMapDesc;
00079 
00080 extern const RVMapDesc ff_ivi_rvmap_tabs[9];
00081 
00082 
00086 typedef struct {
00087     int16_t     xpos;
00088     int16_t     ypos;
00089     uint32_t    buf_offs; 
00090     uint8_t     type;     
00091     uint8_t     cbp;      
00092     int8_t      q_delta;  
00093     int8_t      mv_x;     
00094     int8_t      mv_y;     
00095 } IVIMbInfo;
00096 
00097 
00101 typedef struct {
00102     int         xpos;
00103     int         ypos;
00104     int         width;
00105     int         height;
00106     int         is_empty;  
00107     int         data_size; 
00108     int         num_MBs;   
00109     IVIMbInfo   *mbs;      
00110     IVIMbInfo   *ref_mbs;  
00111 } IVITile;
00112 
00113 
00117 typedef struct {
00118     int             plane;          
00119     int             band_num;       
00120     int             width;
00121     int             height;
00122     const uint8_t   *data_ptr;      
00123     int             data_size;      
00124     int16_t         *buf;           
00125     int16_t         *ref_buf;       
00126     int16_t         *bufs[3];       
00127     int             pitch;          
00128     int             is_empty;       
00129     int             mb_size;        
00130     int             blk_size;       
00131     int             is_halfpel;     
00132     int             inherit_mv;     
00133     int             inherit_qdelta; 
00134     int             qdelta_present; 
00135     int             quant_mat;      
00136     int             glob_quant;     
00137     const uint8_t   *scan;          
00138 
00139     IVIHuffTab      blk_vlc;        
00140 
00141     uint16_t        *dequant_intra; 
00142     uint16_t        *dequant_inter; 
00143     int             num_corr;       
00144     uint8_t         corr[61*2];     
00145     int             rvmap_sel;      
00146     RVMapDesc       *rv_map;        
00147     int             num_tiles;      
00148     IVITile         *tiles;         
00149     void (*inv_transform)(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags); 
00150     void (*dc_transform) (const int32_t *in, int16_t *out, uint32_t pitch, int blk_size);   
00151     int             is_2d_trans;    
00152     int32_t         checksum;       
00153     int             checksum_present;
00154     int             bufsize;        
00155     const uint8_t   *intra_base;    
00156     const uint8_t   *inter_base;    
00157     const uint8_t   *intra_scale;   
00158     const uint8_t   *inter_scale;   
00159 } IVIBandDesc;
00160 
00161 
00165 typedef struct {
00166     uint16_t    width;
00167     uint16_t    height;
00168     uint8_t     num_bands;  
00169     IVIBandDesc *bands;     
00170 } IVIPlaneDesc;
00171 
00172 
00173 typedef struct {
00174     uint16_t    pic_width;
00175     uint16_t    pic_height;
00176     uint16_t    chroma_width;
00177     uint16_t    chroma_height;
00178     uint16_t    tile_width;
00179     uint16_t    tile_height;
00180     uint8_t     luma_bands;
00181     uint8_t     chroma_bands;
00182 } IVIPicConfig;
00183 
00185 static inline int ivi_pic_config_cmp(IVIPicConfig *str1, IVIPicConfig *str2)
00186 {
00187     return (str1->pic_width    != str2->pic_width    || str1->pic_height    != str2->pic_height    ||
00188             str1->chroma_width != str2->chroma_width || str1->chroma_height != str2->chroma_height ||
00189             str1->tile_width   != str2->tile_width   || str1->tile_height   != str2->tile_height   ||
00190             str1->luma_bands   != str2->luma_bands   || str1->chroma_bands  != str2->chroma_bands);
00191 }
00192 
00194 #define IVI_NUM_TILES(stride, tile_size) (((stride) + (tile_size) - 1) / (tile_size))
00195 
00197 #define IVI_MBs_PER_TILE(tile_width, tile_height, mb_size) \
00198     ((((tile_width) + (mb_size) - 1) / (mb_size)) * (((tile_height) + (mb_size) - 1) / (mb_size)))
00199 
00201 #define IVI_TOSIGNED(val) (-(((val) >> 1) ^ -((val) & 1)))
00202 
00204 static inline int ivi_scale_mv(int mv, int mv_scale)
00205 {
00206     return (mv + (mv > 0) + (mv_scale - 1)) >> mv_scale;
00207 }
00208 
00218 int  ff_ivi_create_huff_from_desc(const IVIHuffDesc *cb, VLC *vlc, int flag);
00219 
00223 void ff_ivi_init_static_vlc(void);
00224 
00236 int  ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab,
00237                           IVIHuffTab *huff_tab, AVCodecContext *avctx);
00238 
00246 int  ff_ivi_huff_desc_cmp(const IVIHuffDesc *desc1, const IVIHuffDesc *desc2);
00247 
00254 void ff_ivi_huff_desc_copy(IVIHuffDesc *dst, const IVIHuffDesc *src);
00255 
00263 int  ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg);
00264 
00270 void ff_ivi_free_buffers(IVIPlaneDesc *planes);
00271 
00280 int  ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_height);
00281 
00292 int  ff_ivi_dec_tile_data_size(GetBitContext *gb);
00293 
00305 int  ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile);
00306 
00316 void ff_ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band,
00317                                IVITile *tile, int32_t mv_scale);
00318 
00328 void ff_ivi_output_plane(IVIPlaneDesc *plane, uint8_t *dst, int dst_pitch);
00329 
00330 #if IVI_DEBUG
00331 
00334 uint16_t ivi_calc_band_checksum (IVIBandDesc *band);
00335 
00339 int ivi_check_band (IVIBandDesc *band, const uint8_t *ref, int pitch);
00340 #endif
00341 
00342 #endif /* AVCODEC_IVI_COMMON_H */

Generated on Fri Sep 16 2011 17:17:38 for FFmpeg by  doxygen 1.7.1