From patchwork Mon Oct 19 11:07:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23079 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id DC6B144BBC9 for ; Mon, 19 Oct 2020 14:07:20 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B823568B67A; Mon, 19 Oct 2020 14:07:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A0F2D68AE83 for ; Mon, 19 Oct 2020 14:07:14 +0300 (EEST) Received: by mail-wm1-f68.google.com with SMTP id e2so12382465wme.1 for ; Mon, 19 Oct 2020 04:07:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Z9t1Z2Q8m9wLd06Br48Lgg6jXtNS7AMA4CFkzDZnYfE=; b=AB+BsCvVzpcQbaJMrQhyzoQg1Esn0BQNJ0W+th/ui15JIhIvnvWTipHM82JtNx4agU C8fey8IsowYzm6AzCbtey7CQqe6/tmAVOBxEgIPzN9JSXqbwYoxePJWUymsNh+9oC9XR kJ5UdbZWEPFqrMYzc4AD8f+wNaO4yTO88fc/X8S+sygGYVmw1Bz67qMDFKVZaZa5haDG g0zYISn2JlHllXq0bHV+7v0wvlAvTbXtFYlI4LifWZXk+Ph8AvVcUmTIM3O4ZVwBftaI bVODyehL1O6dbb3+yOXsEkEaoZfCFuHA94IS+KO5EDNcsw5/jhuYt6GE+u6YJbZIDiGU IfBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z9t1Z2Q8m9wLd06Br48Lgg6jXtNS7AMA4CFkzDZnYfE=; b=AKYzLuuE7m65P7ty8MNq5RDCgn53J3i8cgU2ZPHz5ChS06946AsX16TDjCbPxfTFF1 zHLFWMKVYYJzx/aOrem9SWS/E7+vSOTsr7io8YrqDmWydOwFFsG6QVf9Ce9W6rx0Eq0p ORHc574zYUHVC3OWNTgPJT/MXxi8jD2vEZMbL6NmpCykLlhfqdiyYyhpnzNytqP0Xaj1 tZpo6tjDDCXrX6eo7Zm9AO5lPSnzJyBu7S78hZFRXOrUgo4I4FN+XRNf2so73urvoV2T azMzNTXraAWAzA2VaM6Zrwmg8YbzsKh4wLAlzIMMI24aIEuihq6uTZZf909gGIOuqbb7 qX8Q== X-Gm-Message-State: AOAM532IccrA7kQiMQm/rwrUTtzD6w/n+YzygWmiK8AzSFwSU9Inn/2u 6fZJctoWG1jgj+iZxIkrbFTb1CzBmlU= X-Google-Smtp-Source: ABdhPJw8GLMSkZpAOzityL6AAh/fKf91gwN6EXd5UwppD459Ex8NIqUPqwgG6Ouz0FWKb15euIBNhQ== X-Received: by 2002:a1c:4d13:: with SMTP id o19mr18207037wmh.185.1603105633263; Mon, 19 Oct 2020 04:07:13 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id f14sm17130948wrt.53.2020.10.19.04.07.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2020 04:07:12 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 19 Oct 2020 13:07:05 +0200 Message-Id: <20201019110706.857212-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201018064004.667741-1-andreas.rheinhardt@gmail.com> References: <20201018064004.667741-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/5] avcodec/on2avc: Avoid indirection when calling float dsp function X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- libavcodec/on2avc.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/libavcodec/on2avc.c b/libavcodec/on2avc.c index 625e733ca3..3b566e1e4b 100644 --- a/libavcodec/on2avc.c +++ b/libavcodec/on2avc.c @@ -46,7 +46,8 @@ enum WindowTypes { typedef struct On2AVCContext { AVCodecContext *avctx; - AVFloatDSPContext *fdsp; + void (*vector_fmul_window)(float *dst, const float *src0, + const float *src1, const float *win, int len); FFTContext mdct, mdct_half, mdct_small; FFTContext fft128, fft256, fft512, fft1024; void (*wtf)(struct On2AVCContext *ctx, float *out, float *in, int size); @@ -720,7 +721,7 @@ static int on2avc_reconstruct_channel_ext(On2AVCContext *c, AVFrame *dst, int of } memcpy(out, saved, 448 * sizeof(float)); - c->fdsp->vector_fmul_window(wout, saved + 448, buf, c->short_win, 64); + c->vector_fmul_window(wout, saved + 448, buf, c->short_win, 64); memcpy(wout + 128, buf + 64, 448 * sizeof(float)); memcpy(saved, buf + 512, 448 * sizeof(float)); memcpy(saved + 448, buf + 7*128 + 64, 64 * sizeof(float)); @@ -756,20 +757,20 @@ static int on2avc_reconstruct_channel(On2AVCContext *c, int channel, c->prev_window_type == WINDOW_TYPE_LONG_STOP) && (c->window_type == WINDOW_TYPE_LONG || c->window_type == WINDOW_TYPE_LONG_START)) { - c->fdsp->vector_fmul_window(out, saved, buf, c->long_win, 512); + c->vector_fmul_window(out, saved, buf, c->long_win, 512); } else { float *wout = out + 448; memcpy(out, saved, 448 * sizeof(float)); if (c->window_type == WINDOW_TYPE_8SHORT) { - c->fdsp->vector_fmul_window(wout + 0*128, saved + 448, buf + 0*128, c->short_win, 64); - c->fdsp->vector_fmul_window(wout + 1*128, buf + 0*128 + 64, buf + 1*128, c->short_win, 64); - c->fdsp->vector_fmul_window(wout + 2*128, buf + 1*128 + 64, buf + 2*128, c->short_win, 64); - c->fdsp->vector_fmul_window(wout + 3*128, buf + 2*128 + 64, buf + 3*128, c->short_win, 64); - c->fdsp->vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, c->short_win, 64); + c->vector_fmul_window(wout + 0*128, saved + 448, buf + 0*128, c->short_win, 64); + c->vector_fmul_window(wout + 1*128, buf + 0*128 + 64, buf + 1*128, c->short_win, 64); + c->vector_fmul_window(wout + 2*128, buf + 1*128 + 64, buf + 2*128, c->short_win, 64); + c->vector_fmul_window(wout + 3*128, buf + 2*128 + 64, buf + 3*128, c->short_win, 64); + c->vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, c->short_win, 64); memcpy(wout + 4*128, temp, 64 * sizeof(float)); } else { - c->fdsp->vector_fmul_window(wout, saved + 448, buf, c->short_win, 64); + c->vector_fmul_window(wout, saved + 448, buf, c->short_win, 64); memcpy(wout + 128, buf + 64, 448 * sizeof(float)); } } @@ -778,9 +779,9 @@ static int on2avc_reconstruct_channel(On2AVCContext *c, int channel, switch (c->window_type) { case WINDOW_TYPE_8SHORT: memcpy(saved, temp + 64, 64 * sizeof(float)); - c->fdsp->vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, c->short_win, 64); - c->fdsp->vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, c->short_win, 64); - c->fdsp->vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, c->short_win, 64); + c->vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, c->short_win, 64); + c->vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, c->short_win, 64); + c->vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, c->short_win, 64); memcpy(saved + 448, buf + 7*128 + 64, 64 * sizeof(float)); break; case WINDOW_TYPE_LONG_START: @@ -906,6 +907,7 @@ static av_cold void on2avc_free_vlcs(On2AVCContext *c) static av_cold int on2avc_decode_init(AVCodecContext *avctx) { On2AVCContext *c = avctx->priv_data; + AVFloatDSPContext *fdsp; int i; if (avctx->channels > 2U) { @@ -952,9 +954,11 @@ static av_cold int on2avc_decode_init(AVCodecContext *avctx) ff_fft_init(&c->fft256, 7, 0); ff_fft_init(&c->fft512, 8, 1); ff_fft_init(&c->fft1024, 9, 1); - c->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); - if (!c->fdsp) + fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); + if (!fdsp) return AVERROR(ENOMEM); + c->vector_fmul_window = fdsp->vector_fmul_window; + av_free(fdsp); if (init_vlc(&c->scale_diff, 9, ON2AVC_SCALE_DIFFS, ff_on2avc_scale_diff_bits, 1, 1, @@ -975,7 +979,6 @@ static av_cold int on2avc_decode_init(AVCodecContext *avctx) vlc_fail: av_log(avctx, AV_LOG_ERROR, "Cannot init VLC\n"); on2avc_free_vlcs(c); - av_freep(&c->fdsp); return AVERROR(ENOMEM); } @@ -991,8 +994,6 @@ static av_cold int on2avc_decode_close(AVCodecContext *avctx) ff_fft_end(&c->fft512); ff_fft_end(&c->fft1024); - av_freep(&c->fdsp); - on2avc_free_vlcs(c); return 0;