summaryrefslogtreecommitdiff
path: root/libavcodec/dnxhddec.c
diff options
context:
space:
mode:
authorChristophe Gisquet <christophe.gisquet@gmail.com>2015-10-02 21:00:44 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2015-10-05 12:26:30 +0200
commit9139a7e84f759edbff4f1ba0cd145dc07e411379 (patch)
treed3a5db68245c6fcd55ff556545a7b82064af7215 /libavcodec/dnxhddec.c
parentc0152ebb9e0501b9d3d4386531995683a4ac824c (diff)
downloadffmpeg-9139a7e84f759edbff4f1ba0cd145dc07e411379.tar.gz
dnxhddec: cleanup frame header parsing
Rely more on the actual syntax from the specs (also seen in the encoder code). Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/dnxhddec.c')
-rw-r--r--libavcodec/dnxhddec.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index 296f7f74d6..713ce6adbc 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -176,35 +176,35 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
} else {
ctx->cur_field = 0;
}
- ctx->mbaff = buf[0x6] & 32;
+ ctx->mbaff = (buf[0x6] >> 5) & 1;
ctx->height = AV_RB16(buf + 0x18);
ctx->width = AV_RB16(buf + 0x1a);
- ff_dlog(ctx->avctx, "width %d, height %d\n", ctx->width, ctx->height);
-
- if (buf[0x21] == 0x58) { /* 10 bit */
- ctx->bit_depth = ctx->avctx->bits_per_raw_sample = 10;
+ switch(buf[0x21] >> 5) {
+ case 1: ctx->bit_depth = 8; break;
+ case 2: ctx->bit_depth = 10; break;
+ default:
+ av_log(ctx->avctx, AV_LOG_ERROR,
+ "Unknown bitdepth indicator (%d)\n", buf[0x21] >> 5);
+ return AVERROR_INVALIDDATA;
+ }
+ ctx->avctx->bits_per_raw_sample = ctx->bit_depth;
- if (buf[0x4] == 0x2) {
- ctx->decode_dct_block = dnxhd_decode_dct_block_10_444;
- ctx->pix_fmt = AV_PIX_FMT_YUV444P10;
- ctx->is_444 = 1;
- } else {
- ctx->decode_dct_block = dnxhd_decode_dct_block_10;
- ctx->pix_fmt = AV_PIX_FMT_YUV422P10;
- ctx->is_444 = 0;
+ ctx->is_444 = (buf[0x2C] >> 6) & 1;
+ if (ctx->is_444) {
+ if (ctx->bit_depth == 8) {
+ avpriv_request_sample(ctx->avctx, "4:4:4 8 bits\n");
+ return AVERROR_INVALIDDATA;
}
- } else if (buf[0x21] == 0x38) { /* 8 bit */
- ctx->bit_depth = ctx->avctx->bits_per_raw_sample = 8;
-
- ctx->pix_fmt = AV_PIX_FMT_YUV422P;
- ctx->is_444 = 0;
- ctx->decode_dct_block = dnxhd_decode_dct_block_8;
+ ctx->decode_dct_block = dnxhd_decode_dct_block_10_444;
+ ctx->pix_fmt = AV_PIX_FMT_YUV444P10;
+ } else if (ctx->bit_depth == 10) {
+ ctx->decode_dct_block = dnxhd_decode_dct_block_10;
+ ctx->pix_fmt = AV_PIX_FMT_YUV422P10;
} else {
- av_log(ctx->avctx, AV_LOG_ERROR,
- "invalid bit depth value (%d).\n", buf[0x21]);
- return AVERROR_INVALIDDATA;
+ ctx->decode_dct_block = dnxhd_decode_dct_block_8;
+ ctx->pix_fmt = AV_PIX_FMT_YUV422P;
}
if (ctx->bit_depth != old_bit_depth) {
ff_blockdsp_init(&ctx->bdsp, ctx->avctx);
@@ -214,7 +214,6 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
}
cid = AV_RB32(buf + 0x28);
- ff_dlog(ctx->avctx, "compression id %d\n", cid);
if ((ret = dnxhd_init_vlc(ctx, cid)) < 0)
return ret;
@@ -242,15 +241,16 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
return AVERROR_INVALIDDATA;
}
- ctx->mb_width = ctx->width >> 4;
+ ctx->mb_width = (ctx->width + 15)>> 4;
ctx->mb_height = buf[0x16d];
- ff_dlog(ctx->avctx,
- "mb width %d, mb height %d\n", ctx->mb_width, ctx->mb_height);
-
if ((ctx->height + 15) >> 4 == ctx->mb_height && frame->interlaced_frame)
ctx->height <<= 1;
+ av_log(ctx->avctx, AV_LOG_VERBOSE, "%dx%d, 4:%s %d bits, MBAFF=%d ACT=%d\n",
+ ctx->width, ctx->height, ctx->is_444 ? "4:4" : "2:2",
+ ctx->bit_depth, ctx->mbaff, ctx->act);
+
if (ctx->mb_height > 68 ||
(ctx->mb_height << frame->interlaced_frame) > (ctx->height + 15) >> 4) {
av_log(ctx->avctx, AV_LOG_ERROR,