From patchwork Thu Apr 30 12:59:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 19398 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 1ABB444419E for ; Thu, 30 Apr 2020 15:59:37 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 03B0C68C73D; Thu, 30 Apr 2020 15:59:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 11C9568C733 for ; Thu, 30 Apr 2020 15:59:29 +0300 (EEST) Received: by mail-pj1-f68.google.com with SMTP id a31so666383pje.1 for ; Thu, 30 Apr 2020 05:59:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=G4bhzG6Uz1kT1HHStCiLMcrdEJ22+CNEF6X2RN3iI7U=; b=cctTJGKAluMUR22YcfxtO56cBna2R1XsTUXNk3stTvuptwyTHvYo6gyM6FSU6que0F MpYNhnwGZ2Kv4A2DQWi8w37HzLsypD86ibtU7UrN4/9a1jfWDcGkQRe0jXlMnu/UdkRN lSw7yMdOu6QJAr0Klvmgg5K2+HKu104qs+d3Rk8qYi2kFjWhtKkK/t4eh6ZXIq3I5MqU HgJ+i59GzgGQSNfp0tjYyNwZ41I5BnTkjuBtrDamUZI2sWvTB8ImTohudJt1Izv+sQX1 W1mka8uO6ihbuSAGIuiQK15GIGP+1CQM6jJI919e0B2lwNfAIi7reGXTOOVShk2Y9NdQ 6J/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=G4bhzG6Uz1kT1HHStCiLMcrdEJ22+CNEF6X2RN3iI7U=; b=Rrec7MzaeL4nomInIZTw9uoqxh9/z79OMwCgKQKUGgVMz3Hfzcr5pnXQdETHijsn+Y fMrQyCOEav9bOFlKV2La19m6wHilryt1Y65DogysPkZfov1R3YNUefLs9l0pk4/j4QYh MdyfI6d04BGrnNT9NGCjVmTEGWuC5P58kmhN71XE880Amr6Ct5MQvDe5JvbR8eJGp4GL kX9AyNZA3R7DaFl249ZA5ccq9kX8c4KFm8rkorYMm0O896a/R12KRyoo0SSKQ9OSXM5i Ozvapi/aqaD8Au+GlCGgH/mEZxEYRSPMQzZuMWGPk0d++ciXHcwBAsAUBPV/5biHMwjT OfPQ== X-Gm-Message-State: AGi0PuYlvO2QmGMKNadeiGDhzhr6OuYf8Uuqj2kdga/1pR/9PAHh8/vc GF8wr8sOsnJj0fDTYncxyDUNbvwz X-Google-Smtp-Source: APiQypK18sDazWZpGayeY7GygnhWheCafE1Z0C38Cir1XJm51We6XG91QiFvZalvm9Sb0Hv95tPJsw== X-Received: by 2002:a17:90a:31c2:: with SMTP id j2mr2841206pjf.17.1588251567065; Thu, 30 Apr 2020 05:59:27 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id w13sm3416027pfn.192.2020.04.30.05.59.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Apr 2020 05:59:26 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 30 Apr 2020 20:59:14 +0800 Message-Id: <1588251554-3665-5-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1588251554-3665-1-git-send-email-lance.lmwang@gmail.com> References: <1588251554-3665-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 5/5] avcodec/utils: simplify, remove duplicate code 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/utils.c | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index e77090daef..91b271a717 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -584,37 +584,14 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code avctx->internal = avci; avci->to_free = av_frame_alloc(); - if (!avci->to_free) { - ret = AVERROR(ENOMEM); - goto free_and_end; - } - avci->compat_decode_frame = av_frame_alloc(); - if (!avci->compat_decode_frame) { - ret = AVERROR(ENOMEM); - goto free_and_end; - } - avci->buffer_frame = av_frame_alloc(); - if (!avci->buffer_frame) { - ret = AVERROR(ENOMEM); - goto free_and_end; - } - avci->buffer_pkt = av_packet_alloc(); - if (!avci->buffer_pkt) { - ret = AVERROR(ENOMEM); - goto free_and_end; - } - avci->ds.in_pkt = av_packet_alloc(); - if (!avci->ds.in_pkt) { - ret = AVERROR(ENOMEM); - goto free_and_end; - } - avci->last_pkt_props = av_packet_alloc(); - if (!avci->last_pkt_props) { + if (!avci->to_free || !avci->compat_decode_frame || + !avci->buffer_frame || !avci->buffer_pkt || + !avci->ds.in_pkt || !avci->last_pkt_props) { ret = AVERROR(ENOMEM); goto free_and_end; }