ref: 0a571ef92a40cfa18ef1a9d47a39f7ba2756f36c
parent: 47ad4a093876af2f19216dae2dd121c2205231f0
author: Jean-Marc Valin <[email protected]>
date: Sat Jun 5 19:12:19 EDT 2010
Encoding the tf parameters after coarse energy Also a minor cleanup to the recombining/division
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -808,6 +808,8 @@
if (resynth)
{
+ int k;
+
if (split)
{
int j;
@@ -831,34 +833,25 @@
if (lowband)
interleave_vector(lowband, N_B, spread0);
}
- if (time_divide)
+
+ N_B = N_B0;
+ spread = spread0;
+ for (k=0;k<time_divide;k++)
{
- int k;
- N_B = N_B0;
- spread = spread0;
- for (k=0;k<time_divide;k++)
- {
- spread >>= 1;
- N_B <<= 1;
- haar1(X, N_B, spread);
- 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;
- spread = spread0;
- N_B = N_B0;
- for (k=0;k<recombine;k++)
- {
- haar1(X, N_B, spread);
- if (lowband)
- haar1(lowband, N_B, spread);
- 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)
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -536,9 +536,9 @@
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;
VARDECL(celt_word32, metric);
celt_word32 cost0;
@@ -614,6 +614,12 @@
else
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);
curr = tf_res[0];
for (i=1;i<len;i++)
@@ -621,7 +627,6 @@
ec_enc_bit_prob(enc, tf_res[i] ^ curr, 4096);
curr = tf_res[i];
}
- RESTORE_STACK
}
static void tf_decode(int len, int C, int isTransient, int *tf_res, ec_dec *dec)
@@ -905,7 +910,7 @@
}
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 */
ALLOC(error, C*st->mode->nbEBands, celt_word16);
@@ -970,6 +975,8 @@
ec_byte_shrink(&buf, nbCompressedBytes);
}
+ tf_encode(st->mode->nbEBands, isTransient, tf_res, enc);
+
ALLOC(offsets, st->mode->nbEBands, int);
ALLOC(fine_priority, st->mode->nbEBands, int);
@@ -1691,13 +1698,14 @@
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);
/* Get band energies */
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(offsets, st->mode->nbEBands, int);
ALLOC(fine_priority, st->mode->nbEBands, int);