[FFmpeg-devel] [PATCH] add show_demuxers and show_muxers

Michael Niedermayer michael at niedermayer.cc
Fri Nov 4 13:36:07 EET 2016


On Fri, Nov 04, 2016 at 03:17:23PM +0800, Steven Liu wrote:
> add -muxers and -demuxers parameters to list the dexmuers and muxers
> 
> Signed-off-by: Steven Liu <lingjiujianke at gmail.com>
> ---
>  cmdutils.c             | 60 +++++++++++++++++++++++++++++++-------------------
>  cmdutils.h             | 14 ++++++++++++
>  cmdutils_common_opts.h |  2 ++
>  3 files changed, 53 insertions(+), 23 deletions(-)
> 
> diff --git a/cmdutils.c b/cmdutils.c
> index 469c2d5..63a46f3 100644
> --- a/cmdutils.c
> +++ b/cmdutils.c
> @@ -1251,7 +1251,7 @@ static int is_device(const AVClass *avclass)
>      return AV_IS_INPUT_DEVICE(avclass->category) || AV_IS_OUTPUT_DEVICE(avclass->category);
>  }
>  
> -static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only)
> +static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only, int muxdemuxers)
>  {
>      AVInputFormat *ifmt  = NULL;
>      AVOutputFormat *ofmt = NULL;
> @@ -1269,29 +1269,33 @@ static int show_formats_devices(void *optctx, const char *opt, const char *arg,
>          const char *name      = NULL;
>          const char *long_name = NULL;
>  
> -        while ((ofmt = av_oformat_next(ofmt))) {
> -            is_dev = is_device(ofmt->priv_class);
> -            if (!is_dev && device_only)
> -                continue;
> -            if ((!name || strcmp(ofmt->name, name) < 0) &&
> -                strcmp(ofmt->name, last_name) > 0) {
> -                name      = ofmt->name;
> -                long_name = ofmt->long_name;
> -                encode    = 1;
> +        if (muxdemuxers != 2) {
> +            while ((ofmt = av_oformat_next(ofmt))) {
> +                is_dev = is_device(ofmt->priv_class);
> +                if (!is_dev && device_only)
> +                    continue;
> +                if ((!name || strcmp(ofmt->name, name) < 0) &&
> +                    strcmp(ofmt->name, last_name) > 0) {
> +                    name      = ofmt->name;
> +                    long_name = ofmt->long_name;
> +                    encode    = 1;
> +                }
>              }
>          }
> -        while ((ifmt = av_iformat_next(ifmt))) {
> -            is_dev = is_device(ifmt->priv_class);
> -            if (!is_dev && device_only)
> -                continue;
> -            if ((!name || strcmp(ifmt->name, name) < 0) &&
> -                strcmp(ifmt->name, last_name) > 0) {
> -                name      = ifmt->name;
> -                long_name = ifmt->long_name;
> -                encode    = 0;
> +        if (muxdemuxers != 1) {
> +            while ((ifmt = av_iformat_next(ifmt))) {
> +                is_dev = is_device(ifmt->priv_class);
> +                if (!is_dev && device_only)
> +                    continue;
> +                if ((!name || strcmp(ifmt->name, name) < 0) &&
> +                    strcmp(ifmt->name, last_name) > 0) {
> +                    name      = ifmt->name;
> +                    long_name = ifmt->long_name;
> +                    encode    = 0;
> +                }
> +                if (name && strcmp(ifmt->name, name) == 0)
> +                    decode = 1;
>              }
> -            if (name && strcmp(ifmt->name, name) == 0)
> -                decode = 1;
>          }
>          if (!name)
>              break;
> @@ -1308,12 +1312,22 @@ static int show_formats_devices(void *optctx, const char *opt, const char *arg,
>  
>  int show_formats(void *optctx, const char *opt, const char *arg)
>  {
> -    return show_formats_devices(optctx, opt, arg, 0);
> +    return show_formats_devices(optctx, opt, arg, 0, 0);
> +}
> +
> +int show_muxers(void *optctx, const char *opt, const char *arg)
> +{
> +    return show_formats_devices(optctx, opt, arg, 0, 1);
> +}
> +
> +int show_demuxers(void *optctx, const char *opt, const char *arg)
> +{
> +    return show_formats_devices(optctx, opt, arg, 0, 2);
                                                        ^
please use named constants, #define or enum, not just litteral numbers
like 2

it may be confusing to some readers what they mean

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Avoid a single point of failure, be that a person or equipment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20161104/0c87a82d/attachment.sig>


More information about the ffmpeg-devel mailing list