mirror of
https://github.com/xiph/opus.git
synced 2025-06-06 07:21:03 +00:00
More simplifications from denorm pitch
This commit is contained in:
parent
095c1782c5
commit
4834c92e2b
6 changed files with 25 additions and 89 deletions
|
@ -222,7 +222,7 @@ int compute_new_pitch(const CELTMode *m, const celt_sig_t *X, const celt_sig_t *
|
||||||
celt_word16_t g;
|
celt_word16_t g;
|
||||||
const int C = CHANNELS(m);
|
const int C = CHANNELS(m);
|
||||||
celt_word32_t Sxy=0, Sxx=0, Syy=0;
|
celt_word32_t Sxy=0, Sxx=0, Syy=0;
|
||||||
int len = 20*C;
|
int len = m->pitchEnd*C;
|
||||||
#ifdef FIXED_POINT
|
#ifdef FIXED_POINT
|
||||||
int shift = 0;
|
int shift = 0;
|
||||||
celt_word32_t maxabs=0;
|
celt_word32_t maxabs=0;
|
||||||
|
@ -291,7 +291,7 @@ void apply_new_pitch(const CELTMode *m, celt_sig_t *X, const celt_sig_t *P, int
|
||||||
int j;
|
int j;
|
||||||
celt_word16_t gain;
|
celt_word16_t gain;
|
||||||
const int C = CHANNELS(m);
|
const int C = CHANNELS(m);
|
||||||
int len = 20*C;
|
int len = m->pitchEnd*C;
|
||||||
gain = ADD16(QCONST16(.5,14), MULT16_16_16(QCONST16(.05,14),gain_id));
|
gain = ADD16(QCONST16(.5,14), MULT16_16_16(QCONST16(.05,14),gain_id));
|
||||||
if (pred)
|
if (pred)
|
||||||
gain = -gain;
|
gain = -gain;
|
||||||
|
@ -415,7 +415,7 @@ int folding_decision(const CELTMode *m, celt_norm_t *X, celt_word16_t *average,
|
||||||
floor_ener -= MULT16_16(x[max_i-2], x[max_i-2]);
|
floor_ener -= MULT16_16(x[max_i-2], x[max_i-2]);
|
||||||
floor_ener = MAX32(floor_ener, EPSILON);
|
floor_ener = MAX32(floor_ener, EPSILON);
|
||||||
#endif
|
#endif
|
||||||
if (N>7 && eBands[i] >= m->pitchEnd)
|
if (N>7)
|
||||||
{
|
{
|
||||||
celt_word16_t r;
|
celt_word16_t r;
|
||||||
celt_word16_t den = celt_sqrt(floor_ener);
|
celt_word16_t den = celt_sqrt(floor_ener);
|
||||||
|
@ -439,7 +439,7 @@ int folding_decision(const CELTMode *m, celt_norm_t *X, celt_word16_t *average,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Quantisation of the residual */
|
/* Quantisation of the residual */
|
||||||
void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, celt_mask_t *W, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, int *pulses, int shortBlocks, int fold, int total_bits, ec_enc *enc)
|
void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, const celt_ener_t *bandE, int *pulses, int shortBlocks, int fold, int total_bits, ec_enc *enc)
|
||||||
{
|
{
|
||||||
int i, j, remaining_bits, balance;
|
int i, j, remaining_bits, balance;
|
||||||
const celt_int16_t * restrict eBands = m->eBands;
|
const celt_int16_t * restrict eBands = m->eBands;
|
||||||
|
@ -490,7 +490,7 @@ void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, ce
|
||||||
|
|
||||||
if (q > 0)
|
if (q > 0)
|
||||||
{
|
{
|
||||||
int spread = (eBands[i] >= m->pitchEnd && fold) ? B : 0;
|
int spread = fold ? B : 0;
|
||||||
alg_quant(X+eBands[i], eBands[i+1]-eBands[i], q, spread, enc);
|
alg_quant(X+eBands[i], eBands[i+1]-eBands[i], q, spread, enc);
|
||||||
} else {
|
} else {
|
||||||
intra_fold(m, X+eBands[i], eBands[i+1]-eBands[i], norm, X+eBands[i], eBands[i], B);
|
intra_fold(m, X+eBands[i], eBands[i+1]-eBands[i], norm, X+eBands[i], eBands[i], B);
|
||||||
|
@ -503,14 +503,13 @@ void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, ce
|
||||||
|
|
||||||
#ifndef DISABLE_STEREO
|
#ifndef DISABLE_STEREO
|
||||||
|
|
||||||
void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, celt_mask_t *W, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, int *pulses, int shortBlocks, int fold, int total_bits, ec_enc *enc)
|
void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, const celt_ener_t *bandE, int *pulses, int shortBlocks, int fold, int total_bits, ec_enc *enc)
|
||||||
{
|
{
|
||||||
int i, j, remaining_bits, balance;
|
int i, j, remaining_bits, balance;
|
||||||
const celt_int16_t * restrict eBands = m->eBands;
|
const celt_int16_t * restrict eBands = m->eBands;
|
||||||
celt_norm_t * restrict norm;
|
celt_norm_t * restrict norm;
|
||||||
VARDECL(celt_norm_t, _norm);
|
VARDECL(celt_norm_t, _norm);
|
||||||
const int C = CHANNELS(m);
|
const int C = CHANNELS(m);
|
||||||
int pband=-1;
|
|
||||||
int B;
|
int B;
|
||||||
celt_word16_t mid, side;
|
celt_word16_t mid, side;
|
||||||
SAVE_STACK;
|
SAVE_STACK;
|
||||||
|
@ -625,7 +624,7 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t
|
||||||
|
|
||||||
if (q1 > 0)
|
if (q1 > 0)
|
||||||
{
|
{
|
||||||
int spread = (eBands[i] >= m->pitchEnd && fold) ? B : 0;
|
int spread = fold ? B : 0;
|
||||||
alg_quant(v, N, q1, spread, enc);
|
alg_quant(v, N, q1, spread, enc);
|
||||||
} else {
|
} else {
|
||||||
v[0] = QCONST16(1.f, 14);
|
v[0] = QCONST16(1.f, 14);
|
||||||
|
@ -689,13 +688,13 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t
|
||||||
}
|
}
|
||||||
deinterleave(X+C*eBands[i], C*N);
|
deinterleave(X+C*eBands[i], C*N);
|
||||||
if (q1 > 0) {
|
if (q1 > 0) {
|
||||||
int spread = (eBands[i] >= m->pitchEnd && fold) ? B : 0;
|
int spread = fold ? B : 0;
|
||||||
alg_quant(X+C*eBands[i], N, q1, spread, enc);
|
alg_quant(X+C*eBands[i], N, q1, spread, enc);
|
||||||
} else
|
} else
|
||||||
for (j=C*eBands[i];j<C*eBands[i]+N;j++)
|
for (j=C*eBands[i];j<C*eBands[i]+N;j++)
|
||||||
X[j] = P[j];
|
X[j] = P[j];
|
||||||
if (q2 > 0) {
|
if (q2 > 0) {
|
||||||
int spread = (eBands[i] >= m->pitchEnd && fold) ? B : 0;
|
int spread = fold ? B : 0;
|
||||||
alg_quant(X+C*eBands[i]+N, N, q2, spread, enc);
|
alg_quant(X+C*eBands[i]+N, N, q2, spread, enc);
|
||||||
} else
|
} else
|
||||||
for (j=C*eBands[i]+N;j<C*eBands[i+1];j++)
|
for (j=C*eBands[i]+N;j<C*eBands[i+1];j++)
|
||||||
|
@ -732,7 +731,7 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t
|
||||||
#endif /* DISABLE_STEREO */
|
#endif /* DISABLE_STEREO */
|
||||||
|
|
||||||
/* Decoding of the residual */
|
/* Decoding of the residual */
|
||||||
void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, int *pulses, int shortBlocks, int fold, int total_bits, ec_dec *dec)
|
void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, const celt_ener_t *bandE, int *pulses, int shortBlocks, int fold, int total_bits, ec_dec *dec)
|
||||||
{
|
{
|
||||||
int i, j, remaining_bits, balance;
|
int i, j, remaining_bits, balance;
|
||||||
const celt_int16_t * restrict eBands = m->eBands;
|
const celt_int16_t * restrict eBands = m->eBands;
|
||||||
|
@ -783,7 +782,7 @@ void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P,
|
||||||
|
|
||||||
if (q > 0)
|
if (q > 0)
|
||||||
{
|
{
|
||||||
int spread = (eBands[i] >= m->pitchEnd && fold) ? B : 0;
|
int spread = fold ? B : 0;
|
||||||
alg_unquant(X+eBands[i], eBands[i+1]-eBands[i], q, spread, dec);
|
alg_unquant(X+eBands[i], eBands[i+1]-eBands[i], q, spread, dec);
|
||||||
} else {
|
} else {
|
||||||
intra_fold(m, X+eBands[i], eBands[i+1]-eBands[i], norm, X+eBands[i], eBands[i], B);
|
intra_fold(m, X+eBands[i], eBands[i+1]-eBands[i], norm, X+eBands[i], eBands[i], B);
|
||||||
|
@ -796,14 +795,13 @@ void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P,
|
||||||
|
|
||||||
#ifndef DISABLE_STEREO
|
#ifndef DISABLE_STEREO
|
||||||
|
|
||||||
void unquant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, int *pulses, int shortBlocks, int fold, int total_bits, ec_dec *dec)
|
void unquant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, const celt_ener_t *bandE, int *pulses, int shortBlocks, int fold, int total_bits, ec_dec *dec)
|
||||||
{
|
{
|
||||||
int i, j, remaining_bits, balance;
|
int i, j, remaining_bits, balance;
|
||||||
const celt_int16_t * restrict eBands = m->eBands;
|
const celt_int16_t * restrict eBands = m->eBands;
|
||||||
celt_norm_t * restrict norm;
|
celt_norm_t * restrict norm;
|
||||||
VARDECL(celt_norm_t, _norm);
|
VARDECL(celt_norm_t, _norm);
|
||||||
const int C = CHANNELS(m);
|
const int C = CHANNELS(m);
|
||||||
int pband=-1;
|
|
||||||
int B;
|
int B;
|
||||||
celt_word16_t mid, side;
|
celt_word16_t mid, side;
|
||||||
SAVE_STACK;
|
SAVE_STACK;
|
||||||
|
@ -907,7 +905,7 @@ void unquant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm
|
||||||
|
|
||||||
if (q1 > 0)
|
if (q1 > 0)
|
||||||
{
|
{
|
||||||
int spread = (eBands[i] >= m->pitchEnd && fold) ? B : 0;
|
int spread = fold ? B : 0;
|
||||||
alg_unquant(v, N, q1, spread, dec);
|
alg_unquant(v, N, q1, spread, dec);
|
||||||
} else {
|
} else {
|
||||||
v[0] = QCONST16(1.f, 14);
|
v[0] = QCONST16(1.f, 14);
|
||||||
|
@ -967,14 +965,14 @@ void unquant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm
|
||||||
deinterleave(X+C*eBands[i], C*N);
|
deinterleave(X+C*eBands[i], C*N);
|
||||||
if (q1 > 0)
|
if (q1 > 0)
|
||||||
{
|
{
|
||||||
int spread = (eBands[i] >= m->pitchEnd && fold) ? B : 0;
|
int spread = fold ? B : 0;
|
||||||
alg_unquant(X+C*eBands[i], N, q1, spread, dec);
|
alg_unquant(X+C*eBands[i], N, q1, spread, dec);
|
||||||
} else
|
} else
|
||||||
for (j=C*eBands[i];j<C*eBands[i]+N;j++)
|
for (j=C*eBands[i];j<C*eBands[i]+N;j++)
|
||||||
X[j] = P[j];
|
X[j] = P[j];
|
||||||
if (q2 > 0)
|
if (q2 > 0)
|
||||||
{
|
{
|
||||||
int spread = (eBands[i] >= m->pitchEnd && fold) ? B : 0;
|
int spread = fold ? B : 0;
|
||||||
alg_unquant(X+C*eBands[i]+N, N, q2, spread, dec);
|
alg_unquant(X+C*eBands[i]+N, N, q2, spread, dec);
|
||||||
} else
|
} else
|
||||||
for (j=C*eBands[i]+N;j<C*eBands[i+1];j++)
|
for (j=C*eBands[i]+N;j<C*eBands[i+1];j++)
|
||||||
|
|
|
@ -87,9 +87,9 @@ int folding_decision(const CELTMode *m, celt_norm_t *X, celt_word16_t *average,
|
||||||
* @param total_bits Total number of bits that can be used for the frame (including the ones already spent)
|
* @param total_bits Total number of bits that can be used for the frame (including the ones already spent)
|
||||||
* @param enc Entropy encoder
|
* @param enc Entropy encoder
|
||||||
*/
|
*/
|
||||||
void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, celt_mask_t *W, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, int *pulses, int time_domain, int fold, int total_bits, ec_enc *enc);
|
void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, const celt_ener_t *bandE, int *pulses, int time_domain, int fold, int total_bits, ec_enc *enc);
|
||||||
|
|
||||||
void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, celt_mask_t *W, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, int *pulses, int time_domain, int fold, int total_bits, ec_enc *enc);
|
void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, const celt_ener_t *bandE, int *pulses, int time_domain, int fold, int total_bits, ec_enc *enc);
|
||||||
|
|
||||||
/** Decoding of the residual spectrum
|
/** Decoding of the residual spectrum
|
||||||
* @param m Mode data
|
* @param m Mode data
|
||||||
|
@ -98,9 +98,9 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t
|
||||||
* @param total_bits Total number of bits that can be used for the frame (including the ones already spent)
|
* @param total_bits Total number of bits that can be used for the frame (including the ones already spent)
|
||||||
* @param dec Entropy decoder
|
* @param dec Entropy decoder
|
||||||
*/
|
*/
|
||||||
void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, int *pulses, int time_domain, int fold, int total_bits, ec_dec *dec);
|
void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, const celt_ener_t *bandE, int *pulses, int time_domain, int fold, int total_bits, ec_dec *dec);
|
||||||
|
|
||||||
void unquant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, int *pulses, int time_domain, int fold, int total_bits, ec_dec *dec);
|
void unquant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, const celt_ener_t *bandE, int *pulses, int time_domain, int fold, int total_bits, ec_dec *dec);
|
||||||
|
|
||||||
void stereo_decision(const CELTMode *m, celt_norm_t * restrict X, int *stereo_mode, int len);
|
void stereo_decision(const CELTMode *m, celt_norm_t * restrict X, int *stereo_mode, int len);
|
||||||
|
|
||||||
|
|
|
@ -509,7 +509,6 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
|
||||||
VARDECL(celt_norm_t, P);
|
VARDECL(celt_norm_t, P);
|
||||||
VARDECL(celt_ener_t, bandE);
|
VARDECL(celt_ener_t, bandE);
|
||||||
VARDECL(celt_word16_t, bandLogE);
|
VARDECL(celt_word16_t, bandLogE);
|
||||||
VARDECL(celt_pgain_t, gains);
|
|
||||||
VARDECL(int, fine_quant);
|
VARDECL(int, fine_quant);
|
||||||
VARDECL(celt_word16_t, error);
|
VARDECL(celt_word16_t, error);
|
||||||
VARDECL(int, pulses);
|
VARDECL(int, pulses);
|
||||||
|
@ -676,7 +675,6 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
|
||||||
the peak memory usage */
|
the peak memory usage */
|
||||||
ALLOC(X, C*N, celt_norm_t); /**< Interleaved normalised MDCTs */
|
ALLOC(X, C*N, celt_norm_t); /**< Interleaved normalised MDCTs */
|
||||||
ALLOC(P, C*N, celt_norm_t); /**< Interleaved normalised pitch MDCTs*/
|
ALLOC(P, C*N, celt_norm_t); /**< Interleaved normalised pitch MDCTs*/
|
||||||
ALLOC(gains,st->mode->nbPBands, celt_pgain_t);
|
|
||||||
|
|
||||||
ALLOC(pitch_freq, C*N, celt_sig_t); /**< Interleaved signal MDCTs */
|
ALLOC(pitch_freq, C*N, celt_sig_t); /**< Interleaved signal MDCTs */
|
||||||
if (has_pitch)
|
if (has_pitch)
|
||||||
|
@ -712,8 +710,6 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
|
||||||
ec_enc_uint(&enc, pitch_index, MAX_PERIOD-(2*N-2*N4));
|
ec_enc_uint(&enc, pitch_index, MAX_PERIOD-(2*N-2*N4));
|
||||||
ec_enc_uint(&enc, gain_id, 16);
|
ec_enc_uint(&enc, gain_id, 16);
|
||||||
} else {
|
} else {
|
||||||
for (i=0;i<st->mode->nbPBands;i++)
|
|
||||||
gains[i] = 0;
|
|
||||||
for (i=0;i<C*N;i++)
|
for (i=0;i<C*N;i++)
|
||||||
P[i] = 0;
|
P[i] = 0;
|
||||||
}
|
}
|
||||||
|
@ -773,10 +769,10 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
|
||||||
|
|
||||||
/* Residual quantisation */
|
/* Residual quantisation */
|
||||||
if (C==1)
|
if (C==1)
|
||||||
quant_bands(st->mode, X, P, NULL, 0, gains, bandE, pulses, shortBlocks, has_fold, nbCompressedBytes*8, &enc);
|
quant_bands(st->mode, X, P, bandE, pulses, shortBlocks, has_fold, nbCompressedBytes*8, &enc);
|
||||||
#ifndef DISABLE_STEREO
|
#ifndef DISABLE_STEREO
|
||||||
else
|
else
|
||||||
quant_bands_stereo(st->mode, X, P, NULL, 0, gains, bandE, pulses, shortBlocks, has_fold, nbCompressedBytes*8, &enc);
|
quant_bands_stereo(st->mode, X, P, bandE, pulses, shortBlocks, has_fold, nbCompressedBytes*8, &enc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
quant_energy_finalise(st->mode, bandE, st->oldBandE, error, fine_quant, fine_priority, nbCompressedBytes*8-ec_enc_tell(&enc, 0), &enc);
|
quant_energy_finalise(st->mode, bandE, st->oldBandE, error, fine_quant, fine_priority, nbCompressedBytes*8-ec_enc_tell(&enc, 0), &enc);
|
||||||
|
@ -1211,7 +1207,6 @@ int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int
|
||||||
VARDECL(celt_norm_t, X);
|
VARDECL(celt_norm_t, X);
|
||||||
VARDECL(celt_norm_t, P);
|
VARDECL(celt_norm_t, P);
|
||||||
VARDECL(celt_ener_t, bandE);
|
VARDECL(celt_ener_t, bandE);
|
||||||
VARDECL(celt_pgain_t, gains);
|
|
||||||
VARDECL(int, fine_quant);
|
VARDECL(int, fine_quant);
|
||||||
VARDECL(int, pulses);
|
VARDECL(int, pulses);
|
||||||
VARDECL(int, offsets);
|
VARDECL(int, offsets);
|
||||||
|
@ -1243,7 +1238,6 @@ int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int
|
||||||
ALLOC(X, C*N, celt_norm_t); /**< Interleaved normalised MDCTs */
|
ALLOC(X, C*N, celt_norm_t); /**< Interleaved normalised MDCTs */
|
||||||
ALLOC(P, C*N, celt_norm_t); /**< Interleaved normalised pitch MDCTs*/
|
ALLOC(P, C*N, celt_norm_t); /**< Interleaved normalised pitch MDCTs*/
|
||||||
ALLOC(bandE, st->mode->nbEBands*C, celt_ener_t);
|
ALLOC(bandE, st->mode->nbEBands*C, celt_ener_t);
|
||||||
ALLOC(gains, st->mode->nbPBands, celt_pgain_t);
|
|
||||||
|
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
{
|
{
|
||||||
|
@ -1286,8 +1280,6 @@ int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int
|
||||||
gain_id = ec_dec_uint(&dec, 16);
|
gain_id = ec_dec_uint(&dec, 16);
|
||||||
} else {
|
} else {
|
||||||
pitch_index = 0;
|
pitch_index = 0;
|
||||||
for (i=0;i<st->mode->nbPBands;i++)
|
|
||||||
gains[i] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ALLOC(fine_quant, st->mode->nbEBands, int);
|
ALLOC(fine_quant, st->mode->nbEBands, int);
|
||||||
|
@ -1317,10 +1309,10 @@ int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int
|
||||||
|
|
||||||
/* Decode fixed codebook and merge with pitch */
|
/* Decode fixed codebook and merge with pitch */
|
||||||
if (C==1)
|
if (C==1)
|
||||||
unquant_bands(st->mode, X, P, 0, gains, bandE, pulses, shortBlocks, has_fold, len*8, &dec);
|
unquant_bands(st->mode, X, P, bandE, pulses, shortBlocks, has_fold, len*8, &dec);
|
||||||
#ifndef DISABLE_STEREO
|
#ifndef DISABLE_STEREO
|
||||||
else
|
else
|
||||||
unquant_bands_stereo(st->mode, X, P, 0, gains, bandE, pulses, shortBlocks, has_fold, len*8, &dec);
|
unquant_bands_stereo(st->mode, X, P, bandE, pulses, shortBlocks, has_fold, len*8, &dec);
|
||||||
#endif
|
#endif
|
||||||
unquant_energy_finalise(st->mode, bandE, st->oldBandE, fine_quant, fine_priority, len*8-ec_dec_tell(&dec, 0), &dec);
|
unquant_energy_finalise(st->mode, bandE, st->oldBandE, fine_quant, fine_priority, len*8-ec_dec_tell(&dec, 0), &dec);
|
||||||
|
|
||||||
|
|
|
@ -73,16 +73,6 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
|
||||||
fprintf(file, "\n");
|
fprintf(file, "\n");
|
||||||
|
|
||||||
|
|
||||||
fprintf(file, "#ifndef DEF_PBANDS%d_%d\n", mode->Fs, mode->mdctSize);
|
|
||||||
fprintf(file, "#define DEF_PBANDS%d_%d\n", mode->Fs, mode->mdctSize);
|
|
||||||
fprintf (file, "static const celt_int16_t pBands%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbPBands+2);
|
|
||||||
for (j=0;j<mode->nbPBands+2;j++)
|
|
||||||
fprintf (file, "%d, ", mode->pBands[j]);
|
|
||||||
fprintf (file, "};\n");
|
|
||||||
fprintf(file, "#endif\n");
|
|
||||||
fprintf(file, "\n");
|
|
||||||
|
|
||||||
|
|
||||||
fprintf(file, "#ifndef DEF_WINDOW%d\n", mode->overlap);
|
fprintf(file, "#ifndef DEF_WINDOW%d\n", mode->overlap);
|
||||||
fprintf(file, "#define DEF_WINDOW%d\n", mode->overlap);
|
fprintf(file, "#define DEF_WINDOW%d\n", mode->overlap);
|
||||||
fprintf (file, "static const celt_word16_t window%d[%d] = {\n", mode->overlap, mode->overlap);
|
fprintf (file, "static const celt_word16_t window%d[%d] = {\n", mode->overlap, mode->overlap);
|
||||||
|
@ -148,10 +138,8 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
|
||||||
fprintf(file, "%d,\t/* mdctSize */\n", mode->mdctSize);
|
fprintf(file, "%d,\t/* mdctSize */\n", mode->mdctSize);
|
||||||
fprintf(file, "%d,\t/* nbChannels */\n", mode->nbChannels);
|
fprintf(file, "%d,\t/* nbChannels */\n", mode->nbChannels);
|
||||||
fprintf(file, "%d,\t/* nbEBands */\n", mode->nbEBands);
|
fprintf(file, "%d,\t/* nbEBands */\n", mode->nbEBands);
|
||||||
fprintf(file, "%d,\t/* nbPBands */\n", mode->nbPBands);
|
|
||||||
fprintf(file, "%d,\t/* pitchEnd */\n", mode->pitchEnd);
|
fprintf(file, "%d,\t/* pitchEnd */\n", mode->pitchEnd);
|
||||||
fprintf(file, "eBands%d_%d,\t/* eBands */\n", mode->Fs, mode->mdctSize);
|
fprintf(file, "eBands%d_%d,\t/* eBands */\n", mode->Fs, mode->mdctSize);
|
||||||
fprintf(file, "pBands%d_%d,\t/* pBands */\n", mode->Fs, mode->mdctSize);
|
|
||||||
fprintf(file, WORD16 ",\t/* ePredCoef */\n", mode->ePredCoef);
|
fprintf(file, WORD16 ",\t/* ePredCoef */\n", mode->ePredCoef);
|
||||||
fprintf(file, "%d,\t/* nbAllocVectors */\n", mode->nbAllocVectors);
|
fprintf(file, "%d,\t/* nbAllocVectors */\n", mode->nbAllocVectors);
|
||||||
fprintf(file, "allocVectors%d_%d_%d,\t/* allocVectors */\n", mode->Fs, mode->mdctSize, mode->nbChannels);
|
fprintf(file, "allocVectors%d_%d_%d,\t/* allocVectors */\n", mode->Fs, mode->mdctSize, mode->nbChannels);
|
||||||
|
|
|
@ -82,8 +82,6 @@ int celt_mode_info(const CELTMode *mode, int request, celt_int32_t *value)
|
||||||
|
|
||||||
#ifndef STATIC_MODES
|
#ifndef STATIC_MODES
|
||||||
|
|
||||||
#define PBANDS 8
|
|
||||||
|
|
||||||
/* Defining 25 critical bands for the full 0-20 kHz audio bandwidth
|
/* Defining 25 critical bands for the full 0-20 kHz audio bandwidth
|
||||||
Taken from http://ccrma.stanford.edu/~jos/bbt/Bark_Frequency_Scale.html */
|
Taken from http://ccrma.stanford.edu/~jos/bbt/Bark_Frequency_Scale.html */
|
||||||
#define BARK_BANDS 25
|
#define BARK_BANDS 25
|
||||||
|
@ -95,8 +93,6 @@ static const celt_int16_t bark_freq[BARK_BANDS+1] = {
|
||||||
6400, 7700, 9500, 12000, 15500,
|
6400, 7700, 9500, 12000, 15500,
|
||||||
20000};
|
20000};
|
||||||
|
|
||||||
static const celt_int16_t pitch_freq[PBANDS+1] ={0, 345, 689, 1034, 1378, 2067, 3273, 5340, 6374};
|
|
||||||
|
|
||||||
/* This allocation table is per critical band. When creating a mode, the bits get added together
|
/* This allocation table is per critical band. When creating a mode, the bits get added together
|
||||||
into the codec bands, which are sometimes larger than one critical band at low frequency */
|
into the codec bands, which are sometimes larger than one critical band at low frequency */
|
||||||
|
|
||||||
|
@ -179,40 +175,6 @@ static celt_int16_t *compute_ebands(celt_int32_t Fs, int frame_size, int nbShort
|
||||||
return eBands;
|
return eBands;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void compute_pbands(CELTMode *mode, int res)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
celt_int16_t *pBands;
|
|
||||||
pBands=celt_alloc(sizeof(celt_int16_t)*(PBANDS+2));
|
|
||||||
mode->pBands = pBands;
|
|
||||||
if (pBands==NULL)
|
|
||||||
return;
|
|
||||||
mode->nbPBands = PBANDS;
|
|
||||||
for (i=0;i<PBANDS+1;i++)
|
|
||||||
{
|
|
||||||
pBands[i] = (pitch_freq[i]+res/2)/res;
|
|
||||||
if (pBands[i] < mode->eBands[i])
|
|
||||||
pBands[i] = mode->eBands[i];
|
|
||||||
}
|
|
||||||
pBands[PBANDS+1] = mode->eBands[mode->nbEBands+1];
|
|
||||||
for (i=1;i<mode->nbPBands+1;i++)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
for (j=0;j<mode->nbEBands;j++)
|
|
||||||
if (mode->eBands[j] <= pBands[i] && mode->eBands[j+1] > pBands[i])
|
|
||||||
break;
|
|
||||||
if (mode->eBands[j] != pBands[i])
|
|
||||||
{
|
|
||||||
if (pBands[i]-mode->eBands[j] < mode->eBands[j+1]-pBands[i] &&
|
|
||||||
mode->eBands[j] != pBands[i-1])
|
|
||||||
pBands[i] = mode->eBands[j];
|
|
||||||
else
|
|
||||||
pBands[i] = mode->eBands[j+1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mode->pitchEnd = pBands[PBANDS];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void compute_allocation_table(CELTMode *mode, int res)
|
static void compute_allocation_table(CELTMode *mode, int res)
|
||||||
{
|
{
|
||||||
int i, j, nBark;
|
int i, j, nBark;
|
||||||
|
@ -382,9 +344,8 @@ CELTMode *celt_mode_create(celt_int32_t Fs, int channels, int frame_size, int *e
|
||||||
mode->eBands = compute_ebands(Fs, frame_size, mode->nbShortMdcts, &mode->nbEBands);
|
mode->eBands = compute_ebands(Fs, frame_size, mode->nbShortMdcts, &mode->nbEBands);
|
||||||
if (mode->eBands==NULL)
|
if (mode->eBands==NULL)
|
||||||
goto failure;
|
goto failure;
|
||||||
compute_pbands(mode, res);
|
|
||||||
if (mode->pBands==NULL)
|
mode->pitchEnd = 3000*(celt_int32_t)frame_size/Fs;
|
||||||
goto failure;
|
|
||||||
|
|
||||||
/* Overlap must be divisible by 4 */
|
/* Overlap must be divisible by 4 */
|
||||||
if (mode->nbShortMdcts > 1)
|
if (mode->nbShortMdcts > 1)
|
||||||
|
@ -494,7 +455,6 @@ void celt_mode_destroy(CELTMode *mode)
|
||||||
}
|
}
|
||||||
celt_free((int**)mode->bits);
|
celt_free((int**)mode->bits);
|
||||||
celt_free((int*)mode->eBands);
|
celt_free((int*)mode->eBands);
|
||||||
celt_free((int*)mode->pBands);
|
|
||||||
celt_free((int*)mode->allocVectors);
|
celt_free((int*)mode->allocVectors);
|
||||||
|
|
||||||
celt_free((celt_word16_t*)mode->window);
|
celt_free((celt_word16_t*)mode->window);
|
||||||
|
|
|
@ -76,11 +76,9 @@ struct CELTMode {
|
||||||
int nbChannels;
|
int nbChannels;
|
||||||
|
|
||||||
int nbEBands;
|
int nbEBands;
|
||||||
int nbPBands;
|
|
||||||
int pitchEnd;
|
int pitchEnd;
|
||||||
|
|
||||||
const celt_int16_t *eBands; /**< Definition for each "pseudo-critical band" */
|
const celt_int16_t *eBands; /**< Definition for each "pseudo-critical band" */
|
||||||
const celt_int16_t *pBands; /**< Definition of the bands used for the pitch */
|
|
||||||
|
|
||||||
celt_word16_t ePredCoef;/**< Prediction coefficient for the energy encoding */
|
celt_word16_t ePredCoef;/**< Prediction coefficient for the energy encoding */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue