From patchwork Thu Jul 20 19:01:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 4397 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.76 with SMTP id 73csp2507196vsb; Thu, 20 Jul 2017 12:08:28 -0700 (PDT) X-Received: by 10.223.135.175 with SMTP id b44mr7772124wrb.48.1500577708007; Thu, 20 Jul 2017 12:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500577707; cv=none; d=google.com; s=arc-20160816; b=qjZs23BGrXqBApKziHY9iA7D8paR+f/1DwxeDqnURbR5bgU4jj3LwIO4v4d2a8tfOw M2M4tnHz8LnCzyyNRGUD00uWBg+tJtOwjg81YZQqf75835QkkfeDq1D2vbw//WhoazZo Nr6IP+Eva8YbRuTuKNKA8mF9+Uwh7tRp9H/Qbdfo7KIePdsk0C+E/AtAgnP/VFJsByEK qSQXHNDf9CuiHc3FO6+7Ow0Vn8vpE/QwS+Lnj8tYivGPYK0XJ+j1sGc577/v5TKUBS/Y qol4AhiaQNhhcvxtyhdARbJMIGThdUvpvqfrCt6wosS0JzcCmsG+8T12kiGiO2j2ACfS cJ4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=7lKegHXwzQjH/KtKzBIGVmu2qjyUqiNemqu342f/Klg=; b=ukR9BbtSIUFWQE8Kd36Q5f/lVrn8iDWo7HensJbsGhwu01CbjJpPq19DBhmeaJxUze wI309DRubiCEFAXbvq7t0muNQHpyd6wnb96yH+5DtAwF9xYe57w1zDwmTFoeg284WT/D e+BlMCLyGEu08HwpCCLJsynL/i3jj5zubisAdthBnr3brPMrvcWSH0rs0fUts3+Xo+25 K5+SUeNqWeClWvNwh496MOvMRvUCGVyOUHqzQIqE58v7qAIJ+KlgmDep8No7UW+HkuP1 uzAoSztAbjDzJ9i0TTskqAmd3CjYZP2GYSM4RXXm3UfzPmAtcpGb3FmN1/6nPKhYwjNw 70DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.b=lYsK+uf8; 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=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 y23si493768wra.384.2017.07.20.12.08.27; Thu, 20 Jul 2017 12:08: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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.b=lYsK+uf8; 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=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 23DEE689A70; Thu, 20 Jul 2017 22:08:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt0-f194.google.com (mail-qt0-f194.google.com [209.85.216.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 840D8689958 for ; Thu, 20 Jul 2017 22:08:09 +0300 (EEST) Received: by mail-qt0-f194.google.com with SMTP id 50so4577326qtz.0 for ; Thu, 20 Jul 2017 12:08:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=oHLbA5RXR1fs0W/6WTIVE8812BXZ3EqIsAXjSS0MMw0=; b=lYsK+uf8se+ETunKrjovOPnacUpxs2VlYcL5Prhnt8csZNc9sqS5FxgdCjnxN5Q1Y9 5HGNK+5dK7jrjigcQlysV2afizwIURGXyxx5TD9Wkev/hUk8jdjusZmunHPa1SWBMEFw 2Ui9Sg8drznIdXVBlwNj05JtSGnuk4I2+i3YCFS/28xGk8X23DwYZSLYOD7V3lH3FD24 Bhy6Y8/WSzwfUplVhWWa/QsSB4mETq0lcy1smV9jrynBzwGOOK7LVPdC5j6xXQuB9CA9 VK+XDWEkOTaW0dVMGwk+RCujzNDMzCmRx71FjCplQLjPlOG+h4gGOMJzkmGy7QkjNWoU AuqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=oHLbA5RXR1fs0W/6WTIVE8812BXZ3EqIsAXjSS0MMw0=; b=B9GJU8uwDOv3Rr7bnJQghy+SlptBfcAMEFAMjiKJHQvMvFyU7049VCCAefEKz03L+w hM0f1422wZ0TMrTTqcw6AtluCW2E4s5tIMUSWTm355H6Gn8ezHR3ZaOanwLaYfFMqHHb zPcRs7TlXwKCp91VMXWuRxdVh5r+/Y57FBzYYna8gIgj9H5URf3y3drjsHxfEiZQO3jE YI7CJbSSAqmkdJx5nntawjCrhVzNSEJlaGqRJ6HKiCFu+eY84iXHrSohsYvNtred3/Wf oAnPIjiR5F2/ZrMXsQ8Cz2Y8ko8xhbTZriJI9oaBH885lYMtL8Lzv4JP2N2UTe5PK5c2 EG2w== X-Gm-Message-State: AIVw112iQiJCTX7URc5xw0wT4dKuAx1ezErEOyfnXzFet/pxzYwSbvMU UHQ+4PiDud8X8yAu X-Received: by 10.237.61.123 with SMTP id h56mr6237735qtf.1.1500577330991; Thu, 20 Jul 2017 12:02:10 -0700 (PDT) Received: from localhost.localdomain ([181.231.116.134]) by smtp.gmail.com with ESMTPSA id y21sm2257230qkg.97.2017.07.20.12.02.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Jul 2017 12:02:10 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 20 Jul 2017 16:01:31 -0300 Message-Id: <20170720190131.6016-1-jamrial@gmail.com> X-Mailer: git-send-email 2.13.3 Subject: [FFmpeg-devel] [PATCH] avcodec/atrac3p: use float_dsp in ff_atrac3p_power_compensation 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: James Almer --- Fate passes, so i guess the aligment requirements are met. libavcodec/atrac3plus.h | 5 +++-- libavcodec/atrac3plusdec.c | 36 ++++++++++++++++++------------------ libavcodec/atrac3plusdsp.c | 8 ++++---- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/libavcodec/atrac3plus.h b/libavcodec/atrac3plus.h index a33c38a3ee..3c39e293c7 100644 --- a/libavcodec/atrac3plus.h +++ b/libavcodec/atrac3plus.h @@ -199,13 +199,14 @@ void ff_atrac3p_generate_tones(Atrac3pChanUnitCtx *ch_unit, AVFloatDSPContext *f * Perform power compensation aka noise dithering. * * @param[in] ctx ptr to the channel context + * @param[in] fdsp pointer to float DSP context * @param[in] ch_index which channel to process * @param[in,out] sp ptr to channel spectrum to process * @param[in] rng_index indicates which RNG table to use * @param[in] sb_num which subband to process */ -void ff_atrac3p_power_compensation(Atrac3pChanUnitCtx *ctx, int ch_index, - float *sp, int rng_index, int sb_num); +void ff_atrac3p_power_compensation(Atrac3pChanUnitCtx *ctx, AVFloatDSPContext *fdsp, + int ch_index, float *sp, int rng_index, int sb_num); /** * Regular IMDCT and windowing without overlapping, diff --git a/libavcodec/atrac3plusdec.c b/libavcodec/atrac3plusdec.c index 7a2ab3ef95..666d1a5c01 100644 --- a/libavcodec/atrac3plusdec.c +++ b/libavcodec/atrac3plusdec.c @@ -198,7 +198,7 @@ static av_cold int atrac3p_decode_init(AVCodecContext *avctx) return 0; } -static void decode_residual_spectrum(Atrac3pChanUnitCtx *ctx, +static void decode_residual_spectrum(ATRAC3PContext *ctx, Atrac3pChanUnitCtx *ch_unit, float out[2][ATRAC3P_FRAME_SAMPLES], int num_channels, AVCodecContext *avctx) @@ -209,17 +209,17 @@ static void decode_residual_spectrum(Atrac3pChanUnitCtx *ctx, /* calculate RNG table index for each subband */ int sb_RNG_index[ATRAC3P_SUBBANDS] = { 0 }; - if (ctx->mute_flag) { + if (ch_unit->mute_flag) { for (ch = 0; ch < num_channels; ch++) memset(out[ch], 0, ATRAC3P_FRAME_SAMPLES * sizeof(*out[ch])); return; } - for (qu = 0, RNG_index = 0; qu < ctx->used_quant_units; qu++) - RNG_index += ctx->channels[0].qu_sf_idx[qu] + - ctx->channels[1].qu_sf_idx[qu]; + for (qu = 0, RNG_index = 0; qu < ch_unit->used_quant_units; qu++) + RNG_index += ch_unit->channels[0].qu_sf_idx[qu] + + ch_unit->channels[1].qu_sf_idx[qu]; - for (sb = 0; sb < ctx->num_coded_subbands; sb++, RNG_index += 128) + for (sb = 0; sb < ch_unit->num_coded_subbands; sb++, RNG_index += 128) sb_RNG_index[sb] = RNG_index & 0x3FC; /* inverse quant and power compensation */ @@ -227,35 +227,35 @@ static void decode_residual_spectrum(Atrac3pChanUnitCtx *ctx, /* clear channel's residual spectrum */ memset(out[ch], 0, ATRAC3P_FRAME_SAMPLES * sizeof(*out[ch])); - for (qu = 0; qu < ctx->used_quant_units; qu++) { - src = &ctx->channels[ch].spectrum[ff_atrac3p_qu_to_spec_pos[qu]]; + for (qu = 0; qu < ch_unit->used_quant_units; qu++) { + src = &ch_unit->channels[ch].spectrum[ff_atrac3p_qu_to_spec_pos[qu]]; dst = &out[ch][ff_atrac3p_qu_to_spec_pos[qu]]; nspeclines = ff_atrac3p_qu_to_spec_pos[qu + 1] - ff_atrac3p_qu_to_spec_pos[qu]; - if (ctx->channels[ch].qu_wordlen[qu] > 0) { - q = ff_atrac3p_sf_tab[ctx->channels[ch].qu_sf_idx[qu]] * - ff_atrac3p_mant_tab[ctx->channels[ch].qu_wordlen[qu]]; + if (ch_unit->channels[ch].qu_wordlen[qu] > 0) { + q = ff_atrac3p_sf_tab[ch_unit->channels[ch].qu_sf_idx[qu]] * + ff_atrac3p_mant_tab[ch_unit->channels[ch].qu_wordlen[qu]]; for (i = 0; i < nspeclines; i++) dst[i] = src[i] * q; } } - for (sb = 0; sb < ctx->num_coded_subbands; sb++) - ff_atrac3p_power_compensation(ctx, ch, &out[ch][0], + for (sb = 0; sb < ch_unit->num_coded_subbands; sb++) + ff_atrac3p_power_compensation(ch_unit, ctx->fdsp, ch, &out[ch][0], sb_RNG_index[sb], sb); } - if (ctx->unit_type == CH_UNIT_STEREO) { - for (sb = 0; sb < ctx->num_coded_subbands; sb++) { - if (ctx->swap_channels[sb]) { + if (ch_unit->unit_type == CH_UNIT_STEREO) { + for (sb = 0; sb < ch_unit->num_coded_subbands; sb++) { + if (ch_unit->swap_channels[sb]) { for (i = 0; i < ATRAC3P_SUBBAND_SAMPLES; i++) FFSWAP(float, out[0][sb * ATRAC3P_SUBBAND_SAMPLES + i], out[1][sb * ATRAC3P_SUBBAND_SAMPLES + i]); } /* flip coefficients' sign if requested */ - if (ctx->negate_coeffs[sb]) + if (ch_unit->negate_coeffs[sb]) for (i = 0; i < ATRAC3P_SUBBAND_SAMPLES; i++) out[1][sb * ATRAC3P_SUBBAND_SAMPLES + i] = -(out[1][sb * ATRAC3P_SUBBAND_SAMPLES + i]); } @@ -369,7 +369,7 @@ static int atrac3p_decode_frame(AVCodecContext *avctx, void *data, avctx)) < 0) return ret; - decode_residual_spectrum(&ctx->ch_units[ch_block], ctx->samples, + decode_residual_spectrum(ctx, &ctx->ch_units[ch_block], ctx->samples, channels_to_process, avctx); reconstruct_frame(ctx, &ctx->ch_units[ch_block], channels_to_process, avctx); diff --git a/libavcodec/atrac3plusdsp.c b/libavcodec/atrac3plusdsp.c index d089588274..5f7409ade0 100644 --- a/libavcodec/atrac3plusdsp.c +++ b/libavcodec/atrac3plusdsp.c @@ -415,11 +415,12 @@ static const int subband_to_qu[17] = { 0, 8, 12, 16, 18, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 }; -void ff_atrac3p_power_compensation(Atrac3pChanUnitCtx *ctx, int ch_index, +void ff_atrac3p_power_compensation(Atrac3pChanUnitCtx *ctx, AVFloatDSPContext *fdsp, int ch_index, float *sp, int rng_index, int sb) { AtracGainInfo *g1, *g2; - float pwcsp[ATRAC3P_SUBBAND_SAMPLES], *dst, grp_lev, qu_lev; + LOCAL_ALIGNED_32(float, pwcsp, [ATRAC3P_SUBBAND_SAMPLES]); + float *dst, grp_lev, qu_lev; int i, gain_lev, gcv = 0, qu, nsp; int swap_ch = (ctx->unit_type == CH_UNIT_STEREO && ctx->swap_channels[sb]) ? 1 : 0; @@ -456,8 +457,7 @@ void ff_atrac3p_power_compensation(Atrac3pChanUnitCtx *ctx, int ch_index, dst = &sp[ff_atrac3p_qu_to_spec_pos[qu]]; nsp = ff_atrac3p_qu_to_spec_pos[qu + 1] - ff_atrac3p_qu_to_spec_pos[qu]; - for (i = 0; i < nsp; i++) - dst[i] += pwcsp[i] * qu_lev; + fdsp->vector_fmac_scalar(dst, pwcsp, qu_lev, nsp); } }