On 27/01/15 21:56, Vittorio Giovara wrote:
Error out in case of unknown values.
---
This actually fixes pixel format detection for uknown cids.
Vittorio

  libavcodec/dnxhddec.c | 45 ++++++++++++++++++++-------------------------
  1 file changed, 20 insertions(+), 25 deletions(-)

diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index 4f714d8..9b1e481 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -133,35 +133,30 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame 
*frame,

      av_dlog(ctx->avctx, "width %d, height %d\n", ctx->width, ctx->height);

-    ctx->is_444 = 0;
-    if (buf[0x4] == 0x2) {
-        ctx->avctx->pix_fmt = AV_PIX_FMT_YUV444P10;
-        ctx->avctx->bits_per_raw_sample = 10;
-        if (ctx->bit_depth != 10) {
-            ff_blockdsp_init(&ctx->bdsp, ctx->avctx);
-            ff_idctdsp_init(&ctx->idsp, ctx->avctx);
-            ctx->bit_depth = 10;
+    if (!ctx->bit_depth) {
+        ff_blockdsp_init(&ctx->bdsp, ctx->avctx);
+        ff_idctdsp_init(&ctx->idsp, ctx->avctx);
+    }
+    if (buf[0x21] == 0x58) { /* 10 bit */
+        ctx->bit_depth = ctx->avctx->bits_per_raw_sample = 10;
+
+        if (buf[0x4] == 0x2) {
              ctx->decode_dct_block = dnxhd_decode_dct_block_10_444;
-        }
-        ctx->is_444 = 1;
-    } else if (buf[0x21] & 0x40) {
-        ctx->avctx->pix_fmt = AV_PIX_FMT_YUV422P10;
-        ctx->avctx->bits_per_raw_sample = 10;
-        if (ctx->bit_depth != 10) {
-            ff_blockdsp_init(&ctx->bdsp, ctx->avctx);
-            ff_idctdsp_init(&ctx->idsp, ctx->avctx);
-            ctx->bit_depth = 10;
+            ctx->avctx->pix_fmt = AV_PIX_FMT_YUV444P10;
+            ctx->is_444 = 1;
+        } else {
              ctx->decode_dct_block = dnxhd_decode_dct_block_10;
+            ctx->avctx->pix_fmt = AV_PIX_FMT_YUV422P10;
          }
-    } else {
+    } else if (buf[0x21] == 0x38) { /* 8 bit */
+        ctx->bit_depth = ctx->avctx->bits_per_raw_sample = 8;
+
          ctx->avctx->pix_fmt = AV_PIX_FMT_YUV422P;
-        ctx->avctx->bits_per_raw_sample = 8;
-        if (ctx->bit_depth != 8) {
-            ff_blockdsp_init(&ctx->bdsp, ctx->avctx);
-            ff_idctdsp_init(&ctx->idsp, ctx->avctx);
-            ctx->bit_depth = 8;
-            ctx->decode_dct_block = dnxhd_decode_dct_block_8;
-        }
+        ctx->decode_dct_block = dnxhd_decode_dct_block_8;
+    } else {
+        av_log(ctx->avctx, AV_LOG_ERROR, "invalid bit depth value (%d).\n",
+               buf[0x21]);
+        return AVERROR_INVALIDDATA;
      }

      cid = AV_RB32(buf + 0x28);



Ok if tested.
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to