2016-07-09 12:18 GMT+02:00 Michael Niedermayer <mich...@niedermayer.cc>:

> On Sat, Jul 09, 2016 at 11:53:04AM +0200, Hendrik Leppkes wrote:
> > On Sat, Jul 9, 2016 at 11:13 AM, Michael Niedermayer
> > <mich...@niedermayer.cc> wrote:
> > > On Sun, Jun 26, 2016 at 10:45:33PM +0200, Martin Vignali wrote:
> > >> Hello,
> > >>
> > >> in attach patch to fix ret code check in webp lossy decoding (when
> files
> > >> have alpha)
> > >>
> > >> before this patch, if an error occured during rgb decoding
> > >> the return code was ignored. And a useless ret test was made
> > >> after alpha decoding.
> > >>
> > >> after this patch, the return code of rgb is test before
> > >> trying to decode alpha.
> > >>
> > >>
> > >> Comments welcome
> > >>
> > >> Martin
> > >> Jokyo Images
> > >
> > >>  webp.c |    4 ++--
> > >>  1 file changed, 2 insertions(+), 2 deletions(-)
> > >> 494399734be14a906e03a1b976dbca27c442cdac
> 0001-libavcodec-webp-fix-return-code-check-in-lossy-decod.patch
> > >> From 4b7a1b3c03ec1a9062d3100d79668d905f6226fe Mon Sep 17 00:00:00 2001
> > >> From: Martin Vignali <martin.vign...@gmail.com>
> > >> Date: Sun, 26 Jun 2016 22:36:23 +0200
> > >> Subject: [PATCH] libavcodec/webp : fix return code check in lossy
> decoding
> > >>
> > >> before this patch, if an error occured during rgb decoding
> > >> the return code was ignored. And an useless ret test was made
> > >> after alpha decoding.
> > >>
> > >> after this patch, the return code of rgb is test before
> > >> trying to decode alpha.
> > >
> > > should not both be attempted to be decoded and in case both fail an
> > > error be returned?
> > >
> > > One could be correctly decoded and that should not be discarded
> > > but maybe iam missing something
> > >
> >
> > Decoding the alpha plane when the RGB plane failed seems rather
> > useless, doesn't it.
>
> I dont know
> to me having an alpha plane seems better than having nothing
>
> With slices we generally also return what we can even if its just
> one macroblock we could decode
> also with videos and slices previous frames would be used to fill in
> missing areas ...
>

In attach a new patch.
for rgba lossy file :
if rgb decoding failed, an error is log, but alpha is decode
if alpha decoding failed, an error is log
if both failed, return invalid data.

Comments welcome

Martin
From ba52bd0377303e56e322079e71a4d83b95cb5f80 Mon Sep 17 00:00:00 2001
From: Martin Vignali <martin.vign...@gmail.com>
Date: Sat, 9 Jul 2016 17:32:04 +0200
Subject: [PATCH] libavcodec/webp : check return code of rgb and alpha.

---
 libavcodec/webp.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 45abfdc..890cbba 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -1322,7 +1322,7 @@ static int vp8_lossy_decode_frame(AVCodecContext *avctx, AVFrame *p,
 {
     WebPContext *s = avctx->priv_data;
     AVPacket pkt;
-    int ret;
+    int ret, aret;
 
     if (!s->initialized) {
         ff_vp8_decode_init(avctx);
@@ -1343,10 +1343,16 @@ static int vp8_lossy_decode_frame(AVCodecContext *avctx, AVFrame *p,
 
     ret = ff_vp8_decode_frame(avctx, p, got_frame, &pkt);
     if (s->has_alpha) {
-        ret = vp8_lossy_decode_alpha(avctx, p, s->alpha_data,
-                                     s->alpha_data_size);
         if (ret < 0)
-            return ret;
+            av_log(avctx, AV_LOG_ERROR, "Failed to decode rgb\n");
+
+        aret = vp8_lossy_decode_alpha(avctx, p, s->alpha_data,
+                                     s->alpha_data_size);
+        if (aret < 0)
+            av_log(avctx, AV_LOG_ERROR, "Failed to decode alpha\n");
+
+        if ((ret < 0)&&(aret < 0))
+            return AVERROR_INVALIDDATA;
     }
     return ret;
 }
-- 
1.9.3 (Apple Git-50)

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to