From 7be0ade7cef0fe9b4c5ce2a4dd6785a4a52c5b0d Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Thu, 27 Jan 2022 23:04:19 -0800 Subject: [PATCH] Ogg Vorbis and Opus: Fix 7.1ch file remapping File channel remapping was incorrectly only working for 1-7 channel files, not 8 channel files. Fixed that. PLEASE NOTE: This will be my last commit and build for over a week, I promised myself I would stop, and this is the last straw. These are the last two, I promise. No more bug fixes this week, until at least the 7th of February. Please, I'm begging you. Signed-off-by: Christopher Snowhill --- Plugins/Opus/Opus/OpusDecoder.m | 2 +- Plugins/Vorbis/VorbisDecoder.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Opus/Opus/OpusDecoder.m b/Plugins/Opus/Opus/OpusDecoder.m index 42ee99d3f..94cb769be 100644 --- a/Plugins/Opus/Opus/OpusDecoder.m +++ b/Plugins/Opus/Opus/OpusDecoder.m @@ -129,7 +129,7 @@ opus_int64 sourceTell(void *_stream) int toread = size - total; if (toread > 512) toread = 512; numread = op_read_float( opusRef, (channels < MAXCHANNELS) ? tempbuf : out, toread, NULL ); - if (numread > 0 && channels < MAXCHANNELS) { + if (numread > 0 && channels <= MAXCHANNELS) { for (int i = 0; i < numread; ++i) { for (int j = 0; j < channels; ++j) { out[i * channels + j] = tempbuf[i * channels + chmap[channels - 1][j]]; diff --git a/Plugins/Vorbis/VorbisDecoder.m b/Plugins/Vorbis/VorbisDecoder.m index 890795cbb..18ad28045 100644 --- a/Plugins/Vorbis/VorbisDecoder.m +++ b/Plugins/Vorbis/VorbisDecoder.m @@ -106,7 +106,7 @@ long sourceTell(void *datasource) float ** pcm; numread = (int)ov_read_float(&vorbisRef, &pcm, frames - total, ¤tSection); if (numread > 0) { - if (channels < MAXCHANNELS) { + if (channels <= MAXCHANNELS) { for (int i = 0; i < channels; i++) { for (int j = 0; j < numread; j++) { ((float *)buf)[(total + j) * channels + i] = pcm[chmap[channels-1][i]][j];