History

floatdsp: move scalarproduct_float from dsputil to avfloatdsp.

This makes the aac decoder and all voice codecs independent of dsputil.

Ronald S. Bultje committed 13 years ago

Commit d56668b1 parent 5959bfa23 files · +142 −141Browse files

Unified · Split

23 files
  1. libavcodec/aac.h +0 −1
  2. libavcodec/aacdec.c +1 −2
  3. libavcodec/acelp_pitch_delay.c +2 −2
  4. libavcodec/acelp_vectors.c +3 −3
  5. libavcodec/amrnbdec.c +10 −10
  6. libavcodec/amrwbdec.c +17 −16
  7. libavcodec/arm/dsputil_init_neon.c +0 −3
  8. libavcodec/arm/dsputil_neon.S +0 −13
  9. libavcodec/dsputil.c +0 −12
  10. libavcodec/dsputil.h +0 −18
  11. libavcodec/qcelpdec.c +8 −9
  12. libavcodec/ra288.c +2 −2
  13. libavcodec/sipr.c +8 −7
  14. libavcodec/sipr16k.c +4 −4
  15. libavcodec/wmavoice.c +9 −7
  16. libavcodec/x86/dsputil.asm +0 −26
  17. libavcodec/x86/dsputil_mmx.c +0 −6
  18. libavutil/arm/float_dsp_init_neon.c +3 −0
  19. libavutil/arm/float_dsp_neon.S +13 −0
  20. libavutil/float_dsp.c +12 −0
  21. libavutil/float_dsp.h +22 −0
  22. libavutil/x86/float_dsp.asm +25 −0
  23. libavutil/x86/float_dsp_init.c +3 −0
libavcodec/aac.h+0−1
@@ -291,7 +291,6 @@ typedef struct AACContext { · 290 unmodified lines
291291 FFTContext mdct;
292292 FFTContext mdct_small;
293293 FFTContext mdct_ltp;
294− DSPContext dsp;
295294 FmtConvertContext fmt_conv;
296295 AVFloatDSPContext fdsp;
297296 int random_state;
libavcodec/aacdec.c+1−2
@@ -895,7 +895,6 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) · 894 unmodified lines
895895
896896 ff_aac_sbr_init();
897897
898− ff_dsputil_init(&ac->dsp, avctx);
899898 ff_fmt_convert_init(&ac->fmt_conv, avctx);
900899 avpriv_float_dsp_init(&ac->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
901900
@@ -1358,7 +1357,7 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], · 456 unmodified lines
13581357 cfo[k] = ac->random_state;
13591358 }
13601359
1361− band_energy = ac->dsp.scalarproduct_float(cfo, cfo, off_len);
1360+ band_energy = ac->fdsp.scalarproduct_float(cfo, cfo, off_len);
13621361 scale = sf[idx] / sqrtf(band_energy);
13631362 ac->fdsp.vector_fmul_scalar(cfo, cfo, scale, off_len);
13641363 }
libavcodec/acelp_pitch_delay.c+2−2
@@ -21,9 +21,9 @@ · 20 unmodified lines
2121 */
2222
2323 #include "libavutil/common.h"
24+#include "libavutil/float_dsp.h"
2425 #include "libavutil/mathematics.h"
2526 #include "avcodec.h"
26−#include "dsputil.h"
2727 #include "acelp_pitch_delay.h"
2828 #include "celp_math.h"
2929
@@ -120,7 +120,7 @@ float ff_amr_set_fixed_gain(float fixed_gain_factor, float fixed_mean_energy, · 90 unmodified lines
120120 // Note 10^(0.05 * -10log(average x2)) = 1/sqrt((average x2)).
121121 float val = fixed_gain_factor *
122122 exp2f(M_LOG2_10 * 0.05 *
123− (ff_scalarproduct_float_c(pred_table, prediction_error, 4) +
123+ (avpriv_scalarproduct_float_c(pred_table, prediction_error, 4) +
124124 energy_mean)) /
125125 sqrtf(fixed_mean_energy);
126126
libavcodec/acelp_vectors.c+3−3
@@ -23,8 +23,8 @@ · 22 unmodified lines
2323 #include <inttypes.h>
2424
2525 #include "libavutil/common.h"
26+#include "libavutil/float_dsp.h"
2627 #include "avcodec.h"
27−#include "dsputil.h"
2828 #include "acelp_vectors.h"
2929
3030 const uint8_t ff_fc_2pulses_9bits_track1[16] =
@@ -183,7 +183,7 @@ void ff_adaptive_gain_control(float *out, const float *in, float speech_energ, · 152 unmodified lines
183183 int size, float alpha, float *gain_mem)
184184 {
185185 int i;
186− float postfilter_energ = ff_scalarproduct_float_c(in, in, size);
186+ float postfilter_energ = avpriv_scalarproduct_float_c(in, in, size);
187187 float gain_scale_factor = 1.0;
188188 float mem = *gain_mem;
189189
@@ -204,7 +204,7 @@ void ff_scale_vector_to_given_sum_of_squares(float *out, const float *in, · 14 unmodified lines
204204 float sum_of_squares, const int n)
205205 {
206206 int i;
207− float scalefactor = ff_scalarproduct_float_c(in, in, n);
207+ float scalefactor = avpriv_scalarproduct_float_c(in, in, n);
208208 if (scalefactor)
209209 scalefactor = sqrt(sum_of_squares / scalefactor);
210210 for (i = 0; i < n; i++)
libavcodec/amrnbdec.c+10−10
@@ -44,8 +44,8 @@ · 43 unmodified lines
4444 #include <math.h>
4545
4646 #include "libavutil/channel_layout.h"
47+#include "libavutil/float_dsp.h"
4748 #include "avcodec.h"
48−#include "dsputil.h"
4949 #include "libavutil/common.h"
5050 #include "celp_filters.h"
5151 #include "acelp_filters.h"
@@ -794,8 +794,8 @@ static int synthesis(AMRContext *p, float *lpc, · 742 unmodified lines
794794
795795 // emphasize pitch vector contribution
796796 if (p->pitch_gain[4] > 0.5 && !overflow) {
797− float energy = ff_scalarproduct_float_c(excitation, excitation,
798− AMR_SUBFRAME_SIZE);
797+ float energy = avpriv_scalarproduct_float_c(excitation, excitation,
798+ AMR_SUBFRAME_SIZE);
799799 float pitch_factor =
800800 p->pitch_gain[4] *
801801 (p->cur_frame_mode == MODE_12k2 ?
@@ -871,8 +871,8 @@ static float tilt_factor(float *lpc_n, float *lpc_d) · 69 unmodified lines
871871 ff_celp_lp_synthesis_filterf(hf, lpc_d, hf, AMR_TILT_RESPONSE,
872872 LP_FILTER_ORDER);
873873
874− rh0 = ff_scalarproduct_float_c(hf, hf, AMR_TILT_RESPONSE);
875− rh1 = ff_scalarproduct_float_c(hf, hf + 1, AMR_TILT_RESPONSE - 1);
874+ rh0 = avpriv_scalarproduct_float_c(hf, hf, AMR_TILT_RESPONSE);
875+ rh1 = avpriv_scalarproduct_float_c(hf, hf + 1, AMR_TILT_RESPONSE - 1);
876876
877877 // The spec only specifies this check for 12.2 and 10.2 kbit/s
878878 // modes. But in the ref source the tilt is always non-negative.
@@ -892,8 +892,8 @@ static void postfilter(AMRContext *p, float *lpc, float *buf_out) · 13 unmodified lines
892892 int i;
893893 float *samples = p->samples_in + LP_FILTER_ORDER; // Start of input
894894
895− float speech_gain = ff_scalarproduct_float_c(samples, samples,
896− AMR_SUBFRAME_SIZE);
895+ float speech_gain = avpriv_scalarproduct_float_c(samples, samples,
896+ AMR_SUBFRAME_SIZE);
897897
898898 float pole_out[AMR_SUBFRAME_SIZE + LP_FILTER_ORDER]; // Output of pole filter
899899 const float *gamma_n, *gamma_d; // Formant filter factor table
@@ -998,9 +998,9 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data, · 98 unmodified lines
998998
999999 p->fixed_gain[4] =
10001000 ff_amr_set_fixed_gain(fixed_gain_factor,
1001− ff_scalarproduct_float_c(p->fixed_vector,
1002− p->fixed_vector,
1003− AMR_SUBFRAME_SIZE) /
1001+ avpriv_scalarproduct_float_c(p->fixed_vector,
1002+ p->fixed_vector,
1003+ AMR_SUBFRAME_SIZE) /
10041004 AMR_SUBFRAME_SIZE,
10051005 p->prediction_error,
10061006 energy_mean[p->cur_frame_mode], energy_pred_fac);
libavcodec/amrwbdec.c+17−16
@@ -26,10 +26,10 @@ · 25 unmodified lines
2626
2727 #include "libavutil/channel_layout.h"
2828 #include "libavutil/common.h"
29+#include "libavutil/float_dsp.h"
2930 #include "libavutil/lfg.h"
3031
3132 #include "avcodec.h"
32−#include "dsputil.h"
3333 #include "lsp.h"
3434 #include "celp_filters.h"
3535 #include "acelp_filters.h"
@@ -595,11 +595,11 @@ static void pitch_sharpening(AMRWBContext *ctx, float *fixed_vector) · 559 unmodified lines
595595 static float voice_factor(float *p_vector, float p_gain,
596596 float *f_vector, float f_gain)
597597 {
598− double p_ener = (double) ff_scalarproduct_float_c(p_vector, p_vector,
599− AMRWB_SFR_SIZE) *
598+ double p_ener = (double) avpriv_scalarproduct_float_c(p_vector, p_vector,
599+ AMRWB_SFR_SIZE) *
600600 p_gain * p_gain;
601− double f_ener = (double) ff_scalarproduct_float_c(f_vector, f_vector,
602− AMRWB_SFR_SIZE) *
601+ double f_ener = (double) avpriv_scalarproduct_float_c(f_vector, f_vector,
602+ AMRWB_SFR_SIZE) *
603603 f_gain * f_gain;
604604
605605 return (p_ener - f_ener) / (p_ener + f_ener);
@@ -768,8 +768,8 @@ static void synthesis(AMRWBContext *ctx, float *lpc, float *excitation, · 162 unmodified lines
768768 /* emphasize pitch vector contribution in low bitrate modes */
769769 if (ctx->pitch_gain[0] > 0.5 && ctx->fr_cur_mode <= MODE_8k85) {
770770 int i;
771− float energy = ff_scalarproduct_float_c(excitation, excitation,
772− AMRWB_SFR_SIZE);
771+ float energy = avpriv_scalarproduct_float_c(excitation, excitation,
772+ AMRWB_SFR_SIZE);
773773
774774 // XXX: Weird part in both ref code and spec. A unknown parameter
775775 // {beta} seems to be identical to the current pitch gain
@@ -828,9 +828,9 @@ static void upsample_5_4(float *out, const float *in, int o_size) · 52 unmodified lines
828828 i++;
829829
830830 for (k = 1; k < 5; k++) {
831− out[i] = ff_scalarproduct_float_c(in0 + int_part,
832− upsample_fir[4 - frac_part],
833− UPS_MEM_SIZE);
831+ out[i] = avpriv_scalarproduct_float_c(in0 + int_part,
832+ upsample_fir[4 - frac_part],
833+ UPS_MEM_SIZE);
834834 int_part++;
835835 frac_part--;
836836 i++;
@@ -856,8 +856,8 @@ static float find_hb_gain(AMRWBContext *ctx, const float *synth, · 19 unmodified lines
856856 if (ctx->fr_cur_mode == MODE_23k85)
857857 return qua_hb_gain[hb_idx] * (1.0f / (1 << 14));
858858
859− tilt = ff_scalarproduct_float_c(synth, synth + 1, AMRWB_SFR_SIZE - 1) /
860− ff_scalarproduct_float_c(synth, synth, AMRWB_SFR_SIZE);
859+ tilt = avpriv_scalarproduct_float_c(synth, synth + 1, AMRWB_SFR_SIZE - 1) /
860+ avpriv_scalarproduct_float_c(synth, synth, AMRWB_SFR_SIZE);
861861
862862 /* return gain bounded by [0.1, 1.0] */
863863 return av_clipf((1.0 - FFMAX(0.0, tilt)) * (1.25 - 0.25 * wsp), 0.1, 1.0);
@@ -876,7 +876,8 @@ static void scaled_hb_excitation(AMRWBContext *ctx, float *hb_exc, · 12 unmodified lines
876876 const float *synth_exc, float hb_gain)
877877 {
878878 int i;
879− float energy = ff_scalarproduct_float_c(synth_exc, synth_exc, AMRWB_SFR_SIZE);
879+ float energy = avpriv_scalarproduct_float_c(synth_exc, synth_exc,
880+ AMRWB_SFR_SIZE);
880881
881882 /* Generate a white-noise excitation */
882883 for (i = 0; i < AMRWB_SFR_SIZE_16k; i++)
@@ -1168,9 +1169,9 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, · 285 unmodified lines
11681169
11691170 ctx->fixed_gain[0] =
11701171 ff_amr_set_fixed_gain(fixed_gain_factor,
1171− ff_scalarproduct_float_c(ctx->fixed_vector,
1172− ctx->fixed_vector,
1173− AMRWB_SFR_SIZE) /
1172+ avpriv_scalarproduct_float_c(ctx->fixed_vector,
1173+ ctx->fixed_vector,
1174+ AMRWB_SFR_SIZE) /
11741175 AMRWB_SFR_SIZE,
11751176 ctx->prediction_error,
11761177 ENERGY_MEAN, energy_pred_fac);
libavcodec/arm/dsputil_init_neon.c+0−3
@@ -142,8 +142,6 @@ void ff_avg_h264_chroma_mc8_neon(uint8_t *, uint8_t *, int, int, int, int); · 141 unmodified lines
142142 void ff_avg_h264_chroma_mc4_neon(uint8_t *, uint8_t *, int, int, int, int);
143143 void ff_avg_h264_chroma_mc2_neon(uint8_t *, uint8_t *, int, int, int, int);
144144
145−float ff_scalarproduct_float_neon(const float *v1, const float *v2, int len);
146−
147145 void ff_vector_clipf_neon(float *dst, const float *src, float min, float max,
148146 int len);
149147 void ff_vector_clip_int32_neon(int32_t *dst, const int32_t *src, int32_t min,
@@ -293,7 +291,6 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx) · 143 unmodified lines
293291 c->avg_h264_qpel_pixels_tab[1][15] = ff_avg_h264_qpel8_mc33_neon;
294292 }
295293
296− c->scalarproduct_float = ff_scalarproduct_float_neon;
297294 c->vector_clipf = ff_vector_clipf_neon;
298295 c->vector_clip_int32 = ff_vector_clip_int32_neon;
299296
libavcodec/arm/dsputil_neon.S+0−13
@@ -531,19 +531,6 @@ function ff_add_pixels_clamped_neon, export=1 · 530 unmodified lines
531531 bx lr
532532 endfunc
533533
534−function ff_scalarproduct_float_neon, export=1
535− vmov.f32 q2, #0.0
536−1: vld1.32 {q0},[r0,:128]!
537− vld1.32 {q1},[r1,:128]!
538− vmla.f32 q2, q0, q1
539− subs r2, r2, #4
540− bgt 1b
541− vadd.f32 d0, d4, d5
542− vpadd.f32 d0, d0, d0
543−NOVFP vmov.32 r0, d0[0]
544− bx lr
545−endfunc
546−
547534 function ff_vector_clipf_neon, export=1
548535 VFP vdup.32 q1, d0[1]
549536 VFP vdup.32 q0, d0[0]
libavcodec/dsputil.c+0−12
@@ -2353,17 +2353,6 @@ WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c) · 2352 unmodified lines
23532353 WRAPPER8_16_SQ(rd8x8_c, rd16_c)
23542354 WRAPPER8_16_SQ(bit8x8_c, bit16_c)
23552355
2356−float ff_scalarproduct_float_c(const float *v1, const float *v2, int len)
2357−{
2358− float p = 0.0;
2359− int i;
2360−
2361− for (i = 0; i < len; i++)
2362− p += v1[i] * v2[i];
2363−
2364− return p;
2365−}
2366−
23672356 static inline uint32_t clipf_c_one(uint32_t a, uint32_t mini,
23682357 uint32_t maxi, uint32_t maxisign)
23692358 {
@@ -2694,7 +2683,6 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx) · 324 unmodified lines
26942683 c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c;
26952684 c->apply_window_int16 = apply_window_int16_c;
26962685 c->vector_clip_int32 = vector_clip_int32_c;
2697− c->scalarproduct_float = ff_scalarproduct_float_c;
26982686
26992687 c->shrink[0]= av_image_copy_plane;
27002688 c->shrink[1]= ff_shrink22;
libavcodec/dsputil.h+0−18
@@ -342,13 +342,6 @@ typedef struct DSPContext { · 341 unmodified lines
342342
343343 /* assume len is a multiple of 8, and arrays are 16-byte aligned */
344344 void (*vector_clipf)(float *dst /* align 16 */, const float *src /* align 16 */, float min, float max, int len /* align 16 */);
345− /**
346− * Calculate the scalar product of two vectors of floats.
347− * @param v1 first vector, 16-byte aligned
348− * @param v2 second vector, 16-byte aligned
349− * @param len length of vectors, multiple of 4
350− */
351− float (*scalarproduct_float)(const float *v1, const float *v2, int len);
352345
353346 /* (I)DCT */
354347 void (*fdct)(DCTELEM *block/* align 16*/);
@@ -454,17 +447,6 @@ void ff_dsputil_init(DSPContext* p, AVCodecContext *avctx); · 99 unmodified lines
454447
455448 int ff_check_alignment(void);
456449
457−/**
458− * Return the scalar product of two vectors.
459− *
460− * @param v1 first input vector
461− * @param v2 first input vector
462− * @param len number of elements
463− *
464− * @return sum of elementwise products
465− */
466−float ff_scalarproduct_float_c(const float *v1, const float *v2, int len);
467−
468450 /**
469451 * permute block according to permuatation.
470452 * @param last last non zero element in scantable order
libavcodec/qcelpdec.c+8−9
@@ -30,10 +30,10 @@ · 29 unmodified lines
3030 #include <stddef.h>
3131
3232 #include "libavutil/channel_layout.h"
33+#include "libavutil/float_dsp.h"
3334 #include "avcodec.h"
3435 #include "internal.h"
3536 #include "get_bits.h"
36−#include "dsputil.h"
3737 #include "qcelpdata.h"
3838 #include "celp_filters.h"
3939 #include "acelp_filters.h"
@@ -400,12 +400,10 @@ static void apply_gain_ctrl(float *v_out, const float *v_ref, const float *v_in) · 360 unmodified lines
400400 {
401401 int i;
402402
403− for (i = 0; i < 160; i += 40)
404− ff_scale_vector_to_given_sum_of_squares(v_out + i, v_in + i,
405− ff_scalarproduct_float_c(v_ref + i,
406− v_ref + i,
407− 40),
408− 40);
403+ for (i = 0; i < 160; i += 40) {
404+ float res = avpriv_scalarproduct_float_c(v_ref + i, v_ref + i, 40);
405+ ff_scale_vector_to_given_sum_of_squares(v_out + i, v_in + i, res, 40);
406+ }
409407 }
410408
411409 /**
@@ -680,8 +678,9 @@ static void postfilter(QCELPContext *q, float *samples, float *lpc) · 268 unmodified lines
680678 ff_tilt_compensation(&q->postfilter_tilt_mem, 0.3, pole_out + 10, 160);
681679
682680 ff_adaptive_gain_control(samples, pole_out + 10,
683− ff_scalarproduct_float_c(q->formant_mem + 10,
684− q->formant_mem + 10, 160),
681+ avpriv_scalarproduct_float_c(q->formant_mem + 10,
682+ q->formant_mem + 10,
683+ 160),
685684 160, 0.9375, &q->postfilter_agc_mem);
686685 }
687686
libavcodec/ra288.c+2−2
@@ -79,7 +79,7 @@ static av_cold int ra288_decode_init(AVCodecContext *avctx) · 78 unmodified lines
7979 static void convolve(float *tgt, const float *src, int len, int n)
8080 {
8181 for (; n >= 0; n--)
82− tgt[n] = ff_scalarproduct_float_c(src, src - n, len);
82+ tgt[n] = avpriv_scalarproduct_float_c(src, src - n, len);
8383
8484 }
8585
@@ -108,7 +108,7 @@ static void decode(RA288Context *ractx, float gain, int cb_coef) · 22 unmodified lines
108108 for (i=0; i < 5; i++)
109109 buffer[i] = codetable[cb_coef][i] * sumsum;
110110
111− sum = ff_scalarproduct_float_c(buffer, buffer, 5) * ((1 << 24) / 5.);
111+ sum = avpriv_scalarproduct_float_c(buffer, buffer, 5) * ((1 << 24) / 5.);
112112
113113 sum = FFMAX(sum, 1);
114114
libavcodec/sipr.c+8−7
@@ -26,11 +26,11 @@ · 25 unmodified lines
2626 #include <string.h>
2727
2828 #include "libavutil/channel_layout.h"
29+#include "libavutil/float_dsp.h"
2930 #include "libavutil/mathematics.h"
3031 #include "avcodec.h"
3132 #define BITSTREAM_READER_LE
3233 #include "get_bits.h"
33−#include "dsputil.h"
3434 #include "internal.h"
3535
3636 #include "lsp.h"
@@ -411,9 +411,10 @@ static void decode_frame(SiprContext *ctx, SiprParameters *params, · 374 unmodified lines
411411 convolute_with_sparse(fixed_vector, &fixed_cb, impulse_response,
412412 SUBFR_SIZE);
413413
414− avg_energy =
415− (0.01 + ff_scalarproduct_float_c(fixed_vector, fixed_vector, SUBFR_SIZE)) /
416− SUBFR_SIZE;
414+ avg_energy = (0.01 + avpriv_scalarproduct_float_c(fixed_vector,
415+ fixed_vector,
416+ SUBFR_SIZE)) /
417+ SUBFR_SIZE;
417418
418419 ctx->past_pitch_gain = pitch_gain = gain_cb[params->gc_index[i]][0];
419420
@@ -454,9 +455,9 @@ static void decode_frame(SiprContext *ctx, SiprParameters *params, · 34 unmodified lines
454455
455456 if (ctx->mode == MODE_5k0) {
456457 for (i = 0; i < subframe_count; i++) {
457− float energy = ff_scalarproduct_float_c(ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i * SUBFR_SIZE,
458− ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i * SUBFR_SIZE,
459− SUBFR_SIZE);
458+ float energy = avpriv_scalarproduct_float_c(ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i * SUBFR_SIZE,
459+ ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i * SUBFR_SIZE,
460+ SUBFR_SIZE);
460461 ff_adaptive_gain_control(&synth[i * SUBFR_SIZE],
461462 &synth[i * SUBFR_SIZE], energy,
462463 SUBFR_SIZE, 0.9, &ctx->postfilter_agc);
libavcodec/sipr16k.c+4−4
@@ -25,8 +25,8 @@ · 24 unmodified lines
2525
2626 #include "sipr.h"
2727 #include "libavutil/common.h"
28+#include "libavutil/float_dsp.h"
2829 #include "libavutil/mathematics.h"
29−#include "dsputil.h"
3030 #include "lsp.h"
3131 #include "celp_filters.h"
3232 #include "acelp_vectors.h"
@@ -163,11 +163,11 @@ static float acelp_decode_gain_codef(float gain_corr_factor, const float *fc_v, · 130 unmodified lines
163163 const float *ma_prediction_coeff,
164164 int subframe_size, int ma_pred_order)
165165 {
166− mr_energy +=
167− ff_scalarproduct_float_c(quant_energy, ma_prediction_coeff, ma_pred_order);
166+ mr_energy += avpriv_scalarproduct_float_c(quant_energy, ma_prediction_coeff,
167+ ma_pred_order);
168168
169169 mr_energy = gain_corr_factor * exp(M_LN10 / 20. * mr_energy) /
170− sqrt((0.01 + ff_scalarproduct_float_c(fc_v, fc_v, subframe_size)));
170+ sqrt((0.01 + avpriv_scalarproduct_float_c(fc_v, fc_v, subframe_size)));
171171 return mr_energy;
172172 }
173173
libavcodec/wmavoice.c+9−7
@@ -30,8 +30,8 @@ · 29 unmodified lines
3030 #include <math.h>
3131
3232 #include "libavutil/channel_layout.h"
33+#include "libavutil/float_dsp.h"
3334 #include "libavutil/mem.h"
34−#include "dsputil.h"
3535 #include "avcodec.h"
3636 #include "internal.h"
3737 #include "get_bits.h"
@@ -523,7 +523,7 @@ static int kalman_smoothen(WMAVoiceContext *s, int pitch, · 485 unmodified lines
523523
524524 /* find best fitting point in history */
525525 do {
526− dot = ff_scalarproduct_float_c(in, ptr, size);
526+ dot = avpriv_scalarproduct_float_c(in, ptr, size);
527527 if (dot > optimal_gain) {
528528 optimal_gain = dot;
529529 best_hist_ptr = ptr;
@@ -532,7 +532,7 @@ static int kalman_smoothen(WMAVoiceContext *s, int pitch, · 2 unmodified lines
532532
533533 if (optimal_gain <= 0)
534534 return -1;
535− dot = ff_scalarproduct_float_c(best_hist_ptr, best_hist_ptr, size);
535+ dot = avpriv_scalarproduct_float_c(best_hist_ptr, best_hist_ptr, size);
536536 if (dot <= 0) // would be 1.0
537537 return -1;
538538
@@ -562,8 +562,8 @@ static float tilt_factor(const float *lpcs, int n_lpcs) · 23 unmodified lines
562562 {
563563 float rh0, rh1;
564564
565− rh0 = 1.0 + ff_scalarproduct_float_c(lpcs, lpcs, n_lpcs);
566− rh1 = lpcs[0] + ff_scalarproduct_float_c(lpcs, &lpcs[1], n_lpcs - 1);
565+ rh0 = 1.0 + avpriv_scalarproduct_float_c(lpcs, lpcs, n_lpcs);
566+ rh1 = lpcs[0] + avpriv_scalarproduct_float_c(lpcs, &lpcs[1], n_lpcs - 1);
567567
568568 return rh1 / rh0;
569569 }
@@ -656,7 +656,8 @@ static void calc_input_response(WMAVoiceContext *s, float *lpcs, · 86 unmodified lines
656656 -1.8 * tilt_factor(coeffs, remainder - 1),
657657 coeffs, remainder);
658658 }
659− sq = (1.0 / 64.0) * sqrtf(1 / ff_scalarproduct_float_c(coeffs, coeffs, remainder));
659+ sq = (1.0 / 64.0) * sqrtf(1 / avpriv_scalarproduct_float_c(coeffs, coeffs,
660+ remainder));
660661 for (n = 0; n < remainder; n++)
661662 coeffs[n] *= sq;
662663 }
@@ -1320,7 +1321,8 @@ static void synth_block_fcb_acb(WMAVoiceContext *s, GetBitContext *gb, · 657 unmodified lines
13201321 /* Calculate gain for adaptive & fixed codebook signal.
13211322 * see ff_amr_set_fixed_gain(). */
13221323 idx = get_bits(gb, 7);
1323− fcb_gain = expf(ff_scalarproduct_float_c(s->gain_pred_err, gain_coeff, 6) -
1324+ fcb_gain = expf(avpriv_scalarproduct_float_c(s->gain_pred_err,
1325+ gain_coeff, 6) -
13241326 5.2409161640 + wmavoice_gain_codebook_fcb[idx]);
13251327 acb_gain = wmavoice_gain_codebook_acb[idx];
13261328 pred_err = av_clipf(wmavoice_gain_codebook_fcb[idx],
libavcodec/x86/dsputil.asm+0−26
@@ -463,32 +463,6 @@ cglobal add_hfyu_left_prediction, 3,3,7, dst, src, w, left · 462 unmodified lines
463463 .src_unaligned:
464464 ADD_HFYU_LEFT_LOOP 0, 0
465465
466−
467−; float scalarproduct_float_sse(const float *v1, const float *v2, int len)
468−INIT_XMM sse
469−cglobal scalarproduct_float, 3,3,2, v1, v2, offset
470− neg offsetq
471− shl offsetq, 2
472− sub v1q, offsetq
473− sub v2q, offsetq
474− xorps xmm0, xmm0
475− .loop:
476− movaps xmm1, [v1q+offsetq]
477− mulps xmm1, [v2q+offsetq]
478− addps xmm0, xmm1
479− add offsetq, 16
480− js .loop
481− movhlps xmm1, xmm0
482− addps xmm0, xmm1
483− movss xmm1, xmm0
484− shufps xmm0, xmm0, 1
485− addss xmm0, xmm1
486−%if ARCH_X86_64 == 0
487− movss r0m, xmm0
488− fld dword r0m
489−%endif
490− RET
491−
492466 ;-----------------------------------------------------------------------------
493467 ; void ff_vector_clip_int32(int32_t *dst, const int32_t *src, int32_t min,
494468 ; int32_t max, unsigned int len)
libavcodec/x86/dsputil_mmx.c+0−6
@@ -1846,8 +1846,6 @@ int ff_add_hfyu_left_prediction_ssse3(uint8_t *dst, const uint8_t *src, · 1845 unmodified lines
18461846 int ff_add_hfyu_left_prediction_sse4(uint8_t *dst, const uint8_t *src,
18471847 int w, int left);
18481848
1849−float ff_scalarproduct_float_sse(const float *v1, const float *v2, int order);
1850−
18511849 void ff_vector_clip_int32_mmx (int32_t *dst, const int32_t *src,
18521850 int32_t min, int32_t max, unsigned int len);
18531851 void ff_vector_clip_int32_sse2 (int32_t *dst, const int32_t *src,
@@ -2128,10 +2126,6 @@ static void dsputil_init_sse(DSPContext *c, AVCodecContext *avctx, int mm_flags) · 274 unmodified lines
21282126
21292127 c->vector_clipf = vector_clipf_sse;
21302128 #endif /* HAVE_INLINE_ASM */
2131−
2132−#if HAVE_YASM
2133− c->scalarproduct_float = ff_scalarproduct_float_sse;
2134−#endif /* HAVE_YASM */
21352129 }
21362130
21372131 static void dsputil_init_sse2(DSPContext *c, AVCodecContext *avctx,
libavutil/arm/float_dsp_init_neon.c+3−0
@@ -43,6 +43,8 @@ void ff_vector_fmul_reverse_neon(float *dst, const float *src0, · 42 unmodified lines
4343
4444 void ff_butterflies_float_neon(float *v1, float *v2, int len);
4545
46+float ff_scalarproduct_float_neon(const float *v1, const float *v2, int len);
47+
4648 void ff_float_dsp_init_neon(AVFloatDSPContext *fdsp)
4749 {
4850 fdsp->vector_fmul = ff_vector_fmul_neon;
@@ -52,4 +54,5 @@ void ff_float_dsp_init_neon(AVFloatDSPContext *fdsp) · 3 unmodified lines
5254 fdsp->vector_fmul_add = ff_vector_fmul_add_neon;
5355 fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_neon;
5456 fdsp->butterflies_float = ff_butterflies_float_neon;
57+ fdsp->scalarproduct_float = ff_scalarproduct_float_neon;
5558 }
libavutil/arm/float_dsp_neon.S+13−0
@@ -256,3 +256,16 @@ function ff_butterflies_float_neon, export=1 · 255 unmodified lines
256256 bgt 1b
257257 bx lr
258258 endfunc
259+
260+function ff_scalarproduct_float_neon, export=1
261+ vmov.f32 q2, #0.0
262+1: vld1.32 {q0},[r0,:128]!
263+ vld1.32 {q1},[r1,:128]!
264+ vmla.f32 q2, q0, q1
265+ subs r2, r2, #4
266+ bgt 1b
267+ vadd.f32 d0, d4, d5
268+ vpadd.f32 d0, d0, d0
269+NOVFP vmov.32 r0, d0[0]
270+ bx lr
271+endfunc
libavutil/float_dsp.c+12−0
@@ -101,6 +101,17 @@ static void butterflies_float_c(float *restrict v1, float *restrict v2, · 100 unmodified lines
101101 }
102102 }
103103
104+float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len)
105+{
106+ float p = 0.0;
107+ int i;
108+
109+ for (i = 0; i < len; i++)
110+ p += v1[i] * v2[i];
111+
112+ return p;
113+}
114+
104115 void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)
105116 {
106117 fdsp->vector_fmul = vector_fmul_c;
@@ -111,6 +122,7 @@ void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact) · 4 unmodified lines
111122 fdsp->vector_fmul_add = vector_fmul_add_c;
112123 fdsp->vector_fmul_reverse = vector_fmul_reverse_c;
113124 fdsp->butterflies_float = butterflies_float_c;
125+ fdsp->scalarproduct_float = avpriv_scalarproduct_float_c;
114126
115127 #if ARCH_ARM
116128 ff_float_dsp_init_arm(fdsp);
libavutil/float_dsp.h+22−0
@@ -146,8 +146,30 @@ typedef struct AVFloatDSPContext { · 145 unmodified lines
146146 * @param len length of vectors, multiple of 4
147147 */
148148 void (*butterflies_float)(float *restrict v1, float *restrict v2, int len);
149+
150+ /**
151+ * Calculate the scalar product of two vectors of floats.
152+ *
153+ * @param v1 first vector, 16-byte aligned
154+ * @param v2 second vector, 16-byte aligned
155+ * @param len length of vectors, multiple of 4
156+ *
157+ * @return sum of elementwise products
158+ */
159+ float (*scalarproduct_float)(const float *v1, const float *v2, int len);
149160 } AVFloatDSPContext;
150161
162+/**
163+ * Return the scalar product of two vectors.
164+ *
165+ * @param v1 first input vector
166+ * @param v2 first input vector
167+ * @param len number of elements
168+ *
169+ * @return sum of elementwise products
170+ */
171+float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len);
172+
151173 /**
152174 * Initialize a float DSP context.
153175 *
libavutil/x86/float_dsp.asm+25−0
@@ -227,3 +227,28 @@ INIT_XMM sse · 226 unmodified lines
227227 VECTOR_FMUL_REVERSE
228228 INIT_YMM avx
229229 VECTOR_FMUL_REVERSE
230+
231+; float scalarproduct_float_sse(const float *v1, const float *v2, int len)
232+INIT_XMM sse
233+cglobal scalarproduct_float, 3,3,2, v1, v2, offset
234+ neg offsetq
235+ shl offsetq, 2
236+ sub v1q, offsetq
237+ sub v2q, offsetq
238+ xorps xmm0, xmm0
239+.loop:
240+ movaps xmm1, [v1q+offsetq]
241+ mulps xmm1, [v2q+offsetq]
242+ addps xmm0, xmm1
243+ add offsetq, 16
244+ js .loop
245+ movhlps xmm1, xmm0
246+ addps xmm0, xmm1
247+ movss xmm1, xmm0
248+ shufps xmm0, xmm0, 1
249+ addss xmm0, xmm1
250+%if ARCH_X86_64 == 0
251+ movss r0m, xmm0
252+ fld dword r0m
253+%endif
254+ RET
libavutil/x86/float_dsp_init.c+3−0
@@ -51,6 +51,8 @@ void ff_vector_fmul_reverse_sse(float *dst, const float *src0, · 50 unmodified lines
5151 void ff_vector_fmul_reverse_avx(float *dst, const float *src0,
5252 const float *src1, int len);
5353
54+float ff_scalarproduct_float_sse(const float *v1, const float *v2, int order);
55+
5456 #if HAVE_6REGS && HAVE_INLINE_ASM
5557 static void vector_fmul_window_3dnowext(float *dst, const float *src0,
5658 const float *src1, const float *win,
@@ -135,6 +137,7 @@ void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp) · 78 unmodified lines
135137 fdsp->vector_fmul_scalar = ff_vector_fmul_scalar_sse;
136138 fdsp->vector_fmul_add = ff_vector_fmul_add_sse;
137139 fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_sse;
140+ fdsp->scalarproduct_float = ff_scalarproduct_float_sse;
138141 }
139142 if (EXTERNAL_SSE2(mm_flags)) {
140143 fdsp->vector_dmul_scalar = ff_vector_dmul_scalar_sse2;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t