From patchwork Thu Feb 16 18:29:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 2582 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp2613099vsb; Thu, 16 Feb 2017 10:37:33 -0800 (PST) X-Received: by 10.28.182.70 with SMTP id g67mr14048865wmf.131.1487270253222; Thu, 16 Feb 2017 10:37:33 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y63si1505623wme.103.2017.02.16.10.37.32; Thu, 16 Feb 2017 10:37:33 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@tmm1-net.20150623.gappssmtp.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C872B689A31; Thu, 16 Feb 2017 20:37:22 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5661668071F for ; Thu, 16 Feb 2017 20:37:16 +0200 (EET) Received: by mail-pf0-f193.google.com with SMTP id o64so2170039pfb.1 for ; Thu, 16 Feb 2017 10:37:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tmm1-net.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=q9XdfCfy+K+gOmp9cdGr/vfudJBxlgIzM5Qx1mICJHQ=; b=DFsyqkapTbhjgcuD8HlI7GGVGkXOxSFm+JtecnURMxjWtQZa2crphnaZHKyi6zVbkW 5/0q4j2KUGZcF3QNsZ6OcnRpO6JFkw5wiTcf8SlxzmRRv2o7sRUv5OHyETAFkqEZNZi0 532HyssKlO9xHgoogwMAuQuqQO7p+y6LYJk3mrcuR0xqkAhWZDW7Op00syhDw7zS4AvW EJApM6fnMeTM70iMYES15aENRcNtximQkp7VJzNSkJzJadjEd7BJvqfWx7TMkTKJOoNX aRVuczsXeJc1+91nMrM6Y8XY4BaDNuw4JUu7ooS2T/mR2cV8czNZXPOBixjF7JodbP3K Wprg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=q9XdfCfy+K+gOmp9cdGr/vfudJBxlgIzM5Qx1mICJHQ=; b=f/7N3Saa4tOJXzBvtheGeaWLsRTqeNun0zDHH171kCD/2CeBe4NKDxX810ymZLr6Y8 gS1rs0DtiVJbldYDjlsiElK3i5YNSVEClnTaS/3Kme+Pp1JoCipbdNB5b6syo+4SG6D0 ypAdtuGOSDaX+jKJ2T32Dzm/I2u1FZer6fzVyF+YY++LExvdu9WO74CgJs2HhbPHiq3z h8LLXCKXNbIyr7WEWf7nkBk2waD8LHJcTt6lwOl4v3W+woelBOIeqoBPVwW/fYTN193K 8NHdgtNUfy6xBhu6jbzDf/v03+EWM9pD08hd7cIhqzW9yrLeEOPmcWCVq4GiFMWgEqL7 +LrQ== X-Gm-Message-State: AMke39kCseDxvgPeOXSxjnFs0+MD2iYSBfCcMurYGUfUQpnM5lwoGjenV5iSDyMOcqQQ/Q== X-Received: by 10.84.179.165 with SMTP id b34mr5157834plc.147.1487270241125; Thu, 16 Feb 2017 10:37:21 -0800 (PST) Received: from tmm1-macbook.local.net (c-73-252-174-83.hsd1.ca.comcast.net. [73.252.174.83]) by smtp.gmail.com with ESMTPSA id h4sm14939227pfk.96.2017.02.16.10.37.20 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 16 Feb 2017 10:37:20 -0800 (PST) From: Aman Gupta To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Feb 2017 10:29:37 -0800 Message-Id: <20170216182938.55393-2-ffmpeg@tmm1.net> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20170216182938.55393-1-ffmpeg@tmm1.net> References: <20170216182938.55393-1-ffmpeg@tmm1.net> Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/videotoolbox: cosmetic change to simplify code with early return X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Aman Gupta MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Aman Gupta --- 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; } }