diff --git a/src/audio/rsp_mixer.S b/src/audio/rsp_mixer.S index 6643c0557..8e8437ec4 100644 --- a/src/audio/rsp_mixer.S +++ b/src/audio/rsp_mixer.S @@ -1188,9 +1188,13 @@ Mix8Loop: .section .bssovl1 + # Codebook must be aligned to allow for xor trick + # to switch channels + .balign VADPCM_CODEBOOK_SIZE*16 +VADPCM_CODEBOOK: .space VADPCM_CODEBOOK_SIZE*16*2 + .align 4 VADPCM_STATE: .space 16*2 # state, left/right -VADPCM_CODEBOOK: .space VADPCM_CODEBOOK_SIZE*16*2 VADPCM_BUFFER: .space MAX_VADPCM_FRAMES*16*2 VADPCM_BUFFER_END: .space 8 # Extra 8 bytes for misalignment @@ -1267,9 +1271,11 @@ VADPCM_Decompress: ltv pred1a.e0, 0,s0 srl nframes, a1, 24 - addiu nframes, 1 + bgez a2, 1f + addiu nframes, 1 + sll nframes, 1 - # Calculate offset of input buffer inside the output buffer +1: # Calculate offset of input buffer inside the output buffer li dmem_output, %lo(VADPCM_BUFFER) and rdram_input, 0x00FFFFFF and a1, 0x00FFFFFF @@ -1383,6 +1389,7 @@ VADPCM_DecompressMono: sqv vstate1, 0x10,dmem_output srv vstate1, 0x20,dmem_output + addiu nframes, -1 addiu dmem_input, 9 bgez a2, VADPCM_Output addiu dmem_output, 32 @@ -1430,7 +1437,6 @@ VADPCM_InterleaveStereo: # Write output into RDRAM (async) VADPCM_Output: - addiu nframes, -1 bgtz nframes, VADPCM_DecompressLoop nop diff --git a/src/audio/wav64.c b/src/audio/wav64.c index da16a6d83..19017638b 100644 --- a/src/audio/wav64.c +++ b/src/audio/wav64.c @@ -214,7 +214,8 @@ static void waveform_vadpcm_read(void *ctx, samplebuffer_t *sbuf, int wpos, int bool highpri = false; while (wlen > 0) { // Calculate number of frames to decompress in this iteration - int nframes = MIN(wlen / 16, MAX_VADPCM_FRAMES); + int max_vadpcm_frames = (wav->wave.channels == 1) ? MAX_VADPCM_FRAMES : MAX_VADPCM_FRAMES / 2; + int nframes = MIN(wlen / 16, max_vadpcm_frames); // Acquire destination buffer from the sample buffer int16_t *dest = (int16_t*)samplebuffer_append(sbuf, nframes*16);