summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-11-15 15:30:37 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-11-15 15:30:37 +0000
commit140c16a214d8347002d3e1211e7afb407d997434 (patch)
tree428cf3250154e754aba76813cdc10dc7e6e10ab5
parent136fdb6591f02d29968c8e686b46a6bdf8c63577 (diff)
parent0d9f4e132732a45318e2a507c359aeef196f6635 (diff)
downloadsonivox-android12-mainline-sdkext-release.tar.gz
Snap for 7915578 from 0d9f4e132732a45318e2a507c359aeef196f6635 to mainline-sdkext-releaseandroid-mainline-12.0.0_r81android-mainline-12.0.0_r109aml_sdk_311710000android12-mainline-sdkext-release
Change-Id: I028b1516933bd90875eadf0da057dd1983f7499c
-rw-r--r--arm-wt-22k/lib_src/eas_wtengine.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/arm-wt-22k/lib_src/eas_wtengine.c b/arm-wt-22k/lib_src/eas_wtengine.c
index c3012e5..b1ee749 100644
--- a/arm-wt-22k/lib_src/eas_wtengine.c
+++ b/arm-wt-22k/lib_src/eas_wtengine.c
@@ -202,7 +202,7 @@ void WT_Interpolate (S_WT_VOICE *pWTVoice, S_WT_INT_FRAME *pWTIntFrame)
loopEnd = (const EAS_SAMPLE*) pWTVoice->loopEnd + 1;
pSamples = (const EAS_SAMPLE*) pWTVoice->phaseAccum;
/*lint -e{713} truncation is OK */
- phaseFrac = pWTVoice->phaseFrac;
+ phaseFrac = pWTVoice->phaseFrac & PHASE_FRAC_MASK;
phaseInc = pWTIntFrame->frame.phaseIncrement;
/* fetch adjacent samples */
@@ -218,6 +218,8 @@ void WT_Interpolate (S_WT_VOICE *pWTVoice, S_WT_INT_FRAME *pWTIntFrame)
while (numSamples--) {
+ EAS_I32 nextSamplePhaseInc;
+
/* linear interpolation */
acc0 = samp2 - samp1;
acc0 = acc0 * phaseFrac;
@@ -231,19 +233,19 @@ void WT_Interpolate (S_WT_VOICE *pWTVoice, S_WT_INT_FRAME *pWTIntFrame)
/* increment phase */
phaseFrac += phaseInc;
/*lint -e{704} <avoid divide>*/
- acc0 = phaseFrac >> NUM_PHASE_FRAC_BITS;
+ nextSamplePhaseInc = phaseFrac >> NUM_PHASE_FRAC_BITS;
/* next sample */
- if (acc0 > 0) {
-
+ if (nextSamplePhaseInc > 0) {
/* advance sample pointer */
- pSamples += acc0;
- phaseFrac = (EAS_I32)((EAS_U32)phaseFrac & PHASE_FRAC_MASK);
+ pSamples += nextSamplePhaseInc;
+ phaseFrac = phaseFrac & PHASE_FRAC_MASK;
- /* check for loop end */
- acc0 = (EAS_I32) (pSamples - loopEnd);
- if (acc0 >= 0)
- pSamples = (const EAS_SAMPLE*) pWTVoice->loopStart + acc0;
+ /* decrementing pSamples by entire buffer length until second pSample is within */
+ /* loopEnd */
+ while (&pSamples[1] >= loopEnd) {
+ pSamples -= (loopEnd - (const EAS_SAMPLE*)pWTVoice->loopStart);
+ }
/* fetch new samples */
#if defined(_8_BIT_SAMPLES)
@@ -284,6 +286,7 @@ void WT_InterpolateNoLoop (S_WT_VOICE *pWTVoice, S_WT_INT_FRAME *pWTIntFrame)
EAS_I32 phaseFrac;
EAS_I32 acc0;
const EAS_SAMPLE *pSamples;
+ const EAS_SAMPLE *bufferEndP1;
EAS_I32 samp1;
EAS_I32 samp2;
EAS_I32 numSamples;
@@ -298,8 +301,9 @@ void WT_InterpolateNoLoop (S_WT_VOICE *pWTVoice, S_WT_INT_FRAME *pWTIntFrame)
pOutputBuffer = pWTIntFrame->pAudioBuffer;
phaseInc = pWTIntFrame->frame.phaseIncrement;
+ bufferEndP1 = (const EAS_SAMPLE*) pWTVoice->loopEnd + 1;
pSamples = (const EAS_SAMPLE*) pWTVoice->phaseAccum;
- phaseFrac = (EAS_I32)pWTVoice->phaseFrac;
+ phaseFrac = (EAS_I32)(pWTVoice->phaseFrac & PHASE_FRAC_MASK);
/* fetch adjacent samples */
#if defined(_8_BIT_SAMPLES)
@@ -314,6 +318,7 @@ void WT_InterpolateNoLoop (S_WT_VOICE *pWTVoice, S_WT_INT_FRAME *pWTIntFrame)
while (numSamples--) {
+ EAS_I32 nextSamplePhaseInc;
/* linear interpolation */
acc0 = samp2 - samp1;
@@ -328,13 +333,18 @@ void WT_InterpolateNoLoop (S_WT_VOICE *pWTVoice, S_WT_INT_FRAME *pWTIntFrame)
/* increment phase */
phaseFrac += phaseInc;
/*lint -e{704} <avoid divide>*/
- acc0 = phaseFrac >> NUM_PHASE_FRAC_BITS;
+ nextSamplePhaseInc = phaseFrac >> NUM_PHASE_FRAC_BITS;
/* next sample */
- if (acc0 > 0) {
+ if (nextSamplePhaseInc > 0) {
+
+ /* check for loop end */
+ if ( &pSamples[nextSamplePhaseInc+1] >= bufferEndP1) {
+ break;
+ }
/* advance sample pointer */
- pSamples += acc0;
+ pSamples += nextSamplePhaseInc;
phaseFrac = (EAS_I32)((EAS_U32)phaseFrac & PHASE_FRAC_MASK);
/* fetch new samples */