• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • 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_VLC_BITS 13 ///< max number of bits of the ivi's huffman codes
00037 
00041 typedef struct {
00042     int32_t     num_rows;
00043     uint8_t     xbits[16];
00044 } IVIHuffDesc;
00045 
00049 typedef struct {
00050     int32_t     tab_sel;    
00051 
00052     VLC         *tab;       
00053 
00055     IVIHuffDesc cust_desc;  
00056     VLC         cust_tab;   
00057 } IVIHuffTab;
00058 
00059 enum {
00060     IVI_MB_HUFF   = 0,      
00061     IVI_BLK_HUFF  = 1       
00062 };
00063 
00064 extern VLC ff_ivi_mb_vlc_tabs [8]; 
00065 extern VLC ff_ivi_blk_vlc_tabs[8]; 
00066 
00067 
00071 extern const uint8_t ff_ivi_vertical_scan_8x8[64];
00072 extern const uint8_t ff_ivi_horizontal_scan_8x8[64];
00073 extern const uint8_t ff_ivi_direct_scan_4x4[16];
00074 
00075 
00079 typedef void (InvTransformPtr)(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags);
00080 typedef void (DCTransformPtr) (const int32_t *in, int16_t *out, uint32_t pitch, int blk_size);
00081 
00082 
00086 typedef struct {
00087     uint8_t     eob_sym; 
00088     uint8_t     esc_sym; 
00089     uint8_t     runtab[256];
00090     int8_t      valtab[256];
00091 } RVMapDesc;
00092 
00093 extern const RVMapDesc ff_ivi_rvmap_tabs[9];
00094 
00095 
00099 typedef struct {
00100     int16_t     xpos;
00101     int16_t     ypos;
00102     uint32_t    buf_offs; 
00103     uint8_t     type;     
00104     uint8_t     cbp;      
00105     int8_t      q_delta;  
00106     int8_t      mv_x;     
00107     int8_t      mv_y;     
00108 } IVIMbInfo;
00109 
00110 
00114 typedef struct {
00115     int         xpos;
00116     int         ypos;
00117     int         width;
00118     int         height;
00119     int         is_empty;  
00120     int         data_size; 
00121     int         num_MBs;   
00122     IVIMbInfo   *mbs;      
00123     IVIMbInfo   *ref_mbs;  
00124 } IVITile;
00125 
00126 
00130 typedef struct {
00131     int             plane;          
00132     int             band_num;       
00133     int             width;
00134     int             height;
00135     int             aheight;        
00136     const uint8_t   *data_ptr;      
00137     int             data_size;      
00138     int16_t         *buf;           
00139     int16_t         *ref_buf;       
00140     int16_t         *bufs[3];       
00141     int             pitch;          
00142     int             is_empty;       
00143     int             mb_size;        
00144     int             blk_size;       
00145     int             is_halfpel;     
00146     int             inherit_mv;     
00147     int             inherit_qdelta; 
00148     int             qdelta_present; 
00149     int             quant_mat;      
00150     int             glob_quant;     
00151     const uint8_t   *scan;          
00152 
00153     IVIHuffTab      blk_vlc;        
00154 
00155     int             num_corr;       
00156     uint8_t         corr[61*2];     
00157     int             rvmap_sel;      
00158     RVMapDesc       *rv_map;        
00159     int             num_tiles;      
00160     IVITile         *tiles;         
00161     InvTransformPtr *inv_transform;
00162     DCTransformPtr  *dc_transform;
00163     int             is_2d_trans;    
00164     int32_t         checksum;       
00165     int             checksum_present;
00166     int             bufsize;        
00167     const uint16_t  *intra_base;    
00168     const uint16_t  *inter_base;    
00169     const uint8_t   *intra_scale;   
00170     const uint8_t   *inter_scale;   
00171 } IVIBandDesc;
00172 
00173 
00177 typedef struct {
00178     uint16_t    width;
00179     uint16_t    height;
00180     uint8_t     num_bands;  
00181     IVIBandDesc *bands;     
00182 } IVIPlaneDesc;
00183 
00184 
00185 typedef struct {
00186     uint16_t    pic_width;
00187     uint16_t    pic_height;
00188     uint16_t    chroma_width;
00189     uint16_t    chroma_height;
00190     uint16_t    tile_width;
00191     uint16_t    tile_height;
00192     uint8_t     luma_bands;
00193     uint8_t     chroma_bands;
00194 } IVIPicConfig;
00195 
00197 static inline int ivi_pic_config_cmp(IVIPicConfig *str1, IVIPicConfig *str2)
00198 {
00199     return (str1->pic_width    != str2->pic_width    || str1->pic_height    != str2->pic_height    ||
00200             str1->chroma_width != str2->chroma_width || str1->chroma_height != str2->chroma_height ||
00201             str1->tile_width   != str2->tile_width   || str1->tile_height   != str2->tile_height   ||
00202             str1->luma_bands   != str2->luma_bands   || str1->chroma_bands  != str2->chroma_bands);
00203 }
00204 
00206 #define IVI_NUM_TILES(stride, tile_size) (((stride) + (tile_size) - 1) / (tile_size))
00207 
00209 #define IVI_MBs_PER_TILE(tile_width, tile_height, mb_size) \
00210     ((((tile_width) + (mb_size) - 1) / (mb_size)) * (((tile_height) + (mb_size) - 1) / (mb_size)))
00211 
00213 #define IVI_TOSIGNED(val) (-(((val) >> 1) ^ -((val) & 1)))
00214 
00216 static inline int ivi_scale_mv(int mv, int mv_scale)
00217 {
00218     return (mv + (mv > 0) + (mv_scale - 1)) >> mv_scale;
00219 }
00220 
00230 int  ff_ivi_create_huff_from_desc(const IVIHuffDesc *cb, VLC *vlc, int flag);
00231 
00235 void ff_ivi_init_static_vlc(void);
00236 
00248 int  ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab,
00249                           IVIHuffTab *huff_tab, AVCodecContext *avctx);
00250 
00258 int  ff_ivi_huff_desc_cmp(const IVIHuffDesc *desc1, const IVIHuffDesc *desc2);
00259 
00266 void ff_ivi_huff_desc_copy(IVIHuffDesc *dst, const IVIHuffDesc *src);
00267 
00275 int  ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg);
00276 
00282 void ff_ivi_free_buffers(IVIPlaneDesc *planes);
00283 
00292 int  ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_height);
00293 
00304 int  ff_ivi_dec_tile_data_size(GetBitContext *gb);
00305 
00317 int  ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile);
00318 
00328 int ff_ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band,
00329                                IVITile *tile, int32_t mv_scale);
00330 
00340 void ff_ivi_output_plane(IVIPlaneDesc *plane, uint8_t *dst, int dst_pitch);
00341 
00345 uint16_t ivi_calc_band_checksum (IVIBandDesc *band);
00346 
00350 int ivi_check_band (IVIBandDesc *band, const uint8_t *ref, int pitch);
00351 
00352 #endif /* AVCODEC_IVI_COMMON_H */

Generated on Fri Feb 22 2013 07:24:27 for FFmpeg by  doxygen 1.7.1