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

gitlab.com/quite/celt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy B. Terriberry <tterribe@xiph.org>2011-02-04 01:22:15 +0300
committerJean-Marc Valin <jean-marc.valin@usherbrooke.ca>2011-02-04 05:48:52 +0300
commita093f4df740b7680443e938775b4db2b0fa24844 (patch)
tree439682b2f4009e3438095cf7f4d7a932edacd4c9 /libcelt/quant_bands.c
parentef986e44211bc0fd3820700b61e552828a0d8c65 (diff)
Refactor the entropy coder.
This unifies the byte buffer, encoder, and decoder into a single struct. The common encoder and decoder functions (such as ec_tell()) can operate on either one, simplifying code which uses both. The precision argument to ec_tell() has been removed. It now comes in two precisions: ec_tell() gives 1 bit precision in two operations, and ec_tell_frac() gives 1/8th bit precision in... somewhat more. ec_{enc|dec}_bit_prob() were removed (they are no longer needed). Some of the byte buffer access functions were made static and removed from the cross-module API. All of the code in rangeenc.c and rangedec.c was merged into entenc.c and entdec.c, respectively, as we are no longer considering alternative backends. rangeenc.c and rangede.c have been removed entirely. This passes make check, after disabling the modes that we removed support for in cf5d3a8c.
Diffstat (limited to 'libcelt/quant_bands.c')
-rw-r--r--libcelt/quant_bands.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/libcelt/quant_bands.c b/libcelt/quant_bands.c
index 627aa3d..83b9d3b 100644
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -218,7 +218,7 @@ static int quant_coarse_energy_impl(const CELTMode *m, int start, int end,
qi0 = qi;
/* If we don't have enough bits to encode all the energy, just assume
something safe. */
- tell = ec_enc_tell(enc, 0);
+ tell = ec_tell(enc);
bits_left = budget-tell-3*C*(end-i);
if (i!=start && bits_left < 30)
{
@@ -272,7 +272,6 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
VARDECL(celt_word16, oldEBands_intra);
VARDECL(celt_word16, error_intra);
ec_enc enc_start_state;
- ec_byte_buffer buf_start_state;
ec_uint32 tell;
int badness1=0;
SAVE_STACK;
@@ -283,7 +282,7 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
else
*delayedIntra = 0;
- tell = ec_enc_tell(enc, 0);
+ tell = ec_tell(enc);
if (tell+3 > budget)
two_pass = intra = 0;
@@ -297,7 +296,6 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
#endif
enc_start_state = *enc;
- buf_start_state = *(enc->buf);
ALLOC(oldEBands_intra, C*m->nbEBands, celt_word16);
ALLOC(error_intra, C*m->nbEBands, celt_word16);
@@ -312,38 +310,34 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
if (!intra)
{
ec_enc enc_intra_state;
- ec_byte_buffer buf_intra_state;
int tell_intra;
ec_uint32 nstart_bytes;
ec_uint32 nintra_bytes;
int badness2;
VARDECL(unsigned char, intra_bits);
- tell_intra = ec_enc_tell(enc, 3);
+ tell_intra = ec_tell_frac(enc);
enc_intra_state = *enc;
- buf_intra_state = *(enc->buf);
- nstart_bytes = ec_byte_bytes(&buf_start_state);
- nintra_bytes = ec_byte_bytes(&buf_intra_state);
+ nstart_bytes = ec_range_bytes(&enc_start_state);
+ nintra_bytes = ec_range_bytes(&enc_intra_state);
ALLOC(intra_bits, nintra_bytes-nstart_bytes, unsigned char);
/* Copy bits from intra bit-stream */
CELT_COPY(intra_bits,
- ec_byte_get_buffer(&buf_intra_state) + nstart_bytes,
+ ec_get_buffer(&enc_intra_state) + nstart_bytes,
nintra_bytes - nstart_bytes);
*enc = enc_start_state;
- *(enc->buf) = buf_start_state;
badness2 = quant_coarse_energy_impl(m, start, end, eBands, oldEBands, budget,
tell, e_prob_model[LM][intra], error, enc, C, LM, 0, max_decay);
- if (two_pass && (badness1 < badness2 || (badness1 == badness2 && ec_enc_tell(enc, 3) > tell_intra)))
+ if (two_pass && (badness1 < badness2 || (badness1 == badness2 && ec_tell_frac(enc) > tell_intra)))
{
*enc = enc_intra_state;
- *(enc->buf) = buf_intra_state;
/* Copy intra bits to bit-stream */
- CELT_COPY(ec_byte_get_buffer(&buf_intra_state) + nstart_bytes,
+ CELT_COPY(ec_get_buffer(&enc_intra_state) + nstart_bytes,
intra_bits, nintra_bytes - nstart_bytes);
CELT_COPY(oldEBands, oldEBands_intra, C*end);
CELT_COPY(error, error_intra, C*end);
@@ -444,7 +438,7 @@ void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_word16 *o
coef = pred_coef[LM];
}
- budget = dec->buf->storage*8;
+ budget = dec->storage*8;
/* Decode at a fixed coarse resolution */
for (i=start;i<end;i++)
@@ -454,7 +448,7 @@ void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_word16 *o
int qi;
celt_word32 q;
celt_word32 tmp;
- tell = ec_dec_tell(dec, 0);
+ tell = ec_tell(dec);
if(budget-tell>=15)
{
int pi;