comparison dnxhddec.c @ 5794:8412118b41d3 libavcodec

preliminary 10 bit depth decoding support, still miss generic api to export picture, working on it
author bcoudurier
date Mon, 08 Oct 2007 12:23:00 +0000
parents 33c615713e26
children 8b6fe123be88
comparison
equal deleted inserted replaced
5793:33c615713e26 5794:8412118b41d3
44 DECLARE_ALIGNED_8(ScanTable, scantable); 44 DECLARE_ALIGNED_8(ScanTable, scantable);
45 const CIDEntry *cid_table; 45 const CIDEntry *cid_table;
46 } DNXHDContext; 46 } DNXHDContext;
47 47
48 #define DNXHD_VLC_BITS 9 48 #define DNXHD_VLC_BITS 9
49 #define DNXHD_DC_VLC_BITS 6 49 #define DNXHD_DC_VLC_BITS 7
50 50
51 static int dnxhd_decode_init(AVCodecContext *avctx) 51 static int dnxhd_decode_init(AVCodecContext *avctx)
52 { 52 {
53 DNXHDContext *ctx = avctx->priv_data; 53 DNXHDContext *ctx = avctx->priv_data;
54 54
70 } 70 }
71 ctx->cid_table = &ff_dnxhd_cid_table[index]; 71 ctx->cid_table = &ff_dnxhd_cid_table[index];
72 init_vlc(&ctx->ac_vlc, DNXHD_VLC_BITS, 257, 72 init_vlc(&ctx->ac_vlc, DNXHD_VLC_BITS, 257,
73 ctx->cid_table->ac_bits, 1, 1, 73 ctx->cid_table->ac_bits, 1, 1,
74 ctx->cid_table->ac_codes, 2, 2, 0); 74 ctx->cid_table->ac_codes, 2, 2, 0);
75 init_vlc(&ctx->dc_vlc, DNXHD_DC_VLC_BITS, 12, 75 init_vlc(&ctx->dc_vlc, DNXHD_DC_VLC_BITS, ctx->cid_table->bit_depth+4,
76 ctx->cid_table->dc_bits, 1, 1, 76 ctx->cid_table->dc_bits, 1, 1,
77 ctx->cid_table->dc_codes, 1, 1, 0); 77 ctx->cid_table->dc_codes, 1, 1, 0);
78 init_vlc(&ctx->run_vlc, DNXHD_VLC_BITS, 62, 78 init_vlc(&ctx->run_vlc, DNXHD_VLC_BITS, 62,
79 ctx->cid_table->run_bits, 1, 1, 79 ctx->cid_table->run_bits, 1, 1,
80 ctx->cid_table->run_codes, 2, 2, 0); 80 ctx->cid_table->run_codes, 2, 2, 0);
196 196
197 j = ctx->scantable.permutated[i]; 197 j = ctx->scantable.permutated[i];
198 //av_log(ctx->avctx, AV_LOG_DEBUG, "j %d\n", j); 198 //av_log(ctx->avctx, AV_LOG_DEBUG, "j %d\n", j);
199 //av_log(ctx->avctx, AV_LOG_DEBUG, "level %d, weigth %d\n", level, weigth_matrix[i]); 199 //av_log(ctx->avctx, AV_LOG_DEBUG, "level %d, weigth %d\n", level, weigth_matrix[i]);
200 level = (2*level+1) * qscale * weigth_matrix[i]; 200 level = (2*level+1) * qscale * weigth_matrix[i];
201 if (weigth_matrix[i] != 32) // FIXME 10bit 201 if (ctx->cid_table->bit_depth == 10) {
202 level += 32; 202 if (weigth_matrix[i] != 8)
203 level >>= 6; 203 level += 8;
204 level >>= 4;
205 } else {
206 if (weigth_matrix[i] != 32)
207 level += 32;
208 level >>= 6;
209 }
204 //av_log(NULL, AV_LOG_DEBUG, "i %d, j %d, end level %d\n", i, j, level); 210 //av_log(NULL, AV_LOG_DEBUG, "i %d, j %d, end level %d\n", i, j, level);
205 block[j] = (level^sign) - sign; 211 block[j] = (level^sign) - sign;
206 } 212 }
207 } 213 }
208 214
261 { 267 {
262 int x, y; 268 int x, y;
263 for (y = 0; y < ctx->mb_height; y++) { 269 for (y = 0; y < ctx->mb_height; y++) {
264 ctx->last_dc[0] = 270 ctx->last_dc[0] =
265 ctx->last_dc[1] = 271 ctx->last_dc[1] =
266 ctx->last_dc[2] = 1024; // 1024 for levels +128 272 ctx->last_dc[2] = 1<<(ctx->cid_table->bit_depth+2); // for levels +2^(bitdepth-1)
267 init_get_bits(&ctx->gb, buf + ctx->mb_scan_index[y], (buf_size - ctx->mb_scan_index[y]) << 3); 273 init_get_bits(&ctx->gb, buf + ctx->mb_scan_index[y], (buf_size - ctx->mb_scan_index[y]) << 3);
268 for (x = 0; x < ctx->mb_width; x++) { 274 for (x = 0; x < ctx->mb_width; x++) {
269 //START_TIMER; 275 //START_TIMER;
270 dnxhd_decode_macroblock(ctx, x, y); 276 dnxhd_decode_macroblock(ctx, x, y);
271 //STOP_TIMER("decode macroblock"); 277 //STOP_TIMER("decode macroblock");