[FFmpeg-devel] [PATCH 14/47] fftools/ffmpeg_dec: return error codes from dec_packet() instead of aborting

Anton Khirnov anton at khirnov.net
Sat Jul 15 13:45:38 EEST 2023


---
 fftools/ffmpeg.c     | 5 ++++-
 fftools/ffmpeg_dec.c | 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index ddb011741a..b4ea52ac1d 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -814,8 +814,11 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo
     int eof_reached = 0;
     int duration_exceeded;
 
-    if (ist->decoding_needed)
+    if (ist->decoding_needed) {
         ret = dec_packet(ist, pkt, no_eof);
+        if (ret < 0 && ret != AVERROR_EOF)
+            return ret;
+    }
     if (ret == AVERROR_EOF || (!pkt && !ist->decoding_needed))
         eof_reached = 1;
 
diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index 5c1b8888e9..f5f764b6fa 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -816,7 +816,7 @@ finish:
     }
     // non-EOF errors here are all fatal
     if (ret < 0 && ret != AVERROR_EOF)
-        report_and_exit(ret);
+        return ret;
 
     // signal EOF to our downstreams
     if (ist->dec->type == AVMEDIA_TYPE_SUBTITLE)
@@ -825,7 +825,7 @@ finish:
         ret = send_filter_eof(ist);
         if (ret < 0) {
             av_log(NULL, AV_LOG_FATAL, "Error marking filters as finished\n");
-            exit_program(1);
+            return ret;
         }
     }
 
-- 
2.40.1



More information about the ffmpeg-devel mailing list