chromium/media/base/sinc_resampler_unittest.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include <memory>
#include <numbers>

#include "base/containers/heap_array.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "media/base/sinc_resampler.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

_;

namespace media {

static const double kSampleRateRatio =;

// Helper class to ensure ChunkedResample() functions properly.
class MockSource {};

ACTION(ClearBuffer) {}

ACTION(FillBuffer) {}

// Test requesting multiples of ChunkSize() frames results in the proper number
// of callbacks.
TEST(SincResamplerTest, ChunkedResample) {}

// Verify priming the resampler avoids changes to ChunkSize() between calls.
TEST(SincResamplerTest, PrimedResample) {}

// Test flush resets the internal state properly.
TEST(SincResamplerTest, Flush) {}

// This test is designed to be executed manually.
TEST(SincResamplerTest, DISABLED_SetRatioBench) {}

// Ensure various optimized Convolve() methods return the same value.  Only run
// this test if other optimized methods exist, otherwise the default Convolve()
// will be tested by the parameterized SincResampler tests below.
static const double kKernelInterpolationFactor =;

TEST(SincResamplerTest, Convolve) {}

// Fake audio source for testing the resampler.  Generates a sinusoidal linear
// chirp (http://en.wikipedia.org/wiki/Chirp) which can be tuned to stress the
// resampler for the specific sample rate conversion being used.
class SinusoidalLinearChirpSource {};

SincResamplerTestData;
class SincResamplerTest : public testing::TestWithParam<SincResamplerTestData> {};

// Tests resampling using a given input and output sample rate.
TEST_P(SincResamplerTest, Resample) {}

// Tests resampling using a given input and output sample rate, and a small
// kernel size.
TEST_P(SincResamplerTest, Resample_SmallKernel) {}

// Thresholds chosen arbitrarily based on what each resampling reported during
// testing.  All thresholds are in dbFS, http://en.wikipedia.org/wiki/DBFS.

// Almost all conversions have an RMS error of around -15 dbFS and have a high
// frequency error around -12 dbFS.
static const double kRMSMaxError =;
static const double kHighFreqMaxError =;

INSTANTIATE_TEST_SUITE_P();

// Verify the resampler properly reports the max number of input frames it would
// request.
TEST(SincResamplerTest, GetMaxInputFramesRequestedTest) {}

class SincResamplerKernelSizeTest : public testing::Test {};

TEST_F(SincResamplerKernelSizeTest, KernelSizes) {}

}  // namespace media