FreeCalypso > hg > gsm-codec-lib
view libtwamr/autocorr.c @ 477:4c9222d95647
libtwamr encoder: always emit frame->mode = mode;
In the original implementation of amr_encode_frame(), the 'mode' member
of the output struct was set to 0xFF if the output frame type is TX_NO_DATA.
This design was made to mimic the mode field (16-bit word) being set to
0xFFFF (or -1) in 3GPP test sequence format - but nothing actually depends
on this struct member being set in any way, and amr_frame_to_tseq()
generates the needed 0xFFFF on its own, based on frame->type being equal
to TX_NO_DATA.
It is simpler and more efficient to always set frame->mode to the actual
encoding mode in amr_encode_frame(), and this new behavior has already
been documented in doc/AMR-library-API description in anticipation of
the present change.
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sat, 18 May 2024 22:30:42 +0000 |
| parents | 07f936338de1 |
| children |
line wrap: on
line source
/* ******************************************************************************** * * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 * R99 Version 3.3.0 * REL-4 Version 4.1.0 * ******************************************************************************** * * File : autocorr.c * ******************************************************************************** */ /* ******************************************************************************** * MODULE INCLUDE FILE AND VERSION ID ******************************************************************************** */ #include "namespace.h" #include "autocorr.h" /* ******************************************************************************** * INCLUDE FILES ******************************************************************************** */ #include "typedef.h" #include "basic_op.h" #include "oper_32b.h" #include "no_count.h" #include "cnst.h" /* ******************************************************************************** * LOCAL VARIABLES AND TABLES ******************************************************************************** */ /* ******************************************************************************** * PUBLIC PROGRAM CODE ******************************************************************************** */ /* ************************************************************************** * * Function : autocorr * Purpose : Compute autocorrelations of signal with windowing * ************************************************************************** */ Word16 Autocorr ( Word16 x[], /* (i) : Input signal (L_WINDOW) */ Word16 m, /* (i) : LPC order */ Word16 r_h[], /* (o) : Autocorrelations (msb) */ Word16 r_l[], /* (o) : Autocorrelations (lsb) */ const Word16 wind[] /* (i) : window for LPC analysis (L_WINDOW) */ ) { Word16 i, j, norm; Word16 y[L_WINDOW]; Word32 sum; Word16 overfl, overfl_shft; /* Windowing of signal */ for (i = 0; i < L_WINDOW; i++) { y[i] = mult_r (x[i], wind[i]); move16 (); } /* Compute r[0] and test for overflow */ overfl_shft = 0; move16 (); do { overfl = 0; move16 (); sum = 0L; move32 (); for (i = 0; i < L_WINDOW; i++) { sum = L_mac (sum, y[i], y[i]); } /* If overflow divide y[] by 4 */ test (); if (L_sub (sum, MAX_32) == 0L) { overfl_shft = add (overfl_shft, 4); overfl = 1; move16 (); /* Set the overflow flag */ for (i = 0; i < L_WINDOW; i++) { y[i] = shr (y[i], 2); move16 (); } } test (); } while (overfl != 0); sum = L_add (sum, 1L); /* Avoid the case of all zeros */ /* Normalization of r[0] */ norm = norm_l (sum); sum = L_shl (sum, norm); L_Extract (sum, &r_h[0], &r_l[0]); /* Put in DPF format (see oper_32b) */ /* r[1] to r[m] */ for (i = 1; i <= m; i++) { sum = 0; move32 (); for (j = 0; j < L_WINDOW - i; j++) { sum = L_mac (sum, y[j], y[j + i]); } sum = L_shl (sum, norm); L_Extract (sum, &r_h[i], &r_l[i]); } norm = sub (norm, overfl_shft); return norm; }
