[FFmpeg-devel] [PATCH] Move stream_options to avformat
Michael Niedermayer
michaelni at gmx.at
Sun Jan 25 02:28:01 CET 2015
On Sun, Jan 25, 2015 at 02:16:58AM +0100, wm4 wrote:
> On Sun, 25 Jan 2015 01:56:30 +0100
> Michael Niedermayer <michaelni at gmx.at> wrote:
>
> > TODO: APIChanges/version bump
> >
> > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > ---
> > ffmpeg.c | 30 ++++--------------------------
> > libavformat/avformat.h | 6 ++++++
> > libavformat/options.c | 30 ++++++++++++++++++++++++++++++
> > 3 files changed, 40 insertions(+), 26 deletions(-)
> >
> > diff --git a/ffmpeg.c b/ffmpeg.c
> > index b836448..af576c7 100644
> > --- a/ffmpeg.c
> > +++ b/ffmpeg.c
> > @@ -2970,32 +2970,10 @@ static int transcode_init(void)
> > }
> >
> > if (ost->disposition) {
> > - static const AVOption opts[] = {
> > - { "disposition" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit = "flags" },
> > - { "default" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEFAULT }, .unit = "flags" },
> > - { "dub" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DUB }, .unit = "flags" },
> > - { "original" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_ORIGINAL }, .unit = "flags" },
> > - { "comment" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_COMMENT }, .unit = "flags" },
> > - { "lyrics" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_LYRICS }, .unit = "flags" },
> > - { "karaoke" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_KARAOKE }, .unit = "flags" },
> > - { "forced" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_FORCED }, .unit = "flags" },
> > - { "hearing_impaired" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_HEARING_IMPAIRED }, .unit = "flags" },
> > - { "visual_impaired" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_VISUAL_IMPAIRED }, .unit = "flags" },
> > - { "clean_effects" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CLEAN_EFFECTS }, .unit = "flags" },
> > - { "captions" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CAPTIONS }, .unit = "flags" },
> > - { "descriptions" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DESCRIPTIONS }, .unit = "flags" },
> > - { "metadata" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, .unit = "flags" },
> > - { NULL },
> > - };
> > - static const AVClass class = {
> > - .class_name = "",
> > - .item_name = av_default_item_name,
> > - .option = opts,
> > - .version = LIBAVUTIL_VERSION_INT,
> > - };
> > - const AVClass *pclass = &class;
> > -
> > - ret = av_opt_eval_flags(&pclass, &opts[0], ost->disposition, &ost->st->disposition);
> > + const AVClass *pclass = avstream_get_class();
> > + const AVOption *o = av_opt_find(&pclass, "disposition", NULL, 0, 0);
> > +
> > + ret = av_opt_eval_flags(&pclass, o, ost->disposition, &ost->st->disposition);
> > if (ret < 0)
> > goto dump_format;
> > }
> > diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> > index db72c18..e6cd301 100644
> > --- a/libavformat/avformat.h
> > +++ b/libavformat/avformat.h
> > @@ -1895,6 +1895,12 @@ void avformat_free_context(AVFormatContext *s);
> > const AVClass *avformat_get_class(void);
> >
> > /**
> > + * Get the AVClass for AVStream. It can be used in combination with
> > + * AV_OPT_SEARCH_FAKE_OBJ for examining options.
> > + */
> > +const AVClass *avstream_get_class(void);
> > +
> > +/**
> > * Add a new stream to a media file.
> > *
> > * When demuxing, it is called by the demuxer in read_header(). If the
> > diff --git a/libavformat/options.c b/libavformat/options.c
> > index 5044043..d10226d 100644
> > --- a/libavformat/options.c
> > +++ b/libavformat/options.c
> > @@ -130,3 +130,33 @@ const AVClass *avformat_get_class(void)
> > {
> > return &av_format_context_class;
> > }
> > +
> > +static const AVOption stream_options[] = {
> > + { "disposition" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit = "flags" },
> > + { "default" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEFAULT }, .unit = "flags" },
> > + { "dub" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DUB }, .unit = "flags" },
> > + { "original" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_ORIGINAL }, .unit = "flags" },
> > + { "comment" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_COMMENT }, .unit = "flags" },
> > + { "lyrics" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_LYRICS }, .unit = "flags" },
> > + { "karaoke" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_KARAOKE }, .unit = "flags" },
> > + { "forced" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_FORCED }, .unit = "flags" },
> > + { "hearing_impaired" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_HEARING_IMPAIRED }, .unit = "flags" },
> > + { "visual_impaired" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_VISUAL_IMPAIRED }, .unit = "flags" },
> > + { "clean_effects" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CLEAN_EFFECTS }, .unit = "flags" },
> > + { "captions" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CAPTIONS }, .unit = "flags" },
> > + { "descriptions" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DESCRIPTIONS }, .unit = "flags" },
> > + { "metadata" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, .unit = "flags" },
> > + { NULL },
> > +};
> > +
> > +static const AVClass av_stream_class = {
> > + .class_name = "AVStream",
> > + .item_name = av_default_item_name,
> > + .option = stream_options,
> > + .version = LIBAVUTIL_VERSION_INT,
> > +};
> > +
> > +const AVClass *avstream_get_class(void)
> > +{
> > + return &av_stream_class;
> > +}
> > \ No newline at end of file
>
> As an experienced API user, I don't have the slightest clue what I'd do
> with this API, or where to find information about it.
the primary goal is to remove duplicated disposition type tables,
which needs one of the tables to be public first
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150125/80ba7d40/attachment.asc>
More information about the ffmpeg-devel
mailing list