diff options
author | Chris Robinson <[email protected]> | 2018-01-09 23:55:59 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-01-09 23:55:59 -0800 |
commit | ef63ec3fe9364d2036878fa871f49ee60f84482b (patch) | |
tree | 5c818196e004bfc4278b5c6ddd4763b598456ac6 /Alc/converter.c | |
parent | de8c5b18248ee5d121cbd4b34b9af94f5e16df35 (diff) |
Use one macro to handle both resample padding sizes
Diffstat (limited to 'Alc/converter.c')
-rw-r--r-- | Alc/converter.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/Alc/converter.c b/Alc/converter.c index 56dbc79e..8cba04a1 100644 --- a/Alc/converter.c +++ b/Alc/converter.c @@ -205,8 +205,8 @@ ALsizei SampleConverterAvailableOut(SampleConverter *converter, ALsizei srcframe return 0; } - if(prepcount < MAX_POST_SAMPLES+MAX_PRE_SAMPLES && - MAX_POST_SAMPLES+MAX_PRE_SAMPLES-prepcount >= srcframes) + if(prepcount < MAX_RESAMPLE_PADDING*2 && + MAX_RESAMPLE_PADDING*2 - prepcount >= srcframes) { /* Not enough input samples to generate an output sample. */ return 0; @@ -214,7 +214,7 @@ ALsizei SampleConverterAvailableOut(SampleConverter *converter, ALsizei srcframe DataSize64 = prepcount; DataSize64 += srcframes; - DataSize64 -= MAX_POST_SAMPLES+MAX_PRE_SAMPLES; + DataSize64 -= MAX_RESAMPLE_PADDING*2; DataSize64 <<= FRACTIONBITS; DataSize64 -= DataPosFrac; @@ -256,10 +256,10 @@ ALsizei SampleConverterInput(SampleConverter *converter, const ALvoid **src, ALs converter->mSrcPrepCount = 0; continue; } - toread = mini(*srcframes, BUFFERSIZE-(MAX_POST_SAMPLES+MAX_PRE_SAMPLES)); + toread = mini(*srcframes, BUFFERSIZE - MAX_RESAMPLE_PADDING*2); - if(prepcount < MAX_POST_SAMPLES+MAX_PRE_SAMPLES && - MAX_POST_SAMPLES+MAX_PRE_SAMPLES-prepcount >= toread) + if(prepcount < MAX_RESAMPLE_PADDING*2 && + MAX_RESAMPLE_PADDING*2 - prepcount >= toread) { /* Not enough input samples to generate an output sample. Store * what we're given for later. @@ -277,7 +277,7 @@ ALsizei SampleConverterInput(SampleConverter *converter, const ALvoid **src, ALs DataSize64 = prepcount; DataSize64 += toread; - DataSize64 -= MAX_POST_SAMPLES+MAX_PRE_SAMPLES; + DataSize64 -= MAX_RESAMPLE_PADDING*2; DataSize64 <<= FRACTIONBITS; DataSize64 -= DataPosFrac; @@ -310,7 +310,7 @@ ALsizei SampleConverterInput(SampleConverter *converter, const ALvoid **src, ALs sizeof(converter->Chan[chan].mPrevSamples)); else { - size_t len = mini(MAX_PRE_SAMPLES+MAX_POST_SAMPLES, prepcount+toread-SrcDataEnd); + size_t len = mini(MAX_RESAMPLE_PADDING*2, prepcount+toread-SrcDataEnd); memcpy(converter->Chan[chan].mPrevSamples, &SrcData[SrcDataEnd], len*sizeof(ALfloat)); memset(converter->Chan[chan].mPrevSamples+len, 0, @@ -319,7 +319,7 @@ ALsizei SampleConverterInput(SampleConverter *converter, const ALvoid **src, ALs /* Now resample, and store the result in the output buffer. */ ResampledData = converter->mResample(&converter->mState, - SrcData+MAX_PRE_SAMPLES, DataPosFrac, increment, + SrcData+MAX_RESAMPLE_PADDING, DataPosFrac, increment, DstData, DstSize ); @@ -331,8 +331,8 @@ ALsizei SampleConverterInput(SampleConverter *converter, const ALvoid **src, ALs * fractional offset. */ DataPosFrac += increment*DstSize; - converter->mSrcPrepCount = mini(MAX_PRE_SAMPLES+MAX_POST_SAMPLES, - prepcount+toread-(DataPosFrac>>FRACTIONBITS)); + converter->mSrcPrepCount = mini(prepcount + toread - (DataPosFrac>>FRACTIONBITS), + MAX_RESAMPLE_PADDING*2); converter->mFracOffset = DataPosFrac & FRACTIONMASK; /* Update the src and dst pointers in case there's still more to do. */ |