[FFmpeg-devel] [PATCH] Move stream_options to avformat

wm4 nfxjfg at googlemail.com
Sun Jan 25 02:16:58 CET 2015


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.

(Sorry for the nagging.)


More information about the ffmpeg-devel mailing list