diff mbox

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

Message ID 20160905091421.20451-1-michael@niedermayer.cc
State Superseded
Headers show

Commit Message

Michael Niedermayer Sept. 5, 2016, 9:14 a.m. UTC
TODO: version bump, docs

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

Comments

Ronald S. Bultje Sept. 5, 2016, 9:25 a.m. UTC | #1
Hi,

On Sep 5, 2016 11:18 AM, "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 | 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},
>  };

Why int?

At vdd, we discussed parsers, maybe we should sync on that because I
believe it makes this unnecessary.

Ronald
Michael Niedermayer Sept. 5, 2016, 10:04 a.m. UTC | #2
On Mon, Sep 05, 2016 at 05:25:14AM -0400, Ronald S. Bultje wrote:
> Hi,
> 
> On Sep 5, 2016 11:18 AM, "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 | 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},
> >  };
> 
> Why int?

what else ?
a flag doesnt work as AVStreamParseType has more than 1 value


> 
> At vdd, we discussed parsers, maybe we should sync on that because I
> believe it makes this unnecessary.

not sure i understand what you suggest ?

[...]
Ronald S. Bultje Sept. 5, 2016, 10:17 a.m. UTC | #3
Hi,

On Sep 5, 2016 12:05 PM, "Michael Niedermayer" <michael@niedermayer.cc>
wrote:
>
> On Mon, Sep 05, 2016 at 05:25:14AM -0400, Ronald S. Bultje wrote:
> > Hi,
> >
> > On Sep 5, 2016 11:18 AM, "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 | 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},
> > >  };
> >
> > Why int?
>
> what else ?
> a flag doesnt work as AVStreamParseType has more than 1 value

An enum would be nice.

> > At vdd, we discussed parsers, maybe we should sync on that because I
> > believe it makes this unnecessary.
>
> not sure i understand what you suggest ?

Anton expressed interest in merging parsers and bitstream filters. I
believe they are (other than semantically) identical in goal, and the
semantic difference is sometimes violated already. If you think of them as
bitstream filters, we could merge their functionality with auto-insertion
of BSF. It was proposed that we could go one step further and do parsing
not in the demuxer step (av_read_frame), but before the decoder (which is a
change) and in the muxer (which we already do). Auto-insertion mechanisms
would be shared and this would lead to interesting new features that
someone demuxing a mpeg system stream or vp9/divx-with-packed-b-frames
using external tools (which don't split/reframe) but using avcodec decoders
would still see it work. On the other hand, people using lavf to demux such
streams would not need to merge (divx/vp9) before muxing, making that
process more efficient (using lavf) or less buggy (using non-lavf muxers).

(Some people also proposed that maybe reframing - like in mpeg elementary
streams - and splitting/merging - like in packed-divx or vp9 - are perhaps
different enough that they should happen in different places, although I
believe majority agreed it could stay in the same place.)

If you follow this, forceparsing wouldn't be necessary and you could use
existing bitstream CLI options and API to achieve (on the input side) what
parsers do right now.

Ronald
Michael Niedermayer Sept. 5, 2016, 10:49 a.m. UTC | #4
On Mon, Sep 05, 2016 at 06:17:02AM -0400, Ronald S. Bultje wrote:
> Hi,
> 
> On Sep 5, 2016 12:05 PM, "Michael Niedermayer" <michael@niedermayer.cc>
> wrote:
> >
> > On Mon, Sep 05, 2016 at 05:25:14AM -0400, Ronald S. Bultje wrote:
> > > Hi,
> > >
> > > On Sep 5, 2016 11:18 AM, "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 | 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},
> > > >  };
> > >
> > > Why int?
> >
> > what else ?
> > a flag doesnt work as AVStreamParseType has more than 1 value
> 
> An enum would be nice.

enums are not guranteed to be stored in a specific data type
2 enums could be stored in different data types, one could be int16
one uint32 one int64
that makes using enums with AVOption difficult. (which is why i
used an int)


