diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2013-08-08 20:27:24 +0200 |
---|---|---|
committer | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2013-09-22 16:20:54 +0200 |
commit | 547c2f002a87f4412a83c23b0d60364be5e7ce58 (patch) | |
tree | b7ae4ce31ea8d8344a54c1290a4f690936d46a80 /libavcodec/vp56.c | |
parent | a5cbf1991c3d04b0be3c23ee0a7096b5a365cc85 (diff) | |
download | ffmpeg-streaming-547c2f002a87f4412a83c23b0d60364be5e7ce58.zip ffmpeg-streaming-547c2f002a87f4412a83c23b0d60364be5e7ce58.tar.gz |
Make decoding alpha optional for some codecs.
For codecs where decoding of a whole plane can simply
be skipped, we should offer applications to not decode
alpha for better performance (ca. 30% less CPU usage
and 40% reduced memory bandwidth).
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.
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Diffstat (limited to 'libavcodec/vp56.c')
-rw-r--r-- | libavcodec/vp56.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libavcodec/vp56.c b/libavcodec/vp56.c index 25801ea..d67eaa6 100644 --- a/libavcodec/vp56.c +++ b/libavcodec/vp56.c @@ -530,7 +530,7 @@ int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, if (ff_get_buffer(avctx, p, AV_GET_BUFFER_FLAG_REF) < 0) return -1; - if (s->has_alpha) { + if (avctx->pix_fmt == AV_PIX_FMT_YUVA420P) { av_frame_unref(s->alpha_context->frames[VP56_FRAME_CURRENT]); if ((ret = av_frame_ref(s->alpha_context->frames[VP56_FRAME_CURRENT], p)) < 0) { av_frame_unref(p); @@ -545,7 +545,7 @@ int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, } } - if (s->has_alpha) { + if (avctx->pix_fmt == AV_PIX_FMT_YUVA420P) { int bak_w = avctx->width; int bak_h = avctx->height; int bak_cw = avctx->coded_width; @@ -567,7 +567,7 @@ int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, } } - avctx->execute2(avctx, ff_vp56_decode_mbs, 0, 0, s->has_alpha + 1); + avctx->execute2(avctx, ff_vp56_decode_mbs, 0, 0, (avctx->pix_fmt == AV_PIX_FMT_YUVA420P) + 1); if ((res = av_frame_ref(data, p)) < 0) return res; @@ -690,6 +690,7 @@ av_cold int ff_vp56_init_context(AVCodecContext *avctx, VP56Context *s, s->avctx = avctx; avctx->pix_fmt = has_alpha ? AV_PIX_FMT_YUVA420P : AV_PIX_FMT_YUV420P; + if (avctx->skip_alpha) avctx->pix_fmt = AV_PIX_FMT_YUV420P; ff_h264chroma_init(&s->h264chroma, 8); ff_hpeldsp_init(&s->hdsp, avctx->flags); |