This makes the aac decoder and all voice codecs independent of dsputil.
Unified · Split
| @@ -291,7 +291,6 @@ typedef struct AACContext { · 290 unmodified lines | ||
| 291 | 291 | FFTContext mdct; |
| 292 | 292 | FFTContext mdct_small; |
| 293 | 293 | FFTContext mdct_ltp; |
| 294 | − DSPContext dsp; | |
| 295 | 294 | FmtConvertContext fmt_conv; |
| 296 | 295 | AVFloatDSPContext fdsp; |
| 297 | 296 | int random_state; |
| @@ -895,7 +895,6 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) · 894 unmodified lines | ||
| 895 | 895 | |
| 896 | 896 | ff_aac_sbr_init(); |
| 897 | 897 | |
| 898 | − ff_dsputil_init(&ac->dsp, avctx); | |
| 899 | 898 | ff_fmt_convert_init(&ac->fmt_conv, avctx); |
| 900 | 899 | avpriv_float_dsp_init(&ac->fdsp, avctx->flags & CODEC_FLAG_BITEXACT); |
| 901 | 900 | |
| @@ -1358,7 +1357,7 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], · 456 unmodified lines | ||
| 1358 | 1357 | cfo[k] = ac->random_state; |
| 1359 | 1358 | } |
| 1360 | 1359 | |
| 1361 | − band_energy = ac->dsp.scalarproduct_float(cfo, cfo, off_len); | |
| 1360 | + band_energy = ac->fdsp.scalarproduct_float(cfo, cfo, off_len); | |
| 1362 | 1361 | scale = sf[idx] / sqrtf(band_energy); |
| 1363 | 1362 | ac->fdsp.vector_fmul_scalar(cfo, cfo, scale, off_len); |
| 1364 | 1363 | } |
| @@ -21,9 +21,9 @@ · 20 unmodified lines | ||
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | 23 | #include "libavutil/common.h" |
| 24 | +#include "libavutil/float_dsp.h" | |
| 24 | 25 | #include "libavutil/mathematics.h" |
| 25 | 26 | #include "avcodec.h" |
| 26 | −#include "dsputil.h" | |
| 27 | 27 | #include "acelp_pitch_delay.h" |
| 28 | 28 | #include "celp_math.h" |
| 29 | 29 | |
| @@ -120,7 +120,7 @@ float ff_amr_set_fixed_gain(float fixed_gain_factor, float fixed_mean_energy, · 90 unmodified lines | ||
| 120 | 120 | // Note 10^(0.05 * -10log(average x2)) = 1/sqrt((average x2)). |
| 121 | 121 | float val = fixed_gain_factor * |
| 122 | 122 | 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) + | |
| 124 | 124 | energy_mean)) / |
| 125 | 125 | sqrtf(fixed_mean_energy); |
| 126 | 126 | |
| @@ -23,8 +23,8 @@ · 22 unmodified lines | ||
| 23 | 23 | #include <inttypes.h> |
| 24 | 24 | |
| 25 | 25 | #include "libavutil/common.h" |
| 26 | +#include "libavutil/float_dsp.h" | |
| 26 | 27 | #include "avcodec.h" |
| 27 | −#include "dsputil.h" | |
| 28 | 28 | #include "acelp_vectors.h" |
| 29 | 29 | |
| 30 | 30 | 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 | ||
| 183 | 183 | int size, float alpha, float *gain_mem) |
| 184 | 184 | { |
| 185 | 185 | int i; |
| 186 | − float postfilter_energ = ff_scalarproduct_float_c(in, in, size); | |
| 186 | + float postfilter_energ = avpriv_scalarproduct_float_c(in, in, size); | |
| 187 | 187 | float gain_scale_factor = 1.0; |
| 188 | 188 | float mem = *gain_mem; |
| 189 | 189 | |
| @@ -204,7 +204,7 @@ void ff_scale_vector_to_given_sum_of_squares(float *out, const float *in, · 14 unmodified lines | ||
| 204 | 204 | float sum_of_squares, const int n) |
| 205 | 205 | { |
| 206 | 206 | int i; |
| 207 | − float scalefactor = ff_scalarproduct_float_c(in, in, n); | |
| 207 | + float scalefactor = avpriv_scalarproduct_float_c(in, in, n); | |
| 208 | 208 | if (scalefactor) |
| 209 | 209 | scalefactor = sqrt(sum_of_squares / scalefactor); |
| 210 | 210 | for (i = 0; i < n; i++) |
| @@ -44,8 +44,8 @@ · 43 unmodified lines | ||
| 44 | 44 | #include <math.h> |
| 45 | 45 | |
| 46 | 46 | #include "libavutil/channel_layout.h" |
| 47 | +#include "libavutil/float_dsp.h" | |
| 47 | 48 | #include "avcodec.h" |
| 48 | −#include "dsputil.h" | |
| 49 | 49 | #include "libavutil/common.h" |
| 50 | 50 | #include "celp_filters.h" |
| 51 | 51 | #include "acelp_filters.h" |
| @@ -794,8 +794,8 @@ static int synthesis(AMRContext *p, float *lpc, · 742 unmodified lines | ||
| 794 | 794 | |
| 795 | 795 | // emphasize pitch vector contribution |
| 796 | 796 | 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); | |
| 799 | 799 | float pitch_factor = |
| 800 | 800 | p->pitch_gain[4] * |
| 801 | 801 | (p->cur_frame_mode == MODE_12k2 ? |
| @@ -871,8 +871,8 @@ static float tilt_factor(float *lpc_n, float *lpc_d) · 69 unmodified lines | ||
| 871 | 871 | ff_celp_lp_synthesis_filterf(hf, lpc_d, hf, AMR_TILT_RESPONSE, |
| 872 | 872 | LP_FILTER_ORDER); |
| 873 | 873 | |
| 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); | |
| 876 | 876 | |
| 877 | 877 | // The spec only specifies this check for 12.2 and 10.2 kbit/s |
| 878 | 878 | // 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 | ||
| 892 | 892 | int i; |
| 893 | 893 | float *samples = p->samples_in + LP_FILTER_ORDER; // Start of input |
| 894 | 894 | |
| 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); | |
| 897 | 897 | |
| 898 | 898 | float pole_out[AMR_SUBFRAME_SIZE + LP_FILTER_ORDER]; // Output of pole filter |
| 899 | 899 | 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 | ||
| 998 | 998 | |
| 999 | 999 | p->fixed_gain[4] = |
| 1000 | 1000 | 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) / | |
| 1004 | 1004 | AMR_SUBFRAME_SIZE, |
| 1005 | 1005 | p->prediction_error, |
| 1006 | 1006 | energy_mean[p->cur_frame_mode], energy_pred_fac); |
| @@ -26,10 +26,10 @@ · 25 unmodified lines | ||
| 26 | 26 | |
| 27 | 27 | #include "libavutil/channel_layout.h" |
| 28 | 28 | #include "libavutil/common.h" |
| 29 | +#include "libavutil/float_dsp.h" | |
| 29 | 30 | #include "libavutil/lfg.h" |
| 30 | 31 | |
| 31 | 32 | #include "avcodec.h" |
| 32 | −#include "dsputil.h" | |
| 33 | 33 | #include "lsp.h" |
| 34 | 34 | #include "celp_filters.h" |
| 35 | 35 | #include "acelp_filters.h" |
| @@ -595,11 +595,11 @@ static void pitch_sharpening(AMRWBContext *ctx, float *fixed_vector) · 559 unmodified lines | ||
| 595 | 595 | static float voice_factor(float *p_vector, float p_gain, |
| 596 | 596 | float *f_vector, float f_gain) |
| 597 | 597 | { |
| 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) * | |
| 600 | 600 | 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) * | |
| 603 | 603 | f_gain * f_gain; |
| 604 | 604 | |
| 605 | 605 | 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 | ||
| 768 | 768 | /* emphasize pitch vector contribution in low bitrate modes */ |
| 769 | 769 | if (ctx->pitch_gain[0] > 0.5 && ctx->fr_cur_mode <= MODE_8k85) { |
| 770 | 770 | 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); | |
| 773 | 773 | |
| 774 | 774 | // XXX: Weird part in both ref code and spec. A unknown parameter |
| 775 | 775 | // {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 | ||
| 828 | 828 | i++; |
| 829 | 829 | |
| 830 | 830 | 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); | |
| 834 | 834 | int_part++; |
| 835 | 835 | frac_part--; |
| 836 | 836 | i++; |
| @@ -856,8 +856,8 @@ static float find_hb_gain(AMRWBContext *ctx, const float *synth, · 19 unmodified lines | ||
| 856 | 856 | if (ctx->fr_cur_mode == MODE_23k85) |
| 857 | 857 | return qua_hb_gain[hb_idx] * (1.0f / (1 << 14)); |
| 858 | 858 | |
| 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); | |
| 861 | 861 | |
| 862 | 862 | /* return gain bounded by [0.1, 1.0] */ |
| 863 | 863 | 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 | ||
| 876 | 876 | const float *synth_exc, float hb_gain) |
| 877 | 877 | { |
| 878 | 878 | 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); | |
| 880 | 881 | |
| 881 | 882 | /* Generate a white-noise excitation */ |
| 882 | 883 | 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 | ||
| 1168 | 1169 | |
| 1169 | 1170 | ctx->fixed_gain[0] = |
| 1170 | 1171 | 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) / | |
| 1174 | 1175 | AMRWB_SFR_SIZE, |
| 1175 | 1176 | ctx->prediction_error, |
| 1176 | 1177 | ENERGY_MEAN, energy_pred_fac); |
| @@ -142,8 +142,6 @@ void ff_avg_h264_chroma_mc8_neon(uint8_t *, uint8_t *, int, int, int, int); · 141 unmodified lines | ||
| 142 | 142 | void ff_avg_h264_chroma_mc4_neon(uint8_t *, uint8_t *, int, int, int, int); |
| 143 | 143 | void ff_avg_h264_chroma_mc2_neon(uint8_t *, uint8_t *, int, int, int, int); |
| 144 | 144 | |
| 145 | −float ff_scalarproduct_float_neon(const float *v1, const float *v2, int len); | |
| 146 | − | |
| 147 | 145 | void ff_vector_clipf_neon(float *dst, const float *src, float min, float max, |
| 148 | 146 | int len); |
| 149 | 147 | 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 | ||
| 293 | 291 | c->avg_h264_qpel_pixels_tab[1][15] = ff_avg_h264_qpel8_mc33_neon; |
| 294 | 292 | } |
| 295 | 293 | |
| 296 | − c->scalarproduct_float = ff_scalarproduct_float_neon; | |
| 297 | 294 | c->vector_clipf = ff_vector_clipf_neon; |
| 298 | 295 | c->vector_clip_int32 = ff_vector_clip_int32_neon; |
| 299 | 296 | |
| @@ -531,19 +531,6 @@ function ff_add_pixels_clamped_neon, export=1 · 530 unmodified lines | ||
| 531 | 531 | bx lr |
| 532 | 532 | endfunc |
| 533 | 533 | |
| 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 | − | |
| 547 | 534 | function ff_vector_clipf_neon, export=1 |
| 548 | 535 | VFP vdup.32 q1, d0[1] |
| 549 | 536 | VFP vdup.32 q0, d0[0] |
| @@ -2353,17 +2353,6 @@ WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c) · 2352 unmodified lines | ||
| 2353 | 2353 | WRAPPER8_16_SQ(rd8x8_c, rd16_c) |
| 2354 | 2354 | WRAPPER8_16_SQ(bit8x8_c, bit16_c) |
| 2355 | 2355 | |
| 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 | − | |
| 2367 | 2356 | static inline uint32_t clipf_c_one(uint32_t a, uint32_t mini, |
| 2368 | 2357 | uint32_t maxi, uint32_t maxisign) |
| 2369 | 2358 | { |
| @@ -2694,7 +2683,6 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx) · 324 unmodified lines | ||
| 2694 | 2683 | c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c; |
| 2695 | 2684 | c->apply_window_int16 = apply_window_int16_c; |
| 2696 | 2685 | c->vector_clip_int32 = vector_clip_int32_c; |
| 2697 | − c->scalarproduct_float = ff_scalarproduct_float_c; | |
| 2698 | 2686 | |
| 2699 | 2687 | c->shrink[0]= av_image_copy_plane; |
| 2700 | 2688 | c->shrink[1]= ff_shrink22; |
| @@ -342,13 +342,6 @@ typedef struct DSPContext { · 341 unmodified lines | ||
| 342 | 342 | |
| 343 | 343 | /* assume len is a multiple of 8, and arrays are 16-byte aligned */ |
| 344 | 344 | 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); | |
| 352 | 345 | |
| 353 | 346 | /* (I)DCT */ |
| 354 | 347 | void (*fdct)(DCTELEM *block/* align 16*/); |
| @@ -454,17 +447,6 @@ void ff_dsputil_init(DSPContext* p, AVCodecContext *avctx); · 99 unmodified lines | ||
| 454 | 447 | |
| 455 | 448 | int ff_check_alignment(void); |
| 456 | 449 | |
| 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 | − | |
| 468 | 450 | /** |
| 469 | 451 | * permute block according to permuatation. |
| 470 | 452 | * @param last last non zero element in scantable order |
| @@ -30,10 +30,10 @@ · 29 unmodified lines | ||
| 30 | 30 | #include <stddef.h> |
| 31 | 31 | |
| 32 | 32 | #include "libavutil/channel_layout.h" |
| 33 | +#include "libavutil/float_dsp.h" | |
| 33 | 34 | #include "avcodec.h" |
| 34 | 35 | #include "internal.h" |
| 35 | 36 | #include "get_bits.h" |
| 36 | −#include "dsputil.h" | |
| 37 | 37 | #include "qcelpdata.h" |
| 38 | 38 | #include "celp_filters.h" |
| 39 | 39 | #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 | ||
| 400 | 400 | { |
| 401 | 401 | int i; |
| 402 | 402 | |
| 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 | + } | |
| 409 | 407 | } |
| 410 | 408 | |
| 411 | 409 | /** |
| @@ -680,8 +678,9 @@ static void postfilter(QCELPContext *q, float *samples, float *lpc) · 268 unmodified lines | ||
| 680 | 678 | ff_tilt_compensation(&q->postfilter_tilt_mem, 0.3, pole_out + 10, 160); |
| 681 | 679 | |
| 682 | 680 | 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), | |
| 685 | 684 | 160, 0.9375, &q->postfilter_agc_mem); |
| 686 | 685 | } |
| 687 | 686 | |
| @@ -79,7 +79,7 @@ static av_cold int ra288_decode_init(AVCodecContext *avctx) · 78 unmodified lines | ||
| 79 | 79 | static void convolve(float *tgt, const float *src, int len, int n) |
| 80 | 80 | { |
| 81 | 81 | 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); | |
| 83 | 83 | |
| 84 | 84 | } |
| 85 | 85 | |
| @@ -108,7 +108,7 @@ static void decode(RA288Context *ractx, float gain, int cb_coef) · 22 unmodified lines | ||
| 108 | 108 | for (i=0; i < 5; i++) |
| 109 | 109 | buffer[i] = codetable[cb_coef][i] * sumsum; |
| 110 | 110 | |
| 111 | − sum = ff_scalarproduct_float_c(buffer, buffer, 5) * ((1 << 24) / 5.); | |
| 111 | + sum = avpriv_scalarproduct_float_c(buffer, buffer, 5) * ((1 << 24) / 5.); | |
| 112 | 112 | |
| 113 | 113 | sum = FFMAX(sum, 1); |
| 114 | 114 | |
| @@ -26,11 +26,11 @@ · 25 unmodified lines | ||
| 26 | 26 | #include <string.h> |
| 27 | 27 | |
| 28 | 28 | #include "libavutil/channel_layout.h" |
| 29 | +#include "libavutil/float_dsp.h" | |
| 29 | 30 | #include "libavutil/mathematics.h" |
| 30 | 31 | #include "avcodec.h" |
| 31 | 32 | #define BITSTREAM_READER_LE |
| 32 | 33 | #include "get_bits.h" |
| 33 | −#include "dsputil.h" | |
| 34 | 34 | #include "internal.h" |
| 35 | 35 | |
| 36 | 36 | #include "lsp.h" |
| @@ -411,9 +411,10 @@ static void decode_frame(SiprContext *ctx, SiprParameters *params, · 374 unmodified lines | ||
| 411 | 411 | convolute_with_sparse(fixed_vector, &fixed_cb, impulse_response, |
| 412 | 412 | SUBFR_SIZE); |
| 413 | 413 | |
| 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; | |
| 417 | 418 | |
| 418 | 419 | ctx->past_pitch_gain = pitch_gain = gain_cb[params->gc_index[i]][0]; |
| 419 | 420 | |
| @@ -454,9 +455,9 @@ static void decode_frame(SiprContext *ctx, SiprParameters *params, · 34 unmodified lines | ||
| 454 | 455 | |
| 455 | 456 | if (ctx->mode == MODE_5k0) { |
| 456 | 457 | 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); | |
| 460 | 461 | ff_adaptive_gain_control(&synth[i * SUBFR_SIZE], |
| 461 | 462 | &synth[i * SUBFR_SIZE], energy, |
| 462 | 463 | SUBFR_SIZE, 0.9, &ctx->postfilter_agc); |
| @@ -25,8 +25,8 @@ · 24 unmodified lines | ||
| 25 | 25 | |
| 26 | 26 | #include "sipr.h" |
| 27 | 27 | #include "libavutil/common.h" |
| 28 | +#include "libavutil/float_dsp.h" | |
| 28 | 29 | #include "libavutil/mathematics.h" |
| 29 | −#include "dsputil.h" | |
| 30 | 30 | #include "lsp.h" |
| 31 | 31 | #include "celp_filters.h" |
| 32 | 32 | #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 | ||
| 163 | 163 | const float *ma_prediction_coeff, |
| 164 | 164 | int subframe_size, int ma_pred_order) |
| 165 | 165 | { |
| 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); | |
| 168 | 168 | |
| 169 | 169 | 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))); | |
| 171 | 171 | return mr_energy; |
| 172 | 172 | } |
| 173 | 173 | |
| @@ -30,8 +30,8 @@ · 29 unmodified lines | ||
| 30 | 30 | #include <math.h> |
| 31 | 31 | |
| 32 | 32 | #include "libavutil/channel_layout.h" |
| 33 | +#include "libavutil/float_dsp.h" | |
| 33 | 34 | #include "libavutil/mem.h" |
| 34 | −#include "dsputil.h" | |
| 35 | 35 | #include "avcodec.h" |
| 36 | 36 | #include "internal.h" |
| 37 | 37 | #include "get_bits.h" |
| @@ -523,7 +523,7 @@ static int kalman_smoothen(WMAVoiceContext *s, int pitch, · 485 unmodified lines | ||
| 523 | 523 | |
| 524 | 524 | /* find best fitting point in history */ |
| 525 | 525 | do { |
| 526 | − dot = ff_scalarproduct_float_c(in, ptr, size); | |
| 526 | + dot = avpriv_scalarproduct_float_c(in, ptr, size); | |
| 527 | 527 | if (dot > optimal_gain) { |
| 528 | 528 | optimal_gain = dot; |
| 529 | 529 | best_hist_ptr = ptr; |
| @@ -532,7 +532,7 @@ static int kalman_smoothen(WMAVoiceContext *s, int pitch, · 2 unmodified lines | ||
| 532 | 532 | |
| 533 | 533 | if (optimal_gain <= 0) |
| 534 | 534 | 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); | |
| 536 | 536 | if (dot <= 0) // would be 1.0 |
| 537 | 537 | return -1; |
| 538 | 538 | |
| @@ -562,8 +562,8 @@ static float tilt_factor(const float *lpcs, int n_lpcs) · 23 unmodified lines | ||
| 562 | 562 | { |
| 563 | 563 | float rh0, rh1; |
| 564 | 564 | |
| 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); | |
| 567 | 567 | |
| 568 | 568 | return rh1 / rh0; |
| 569 | 569 | } |
| @@ -656,7 +656,8 @@ static void calc_input_response(WMAVoiceContext *s, float *lpcs, · 86 unmodified lines | ||
| 656 | 656 | -1.8 * tilt_factor(coeffs, remainder - 1), |
| 657 | 657 | coeffs, remainder); |
| 658 | 658 | } |
| 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)); | |
| 660 | 661 | for (n = 0; n < remainder; n++) |
| 661 | 662 | coeffs[n] *= sq; |
| 662 | 663 | } |
| @@ -1320,7 +1321,8 @@ static void synth_block_fcb_acb(WMAVoiceContext *s, GetBitContext *gb, · 657 unmodified lines | ||
| 1320 | 1321 | /* Calculate gain for adaptive & fixed codebook signal. |
| 1321 | 1322 | * see ff_amr_set_fixed_gain(). */ |
| 1322 | 1323 | 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) - | |
| 1324 | 1326 | 5.2409161640 + wmavoice_gain_codebook_fcb[idx]); |
| 1325 | 1327 | acb_gain = wmavoice_gain_codebook_acb[idx]; |
| 1326 | 1328 | pred_err = av_clipf(wmavoice_gain_codebook_fcb[idx], |
| @@ -463,32 +463,6 @@ cglobal add_hfyu_left_prediction, 3,3,7, dst, src, w, left · 462 unmodified lines | ||
| 463 | 463 | .src_unaligned: |
| 464 | 464 | ADD_HFYU_LEFT_LOOP 0, 0 |
| 465 | 465 | |
| 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 | − | |
| 492 | 466 | ;----------------------------------------------------------------------------- |
| 493 | 467 | ; void ff_vector_clip_int32(int32_t *dst, const int32_t *src, int32_t min, |
| 494 | 468 | ; int32_t max, unsigned int len) |
| @@ -1846,8 +1846,6 @@ int ff_add_hfyu_left_prediction_ssse3(uint8_t *dst, const uint8_t *src, · 1845 unmodified lines | ||
| 1846 | 1846 | int ff_add_hfyu_left_prediction_sse4(uint8_t *dst, const uint8_t *src, |
| 1847 | 1847 | int w, int left); |
| 1848 | 1848 | |
| 1849 | −float ff_scalarproduct_float_sse(const float *v1, const float *v2, int order); | |
| 1850 | − | |
| 1851 | 1849 | void ff_vector_clip_int32_mmx (int32_t *dst, const int32_t *src, |
| 1852 | 1850 | int32_t min, int32_t max, unsigned int len); |
| 1853 | 1851 | 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 | ||
| 2128 | 2126 | |
| 2129 | 2127 | c->vector_clipf = vector_clipf_sse; |
| 2130 | 2128 | #endif /* HAVE_INLINE_ASM */ |
| 2131 | − | |
| 2132 | −#if HAVE_YASM | |
| 2133 | − c->scalarproduct_float = ff_scalarproduct_float_sse; | |
| 2134 | −#endif /* HAVE_YASM */ | |
| 2135 | 2129 | } |
| 2136 | 2130 | |
| 2137 | 2131 | static void dsputil_init_sse2(DSPContext *c, AVCodecContext *avctx, |
| @@ -43,6 +43,8 @@ void ff_vector_fmul_reverse_neon(float *dst, const float *src0, · 42 unmodified lines | ||
| 43 | 43 | |
| 44 | 44 | void ff_butterflies_float_neon(float *v1, float *v2, int len); |
| 45 | 45 | |
| 46 | +float ff_scalarproduct_float_neon(const float *v1, const float *v2, int len); | |
| 47 | + | |
| 46 | 48 | void ff_float_dsp_init_neon(AVFloatDSPContext *fdsp) |
| 47 | 49 | { |
| 48 | 50 | fdsp->vector_fmul = ff_vector_fmul_neon; |
| @@ -52,4 +54,5 @@ void ff_float_dsp_init_neon(AVFloatDSPContext *fdsp) · 3 unmodified lines | ||
| 52 | 54 | fdsp->vector_fmul_add = ff_vector_fmul_add_neon; |
| 53 | 55 | fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_neon; |
| 54 | 56 | fdsp->butterflies_float = ff_butterflies_float_neon; |
| 57 | + fdsp->scalarproduct_float = ff_scalarproduct_float_neon; | |
| 55 | 58 | } |
| @@ -256,3 +256,16 @@ function ff_butterflies_float_neon, export=1 · 255 unmodified lines | ||
| 256 | 256 | bgt 1b |
| 257 | 257 | bx lr |
| 258 | 258 | 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 | |
| @@ -101,6 +101,17 @@ static void butterflies_float_c(float *restrict v1, float *restrict v2, · 100 unmodified lines | ||
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 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 | + | |
| 104 | 115 | void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact) |
| 105 | 116 | { |
| 106 | 117 | fdsp->vector_fmul = vector_fmul_c; |
| @@ -111,6 +122,7 @@ void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact) · 4 unmodified lines | ||
| 111 | 122 | fdsp->vector_fmul_add = vector_fmul_add_c; |
| 112 | 123 | fdsp->vector_fmul_reverse = vector_fmul_reverse_c; |
| 113 | 124 | fdsp->butterflies_float = butterflies_float_c; |
| 125 | + fdsp->scalarproduct_float = avpriv_scalarproduct_float_c; | |
| 114 | 126 | |
| 115 | 127 | #if ARCH_ARM |
| 116 | 128 | ff_float_dsp_init_arm(fdsp); |
| @@ -146,8 +146,30 @@ typedef struct AVFloatDSPContext { · 145 unmodified lines | ||
| 146 | 146 | * @param len length of vectors, multiple of 4 |
| 147 | 147 | */ |
| 148 | 148 | 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); | |
| 149 | 160 | } AVFloatDSPContext; |
| 150 | 161 | |
| 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 | + | |
| 151 | 173 | /** |
| 152 | 174 | * Initialize a float DSP context. |
| 153 | 175 | * |
| @@ -227,3 +227,28 @@ INIT_XMM sse · 226 unmodified lines | ||
| 227 | 227 | VECTOR_FMUL_REVERSE |
| 228 | 228 | INIT_YMM avx |
| 229 | 229 | 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 | |
| @@ -51,6 +51,8 @@ void ff_vector_fmul_reverse_sse(float *dst, const float *src0, · 50 unmodified lines | ||
| 51 | 51 | void ff_vector_fmul_reverse_avx(float *dst, const float *src0, |
| 52 | 52 | const float *src1, int len); |
| 53 | 53 | |
| 54 | +float ff_scalarproduct_float_sse(const float *v1, const float *v2, int order); | |
| 55 | + | |
| 54 | 56 | #if HAVE_6REGS && HAVE_INLINE_ASM |
| 55 | 57 | static void vector_fmul_window_3dnowext(float *dst, const float *src0, |
| 56 | 58 | const float *src1, const float *win, |
| @@ -135,6 +137,7 @@ void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp) · 78 unmodified lines | ||
| 135 | 137 | fdsp->vector_fmul_scalar = ff_vector_fmul_scalar_sse; |
| 136 | 138 | fdsp->vector_fmul_add = ff_vector_fmul_add_sse; |
| 137 | 139 | fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_sse; |
| 140 | + fdsp->scalarproduct_float = ff_scalarproduct_float_sse; | |
| 138 | 141 | } |
| 139 | 142 | if (EXTERNAL_SSE2(mm_flags)) { |
| 140 | 143 | fdsp->vector_dmul_scalar = ff_vector_dmul_scalar_sse2; |