> 
> > > At vdd, we discussed parsers, maybe we should sync on that because I
> > > believe it makes this unnecessary.
> >
> > not sure i understand what you suggest ?
> 
> Anton expressed interest in merging parsers and bitstream filters. I
> believe they are (other than semantically) identical in goal, and the
> semantic difference is sometimes violated already. If you think of them as
> bitstream filters, we could merge their functionality with auto-insertion
> of BSF. It was proposed that we could go one step further and do parsing
> not in the demuxer step (av_read_frame), but before the decoder (which is a
> change) and in the muxer (which we already do). Auto-insertion mechanisms
> would be shared and this would lead to interesting new features that
> someone demuxing a mpeg system stream or vp9/divx-with-packed-b-frames
> using external tools (which don't split/reframe) but using avcodec decoders
> would still see it work. On the other hand, people using lavf to demux such
> streams would not need to merge (divx/vp9) before muxing, making that
> process more efficient (using lavf) or less buggy (using non-lavf muxers).

Parsers extract all kinds on information like keyframe flags, frame
types and reorder timestamps and so on.
bitstream filters did at least previously not do anything like that

so they are a bit different. But if someone wants to implement or
merge this iam sure happy and this patch can be dropped.

Though that redesign suggested is probably orders of magnitude more
work than the simple patch i wrote here.
Has it been considered if all the advantages and disadvantages
of the old design vs. the new one (+bugfixing and potential merge bugs)
make it worth the work ?

[...]
Paul B Mahol Sept. 5, 2016, 10:52 a.m. UTC | #5
On 9/5/16, Ronald S. Bultje <rsbultje@gmail.com> wrote:
> Hi,
>
> On Sep 5, 2016 12:05 PM, "Michael Niedermayer" <michael@niedermayer.cc>
> wrote:
>>
>> On Mon, Sep 05, 2016 at 05:25:14AM -0400, Ronald S. Bultje wrote:
>> > Hi,
>> >
>> > On Sep 5, 2016 11:18 AM, "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 | 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},
>> > >  };
>> >
>> > Why int?
>>
>> what else ?
>> a flag doesnt work as AVStreamParseType has more than 1 value
>
> An enum would be nice.
>
>> > At vdd, we discussed parsers, maybe we should sync on that because I
>> > believe it makes this unnecessary.
>>
>> not sure i understand what you suggest ?
>
> Anton expressed interest in merging parsers and bitstream filters. I
> believe they are (other than semantically) identical in goal, and the
> semantic difference is sometimes violated already. If you think of them as
> bitstream filters, we could merge their functionality with auto-insertion
> of BSF. It was proposed that we could go one step further and do parsing
> not in the demuxer step (av_read_frame), but before the decoder (which is a
> change) and in the muxer (which we already do). Auto-insertion mechanisms
> would be shared and this would lead to interesting new features that
> someone demuxing a mpeg system stream or vp9/divx-with-packed-b-frames
> using external tools (which don't split/reframe) but using avcodec decoders
> would still see it work. On the other hand, people using lavf to demux such
> streams would not need to merge (divx/vp9) before muxing, making that
> process more efficient (using lavf) or less buggy (using non-lavf muxers).

Are you telling that using non-lavf muxers is less buggy?
Hendrik Leppkes Sept. 5, 2016, 11:08 a.m. UTC | #6
On Mon, Sep 5, 2016 at 12:17 PM, Ronald S. Bultje <rsbultje@gmail.com> wrote:
> It was proposed that we could go one step further and do parsing
> not in the demuxer step (av_read_frame)

Personally, I use avformat demuxing with a bunch of other decoders
which might still need the parser to run first to re-package frames on
proper boundaries, so having the decoders do that instead of the
demuxers sounds like the wrong approach to me.
A demuxer should ideally output fully re-constructed packages, and not
a raw bitstream that still needs re-construction before decoding, at
least IMHO.

- Hendrik
Ronald S. Bultje Sept. 6, 2016, 12:02 a.m. UTC | #7
Hi,

On Mon, Sep 5, 2016 at 6:49 AM, Michael Niedermayer <michael@niedermayer.cc>
wrote:

> On Mon, Sep 05, 2016 at 06:17:02AM -0400, Ronald S. Bultje wrote:
> > Hi,
> >
> > On Sep 5, 2016 12:05 PM, "Michael Niedermayer" <michael@niedermayer.cc>
> > wrote:
> > >
> > > On Mon, Sep 05, 2016 at 05:25:14AM -0400, Ronald S. Bultje wrote:
> > > > Hi,
> > > >
> > > > On Sep 5, 2016 11:18 AM, "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 | 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},
> > > > >  };
> > > >
> > > > Why int?
> > >
> > > what else ?
> > > a flag doesnt work as AVStreamParseType has more than 1 value
> >
> > An enum would be nice.
>
> enums are not guranteed to be stored in a specific data type
> 2 enums could be stored in different data types, one could be int16
> one uint32 one int64
> that makes using enums with AVOption difficult. (which is why i
> used an int)


