Part 2 of 2 of Kenan Gillet's 'make ff_qcelp_lspf2lpc
more general' changeset. This one relocates the QCELP especific code to the qcelpdec.* files. Originally committed as revision 17800 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
77bd18e117
commit
87574416f7
@ -29,15 +29,6 @@
|
|||||||
|
|
||||||
#include "libavutil/mathematics.h"
|
#include "libavutil/mathematics.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* initial coefficient to perform bandwidth expansion on LPC
|
|
||||||
*
|
|
||||||
* @note: 0.9883 looks like an approximation of 253/256.
|
|
||||||
*
|
|
||||||
* TIA/EIA/IS-733 2.4.3.3.6 6
|
|
||||||
*/
|
|
||||||
#define QCELP_BANDWITH_EXPANSION_COEFF 0.9883
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the Pa / (1 + z(-1)) or Qa / (1 - z(-1)) coefficients
|
* Computes the Pa / (1 + z(-1)) or Qa / (1 - z(-1)) coefficients
|
||||||
* needed for LSP to LPC conversion.
|
* needed for LSP to LPC conversion.
|
||||||
@ -88,33 +79,3 @@ void ff_celp_lspf2lpc(const double *lspf, float *lpc)
|
|||||||
lpc[9-i] = 0.5*(paf-qaf);
|
lpc[9-i] = 0.5*(paf-qaf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reconstructs LPC coefficients from the line spectral pair frequencies
|
|
||||||
* and performs bandwidth expansion.
|
|
||||||
*
|
|
||||||
* @param lspf line spectral pair frequencies
|
|
||||||
* @param lpc linear predictive coding coefficients
|
|
||||||
*
|
|
||||||
* @note: bandwith_expansion_coeff could be precalculated into a table
|
|
||||||
* but it seems to be slower on x86
|
|
||||||
*
|
|
||||||
* TIA/EIA/IS-733 2.4.3.3.5
|
|
||||||
*/
|
|
||||||
void ff_qcelp_lspf2lpc(const float *lspf, float *lpc)
|
|
||||||
{
|
|
||||||
double lsf[10];
|
|
||||||
double bandwith_expansion_coeff = QCELP_BANDWITH_EXPANSION_COEFF;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i=0; i<10; i++)
|
|
||||||
lsf[i] = cos(M_PI * lspf[i]);
|
|
||||||
|
|
||||||
ff_celp_lspf2lpc(lsf, lpc);
|
|
||||||
|
|
||||||
for (i=0; i<10; i++)
|
|
||||||
{
|
|
||||||
lpc[i] *= bandwith_expansion_coeff;
|
|
||||||
bandwith_expansion_coeff *= QCELP_BANDWITH_EXPANSION_COEFF;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -550,4 +550,13 @@ static const double qcelp_rnd_fir_coefs[11] = {
|
|||||||
*/
|
*/
|
||||||
#define QCELP_LSP_OCTAVE_PREDICTOR 29.0/32
|
#define QCELP_LSP_OCTAVE_PREDICTOR 29.0/32
|
||||||
|
|
||||||
|
/**
|
||||||
|
* initial coefficient to perform bandwidth expansion on LPC
|
||||||
|
*
|
||||||
|
* @note: 0.9883 looks like an approximation of 253/256.
|
||||||
|
*
|
||||||
|
* TIA/EIA/IS-733 2.4.3.3.6 6
|
||||||
|
*/
|
||||||
|
#define QCELP_BANDWITH_EXPANSION_COEFF 0.9883
|
||||||
|
|
||||||
#endif /* AVCODEC_QCELPDATA_H */
|
#endif /* AVCODEC_QCELPDATA_H */
|
||||||
|
@ -79,7 +79,7 @@ typedef struct
|
|||||||
*
|
*
|
||||||
* TIA/EIA/IS-733 2.4.3.3.5
|
* TIA/EIA/IS-733 2.4.3.3.5
|
||||||
*/
|
*/
|
||||||
void ff_qcelp_lspf2lpc(const float *lspf, float *lpc);
|
void ff_celp_lspf2lpc(const double *lspf, float *lpc);
|
||||||
|
|
||||||
static void weighted_vector_sumf(float *out, const float *in_a,
|
static void weighted_vector_sumf(float *out, const float *in_a,
|
||||||
const float *in_b, float weight_coeff_a,
|
const float *in_b, float weight_coeff_a,
|
||||||
@ -584,6 +584,36 @@ static void apply_pitch_filters(QCELPContext *q, float *cdn_vector)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reconstructs LPC coefficients from the line spectral pair frequencies
|
||||||
|
* and performs bandwidth expansion.
|
||||||
|
*
|
||||||
|
* @param lspf line spectral pair frequencies
|
||||||
|
* @param lpc linear predictive coding coefficients
|
||||||
|
*
|
||||||
|
* @note: bandwith_expansion_coeff could be precalculated into a table
|
||||||
|
* but it seems to be slower on x86
|
||||||
|
*
|
||||||
|
* TIA/EIA/IS-733 2.4.3.3.5
|
||||||
|
*/
|
||||||
|
void lspf2lpc(const float *lspf, float *lpc)
|
||||||
|
{
|
||||||
|
double lsf[10];
|
||||||
|
double bandwith_expansion_coeff = QCELP_BANDWITH_EXPANSION_COEFF;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0; i<10; i++)
|
||||||
|
lsf[i] = cos(M_PI * lspf[i]);
|
||||||
|
|
||||||
|
ff_celp_lspf2lpc(lsf, lpc);
|
||||||
|
|
||||||
|
for (i=0; i<10; i++)
|
||||||
|
{
|
||||||
|
lpc[i] *= bandwith_expansion_coeff;
|
||||||
|
bandwith_expansion_coeff *= QCELP_BANDWITH_EXPANSION_COEFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interpolates LSP frequencies and computes LPC coefficients
|
* Interpolates LSP frequencies and computes LPC coefficients
|
||||||
* for a given bitrate & pitch subframe.
|
* for a given bitrate & pitch subframe.
|
||||||
@ -612,12 +642,12 @@ void interpolate_lpc(QCELPContext *q, const float *curr_lspf, float *lpc,
|
|||||||
{
|
{
|
||||||
weighted_vector_sumf(interpolated_lspf, curr_lspf, q->prev_lspf,
|
weighted_vector_sumf(interpolated_lspf, curr_lspf, q->prev_lspf,
|
||||||
weight, 1.0 - weight, 10);
|
weight, 1.0 - weight, 10);
|
||||||
ff_qcelp_lspf2lpc(interpolated_lspf, lpc);
|
lspf2lpc(interpolated_lspf, lpc);
|
||||||
}else if(q->bitrate >= RATE_QUARTER ||
|
}else if(q->bitrate >= RATE_QUARTER ||
|
||||||
(q->bitrate == I_F_Q && !subframe_num))
|
(q->bitrate == I_F_Q && !subframe_num))
|
||||||
ff_qcelp_lspf2lpc(curr_lspf, lpc);
|
lspf2lpc(curr_lspf, lpc);
|
||||||
else if(q->bitrate == SILENCE && !subframe_num)
|
else if(q->bitrate == SILENCE && !subframe_num)
|
||||||
ff_qcelp_lspf2lpc(q->prev_lspf, lpc);
|
lspf2lpc(q->prev_lspf, lpc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static qcelp_packet_rate buf_size2bitrate(const int buf_size)
|
static qcelp_packet_rate buf_size2bitrate(const int buf_size)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user