[FFmpeg-devel] [PATCH 2/3] avcodec/videotoolbox: cosmetic change to simplify code with early return

wm4 nfxjfg at googlemail.com
Fri Feb 17 08:01:08 EET 2017


On Thu, 16 Feb 2017 10:29:37 -0800
Aman Gupta <ffmpeg at tmm1.net> wrote:

> From: Aman Gupta <aman at tmm1.net>
> 
> ---
>  libavcodec/videotoolbox.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
> index 1288aa5..9be7bee 100644
> --- a/libavcodec/videotoolbox.c
> +++ b/libavcodec/videotoolbox.c
> @@ -590,15 +590,16 @@ static int videotoolbox_default_init(AVCodecContext *avctx)
>  static void videotoolbox_default_free(AVCodecContext *avctx)
>  {
>      AVVideotoolboxContext *videotoolbox = avctx->hwaccel_context;
> +    if (!videotoolbox)
> +        return;
>  
> -    if (videotoolbox) {
> -        if (videotoolbox->cm_fmt_desc)
> -            CFRelease(videotoolbox->cm_fmt_desc);
> +    if (videotoolbox->cm_fmt_desc)
> +        CFRelease(videotoolbox->cm_fmt_desc);
>  
> -        if (videotoolbox->session) {
> -            VTDecompressionSessionInvalidate(videotoolbox->session);
> -            CFRelease(videotoolbox->session);
> -        }
> +    if (videotoolbox->session) {
> +        VTDecompressionSessionInvalidate(videotoolbox->session);
> +        CFRelease(videotoolbox->session);
> +        videotoolbox->session = NULL;
>      }
>  }
>  

LGTM


More information about the ffmpeg-devel mailing list