Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6b66a33d authored by Andy Hung's avatar Andy Hung Committed by Android (Google) Code Review
Browse files

Merge "Change references of Q19.12 to Q4.27 for clarity"

parents a3fef05b 84a0c6e8
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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<float *>(out), outTemp, BLOCKSIZE * 2);
                memcpy_to_float_from_q4_27(reinterpret_cast<float *>(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<float*>(out), outTemp, numFrames*2);
            memcpy_to_float_from_q4_27(reinterpret_cast<float*>(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);
+1 −1
Original line number Diff line number Diff line
@@ -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.
+1 −1
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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:
+3 −2
Original line number Diff line number Diff line
@@ -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