[FFmpeg-devel] [PATCH] avformat: Allow forcing use of AVParsers

Michael Niedermayer michael at niedermayer.cc
Mon Sep 5 12:14:21 EEST 2016


TODO: version bump, docs

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavformat/avformat.h      | 8 ++++++++
 libavformat/options_table.h | 1 +
 libavformat/utils.c         | 3 +++
 3 files changed, 12 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 3ee7051..33b921a 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1886,6 +1886,14 @@ typedef struct AVFormatContext {
      * - decoding: set by user through AVOptions (NO direct access)
      */
     char *protocol_blacklist;
+
+    /**
+     * Force parsing.
+     * - encoding: unused
+     * - decoding: set by user through AVOptions (NO direct access)
+     */
+    int force_parsing;
+
 } AVFormatContext;
 
 int av_format_get_probe_score(const AVFormatContext *s);
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index 3b74d1b..359796c 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -103,6 +103,7 @@ static const AVOption avformat_options[] = {
 {"format_whitelist", "List of demuxers that are allowed to be used", OFFSET(format_whitelist), AV_OPT_TYPE_STRING, { .str = NULL },  CHAR_MIN, CHAR_MAX, D },
 {"protocol_whitelist", "List of protocols that are allowed to be used", OFFSET(protocol_whitelist), AV_OPT_TYPE_STRING, { .str = NULL },  CHAR_MIN, CHAR_MAX, D },
 {"protocol_blacklist", "List of protocols that are not allowed to be used", OFFSET(protocol_blacklist), AV_OPT_TYPE_STRING, { .str = NULL },  CHAR_MIN, CHAR_MAX, D },
+{"forceparsing", "force use of AVParsers", OFFSET(force_parsing), AV_OPT_TYPE_INT, { .i64 = -1 },  -1, AVSTREAM_PARSE_FULL_ONCE, D },
 {NULL},
 };
 
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 7d23c4a..a692e65 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4197,6 +4197,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
          * timestamps have their first few packets buffered and the
          * timestamps corrected before they are returned to the user */
         st->cur_dts = RELATIVE_TS_BASE;
+
+        if (s->force_parsing >= 0)
+            st->need_parsing = s->force_parsing;
     } else {
         st->cur_dts = AV_NOPTS_VALUE;
     }
-- 
2.9.3



More information about the ffmpeg-devel mailing list