Named options, or whatever you want to call it.

AVOptions supports it, please use it.

Ronald
Ronald S. Bultje Sept. 6, 2016, 12:03 a.m. UTC | #8
Hi,

On Mon, Sep 5, 2016 at 7:08 AM, Hendrik Leppkes <h.leppkes@gmail.com> wrote:

> On Mon, Sep 5, 2016 at 12:17 PM, Ronald S. Bultje <rsbultje@gmail.com>
> wrote:
> > It was proposed that we could go one step further and do parsing
> > not in the demuxer step (av_read_frame)
>
> Personally, I use avformat demuxing with a bunch of other decoders
> which might still need the parser to run first to re-package frames on
> proper boundaries, so having the decoders do that instead of the
> demuxers sounds like the wrong approach to me.
> A demuxer should ideally output fully re-constructed packages, and not
> a raw bitstream that still needs re-construction before decoding, at
> least IMHO.


It's a good point, we should support both external-demuxer-lavc-decoder as
well as lavf-demuxer-external-decoder. That wasn't addressed in the current
proposal.

Ronald
Ronald S. Bultje Sept. 6, 2016, 12:03 a.m. UTC | #9
Hi,

On Mon, Sep 5, 2016 at 6:52 AM, Paul B Mahol <onemda@gmail.com> wrote:

> On 9/5/16, Ronald S. Bultje <rsbultje@gmail.com> wrote:
> > Hi,
> >
> > On Sep 5, 2016 12:05 PM, "Michael Niedermayer" <michael@niedermayer.cc>
> > wrote:
> >>
> >> On Mon, Sep 05, 2016 at 05:25:14AM -0400, Ronald S. Bultje wrote:
> >> > Hi,
> >> >
> >> > On Sep 5, 2016 11:18 AM, "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 | 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},
> >> > >  };
> >> >
> >> > Why int?
> >>
> >> what else ?
> >> a flag doesnt work as AVStreamParseType has more than 1 value
> >
> > An enum would be nice.
> >
> >> > At vdd, we discussed parsers, maybe we should sync on that because I
> >> > believe it makes this unnecessary.
> >>
> >> not sure i understand what you suggest ?
> >
> > Anton expressed interest in merging parsers and bitstream filters. I
> > believe they are (other than semantically) identical in goal, and the
> > semantic difference is sometimes violated already. If you think of them
> as
> > bitstream filters, we could merge their functionality with auto-insertion
> > of BSF. It was proposed that we could go one step further and do parsing
> > not in the demuxer step (av_read_frame), but before the decoder (which
> is a
> > change) and in the muxer (which we already do). Auto-insertion mechanisms
> > would be shared and this would lead to interesting new features that
> > someone demuxing a mpeg system stream or vp9/divx-with-packed-b-frames
> > using external tools (which don't split/reframe) but using avcodec
> decoders
> > would still see it work. On the other hand, people using lavf to demux
> such
> > streams would not need to merge (divx/vp9) before muxing, making that
> > process more efficient (using lavf) or less buggy (using non-lavf
> muxers).
>
> Are you telling that using non-lavf muxers is less buggy?


No.

Just that people are using it like that (sometimes).

Ronald
diff mbox

Patch

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;
     }