[FFmpeg-devel] [PATCH 2/4] concatdec: store eof condition in context

Marton Balint cus at passwd.hu
Mon Jul 6 02:28:49 CEST 2015


This is needed later for outpoint support which may leave the last file in a
not-eof state.

Signed-off-by: Marton Balint <cus at passwd.hu>
---
 libavformat/concatdec.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index c61a1a3..11e6759 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -55,6 +55,7 @@ typedef struct {
     AVFormatContext *avf;
     int safe;
     int seekable;
+    int eof;
     ConcatMatchMode stream_match_mode;
     unsigned auto_convert;
 } ConcatContext;
@@ -444,8 +445,10 @@ static int open_next_file(AVFormatContext *avf)
             cat->cur_file->duration -= (cat->cur_file->inpoint - file_start_time);
     }
 
-    if (++fileno >= cat->nb_files)
+    if (++fileno >= cat->nb_files) {
+        cat->eof = 1;
         return AVERROR_EOF;
+    }
     return open_file(avf, fileno);
 }
 
@@ -509,6 +512,9 @@ static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt)
     ConcatStream *cs;
     AVStream *st;
 
+    if (cat->eof)
+        return AVERROR_EOF;
+
     if (!cat->avf)
         return AVERROR(EIO);
 
@@ -640,6 +646,7 @@ static int concat_seek(AVFormatContext *avf, int stream,
         cat->cur_file = cur_file_saved;
     } else {
         avformat_close_input(&cur_avf_saved);
+        cat->eof = 0;
     }
     return ret;
 }
-- 
2.1.4



More information about the ffmpeg-devel mailing list