Commit 5e7f02de authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Moving intra decision to quant_coarse_energy()

parent 908958ca
......@@ -619,7 +619,6 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, c
VARDECL(int, offsets);
VARDECL(int, fine_priority);
VARDECL(int, tf_res);
int intra_ener = 0;
int shortBlocks=0;
int isTransient=0;
int transient_time, transient_time_quant;
......@@ -630,7 +629,6 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, c
int mdct_weight_pos=0;
int LM, M;
int tf_select;
celt_word16 max_decay;
int nbFilledBytes, nbAvailableBytes;
int effEnd;
SAVE_STACK;
......@@ -795,28 +793,15 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, c
}
ALLOC(tf_res, st->mode->nbEBands, int);
/* Needs to be before coarse energy quantization because otherwise the energy gets modified */
tf_select = tf_analysis(bandLogE, st->oldBandE, effEnd, C, isTransient, tf_res, nbAvailableBytes);
for (i=effEnd;i<st->end;i++)
tf_res[i] = tf_res[effEnd-1];
/* Don't use intra energy when we're operating at low bit-rate */
intra_ener = st->force_intra || (st->delayedIntra && nbAvailableBytes > st->end);
if (shortBlocks || intra_decision(bandLogE, st->oldBandE, st->start, effEnd, st->mode->nbEBands, C))
st->delayedIntra = 1;
else
st->delayedIntra = 0;
/* Encode the global flags using a simple probability model
(first symbols in the stream) */
ec_enc_bit_prob(enc, intra_ener, 8192);
ALLOC(error, C*st->mode->nbEBands, celt_word16);
#ifdef FIXED_POINT
max_decay = MIN32(QCONST16(16,DB_SHIFT), SHL32(EXTEND32(nbAvailableBytes),DB_SHIFT-3));
#else
max_decay = MIN32(16.f, .125f*nbAvailableBytes);
#endif
quant_coarse_energy(st->mode, st->start, st->end, bandLogE, st->oldBandE, nbCompressedBytes*8, intra_ener, st->mode->prob, error, enc, C, LM, max_decay);
quant_coarse_energy(st->mode, st->start, st->end, effEnd, bandLogE,
st->oldBandE, nbCompressedBytes*8, st->mode->prob,
error, enc, C, LM, nbAvailableBytes, st->force_intra, &st->delayedIntra);
ec_enc_bit_prob(enc, shortBlocks!=0, 8192);
......
......@@ -66,7 +66,7 @@ static const celt_word16 pred_coef[4] = {29440, 26112, 21248, 16384};
static const celt_word16 pred_coef[4] = {29440/32768., 26112/32768., 21248/32768., 16384/32768.};
#endif
int intra_decision(celt_word16 *eBands, celt_word16 *oldEBands, int start, int end, int len, int C)
static int intra_decision(const celt_word16 *eBands, celt_word16 *oldEBands, int start, int end, int len, int C)
{
int c, i;
celt_word32 dist = 0;
......@@ -106,13 +106,34 @@ void quant_prob_free(int *freq)
celt_free(freq);
}
void quant_coarse_energy(const CELTMode *m, int start, int end, const celt_word16 *eBands, celt_word16 *oldEBands, int budget, int intra, int *prob, celt_word16 *error, ec_enc *enc, int _C, int LM, celt_word16 max_decay)
void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
const celt_word16 *eBands, celt_word16 *oldEBands, int budget,
int *prob, celt_word16 *error, ec_enc *enc, int _C, int LM,
int nbAvailableBytes, int force_intra, int *delayedIntra)
{
int i, c;
celt_word32 prev[2] = {0,0};
celt_word16 coef;
celt_word16 beta;
const int C = CHANNELS(_C);
int intra;
celt_word16 max_decay;
intra = force_intra || (*delayedIntra && nbAvailableBytes > end);
if (/*shortBlocks || */intra_decision(eBands, oldEBands, start, effEnd, m->nbEBands, C))
*delayedIntra = 1;
else
*delayedIntra = 0;
/* Encode the global flags using a simple probability model
(first symbols in the stream) */
ec_enc_bit_prob(enc, intra, 8192);
#ifdef FIXED_POINT
max_decay = MIN32(QCONST16(16,DB_SHIFT), SHL32(EXTEND32(nbAvailableBytes),DB_SHIFT-3));
#else
max_decay = MIN32(16.f, .125f*nbAvailableBytes);
#endif
coef = pred_coef[LM];
......
......@@ -48,9 +48,10 @@ void log2Amp(const CELTMode *m, int start, int end,
int *quant_prob_alloc(const CELTMode *m);
void quant_prob_free(int *freq);
int intra_decision(celt_word16 *eBands, celt_word16 *oldEBands, int start, int end, int len, int C);
void quant_coarse_energy(const CELTMode *m, int start, int end, const celt_word16 *eBands, celt_word16 *oldEBands, int budget, int intra, int *prob, celt_word16 *error, ec_enc *enc, int _C, int LM, celt_word16 max_decay);
void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
const celt_word16 *eBands, celt_word16 *oldEBands, int budget,
int *prob, celt_word16 *error, ec_enc *enc, int _C, int LM,
int nbAvailableBytes, int force_intra, int *delayedIntra);
void quant_fine_energy(const CELTMode *m, int start, int end, celt_ener *eBands, celt_word16 *oldEBands, celt_word16 *error, int *fine_quant, ec_enc *enc, int _C);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment