diff mbox series

[FFmpeg-devel,09/12] lavf/concat: add support for chapters

Message ID 20210831180739.873390-9-george@nsup.org
State Accepted
Commit 2263ff505c986f03005674072c1d46f0723143ea
Headers show
Series [FFmpeg-devel,01/12] lavf/concat: refactor parsing | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Nicolas George Aug. 31, 2021, 6:07 p.m. UTC
Signed-off-by: Nicolas George <george@nsup.org>
---
 doc/demuxers.texi       |  4 ++++
 libavformat/concatdec.c | 12 +++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 6bb0574e94..0c347e3f47 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -184,6 +184,10 @@  Can be present multiple times.
 @item @code{stream_codec @var{value}}
 Codec for the stream.
 
+@item @code{cahpter @var{id} @var{start} @var{end}}
+Add a chapter. @var{id} is an unique identifier, possibly small and
+consecutive.
+
 @end table
 
 @subsection Options
diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index a0d68d51cc..0dd39a149e 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -408,7 +408,7 @@  static int concat_read_close(AVFormatContext *avf)
     return 0;
 }
 
-#define MAX_ARGS 2
+#define MAX_ARGS 3
 #define NEEDS_UNSAFE   (1 << 1)
 #define NEEDS_FILE     (1 << 1)
 #define NEEDS_STREAM   (1 << 2)
@@ -432,6 +432,7 @@  typedef enum ParseDirective {
    DIR_EXSID,
    DIR_STMETA,
    DIR_STCODEC,
+   DIR_CHAPTER,
 } ParseDirective;
 
 static const ParseSyntax syntax[] = {
@@ -447,6 +448,7 @@  static const ParseSyntax syntax[] = {
     [DIR_EXSID    ] = { "exact_stream_id",      "i",    NEEDS_STREAM },
     [DIR_STMETA   ] = { "stream_meta",          "ks",   NEEDS_STREAM },
     [DIR_STCODEC  ] = { "stream_codec",         "k",    NEEDS_STREAM },
+    [DIR_CHAPTER  ] = { "chapter",              "idd",  0 },
 };
 
 static int concat_parse_script(AVFormatContext *avf)
@@ -457,6 +459,7 @@  static int concat_parse_script(AVFormatContext *avf)
     uint8_t *cursor, *keyword;
     ConcatFile *file = NULL;
     AVStream *stream = NULL;
+    AVChapter *chapter = NULL;
     unsigned line = 0, arg;
     const ParseSyntax *dir;
     char *arg_kw[MAX_ARGS];
@@ -609,6 +612,13 @@  static int concat_parse_script(AVFormatContext *avf)
             break;
         }
 
+        case DIR_CHAPTER:
+            chapter = avpriv_new_chapter(avf, arg_int[0], AV_TIME_BASE_Q,
+                                         arg_int[1], arg_int[2], NULL);
+            if (!chapter)
+                return AVERROR(ENOMEM);
+            break;
+
         default:
             FAIL(AVERROR_BUG);
         }