ref: fe0b8e8db420303dc891cfe8d23eac73a5bc7846
parent: 21f2666155d52d2604157dcad94249291062f7b4
author: Jean-Marc Valin <[email protected]>
date: Fri May 23 09:35:35 EDT 2008
infrastructure changes for upcoming stereo improvements
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -289,7 +289,6 @@
P[i] = 0;
}
-
/* Quantisation of the residual */
void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, celt_mask_t *W, int total_bits, ec_enc *enc)
{
@@ -409,6 +408,16 @@
}
#ifndef DISABLE_STEREO
+void stereo_decision(const CELTMode *m, celt_norm_t * restrict X, int *stereo_mode, int len)
+{
+ int i;
+ for (i=0;i<len-5;i++)
+ stereo_mode[i] = 0;
+ for (;i<len;i++)
+ stereo_mode[i] = 1;
+}
+
+
void stereo_mix(const CELTMode *m, celt_norm_t *X, const celt_ener_t *bank, int dir)
{
int i;
--- a/libcelt/bands.h
+++ b/libcelt/bands.h
@@ -97,6 +97,8 @@
*/
void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, int total_bits, ec_dec *dec);
+void stereo_decision(const CELTMode *m, celt_norm_t * restrict X, int *stereo_mode, int len);
+
void stereo_mix(const CELTMode *m, celt_norm_t *X, const celt_ener_t *bank, int dir);
#endif /* BANDS_H */
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -364,7 +364,7 @@
#endif
mode->window = window;
- compute_alloc_cache(mode);
+ mode->bits = (const celt_int16_t **)compute_alloc_cache(mode, mode->nbChannels);
#ifndef SHORTCUTS
psydecay_init(&mode->psy, MAX_PERIOD/2, mode->Fs);
--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -97,19 +97,19 @@
return L;
}
-void compute_alloc_cache(CELTMode *m)
+celt_int16_t **compute_alloc_cache(CELTMode *m, int C)
{
- int i, prevN, BC;
+ int i, prevN;
celt_int16_t **bits;
const celt_int16_t *eBands = m->eBands;
bits = celt_alloc(m->nbEBands*sizeof(celt_int16_t*));
- BC = m->nbChannels;
+ C = m->nbChannels;
prevN = -1;
for (i=0;i<m->nbEBands;i++)
{
- int N = BC*(eBands[i+1]-eBands[i]);
+ int N = C*(eBands[i+1]-eBands[i]);
if (N == prevN && eBands[i] < m->pitchEnd)
{
bits[i] = bits[i-1];
@@ -150,7 +150,7 @@
RESTORE_STACK;
}
}
- m->bits = (const celt_int16_t * const *)bits;
+ return bits;
}
#endif /* !STATIC_MODES */
--- a/libcelt/rate.h
+++ b/libcelt/rate.h
@@ -36,7 +36,7 @@
#define LOG_MAX_PULSES 6
/** Computes a cache of the pulses->bits mapping in each band */
-void compute_alloc_cache(CELTMode *m);
+celt_int16_t **compute_alloc_cache(CELTMode *m, int C);
/** Compute the pulse allocation, i.e. how many pulses will go in each
* band.