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 ESMTP id 399FA489C5 for ; Fri, 22 Dec 2023 11:52:12 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 920DA68D2DB; Fri, 22 Dec 2023 13:52:02 +0200 (EET) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 30D2468D2D6 for ; Fri, 22 Dec 2023 13:51:56 +0200 (EET) Received: by mail.gandi.net (Postfix) with ESMTPSA id 81113FF815 for ; Fri, 22 Dec 2023 11:51:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1703245914; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:in-reply-to:in-reply-to:references:references; bh=1H4I/KUv1857FU2YRjqhBHXUR0Octqppm5UWsG0Tp+s=; b=GFKmQ5PVaZifeq3GJbsD+94OK8+lQTtGhpJvRjTrvJvD1hiX25TFfk1ZoLieaZ6rHVSHYs XBoF7RJoO/0PgVpf3Ki1YbqKxX9qm7XQzSqrq/mqCuXD5rv0XmF1DOQ8P/IEI3i1dNNuKe 3V+mPaMXu6iRq8sm5tiIz90yjHrShKP5deLuGMZN7qkA5GkGjkhL2JzLmvacusLyjHMYXJ 8cSXC9M/9KUlyshv/oX0PdghREzRs6JqlximFoiBRQKyO034aCGJCcKjk1IbqnRq5iHuNu RsXNku3hZ3Itc4vLW63dskCkN4JeyAEwOgVaGCe5uP6xyUx9SZU0UB5Z5KeTnA== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 22 Dec 2023 12:51:52 +0100 Message-Id: <20231222115152.12329-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231222115152.12329-1-michael@niedermayer.cc> References: <20231222115152.12329-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_weave: Fix odd height handling 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 MIME-Version: 1.0 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: Fixes: out of array access Fixes: tickets/10743/poc10ffmpeg Found-by: Zeng Yunxiang and Li Zeyuan Signed-off-by: Michael Niedermayer --- libavfilter/vf_weave.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_weave.c b/libavfilter/vf_weave.c index 84f3c5f337d..7ad29bdedbe 100644 --- a/libavfilter/vf_weave.c +++ b/libavfilter/vf_weave.c @@ -32,6 +32,7 @@ typedef struct WeaveContext { int double_weave; int nb_planes; int planeheight[4]; + int outheight[4]; int linesize[4]; AVFrame *prev; @@ -81,6 +82,9 @@ static int config_props_output(AVFilterLink *outlink) s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h); s->planeheight[0] = s->planeheight[3] = inlink->h; + s->outheight[1] = s->outheight[2] = AV_CEIL_RSHIFT(2*inlink->h, desc->log2_chroma_h); + s->outheight[0] = s->outheight[3] = 2*inlink->h; + s->nb_planes = av_pix_fmt_count_planes(inlink->format); return 0; @@ -106,19 +110,20 @@ static int weave_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) const int height = s->planeheight[i]; const int start = (height * jobnr) / nb_jobs; const int end = (height * (jobnr+1)) / nb_jobs; + const int compensation = 2*end > s->outheight[i]; av_image_copy_plane(out->data[i] + out->linesize[i] * field1 + out->linesize[i] * start * 2, out->linesize[i] * 2, in->data[i] + start * in->linesize[i], in->linesize[i], - s->linesize[i], end - start); + s->linesize[i], end - start - compensation * field1); av_image_copy_plane(out->data[i] + out->linesize[i] * field2 + out->linesize[i] * start * 2, out->linesize[i] * 2, s->prev->data[i] + start * s->prev->linesize[i], s->prev->linesize[i], - s->linesize[i], end - start); + s->linesize[i], end - start - compensation * field2); } return 0; -- 2.17.1 _______________________________________________ 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".