Making the modified transient code work with stereo as well

This commit is contained in:
Jean-Marc Valin 2009-05-30 10:09:06 -04:00
parent 18c1c22e16
commit e4c05a4d74

View file

@ -547,15 +547,18 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
compute_mdcts(st->mode, shortBlocks, in, freq); compute_mdcts(st->mode, shortBlocks, in, freq);
if (shortBlocks && !transient_shift) if (shortBlocks && !transient_shift)
{ {
celt_word32_t sum[4]; celt_word32_t sum[4]={1,1,1,1};
int m=0; int m;
for (c=0;c<C;c++)
{
m=0;
do { do {
sum[m] = 1;
celt_word32_t tmp=0; celt_word32_t tmp=0;
for (i=m;i<N;i+=st->mode->nbShortMdcts) for (i=m*C+c;i<N;i+=C*st->mode->nbShortMdcts)
tmp += ABS32(freq[i]); tmp += ABS32(freq[i]);
sum[m++] = tmp; sum[m++] += tmp;
} while (m<st->mode->nbShortMdcts); } while (m<st->mode->nbShortMdcts);
}
m=0; m=0;
#ifdef FIXED_POINT #ifdef FIXED_POINT
do { do {
@ -570,8 +573,13 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
} }
m++; m++;
} while (m<st->mode->nbShortMdcts-1); } while (m<st->mode->nbShortMdcts-1);
for (i=1;i<N;i+=2) if (mdct_weight_shift)
{
for (c=0;c<C;c++)
for (m=mdct_weight_pos+1;m<st->mode->nbShortMdcts;m++)
for (i=m*C+c;i<N;i+=C*st->mode->nbShortMdcts)
freq[i] = SHR32(freq[i],mdct_weight_shift); freq[i] = SHR32(freq[i],mdct_weight_shift);
}
#else #else
do { do {
if (sum[m+1] > 8*sum[m]) if (sum[m+1] > 8*sum[m])
@ -587,8 +595,9 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
} while (m<st->mode->nbShortMdcts-1); } while (m<st->mode->nbShortMdcts-1);
if (mdct_weight_shift) if (mdct_weight_shift)
{ {
for (c=0;c<C;c++)
for (m=mdct_weight_pos+1;m<st->mode->nbShortMdcts;m++) for (m=mdct_weight_pos+1;m<st->mode->nbShortMdcts;m++)
for (i=m;i<N;i+=st->mode->nbShortMdcts) for (i=m*C+c;i<N;i+=C*st->mode->nbShortMdcts)
freq[i] = (1./(1<<mdct_weight_shift))*freq[i]; freq[i] = (1./(1<<mdct_weight_shift))*freq[i];
} }
#endif #endif
@ -793,8 +802,9 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
if (mdct_weight_shift) if (mdct_weight_shift)
{ {
int m; int m;
for (c=0;c<C;c++)
for (m=mdct_weight_pos+1;m<st->mode->nbShortMdcts;m++) for (m=mdct_weight_pos+1;m<st->mode->nbShortMdcts;m++)
for (i=m;i<N;i+=st->mode->nbShortMdcts) for (i=m*C+c;i<N;i+=C*st->mode->nbShortMdcts)
#ifdef FIXED_POINT #ifdef FIXED_POINT
freq[i] = SHL32(freq[i], mdct_weight_shift); freq[i] = SHL32(freq[i], mdct_weight_shift);
#else #else
@ -1251,8 +1261,9 @@ int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int
if (mdct_weight_shift) if (mdct_weight_shift)
{ {
int m; int m;
for (c=0;c<C;c++)
for (m=mdct_weight_pos+1;m<st->mode->nbShortMdcts;m++) for (m=mdct_weight_pos+1;m<st->mode->nbShortMdcts;m++)
for (i=m;i<N;i+=st->mode->nbShortMdcts) for (i=m*C+c;i<N;i+=C*st->mode->nbShortMdcts)
#ifdef FIXED_POINT #ifdef FIXED_POINT
freq[i] = SHL32(freq[i], mdct_weight_shift); freq[i] = SHL32(freq[i], mdct_weight_shift);
#else #else