From 5ab70ff91fd1917543b09c8565de8a951de0a39c Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 26 Nov 2023 18:50:22 -0500 Subject: [PATCH] PCM DAC: fix possible overflow in linear interpola --- src/engine/platform/pcmdac.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/platform/pcmdac.cpp b/src/engine/platform/pcmdac.cpp index 1ddd22dae..adc8770ee 100644 --- a/src/engine/platform/pcmdac.cpp +++ b/src/engine/platform/pcmdac.cpp @@ -67,7 +67,7 @@ void DivPlatformPCMDAC::acquire(short** buf, size_t len) { switch (interp) { case 1: // linear - output=s6+((s7-s6)*(chan[0].audSub&0xffff)>>16); + output=s6+(((int)((int)s7-(int)s6)*((chan[0].audSub>>1)&0x7fff))>>15); break; case 2: { // cubic float* cubicTable=DivFilterTables::getCubicTable(); @@ -188,7 +188,7 @@ void DivPlatformPCMDAC::acquire(short** buf, size_t len) { switch (interp) { case 1: // linear - output=s6+((s7-s6)*(chan[0].audSub&0xffff)>>16); + output=s6+(((int)((int)s7-(int)s6)*((chan[0].audSub>>1)&0x7fff))>>15); break; case 2: { // cubic float* cubicTable=DivFilterTables::getCubicTable();