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

Commit 1319a4af authored by Robert Wu's avatar Robert Wu Committed by Android (Google) Code Review
Browse files

Merge "AAudio: Resampler should not filter when upscaling"

parents f85cb5c4 cc90d54e
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -135,10 +135,9 @@ void MultiChannelResampler::generateCoefficients(int32_t inputRate,
    int coefficientIndex = 0;
    double phase = 0.0; // ranges from 0.0 to 1.0, fraction between samples
    // Stretch the sinc function for low pass filtering.
    const float cutoffScaler = normalizedCutoff *
            ((outputRate < inputRate)
             ? ((float)outputRate / inputRate)
             : ((float)inputRate / outputRate));
    const float cutoffScaler = (outputRate < inputRate)
             ? (normalizedCutoff * (float)outputRate / inputRate)
             : 1.0f; // Do not filter when upsampling.
    const int numTapsHalf = getNumTaps() / 2; // numTaps must be even.
    const float numTapsHalfInverse = 1.0f / numTapsHalf;
    for (int i = 0; i < numRows; i++) {
+7 −0
Original line number Diff line number Diff line
@@ -111,6 +111,9 @@ public:
         * Set lower to reduce aliasing.
         * Default is 0.70.
         *
         * Note that this value is ignored when upsampling, which is when
         * the outputRate is higher than the inputRate.
         *
         * @param normalizedCutoff anti-aliasing filter cutoff
         * @return address of this builder for chaining calls
         */
@@ -227,6 +230,10 @@ protected:

    /**
     * Generate the filter coefficients in optimal order.
     *
     * Note that normalizedCutoff is ignored when upsampling, which is when
     * the outputRate is higher than the inputRate.
     *
     * @param inputRate sample rate of the input stream
     * @param outputRate  sample rate of the output stream
     * @param numRows number of rows in the array that contain a set of tap coefficients
+3 −4
Original line number Diff line number Diff line
@@ -193,10 +193,9 @@ TEST(test_resampler, resampler_11025_44100_best) {
    checkResampler(11025, 44100, MultiChannelResampler::Quality::Best);
}

// TODO This fails because the output is very low.
//TEST(test_resampler, resampler_11025_88200_best) {
//    checkResampler(11025, 88200, MultiChannelResampler::Quality::Best);
//}
TEST(test_resampler, resampler_11025_88200_best) {
    checkResampler(11025, 88200, MultiChannelResampler::Quality::Best);
}

TEST(test_resampler, resampler_16000_48000_best) {
    checkResampler(16000, 48000, MultiChannelResampler::Quality::Best);