From patchwork Mon Apr 19 20:25:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 27118 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:5014:0:0:0:0:0 with SMTP id e20csp839426iob; Mon, 19 Apr 2021 13:25:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRLzNBLVBwZksJPE1V5mww5VT/UzejkYQMlEuKOum7QQahvDBRopGu/Ztp8u4NEa1X5kZX X-Received: by 2002:a17:907:c10:: with SMTP id ga16mr9698178ejc.402.1618863908871; Mon, 19 Apr 2021 13:25:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618863908; cv=none; d=google.com; s=arc-20160816; b=be8tkGxe3xDb2kx9T/SddhTT7/GhrliEl3WDxkQjnsMnV6sN4cXZKdIJPiqS0qq66f MGHquDTIqHlE8wdQujiGfDD6Mz/ZqkzGiHy0LBaU0ZSBYZlS/QM5/HQet230IBmnUt7W tL5FaO2mmcArt9KR9R5lQCUtI6b9F8n+SuoPvWWls2+oAm+TcOhtaky93hTyISS7E8+m T/sKUstRBz4Zt8siMq6BOuC9lIIqTFCB6K+CMaABqzyKpN6C2p0NWUB0GGzQ3665EjV1 f/Me7qDW/lF1N4SA5+mpJEg+WroTBHChqsc/4l8ChajujCnYeZmdAwNKiOALqTpEC6LI sbfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:to:from:date :dkim-signature:delivered-to; bh=MKso3r9gaRIOk5S9nQGSx9HOJOrrE0jtNB8Ax0Kzhdo=; b=Td1O2MeYPN4R0So68yCPwLoYPgvd+xUtxdUvTDG6WDPgnM2oCCyGDYnxmRNa0QPcCw 8YRrm9v5ICDi5cYSj1n3tzjXOvYuSjyGq4hlRLopAsj2ykOwcwl6N0G0rEVQ67um2B2x uevsgaRwfxYSbRaOWbK8IWay+eFPjUQ+0Z6cHAdKO1Hukz7sbeFHaYtq9sKny+d8oj68 U3oesx3LhyDu9rXo134jcFD+/W7fABh7ych8bIrJ+qFQQeypHyOkEIsGsNfHE9tcxMvy q6F3XC9PyciOk7NRssh3HX8wvFzj5WbAiOxz6E4Ea65w/wt6bLwJbQ/8zxbHcVhlj2e/ uOmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@lynne.ee header.s=s1 header.b=zugMwxwY; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=lynne.ee Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dd21si5302853edb.45.2021.04.19.13.25.08; Mon, 19 Apr 2021 13:25:08 -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; dkim=neutral (body hash did not verify) header.i=@lynne.ee header.s=s1 header.b=zugMwxwY; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=lynne.ee Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3600D689B7A; Mon, 19 Apr 2021 23:25:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3BD826806A2 for ; Mon, 19 Apr 2021 23:25:03 +0300 (EEST) Received: from w3.tutanota.de (unknown [192.168.1.164]) by w4.tutanota.de (Postfix) with ESMTP id A2086106015A for ; Mon, 19 Apr 2021 20:25:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1618863903; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=V0depmjPVa8OwA6u/eLbEoO2uW5IodqVb2QzShLrGfg=; b=zugMwxwYaGj0PYkhfeTCrl+O3jJ/d5OrzVnJyVK7po1GKcMzQSoN0e0BJbVMht4V buizCDKOSe9mqiz1T1nmGE/aFxgTXtTzxhGEspj7LCWbyVTkGZROp/6w9IMVMj/bnuQ Gi0UIeIU3us7fuR4yrjWv0rvnrDMqf11XJbODbYlXo8ZwG6Vz0zShwnr233EchknARb gqlnM1Dt0fY8H0tY/VTmJnYGwFX+m5GzyspXccet5BApJ1XlIOpC+Rus6miXLVwz1Ta ZIimgdtULvYgoLzYLQW2gOFo/bDQzkqGgq0cdMIooIjqoO+tuddeJ73TjJZEz5GYf4j hkcNTYWFWQ== Date: Mon, 19 Apr 2021 22:25:03 +0200 (CEST) From: Lynne To: FFmpeg development discussions and patches Message-ID: In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/11] lavu/tx: add parity revtab generator version 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: QVh4Xa3sWghj This will be used for SIMD support. Patch attached. Subject: [PATCH 08/11] lavu/tx: add parity revtab generator version This will be used for SIMD support. --- libavutil/tx.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ libavutil/tx_priv.h | 31 ++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/libavutil/tx.c b/libavutil/tx.c index 05d4de30cc..6d0e854084 100644 --- a/libavutil/tx.c +++ b/libavutil/tx.c @@ -158,6 +158,55 @@ int ff_tx_gen_ptwo_inplace_revtab_idx(AVTXContext *s) return 0; } +static void parity_revtab_generator(int *revtab, int n, int inv, int offset, + int is_dual, int dual_high, int len, + int basis, int dual_stride) +{ + len >>= 1; + + if (len <= basis) { + int k1, k2, *even, *odd, stride; + + is_dual = is_dual && dual_stride; + dual_high = is_dual & dual_high; + stride = is_dual ? FFMIN(dual_stride, len) : 0; + + even = &revtab[offset + dual_high*(stride - 2*len)]; + odd = &even[len + (is_dual && !dual_high)*len + dual_high*len]; + + for (int i = 0; i < len; i++) { + k1 = -split_radix_permutation(offset + i*2 + 0, n, inv) & (n - 1); + k2 = -split_radix_permutation(offset + i*2 + 1, n, inv) & (n - 1); + *even++ = k1; + *odd++ = k2; + if (stride && !((i + 1) % stride)) { + even += stride; + odd += stride; + } + } + + return; + } + + parity_revtab_generator(revtab, n, inv, offset, + 0, 0, len >> 0, basis, dual_stride); + parity_revtab_generator(revtab, n, inv, offset + (len >> 0), + 1, 0, len >> 1, basis, dual_stride); + parity_revtab_generator(revtab, n, inv, offset + (len >> 0) + (len >> 1), + 1, 1, len >> 1, basis, dual_stride); +} + +void ff_tx_gen_split_radix_parity_revtab(int *revtab, int len, int inv, + int basis, int dual_stride) +{ + basis >>= 1; + if (len < basis) + return; + av_assert0(!dual_stride || !(dual_stride & (dual_stride - 1))); + av_assert0(dual_stride <= basis); + parity_revtab_generator(revtab, len, inv, 0, 0, 0, len, basis, dual_stride); +} + av_cold void av_tx_uninit(AVTXContext **ctx) { if (!(*ctx)) diff --git a/libavutil/tx_priv.h b/libavutil/tx_priv.h index 1d4245e71b..b889f6d3b4 100644 --- a/libavutil/tx_priv.h +++ b/libavutil/tx_priv.h @@ -149,6 +149,37 @@ int ff_tx_gen_ptwo_revtab(AVTXContext *s, int invert_lookup); */ int ff_tx_gen_ptwo_inplace_revtab_idx(AVTXContext *s); +/* + * This generates a parity-based revtab of length len and direction inv. + * + * Parity means even and odd complex numbers will be split, e.g. the even + * coefficients will come first, after which the odd coefficients will be + * placed. For example, a 4-point transform's coefficients after reordering: + * z[0].re, z[0].im, z[2].re, z[2].im, z[1].re, z[1].im, z[3].re, z[3].im + * + * The basis argument is the length of the largest non-composite transform + * supported, and also implies that the basis/2 transform is supported as well, + * as the split-radix algorithm requires it to be. + * + * The dual_stride argument indicates that both the basis, as well as the + * basis/2 transforms support doing two transforms at once, and the coefficients + * will be interleaved between each pair in a split-radix like so (stride == 2): + * tx1[0], tx1[2], tx2[0], tx2[2], tx1[1], tx1[3], tx2[1], tx2[3] + * A non-zero number switches this on, with the value indicating the stride + * (how many values of 1 transform to put first before switching to the other). + * Must be a power of two or 0. Must be less than the basis. + * Value will be clipped to the transform size, so for a basis of 16 and a + * dual_stride of 8, dual 8-point transforms will be laid out as if dual_stride + * was set to 4. + * Usually you'll set this to half the complex numbers that fit in a single + * register or 0. This allows to reuse SSE functions as dual-transform + * functions in AVX mode. + * + * If length is smaller than basis/2 this function will not do anything. + */ +void ff_tx_gen_split_radix_parity_revtab(int *revtab, int len, int inv, + int basis, int dual_stride); + /* Templated init functions */ int ff_tx_init_mdct_fft_float(AVTXContext *s, av_tx_fn *tx, enum AVTXType type, int inv, int len,