| Index: services/media/audio/platform/generic/mixers/point_sampler.cc
|
| diff --git a/services/media/audio/platform/generic/mixers/point_sampler.cc b/services/media/audio/platform/generic/mixers/point_sampler.cc
|
| index 293d4061ceadb187992559cc60a55d4364ec5168..9a36682a5c429283852572b5c6c163f365c0c3a7 100644
|
| --- a/services/media/audio/platform/generic/mixers/point_sampler.cc
|
| +++ b/services/media/audio/platform/generic/mixers/point_sampler.cc
|
| @@ -15,15 +15,14 @@ namespace audio {
|
| namespace mixers {
|
|
|
| // Point Sample Mixer implementation.
|
| -template <typename DType,
|
| - size_t DChCount,
|
| +template <size_t DChCount,
|
| typename SType,
|
| size_t SChCount>
|
| class PointSamplerImpl : public PointSampler {
|
| public:
|
| PointSamplerImpl() : PointSampler(0, FRAC_ONE - 1) {}
|
|
|
| - bool Mix(void* dst,
|
| + bool Mix(int32_t* dst,
|
| uint32_t dst_frames,
|
| uint32_t* dst_offset,
|
| const void* src,
|
| @@ -34,7 +33,7 @@ class PointSamplerImpl : public PointSampler {
|
|
|
| private:
|
| template <bool DoAccumulate>
|
| - static inline bool Mix(void* dst,
|
| + static inline bool Mix(int32_t* dst,
|
| uint32_t dst_frames,
|
| uint32_t* dst_offset,
|
| const void* src,
|
| @@ -43,13 +42,12 @@ class PointSamplerImpl : public PointSampler {
|
| uint32_t frac_step_size);
|
| };
|
|
|
| -template <typename DType,
|
| - size_t DChCount,
|
| +template <size_t DChCount,
|
| typename SType,
|
| size_t SChCount>
|
| template <bool DoAccumulate>
|
| -inline bool PointSamplerImpl<DType, DChCount, SType, SChCount>::Mix(
|
| - void* dst_void,
|
| +inline bool PointSamplerImpl<DChCount, SType, SChCount>::Mix(
|
| + int32_t* dst,
|
| uint32_t dst_frames,
|
| uint32_t* dst_offset,
|
| const void* src_void,
|
| @@ -57,10 +55,9 @@ inline bool PointSamplerImpl<DType, DChCount, SType, SChCount>::Mix(
|
| int32_t* frac_src_offset,
|
| uint32_t frac_step_size) {
|
| using SR = utils::SrcReader<SType, SChCount, DChCount>;
|
| - using DM = utils::DstMixer<DType, DoAccumulate>;
|
| + using DM = utils::DstMixer<DoAccumulate>;
|
|
|
| const SType* src = static_cast<const SType*>(src_void);
|
| - DType* dst = static_cast<DType*>(dst_void);
|
| uint32_t doff = *dst_offset;
|
| int32_t soff = *frac_src_offset;
|
|
|
| @@ -72,14 +69,14 @@ inline bool PointSamplerImpl<DType, DChCount, SType, SChCount>::Mix(
|
| while ((doff < dst_frames) &&
|
| (soff < static_cast<int32_t>(frac_src_frames))) {
|
| uint32_t src_iter;
|
| - DType* out;
|
| + int32_t* out;
|
|
|
| src_iter = (soff >> AudioTrackImpl::PTS_FRACTIONAL_BITS) * SChCount;
|
| out = dst + (doff * DChCount);
|
|
|
| for (size_t dst_iter = 0; dst_iter < DChCount; ++dst_iter) {
|
| int32_t sample = SR::Read(src + src_iter + (dst_iter / SR::DstPerSrc));
|
| - out[dst_iter] = DM::Mix(out + dst_iter, sample);
|
| + out[dst_iter] = DM::Mix(out[dst_iter], sample);
|
| }
|
|
|
| doff += 1;
|
| @@ -92,12 +89,11 @@ inline bool PointSamplerImpl<DType, DChCount, SType, SChCount>::Mix(
|
| return (soff >= static_cast<int32_t>(frac_src_frames));
|
| }
|
|
|
| -template <typename DType,
|
| - size_t DChCount,
|
| +template <size_t DChCount,
|
| typename SType,
|
| size_t SChCount>
|
| -bool PointSamplerImpl<DType, DChCount, SType, SChCount>::Mix(
|
| - void* dst,
|
| +bool PointSamplerImpl<DChCount, SType, SChCount>::Mix(
|
| + int32_t* dst,
|
| uint32_t dst_frames,
|
| uint32_t* dst_offset,
|
| const void* src,
|
| @@ -115,64 +111,48 @@ bool PointSamplerImpl<DType, DChCount, SType, SChCount>::Mix(
|
|
|
| // Templates used to expand all of the different combinations of the possible
|
| // Point Sampler Mixer configurations.
|
| -template <typename DType,
|
| - size_t DChCount,
|
| +template <size_t DChCount,
|
| typename SType,
|
| size_t SChCount>
|
| static inline MixerPtr SelectPSM(const LpcmMediaTypeDetailsPtr& src_format,
|
| const LpcmMediaTypeDetailsPtr& dst_format) {
|
| - return MixerPtr(new PointSamplerImpl<DType, DChCount, SType, SChCount>());
|
| + return MixerPtr(new PointSamplerImpl<DChCount, SType, SChCount>());
|
| }
|
|
|
| -template <typename DType,
|
| - size_t DChCount,
|
| +template <size_t DChCount,
|
| typename SType>
|
| static inline MixerPtr SelectPSM(const LpcmMediaTypeDetailsPtr& src_format,
|
| const LpcmMediaTypeDetailsPtr& dst_format) {
|
| switch (src_format->channels) {
|
| case 1:
|
| - return SelectPSM<DType, DChCount, SType, 1>(src_format, dst_format);
|
| + return SelectPSM<DChCount, SType, 1>(src_format, dst_format);
|
| case 2:
|
| - return SelectPSM<DType, DChCount, SType, 2>(src_format, dst_format);
|
| + return SelectPSM<DChCount, SType, 2>(src_format, dst_format);
|
| default:
|
| return nullptr;
|
| }
|
| }
|
|
|
| -template <typename DType,
|
| - size_t DChCount>
|
| +template <size_t DChCount>
|
| static inline MixerPtr SelectPSM(const LpcmMediaTypeDetailsPtr& src_format,
|
| const LpcmMediaTypeDetailsPtr& dst_format) {
|
| switch (src_format->sample_format) {
|
| case LpcmSampleFormat::UNSIGNED_8:
|
| - return SelectPSM<DType, DChCount, uint8_t>(src_format, dst_format);
|
| + return SelectPSM<DChCount, uint8_t>(src_format, dst_format);
|
| case LpcmSampleFormat::SIGNED_16:
|
| - return SelectPSM<DType, DChCount, int16_t>(src_format, dst_format);
|
| + return SelectPSM<DChCount, int16_t>(src_format, dst_format);
|
| default:
|
| return nullptr;
|
| }
|
| }
|
|
|
| -template <typename DType>
|
| -static inline MixerPtr SelectPSM(const LpcmMediaTypeDetailsPtr& src_format,
|
| - const LpcmMediaTypeDetailsPtr& dst_format) {
|
| +MixerPtr PointSampler::Select(const LpcmMediaTypeDetailsPtr& src_format,
|
| + const LpcmMediaTypeDetailsPtr& dst_format) {
|
| switch (dst_format->channels) {
|
| case 1:
|
| - return SelectPSM<DType, 1>(src_format, dst_format);
|
| + return SelectPSM<1>(src_format, dst_format);
|
| case 2:
|
| - return SelectPSM<DType, 2>(src_format, dst_format);
|
| - default:
|
| - return nullptr;
|
| - }
|
| -}
|
| -
|
| -MixerPtr PointSampler::Select(const LpcmMediaTypeDetailsPtr& src_format,
|
| - const LpcmMediaTypeDetailsPtr& dst_format) {
|
| - switch (dst_format->sample_format) {
|
| - case LpcmSampleFormat::UNSIGNED_8:
|
| - return SelectPSM<uint8_t>(src_format, dst_format);
|
| - case LpcmSampleFormat::SIGNED_16:
|
| - return SelectPSM<int16_t>(src_format, dst_format);
|
| + return SelectPSM<2>(src_format, dst_format);
|
| default:
|
| return nullptr;
|
| }
|
|
|