On Wed, Nov 29, 2017 at 5:58 PM, Michael Niedermayer <mich...@niedermayer.cc
> wrote:

>
> AV_EF_EXPLODE appears to be a possibility, yes
> in general demuxers should try to extract as much as possible from a
> file and not give up if some broken packet is found
>

I don't think this is a good idea; some of these errors seem fairly fatal
to the overall process. I think instead it's better to write off the sample
you have as being invalid. That said, I defer to your judgement here, so
I've produced both versions of the patch and leave it to your decision.
Chrome is now always using AV_EF_EXPLODE, so either works for our usage.

- dale
From e47bd6161b4e062c669dad1989d2289fd1e3a8dc Mon Sep 17 00:00:00 2001
From: Dale Curtis <dalecur...@chromium.org>
Date: Tue, 28 Nov 2017 13:40:20 -0800
Subject: [PATCH] Respect AVERROR codes returned by ogg parsers.

Fixes ticket #6804. All of the ogg header and packet parsers may
return standard AVERROR codes; these return values should not be
treated as success. Despite returning some fairly serious error
codes, this version of the patch puts these failures behind an
error_recognition flag of AV_EF_EXPLODE.

Signed-off-by: Dale Curtis <dalecur...@chromium.org>
---
 libavformat/oggdec.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 193a286e43..03053bef7a 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -543,7 +543,11 @@ static int ogg_packet(AVFormatContext *s, int *sid, int *dstart, int *dsize,
     os->incomplete = 0;
 
     if (os->header) {
-        os->header = os->codec->header(s, idx);
+        if ((ret = os->codec->header(s, idx)) < 0 && (s->error_recognition & AV_EF_EXPLODE)) {
+            av_log(s, AV_LOG_ERROR, "Header processing failed: %d\n", ret);
+            return ret;
+        }
+        os->header = ret;
         if (!os->header) {
             os->segp  = segp;
             os->psize = psize;
@@ -574,8 +578,12 @@ static int ogg_packet(AVFormatContext *s, int *sid, int *dstart, int *dsize,
     } else {
         os->pflags    = 0;
         os->pduration = 0;
-        if (os->codec && os->codec->packet)
-            os->codec->packet(s, idx);
+        if (os->codec && os->codec->packet) {
+            if ((ret = os->codec->packet(s, idx)) < 0 && (s->error_recognition & AV_EF_EXPLODE)) {
+                av_log(s, AV_LOG_ERROR, "Packet processing failed: %d\n", ret);
+                return ret;
+            }
+        }
         if (sid)
             *sid = idx;
         if (dstart)
-- 
2.15.0.531.g2ccb3012c9-goog

From 80975de4c72f81d65ad9d3fa0c45ea2903a52434 Mon Sep 17 00:00:00 2001
From: Dale Curtis <dalecur...@chromium.org>
Date: Tue, 28 Nov 2017 13:40:20 -0800
Subject: [PATCH] Respect AVERROR codes returned by ogg parsers.

Fixes ticket #6804. All of the ogg header and packet parsers may
return standard AVERROR codes; these return values should not be
treated as success.

Signed-off-by: Dale Curtis <dalecur...@chromium.org>
---
 libavformat/oggdec.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 193a286e43..a55743db0d 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -543,7 +543,11 @@ static int ogg_packet(AVFormatContext *s, int *sid, int *dstart, int *dsize,
     os->incomplete = 0;
 
     if (os->header) {
-        os->header = os->codec->header(s, idx);
+        if ((ret = os->codec->header(s, idx)) < 0) {
+            av_log(s, AV_LOG_ERROR, "Header processing failed: %d\n", ret);
+            return ret;
+        }
+        os->header = ret;
         if (!os->header) {
             os->segp  = segp;
             os->psize = psize;
@@ -574,8 +578,12 @@ static int ogg_packet(AVFormatContext *s, int *sid, int *dstart, int *dsize,
     } else {
         os->pflags    = 0;
         os->pduration = 0;
-        if (os->codec && os->codec->packet)
-            os->codec->packet(s, idx);
+        if (os->codec && os->codec->packet) {
+            if ((ret = os->codec->packet(s, idx)) < 0) {
+                av_log(s, AV_LOG_ERROR, "Packet processing failed: %d\n", ret);
+                return ret;
+            }
+        }
         if (sid)
             *sid = idx;
         if (dstart)
-- 
2.15.0.531.g2ccb3012c9-goog

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

Reply via email to