diff mbox

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

Message ID 20161106201643.14758-1-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Nov. 6, 2016, 8:16 p.m. UTC
TODO: version bump, docs

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

Comments

Hendrik Leppkes Nov. 6, 2016, 10:24 p.m. UTC | #1
On Sun, Nov 6, 2016 at 9:16 PM, Michael Niedermayer
<michael@niedermayer.cc> wrote:
> TODO: version bump, docs
>
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/avformat.h      | 8 ++++++++
>  libavformat/options_table.h | 7 +++++++
>  libavformat/utils.c         | 3 +++
>  3 files changed, 18 insertions(+)
>
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index f9f4d72..96e6b94 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -1899,6 +1899,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;
> +

Might be a good idea to document  that this takes the same values as
st->need_parsing (ie. AVSTREAM_PARSE_* constants), otherwise its
really not obvious when using the API - only in the AVOptions.

>  } AVFormatContext;
>
>  int av_format_get_probe_score(const AVFormatContext *s);
> diff --git a/libavformat/options_table.h b/libavformat/options_table.h
> index 9d61d5a..50ea3c1 100644
> --- a/libavformat/options_table.h
> +++ b/libavformat/options_table.h
> @@ -105,6 +105,13 @@ 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, "forceparsing"},
> +{"none",        NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVSTREAM_PARSE_NONE       }, INT_MIN, INT_MAX, D, "forceparsing" },
> +{"full",        NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVSTREAM_PARSE_FULL       }, INT_MIN, INT_MAX, D, "forceparsing" },
> +{"headers",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVSTREAM_PARSE_HEADERS    }, INT_MIN, INT_MAX, D, "forceparsing" },
> +{"timestamps",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVSTREAM_PARSE_TIMESTAMPS }, INT_MIN, INT_MAX, D, "forceparsing" },
> +{"once",        NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVSTREAM_PARSE_FULL_ONCE  }, INT_MIN, INT_MAX, D, "forceparsing" },
> +{"raw",         NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVSTREAM_PARSE_FULL_RAW   }, INT_MIN, INT_MAX, D, "forceparsing" },
>  {NULL},
>  };
>
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 5664646..23e063f 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -4264,6 +4264,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.10.2
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
wm4 Nov. 10, 2016, 11:43 a.m. UTC | #2
On Sun,  6 Nov 2016 21:16:43 +0100
Michael Niedermayer <michael@niedermayer.cc> wrote:

> TODO: version bump, docs
> 
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/avformat.h      | 8 ++++++++
>  libavformat/options_table.h | 7 +++++++
>  libavformat/utils.c         | 3 +++
>  3 files changed, 18 insertions(+)
> 
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index f9f4d72..96e6b94 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -1899,6 +1899,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 9d61d5a..50ea3c1 100644
> --- a/libavformat/options_table.h
> +++ b/libavformat/options_table.h
> @@ -105,6 +105,13 @@ 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, "forceparsing"},
> +{"none",        NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVSTREAM_PARSE_NONE       }, INT_MIN, INT_MAX, D, "forceparsing" },
> +{"full",        NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVSTREAM_PARSE_FULL       }, INT_MIN, INT_MAX, D, "forceparsing" },
> +{"headers",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVSTREAM_PARSE_HEADERS    }, INT_MIN, INT_MAX, D, "forceparsing" },
> +{"timestamps",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVSTREAM_PARSE_TIMESTAMPS }, INT_MIN, INT_MAX, D, "forceparsing" },
> +{"once",        NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVSTREAM_PARSE_FULL_ONCE  }, INT_MIN, INT_MAX, D, "forceparsing" },
> +{"raw",         NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVSTREAM_PARSE_FULL_RAW   }, INT_MIN, INT_MAX, D, "forceparsing" },
>  {NULL},
>  };
>  
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 5664646..23e063f 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -4264,6 +4264,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;
>      }

Use case?
diff mbox

Patch

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index f9f4d72..96e6b94 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1899,6 +1899,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 9d61d5a..50ea3c1 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -105,6 +105,13 @@  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, "forceparsing"},
+{"none",        NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVSTREAM_PARSE_NONE       }, INT_MIN, INT_MAX, D, "forceparsing" },
+{"full",        NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVSTREAM_PARSE_FULL       }, INT_MIN, INT_MAX, D, "forceparsing" },
+{"headers",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVSTREAM_PARSE_HEADERS    }, INT_MIN, INT_MAX, D, "forceparsing" },
+{"timestamps",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVSTREAM_PARSE_TIMESTAMPS }, INT_MIN, INT_MAX, D, "forceparsing" },
+{"once",        NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVSTREAM_PARSE_FULL_ONCE  }, INT_MIN, INT_MAX, D, "forceparsing" },
+{"raw",         NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVSTREAM_PARSE_FULL_RAW   }, INT_MIN, INT_MAX, D, "forceparsing" },
 {NULL},
 };
 
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 5664646..23e063f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4264,6 +4264,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;
     }