This a 4:4:4 10 bits profile, where image size is not fixed by the profile, and which strays a bit outside the old frame header parsing code.
Fixes ticket #4581 (DNxHR is not stricly supported, but that sequence is). --- libavcodec/dnxhddata.c | 23 +++++++++++++-------- libavcodec/dnxhddec.c | 56 +++++++++++++++++++++++++------------------------- 2 files changed, 43 insertions(+), 36 deletions(-) diff --git a/libavcodec/dnxhddata.c b/libavcodec/dnxhddata.c index e39208d..afe6705 100644 --- a/libavcodec/dnxhddata.c +++ b/libavcodec/dnxhddata.c @@ -25,7 +25,7 @@ /* The quantization tables below are in zigzag order! */ -/* Used in CID 1235, 1256 */ +/* Used in CID 1235, 1256, 1270 */ static const uint8_t dnxhd_1235_luma_weight[] = { 0, 32, 32, 32, 33, 32, 32, 32, 32, 31, 32, 33, 33, 33, 33, 35, @@ -250,12 +250,12 @@ static const uint8_t dnxhd_1260_chroma_weight[] = { 56, 56, 53, 53, 53, 54, 58, 58, }; -/* Used in CID 1235, 1241, 1250, 1256 */ +/* Used in CID 1235, 1236, 1241, 1250, 1256, 1257, 1270, 1271 */ static const uint8_t dnxhd_1235_dc_codes[14] = { 10, 62, 11, 12, 13, 0, 1, 2, 3, 4, 14, 30, 126, 127, }; -/* Used in CID 1235, 1241, 1250, 1256 */ +/* Used in CID 1235, 1236, 1241, 1250, 1256, 1257, 1270, 1271 */ static const uint8_t dnxhd_1235_dc_bits[14] = { 4, 6, 4, 4, 4, 3, 3, 3, 3, 3, 4, 5, 7, 7, }; @@ -370,7 +370,7 @@ static const uint8_t dnxhd_1237_ac_flags[257] = { 3, }; -/* Used in CID 1238, 1243 */ +/* Used in CID 1238, 1240, 1243, 1272 */ static const uint16_t dnxhd_1238_ac_codes[257] = { 0, 1, 4, 10, 11, 24, 25, 26, 54, 55, 56, 57, 116, 117, 118, 119, @@ -407,7 +407,7 @@ static const uint16_t dnxhd_1238_ac_codes[257] = { 65535, }; -/* Used in CID 1238, 1243 */ +/* Used in CID 1238, 1240, 1243, 1272 */ static const uint8_t dnxhd_1238_ac_bits[257] = { 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, @@ -428,7 +428,7 @@ static const uint8_t dnxhd_1238_ac_bits[257] = { 16, }; -/* Used in CID 1238, 1243 */ +/* Used in CID 1238, 1240, 1243, 1272 */ static const uint8_t dnxhd_1238_ac_level[257] = { 3, 3, 5, 7, 0, 9, 11, 5, 13, 15, 17, 7, 19, 21, 23, 9, 25, 27, 29, 31, 33, 11, 35, 37, 39, 41, 43, 45, 13, 15, 47, 49, @@ -469,7 +469,7 @@ static const uint8_t dnxhd_1238_ac_flags[257] = { 3, }; -/* Used in CID 1235, 1241, 1256 */ +/* Used in CID 1235, 1236, 1241, 1256, 1257, 1270, 1271 */ static const uint16_t dnxhd_1235_ac_codes[257] = { 0, 1, 4, 10, 11, 24, 25, 26, 54, 55, 56, 57, 116, 117, 118, 119, @@ -506,7 +506,7 @@ static const uint16_t dnxhd_1235_ac_codes[257] = { 65535, }; -/* Used in CID 1235, 1241, 1256 */ +/* Used in CID 1235, 1236, 1241, 1256, 1257, 1270, 1271 */ static const uint8_t dnxhd_1235_ac_bits[257] = { 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, @@ -1058,6 +1058,13 @@ const CIDEntry ff_dnxhd_cid_table[] = { dnxhd_1237_ac_flags, dnxhd_1237_run_codes, dnxhd_1237_run_bits, dnxhd_1237_run, { 80, 90, 100, 110 } }, + { 1270, 0, 0, 0, 0, 0, 6, 10, 4, + dnxhd_1235_luma_weight, dnxhd_1235_luma_weight, + dnxhd_1235_dc_codes, dnxhd_1235_dc_bits, + dnxhd_1235_ac_codes, dnxhd_1235_ac_bits, dnxhd_1235_ac_level, + dnxhd_1235_ac_flags, + dnxhd_1235_run_codes, dnxhd_1235_run_bits, dnxhd_1235_run, + { 0 } }, { 1274, 0, 0, 0, 0, 0, 4, 8, 3, dnxhd_1237_luma_weight, dnxhd_1237_chroma_weight, dnxhd_1237_dc_codes, dnxhd_1237_dc_bits, diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index 1c8660e..b744e71 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -177,35 +177,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); @@ -215,7 +215,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; @@ -224,7 +223,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame, "Adaptive MB interlace flag in an unsupported profile.\n"); ctx->act = buf[0x2C] & 7; - if (ctx->act && ctx->cid_table->cid != 1256) + if (ctx->act && ctx->cid_table->cid != 1256 && ctx->cid_table->cid != 1270) av_log(ctx->avctx, AV_LOG_WARNING, "Adaptive color transform in an unsupported profile.\n"); @@ -243,15 +242,16 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame, return AVERROR_INVALIDDATA; } - ctx->mb_width = ctx->width >> 4; ctx->mb_height = buf[0x16d]; - - ff_dlog(ctx->avctx, - "mb width %d, mb height %d\n", ctx->mb_width, ctx->mb_height); + ctx->mb_width = (ctx->width + 15)>> 4; 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, -- 2.5.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel