|
|
@ -28,8 +28,8 @@ |
|
|
|
#include "libavutil/lfg.h" |
|
|
|
#include "libavutil/lfg.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "avcodec.h" |
|
|
|
#include "avcodec.h" |
|
|
|
|
|
|
|
#include "dsputil.h" |
|
|
|
#include "lsp.h" |
|
|
|
#include "lsp.h" |
|
|
|
#include "celp_math.h" |
|
|
|
|
|
|
|
#include "celp_filters.h" |
|
|
|
#include "celp_filters.h" |
|
|
|
#include "acelp_filters.h" |
|
|
|
#include "acelp_filters.h" |
|
|
|
#include "acelp_vectors.h" |
|
|
|
#include "acelp_vectors.h" |
|
|
@ -585,10 +585,12 @@ static void pitch_sharpening(AMRWBContext *ctx, float *fixed_vector) |
|
|
|
static float voice_factor(float *p_vector, float p_gain, |
|
|
|
static float voice_factor(float *p_vector, float p_gain, |
|
|
|
float *f_vector, float f_gain) |
|
|
|
float *f_vector, float f_gain) |
|
|
|
{ |
|
|
|
{ |
|
|
|
double p_ener = (double) ff_dot_productf(p_vector, p_vector, |
|
|
|
double p_ener = (double) ff_scalarproduct_float_c(p_vector, p_vector, |
|
|
|
AMRWB_SFR_SIZE) * p_gain * p_gain; |
|
|
|
AMRWB_SFR_SIZE) * |
|
|
|
double f_ener = (double) ff_dot_productf(f_vector, f_vector, |
|
|
|
p_gain * p_gain; |
|
|
|
AMRWB_SFR_SIZE) * f_gain * f_gain; |
|
|
|
double f_ener = (double) ff_scalarproduct_float_c(f_vector, f_vector, |
|
|
|
|
|
|
|
AMRWB_SFR_SIZE) * |
|
|
|
|
|
|
|
f_gain * f_gain; |
|
|
|
|
|
|
|
|
|
|
|
return (p_ener - f_ener) / (p_ener + f_ener); |
|
|
|
return (p_ener - f_ener) / (p_ener + f_ener); |
|
|
|
} |
|
|
|
} |
|
|
@ -756,7 +758,7 @@ static void synthesis(AMRWBContext *ctx, float *lpc, float *excitation, |
|
|
|
/* emphasize pitch vector contribution in low bitrate modes */ |
|
|
|
/* emphasize pitch vector contribution in low bitrate modes */ |
|
|
|
if (ctx->pitch_gain[0] > 0.5 && ctx->fr_cur_mode <= MODE_8k85) { |
|
|
|
if (ctx->pitch_gain[0] > 0.5 && ctx->fr_cur_mode <= MODE_8k85) { |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
float energy = ff_dot_productf(excitation, excitation, |
|
|
|
float energy = ff_scalarproduct_float_c(excitation, excitation, |
|
|
|
AMRWB_SFR_SIZE); |
|
|
|
AMRWB_SFR_SIZE); |
|
|
|
|
|
|
|
|
|
|
|
// XXX: Weird part in both ref code and spec. A unknown parameter
|
|
|
|
// XXX: Weird part in both ref code and spec. A unknown parameter
|
|
|
@ -816,7 +818,8 @@ static void upsample_5_4(float *out, const float *in, int o_size) |
|
|
|
i++; |
|
|
|
i++; |
|
|
|
|
|
|
|
|
|
|
|
for (k = 1; k < 5; k++) { |
|
|
|
for (k = 1; k < 5; k++) { |
|
|
|
out[i] = ff_dot_productf(in0 + int_part, upsample_fir[4 - frac_part], |
|
|
|
out[i] = ff_scalarproduct_float_c(in0 + int_part, |
|
|
|
|
|
|
|
upsample_fir[4 - frac_part], |
|
|
|
UPS_MEM_SIZE); |
|
|
|
UPS_MEM_SIZE); |
|
|
|
int_part++; |
|
|
|
int_part++; |
|
|
|
frac_part--; |
|
|
|
frac_part--; |
|
|
@ -843,8 +846,8 @@ static float find_hb_gain(AMRWBContext *ctx, const float *synth, |
|
|
|
if (ctx->fr_cur_mode == MODE_23k85) |
|
|
|
if (ctx->fr_cur_mode == MODE_23k85) |
|
|
|
return qua_hb_gain[hb_idx] * (1.0f / (1 << 14)); |
|
|
|
return qua_hb_gain[hb_idx] * (1.0f / (1 << 14)); |
|
|
|
|
|
|
|
|
|
|
|
tilt = ff_dot_productf(synth, synth + 1, AMRWB_SFR_SIZE - 1) / |
|
|
|
tilt = ff_scalarproduct_float_c(synth, synth + 1, AMRWB_SFR_SIZE - 1) / |
|
|
|
ff_dot_productf(synth, synth, AMRWB_SFR_SIZE); |
|
|
|
ff_scalarproduct_float_c(synth, synth, AMRWB_SFR_SIZE); |
|
|
|
|
|
|
|
|
|
|
|
/* return gain bounded by [0.1, 1.0] */ |
|
|
|
/* return gain bounded by [0.1, 1.0] */ |
|
|
|
return av_clipf((1.0 - FFMAX(0.0, tilt)) * (1.25 - 0.25 * wsp), 0.1, 1.0); |
|
|
|
return av_clipf((1.0 - FFMAX(0.0, tilt)) * (1.25 - 0.25 * wsp), 0.1, 1.0); |
|
|
@ -863,7 +866,7 @@ static void scaled_hb_excitation(AMRWBContext *ctx, float *hb_exc, |
|
|
|
const float *synth_exc, float hb_gain) |
|
|
|
const float *synth_exc, float hb_gain) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
float energy = ff_dot_productf(synth_exc, synth_exc, AMRWB_SFR_SIZE); |
|
|
|
float energy = ff_scalarproduct_float_c(synth_exc, synth_exc, AMRWB_SFR_SIZE); |
|
|
|
|
|
|
|
|
|
|
|
/* Generate a white-noise excitation */ |
|
|
|
/* Generate a white-noise excitation */ |
|
|
|
for (i = 0; i < AMRWB_SFR_SIZE_16k; i++) |
|
|
|
for (i = 0; i < AMRWB_SFR_SIZE_16k; i++) |
|
|
@ -1156,8 +1159,10 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, |
|
|
|
|
|
|
|
|
|
|
|
ctx->fixed_gain[0] = |
|
|
|
ctx->fixed_gain[0] = |
|
|
|
ff_amr_set_fixed_gain(fixed_gain_factor, |
|
|
|
ff_amr_set_fixed_gain(fixed_gain_factor, |
|
|
|
ff_dot_productf(ctx->fixed_vector, ctx->fixed_vector, |
|
|
|
ff_scalarproduct_float_c(ctx->fixed_vector, |
|
|
|
AMRWB_SFR_SIZE) / AMRWB_SFR_SIZE, |
|
|
|
ctx->fixed_vector, |
|
|
|
|
|
|
|
AMRWB_SFR_SIZE) / |
|
|
|
|
|
|
|
AMRWB_SFR_SIZE, |
|
|
|
ctx->prediction_error, |
|
|
|
ctx->prediction_error, |
|
|
|
ENERGY_MEAN, energy_pred_fac); |
|
|
|
ENERGY_MEAN, energy_pred_fac); |
|
|
|
|
|
|
|
|
|
|
|