Mercurial > libavcodec.hg
comparison dnxhddec.c @ 5466:587b3e6c8d4f libavcodec
no need to duplicate cid table vars in context
author | bcoudurier |
---|---|
date | Sat, 04 Aug 2007 13:09:08 +0000 |
parents | 6478c562c80f |
children | 740cf5d1691e |
comparison
equal
deleted
inserted
replaced
5465:6478c562c80f | 5466:587b3e6c8d4f |
---|---|
52 int cid; ///< compression id | 52 int cid; ///< compression id |
53 unsigned int width, height; | 53 unsigned int width, height; |
54 unsigned int mb_width, mb_height; | 54 unsigned int mb_width, mb_height; |
55 uint32_t mb_scan_index[68]; /* max for 1080p */ | 55 uint32_t mb_scan_index[68]; /* max for 1080p */ |
56 int cur_field; ///< current interlaced field | 56 int cur_field; ///< current interlaced field |
57 int index_bits; ///< length of index value | |
58 VLC ac_vlc, dc_vlc, run_vlc; | 57 VLC ac_vlc, dc_vlc, run_vlc; |
59 const uint8_t *ac_level, *run; | |
60 const uint8_t *ac_run_flag, *ac_index_flag; | |
61 const uint8_t *luma_weigth, *chroma_weigth; | |
62 int last_dc[3]; | 58 int last_dc[3]; |
63 DSPContext dsp; | 59 DSPContext dsp; |
64 DECLARE_ALIGNED_16(DCTELEM, blocks[8][64]); | 60 DECLARE_ALIGNED_16(DCTELEM, blocks[8][64]); |
65 DECLARE_ALIGNED_8(ScanTable, scantable); | 61 DECLARE_ALIGNED_8(ScanTable, scantable); |
66 const CIDEntry *cid_table; | 62 const CIDEntry *cid_table; |
122 ctx->cid_table->dc_codes, 1, 1, 0); | 118 ctx->cid_table->dc_codes, 1, 1, 0); |
123 init_vlc(&ctx->run_vlc, DNXHD_VLC_BITS, 62, | 119 init_vlc(&ctx->run_vlc, DNXHD_VLC_BITS, 62, |
124 ctx->cid_table->run_bits, 1, 1, | 120 ctx->cid_table->run_bits, 1, 1, |
125 ctx->cid_table->run_codes, 2, 2, 0); | 121 ctx->cid_table->run_codes, 2, 2, 0); |
126 | 122 |
127 ctx->run = ctx->cid_table->run; | |
128 ctx->ac_level = ctx->cid_table->ac_level; | |
129 ctx->ac_run_flag = ctx->cid_table->ac_run_flag; | |
130 ctx->ac_index_flag = ctx->cid_table->ac_index_flag; | |
131 ctx->luma_weigth = ctx->cid_table->luma_weigth; | |
132 ctx->chroma_weigth = ctx->cid_table->chroma_weigth; | |
133 | |
134 ctx->index_bits = ctx->cid_table->index_bits; | |
135 | |
136 ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable, ff_zigzag_direct); | 123 ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable, ff_zigzag_direct); |
137 } | 124 } |
138 return 0; | 125 return 0; |
139 } | 126 } |
140 | 127 |
211 int level, component, sign; | 198 int level, component, sign; |
212 const uint8_t *weigth_matrix; | 199 const uint8_t *weigth_matrix; |
213 | 200 |
214 if (n&2) { | 201 if (n&2) { |
215 component = 1 + (n&1); | 202 component = 1 + (n&1); |
216 weigth_matrix = ctx->chroma_weigth; | 203 weigth_matrix = ctx->cid_table->chroma_weigth; |
217 } else { | 204 } else { |
218 component = 0; | 205 component = 0; |
219 weigth_matrix = ctx->luma_weigth; | 206 weigth_matrix = ctx->cid_table->luma_weigth; |
220 } | 207 } |
221 | 208 |
222 ctx->last_dc[component] += dnxhd_decode_dc(ctx); | 209 ctx->last_dc[component] += dnxhd_decode_dc(ctx); |
223 block[0] = ctx->last_dc[component]; | 210 block[0] = ctx->last_dc[component]; |
224 //av_log(ctx->avctx, AV_LOG_DEBUG, "dc %d\n", block[0]); | 211 //av_log(ctx->avctx, AV_LOG_DEBUG, "dc %d\n", block[0]); |
225 for (i = 1; ; i++) { | 212 for (i = 1; ; i++) { |
226 index = get_vlc2(&ctx->gb, ctx->ac_vlc.table, DNXHD_VLC_BITS, 2); | 213 index = get_vlc2(&ctx->gb, ctx->ac_vlc.table, DNXHD_VLC_BITS, 2); |
227 //av_log(ctx->avctx, AV_LOG_DEBUG, "index %d\n", index); | 214 //av_log(ctx->avctx, AV_LOG_DEBUG, "index %d\n", index); |
228 level = ctx->ac_level[index]; | 215 level = ctx->cid_table->ac_level[index]; |
229 if (!level) { /* EOB */ | 216 if (!level) { /* EOB */ |
230 //av_log(ctx->avctx, AV_LOG_DEBUG, "EOB\n"); | 217 //av_log(ctx->avctx, AV_LOG_DEBUG, "EOB\n"); |
231 return; | 218 return; |
232 } | 219 } |
233 sign = get_sbits(&ctx->gb, 1); | 220 sign = get_sbits(&ctx->gb, 1); |
234 | 221 |
235 if (ctx->ac_index_flag[index]) { | 222 if (ctx->cid_table->ac_index_flag[index]) { |
236 level += get_bits(&ctx->gb, ctx->index_bits)<<6; | 223 level += get_bits(&ctx->gb, ctx->cid_table->index_bits)<<6; |
237 } | 224 } |
238 | 225 |
239 if (ctx->ac_run_flag[index]) { | 226 if (ctx->cid_table->ac_run_flag[index]) { |
240 index2 = get_vlc2(&ctx->gb, ctx->run_vlc.table, DNXHD_VLC_BITS, 2); | 227 index2 = get_vlc2(&ctx->gb, ctx->run_vlc.table, DNXHD_VLC_BITS, 2); |
241 i += ctx->run[index2]; | 228 i += ctx->cid_table->run[index2]; |
242 } | 229 } |
243 | 230 |
244 j = ctx->scantable.permutated[i]; | 231 j = ctx->scantable.permutated[i]; |
245 //av_log(ctx->avctx, AV_LOG_DEBUG, "j %d\n", j); | 232 //av_log(ctx->avctx, AV_LOG_DEBUG, "j %d\n", j); |
246 //av_log(ctx->avctx, AV_LOG_DEBUG, "level %d, weigth %d\n", level, weigth_matrix[i]); | 233 //av_log(ctx->avctx, AV_LOG_DEBUG, "level %d, weigth %d\n", level, weigth_matrix[i]); |