X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fmpeg12dec.c;h=5f42e95f7046ca131d984eb22f11d40d85b78f1f;hb=0cbae3763d96f40e0eae0c9f04794a38e1f78ca6;hp=480cf41f675cc5e740e9d61c361e2465fdc4dd60;hpb=d12be9ed70f55e918ec852d2d4097a8fbdd36cb9;p=ffmpeg diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 480cf41f675..5f42e95f704 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -844,7 +844,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) ff_xvmc_pack_pblocks(s, -1); // inter are always full blocks if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) { - if (s->avctx->flags2 & CODEC_FLAG2_FAST) { + if (s->avctx->flags2 & AV_CODEC_FLAG2_FAST) { for (i = 0; i < 6; i++) mpeg2_fast_decode_block_intra(s, *s->pblocks[i], i); } else { @@ -1064,7 +1064,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) ff_xvmc_pack_pblocks(s, cbp); if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) { - if (s->avctx->flags2 & CODEC_FLAG2_FAST) { + if (s->avctx->flags2 & AV_CODEC_FLAG2_FAST) { for (i = 0; i < 6; i++) { if (cbp & 32) mpeg2_fast_decode_block_non_intra(s, *s->pblocks[i], i); @@ -1086,7 +1086,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) } } } else { - if (s->avctx->flags2 & CODEC_FLAG2_FAST) { + if (s->avctx->flags2 & AV_CODEC_FLAG2_FAST) { for (i = 0; i < 6; i++) { if (cbp & 32) mpeg1_fast_decode_block_inter(s, *s->pblocks[i], i); @@ -1186,8 +1186,10 @@ static const enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[] = { #if CONFIG_MPEG1_XVMC_HWACCEL AV_PIX_FMT_XVMC, #endif -#if CONFIG_MPEG1_VDPAU_HWACCEL +#if CONFIG_MPEG1_VDPAU_DECODER && FF_API_VDPAU AV_PIX_FMT_VDPAU_MPEG1, +#endif +#if CONFIG_MPEG1_VDPAU_HWACCEL AV_PIX_FMT_VDPAU, #endif AV_PIX_FMT_YUV420P, @@ -1198,8 +1200,10 @@ static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = { #if CONFIG_MPEG2_XVMC_HWACCEL AV_PIX_FMT_XVMC, #endif -#if CONFIG_MPEG2_VDPAU_HWACCEL +#if CONFIG_MPEG_VDPAU_DECODER && FF_API_VDPAU AV_PIX_FMT_VDPAU_MPEG2, +#endif +#if CONFIG_MPEG2_VDPAU_HWACCEL AV_PIX_FMT_VDPAU, #endif #if CONFIG_MPEG2_DXVA2_HWACCEL @@ -1209,7 +1213,10 @@ static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = { AV_PIX_FMT_D3D11VA_VLD, #endif #if CONFIG_MPEG2_VAAPI_HWACCEL - AV_PIX_FMT_VAAPI_VLD, + AV_PIX_FMT_VAAPI, +#endif +#if CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL + AV_PIX_FMT_VIDEOTOOLBOX, #endif AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE @@ -1225,9 +1232,11 @@ static const enum AVPixelFormat mpeg12_pixfmt_list_444[] = { AV_PIX_FMT_NONE }; +#if FF_API_VDPAU static inline int uses_vdpau(AVCodecContext *avctx) { return avctx->pix_fmt == AV_PIX_FMT_VDPAU_MPEG1 || avctx->pix_fmt == AV_PIX_FMT_VDPAU_MPEG2; } +#endif static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx) { @@ -1235,7 +1244,7 @@ static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx) MpegEncContext *s = &s1->mpeg_enc_ctx; const enum AVPixelFormat *pix_fmts; - if (CONFIG_GRAY && (avctx->flags & CODEC_FLAG_GRAY)) + if (CONFIG_GRAY && (avctx->flags & AV_CODEC_FLAG_GRAY)) return AV_PIX_FMT_GRAY8; if (s->chroma_format < 2) @@ -1253,7 +1262,11 @@ static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx) static void setup_hwaccel_for_pixfmt(AVCodecContext *avctx) { // until then pix_fmt may be changed right after codec init - if (avctx->hwaccel || uses_vdpau(avctx)) + if (avctx->hwaccel +#if FF_API_VDPAU + || uses_vdpau(avctx) +#endif + ) if (avctx->idct_algo == FF_IDCT_AUTO) avctx->idct_algo = FF_IDCT_SIMPLE; @@ -1263,7 +1276,9 @@ static void setup_hwaccel_for_pixfmt(AVCodecContext *avctx) s->pack_pblocks = 1; #if FF_API_XVMC +FF_DISABLE_DEPRECATION_WARNINGS avctx->xvmc_acceleration = 2; +FF_ENABLE_DEPRECATION_WARNINGS #endif /* FF_API_XVMC */ } } @@ -1381,6 +1396,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) case 1: avctx->chroma_sample_location = AVCHROMA_LOC_LEFT; break; case 2: case 3: avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT; break; + default: av_assert0(0); } } // MPEG-2 @@ -1463,6 +1479,12 @@ static void mpeg_decode_sequence_extension(Mpeg1Context *s1) s->avctx->level = get_bits(&s->gb, 4); s->progressive_sequence = get_bits1(&s->gb); /* progressive_sequence */ s->chroma_format = get_bits(&s->gb, 2); /* chroma_format 1=420, 2=422, 3=444 */ + + if (!s->chroma_format) { + s->chroma_format = 1; + av_log(s->avctx, AV_LOG_WARNING, "Chroma format invalid\n"); + } + horiz_size_ext = get_bits(&s->gb, 2); vert_size_ext = get_bits(&s->gb, 2); s->width |= (horiz_size_ext << 12); @@ -1473,7 +1495,7 @@ static void mpeg_decode_sequence_extension(Mpeg1Context *s1) s->avctx->rc_buffer_size += get_bits(&s->gb, 8) * 1024 * 16 << 10; s->low_delay = get_bits1(&s->gb); - if (s->avctx->flags & CODEC_FLAG_LOW_DELAY) + if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) s->low_delay = 1; s1->frame_rate_ext.num = get_bits(&s->gb, 2) + 1; @@ -1720,9 +1742,11 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) if (s->avctx->hwaccel && (s->avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD)) { - if (s->avctx->hwaccel->end_frame(s->avctx) < 0) + if ((ret = s->avctx->hwaccel->end_frame(s->avctx)) < 0) { av_log(avctx, AV_LOG_ERROR, "hardware accelerator failed to decode first field\n"); + return ret; + } } for (i = 0; i < 4; i++) { @@ -2079,9 +2103,12 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict) return 0; if (s->avctx->hwaccel) { - if (s->avctx->hwaccel->end_frame(s->avctx) < 0) + int ret = s->avctx->hwaccel->end_frame(s->avctx); + if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "hardware accelerator failed to decode picture\n"); + return ret; + } } /* end of slice reached */ @@ -2196,7 +2223,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx, s->avctx->codec_id = AV_CODEC_ID_MPEG1VIDEO; s->out_format = FMT_MPEG1; s->swap_uv = 0; // AFAIK VCR2 does not have SEQ_HEADER - if (s->avctx->flags & CODEC_FLAG_LOW_DELAY) + if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) s->low_delay = 1; if (s->avctx->debug & FF_DEBUG_PICT_INFO) @@ -2445,9 +2472,11 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, s2->er.error_count += s2->thread_context[i]->er.error_count; } +#if FF_API_VDPAU if ((CONFIG_MPEG_VDPAU_DECODER || CONFIG_MPEG1_VDPAU_DECODER) && uses_vdpau(avctx)) ff_vdpau_mpeg_picture_complete(s2, buf, buf_size, s->slice_count); +#endif ret = slice_end(avctx, picture); if (ret < 0) @@ -2649,7 +2678,7 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, } } } - if (s2->pict_type == AV_PICTURE_TYPE_I || (s2->avctx->flags2 & CODEC_FLAG2_SHOW_ALL)) + if (s2->pict_type == AV_PICTURE_TYPE_I || (s2->avctx->flags2 & AV_CODEC_FLAG2_SHOW_ALL)) s->sync = 1; if (!s2->next_picture_ptr) { /* Skip P-frames if we do not have a reference frame or @@ -2696,10 +2725,12 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, return AVERROR_INVALIDDATA; } +#if FF_API_VDPAU if (uses_vdpau(avctx)) { s->slice_count++; break; } +#endif if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE) && @@ -2770,7 +2801,7 @@ static int mpeg_decode_frame(AVCodecContext *avctx, void *data, return buf_size; } - if (s2->avctx->flags & CODEC_FLAG_TRUNCATED) { + if (s2->avctx->flags & AV_CODEC_FLAG_TRUNCATED) { int next = ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size, NULL); @@ -2848,9 +2879,9 @@ AVCodec ff_mpeg1video_decoder = { .init = mpeg_decode_init, .close = mpeg_decode_end, .decode = mpeg_decode_frame, - .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | - CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | - CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_SLICE_THREADS, .flush = flush, .max_lowres = 3, .update_thread_context = ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context) @@ -2865,9 +2896,9 @@ AVCodec ff_mpeg2video_decoder = { .init = mpeg_decode_init, .close = mpeg_decode_end, .decode = mpeg_decode_frame, - .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | - CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | - CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_SLICE_THREADS, .flush = flush, .max_lowres = 3, .profiles = NULL_IF_CONFIG_SMALL(mpeg2_video_profiles), @@ -2883,13 +2914,14 @@ AVCodec ff_mpegvideo_decoder = { .init = mpeg_decode_init, .close = mpeg_decode_end, .decode = mpeg_decode_frame, - .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS, .flush = flush, .max_lowres = 3, }; #if FF_API_XVMC #if CONFIG_MPEG_XVMC_DECODER +FF_DISABLE_DEPRECATION_WARNINGS static av_cold int mpeg_mc_decode_init(AVCodecContext *avctx) { if (avctx->active_thread_type & FF_THREAD_SLICE) @@ -2916,15 +2948,16 @@ AVCodec ff_mpeg_xvmc_decoder = { .init = mpeg_mc_decode_init, .close = mpeg_decode_end, .decode = mpeg_decode_frame, - .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | - CODEC_CAP_TRUNCATED | CODEC_CAP_HWACCEL | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_TRUNCATED | CODEC_CAP_HWACCEL | + AV_CODEC_CAP_DELAY, .flush = flush, }; - +FF_ENABLE_DEPRECATION_WARNINGS #endif #endif /* FF_API_XVMC */ -#if CONFIG_MPEG_VDPAU_DECODER +#if CONFIG_MPEG_VDPAU_DECODER && FF_API_VDPAU AVCodec ff_mpeg_vdpau_decoder = { .name = "mpegvideo_vdpau", .long_name = NULL_IF_CONFIG_SMALL("MPEG-1/2 video (VDPAU acceleration)"), @@ -2934,13 +2967,13 @@ AVCodec ff_mpeg_vdpau_decoder = { .init = mpeg_decode_init, .close = mpeg_decode_end, .decode = mpeg_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | - CODEC_CAP_HWACCEL_VDPAU | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_TRUNCATED | + AV_CODEC_CAP_HWACCEL_VDPAU | AV_CODEC_CAP_DELAY, .flush = flush, }; #endif -#if CONFIG_MPEG1_VDPAU_DECODER +#if CONFIG_MPEG1_VDPAU_DECODER && FF_API_VDPAU AVCodec ff_mpeg1_vdpau_decoder = { .name = "mpeg1video_vdpau", .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video (VDPAU acceleration)"), @@ -2950,8 +2983,8 @@ AVCodec ff_mpeg1_vdpau_decoder = { .init = mpeg_decode_init, .close = mpeg_decode_end, .decode = mpeg_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | - CODEC_CAP_HWACCEL_VDPAU | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_TRUNCATED | + AV_CODEC_CAP_HWACCEL_VDPAU | AV_CODEC_CAP_DELAY, .flush = flush, }; #endif