On 07/09/2017 21:49, Mark Thompson wrote:
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.
---
(What idiot wrote something which returned a format not in the list from 
get_format()...)


  libavcodec/vp8.c  |  4 +++-
  libavcodec/vp8.h  |  1 +
  libavcodec/webp.c | 16 +++++-----------
  3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index a07206706..fd8d9362c 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 1870705ad..1bf7561d0 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 18d68e914..0e769c307 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;

Seems fine.
_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to