Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/6] ffmpeg: flush delayed frames in codec copy scenarios
@ 2022-02-14 22:41 James Almer
  2022-02-14 22:41 ` [FFmpeg-devel] [PATCH 2/6] avcodec/bsf: add a capabilities field to AVBitStreamFilter James Almer
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: James Almer @ 2022-02-14 22:41 UTC (permalink / raw)
  To: ffmpeg-devel

Bitstream filters inserted between the input and output were
never drained, resulting packets being lost if the bsf had any
buffered.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 fftools/ffmpeg.c        | 11 +++++++----
 fftools/ffmpeg.h        |  1 +
 fftools/ffmpeg_filter.c |  1 +
 fftools/ffmpeg_opt.c    |  4 ++++
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 7beea11933..6aa0986f02 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2733,7 +2733,9 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo
         }
         ist->pts = ist->dts;
         ist->next_pts = ist->next_dts;
-    }
+    } else if (!ist->decoding_needed)
+        eof_reached = 1;
+
     for (i = 0; i < nb_output_streams; i++) {
         OutputStream *ost = output_streams[i];
 
@@ -4213,11 +4215,12 @@ static int process_input(int file_index)
         for (i = 0; i < ifile->nb_streams; i++) {
             ist = input_streams[ifile->ist_index + i];
             avctx = ist->dec_ctx;
-            if (ist->decoding_needed) {
+            if (ist->processing_needed) {
                 ret = process_input_packet(ist, NULL, 1);
                 if (ret>0)
                     return 0;
-                avcodec_flush_buffers(avctx);
+                if (ist->decoding_needed)
+                    avcodec_flush_buffers(avctx);
             }
         }
 #if HAVE_THREADS
@@ -4247,7 +4250,7 @@ static int process_input(int file_index)
 
         for (i = 0; i < ifile->nb_streams; i++) {
             ist = input_streams[ifile->ist_index + i];
-            if (ist->decoding_needed) {
+            if (ist->processing_needed) {
                 ret = process_input_packet(ist, NULL, 0);
                 if (ret>0)
                     return 0;
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 81ec4d5970..1b8bbace3f 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -307,6 +307,7 @@ typedef struct InputStream {
     int decoding_needed;     /* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */
 #define DECODING_FOR_OST    1
 #define DECODING_FOR_FILTER 2
+    int processing_needed;   /* non zero if the packets must be processed */
 
     AVCodecContext *dec_ctx;
     const AVCodec *dec;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 41d87377c7..8ec1f0ffaf 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -277,6 +277,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
 
     ist->discard         = 0;
     ist->decoding_needed |= DECODING_FOR_FILTER;
+    ist->processing_needed = 1;
     ist->st->discard = AVDISCARD_NONE;
 
     ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 3102851885..bf1bbcae4c 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -2610,6 +2610,7 @@ loop_end:
         if (ost->encoding_needed && ost->source_index >= 0) {
             InputStream *ist = input_streams[ost->source_index];
             ist->decoding_needed |= DECODING_FOR_OST;
+            ist->processing_needed = 1;
 
             if (ost->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
                 ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
@@ -2622,6 +2623,9 @@ loop_end:
                     exit_program(1);
                 }
             }
+        } else if (ost->stream_copy && ost->source_index >= 0) {
+            InputStream *ist = input_streams[ost->source_index];
+            ist->processing_needed = 1;
         }
 
         /* set the filter output constraints */
-- 
2.35.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-02-22 16:54 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-14 22:41 [FFmpeg-devel] [PATCH 1/6] ffmpeg: flush delayed frames in codec copy scenarios James Almer
2022-02-14 22:41 ` [FFmpeg-devel] [PATCH 2/6] avcodec/bsf: add a capabilities field to AVBitStreamFilter James Almer
2022-02-14 22:41 ` [FFmpeg-devel] [PATCH 3/6] avcodec/bsf: set delay capability on the list filter James Almer
2022-02-14 22:41 ` [FFmpeg-devel] [PATCH 4/6] ffmpeg: don't skip packets before a keyframe was seen if a bsf with delay is used James Almer
2022-02-15 11:41   ` Anton Khirnov
2022-02-15 11:48     ` James Almer
2022-02-15 12:03       ` Anton Khirnov
2022-02-15 12:12         ` James Almer
2022-02-21 15:34           ` Anton Khirnov
2022-02-14 22:41 ` [FFmpeg-devel] [PATCH 5/6] avcodec/setts_bsf: add NEXT_PTS/DTS expression constants James Almer
2022-02-14 22:41 ` [FFmpeg-devel] [PATCH 6/6] avcodec/setts_bsf: add constants to modify packet duration James Almer
2022-02-22 16:49   ` James Almer
2022-02-22 16:55     ` Paul B Mahol
2022-02-15 15:56 ` [FFmpeg-devel] [PATCH 2/4] ffmpeg: ensure a keyframe was not seen before skipping packets James Almer

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git