Skip to content

Commit

Permalink
wav64: fix opus looping bug for mono waveforms
Browse files Browse the repository at this point in the history
  • Loading branch information
rasky committed Oct 28, 2024
1 parent 40d2560 commit e36e91e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/audio/libopus_rsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,8 @@ void rsp_opus_deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int down
assertf(nn % 8 == 0, "nn:%d", nn);
int nnO = nn * C / downsample;

assert(PhysicalAddr(incur[0]) % 8 == 0);
if (C>1) assert(PhysicalAddr(incur[1]) % 8 == 0);
rsp_cmd_deemphasis(incur[0], (C>1 ? incur[1] : 0), pcmcur, mem, nn, downsample);

incur[0] += nn;
Expand Down
3 changes: 2 additions & 1 deletion src/audio/opus/celt_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1354,13 +1354,14 @@ int opus_custom_decoder_ctl(CELTDecoder * OPUS_RESTRICT st, int request, ...)

int st_size = opus_custom_decoder_get_size(st->mode, st->channels);
OPUS_CLEAR((char*)&st->DECODER_RESET_START,
(char*)&st->_decode_mem[0] - (char*)&st->DECODER_RESET_START);
(char*)&st->preemph_memD[0] - (char*)&st->DECODER_RESET_START);
OPUS_CLEAR((char*)lpc,
(char*)st + st_size - (char*)lpc);
#ifdef N64
data_cache_hit_writeback_invalidate(st->preemph_memD, sizeof(st->preemph_memD));
data_cache_hit_writeback_invalidate(st->_decode_mem, (DECODE_BUFFER_SIZE+st->overlap)*st->channels*sizeof(celt_sig));
rspq_highpri_begin();
rsp_opus_clear(st->preemph_memD, 2);
rsp_opus_clear(st->_decode_mem, (DECODE_BUFFER_SIZE+st->overlap)*st->channels);
rspq_highpri_end();
#else
Expand Down
9 changes: 6 additions & 3 deletions src/audio/rsp_opus_dsp.S
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ OPUS_deemphasis:
li t0, DMA_SIZE(4*2, 1)

li out_step, 2
li s4, %lo(DEEMPH_OUT) - 2*8
li dmem_out, %lo(DEEMPH_OUT) - 2*8

# Check if there is a second buffer
srl downsample_factor, a1, 24; vxor vmtx7, vmtx7
Expand All @@ -534,11 +534,14 @@ OPUS_deemphasis:

li out_step, 4
li dmem_out, %lo(DEEMPH_OUT) - 4*8
andi t0, rdram_out, 7

# Handle misalignment of RDRAM output buffer by shifting
# our DMEM buffer by the same amount.
1: andi t0, rdram_out, 7
addu dmem_out, t0

# Load coefficient matrix
1: li s0, %lo(KEMPHTABLE)
li s0, %lo(KEMPHTABLE)
lqv vmtx0.e0, 0x00,s0
lqv vmtx1.e1, 0x00,s0
lqv vmtx2.e2, 0x00,s0
Expand Down

0 comments on commit e36e91e

Please sign in to comment.