Commit f2515cd6 authored by Justin Ruggles's avatar Justin Ruggles

alac: simplify lpc coefficient adaptation

parent abc4376b
...@@ -206,6 +206,7 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer, ...@@ -206,6 +206,7 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer,
int j; int j;
int val = 0; int val = 0;
int error_val = error_buffer[i]; int error_val = error_buffer[i];
int error_sign;
for (j = 0; j < predictor_coef_num; j++) { for (j = 0; j < predictor_coef_num; j++) {
val += (buffer_out[predictor_coef_num-j] - buffer_out[0]) * val += (buffer_out[predictor_coef_num-j] - buffer_out[0]) *
...@@ -218,39 +219,17 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer, ...@@ -218,39 +219,17 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer,
buffer_out[predictor_coef_num + 1] = sign_extend(val, readsamplesize); buffer_out[predictor_coef_num + 1] = sign_extend(val, readsamplesize);
if (error_val > 0) { /* adapt LPC coefficients */
int predictor_num = predictor_coef_num - 1; error_sign = sign_only(error_val);
if (error_sign) {
while (predictor_num >= 0 && error_val > 0) { for (j = predictor_coef_num - 1; j >= 0 && error_val * error_sign > 0; j--) {
int sign; int sign;
val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num]; val = buffer_out[0] - buffer_out[predictor_coef_num - j];
sign = sign_only(val); sign = sign_only(val) * error_sign;
predictor_coef_table[j] -= sign;
predictor_coef_table[predictor_num] -= sign; val *= sign;
val *= sign; /* absolute value */
error_val -= ((val >> predictor_quantitization) * error_val -= ((val >> predictor_quantitization) *
(predictor_coef_num - predictor_num)); (predictor_coef_num - j));
predictor_num--;
}
} else if (error_val < 0) {
int predictor_num = predictor_coef_num - 1;
while (predictor_num >= 0 && error_val < 0) {
int sign;
val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num];
sign = -sign_only(val);
predictor_coef_table[predictor_num] -= sign;
val *= sign; /* neg value */
error_val -= ((val >> predictor_quantitization) *
(predictor_coef_num - predictor_num));
predictor_num--;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment