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

Michael Niedermayer michaelni at gmx.at
Mon Sep 10 18:28:23 CEST 2012


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 ?
I think it should support all
AVInputFormat.codec_tag and AVOutputFormat.codec_tag

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120910/dbe6da41/attachment.asc>


More information about the ffmpeg-devel mailing list