[FFmpeg-devel] [PATCH] Make decoding alpha option for some codecs.
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Wed Sep 18 00:35:19 CEST 2013
On Tue, Sep 17, 2013 at 09:36:02PM +0200, Michael Niedermayer wrote:
> On Tue, Sep 17, 2013 at 09:31:07PM +0200, Reimar Döffinger wrote:
> > For codecs where decoding of a whole plane can simply
> > be skipped, we should offer applications to not decode
> > alpha for better performance.
> > It also means applications do not need to implement support
> > (even if it is rather simple) for YUVA formats in order to be
> > able to play these files.
> > Unfortunately a good way to test this via FFmpeg only is missing,
> > suggestions welcome.
> >
> > Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
> > ---
> > libavcodec/ffv1dec.c | 15 ++++++++++++---
> > libavcodec/proresdec2.c | 8 +++++++-
> > libavcodec/proresdec_lgpl.c | 14 +++++++++++++-
> > libavcodec/vp56.c | 12 ++++++++----
> > 4 files changed, 40 insertions(+), 9 deletions(-)
> >
>
> > diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
> > index 5455660..75e26bc 100644
> > --- a/libavcodec/ffv1dec.c
> > +++ b/libavcodec/ffv1dec.c
> > @@ -659,14 +659,23 @@ static int read_header(FFV1Context *f)
> > return AVERROR(ENOSYS);
> > }
> > } else if (f->avctx->bits_per_raw_sample <= 8 && f->transparency) {
> > + static const enum AVPixelFormat alpha_fmts[][3] = {
> > + {AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_NONE},
> > + {AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE},
> > + {AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE}
> > + };
> > switch(16*f->chroma_h_shift + f->chroma_v_shift) {
> > - case 0x00: f->avctx->pix_fmt = AV_PIX_FMT_YUVA444P; break;
> > - case 0x10: f->avctx->pix_fmt = AV_PIX_FMT_YUVA422P; break;
> > - case 0x11: f->avctx->pix_fmt = AV_PIX_FMT_YUVA420P; break;
> > + case 0x00: f->avctx->pix_fmt = f->avctx->get_format(f->avctx, alpha_fmts[0]); break;
> > + case 0x10: f->avctx->pix_fmt = f->avctx->get_format(f->avctx, alpha_fmts[1]); break;
> > + case 0x11: f->avctx->pix_fmt = f->avctx->get_format(f->avctx, alpha_fmts[2]); break;
> > default:
> > av_log(f->avctx, AV_LOG_ERROR, "format not supported\n");
> > return AVERROR(ENOSYS);
> > }
> > + if (f->avctx->pix_fmt != AV_PIX_FMT_YUVA444P &&
> > + f->avctx->pix_fmt != AV_PIX_FMT_YUVA422P &&
> > + f->avctx->pix_fmt != AV_PIX_FMT_YUVA420P)
> > + f->transparency = 0;
> > } else if (f->avctx->bits_per_raw_sample == 9) {
> > f->packed_at_lsb = 1;
> > switch(16 * f->chroma_h_shift + f->chroma_v_shift) {
>
> LGTM if tested
FATE does not seem to test YUV FFV1 with transparency, so I can only
test manually which is not so reliable.
Any plans of maybe extending the test coverage?
More information about the ffmpeg-devel
mailing list