diff mbox series

[FFmpeg-devel,25/25] fftools/ffmpeg: move handling corrupt packets to the input thread

Message ID 20220803135844.16662-25-anton@khirnov.net
State Accepted
Commit a5e025e826789164569d2ff44a784cd3f953eaca
Headers show
Series [FFmpeg-devel,01/25] fftools/ffmpeg_opt: move adding attachments out of open_output_file() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov Aug. 3, 2022, 1:58 p.m. UTC
---
 fftools/ffmpeg.c       |  7 -------
 fftools/ffmpeg_demux.c | 11 +++++++++++
 2 files changed, 11 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index a9eda3c33e..09a4d20028 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3729,13 +3729,6 @@  static int process_input(int file_index)
     if (ist->discard)
         goto discard_packet;
 
-    if (pkt->flags & AV_PKT_FLAG_CORRUPT) {
-        av_log(NULL, exit_on_error ? AV_LOG_FATAL : AV_LOG_WARNING,
-               "%s: corrupt input packet in stream %d\n", is->url, pkt->stream_index);
-        if (exit_on_error)
-            exit_program(1);
-    }
-
     if (debug_ts) {
         av_log(NULL, AV_LOG_INFO, "demuxer -> ist_index:%d type:%s "
                "next_dts:%s next_dts_time:%s next_pts:%s next_pts_time:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s duration:%s duration_time:%s off:%s off_time:%s\n",
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index af54ea3de1..097a6e3d1d 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -165,6 +165,17 @@  static void *input_thread(void *arg)
             continue;
         }
 
+        if (pkt->flags & AV_PKT_FLAG_CORRUPT) {
+            av_log(NULL, exit_on_error ? AV_LOG_FATAL : AV_LOG_WARNING,
+                   "%s: corrupt input packet in stream %d\n",
+                   f->ctx->url, pkt->stream_index);
+            if (exit_on_error) {
+                av_packet_unref(pkt);
+                ret = AVERROR_INVALIDDATA;
+                break;
+            }
+        }
+
         msg.pkt = av_packet_alloc();
         if (!msg.pkt) {
             av_packet_unref(pkt);