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 CE42542D51 for ; Thu, 7 Jul 2022 22:30:24 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8BEAE68B8E6; Fri, 8 Jul 2022 01:30:17 +0300 (EEST) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F20C068B83C for ; Fri, 8 Jul 2022 01:30:10 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id E4D4DE7620; Fri, 8 Jul 2022 00:30:10 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tJoJL7mw1lnR; Fri, 8 Jul 2022 00:29:42 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 7C044E7622; Fri, 8 Jul 2022 00:29:42 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Fri, 8 Jul 2022 00:29:30 +0200 Message-Id: <20220707222931.16118-2-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220707222931.16118-1-cus@passwd.hu> References: <20220707222931.16118-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avfilter/vf_zscale: simplify and fix slice_params calculations 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: Marton Balint 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: Do not insist on a fixed slice height, because that can still cause overflows in corner cases as described in this comment: https://github.com/sekrit-twc/zimg/issues/177#issuecomment-1157734233 Signed-off-by: Marton Balint --- libavfilter/vf_zscale.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c index 6861eef278..8e50457c6b 100644 --- a/libavfilter/vf_zscale.c +++ b/libavfilter/vf_zscale.c @@ -227,22 +227,12 @@ static int query_formats(AVFilterContext *ctx) static void slice_params(ZScaleContext *s, int out_h, int in_h) { - int slice_size; - - slice_size = (out_h + (s->nb_threads / 2)) / s->nb_threads; - if (slice_size % 2) - slice_size += 1; s->out_slice_start[0] = 0; - s->out_slice_end[0] = FFMIN(out_h, slice_size); - for (int i = 1; i < s->nb_threads - 1; i++) { - s->out_slice_start[i] = s->out_slice_end[i-1]; - s->out_slice_end[i] = s->out_slice_start[i] + slice_size; - } - - if (s->nb_threads > 1) { - s->out_slice_start[s->nb_threads - 1] = s->out_slice_end[s->nb_threads - 2]; - s->out_slice_end[s->nb_threads - 1] = out_h; + for (int i = 1; i < s->nb_threads; i++) { + int slice_end = out_h * i / s->nb_threads; + s->out_slice_end[i - 1] = s->out_slice_start[i] = FFALIGN(slice_end, 2); } + s->out_slice_end[s->nb_threads - 1] = out_h; for (int i = 0; i < s->nb_threads; i++) { s->in_slice_start[i] = s->out_slice_start[i] * in_h / (double)out_h; -- 2.35.3 _______________________________________________ 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".