Loading services/audioflinger/Android.mk +24 −3 Original line number Diff line number Diff line Loading @@ -19,11 +19,9 @@ LOCAL_SRC_FILES:= \ AudioResampler.cpp.arm \ AudioPolicyService.cpp \ ServiceUtilities.cpp \ AudioResamplerCubic.cpp.arm \ AudioResamplerSinc.cpp.arm # uncomment to enable AudioResampler::MED_QUALITY # LOCAL_SRC_FILES += AudioResamplerCubic.cpp.arm LOCAL_SRC_FILES += StateQueue.cpp # uncomment for debugging timing problems related to StateQueue::push() Loading Loading @@ -80,4 +78,27 @@ LOCAL_CFLAGS += -UFAST_TRACKS_AT_NON_NATIVE_SAMPLE_RATE include $(BUILD_SHARED_LIBRARY) # # build audio resampler test tool # include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ test-resample.cpp \ AudioResampler.cpp.arm \ AudioResamplerCubic.cpp.arm \ AudioResamplerSinc.cpp.arm LOCAL_SHARED_LIBRARIES := \ libdl \ libcutils \ libutils LOCAL_MODULE:= test-resample LOCAL_MODULE_TAGS := optional include $(BUILD_EXECUTABLE) include $(call all-makefiles-under,$(LOCAL_PATH)) services/audioflinger/AudioResampler.cpp +0 −4 Original line number Diff line number Diff line Loading @@ -82,10 +82,8 @@ bool AudioResampler::qualityIsSupported(src_quality quality) switch (quality) { case DEFAULT_QUALITY: case LOW_QUALITY: #if 0 // these have not been qualified recently so are not supported unless explicitly requested case MED_QUALITY: case HIGH_QUALITY: #endif case VERY_HIGH_QUALITY: return true; default: Loading Loading @@ -190,12 +188,10 @@ AudioResampler* AudioResampler::create(int bitDepth, int inChannelCount, ALOGV("Create linear Resampler"); resampler = new AudioResamplerOrder1(bitDepth, inChannelCount, sampleRate); break; #if 0 // disabled because it has not been qualified recently, if requested will use default: case MED_QUALITY: ALOGV("Create cubic Resampler"); resampler = new AudioResamplerCubic(bitDepth, inChannelCount, sampleRate); break; #endif case HIGH_QUALITY: ALOGV("Create HIGH_QUALITY sinc Resampler"); resampler = new AudioResamplerSinc(bitDepth, inChannelCount, sampleRate); Loading services/audioflinger/AudioResamplerSinc.cpp +525 −134 File changed.Preview size limit exceeded, changes collapsed. Show changes services/audioflinger/AudioResamplerSinc.h +7 −6 Original line number Diff line number Diff line Loading @@ -44,18 +44,21 @@ public: private: void init(); virtual void setVolume(int16_t left, int16_t right); template<int CHANNELS> void resample(int32_t* out, size_t outFrameCount, AudioBufferProvider* provider); template<int CHANNELS> inline void filterCoefficient( int32_t& l, int32_t& r, uint32_t phase, const int16_t *samples); int32_t* out, uint32_t phase, const int16_t *samples, uint32_t vRL); template<int CHANNELS> inline void interpolate( int32_t& l, int32_t& r, const int32_t* coefs, int16_t lerp, const int16_t* samples); const int32_t* coefs, size_t offset, int32_t lerp, const int16_t* samples); template<int CHANNELS> inline void read(int16_t*& impulse, uint32_t& phaseFraction, Loading @@ -64,6 +67,7 @@ private: int16_t *mState; int16_t *mImpulse; int16_t *mRingFull; int32_t mVolumeSIMD[2]; const int32_t * mFirCoefs; static const int32_t mFirCoefsDown[]; Loading @@ -71,17 +75,14 @@ private: // ---------------------------------------------------------------------------- static const int32_t RESAMPLE_FIR_NUM_COEF = 8; static const int32_t RESAMPLE_FIR_LERP_INT_BITS = 4; static const int32_t RESAMPLE_FIR_LERP_INT_BITS = 7; struct Constants { // we have 16 coefs samples per zero-crossing int coefsBits; int cShift; uint32_t cMask; int pShift; uint32_t pMask; // number of zero-crossing on each side unsigned int halfNumCoefs; }; Loading services/audioflinger/audio-resampler/AudioResamplerCoefficients.cpp +14 −15 Original line number Diff line number Diff line Loading @@ -14,42 +14,41 @@ * limitations under the License. */ #include <dnsampler_filter_coefficients_x128_10112011.h> #include <resampler_filter_coefficients_10042011.h> #undef LOG_TAG #include <utils/Log.h> //#include "common_log.h" #define LOG_TAG "ResamplerCoefficients" #define LOG_NDEBUG 0 #include <utils/Log.h> #include "filter_coefficients.h" const int32_t RESAMPLE_FIR_NUM_COEF = 16; const int32_t RESAMPLE_FIR_LERP_INT_BITS = 7; using namespace android; #ifdef __cplusplus extern "C" { #endif const int32_t* readResamplerCoefficients(bool upSample) { ALOGV("readResamplerCoefficients"); if (upSample) { return resampler_filter_coefficients_10042011; } else { return dnsampler_filter_coefficients_x128_10112011; return up_sampler_filter_coefficients; } else { return dn_sampler_filter_coefficients; } } int32_t readResampleFirNumCoeff() { return RESAMPLE_FIR_NUM_COEF; } int32_t readResampleFirLerpIntBits() { return RESAMPLE_FIR_LERP_INT_BITS; } #ifdef __cplusplus } #endif Loading
services/audioflinger/Android.mk +24 −3 Original line number Diff line number Diff line Loading @@ -19,11 +19,9 @@ LOCAL_SRC_FILES:= \ AudioResampler.cpp.arm \ AudioPolicyService.cpp \ ServiceUtilities.cpp \ AudioResamplerCubic.cpp.arm \ AudioResamplerSinc.cpp.arm # uncomment to enable AudioResampler::MED_QUALITY # LOCAL_SRC_FILES += AudioResamplerCubic.cpp.arm LOCAL_SRC_FILES += StateQueue.cpp # uncomment for debugging timing problems related to StateQueue::push() Loading Loading @@ -80,4 +78,27 @@ LOCAL_CFLAGS += -UFAST_TRACKS_AT_NON_NATIVE_SAMPLE_RATE include $(BUILD_SHARED_LIBRARY) # # build audio resampler test tool # include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ test-resample.cpp \ AudioResampler.cpp.arm \ AudioResamplerCubic.cpp.arm \ AudioResamplerSinc.cpp.arm LOCAL_SHARED_LIBRARIES := \ libdl \ libcutils \ libutils LOCAL_MODULE:= test-resample LOCAL_MODULE_TAGS := optional include $(BUILD_EXECUTABLE) include $(call all-makefiles-under,$(LOCAL_PATH))
services/audioflinger/AudioResampler.cpp +0 −4 Original line number Diff line number Diff line Loading @@ -82,10 +82,8 @@ bool AudioResampler::qualityIsSupported(src_quality quality) switch (quality) { case DEFAULT_QUALITY: case LOW_QUALITY: #if 0 // these have not been qualified recently so are not supported unless explicitly requested case MED_QUALITY: case HIGH_QUALITY: #endif case VERY_HIGH_QUALITY: return true; default: Loading Loading @@ -190,12 +188,10 @@ AudioResampler* AudioResampler::create(int bitDepth, int inChannelCount, ALOGV("Create linear Resampler"); resampler = new AudioResamplerOrder1(bitDepth, inChannelCount, sampleRate); break; #if 0 // disabled because it has not been qualified recently, if requested will use default: case MED_QUALITY: ALOGV("Create cubic Resampler"); resampler = new AudioResamplerCubic(bitDepth, inChannelCount, sampleRate); break; #endif case HIGH_QUALITY: ALOGV("Create HIGH_QUALITY sinc Resampler"); resampler = new AudioResamplerSinc(bitDepth, inChannelCount, sampleRate); Loading
services/audioflinger/AudioResamplerSinc.cpp +525 −134 File changed.Preview size limit exceeded, changes collapsed. Show changes
services/audioflinger/AudioResamplerSinc.h +7 −6 Original line number Diff line number Diff line Loading @@ -44,18 +44,21 @@ public: private: void init(); virtual void setVolume(int16_t left, int16_t right); template<int CHANNELS> void resample(int32_t* out, size_t outFrameCount, AudioBufferProvider* provider); template<int CHANNELS> inline void filterCoefficient( int32_t& l, int32_t& r, uint32_t phase, const int16_t *samples); int32_t* out, uint32_t phase, const int16_t *samples, uint32_t vRL); template<int CHANNELS> inline void interpolate( int32_t& l, int32_t& r, const int32_t* coefs, int16_t lerp, const int16_t* samples); const int32_t* coefs, size_t offset, int32_t lerp, const int16_t* samples); template<int CHANNELS> inline void read(int16_t*& impulse, uint32_t& phaseFraction, Loading @@ -64,6 +67,7 @@ private: int16_t *mState; int16_t *mImpulse; int16_t *mRingFull; int32_t mVolumeSIMD[2]; const int32_t * mFirCoefs; static const int32_t mFirCoefsDown[]; Loading @@ -71,17 +75,14 @@ private: // ---------------------------------------------------------------------------- static const int32_t RESAMPLE_FIR_NUM_COEF = 8; static const int32_t RESAMPLE_FIR_LERP_INT_BITS = 4; static const int32_t RESAMPLE_FIR_LERP_INT_BITS = 7; struct Constants { // we have 16 coefs samples per zero-crossing int coefsBits; int cShift; uint32_t cMask; int pShift; uint32_t pMask; // number of zero-crossing on each side unsigned int halfNumCoefs; }; Loading
services/audioflinger/audio-resampler/AudioResamplerCoefficients.cpp +14 −15 Original line number Diff line number Diff line Loading @@ -14,42 +14,41 @@ * limitations under the License. */ #include <dnsampler_filter_coefficients_x128_10112011.h> #include <resampler_filter_coefficients_10042011.h> #undef LOG_TAG #include <utils/Log.h> //#include "common_log.h" #define LOG_TAG "ResamplerCoefficients" #define LOG_NDEBUG 0 #include <utils/Log.h> #include "filter_coefficients.h" const int32_t RESAMPLE_FIR_NUM_COEF = 16; const int32_t RESAMPLE_FIR_LERP_INT_BITS = 7; using namespace android; #ifdef __cplusplus extern "C" { #endif const int32_t* readResamplerCoefficients(bool upSample) { ALOGV("readResamplerCoefficients"); if (upSample) { return resampler_filter_coefficients_10042011; } else { return dnsampler_filter_coefficients_x128_10112011; return up_sampler_filter_coefficients; } else { return dn_sampler_filter_coefficients; } } int32_t readResampleFirNumCoeff() { return RESAMPLE_FIR_NUM_COEF; } int32_t readResampleFirLerpIntBits() { return RESAMPLE_FIR_LERP_INT_BITS; } #ifdef __cplusplus } #endif