From 84a0c6e87c48f58a0d3be71961432c086a4d24cc Mon Sep 17 00:00:00 2001 From: Andy Hung Date: Wed, 2 Apr 2014 11:24:53 -0700 Subject: Change references of Q19.12 to Q4.27 for clarity Change-Id: I5beb7daf6ff9bc123ff3582f7c294edcaf8652f6 Signed-off-by: Andy Hung --- services/audioflinger/AudioMixer.cpp | 8 ++++---- services/audioflinger/AudioResampler.h | 2 +- services/audioflinger/RecordTracks.h | 2 +- services/audioflinger/Threads.cpp | 2 +- services/audioflinger/test-resample.cpp | 5 +++-- 5 files changed, 10 insertions(+), 9 deletions(-) (limited to 'services/audioflinger') diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp index a1783fe..2d67efb 100644 --- a/services/audioflinger/AudioMixer.cpp +++ b/services/audioflinger/AudioMixer.cpp @@ -1181,7 +1181,7 @@ void AudioMixer::process__genericNoResampling(state_t* state, int64_t pts) } switch (t1.mMixerFormat) { case AUDIO_FORMAT_PCM_FLOAT: - memcpy_to_float_from_q19_12(reinterpret_cast(out), outTemp, BLOCKSIZE * 2); + memcpy_to_float_from_q4_27(reinterpret_cast(out), outTemp, BLOCKSIZE * 2); out += BLOCKSIZE * 2; // output is 2 floats/frame. break; case AUDIO_FORMAT_PCM_16_BIT: @@ -1274,7 +1274,7 @@ void AudioMixer::process__genericResampling(state_t* state, int64_t pts) } switch (t1.mMixerFormat) { case AUDIO_FORMAT_PCM_FLOAT: - memcpy_to_float_from_q19_12(reinterpret_cast(out), outTemp, numFrames*2); + memcpy_to_float_from_q4_27(reinterpret_cast(out), outTemp, numFrames*2); break; case AUDIO_FORMAT_PCM_16_BIT: ditherAndClamp(out, outTemp, numFrames); @@ -1330,8 +1330,8 @@ void AudioMixer::process__OneTrack16BitsStereoNoResampling(state_t* state, in += 2; int32_t l = mulRL(1, rl, vrl); int32_t r = mulRL(0, rl, vrl); - *fout++ = float_from_q19_12(l); - *fout++ = float_from_q19_12(r); + *fout++ = float_from_q4_27(l); + *fout++ = float_from_q4_27(r); // Note: In case of later int16_t sink output, // conversion and clamping is done by memcpy_to_i16_from_float(). } while (--outFrames); diff --git a/services/audioflinger/AudioResampler.h b/services/audioflinger/AudioResampler.h index 0592855..b84567e 100644 --- a/services/audioflinger/AudioResampler.h +++ b/services/audioflinger/AudioResampler.h @@ -63,7 +63,7 @@ public: // A mono provider delivers a sequence of samples. // A stereo provider delivers a sequence of interleaved pairs of samples. // Multi-channel providers are not supported. - // In either case, 'out' holds interleaved pairs of fixed-point signed Q19.12. + // In either case, 'out' holds interleaved pairs of fixed-point Q4.27. // That is, for a mono provider, there is an implicit up-channeling. // Since this method accumulates, the caller is responsible for clearing 'out' initially. // FIXME assumes provider is always successful; it should return the actual frame count. diff --git a/services/audioflinger/RecordTracks.h b/services/audioflinger/RecordTracks.h index 3ec9889..6fc06d8 100644 --- a/services/audioflinger/RecordTracks.h +++ b/services/audioflinger/RecordTracks.h @@ -66,7 +66,7 @@ private: // updated by RecordThread::readInputParameters_l() AudioResampler *mResampler; - // interleaved stereo pairs of fixed-point signed Q19.12 + // interleaved stereo pairs of fixed-point Q4.27 int32_t *mRsmpOutBuffer; // current allocated frame count for the above, which may be larger than needed size_t mRsmpOutFrameCount; diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index 65e9eec..feedd89 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -4954,7 +4954,7 @@ reacquire_wakelock: // ditherAndClamp() works as long as all buffers returned by // activeTrack->getNextBuffer() are 32 bit aligned which should be always true. if (activeTrack->mChannelCount == 1) { - // temporarily type pun mRsmpOutBuffer from Q19.12 to int16_t + // temporarily type pun mRsmpOutBuffer from Q4.27 to int16_t ditherAndClamp(activeTrack->mRsmpOutBuffer, activeTrack->mRsmpOutBuffer, framesOut); // the resampler always outputs stereo samples: diff --git a/services/audioflinger/test-resample.cpp b/services/audioflinger/test-resample.cpp index 3ab3ba9..7b7cdac 100644 --- a/services/audioflinger/test-resample.cpp +++ b/services/audioflinger/test-resample.cpp @@ -352,8 +352,9 @@ int main(int argc, char* argv[]) { size_t out_frames = output_size/8; /* set volume precision to 12 bits, so the volume scale is 1<<12. - * This means the "integer" part fits in the Q19.12 precision - * representation of output int32_t. + * The output int32_t is represented as Q4.27, with 4 bits of guard + * followed by the int16_t Q.15 portion, and then 12 trailing bits of + * additional precision. * * Generally 0 < volumePrecision <= 14 (due to the limits of * int16_t values for Volume). volumePrecision cannot be 0 due -- cgit v1.1