[FFmpeg-devel] [PATCH 2/8] avcodec/decode: Return early upon failure

James Almer jamrial at gmail.com
Thu Mar 4 19:15:02 EET 2021


On 3/4/2021 12:42 PM, Andreas Rheinhardt wrote:
> Allows to remove one level of indentation.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
>   libavcodec/decode.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 5e5d0c7066..db6ee9cb04 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -1043,9 +1043,9 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
>           AVPacket pkt_recoded = *avpkt;
>   
>           ret = recode_subtitle(avctx, &pkt_recoded, avpkt);
> -        if (ret < 0) {
> -            *got_sub_ptr = 0;
> -        } else {
> +        if (ret < 0)
> +            return ret;
> +
>                ret = extract_packet_props(avctx->internal, &pkt_recoded);
>                if (ret < 0)
>                   return ret;
> @@ -1099,7 +1099,6 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
>   
>                   av_packet_unref(&pkt_recoded);
>               }
> -        }
>   
>           if (*got_sub_ptr)
>               avctx->frame_number++;

LGTM.


More information about the ffmpeg-devel mailing list