summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/AudioResamplerSinc.h
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-10-01 14:04:31 -0700
committerGlenn Kasten <gkasten@google.com>2012-10-04 09:44:04 -0700
commitac6020508acedd316391dee42329040bf45f8d90 (patch)
tree034a8ac9c453dfce993c8d2568121a9b6d042bd0 /services/audioflinger/AudioResamplerSinc.h
parentd69fd4d2567f9fce02252ce10d7ae3a28fc79e04 (diff)
downloadframeworks_av-ac6020508acedd316391dee42329040bf45f8d90.zip
frameworks_av-ac6020508acedd316391dee42329040bf45f8d90.tar.gz
frameworks_av-ac6020508acedd316391dee42329040bf45f8d90.tar.bz2
Integrate improved coefficient sinc resampler: VHQ
Summary: Very high quality is enabled only for 44.1 -> 48 or 48 -> 44.1, and uses low quality for all other use cases. Track estimated CPU load and throttles the quality based on load; as currently configured it should allow up to 2 instances of very high quality. Medium quality and high quality are currently disabled unless explicitly requested. Details: Only load .so the first time it is needed. Cleanup code style: formatting, indentation, whitespace. Restore medium quality resampler, but it is not used (see next line). Fix memory leak for sinc resampler. Check sample rate in resampler constructor. Add logs for debugging. Rename DEFAULT to DEFAULT_QUALITY for consistency with other quality levels. Renumber VERY_HIGH_QUALITY from 255 to 4. Use enum src_quality consistently. Improve parsing of property af.resampler.quality. Fix reentrancy bug - allow an instance of high quality and an instance of very high quality to both be active concurrently. Bug: 7229644 Change-Id: I0ce6b913b05038889f50462a38830b61a602a9f7
Diffstat (limited to 'services/audioflinger/AudioResamplerSinc.h')
-rw-r--r--services/audioflinger/AudioResamplerSinc.h39
1 files changed, 20 insertions, 19 deletions
diff --git a/services/audioflinger/AudioResamplerSinc.h b/services/audioflinger/AudioResamplerSinc.h
index c53c66d..25fc025 100644
--- a/services/audioflinger/AudioResamplerSinc.h
+++ b/services/audioflinger/AudioResamplerSinc.h
@@ -27,14 +27,15 @@ namespace android {
typedef const int32_t * (*readCoefficientsFn)(bool upDownSample);
-typedef int32_t (*readResampleFirNumCoeffFn)();
-typedef int32_t (*readResampleFirLerpIntBitsFn)();
+typedef int32_t (*readResampleFirNumCoeffFn)();
+typedef int32_t (*readResampleFirLerpIntBitsFn)();
// ----------------------------------------------------------------------------
class AudioResamplerSinc : public AudioResampler {
public:
- AudioResamplerSinc(int bitDepth, int inChannelCount, int32_t sampleRate, int32_t quality = HIGH_QUALITY);
+ AudioResamplerSinc(int bitDepth, int inChannelCount, int32_t sampleRate,
+ src_quality quality = HIGH_QUALITY);
virtual ~AudioResamplerSinc();
@@ -60,10 +61,6 @@ private:
inline void read(int16_t*& impulse, uint32_t& phaseFraction,
const int16_t* in, size_t inputIndex);
- readCoefficientsFn mReadResampleCoefficients ;
- readResampleFirNumCoeffFn mReadResampleFirNumCoeff;
- readResampleFirLerpIntBitsFn mReadResampleFirLerpIntBits;
-
int16_t *mState;
int16_t *mImpulse;
int16_t *mRingFull;
@@ -72,24 +69,28 @@ private:
static const int32_t mFirCoefsDown[];
static const int32_t mFirCoefsUp[];
- void * mResampleCoeffLib;
// ----------------------------------------------------------------------------
static const int32_t RESAMPLE_FIR_NUM_COEF = 8;
static const int32_t RESAMPLE_FIR_LERP_INT_BITS = 4;
- // we have 16 coefs samples per zero-crossing
- static int coefsBits;
- static int cShift;
- static uint32_t cMask;
+ 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;
+ };
- // and we use 15 bits to interpolate between these samples
- // this cannot change because the mul below rely on it.
- static const int pLerpBits = 15;
- static int pShift;
- static uint32_t pMask;
+ static Constants highQualityConstants;
+ static Constants veryHighQualityConstants;
+ const Constants *mConstants; // points to appropriate set of coefficient parameters
- // number of zero-crossing on each side
- static unsigned int halfNumCoefs;
+ static void init_routine();
};
// ----------------------------------------------------------------------------