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

Stefano Sabatini stefasab at gmail.com
Fri Dec 13 09:47:10 CET 2013


On date Friday 2013-12-13 08:32:53 +0000, Even Wiik Thomassen encoded:
> >> 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.
> >
> > 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.
> 
> I've attached an updated patch that uses AVERROR(EINVAL), as that seemed
> more consistent with the rest of the file, and tested it.
> 
> Regards,
> -- 
> Even Wiik Thomassen

> From b704dc4318b478c9a515a665993e61315d26b1a0 Mon Sep 17 00:00:00 2001
> From: Even Wiik Thomassen <e.thomassen at sportradar.com>
> Date: Fri, 13 Dec 2013 09:24:18 +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 AVERROR(EINVAL) 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..bd034cc 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 AVERROR(EINVAL);
>          }

Applied, thanks.
-- 
FFmpeg = Fundamentalist Frightening Merciless Powered Energized Genius


More information about the ffmpeg-devel mailing list