From patchwork Mon May 31 07:55:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28007 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2656854iof; Mon, 31 May 2021 00:57:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzvN4pR9NjYD6GyrthYwvY394X5XpoTR7uxuwrxRGooB3Z9CD5SWi2YGc0/+Iemhqak6TK X-Received: by 2002:a17:906:7842:: with SMTP id p2mr21106611ejm.487.1622447841553; Mon, 31 May 2021 00:57:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447841; cv=none; d=google.com; s=arc-20160816; b=lrtAuf4bR6jwxtEWkNEndNBXnD2HgZWu2iLbkffinEqi7Ga0yodQ/Hw0Xw2AVVxMDb +gvsaQ6NLGxDLsdXk2PhiSBp8Qu06RBRjGL4/2nZ2StK48O+v5Sa1XT7W5y5nciep/Jw 8Hr8Ee6ASMoQS92aBmiN37wZpbbzpis12g/x5GFnXB0Zz5WEaL+alNk4xtR39jgvlpDy oZk8QEzTuPdIoPh5UalSrLfs6cdmRslAPJdJQqKpC/VjZ1RJT8sNF+g7Bznu9xjaAcfw kGO3rbv83q93/0Uw4JtTVOG7g1FoK7n9+DYeSc5b0RaSIc0IPwE1xeCsTy5a2AFGMHjC kkZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=qROP6JTAar9QySyytiPn0s0ePjPEsmiJBEu5DtRQFrQ=; b=rbH3VOJK7a4+GRXf6MnZdKdDSNUlfWpOkKTYnx9kOT3TvkdzBJSt/lcmSG8Nwv8OQm Y3IvGQqV5nxyb6k0z1iyTslGyTFGc/3sQ83HUIGwZ41US6d+MejN7Dx0yTRJ7NRQYTAC Gb4atE+KhQdgloYaTh2YHtlfiFWLHQL1TDe7vFvFAzq7f9z2wPFTMVKAPlz6mugf0xEe GRrsorvLNFUIhBdKdHcLZysBAMEBAEw7+mSZwUqyTTgbuqyn1PMQfUtkn19Eh3SoO1s5 SkCL1a0KEUO2bcDRI15NRlKpPcxv1Sb0QKhvYyMpMQr7R+shr2q6ZazqTI7IwTY++QnX 22XA== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id nb27si12049328ejc.548.2021.05.31.00.57.21; Mon, 31 May 2021 00:57:21 -0700 (PDT) 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; 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 D695968803C; Mon, 31 May 2021 10:55:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 17F7368804C for ; Mon, 31 May 2021 10:55:29 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 46DE024069E for ; Mon, 31 May 2021 09:55:26 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 6-rxFBb7_9R5 for ; Mon, 31 May 2021 09:55:25 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 4C65124042A for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 1CE153A178D; Mon, 31 May 2021 09:55:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:08 +0200 Message-Id: <20210531075515.19544-17-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 17/24] sws: move the early return for zero-sized slices higher up X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: IQgw7TjKJUts Place it right after the input parameter validation. There is no point in performing any setup if the sws_scale() call won't do anything. --- libswscale/swscale.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 270adcc072..2d6ed95cfb 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -897,6 +897,10 @@ int attribute_align_arg sws_scale(struct SwsContext *c, return AVERROR(EINVAL); } + // do not mess up sliceDir if we have a "trailing" 0-size slice + if (srcSliceH == 0) + return 0; + if (c->gamma_flag && c->cascaded_context[0]) return scale_gamma(c, srcSlice, srcStride, srcSliceY, srcSliceH, dst, dstStride); @@ -908,10 +912,6 @@ int attribute_align_arg sws_scale(struct SwsContext *c, memcpy(srcStride2, srcStride, sizeof(srcStride2)); memcpy(dstStride2, dstStride, sizeof(dstStride2)); - // do not mess up sliceDir if we have a "trailing" 0-size slice - if (srcSliceH == 0) - return 0; - if (frame_start) { if (srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) { av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n");