diff options
author | Ivan Kalvachev <ikalvachev@gmail.com> | 2013-12-14 21:29:15 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-12-22 22:03:47 +0100 |
commit | 1c63aed232febf4404659bf006237ee4f7f17c9c (patch) | |
tree | 8024b37b264802e26a7c481692b6ea1566e83284 /libavcodec/mpeg12dec.c | |
parent | c19f193c6b239782b10bd9df117da2e50468edf9 (diff) | |
download | ffmpeg-1c63aed232febf4404659bf006237ee4f7f17c9c.tar.gz |
Convert XvMC to hwaccel v3
Signed-off-by: Ivan Kalvachev <ikalvachev@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/mpeg12dec.c')
-rw-r--r-- | libavcodec/mpeg12dec.c | 91 |
1 files changed, 19 insertions, 72 deletions
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 653e78c301..de6b2b6859 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -666,14 +666,6 @@ static inline int get_qscale(MpegEncContext *s) } } -static void exchange_uv(MpegEncContext *s) -{ - int16_t (*tmp)[64]; - - tmp = s->pblocks[4]; - s->pblocks[4] = s->pblocks[5]; - s->pblocks[5] = tmp; -} /* motion type (for MPEG-2) */ #define MT_FIELD 1 @@ -777,17 +769,10 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) } else memset(s->last_mv, 0, sizeof(s->last_mv)); /* reset mv prediction */ s->mb_intra = 1; -#if FF_API_XVMC -FF_DISABLE_DEPRECATION_WARNINGS // if 1, we memcpy blocks in xvmcvideo - if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1) { + if (CONFIG_XVMC && s->pack_pblocks) { ff_xvmc_pack_pblocks(s, -1); // inter are always full blocks - if (s->swap_uv) { - exchange_uv(s); - } } -FF_ENABLE_DEPRECATION_WARNINGS -#endif /* FF_API_XVMC */ if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) { if (s->flags2 & CODEC_FLAG2_FAST) { @@ -1000,17 +985,10 @@ FF_ENABLE_DEPRECATION_WARNINGS return -1; } -#if FF_API_XVMC -FF_DISABLE_DEPRECATION_WARNINGS //if 1, we memcpy blocks in xvmcvideo - if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1) { + if (CONFIG_XVMC && s->pack_pblocks) { ff_xvmc_pack_pblocks(s, cbp); - if (s->swap_uv) { - exchange_uv(s); - } } -FF_ENABLE_DEPRECATION_WARNINGS -#endif /* FF_API_XVMC */ if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) { if (s->flags2 & CODEC_FLAG2_FAST) { @@ -1134,12 +1112,9 @@ static void quant_matrix_rebuild(uint16_t *matrix, const uint8_t *old_perm, } static const enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[] = { -#if FF_API_XVMC -#if CONFIG_MPEG_XVMC_DECODER - AV_PIX_FMT_XVMC_MPEG2_IDCT, - AV_PIX_FMT_XVMC_MPEG2_MC, +#if CONFIG_MPEG1_XVMC_HWACCEL + AV_PIX_FMT_XVMC, #endif -#endif /* FF_API_XVMC */ #if CONFIG_MPEG1_VDPAU_HWACCEL AV_PIX_FMT_VDPAU_MPEG1, AV_PIX_FMT_VDPAU, @@ -1149,12 +1124,9 @@ static const enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[] = { }; static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = { -#if FF_API_XVMC -#if CONFIG_MPEG_XVMC_DECODER - AV_PIX_FMT_XVMC_MPEG2_IDCT, - AV_PIX_FMT_XVMC_MPEG2_MC, +#if CONFIG_MPEG2_XVMC_HWACCEL + AV_PIX_FMT_XVMC, #endif -#endif /* FF_API_XVMC */ #if CONFIG_MPEG2_VDPAU_HWACCEL AV_PIX_FMT_VDPAU_MPEG2, AV_PIX_FMT_VDPAU, @@ -1191,25 +1163,21 @@ static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx) static void setup_hwaccel_for_pixfmt(AVCodecContext *avctx) { -#if FF_API_XVMC -FF_DISABLE_DEPRECATION_WARNINGS - if (avctx->pix_fmt != AV_PIX_FMT_XVMC_MPEG2_IDCT && avctx->pix_fmt != AV_PIX_FMT_XVMC_MPEG2_MC) { - avctx->xvmc_acceleration = 0; - } else if (!avctx->xvmc_acceleration) { - avctx->xvmc_acceleration = 2; - } -FF_ENABLE_DEPRECATION_WARNINGS -#endif /* FF_API_XVMC */ avctx->hwaccel = ff_find_hwaccel(avctx); // until then pix_fmt may be changed right after codec init -#if FF_API_XVMC - if (avctx->pix_fmt == AV_PIX_FMT_XVMC_MPEG2_IDCT || -#else - if ( -#endif - avctx->hwaccel || uses_vdpau(avctx)) + if (avctx->hwaccel || uses_vdpau(avctx)) if (avctx->idct_algo == FF_IDCT_AUTO) avctx->idct_algo = FF_IDCT_SIMPLE; + + if (avctx->hwaccel && avctx->pix_fmt == AV_PIX_FMT_XVMC) { + Mpeg1Context *s1 = avctx->priv_data; + MpegEncContext *s = &s1->mpeg_enc_ctx; + + s->pack_pblocks = 1; +#if FF_API_XVMC + avctx->xvmc_acceleration = 2; +#endif /* FF_API_XVMC */ + } } /* Call this function when we know all parameters. @@ -1630,16 +1598,6 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) return -1; } -#if FF_API_XVMC -FF_DISABLE_DEPRECATION_WARNINGS -// MPV_frame_start will call this function too, -// but we need to call it on every field - if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration) - if (ff_xvmc_field_start(s, avctx) < 0) - return -1; -FF_ENABLE_DEPRECATION_WARNINGS -#endif /* FF_API_XVMC */ - return 0; } @@ -1711,7 +1669,7 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y, return -1; } - if (avctx->hwaccel) { + if (avctx->hwaccel && avctx->hwaccel->decode_slice) { const uint8_t *buf_end, *buf_start = *buf - 4; /* include start_code */ int start_code = -1; buf_end = avpriv_find_start_code(buf_start + 2, *buf + buf_size, &start_code); @@ -1741,13 +1699,9 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y, } for (;;) { -#if FF_API_XVMC -FF_DISABLE_DEPRECATION_WARNINGS // If 1, we memcpy blocks in xvmcvideo. - if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1) + if (CONFIG_XVMC && s->pack_pblocks) ff_xvmc_init_block(s); // set s->block -FF_ENABLE_DEPRECATION_WARNINGS -#endif /* FF_API_XVMC */ if (mpeg_decode_mb(s, s->block) < 0) return -1; @@ -1949,13 +1903,6 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict) av_log(avctx, AV_LOG_ERROR, "hardware accelerator failed to decode picture\n"); } -#if FF_API_XVMC -FF_DISABLE_DEPRECATION_WARNINGS - if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration) - ff_xvmc_field_end(s); -FF_ENABLE_DEPRECATION_WARNINGS -#endif /* FF_API_XVMC */ - /* end of slice reached */ if (/*s->mb_y << field_pic == s->mb_height &&*/ !s->first_field && !s1->first_slice) { /* end of image */ |