X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fmagicyuv.c;h=5d76274d54b4a104679ff0c8ca121fec65b98ae2;hb=6c777a6688715b21a15cab2cd87c8379225e53ec;hp=1a129c26198af3645bedbccd647fed2ecf063012;hpb=e645d7a6d452df83cedcbb1d6708429ceea156da;p=ffmpeg diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c index 1a129c26198..5d76274d54b 100644 --- a/libavcodec/magicyuv.c +++ b/libavcodec/magicyuv.c @@ -547,10 +547,7 @@ static int magy_decode_frame(AVCodecContext *avctx, void *data, s->hshift[2] = s->vshift[2] = 0; s->decorrelate = 0; - s->max = 256; s->bps = 8; - s->huff_build = huff_build; - s->magy_decode_slice = magy_decode_slice; format = bytestream2_get_byte(&gbyte); switch (format) { @@ -587,54 +584,46 @@ static int magy_decode_frame(AVCodecContext *avctx, void *data, avctx->pix_fmt = AV_PIX_FMT_YUV422P10; s->hshift[1] = s->hshift[2] = 1; - s->max = 1024; - s->huff_build = huff_build10; - s->magy_decode_slice = magy_decode_slice10; + s->bps = 10; + break; + case 0x76: + avctx->pix_fmt = AV_PIX_FMT_YUV444P10; s->bps = 10; break; case 0x6d: avctx->pix_fmt = AV_PIX_FMT_GBRP10; s->decorrelate = 1; - s->max = 1024; - s->huff_build = huff_build10; - s->magy_decode_slice = magy_decode_slice10; s->bps = 10; break; case 0x6e: avctx->pix_fmt = AV_PIX_FMT_GBRAP10; s->decorrelate = 1; - s->max = 1024; - s->huff_build = huff_build10; - s->magy_decode_slice = magy_decode_slice10; s->bps = 10; break; case 0x6f: avctx->pix_fmt = AV_PIX_FMT_GBRP12; s->decorrelate = 1; - s->max = 4096; - s->huff_build = huff_build12; - s->magy_decode_slice = magy_decode_slice10; s->bps = 12; break; case 0x70: avctx->pix_fmt = AV_PIX_FMT_GBRAP12; s->decorrelate = 1; - s->max = 4096; - s->huff_build = huff_build12; - s->magy_decode_slice = magy_decode_slice10; s->bps = 12; break; case 0x73: avctx->pix_fmt = AV_PIX_FMT_GRAY10; - s->max = 1024; - s->huff_build = huff_build10; - s->magy_decode_slice = magy_decode_slice10; s->bps = 10; break; default: avpriv_request_sample(avctx, "Format 0x%X", format); return AVERROR_PATCHWELCOME; } + s->max = 1 << s->bps; + s->magy_decode_slice = s->bps == 8 ? magy_decode_slice : magy_decode_slice10; + if ( s->bps == 8) + s->huff_build = huff_build; + else + s->huff_build = s->bps == 10 ? huff_build10 : huff_build12; s->planes = av_pix_fmt_count_planes(avctx->pix_fmt); bytestream2_skip(&gbyte, 1); @@ -670,6 +659,17 @@ static int magy_decode_frame(AVCodecContext *avctx, void *data, return AVERROR_INVALIDDATA; } + if (s->interlaced) { + if ((s->slice_height >> s->vshift[1]) < 2) { + av_log(avctx, AV_LOG_ERROR, "impossible slice height\n"); + return AVERROR_INVALIDDATA; + } + if ((avctx->coded_height % s->slice_height) && ((avctx->coded_height % s->slice_height) >> s->vshift[1]) < 2) { + av_log(avctx, AV_LOG_ERROR, "impossible height\n"); + return AVERROR_INVALIDDATA; + } + } + for (i = 0; i < s->planes; i++) { av_fast_malloc(&s->slices[i], &s->slices_size[i], s->nb_slices * sizeof(Slice)); if (!s->slices[i]) @@ -749,21 +749,6 @@ static int magy_decode_frame(AVCodecContext *avctx, void *data, return avpkt->size; } -#if HAVE_THREADS -static int magy_init_thread_copy(AVCodecContext *avctx) -{ - MagicYUVContext *s = avctx->priv_data; - int i; - - for (i = 0; i < FF_ARRAY_ELEMS(s->slices); i++) { - s->slices[i] = NULL; - s->slices_size[i] = 0; - } - - return 0; -} -#endif - static av_cold int magy_decode_init(AVCodecContext *avctx) { MagicYUVContext *s = avctx->priv_data; @@ -792,7 +777,6 @@ AVCodec ff_magicyuv_decoder = { .id = AV_CODEC_ID_MAGICYUV, .priv_data_size = sizeof(MagicYUVContext), .init = magy_decode_init, - .init_thread_copy = ONLY_IF_THREADS_ENABLED(magy_init_thread_copy), .close = magy_decode_end, .decode = magy_decode_frame, .capabilities = AV_CODEC_CAP_DR1 |