comparison ivi_common.c @ 11246:b75449aaea3e libavcodec

Macroblock and block Huffman code sets are to be used by both Indeo 4 and Indeo 5, so make them global and move their initialization to the common place as well. And fix static VLC initialization, as ff_ivi_create_huff_from_desc() used old way to do so.
author kostya
date Mon, 22 Feb 2010 13:51:32 +0000
parents 3b79a8709f43
children 4a6bf3fbf367
comparison
equal deleted inserted replaced
11245:1e9ff636c3db 11246:b75449aaea3e
31 #include "get_bits.h" 31 #include "get_bits.h"
32 #include "ivi_common.h" 32 #include "ivi_common.h"
33 #include "libavutil/common.h" 33 #include "libavutil/common.h"
34 #include "ivi_dsp.h" 34 #include "ivi_dsp.h"
35 35
36 extern const IVIHuffDesc ff_ivi_mb_huff_desc[8]; ///< static macroblock huffman tables
37 extern const IVIHuffDesc ff_ivi_blk_huff_desc[8]; ///< static block huffman tables
38
39 VLC ff_ivi_mb_vlc_tabs [8];
40 VLC ff_ivi_blk_vlc_tabs[8];
41
36 /** 42 /**
37 * Reverses "nbits" bits of the value "val" and returns the result 43 * Reverses "nbits" bits of the value "val" and returns the result
38 * in the least significant bits. 44 * in the least significant bits.
39 */ 45 */
40 static uint16_t inv_bits(uint16_t val, int nbits) 46 static uint16_t inv_bits(uint16_t val, int nbits)
78 }//for j 84 }//for j
79 }//for i 85 }//for i
80 86
81 /* number of codewords = pos */ 87 /* number of codewords = pos */
82 return init_vlc(vlc, IVI_VLC_BITS, pos, bits, 1, 1, codewords, 2, 2, 88 return init_vlc(vlc, IVI_VLC_BITS, pos, bits, 1, 1, codewords, 2, 2,
83 (flag & 1) | INIT_VLC_LE); 89 (flag ? INIT_VLC_USE_NEW_STATIC : 0) | INIT_VLC_LE);
90 }
91
92 void ff_ivi_init_static_vlc()
93 {
94 int i;
95 static VLC table_data[8192 * 16][2];
96 static int initialized_vlcs = 0;
97
98 if (initialized_vlcs)
99 return;
100 for (i = 0; i < 8; i++) {
101 ff_ivi_mb_vlc_tabs[i].table = table_data + i * 2 * 8192;
102 ff_ivi_mb_vlc_tabs[i].table_allocated = 8192;
103 ff_ivi_create_huff_from_desc(&ff_ivi_mb_huff_desc[i], &ff_ivi_mb_vlc_tabs[i], 1);
104 ff_ivi_blk_vlc_tabs[i].table = table_data + (i * 2 + 1) * 8192;
105 ff_ivi_blk_vlc_tabs[i].table_allocated = 8192;
106 ff_ivi_create_huff_from_desc(&ff_ivi_blk_huff_desc[i], &ff_ivi_blk_vlc_tabs[i], 1);
107 }
108 initialized_vlcs = 1;
84 } 109 }
85 110
86 int ff_ivi_dec_huff_desc(GetBitContext *gb, IVIHuffDesc *desc) 111 int ff_ivi_dec_huff_desc(GetBitContext *gb, IVIHuffDesc *desc)
87 { 112 {
88 int tab_sel, i; 113 int tab_sel, i;