Encoding the tf parameters after coarse energy

Also a minor cleanup to the recombining/division
This commit is contained in:
Jean-Marc Valin 2010-06-05 23:12:19 -04:00
parent 47ad4a0938
commit 0a571ef92a
2 changed files with 32 additions and 31 deletions

View file

@ -808,6 +808,8 @@ static void quant_band(int encode, const CELTMode *m, int i, celt_norm *X, celt_
if (resynth) if (resynth)
{ {
int k;
if (split) if (split)
{ {
int j; int j;
@ -831,34 +833,25 @@ static void quant_band(int encode, const CELTMode *m, int i, celt_norm *X, celt_
if (lowband) if (lowband)
interleave_vector(lowband, N_B, spread0); interleave_vector(lowband, N_B, spread0);
} }
if (time_divide)
N_B = N_B0;
spread = spread0;
for (k=0;k<time_divide;k++)
{ {
int k; spread >>= 1;
N_B = N_B0; N_B <<= 1;
spread = spread0; haar1(X, N_B, spread);
for (k=0;k<time_divide;k++) if (lowband)
{ haar1(lowband, N_B, spread);
spread >>= 1;
N_B <<= 1;
haar1(X, N_B, spread);
if (lowband)
haar1(lowband, N_B, spread);
}
} }
if (!stereo && level == 0) for (k=0;k<recombine;k++)
{ {
int k; haar1(X, N_B, spread);
spread = spread0; if (lowband)
N_B = N_B0; haar1(lowband, N_B, spread);
for (k=0;k<recombine;k++) N_B>>=1;
{ spread <<= 1;
haar1(X, N_B, spread);
if (lowband)
haar1(lowband, N_B, spread);
N_B>>=1;
spread <<= 1;
}
} }
if (lowband_out && !stereo) if (lowband_out && !stereo)

View file

@ -536,9 +536,9 @@ static void mdct_shape(const CELTMode *mode, celt_norm *X, int start,
renormalise_bands(mode, X, C, M); renormalise_bands(mode, X, C, M);
} }
static void tf_encode(celt_word16 *bandLogE, celt_word16 *oldBandE, int len, int C, int isTransient, int *tf_res, int nbCompressedBytes, ec_enc *enc) static void tf_analysis(celt_word16 *bandLogE, celt_word16 *oldBandE, int len, int C, int isTransient, int *tf_res, int nbCompressedBytes)
{ {
int i, curr; int i;
celt_word16 threshold; celt_word16 threshold;
VARDECL(celt_word32, metric); VARDECL(celt_word32, metric);
celt_word32 cost0; celt_word32 cost0;
@ -614,6 +614,12 @@ static void tf_encode(celt_word16 *bandLogE, celt_word16 *oldBandE, int len, int
else else
tf_res[i] = path0[i+1]; tf_res[i] = path0[i+1];
} }
RESTORE_STACK
}
static void tf_encode(int len, int isTransient, int *tf_res, ec_enc *enc)
{
int curr, i;
ec_enc_bit_prob(enc, tf_res[0], isTransient ? 16384 : 4096); ec_enc_bit_prob(enc, tf_res[0], isTransient ? 16384 : 4096);
curr = tf_res[0]; curr = tf_res[0];
for (i=1;i<len;i++) for (i=1;i<len;i++)
@ -621,7 +627,6 @@ static void tf_encode(celt_word16 *bandLogE, celt_word16 *oldBandE, int len, int
ec_enc_bit_prob(enc, tf_res[i] ^ curr, 4096); ec_enc_bit_prob(enc, tf_res[i] ^ curr, 4096);
curr = tf_res[i]; curr = tf_res[i];
} }
RESTORE_STACK
} }
static void tf_decode(int len, int C, int isTransient, int *tf_res, ec_dec *dec) static void tf_decode(int len, int C, int isTransient, int *tf_res, ec_dec *dec)
@ -905,7 +910,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, c
} }
ALLOC(tf_res, st->mode->nbEBands, int); ALLOC(tf_res, st->mode->nbEBands, int);
tf_encode(bandLogE, st->oldBandE, st->mode->nbEBands, C, isTransient, tf_res, nbCompressedBytes, enc); tf_analysis(bandLogE, st->oldBandE, st->mode->nbEBands, C, isTransient, tf_res, nbCompressedBytes);
/* Bit allocation */ /* Bit allocation */
ALLOC(error, C*st->mode->nbEBands, celt_word16); ALLOC(error, C*st->mode->nbEBands, celt_word16);
@ -970,6 +975,8 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, c
ec_byte_shrink(&buf, nbCompressedBytes); ec_byte_shrink(&buf, nbCompressedBytes);
} }
tf_encode(st->mode->nbEBands, isTransient, tf_res, enc);
ALLOC(offsets, st->mode->nbEBands, int); ALLOC(offsets, st->mode->nbEBands, int);
ALLOC(fine_priority, st->mode->nbEBands, int); ALLOC(fine_priority, st->mode->nbEBands, int);
@ -1691,13 +1698,14 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da
pitch_index = 0; pitch_index = 0;
} }
ALLOC(tf_res, st->mode->nbEBands, int);
tf_decode(st->mode->nbEBands, C, isTransient, tf_res, dec);
ALLOC(fine_quant, st->mode->nbEBands, int); ALLOC(fine_quant, st->mode->nbEBands, int);
/* Get band energies */ /* Get band energies */
unquant_coarse_energy(st->mode, st->start, bandE, st->oldBandE, len*4-8, intra_ener, st->mode->prob, dec, C); unquant_coarse_energy(st->mode, st->start, bandE, st->oldBandE, len*4-8, intra_ener, st->mode->prob, dec, C);
ALLOC(tf_res, st->mode->nbEBands, int);
tf_decode(st->mode->nbEBands, C, isTransient, tf_res, dec);
ALLOC(pulses, st->mode->nbEBands, int); ALLOC(pulses, st->mode->nbEBands, int);
ALLOC(offsets, st->mode->nbEBands, int); ALLOC(offsets, st->mode->nbEBands, int);
ALLOC(fine_priority, st->mode->nbEBands, int); ALLOC(fine_priority, st->mode->nbEBands, int);