[FFmpeg-devel] [PATCH] examples/demuxing_decoding return value error

Stefano Sabatini stefasab at gmail.com
Thu Dec 12 23:38:39 CET 2013


On date Thursday 2013-12-12 16:12:13 +0000, Even Wiik Thomassen encoded:
> I've attached a trivial patch to fix a bug in the demuxing_decoding example.
> 
> Now the open_codec_context function will return -1 to signal an error if it
> fails to find a codec.
> 
> Before it would return the stream index, which was always >= 0. The two
> places where the function was called checked if the return value was < 0
> to check if there was an error, and would therefor not notice when a codec
> was not found.
> 
> This change make it fail faster, instead of repeated failed tries to decode
> frames with no codec.
> 
> 
> Please review,
> -- 
> Even Wiik Thomassen
> e.thomassen at sportradar.com

> From 12eec02e805625093f250ff5ebab9a773ec9b5cf Mon Sep 17 00:00:00 2001
> From: Even Wiik Thomassen <e.thomassen at sportradar.com>
> Date: Thu, 12 Dec 2013 16:51:28 +0100
> Subject: [PATCH] examples/demuxing_decoding: Return error when no codec found.
> 
> The open_codec_context function, when it fails to find a codec, now
> return -1 to signal an error.
> 
> Before it would return the stream index, which was always >= 0, and
> continue as if a codec was found. This change make it fail faster,
> instead of repeated failed tries to decode frames with no codec.
> 
> Signed-off-by: Even Wiik Thomassen <e.thomassen at sportradar.com>
> ---
>  doc/examples/demuxing_decoding.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/doc/examples/demuxing_decoding.c b/doc/examples/demuxing_decoding.c
> index 1b5a989..c7d6f67 100644
> --- a/doc/examples/demuxing_decoding.c
> +++ b/doc/examples/demuxing_decoding.c
> @@ -159,7 +159,7 @@ static int open_codec_context(int *stream_idx,

>          if (!dec) {
>              fprintf(stderr, "Failed to find %s codec\n",
>                      av_get_media_type_string(type));
> -            return ret;
> +            return -1;

It should be AVERROR_DECODER_NOT_FOUND (which I dislike, but there is
no point in complaining) or AVERROR(EINVAL). -1 usually is mapped to
ENOPERM.

Looks correct otherwise.
-- 
FFmpeg = Fanciful and Fascinating Moronic Peaceful Encoding/decoding Governor


More information about the ffmpeg-devel mailing list