From patchwork Wed May 10 14:25:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 41571 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp3892183pzb; Wed, 10 May 2023 07:25:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7IX5AoHKZfA4TPJmCBVepU9exHsOdPn/4NUDjsYdWe7tQxA95FVgJOQUtWThvTEj95x63e X-Received: by 2002:a17:907:72d6:b0:94e:43ce:95f6 with SMTP id du22-20020a17090772d600b0094e43ce95f6mr17415725ejc.47.1683728750287; Wed, 10 May 2023 07:25:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683728750; cv=none; d=google.com; s=arc-20160816; b=h2ZZvnJD4lrKrTiXFZL9HHbAiOiFAu9ObD/YLYURCpCQtnNeNFhsbqVxCaGkepTEUi jQY/gFpLzZ1ftOsMeKQl6y9z+BVLySfmMFZ8wsbTmbm9kfDmk+mX1yMXNmERdSbqj4YZ 1sWIPmpJBPRUfbUkvgJ/bMmUVq7/R0mBbZOj9gZNmH1dcRSAebVeLA26opbhfwbCLnFW 2UqWgUPA2jGxqbInmoZfSfCDoSx2fqubaKr518mdkqaXmihmZJmElZki2PtC63PxyYuC 1PztA/BDDy50j3SgUbxIsIFJsI/3pCi7kdhlCPgLZsNkHC3mMGDliGBpwQTNZkdvgbpJ CRwQ== 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:to :message-id:date:from:mime-version:dkim-signature:delivered-to; bh=JcPP/1FOg9/yTG/kiuB7XcF+91cozvmGCHchE0CQdug=; b=Jus7EzRWLotQVubHcHQAmfC40DYV//AFBFhAwe1aCkFH/zx4cIkFKz46Uo3QEYvBN9 rae8Fa75peTAqk7nLkk7KteM0nI2Xpy4/iOu5+7nBJUn/FC2Dmh8koj2HyDCa43XpAFP ojse4JeRO9VPO2+63n5vWwdl7uXwvUooNkk/XGzeSPDOnv5fgIE+Ua1WqD49xrqO5py2 oR4VNowgvzbRn1oT5TFp9rKZXteXJCD5q3wxdfxPB5R7OYAGd+mCJrV7YXkqTa/1PM0l l+KxKZgb9L2czYTB5WXMOx0wJY9iDhpvzcy6tIRTNP2MDKoZF0vzXlR77dUDG5RHRB/J o25Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=G6+hYi5Y; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 1-20020a170906318100b00961703e405asi4009506ejy.559.2023.05.10.07.25.49; Wed, 10 May 2023 07:25:50 -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=@gmail.com header.s=20221208 header.b=G6+hYi5Y; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5458868B4FE; Wed, 10 May 2023 17:25:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-vk1-f173.google.com (mail-vk1-f173.google.com [209.85.221.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6A76D687EEB for ; Wed, 10 May 2023 17:25:38 +0300 (EEST) Received: by mail-vk1-f173.google.com with SMTP id 71dfb90a1353d-44ffef66dabso3983233e0c.2 for ; Wed, 10 May 2023 07:25:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683728737; x=1686320737; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=g0dqIt1xx3IPko7N8A+DOAd96WLo4JG2XLt8/oPy3II=; b=G6+hYi5YCLBzpQCB7AER9gSBl1D+DBVwapEU7C754yd1+Ugad63j+QhRgs1VRJxsM0 a6VQQOUWBs4O5lxdlROgD38AYlKYWPR0vK2SY9zu7aDn7OGaMn4rVxX+QeS4RSx1NMJ4 4JfsmoKlCU+kL1+ws9UixAs7j8WNAoWryq032oyAgi5LtED/4Rq7ROj5x5SKdh4o9S+p UoHoz+uaQi8lzfavAXCYkWYcYgvqfxdrc6pbIW31f7Qak9NWrIdCNwkduIXCDRQoOQSB 90auEAIdCvnA41toOM33uYfoR3pRDQ0W61Hu3ieuhfDGbxoglgHn0rVRuJMdwkQE6One IcIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683728737; x=1686320737; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=g0dqIt1xx3IPko7N8A+DOAd96WLo4JG2XLt8/oPy3II=; b=Nxvabe8E/zVFxsXrmqAukvc62OFpi6q85PUPT7cbON8HDiR9BlXLj499OFDWGoTQl5 uOyyrjQ22E+Ju1S1yHazXhbOJoMny2yvUlriw0bRWLUpQ2S4T5FUjOaLDZrNBDDxb0dh 9sfk42gfiE7wh+BzWNBhSpth9Em154rN9S8gVEfsQjErVr2Qikmv3cJrjRbKlMnvZvto sMSi3kcLdW38BXqb+4+ijWswz7lb3q2F27dV+sQjNsOCfeJ4HU4AhB3uAMMYUQxxT9Kv HI8FaxxXAxiKhxiBqXsZ13QlbkVamZsPtIFREnRGfGGEPe/ksC7fzN7evDE7W2wclOug uRFA== X-Gm-Message-State: AC+VfDwtSPix8qOmk3rOQGjdUTwJ8f9JEioeogU6vhYd/qkiLVG1oOAk Yqx7i+am5X6Axqqb41zAiAuYSP2JetCgzahPQheITP0j X-Received: by 2002:a1f:c112:0:b0:43f:ea80:e8af with SMTP id r18-20020a1fc112000000b0043fea80e8afmr5880168vkf.4.1683728736789; Wed, 10 May 2023 07:25:36 -0700 (PDT) MIME-Version: 1.0 From: Paul B Mahol Date: Wed, 10 May 2023 16:25:06 +0200 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [FFmpeg-devel] [PATCH] swresample: reuse DSP functions from avutil 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: 3hEv/5bOX8jx Attached. From 1f6aded57aab1fd8c6c7ba6fa5261d7979666f66 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Wed, 10 May 2023 15:41:01 +0200 Subject: [PATCH] swresample: reuse DSP functions from avutil Improves generic mixing dramatically. Signed-off-by: Paul B Mahol --- libswresample/rematrix.c | 30 +++++++++++++++++++++++++++-- libswresample/swresample.c | 5 +++++ libswresample/swresample_internal.h | 2 ++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c index 79e8a43eac..0d234bc97e 100644 --- a/libswresample/rematrix.c +++ b/libswresample/rematrix.c @@ -652,7 +652,20 @@ int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mus break;} default: if(s->int_sample_fmt == AV_SAMPLE_FMT_FLTP){ - for(i=0; i 0) { + in_i = s->matrix_ch[out_i][1+0]; + s->fdsp->vector_fmul_scalar((float *)out->ch[out_i], + (const float *)in->ch[in_i], + s->matrix_flt[out_i][in_i], len1); + for (j = 1; j < s->matrix_ch[out_i][0]; j++) { + in_i = s->matrix_ch[out_i][1+j]; + s->fdsp->vector_fmac_scalar((float *)out->ch[out_i], + (const float *)in->ch[in_i], + s->matrix_flt[out_i][in_i], len1); + } + } + for (i = len1; i < len; i++) { float v=0; for(j=0; jmatrix_ch[out_i][0]; j++){ in_i= s->matrix_ch[out_i][1+j]; @@ -661,7 +674,20 @@ int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mus ((float*)out->ch[out_i])[i]= v; } }else if(s->int_sample_fmt == AV_SAMPLE_FMT_DBLP){ - for(i=0; i 0) { + in_i = s->matrix_ch[out_i][1+0]; + s->fdsp->vector_dmul_scalar((double *)out->ch[out_i], + (const double *)in->ch[in_i], + s->matrix[out_i][in_i], len1); + for (j = 1; j < s->matrix_ch[out_i][0]; j++) { + in_i = s->matrix_ch[out_i][1+j]; + s->fdsp->vector_dmac_scalar((double *)out->ch[out_i], + (const double *)in->ch[in_i], + s->matrix[out_i][in_i], len1); + } + } + for (i = len1; i < len; i++) { double v=0; for(j=0; jmatrix_ch[out_i][0]; j++){ in_i= s->matrix_ch[out_i][1+j]; diff --git a/libswresample/swresample.c b/libswresample/swresample.c index 6dc329a9d0..b0b6f6a5c5 100644 --- a/libswresample/swresample.c +++ b/libswresample/swresample.c @@ -181,6 +181,7 @@ av_cold void swr_free(SwrContext **ss){ if (s->resampler) s->resampler->free(&s->resample); + av_freep(&s->fdsp); } av_freep(ss); @@ -504,6 +505,10 @@ av_assert0(s->out.ch_count); goto fail; } + s->fdsp = avpriv_float_dsp_alloc(0); + if (!s->fdsp) + goto fail; + return 0; fail: swr_close(s); diff --git a/libswresample/swresample_internal.h b/libswresample/swresample_internal.h index ad902d73fa..dba678c502 100644 --- a/libswresample/swresample_internal.h +++ b/libswresample/swresample_internal.h @@ -22,6 +22,7 @@ #define SWRESAMPLE_SWRESAMPLE_INTERNAL_H #include "swresample.h" +#include "libavutil/float_dsp.h" #include "libavutil/channel_layout.h" #include "config.h" @@ -189,6 +190,7 @@ struct SwrContext { mix_any_func_type *mix_any_f; + AVFloatDSPContext *fdsp; /* TODO: callbacks for ASM optimizations */ }; -- 2.39.1