[FFmpeg-devel] [PATCH] mpeg12: reduce hwaccel-related code duplication.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Feb 24 19:16:32 CET 2013


On Sun, Feb 24, 2013 at 06:06:08PM +0100, Michael Niedermayer wrote:
> On Sun, Feb 24, 2013 at 05:22:16PM +0100, Reimar Döffinger wrote:
> > 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;
> 
> with that mpeg_get_pixelformat would do more than just getting the
> pixel format (which is suggested by its name)

It does that already, it sets up avctx->xvmc_acceleration for example.
Setting up that one inside and hwaccel outside seem inconsistent for no
good reason.
Though moving all to a setup_for_hwaccel function or similar probably
should be fine just as much from my side.


More information about the ffmpeg-devel mailing list