ref: 5b236756a3243b5ea71f8910bbb09f319c5e4e15
parent: b3c05b6be2a6579af55a625903e9e70687a4d77f
author: Gregory Maxwell <[email protected]>
date: Mon Feb 14 10:27:52 EST 2011
Correct a number of uninitialized value problems when end!=nbEBands. Now 8khz/20ms audio can be decoded at 48kHz and vice versa (with the PF turned off).
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -202,7 +202,7 @@
x++;
} while (++j<band_end);
}
- for (i=M*eBands[m->nbEBands];i<N;i++)
+ for (i=M*eBands[end];i<N;i++)
*f++ = 0;
} while (++c<C);
}
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -272,7 +272,7 @@
int badness1=0;
SAVE_STACK;
- intra = force_intra || (*delayedIntra && nbAvailableBytes > end*C);
+ intra = force_intra || (*delayedIntra && nbAvailableBytes > (end-start)*C);
if (/*shortBlocks || */intra_decision(eBands, oldEBands, start, effEnd, m->nbEBands, C))
*delayedIntra = 1;
else
@@ -295,7 +295,7 @@
ALLOC(oldEBands_intra, C*m->nbEBands, celt_word16);
ALLOC(error_intra, C*m->nbEBands, celt_word16);
- CELT_COPY(oldEBands_intra, oldEBands, C*end);
+ CELT_COPY(oldEBands_intra, oldEBands, C*m->nbEBands);
if (two_pass || intra)
{
@@ -335,12 +335,12 @@
/* Copy intra bits to bit-stream */
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);
+ CELT_COPY(oldEBands, oldEBands_intra, C*m->nbEBands);
+ CELT_COPY(error, error_intra, C*m->nbEBands);
}
} else {
- CELT_COPY(oldEBands, oldEBands_intra, C*end);
- CELT_COPY(error, error_intra, C*end);
+ CELT_COPY(oldEBands, oldEBands_intra, C*m->nbEBands);
+ CELT_COPY(error, error_intra, C*m->nbEBands);
}
RESTORE_STACK;
}