Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/celt-0.7.0.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jean-marc.valin@usherbrooke.ca>2009-10-21 15:08:27 +0400
committerJean-Marc Valin <jean-marc.valin@usherbrooke.ca>2009-10-21 15:08:27 +0400
commitab4dcc5c90140f7a6fefdef2e2acfdf7ecc152c9 (patch)
tree7d79d5dc86a2978c263c8c0d55ad777c63c7ad70
parent73bf6332ed4f60dd40469970f36f0505c595afc0 (diff)
Allow coarse energy to take almost all the bits. Also, fixed a some issues with
the VBR rate controller.
-rw-r--r--libcelt/celt.c9
-rw-r--r--libcelt/quant_bands.c12
2 files changed, 7 insertions, 14 deletions
diff --git a/libcelt/celt.c b/libcelt/celt.c
index 2c9f4ef..21edb0c 100644
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -546,7 +546,7 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig * pcm, celt_sig
int pitch_index;
int bits;
int has_fold=1;
- unsigned coarse_needed;
+ int coarse_needed;
ec_byte_buffer buf;
ec_enc enc;
VARDECL(celt_sig, in);
@@ -766,7 +766,7 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig * pcm, celt_sig
/* Bit allocation */
ALLOC(error, C*st->mode->nbEBands, celt_word16);
- coarse_needed = quant_coarse_energy(st->mode, bandLogE, st->oldBandE, nbCompressedBytes*8/3, intra_ener, st->mode->prob, error, &enc, C);
+ coarse_needed = quant_coarse_energy(st->mode, bandLogE, st->oldBandE, nbCompressedBytes*8-16, intra_ener, st->mode->prob, error, &enc, C);
coarse_needed = ((coarse_needed*3-1)>>3)+1;
/* Variable bitrate */
@@ -791,7 +791,6 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig * pcm, celt_sig
/* In VBR mode the frame size must not be reduced so much that it would result in the coarse energy busting its budget */
target=IMAX(coarse_needed,(target+64)/128);
nbCompressedBytes=IMIN(nbCompressedBytes,target);
-
/* Make the adaptation coef (alpha) higher at the beginning */
if (st->vbr_count < 990)
{
@@ -820,7 +819,6 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig * pcm, celt_sig
int adjust = 1+(st->vbr_reservoir-vbr_bound-1)/(8<<BITRES);
nbCompressedBytes -= adjust;
st->vbr_reservoir -= adjust*(8<<BITRES);
- st->vbr_offset -= 8<<BITRES;
/*printf ("-%d\n", adjust);*/
} else if (st->vbr_reservoir < 0)
{
@@ -828,7 +826,6 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig * pcm, celt_sig
int adjust = 1-(st->vbr_reservoir-1)/(8<<BITRES);
st->vbr_reservoir += adjust*(8<<BITRES);
nbCompressedBytes += adjust;
- st->vbr_offset += 8<<BITRES;
/*printf ("+%d\n", adjust);*/
}
@@ -1376,7 +1373,7 @@ int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int
ALLOC(fine_quant, st->mode->nbEBands, int);
/* Get band energies */
- unquant_coarse_energy(st->mode, bandE, st->oldBandE, len*8/3, intra_ener, st->mode->prob, &dec, C);
+ unquant_coarse_energy(st->mode, bandE, st->oldBandE, len*8-16, intra_ener, st->mode->prob, &dec, C);
ALLOC(pulses, st->mode->nbEBands, int);
ALLOC(offsets, st->mode->nbEBands, int);
diff --git a/libcelt/quant_bands.c b/libcelt/quant_bands.c
index 753c01d..dac64be 100644
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -89,7 +89,6 @@ void quant_prob_free(int *freq)
unsigned quant_coarse_energy(const CELTMode *m, celt_word16 *eBands, celt_word16 *oldEBands, int budget, int intra, int *prob, celt_word16 *error, ec_enc *enc, int _C)
{
int i, c;
- unsigned bits;
unsigned bits_used = 0;
celt_word16 prev[2] = {0,0};
celt_word16 coef = m->ePredCoef;
@@ -103,8 +102,7 @@ unsigned quant_coarse_energy(const CELTMode *m, celt_word16 *eBands, celt_word16
}
/* The .8 is a heuristic */
beta = MULT16_16_Q15(QCONST16(.8f,15),coef);
-
- bits = ec_enc_tell(enc, 0);
+
/* Encode at a fixed coarse resolution */
for (i=0;i<m->nbEBands;i++)
{
@@ -127,7 +125,7 @@ unsigned quant_coarse_energy(const CELTMode *m, celt_word16 *eBands, celt_word16
#endif
/* If we don't have enough bits to encode all the energy, just assume something safe.
We allow slightly busting the budget here */
- bits_used=ec_enc_tell(enc, 0) - bits;
+ bits_used=ec_enc_tell(enc, 0);
if (bits_used > budget)
{
qi = -1;
@@ -223,7 +221,6 @@ void quant_energy_finalise(const CELTMode *m, celt_ener *eBands, celt_word16 *ol
void unquant_coarse_energy(const CELTMode *m, celt_ener *eBands, celt_word16 *oldEBands, int budget, int intra, int *prob, ec_dec *dec, int _C)
{
int i, c;
- unsigned bits;
celt_word16 prev[2] = {0, 0};
celt_word16 coef = m->ePredCoef;
celt_word16 beta;
@@ -236,8 +233,7 @@ void unquant_coarse_energy(const CELTMode *m, celt_ener *eBands, celt_word16 *ol
}
/* The .8 is a heuristic */
beta = MULT16_16_Q15(QCONST16(.8f,15),coef);
-
- bits = ec_dec_tell(dec, 0);
+
/* Decode at a fixed coarse resolution */
for (i=0;i<m->nbEBands;i++)
{
@@ -248,7 +244,7 @@ void unquant_coarse_energy(const CELTMode *m, celt_ener *eBands, celt_word16 *ol
celt_word16 mean = MULT16_16_Q15(Q15ONE-coef,eMeans[i]);
/* If we didn't have enough bits to encode all the energy, just assume something safe.
We allow slightly busting the budget here */
- if (ec_dec_tell(dec, 0) - bits > budget)
+ if (ec_dec_tell(dec, 0) > budget)
qi = -1;
else
qi = ec_laplace_decode_start(dec, prob[2*i], prob[2*i+1]);