Cleaning up intra_decision()
diff --git a/libcelt/celt.c b/libcelt/celt.c
index 8e9e4f6..3e3c0cb 100644
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -883,7 +883,7 @@
/* Don't use intra energy when we're operating at low bit-rate */
intra_ener = st->force_intra || (!has_pitch && st->delayedIntra && nbAvailableBytes > st->end);
- if (shortBlocks || intra_decision(bandLogE, st->oldBandE, effEnd))
+ if (shortBlocks || intra_decision(bandLogE, st->oldBandE, st->start, effEnd, st->mode->nbEBands, C))
st->delayedIntra = 1;
else
st->delayedIntra = 0;
diff --git a/libcelt/quant_bands.c b/libcelt/quant_bands.c
index 9e45292..52f6410 100644
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -53,17 +53,19 @@
static const celt_word16 pred_coef[4] = {29440/32768., 26112/32768., 21248/32768., 16384/32768.};
#endif
-/* FIXME: Implement for stereo */
-int intra_decision(celt_word16 *eBands, celt_word16 *oldEBands, int len)
+int intra_decision(celt_word16 *eBands, celt_word16 *oldEBands, int start, int end, int len, int C)
{
- int i;
+ int c, i;
celt_word32 dist = 0;
- for (i=0;i<len;i++)
+ for (c=0;c<C;c++)
{
- celt_word16 d = SUB16(eBands[i], oldEBands[i]);
- dist = MAC16_16(dist, d,d);
+ for (i=start;i<end;i++)
+ {
+ celt_word16 d = SUB16(eBands[i+c*len], oldEBands[i+c*len]);
+ dist = MAC16_16(dist, d,d);
+ }
}
- return SHR32(dist,2*DB_SHIFT) > 2*len;
+ return SHR32(dist,2*DB_SHIFT) > 2*C*(end-start);
}
int *quant_prob_alloc(const CELTMode *m)
diff --git a/libcelt/quant_bands.h b/libcelt/quant_bands.h
index 722a534..a90ec4f 100644
--- a/libcelt/quant_bands.h
+++ b/libcelt/quant_bands.h
@@ -54,7 +54,7 @@
void compute_fine_allocation(const CELTMode *m, int *bits, int budget);
-int intra_decision(celt_word16 *eBands, celt_word16 *oldEBands, int len);
+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);