[FFmpeg-devel] [PATCH] examples/decoding_encoding: make operation logic more self-evident / predictable

Clément Bœsch ubitux at gmail.com
Sat Aug 25 17:37:58 CEST 2012


On Fri, Aug 24, 2012 at 05:18:34PM +0200, Stefano Sabatini wrote:
> Add a switch which control which operation to perform.  Useful to testing
> only a single feature. Also the new behavior is globally more
> self-consistent.
> ---
>  doc/examples/decoding_encoding.c |   30 +++++++++++++++++++-----------
>  1 files changed, 19 insertions(+), 11 deletions(-)
> 
> diff --git a/doc/examples/decoding_encoding.c b/doc/examples/decoding_encoding.c
> index 309342f..fb3854a 100644
> --- a/doc/examples/decoding_encoding.c
> +++ b/doc/examples/decoding_encoding.c
> @@ -600,24 +600,32 @@ static void video_decode_example(const char *outfilename, const char *filename)
>  
>  int main(int argc, char **argv)
>  {
> -    const char *filename;
> -
> +    const char *output_type;
>      /* register all the codecs */
>      avcodec_register_all();
>  
> -    if (argc <= 1) {
> -        audio_encode_example("test.mp2");
> -        audio_decode_example("test.sw", "test.mp2");
> +    if (argc < 2) {
> +        printf("usage: %s output_type\n"
> +               "API example program to decode/encode a media stream with libavcodec.\n"
> +               "output_type must be choosen between 'mpg', 'mp2', 'h264'\n",

nit: maybe keep a consistent order with...

> +               argv[0]);
> +        return 1;
> +    }
> +    output_type = argv[1];
>  
> -        video_encode_example("test.h264", AV_CODEC_ID_H264);
> +    if (!strcmp(output_type, "mpg")) {
>          video_encode_example("test.mpg", AV_CODEC_ID_MPEG1VIDEO);
> -        filename = "test.mpg";
> +        video_decode_example("test%02d.pgm", "test.mpg");
> +    } else if (!strcmp(output_type, "h264")) {
> +        video_encode_example("test.h264", AV_CODEC_ID_H264);
> +    } else if (!strcmp(output_type, "mp2")) {
> +        audio_encode_example("test.mp2");
> +        audio_decode_example("test.sw", "test.mp2");
>      } else {
> -        filename = argv[1];
> +        fprintf(stderr, "Invalid output type '%s', choose between 'mpg', 'h264' or 'mp2'\n",

... this list?

Looks OK to me, thanks for working on the examples.

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120825/f1ff8c79/attachment.asc>


More information about the ffmpeg-devel mailing list