summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlibvideoeditor/vss/common/inc/VideoEditorResampler.h45
-rwxr-xr-xlibvideoeditor/vss/common/inc/gLVAudioResampler.h119
-rwxr-xr-xlibvideoeditor/vss/mcs/src/M4MCS_API.c2
-rwxr-xr-xlibvideoeditor/vss/src/Android.mk9
-rwxr-xr-xlibvideoeditor/vss/src/M4VSS3GPP_AudioMixing.c2
-rwxr-xr-xlibvideoeditor/vss/src/VideoEditorResampler.cpp130
-rwxr-xr-xlibvideoeditor/vss/src/glvaudioresampler.c326
7 files changed, 183 insertions, 450 deletions
diff --git a/libvideoeditor/vss/common/inc/VideoEditorResampler.h b/libvideoeditor/vss/common/inc/VideoEditorResampler.h
new file mode 100755
index 0000000..2686212
--- /dev/null
+++ b/libvideoeditor/vss/common/inc/VideoEditorResampler.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2011 NXP Software
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef VIDEOEDITORRESAMPLER_H
+#define VIDEOEDITORRESAMPLER_H
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "M4OSA_Types.h"
+
+M4OSA_Int32 LVAudioResamplerCreate(M4OSA_Int32 bitDepth, M4OSA_Int32 inChannelCount,
+ M4OSA_Int32 sampleRate, M4OSA_Int32 quality);
+void LVAudiosetSampleRate(M4OSA_Int32 resamplerContext,M4OSA_Int32 inSampleRate);
+void LVAudiosetVolume(M4OSA_Int32 resamplerContext, M4OSA_Int16 left, M4OSA_Int16 right) ;
+void LVAudioresample_LowQuality(M4OSA_Int16* out, M4OSA_Int16* input,
+ M4OSA_Int32 outFrameCount, M4OSA_Int32 resamplerContext);
+
+void MonoTo2I_16( const M4OSA_Int16 *src,
+ M4OSA_Int16 *dst,
+ M4OSA_Int16 n);
+
+void From2iToMono_16( const M4OSA_Int16 *src,
+ M4OSA_Int16 *dst,
+ M4OSA_Int16 n);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* VIDEOEDITORRESAMPLER_H */
+
+
diff --git a/libvideoeditor/vss/common/inc/gLVAudioResampler.h b/libvideoeditor/vss/common/inc/gLVAudioResampler.h
deleted file mode 100755
index 9d3d63f..0000000
--- a/libvideoeditor/vss/common/inc/gLVAudioResampler.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-#ifndef GLVAUDIORESAMPLER_H
-#define GLVAUDIORESAMPLER_H
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#ifndef int8_t
-#define int8_t signed char
-#endif
-
-#ifndef int32_t
-#define int32_t long int
-#endif
-
-#ifndef uint32_t
-#define uint32_t unsigned long int
-#endif
-
-#ifndef int16_t
-#define int16_t signed short
-#endif
-
-#ifndef uint16_t
-#define uint16_t unsigned short
-#endif
-
-#ifndef status_t
-#define status_t long int
-#endif
-
- static const int kNumPhaseBits = 30;
- // phase mask for fraction
- static const uint32_t kPhaseMask = (1<<30)-1;
- // multiplier to calculate fixed point phase increment
- static const uint32_t kPhaseMultiplier = (1 << 30);
-
- static const int kNumInterpBits = 15;
-
- // bits to shift the phase fraction down to avoid overflow
- static const int kPreInterpShift = 15; //=kNumPhaseBits - kNumInterpBits;
-
-typedef struct Buffer {
- void* raw;
- short* i16;
- int8_t* i8;
- long frameCount;
- }Buffer;
-
-typedef enum src_quality {
- DEFAULT=0,
- LOW_QUALITY=1,
- MED_QUALITY=2,
- HIGH_QUALITY=3
- }src_quality;
-
-typedef struct LVAudioResampler
-{
-
- int32_t mBitDepth;
- int32_t mChannelCount;
- int32_t mSampleRate;
- int32_t mInSampleRate;
- Buffer mBuffer;
- int16_t mVolume[2];
- int16_t mTargetVolume[2];
- int mFormat;
- long mInputIndex;
- int32_t mPhaseIncrement;
- uint32_t mPhaseFraction;
- int mX0L;
- int mX0R;
- int32_t kPreInterpShift;
- int32_t kNumInterpBits;
- src_quality mQuality;
-}LVAudioResampler;
-
-
-int32_t LVAudioResamplerCreate(int bitDepth, int inChannelCount,
- int32_t sampleRate, int quality);
-void LVAudiosetSampleRate(int32_t context,int32_t inSampleRate);
-void LVAudiosetVolume(int32_t context, int16_t left, int16_t right) ;
-
-void LVAudioresample_LowQuality(int16_t* out, int16_t* input, long outFrameCount, int32_t context);
-void LVResampler_LowQualityInit(int bitDepth, int inChannelCount,
- int32_t sampleRate, int32_t context);
-
-
-void MonoTo2I_16( const short *src,
- short *dst,
- short n);
-
-void From2iToMono_16( const short *src,
- short *dst,
- short n);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* GLVAUDIORESAMPLER_H */
-
-
diff --git a/libvideoeditor/vss/mcs/src/M4MCS_API.c b/libvideoeditor/vss/mcs/src/M4MCS_API.c
index bc60688..b2b341e 100755
--- a/libvideoeditor/vss/mcs/src/M4MCS_API.c
+++ b/libvideoeditor/vss/mcs/src/M4MCS_API.c
@@ -34,7 +34,7 @@
#include "M4OSA_Debug.h" /**< OSAL debug management */
/* PCM samples */
-#include "gLVAudioResampler.h"
+#include "VideoEditorResampler.h"
/**
* Decoder interface */
#include "M4DECODER_Common.h"
diff --git a/libvideoeditor/vss/src/Android.mk b/libvideoeditor/vss/src/Android.mk
index f880eb4..57c970f 100755
--- a/libvideoeditor/vss/src/Android.mk
+++ b/libvideoeditor/vss/src/Android.mk
@@ -38,7 +38,6 @@ LOCAL_SRC_FILES:= \
M4VSS3GPP_EditAudio.c \
M4VSS3GPP_EditVideo.c \
M4VSS3GPP_MediaAndCodecSubscription.c \
- glvaudioresampler.c \
M4ChannelCoverter.c \
M4VD_EXTERNAL_BitstreamParser.c \
M4VD_EXTERNAL_Interface.c \
@@ -48,7 +47,8 @@ LOCAL_SRC_FILES:= \
M4AD_Null.c \
M4AMRR_CoreReader.c \
M4READER_Amr.c \
- M4VD_Tools.c
+ M4VD_Tools.c \
+ VideoEditorResampler.cpp
LOCAL_MODULE_TAGS := optional
@@ -63,11 +63,14 @@ LOCAL_STATIC_LIBRARIES := \
libvideoeditor_stagefrightshells
LOCAL_C_INCLUDES += \
+ $(TOP)/frameworks/base/include \
$(TOP)/frameworks/media/libvideoeditor/osal/inc \
$(TOP)/frameworks/media/libvideoeditor/vss/inc \
$(TOP)/frameworks/media/libvideoeditor/vss/mcs/inc \
$(TOP)/frameworks/media/libvideoeditor/vss/common/inc \
- $(TOP)/frameworks/media/libvideoeditor/vss/stagefrightshells/inc
+ $(TOP)/frameworks/media/libvideoeditor/vss/stagefrightshells/inc \
+ $(TOP)/frameworks/base/services/audioflinger \
+
ifeq ($(TARGET_SIMULATOR),true)
else
diff --git a/libvideoeditor/vss/src/M4VSS3GPP_AudioMixing.c b/libvideoeditor/vss/src/M4VSS3GPP_AudioMixing.c
index 6f6ba3c..157f200 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_AudioMixing.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_AudioMixing.c
@@ -44,7 +44,7 @@
#include "M4OSA_Debug.h" /**< OSAL debug management */
-#include "gLVAudioResampler.h"
+#include "VideoEditorResampler.h"
/**
******************************************************************************
* @brief Static functions
diff --git a/libvideoeditor/vss/src/VideoEditorResampler.cpp b/libvideoeditor/vss/src/VideoEditorResampler.cpp
new file mode 100755
index 0000000..82a2423
--- /dev/null
+++ b/libvideoeditor/vss/src/VideoEditorResampler.cpp
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2011 NXP Software
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_NDEBUG 1
+#include <utils/Log.h>
+#include "AudioMixer.h"
+#include "VideoEditorResampler.h"
+
+namespace android {
+
+struct VideoEditorResampler : public AudioBufferProvider {
+
+ public:
+
+ virtual status_t getNextBuffer(Buffer* buffer);
+ virtual void releaseBuffer(Buffer* buffer);
+
+ enum { //Sampling freq
+ kFreq8000Hz = 8000,
+ kFreq11025Hz = 11025,
+ kFreq12000Hz = 12000,
+ kFreq16000Hz = 16000,
+ kFreq22050Hz = 22050,
+ kFreq240000Hz = 24000,
+ kFreq32000Hz = 32000,
+ kFreq44100 = 44100,
+ kFreq48000 = 48000,
+ };
+
+ AudioResampler *mResampler;
+ int16_t* mInput;
+ int nbChannels;
+ int nbSamples;
+
+};
+
+
+status_t VideoEditorResampler::getNextBuffer(AudioBufferProvider::Buffer *pBuffer) {
+
+ pBuffer->raw = (void*)(this->mInput);
+ return OK;
+}
+
+void VideoEditorResampler::releaseBuffer(AudioBufferProvider::Buffer *pBuffer) {
+
+ if(pBuffer->raw != NULL) {
+ pBuffer->raw = NULL;
+ }
+ pBuffer->frameCount = 0;
+}
+
+extern "C" {
+
+M4OSA_Int32 LVAudioResamplerCreate(M4OSA_Int32 bitDepth, M4OSA_Int32 inChannelCount,
+ M4OSA_Int32 sampleRate, M4OSA_Int32 quality) {
+
+ VideoEditorResampler *context = new VideoEditorResampler();
+ context->mResampler = AudioResampler::create(
+ bitDepth, inChannelCount, sampleRate, AudioResampler::DEFAULT);
+ if (context->mResampler == NULL) {
+ return NO_MEMORY;
+ }
+ context->mResampler->setSampleRate(32000);
+ context->mResampler->setVolume(0x1000, 0x1000);
+ context->nbChannels = inChannelCount;
+
+ return ((M4OSA_Int32)context);
+}
+
+
+void LVAudiosetSampleRate(M4OSA_Int32 resamplerContext, M4OSA_Int32 inSampleRate) {
+
+ VideoEditorResampler *context =
+ (VideoEditorResampler *)resamplerContext;
+ context->mResampler->setSampleRate(inSampleRate);
+ /*
+ * nbSamples is calculated for 40ms worth of data;hence sample rate
+ * is used to calculate the nbSamples
+ */
+ context->nbSamples = inSampleRate / 25;
+ context->mInput = (int16_t*)malloc(context->nbSamples *
+ context->nbChannels * sizeof(int16_t));
+}
+
+void LVAudiosetVolume(M4OSA_Int32 resamplerContext, M4OSA_Int16 left, M4OSA_Int16 right) {
+
+ VideoEditorResampler *context =
+ (VideoEditorResampler *)resamplerContext;
+ context->mResampler->setVolume(left,right);
+}
+
+
+void LVAudioresample_LowQuality(M4OSA_Int16* out, M4OSA_Int16* input,
+ M4OSA_Int32 outFrameCount, M4OSA_Int32 resamplerContext) {
+
+ VideoEditorResampler *context =
+ (VideoEditorResampler *)resamplerContext;
+ int32_t *pTmpBuffer = NULL;
+ memcpy(context->mInput,input,(context->nbSamples * context->nbChannels * sizeof(int16_t)));
+ /*
+ SRC module always gives stereo output, hence 2 for stereo audio
+ */
+ pTmpBuffer = (int32_t*)malloc(outFrameCount * 2 * sizeof(int32_t));
+ memset(pTmpBuffer, 0x00, outFrameCount * 2 * sizeof(int32_t));
+
+ context->mResampler->resample((int32_t *)pTmpBuffer,
+ (size_t)outFrameCount, (VideoEditorResampler *)resamplerContext);
+ // Convert back to 16 bits
+ AudioMixer::ditherAndClamp((int32_t*)out, pTmpBuffer, outFrameCount);
+ free(pTmpBuffer);
+ pTmpBuffer = NULL;
+}
+
+}
+
+} //namespace android
diff --git a/libvideoeditor/vss/src/glvaudioresampler.c b/libvideoeditor/vss/src/glvaudioresampler.c
deleted file mode 100755
index 852329e..0000000
--- a/libvideoeditor/vss/src/glvaudioresampler.c
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- ******************************************************************************
- * @file glvaudioresampler.c
- * @brief
- * @note
- ******************************************************************************
- */
-/**
- * OSAL headers */
-#include "M4OSA_Memory.h" /**< OSAL memory management */
-#include "M4OSA_Debug.h" /**< OSAL debug management */
-#include "M4OSA_CoreID.h"
-#include "gLVAudioResampler.h"
-
-
-static void resampleStereo16(int32_t* out, int16_t* input, long outFrameCount,
- LVAudioResampler *resampler) ;
-static void resampleMono16(int32_t* out, int16_t* input, long outFrameCount,
- LVAudioResampler *resampler) ;
-
-int32_t LVAudioResamplerCreate(int bitDepth, int inChannelCount,
- int32_t sampleRate, int quality)
-{
- int32_t context;
- LVAudioResampler *resampler;
-
- resampler = (LVAudioResampler *)M4OSA_malloc(sizeof(LVAudioResampler), M4VSS3GPP,
- (M4OSA_Char *)"LVAudioResampler");
- context = (int32_t)resampler;
-
- if (quality == DEFAULT)
- quality = LOW_QUALITY;
-
-
- switch (quality) {
- default:
- case LOW_QUALITY:
- resampler->mQuality = LOW_QUALITY;
- LVResampler_LowQualityInit(bitDepth, inChannelCount, sampleRate, context);
- break;
- case MED_QUALITY:
- resampler->mQuality = MED_QUALITY;
- break;
- case HIGH_QUALITY:
- resampler->mQuality = HIGH_QUALITY;
- break;
- }
-
- return (context);
-}
-
-static int32_t Interp(int32_t x0, int32_t x1, uint32_t f) {
- int32_t t_datta;
- t_datta = x0 + (((x1 - x0) * (int32_t)(f >> kPreInterpShift)) >> kNumInterpBits);
- return t_datta;
-}
-static void Advance(long* index, uint32_t* frac, uint32_t inc) {
- *frac += inc;
- *index += (long)(*frac >> kNumPhaseBits);
- *frac &= kPhaseMask;
-}
-
-void LVResampler_LowQualityInit(int bitDepth, int inChannelCount,
- int32_t sampleRate, int32_t context )
-{
- LVAudioResampler *resampler = (LVAudioResampler *) context;
- resampler->mBitDepth = bitDepth;
- resampler->mChannelCount = inChannelCount;
- resampler->mSampleRate = sampleRate;
- resampler->mInSampleRate = sampleRate;
- resampler->mInputIndex = 0;
- resampler->mPhaseFraction = 0;
- // sanity check on format
- if ((bitDepth != 16) ||(inChannelCount < 1) || (inChannelCount > 2))
- {
- //LOGE("Unsupported sample format, %d bits, %d channels", bitDepth,
- // inChannelCount);
- // LOG_ASSERT(0);
- }
- // initialize common members
- resampler->mVolume[0] =
- resampler->mVolume[1] = 0;
- resampler->mBuffer.frameCount = 0;
- // save format for quick lookup
- if (inChannelCount == 1)
- {
- resampler->mFormat = 1;//MONO_16_BIT;
- }
- else
- {
- resampler->mFormat = 2;//STEREO_16_BIT;
- }
-}
-
-void LVAudiosetSampleRate(int32_t context,int32_t inSampleRate)
-{
- LVAudioResampler *resampler = (LVAudioResampler *)context;
- long temp;
- temp = kPhaseMultiplier;
-
- resampler->mInSampleRate = inSampleRate;
- resampler->mPhaseIncrement = (uint32_t)((temp / resampler->mSampleRate)* inSampleRate );
-}
-void LVAudiosetVolume(int32_t context, int16_t left, int16_t right)
-{
- LVAudioResampler *resampler = (LVAudioResampler *)context;
- // TODO: Implement anti-zipper filter
- resampler->mVolume[0] = left;
- resampler->mVolume[1] = right;
-}
-
-
-
-static int16_t clamp16(int32_t sample)
-{
- if ((sample>>15) ^ (sample>>31))
- sample = 0x7FFF ^ (sample>>31);
- return sample;
-}
-
-
-static void DitherAndClamp(int32_t* out, int32_t const *sums, long c)
-{
- long i;
- //ditherAndClamp((int32_t*)reSampledBuffer, pTmpBuffer, outBufferSize/2);
- for ( i=0 ; i<c ; i++)
- {
- int32_t l = *sums++;
- int32_t r = *sums++;
- int32_t nl = l >> 12;
- int32_t nr = r >> 12;
- l = clamp16(nl);
- r = clamp16(nr);
- *out++ = (r<<16) | (l & 0xFFFF);
- }
-
-}
-
-void LVAudioresample_LowQuality(int16_t* out,
- int16_t* input,
- long outFrameCount,
- int32_t context)
-{
- LVAudioResampler *resampler = (LVAudioResampler *)context;
-
- int32_t *tempBuff = (int32_t *)M4OSA_malloc(
- (outFrameCount * sizeof(int32_t) * 2),
- M4VSS3GPP, (M4OSA_Char *)"tempBuff");
-
- M4OSA_memset((M4OSA_MemAddr8)tempBuff,
- (outFrameCount * sizeof(int32_t) * 2), 0);
-
- switch (resampler->mChannelCount)
- {
- case 1:
- resampleMono16(tempBuff, input, outFrameCount, resampler);
- break;
- case 2:
- resampleStereo16(tempBuff, input, outFrameCount, resampler);
- break;
- }
-
- // Dither and Clamp
- DitherAndClamp((int32_t*)out, tempBuff, outFrameCount);
-
- M4OSA_free((M4OSA_MemAddr32)tempBuff);
-}
-
-void resampleStereo16(int32_t* out, int16_t* input,long outFrameCount,
- LVAudioResampler *resampler)
-{
-
- int32_t vl = resampler->mVolume[0];
- int32_t vr = resampler->mVolume[1];
-
- long inputIndex = resampler->mInputIndex;
- uint32_t phaseFraction = resampler->mPhaseFraction;
- uint32_t phaseIncrement = resampler->mPhaseIncrement;
- long outputIndex = 0;
-
-
- long outputSampleCount = outFrameCount * 2;
- long inFrameCount = (outFrameCount* resampler->mInSampleRate)/resampler->mSampleRate;
- int16_t *in;
-
- resampler->mBuffer.i16 = input;
-
- // LOGE("starting resample %d frames, inputIndex=%d, phaseFraction=%d, phaseIncrement=%d\n",
- // outFrameCount, inputIndex, phaseFraction, phaseIncrement);
-
- while (outputIndex < outputSampleCount)
- {
- resampler->mBuffer.frameCount = inFrameCount;
- resampler->mX0L = 0;
- resampler->mX0R = 0;
- inputIndex = 0;
-
- in = resampler->mBuffer.i16;
-
- // handle boundary case
- while (inputIndex == 0) {
- // LOGE("boundary case\n");
- out[outputIndex++] += vl * Interp(resampler->mX0L, in[0], phaseFraction);
- out[outputIndex++] += vr * Interp(resampler->mX0R, in[1], phaseFraction);
- Advance(&inputIndex, &phaseFraction, phaseIncrement);
- if (outputIndex == outputSampleCount)
- break;
- }
-
- // process input samples
- while (outputIndex < outputSampleCount && inputIndex < resampler->mBuffer.frameCount) {
- out[outputIndex++] += vl * Interp(in[inputIndex*2-2],
- in[inputIndex*2], phaseFraction);
- out[outputIndex++] += vr * Interp(in[inputIndex*2-1],
- in[inputIndex*2+1], phaseFraction);
- Advance(&inputIndex, &phaseFraction, phaseIncrement);
- }
-
- resampler->mX0L = resampler->mBuffer.i16[resampler->mBuffer.frameCount*2-2];
- resampler->mX0R = resampler->mBuffer.i16[resampler->mBuffer.frameCount*2-1];
- }
-
-resampleStereo16_exit:
- // save state
- resampler->mInputIndex = inputIndex;
- resampler->mPhaseFraction = phaseFraction;
-}
-
-
-void resampleMono16(int32_t* out, int16_t* input,long outFrameCount, LVAudioResampler *resampler/*,
- AudioBufferProvider* provider*/)
-{
-
- int32_t vl = resampler->mVolume[0];
- int32_t vr = resampler->mVolume[1];
- int16_t *in;
-
- long inputIndex = resampler->mInputIndex;
- uint32_t phaseFraction = resampler->mPhaseFraction;
- uint32_t phaseIncrement = resampler->mPhaseIncrement;
- long outputIndex = 0;
- long outputSampleCount = outFrameCount * 2;
- long inFrameCount = (outFrameCount*resampler->mInSampleRate)/resampler->mSampleRate;
-
- resampler->mBuffer.i16 = input;
- resampler->mBuffer.i8 = (int8_t *)input;
- resampler->mBuffer.raw = (void *)input;
-
- // LOGE("starting resample %d frames, inputIndex=%d, phaseFraction=%d, phaseIncrement=%d\n",
- // outFrameCount, inputIndex, phaseFraction, phaseIncrement);
- while (outputIndex < outputSampleCount) {
- // buffer is empty, fetch a new one
- while (resampler->mBuffer.frameCount == 0) {
- resampler->mBuffer.frameCount = inFrameCount;
- //provider->getNextBuffer(&mBuffer);
-
- if (resampler->mBuffer.raw == M4OSA_NULL) {
- resampler->mInputIndex = inputIndex;
- resampler->mPhaseFraction = phaseFraction;
- goto resampleMono16_exit;
- }
- resampler->mX0L = 0;
- // LOGE("New buffer fetched: %d frames\n", mBuffer.frameCount);
- if (resampler->mBuffer.frameCount > inputIndex)
- break;
-
- inputIndex -= resampler->mBuffer.frameCount;
- resampler->mX0L = resampler->mBuffer.i16[resampler->mBuffer.frameCount-1];
- //provider->releaseBuffer(&resampler->mBuffer);
- // mBuffer.frameCount == 0 now so we reload a new buffer
- }
-
- in = resampler->mBuffer.i16;
-
- // handle boundary case
- while (inputIndex == 0) {
- // LOGE("boundary case\n");
- int32_t sample = Interp(resampler->mX0L, in[0], phaseFraction);
- out[outputIndex++] += vl * sample;
- out[outputIndex++] += vr * sample;
- Advance(&inputIndex, &phaseFraction, phaseIncrement);
- if (outputIndex == outputSampleCount)
- break;
- }
-
- // process input samples
- while (outputIndex < outputSampleCount && inputIndex < resampler->mBuffer.frameCount) {
- int32_t sample = Interp(in[inputIndex-1], in[inputIndex],
- phaseFraction);
- out[outputIndex++] += vl * sample;
- out[outputIndex++] += vr * sample;
- Advance(&inputIndex, &phaseFraction, phaseIncrement);
- }
-
- // LOGE("loop done - outputIndex=%d, inputIndex=%d\n", outputIndex, inputIndex);
- // if done with buffer, save samples
- if (inputIndex >= resampler->mBuffer.frameCount) {
- inputIndex -= resampler->mBuffer.frameCount;
-
- // LOGE("buffer done, new input index %d", inputIndex);
- resampler->mX0L = resampler->mBuffer.i16[resampler->mBuffer.frameCount-1];
- }
- }
-
-resampleMono16_exit:
- // save state
- resampler->mInputIndex = inputIndex;
- resampler->mPhaseFraction = phaseFraction;
-}
-