X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fdnxhddec.c;h=c78d55aee51ec282af3ae3b5d8a31d46edbb63e6;hb=b8accd1175d20ab308de69dbd06bda06a02183e3;hp=1e95086696703b390636f237a2d58ea32c014472;hpb=c268712895f6fd557e5affa6566983815046b9a8;p=ffmpeg diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index 1e950866967..c78d55aee51 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -25,7 +25,8 @@ */ #include "libavutil/imgutils.h" -#include "libavutil/timer.h" +#include "libavutil/mem_internal.h" + #include "avcodec.h" #include "blockdsp.h" #define UNCHECKED_BITSTREAM_READER 1 @@ -112,18 +113,19 @@ static av_cold int dnxhd_decode_init(AVCodecContext *avctx) static int dnxhd_init_vlc(DNXHDContext *ctx, uint32_t cid, int bitdepth) { if (cid != ctx->cid) { - int index; + const CIDEntry *cid_table = ff_dnxhd_get_cid_table(cid); - if ((index = ff_dnxhd_get_cid_table(cid)) < 0) { + if (!cid_table) { av_log(ctx->avctx, AV_LOG_ERROR, "unsupported cid %"PRIu32"\n", cid); return AVERROR(ENOSYS); } - if (ff_dnxhd_cid_table[index].bit_depth != bitdepth && - ff_dnxhd_cid_table[index].bit_depth != DNXHD_VARIABLE) { - av_log(ctx->avctx, AV_LOG_ERROR, "bit depth mismatches %d %d\n", ff_dnxhd_cid_table[index].bit_depth, bitdepth); + if (cid_table->bit_depth != bitdepth && + cid_table->bit_depth != DNXHD_VARIABLE) { + av_log(ctx->avctx, AV_LOG_ERROR, "bit depth mismatches %d %d\n", + cid_table->bit_depth, bitdepth); return AVERROR_INVALIDDATA; } - ctx->cid_table = &ff_dnxhd_cid_table[index]; + ctx->cid_table = cid_table; av_log(ctx->avctx, AV_LOG_VERBOSE, "Profile cid %"PRIu32".\n", cid); ff_free_vlc(&ctx->ac_vlc); @@ -145,21 +147,6 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, uint32_t cid, int bitdepth) return 0; } -static av_cold int dnxhd_decode_init_thread_copy(AVCodecContext *avctx) -{ - DNXHDContext *ctx = avctx->priv_data; - - ctx->avctx = avctx; - // make sure VLC tables will be loaded when cid is parsed - ctx->cid = -1; - - ctx->rows = av_mallocz_array(avctx->thread_count, sizeof(RowContext)); - if (!ctx->rows) - return AVERROR(ENOMEM); - - return 0; -} - static int dnxhd_get_profile(int cid) { switch(cid) { @@ -235,7 +222,14 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame, av_log(ctx->avctx, AV_LOG_WARNING, "Adaptive MB interlace flag in an unsupported profile.\n"); - ctx->act = buf[0x2C] & 7; + switch ((buf[0x2C] >> 1) & 3) { + case 0: frame->colorspace = AVCOL_SPC_BT709; break; + case 1: frame->colorspace = AVCOL_SPC_BT2020_NCL; break; + case 2: frame->colorspace = AVCOL_SPC_BT2020_CL; break; + case 3: frame->colorspace = AVCOL_SPC_UNSPECIFIED; break; + } + + ctx->act = buf[0x2C] & 1; 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"); @@ -600,13 +594,11 @@ static int dnxhd_decode_row(AVCodecContext *avctx, void *data, return ret; } for (x = 0; x < ctx->mb_width; x++) { - //START_TIMER; int ret = dnxhd_decode_macroblock(ctx, row, data, x, rownb); if (ret < 0) { row->errors++; return ret; } - //STOP_TIMER("decode macroblock"); } return 0; @@ -736,6 +728,5 @@ AVCodec ff_dnxhd_decoder = { .decode = dnxhd_decode_frame, .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS, - .init_thread_copy = ONLY_IF_THREADS_ENABLED(dnxhd_decode_init_thread_copy), .profiles = NULL_IF_CONFIG_SMALL(ff_dnxhd_profiles), };