[FFmpeg-devel] [PATCH] Implement a cmdutils functions for listing available elements

Stefano Sabatini stefano.sabatini-lala
Sun Oct 25 22:33:14 CET 2009


On date Sunday 2009-10-25 20:35:24 +0100, Michael Niedermayer encoded:
> On Sun, Oct 25, 2009 at 06:53:52PM +0100, Stefano Sabatini wrote:
[...]
> > Index: cmdutils.h
> > ===================================================================
> > --- cmdutils.h	(revision 20371)
> > +++ cmdutils.h	(working copy)
> > @@ -56,6 +56,12 @@
> >  int opt_loglevel(const char *opt, const char *arg);
> >  
> >  /**
> > + * Lists available formats, codecs, protocols and other elements
> > + * integrated into the current build.
> > + */
> > +int opt_list(const char *opt, const char *arg);
> 
> this doxy is not enough to use this function, one has to read the code
> thats not ideal

Updated (I prefer not to write the actual values supported, this may lead
to code/doc desynch).

> > +/**
> >   * Parses a string and returns its corresponding value as a double.
> >   * Exits from the application if the string cannot be correctly
> >   * parsed or the corresponding value is invalid.
> > Index: cmdutils.c
> > ===================================================================
> > --- cmdutils.c	(revision 20371)
> > +++ cmdutils.c	(working copy)
> > @@ -35,6 +35,7 @@
> >  #include "libswscale/swscale.h"
> >  #include "libpostproc/postprocess.h"
> >  #include "libavutil/avstring.h"
> > +#include "libavcodec/audioconvert.h"
> >  #include "libavcodec/opt.h"
> >  #include "cmdutils.h"
> >  #include "version.h"
> > @@ -256,6 +257,139 @@
> >      return 0;
> >  }
> >  
> > +static void list_fmts(void (*get_fmt_string)(char *buf, int buf_size, int fmt), int nb_fmts)
> > +{
> > +    int i;
> > +    char fmt_str[128];
> > +    for (i = -1; i < nb_fmts; i++) {
> > +        get_fmt_string (fmt_str, sizeof(fmt_str), i);
> > +        fprintf(stdout, "%s\n", fmt_str);
> > +    }
> > +}
> > +
> 
> > +int opt_list(const char *opt, const char *arg)
> 
> opt is unused and isnt documented either ...

opt was used and now is documented.

> > +{
> > +    if (!strcmp(arg, "formats")) {
> > +        AVInputFormat  *ifmt = NULL;
> > +        AVOutputFormat *ofmt = NULL;
> > +        const char *last_name = "000";
> > +
> 
> > +        fprintf(stderr,
> > +            "D. = Demuxing supported\n"
> > +            ".E = Muxing supported\n"
> > +            "--\n");
> 
> i wonder if av_log() would be better, i cant think of any real advantage
> for ff* but maybe one day this function could be used by an application
> for which fprintf(stderr) is inconvenient

Yes using av_log() is a fine idea.
 
> [...]
> 
> > +            printf(
> 
> iam sure mixing stderr & stdout like that is not a good idea

Please check again, I'm using now av_log(NULL, AV_LOG_INFO, ...) for
the headers / explanations, and printf() for the actual listing,
I believe that's the expected behavior, as the user wants to
read/grep/filter from stdout.

Regards.
-- 
FFmpeg = Frenzy and Fundamentalist Multimedia Picky Evanescent God
-------------- next part --------------
A non-text attachment was scrubbed...
Name: implement-opt-list.patch
Type: text/x-diff
Size: 6092 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091025/e80e85ca/attachment.patch>



More information about the ffmpeg-devel mailing list