[FFmpeg-devel] [PATCH] lavf/riff: add riff-test program

Stefano Sabatini stefasab at gmail.com
Fri Sep 14 14:55:28 CEST 2012


On date Monday 2012-09-10 18:28:23 +0200, Michael Niedermayer encoded:
> On Fri, Sep 07, 2012 at 12:18:37AM +0200, Stefano Sabatini wrote:
> > This test program is very simialar to libavcodec/raw-test, and is useful
> > to test the mapping between codec fourccs and codec IDs.
> > ---
> >  libavformat/Makefile |    2 +-
> >  libavformat/riff.c   |   94 ++++++++++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 95 insertions(+), 1 deletions(-)
> 
> does this qualify as "test" program ?
> i mean it doesnt test anything ...
> not sure where that would make it belong, maybe tools maybe ffmpeg ...
> 
> 
> > 
> > diff --git a/libavformat/Makefile b/libavformat/Makefile
> > index 72f9c22..681f507 100644
> > --- a/libavformat/Makefile
> > +++ b/libavformat/Makefile
> > @@ -405,7 +405,7 @@ OBJS-$(CONFIG_UDP_PROTOCOL)              += udp.o
> >  
> >  SKIPHEADERS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh.h
> >  SKIPHEADERS-$(CONFIG_NETWORK)            += network.h rtsp.h
> > -TESTPROGS = seek
> > +TESTPROGS = riff seek
> >  
> >  TOOLS     = aviocat                                                     \
> >              ismindex                                                    \
> > diff --git a/libavformat/riff.c b/libavformat/riff.c
> > index 9ff2148..3400041 100644
> > --- a/libavformat/riff.c
> > +++ b/libavformat/riff.c
> > @@ -794,3 +794,97 @@ int ff_read_riff_info(AVFormatContext *s, int64_t size)
> >  
> >      return 0;
> >  }
> > +
> > +#ifdef TEST
> > +
> > +#include <unistd.h>             /* getopt */
> > +#include "libavutil/pixdesc.h"
> > +
> > +#undef printf
> > +#undef fprintf
> > +
> > +static void usage(void)
> > +{
> > +    printf("\n"
> > +           "Options:\n"
> > +           "-c CODEC_NAME     given a codec name, print the list of associated fourccs (one per line)\n"
> > +           "-l                list the codec name for each fourcc\n"
> > +           "-L                list the fourccs for each codec\n"
> > +           "-h                print this help\n");
> > +}
> > +
> > +static void print_codec_fourccs(enum AVCodecID codec_id, char sep)
> > +{
> > +    int i;
> > +
> > +    for (i = 0; i < FF_ARRAY_ELEMS(ff_codec_bmp_tags); i++) {
> > +        if (ff_codec_bmp_tags[i].id == codec_id) {
> > +            char buf[32];
> > +            av_get_codec_tag_string(buf, sizeof(buf), ff_codec_bmp_tags[i].tag);
> > +            printf("%s%c", buf, sep);
> > +        }
> > +    }
> > +}
> > +
> > +int main(int argc, char **argv)
> > +{
> > +    int i, list_fourcc_codec = 0, list_codec_fourccs = 0;
> > +    const char *codec_name = NULL;
> > +    char c;
> > +
> > +    if (argc == 1) {
> > +        usage();
> > +        return 0;
> > +    }
> > +
> > +    while ((c = getopt(argc, argv, "c:hlL")) != -1) {
> > +        switch (c) {
> > +        case 'h':
> > +            usage();
> > +            return 0;
> > +        case 'l':
> > +            list_fourcc_codec = 1;
> > +            break;
> > +        case 'L':
> > +            list_codec_fourccs = 1;
> > +            break;
> > +        case 'c':
> > +            codec_name = optarg;
> > +            break;
> > +        case '?':
> > +            usage();
> > +            return 1;
> > +        }
> > +    }
> > +
> > +    if (list_fourcc_codec) {
> > +        for (i = 0; i < FF_ARRAY_ELEMS(ff_codec_bmp_tags); i++) {
> > +            char buf[32];
> > +            av_get_codec_tag_string(buf, sizeof(buf), ff_codec_bmp_tags[i].tag);
> > +            if (ff_codec_bmp_tags[i].id != AV_CODEC_ID_NONE)
> > +                printf("%s: %s\n", buf, avcodec_get_name(ff_codec_bmp_tags[i].id));
> > +        }
> > +    }
> 

> why just ff_codec_bmp_tags ?

Good point.

> I think it should support all
> AVInputFormat.codec_tag and AVOutputFormat.codec_tag

Possible solutions:
- a tool which write the list for each format
- extend ffprobe to accept an option -show_formats which show such info for each format
- extend ff* -formats, but the output would result definitively non-parsable

And BTW we may consider to add a sort of AVFormatDescriptor, so that
we don't have to duplicate information between AVInput/OutputFormat.
-- 
FFmpeg = Forgiving Fabulous Martial Patchable Eretic Guru


More information about the ffmpeg-devel mailing list