From patchwork Wed Jan 23 01:10:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 11830 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 5FF1844C68C for ; Wed, 23 Jan 2019 03:12:21 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8701568ABB2; Wed, 23 Jan 2019 03:12:09 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe05-1.mx.upcmail.net (vie01a-dmta-pe05-1.mx.upcmail.net [84.116.36.11]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 850A368AB16 for ; Wed, 23 Jan 2019 03:12:03 +0200 (EET) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe05.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1gm75Z-0007Bx-0H for ffmpeg-devel@ffmpeg.org; Wed, 23 Jan 2019 02:12:21 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id m73dg0sjT2WSsm73dgnmYj; Wed, 23 Jan 2019 02:10:21 +0100 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.41.20 X-CNFS-Analysis: v=2.3 cv=E7kcWpVl c=1 sm=1 tr=0 a=I1eytVlZLDX1BM2VTtTtSw==:117 a=I1eytVlZLDX1BM2VTtTtSw==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=X-rqr9CWmesVu09tUaUA:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 23 Jan 2019 02:10:19 +0100 Message-Id: <20190123011020.5726-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190123011020.5726-1-michael@niedermayer.cc> References: <20190123011020.5726-1-michael@niedermayer.cc> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfAfiwDDMgJeFlmS9nwla5fCzLoKPKY5VRNqnOtiW038LHBpiji+w0iaEq/dVZw4WpnVvAPD3oZP0nA8pEOuyazeOLHzpDpeq+xeid05MtvkEUAxa9ZWd cayTsqAQIA6wls3B+cJ8qQf/Z26A405DA/P7nlESc8UGQH5mJK064qdH Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/rasc: Move ff_get_buffer() after frame checks 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" If the frame1/2 checks fail this avoids doing the allocation of a new frame Signed-off-by: Michael Niedermayer --- libavcodec/rasc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/rasc.c b/libavcodec/rasc.c index 6e32c1540e..21fc43f325 100644 --- a/libavcodec/rasc.c +++ b/libavcodec/rasc.c @@ -723,12 +723,12 @@ static int decode_frame(AVCodecContext *avctx, return ret; } - if ((ret = ff_get_buffer(avctx, s->frame, 0)) < 0) - return ret; - if (!s->frame2->data[0] || !s->frame1->data[0]) return AVERROR_INVALIDDATA; + if ((ret = ff_get_buffer(avctx, s->frame, 0)) < 0) + return ret; + copy_plane(avctx, s->frame2, s->frame); if (avctx->pix_fmt == AV_PIX_FMT_PAL8) memcpy(s->frame->data[1], s->frame2->data[1], 1024);