Decode VAG samples in one shot, not two.

This commit is contained in:
Unknown W. Brackets 2013-05-27 17:37:41 -07:00
parent 40877cf813
commit e8be3d8da2
2 changed files with 9 additions and 7 deletions

View File

@ -66,14 +66,9 @@ void VagDecoder::DecodeBlock(u8 *&readp) {
for (int i = 0; i < 28; i += 2) {
int d = *readp++;
int s = (short)((d & 0xf) << 12);
samples[i] = s >> shift_factor;
DecodeSample(i, s >> shift_factor, predict_nr);
s = (short)((d & 0xf0) << 8);
samples[i + 1] = s >> shift_factor;
}
for (int i = 0; i < 28; i++) {
samples[i] = (int) (samples[i] + ((s_1 * f[predict_nr][0] + s_2 * f[predict_nr][1]) >> 6));
s_2 = s_1;
s_1 = samples[i];
DecodeSample(i + 1, s >> shift_factor, predict_nr);
}
curSample = 0;
curBlock_++;
@ -82,6 +77,12 @@ void VagDecoder::DecodeBlock(u8 *&readp) {
}
}
inline void VagDecoder::DecodeSample(int i, int sample, int predict_nr) {
samples[i] = (int) (sample + ((s_1 * f[predict_nr][0] + s_2 * f[predict_nr][1]) >> 6));
s_2 = s_1;
s_1 = samples[i];
}
void VagDecoder::GetSamples(s16 *outSamples, int numSamples) {
if (end_) {
memset(outSamples, 0, numSamples * sizeof(s16));

View File

@ -86,6 +86,7 @@ public:
void DoState(PointerWrap &p);
private:
void DecodeSample(int i, int sample, int predict_nr);
int samples[28];
int curSample;