diff mbox series

[FFmpeg-devel,11/11] fftools/ffmpeg: discard packets for unused streams in demuxing thread

Message ID 20230505090723.24872-11-anton@khirnov.net
State Accepted
Commit 2d43c23b812ade93b60f5025dd18bf55dbea5e3d
Headers show
Series [FFmpeg-devel,01/11] fftools/ffmpeg: merge choose_output() and got_eagain() | 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 May 5, 2023, 9:07 a.m. UTC
Avoids the pointless overhead of transferring them to the main thread.
---
 fftools/ffmpeg.c       | 4 ----
 fftools/ffmpeg_demux.c | 3 ++-
 2 files changed, 2 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 1ae9445b5d..0edcd3466e 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1961,9 +1961,6 @@  static int process_input(int file_index)
     ist->data_size += pkt->size;
     ist->nb_packets++;
 
-    if (ist->discard)
-        goto discard_packet;
-
     /* add the stream-global side data to the first packet */
     if (ist->nb_packets == 1) {
         for (i = 0; i < ist->st->nb_side_data; i++) {
@@ -2002,7 +1999,6 @@  static int process_input(int file_index)
 
     process_input_packet(ist, pkt, 0);
 
-discard_packet:
     av_packet_free(&pkt);
 
     return 0;
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index ad283356ba..6ba9aaca33 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -318,7 +318,8 @@  static void *input_thread(void *arg)
 
         /* the following test is needed in case new streams appear
            dynamically in stream : we ignore them */
-        if (pkt->stream_index >= f->nb_streams) {
+        if (pkt->stream_index >= f->nb_streams ||
+            f->streams[pkt->stream_index]->discard) {
             report_new_stream(d, pkt);
             av_packet_unref(pkt);
             continue;