[FFmpeg-devel] [PATCH] mpeg12: reduce hwaccel-related code duplication.
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Sun Feb 24 17:22:16 CET 2013
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
---
libavcodec/mpeg12.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 2ef3360..85cf068 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -1245,6 +1245,12 @@ static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx)
} else if (!avctx->xvmc_acceleration) {
avctx->xvmc_acceleration = 2;
}
+ avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
+ // until then pix_fmt may be changed right after codec init
+ if (avctx->pix_fmt == AV_PIX_FMT_XVMC_MPEG2_IDCT ||
+ avctx->hwaccel || uses_vdpau(avctx))
+ if (avctx->idct_algo == FF_IDCT_AUTO)
+ avctx->idct_algo = FF_IDCT_SIMPLE;
return res;
} else if(s->chroma_format == 2)
return AV_PIX_FMT_YUV422P;
@@ -1346,12 +1352,6 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
} // MPEG-2
avctx->pix_fmt = mpeg_get_pixelformat(avctx);
- avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
- // until then pix_fmt may be changed right after codec init
- if (avctx->pix_fmt == AV_PIX_FMT_XVMC_MPEG2_IDCT ||
- avctx->hwaccel || uses_vdpau(avctx))
- if (avctx->idct_algo == FF_IDCT_AUTO)
- avctx->idct_algo = FF_IDCT_SIMPLE;
/* Quantization matrices may need reordering
* if DCT permutation is changed. */
@@ -2083,11 +2083,6 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
s->low_delay = 1;
avctx->pix_fmt = mpeg_get_pixelformat(avctx);
- avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
-
- if (avctx->pix_fmt == AV_PIX_FMT_XVMC_MPEG2_IDCT || avctx->hwaccel || uses_vdpau(avctx))
- if (avctx->idct_algo == FF_IDCT_AUTO)
- avctx->idct_algo = FF_IDCT_SIMPLE;
if (ff_MPV_common_init(s) < 0)
return -1;
--
1.7.10.4
More information about the ffmpeg-devel
mailing list