summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2017-10-26 00:18:42 +0100
committerMark Thompson <sw@jkqxz.net>2017-12-19 23:21:59 +0000
commit57623cba1301ee7874687dd7e04c611051638e9d (patch)
tree86f891c6a341fc5de1ec62a5a22d14a71f902bf5 /libavcodec
parent2fcb0090115f7fc7648ad241a5903f866760d4b6 (diff)
webp: Fix alpha initialisation
ff_get_format() in the next patch will reject formats which aren't in the offered list, so the hack in 7cb9296db872c4221453e5411f242ebcfca62664 is no longer valid. Change the hack by adding a new field in the VP8 decoder context to indicate that it's actually WebP and don't call ff_get_format() at all in that case.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/vp8.c4
-rw-r--r--libavcodec/vp8.h1
-rw-r--r--libavcodec/webp.c16
3 files changed, 9 insertions, 12 deletions
diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index 6d1a399304..5c0b4749ad 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -2515,7 +2515,9 @@ int vp78_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (ret < 0)
goto err;
- if (!is_vp7 && s->pix_fmt == AV_PIX_FMT_NONE) {
+ if (s->actually_webp) {
+ // avctx->pix_fmt already set in caller.
+ } else if (!is_vp7 && s->pix_fmt == AV_PIX_FMT_NONE) {
enum AVPixelFormat pix_fmts[] = {
#if CONFIG_VP8_VAAPI_HWACCEL
AV_PIX_FMT_VAAPI,
diff --git a/libavcodec/vp8.h b/libavcodec/vp8.h
index 1870705ad2..1bf7561d05 100644
--- a/libavcodec/vp8.h
+++ b/libavcodec/vp8.h
@@ -140,6 +140,7 @@ typedef struct VP8Context {
VP8ThreadData *thread_data;
AVCodecContext *avctx;
enum AVPixelFormat pix_fmt;
+ int actually_webp;
VP8Frame *framep[4];
VP8Frame *next_framep[4];
diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 18d68e9140..0e769c307d 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -1288,16 +1288,6 @@ static int vp8_lossy_decode_alpha(AVCodecContext *avctx, AVFrame *p,
return 0;
}
-static enum AVPixelFormat webp_get_format(AVCodecContext *avctx,
- const enum AVPixelFormat *formats)
-{
- WebPContext *s = avctx->priv_data;
- if (s->has_alpha)
- return AV_PIX_FMT_YUVA420P;
- else
- return AV_PIX_FMT_YUV420P;
-}
-
static int vp8_lossy_decode_frame(AVCodecContext *avctx, AVFrame *p,
int *got_frame, uint8_t *data_start,
unsigned int data_size)
@@ -1309,7 +1299,11 @@ static int vp8_lossy_decode_frame(AVCodecContext *avctx, AVFrame *p,
if (!s->initialized) {
ff_vp8_decode_init(avctx);
s->initialized = 1;
- avctx->get_format = webp_get_format;
+ s->v.actually_webp = 1;
+ if (s->has_alpha)
+ avctx->pix_fmt = AV_PIX_FMT_YUVA420P;
+ else
+ avctx->pix_fmt = AV_PIX_FMT_YUV420P;
}
s->lossless = 0;