1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avutil/float_dsp: Unavpriv avpriv_scalarproduct_float_c()

Not worth the overhead of exporting it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
Andreas Rheinhardt
2025-03-15 22:26:26 +01:00
committed by James Almer
parent c389d9ac78
commit 0ccf385e13
13 changed files with 82 additions and 40 deletions

View File

@ -61,7 +61,8 @@ OBJS = ac3_parser.o \
vorbis_parser.o \
xiph.o \
SHLIBOBJS = timecode_internal.o \
SHLIBOBJS = float_scalarproduct.o \
timecode_internal.o \
# subsystems
include $(SRC_PATH)/libavcodec/aac/Makefile

View File

@ -90,7 +90,7 @@ float ff_amr_set_fixed_gain(float fixed_gain_factor, float fixed_mean_energy,
// Note 10^(0.05 * -10log(average x2)) = 1/sqrt((average x2)).
float val = fixed_gain_factor *
ff_exp10(0.05 *
(avpriv_scalarproduct_float_c(pred_table, prediction_error, 4) +
(ff_scalarproduct_float_c(pred_table, prediction_error, 4) +
energy_mean)) /
sqrtf(fixed_mean_energy ? fixed_mean_energy : 1.0);

View File

@ -193,7 +193,7 @@ void ff_adaptive_gain_control(float *out, const float *in, float speech_energ,
int size, float alpha, float *gain_mem)
{
int i;
float postfilter_energ = avpriv_scalarproduct_float_c(in, in, size);
float postfilter_energ = ff_scalarproduct_float_c(in, in, size);
float gain_scale_factor = 1.0;
float mem = *gain_mem;
@ -214,7 +214,7 @@ void ff_scale_vector_to_given_sum_of_squares(float *out, const float *in,
float sum_of_squares, const int n)
{
int i;
float scalefactor = avpriv_scalarproduct_float_c(in, in, n);
float scalefactor = ff_scalarproduct_float_c(in, in, n);
if (scalefactor)
scalefactor = sqrt(sum_of_squares / scalefactor);
for (i = 0; i < n; i++)

View File

@ -0,0 +1,19 @@
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/float_scalarproduct.c"

View File

@ -397,7 +397,7 @@ static void apply_gain_ctrl(float *v_out, const float *v_ref, const float *v_in)
int i;
for (i = 0; i < 160; i += 40) {
float res = avpriv_scalarproduct_float_c(v_ref + i, v_ref + i, 40);
float res = ff_scalarproduct_float_c(v_ref + i, v_ref + i, 40);
ff_scale_vector_to_given_sum_of_squares(v_out + i, v_in + i, res, 40);
}
}
@ -676,7 +676,7 @@ static void postfilter(QCELPContext *q, float *samples, float *lpc)
ff_tilt_compensation(&q->postfilter_tilt_mem, 0.3, pole_out + 10, 160);
ff_adaptive_gain_control(samples, pole_out + 10,
avpriv_scalarproduct_float_c(q->formant_mem + 10,
ff_scalarproduct_float_c(q->formant_mem + 10,
q->formant_mem + 10,
160),
160, 0.9375, &q->postfilter_agc_mem);

View File

@ -90,7 +90,7 @@ static av_cold int ra288_decode_init(AVCodecContext *avctx)
static void convolve(float *tgt, const float *src, int len, int n)
{
for (; n >= 0; n--)
tgt[n] = avpriv_scalarproduct_float_c(src, src - n, len);
tgt[n] = ff_scalarproduct_float_c(src, src - n, len);
}
@ -119,7 +119,7 @@ static void decode(RA288Context *ractx, float gain, int cb_coef)
for (i=0; i < 5; i++)
buffer[i] = codetable[cb_coef][i] * sumsum;
sum = avpriv_scalarproduct_float_c(buffer, buffer, 5);
sum = ff_scalarproduct_float_c(buffer, buffer, 5);
sum = FFMAX(sum, 5.0 / (1<<24));

View File

@ -412,7 +412,7 @@ static void decode_frame(SiprContext *ctx, SiprParameters *params,
convolute_with_sparse(fixed_vector, &fixed_cb, impulse_response,
SUBFR_SIZE);
avg_energy = (0.01 + avpriv_scalarproduct_float_c(fixed_vector,
avg_energy = (0.01 + ff_scalarproduct_float_c(fixed_vector,
fixed_vector,
SUBFR_SIZE)) /
SUBFR_SIZE;
@ -456,7 +456,7 @@ static void decode_frame(SiprContext *ctx, SiprParameters *params,
if (ctx->mode == MODE_5k0) {
for (i = 0; i < subframe_count; i++) {
float energy = avpriv_scalarproduct_float_c(ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i * SUBFR_SIZE,
float energy = ff_scalarproduct_float_c(ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i * SUBFR_SIZE,
ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i * SUBFR_SIZE,
SUBFR_SIZE);
ff_adaptive_gain_control(&synth[i * SUBFR_SIZE],

View File

@ -163,11 +163,11 @@ static float acelp_decode_gain_codef(float gain_corr_factor, const float *fc_v,
const float *ma_prediction_coeff,
int subframe_size, int ma_pred_order)
{
mr_energy += avpriv_scalarproduct_float_c(quant_energy, ma_prediction_coeff,
mr_energy += ff_scalarproduct_float_c(quant_energy, ma_prediction_coeff,
ma_pred_order);
mr_energy = gain_corr_factor * exp(M_LN10 / 20. * mr_energy) /
sqrt((0.01 + avpriv_scalarproduct_float_c(fc_v, fc_v, subframe_size)));
sqrt((0.01 + ff_scalarproduct_float_c(fc_v, fc_v, subframe_size)));
return mr_energy;
}

View File

@ -559,7 +559,7 @@ static int kalman_smoothen(WMAVoiceContext *s, int pitch,
/* find best fitting point in history */
do {
dot = avpriv_scalarproduct_float_c(in, ptr, size);
dot = ff_scalarproduct_float_c(in, ptr, size);
if (dot > optimal_gain) {
optimal_gain = dot;
best_hist_ptr = ptr;
@ -568,7 +568,7 @@ static int kalman_smoothen(WMAVoiceContext *s, int pitch,
if (optimal_gain <= 0)
return -1;
dot = avpriv_scalarproduct_float_c(best_hist_ptr, best_hist_ptr, size);
dot = ff_scalarproduct_float_c(best_hist_ptr, best_hist_ptr, size);
if (dot <= 0) // would be 1.0
return -1;
@ -598,8 +598,8 @@ static float tilt_factor(const float *lpcs, int n_lpcs)
{
float rh0, rh1;
rh0 = 1.0 + avpriv_scalarproduct_float_c(lpcs, lpcs, n_lpcs);
rh1 = lpcs[0] + avpriv_scalarproduct_float_c(lpcs, &lpcs[1], n_lpcs - 1);
rh0 = 1.0 + ff_scalarproduct_float_c(lpcs, lpcs, n_lpcs);
rh1 = lpcs[0] + ff_scalarproduct_float_c(lpcs, &lpcs[1], n_lpcs - 1);
return rh1 / rh0;
}
@ -699,7 +699,7 @@ static void calc_input_response(WMAVoiceContext *s, float *lpcs_src,
-1.8 * tilt_factor(coeffs_dst, remainder - 1),
coeffs_dst, remainder);
}
sq = (1.0 / 64.0) * sqrtf(1 / avpriv_scalarproduct_float_c(coeffs_dst, coeffs_dst,
sq = (1.0 / 64.0) * sqrtf(1 / ff_scalarproduct_float_c(coeffs_dst, coeffs_dst,
remainder));
for (n = 0; n < remainder; n++)
coeffs_dst[n] *= sq;
@ -1378,7 +1378,7 @@ static void synth_block_fcb_acb(WMAVoiceContext *s, GetBitContext *gb,
/* Calculate gain for adaptive & fixed codebook signal.
* see ff_amr_set_fixed_gain(). */
idx = get_bits(gb, 7);
fcb_gain = expf(avpriv_scalarproduct_float_c(s->gain_pred_err,
fcb_gain = expf(ff_scalarproduct_float_c(s->gain_pred_err,
gain_coeff, 6) -
5.2409161640 + wmavoice_gain_codebook_fcb[idx]);
acb_gain = wmavoice_gain_codebook_acb[idx];

View File

@ -140,6 +140,7 @@ OBJS = adler32.o \
file_open.o \
float_dsp.o \
float2half.o \
float_scalarproduct.o \
film_grain_params.o \
fixed_dsp.o \
frame.o \

View File

@ -121,17 +121,6 @@ static void butterflies_float_c(float *restrict v1, float *restrict v2,
}
}
float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len)
{
float p = 0.0;
int i;
for (i = 0; i < len; i++)
p += v1[i] * v2[i];
return p;
}
double ff_scalarproduct_double_c(const double *v1, const double *v2,
size_t len)
{
@ -159,7 +148,7 @@ av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact)
fdsp->vector_fmul_add = vector_fmul_add_c;
fdsp->vector_fmul_reverse = vector_fmul_reverse_c;
fdsp->butterflies_float = butterflies_float_c;
fdsp->scalarproduct_float = avpriv_scalarproduct_float_c;
fdsp->scalarproduct_float = ff_scalarproduct_float_c;
fdsp->scalarproduct_double = ff_scalarproduct_double_c;
#if ARCH_AARCH64

View File

@ -215,7 +215,7 @@ typedef struct AVFloatDSPContext {
*
* @return sum of elementwise products
*/
float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len);
float ff_scalarproduct_float_c(const float *v1, const float *v2, int len);
/**
* Return the scalar product of two vectors of doubles.

View File

@ -0,0 +1,32 @@
/*
* Copyright 2005 Balatoni Denes
* Copyright 2006 Loren Merritt
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "float_dsp.h"
float ff_scalarproduct_float_c(const float *v1, const float *v2, int len)
{
float p = 0.0;
for (int i = 0; i < len; i++)
p += v1[i] * v2[i];
return p;
}