Commit 48ac225d authored by Marcelo Galvăo Póvoa's avatar Marcelo Galvăo Póvoa Committed by Vitor Sessak

Move lsp2lpc_sipr() function to common code so it can be reused in a

AMRWB decoder.

Patch by Marcelo Galvăo Póvoa.

Originally committed as revision 25062 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 1d96cc08
...@@ -117,6 +117,32 @@ void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order) ...@@ -117,6 +117,32 @@ void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order)
} }
} }
void ff_amrwb_lsp2lpc(const double *lsp, float *lp, int lp_order)
{
int lp_half_order = lp_order >> 1;
double buf[lp_half_order + 1];
double pa[lp_half_order + 1];
double *qa = buf + 1;
int i,j;
qa[-1] = 0.0;
ff_lsp2polyf(lsp , pa, lp_half_order );
ff_lsp2polyf(lsp + 1, qa, lp_half_order - 1);
for (i = 1, j = lp_order - 1; i < lp_half_order; i++, j--) {
double paf = pa[i] * (1 + lsp[lp_order - 1]);
double qaf = (qa[i] - qa[i-2]) * (1 - lsp[lp_order - 1]);
lp[i-1] = (paf + qaf) * 0.5;
lp[j-1] = (paf - qaf) * 0.5;
}
lp[lp_half_order - 1] = (1.0 + lsp[lp_order - 1]) *
pa[lp_half_order] * 0.5;
lp[lp_order - 1] = lsp[lp_order - 1];
}
void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd, const int16_t* lsp_prev, int lp_order) void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd, const int16_t* lsp_prev, int lp_order)
{ {
int16_t lsp_1st[MAX_LP_ORDER]; // (0.15) int16_t lsp_1st[MAX_LP_ORDER]; // (0.15)
......
...@@ -75,6 +75,11 @@ void ff_acelp_lsf2lspd(double *lsp, const float *lsf, int lp_order); ...@@ -75,6 +75,11 @@ void ff_acelp_lsf2lspd(double *lsp, const float *lsf, int lp_order);
*/ */
void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order); void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order);
/**
* LSP to LP conversion (5.2.4 of AMR-WB)
*/
void ff_amrwb_lsp2lpc(const double *lsp, float *lp, int lp_order);
/** /**
* \brief Interpolate LSP for the first subframe and convert LSP -> LP for both subframes (3.2.5 and 3.2.6 of G.729) * \brief Interpolate LSP for the first subframe and convert LSP -> LP for both subframes (3.2.5 and 3.2.6 of G.729)
* \param[out] lp_1st decoded LP coefficients for first subframe (-0x8000 <= (3.12) < 0x8000) * \param[out] lp_1st decoded LP coefficients for first subframe (-0x8000 <= (3.12) < 0x8000)
......
...@@ -209,32 +209,6 @@ static void decode_parameters(SiprParameters* parms, GetBitContext *pgb, ...@@ -209,32 +209,6 @@ static void decode_parameters(SiprParameters* parms, GetBitContext *pgb,
} }
} }
static void lsp2lpc_sipr(const double *lsp, float *Az)
{
int lp_half_order = LP_FILTER_ORDER >> 1;
double buf[(LP_FILTER_ORDER >> 1) + 1];
double pa[(LP_FILTER_ORDER >> 1) + 1];
double *qa = buf + 1;
int i,j;
qa[-1] = 0.0;
ff_lsp2polyf(lsp , pa, lp_half_order );
ff_lsp2polyf(lsp + 1, qa, lp_half_order - 1);
for (i = 1, j = LP_FILTER_ORDER - 1; i < lp_half_order; i++, j--) {
double paf = pa[i] * (1 + lsp[LP_FILTER_ORDER - 1]);
double qaf = (qa[i] - qa[i-2]) * (1 - lsp[LP_FILTER_ORDER - 1]);
Az[i-1] = (paf + qaf) * 0.5;
Az[j-1] = (paf - qaf) * 0.5;
}
Az[lp_half_order - 1] = (1.0 + lsp[LP_FILTER_ORDER - 1]) *
pa[lp_half_order] * 0.5;
Az[LP_FILTER_ORDER - 1] = lsp[LP_FILTER_ORDER - 1];
}
static void sipr_decode_lp(float *lsfnew, const float *lsfold, float *Az, static void sipr_decode_lp(float *lsfnew, const float *lsfold, float *Az,
int num_subfr) int num_subfr)
{ {
...@@ -247,7 +221,7 @@ static void sipr_decode_lp(float *lsfnew, const float *lsfold, float *Az, ...@@ -247,7 +221,7 @@ static void sipr_decode_lp(float *lsfnew, const float *lsfold, float *Az,
for (j = 0; j < LP_FILTER_ORDER; j++) for (j = 0; j < LP_FILTER_ORDER; j++)
lsfint[j] = lsfold[j] * (1 - t) + t * lsfnew[j]; lsfint[j] = lsfold[j] * (1 - t) + t * lsfnew[j];
lsp2lpc_sipr(lsfint, Az); ff_amrwb_lsp2lpc(lsfint, Az, LP_FILTER_ORDER);
Az += LP_FILTER_ORDER; Az += LP_FILTER_ORDER;
t += t0; t += t0;
} }
......
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