From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id EAC484DF16 for ; Sat, 26 Apr 2025 17:56:58 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 44DFB68B4D4; Sat, 26 Apr 2025 20:56:21 +0300 (EEST) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0DFD168A2DE for ; Sat, 26 Apr 2025 20:56:11 +0300 (EEST) Received: from haasn.dev (unknown [10.30.1.1]) by haasn.dev (Postfix) with UTF8SMTP id CF65C4255D; Sat, 26 Apr 2025 19:56:10 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Sat, 26 Apr 2025 19:41:07 +0200 Message-ID: <20250426175603.726924-4-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250426175603.726924-1-ffmpeg@haasn.xyz> References: <20250426175603.726924-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/17] swscale/graph: make noop loop more robust 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 Cc: Niklas Haas Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Niklas Haas The current loop only works if the input and output have the same number of planes. However, with the new scaling logic, we can also optimize into a noop the case where the input has extra unneeded planes. For the memcpy fallback to work in these cases we have to instead check if the *output* pointer is set, rather than the input pointer. --- libswscale/graph.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libswscale/graph.c b/libswscale/graph.c index 6cfcf4f2c6..c5a46eb257 100644 --- a/libswscale/graph.c +++ b/libswscale/graph.c @@ -115,8 +115,10 @@ static void run_copy(const SwsImg *out_base, const SwsImg *in_base, SwsImg in = shift_img(in_base, y); SwsImg out = shift_img(out_base, y); - for (int i = 0; i < FF_ARRAY_ELEMS(in.data) && in.data[i]; i++) { + for (int i = 0; i < FF_ARRAY_ELEMS(out.data) && out.data[i]; i++) { const int lines = h >> vshift(in.fmt, i); + av_assert1(in.data[i]); + if (in.linesize[i] == out.linesize[i]) { memcpy(out.data[i], in.data[i], lines * out.linesize[i]); } else { -- 2.49.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".