diff 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
line wrap: on
line diff
--- a/dnxhddec.c	Mon Oct 08 12:14:43 2007 +0000
+++ b/dnxhddec.c	Mon Oct 08 12:23:00 2007 +0000
@@ -46,7 +46,7 @@
 } DNXHDContext;
 
 #define DNXHD_VLC_BITS 9
-#define DNXHD_DC_VLC_BITS 6
+#define DNXHD_DC_VLC_BITS 7
 
 static int dnxhd_decode_init(AVCodecContext *avctx)
 {
@@ -72,7 +72,7 @@
         init_vlc(&ctx->ac_vlc, DNXHD_VLC_BITS, 257,
                  ctx->cid_table->ac_bits, 1, 1,
                  ctx->cid_table->ac_codes, 2, 2, 0);
-        init_vlc(&ctx->dc_vlc, DNXHD_DC_VLC_BITS, 12,
+        init_vlc(&ctx->dc_vlc, DNXHD_DC_VLC_BITS, ctx->cid_table->bit_depth+4,
                  ctx->cid_table->dc_bits, 1, 1,
                  ctx->cid_table->dc_codes, 1, 1, 0);
         init_vlc(&ctx->run_vlc, DNXHD_VLC_BITS, 62,
@@ -198,9 +198,15 @@
         //av_log(ctx->avctx, AV_LOG_DEBUG, "j %d\n", j);
         //av_log(ctx->avctx, AV_LOG_DEBUG, "level %d, weigth %d\n", level, weigth_matrix[i]);
         level = (2*level+1) * qscale * weigth_matrix[i];
-        if (weigth_matrix[i] != 32) // FIXME 10bit
-            level += 32;
-        level >>= 6;
+        if (ctx->cid_table->bit_depth == 10) {
+            if (weigth_matrix[i] != 8)
+                level += 8;
+            level >>= 4;
+        } else {
+            if (weigth_matrix[i] != 32)
+                level += 32;
+            level >>= 6;
+        }
         //av_log(NULL, AV_LOG_DEBUG, "i %d, j %d, end level %d\n", i, j, level);
         block[j] = (level^sign) - sign;
     }
@@ -263,7 +269,7 @@
     for (y = 0; y < ctx->mb_height; y++) {
         ctx->last_dc[0] =
         ctx->last_dc[1] =
-        ctx->last_dc[2] = 1024; // 1024 for levels +128
+        ctx->last_dc[2] = 1<<(ctx->cid_table->bit_depth+2); // for levels +2^(bitdepth-1)
         init_get_bits(&ctx->gb, buf + ctx->mb_scan_index[y], (buf_size - ctx->mb_scan_index[y]) << 3);
         for (x = 0; x < ctx->mb_width; x++) {
             //START_TIMER;