From patchwork Thu Jul 7 22:29:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 36704 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:8b27:b0:88:1bbf:7fd2 with SMTP id l39csp5187862pzh; Thu, 7 Jul 2022 15:30:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ulf18Rk//N8R/o7Py/q2RiyW+Vo7Od5CIc66b/SMlUJeGr0YoRoLo8zTHM48YHUYGL7ZKK X-Received: by 2002:a05:6402:84f:b0:437:6293:d264 with SMTP id b15-20020a056402084f00b004376293d264mr459335edz.317.1657233042975; Thu, 07 Jul 2022 15:30:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657233042; cv=none; d=google.com; s=arc-20160816; b=rn3T8XBM23j3eolvUtM2+v+VE64GVfy+OdhM676qofKT0XdSFuokG37tsOIjfECBwK zmnAO12cbbnBxrJAzUzdAtzMKDcQcpDTmps7tkg0Cxp7fGF2vl+squGFiHNxRVcJJQit DgvKNYEqrgNIkkjc70YLCZak+2lektp4N3H3+NnellT2l8hs/AbG4SE8n+Ndi11ZCCaG mlCI7FBphVwwZaqwKrBiyaLW7W0phShlg8dR9HBRhsj+iRG1112WZPQCkUXKnO1+iRlL Yq5P94tOcOxDxaelnLmDDA72InArRHncwGJjvErN1W/oQ2k4mPj8IrqpfVpBRe+sXKpr YPuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=Zb8Vzd7Az+EI+4bJ9A6bQlsRPtbMS7tpHQNL34GIyiA=; b=abBt9g8B5B3up7mEK1cAl0xk6Oo784O12c9V+4lWFoCwV6jFgBehZVNfOCjhAa9NN3 52Tl4v+zfdN0iA5jsa0syjc2YwxuSceOqY9+bGKICRAmzwKRJfFXBTOz+HHL3pA2aG/s qeg0TKjfUiURcxalVklZqREjryQGi1r2wiLIfzpmsquEoc6qD4XJOjLjtH10xoKgY0n9 htiy1mkngpe+5rgNUKevaVNQQgQEAO6JusSYMSOBkw9i+D4gaURlfDT6bsWVo7wnidZp mw4vDZZNWmqO/d0UETbBguR6gCO4CIBGgLLWgItnVrr5lblG/sBDFmdRVAej9Ua+/We1 Kr4A== 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 js9-20020a17090797c900b00726b4f8d88esi28452645ejc.78.2022.07.07.15.30.19; Thu, 07 Jul 2022 15:30:42 -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 8F09D68B830; Fri, 8 Jul 2022 01:30:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 520D868B830 for ; Fri, 8 Jul 2022 01:30:05 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id B5039E7626; Fri, 8 Jul 2022 00:30:04 +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 OV-gJdxzwzyB; Fri, 8 Jul 2022 00:29:35 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id A708EE7620; Fri, 8 Jul 2022 00:29:35 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Fri, 8 Jul 2022 00:29:29 +0200 Message-Id: <20220707222931.16118-1-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avfilter/vf_zscale: remove some unneeded initializations 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: RxuoA5ewHz85 Signed-off-by: Marton Balint --- libavfilter/vf_zscale.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c index 44cb4b9c61..6861eef278 100644 --- a/libavfilter/vf_zscale.c +++ b/libavfilter/vf_zscale.c @@ -149,12 +149,6 @@ static av_cold int init(AVFilterContext *ctx) { ZScaleContext *s = ctx->priv; int ret; - int i; - for (i = 0; i < MAX_THREADS; i++) { - s->tmp[i] = NULL; - s->graph[i] = NULL; - s->alpha_graph[i] = NULL; - } zimg_image_format_default(&s->src_format, ZIMG_API_VERSION); zimg_image_format_default(&s->dst_format, ZIMG_API_VERSION); zimg_image_format_default(&s->src_format_tmp, ZIMG_API_VERSION); From patchwork Thu Jul 7 22:29:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 36703 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:8b27:b0:88:1bbf:7fd2 with SMTP id l39csp5187697pzh; Thu, 7 Jul 2022 15:30:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sa8VY3JZ7UpwiY3kPlzs3u/2Yv4me6mMOYLMLBf8UjfUHI1ocqAlvhU4gJIuAnF1PjPLID X-Received: by 2002:a05:6402:520b:b0:435:c2a4:f822 with SMTP id s11-20020a056402520b00b00435c2a4f822mr542571edd.198.1657233027419; Thu, 07 Jul 2022 15:30:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657233027; cv=none; d=google.com; s=arc-20160816; b=ANEIPyVke2SPunhoWdjPu7Goq74WISZNANAs5debDKD/P+3T2As9ZOVdLIyUe2qnCo LhDny/mClQdNksPngIYML2BIlUFwQaAxeaHwaiqM35mwJK3Zjcva381JiaZl864Ubgc6 xpB9rO5JJA2/8UIq3jEyn4pWdHwgYAKBUnr9qkS8XTLtERKu2PREEqkyZgcV+TseLr7m qEcPM4UAc0LCIpo03mEeaIgf4jZMBEUlZOhGVbVhBc/1Z+QKXYqcgUxmvYRDBOMlGeZb W5uXbxKF9eReWzMZb6WoB4pHsqpY+iq6Lk72YfIV+IhhYgzC+a0on8kFKWklqra72fVA RJZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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=d1fQ82ao/8uax4K3n0hTv966q6xnRUxFei+K51IlVok=; b=d3TH55BtSqLxPV6/se6t7SZr9bIVOtLDVDUPgf6TiJfUtqnhpeBL64HcUhSyhuBSsj hAWM2YNo516mk0rOGbNu5EQVfyaDwO5SK13YHM3FUP089zi2cfO5a2lMBo0PuRyZNCPf KuuGNvmd/LaAy1ySTQpsNsJlSwWvJ44Dyk4BOc7SgKIIAulllv+BxUG9uUdT+ncEW+Rg auhK13hQ/wgXaPJQ3yEc1Vkutm9Bd/jnCycpDjmwL+wxOx4D+kvAdgNCXzWr4vMkoDot 6ynLVtnqTwpqhsXLw7+ZO6Ibl+SMQkW61MQub7trtkTBgzaiIuTPyb2+7+J2c1lvUxKS C+0A== 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 ht8-20020a170907608800b007262a166933si2461167ejc.165.2022.07.07.15.30.27; Thu, 07 Jul 2022 15:30:27 -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 C571268B8EB; Fri, 8 Jul 2022 01:30:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: QGXk6VykE5gp 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; From patchwork Thu Jul 7 22:29:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 36705 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:8b27:b0:88:1bbf:7fd2 with SMTP id l39csp5187892pzh; Thu, 7 Jul 2022 15:30:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u7AZ8DKmaD/zfYXZ5BLzZdmraefd649YASyU9naqdDkPYrp+hb0jkpvqp9D0BNACuxYl1f X-Received: by 2002:a05:6402:c2:b0:439:c840:b95 with SMTP id i2-20020a05640200c200b00439c8400b95mr489518edu.376.1657233046224; Thu, 07 Jul 2022 15:30:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657233046; cv=none; d=google.com; s=arc-20160816; b=I3mLH8wnAHuoZBKqdgd5qWQRsbU1ww8dT8h1BNzyH/rL+0IjgBkA/p5+ipZZ3hcugA d0o4YqSs7l2domI7C0yPPQH85EWBUoPBGAHh2cqUG6+T720SSrj1+W9CgeHqbi9+4p+R EcQ2lL143j+4qV/vYVV52W2Xiu++JQ2A8tT0dKHUxqaIuQP5b4ex1IzLAKvNrjwJZCtM FjvCLdHDS+Af8K9W6mUWOs0PT3dV2hSpDI1m2Iz+ZNxyUmuFI7fPdYXMZgrFJJKcV1qT w0B0acxKbW6xGxusnJ1c0qnZUhpIZko4m2/GhlAj+DJfu8M8Y7LBZ67Yra+efl3gdHdl 8AfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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=U1/4na2otCcKNZ6px5dgyLQfbKU6I1PiQxva2xo2An0=; b=j5X3BY3oP5pddtZtQURPSLTMK3mL6xfOnwcIQbdeXFGh3IlYt7qC+a1evYkDC6hLoJ OTwgN5PtHQ0f5ZQwx1K0JeW14eZe3jdPgamYmEDbypUvgp+WojNmsHXt8GdG3Qe4Eb8s vKumSdT2Ce3mPNf7PMgHSa6VDyz7hE5O/xkh5mZ+nk1pdsvpNPPpgIdsxGxxn0Ix3isG g44VG+UvKxeQf/4SfKj36CGSdkzyBdULrxWQGej88YP8CEX26/32IANljpgLM1nQmlZn RIy223rgDm5EeMOcdjFNvnKLvz/BfWv3RdIbB2sqyWqr0uQLfcJTWqWuD8SzlD6qYxEa hLXw== 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 o12-20020a170906974c00b0070790bfa9a2si4376850ejy.154.2022.07.07.15.30.40; Thu, 07 Jul 2022 15:30:46 -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 96F9E68B9D4; Fri, 8 Jul 2022 01:30:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4F69768B915 for ; Fri, 8 Jul 2022 01:30:32 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id A105DE7628; Fri, 8 Jul 2022 00:30:32 +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 lafZQHbpmiQI; Fri, 8 Jul 2022 00:30:04 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 4B0A4E7624; Fri, 8 Jul 2022 00:29:49 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Fri, 8 Jul 2022 00:29:31 +0200 Message-Id: <20220707222931.16118-3-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 3/3] avfilter/vf_zscake: enable AVX512 zscale functions 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: QTIrt7pxY2y0 Signed-off-by: Marton Balint --- libavfilter/vf_zscale.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c index 8e50457c6b..91166dcbcb 100644 --- a/libavfilter/vf_zscale.c +++ b/libavfilter/vf_zscale.c @@ -837,7 +837,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) s->first_time = 0; s->params.dither_type = s->dither; - s->params.cpu_type = ZIMG_CPU_AUTO; + s->params.cpu_type = ZIMG_CPU_AUTO_64B; s->params.resample_filter = s->filter; s->params.resample_filter_uv = s->filter; s->params.nominal_peak_luminance = s->nominal_peak_luminance; @@ -851,7 +851,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) zimg_graph_builder_params_default(&s->alpha_params, ZIMG_API_VERSION); s->alpha_params.dither_type = s->dither; - s->alpha_params.cpu_type = ZIMG_CPU_AUTO; + s->alpha_params.cpu_type = ZIMG_CPU_AUTO_64B; s->alpha_params.resample_filter = s->filter; s->alpha_src_format.width = in->width;