| Index: services/media/audio/platform/generic/mixers/linear_sampler.cc
|
| diff --git a/services/media/audio/platform/generic/mixers/linear_sampler.cc b/services/media/audio/platform/generic/mixers/linear_sampler.cc
|
| index 3bb8a0bd51ef926dcda4e730be07aecdb84728c4..1abe1a5c059b010bc3229ccbab1ca17ebadbef80 100644
|
| --- a/services/media/audio/platform/generic/mixers/linear_sampler.cc
|
| +++ b/services/media/audio/platform/generic/mixers/linear_sampler.cc
|
| @@ -13,8 +13,7 @@ namespace media {
|
| namespace audio {
|
| namespace mixers {
|
|
|
| -template <typename DType,
|
| - size_t DChCount,
|
| +template <size_t DChCount,
|
| typename SType,
|
| size_t SChCount>
|
| class LinearSamplerImpl : public LinearSampler {
|
| @@ -24,7 +23,7 @@ class LinearSamplerImpl : public LinearSampler {
|
| Reset();
|
| }
|
|
|
| - bool Mix(void* dst,
|
| + bool Mix(int32_t* dst,
|
| uint32_t dst_frames,
|
| uint32_t* dst_offset,
|
| const void* src,
|
| @@ -39,7 +38,7 @@ class LinearSamplerImpl : public LinearSampler {
|
|
|
| private:
|
| template <bool DoAccumulate>
|
| - inline bool Mix(void* dst,
|
| + inline bool Mix(int32_t* dst,
|
| uint32_t dst_frames,
|
| uint32_t* dst_offset,
|
| const void* src,
|
| @@ -56,13 +55,12 @@ class LinearSamplerImpl : public LinearSampler {
|
| int32_t filter_data_[2 * DChCount];
|
| };
|
|
|
| -template <typename DType,
|
| - size_t DChCount,
|
| +template <size_t DChCount,
|
| typename SType,
|
| size_t SChCount>
|
| template <bool DoAccumulate>
|
| -inline bool LinearSamplerImpl<DType, DChCount, SType, SChCount>::Mix(
|
| - void* dst_void,
|
| +inline bool LinearSamplerImpl<DChCount, SType, SChCount>::Mix(
|
| + int32_t* dst,
|
| uint32_t dst_frames,
|
| uint32_t* dst_offset,
|
| const void* src_void,
|
| @@ -70,9 +68,8 @@ inline bool LinearSamplerImpl<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;
|
|
|
| @@ -89,13 +86,13 @@ inline bool LinearSamplerImpl<DType, DChCount, SType, SChCount>::Mix(
|
| }
|
|
|
| do {
|
| - DType* out = dst + (doff * DChCount);
|
| + int32_t* out = dst + (doff * DChCount);
|
|
|
| for (size_t D = 0; D < DChCount; ++D) {
|
| int32_t sample = Interpolate(filter_data_[DChCount + D],
|
| filter_data_[D],
|
| -soff);
|
| - out[D] = DM::Mix(out + D, sample);
|
| + out[D] = DM::Mix(out[D], sample);
|
| }
|
|
|
| doff += 1;
|
| @@ -106,13 +103,13 @@ inline bool LinearSamplerImpl<DType, DChCount, SType, SChCount>::Mix(
|
| int32_t source_end = static_cast<int32_t>(frac_src_frames - FRAC_ONE);
|
| while ((doff < dst_frames) && (soff < source_end)) {
|
| uint32_t S = (soff >> AudioTrackImpl::PTS_FRACTIONAL_BITS) * SChCount;
|
| - DType* out = dst + (doff * DChCount);
|
| + int32_t* out = dst + (doff * DChCount);
|
|
|
| for (size_t D = 0; D < DChCount; ++D) {
|
| int32_t s1 = SR::Read(src + S + (D / SR::DstPerSrc));
|
| int32_t s2 = SR::Read(src + S + (D / SR::DstPerSrc) + SChCount);
|
| int32_t sample = Interpolate(s1, s2, soff & FRAC_MASK);
|
| - out[D] = DM::Mix(out + D, sample);
|
| + out[D] = DM::Mix(out[D], sample);
|
| }
|
|
|
| doff += 1;
|
| @@ -124,11 +121,11 @@ inline bool LinearSamplerImpl<DType, DChCount, SType, SChCount>::Mix(
|
| // final frame into the output buffer.
|
| if ((doff < dst_frames) && (soff == source_end)) {
|
| uint32_t S = (soff >> AudioTrackImpl::PTS_FRACTIONAL_BITS) * SChCount;
|
| - DType* out = dst + (doff * DChCount);
|
| + int32_t* out = dst + (doff * DChCount);
|
|
|
| for (size_t D = 0; D < DChCount; ++D) {
|
| int32_t sample = SR::Read(src + S + (D / SR::DstPerSrc));
|
| - out[D] = DM::Mix(out + D, sample);
|
| + out[D] = DM::Mix(out[D], sample);
|
| }
|
|
|
| doff += 1;
|
| @@ -149,12 +146,11 @@ inline bool LinearSamplerImpl<DType, DChCount, SType, SChCount>::Mix(
|
| return false;
|
| }
|
|
|
| -template <typename DType,
|
| - size_t DChCount,
|
| +template <size_t DChCount,
|
| typename SType,
|
| size_t SChCount>
|
| -bool LinearSamplerImpl<DType, DChCount, SType, SChCount>::Mix(
|
| - void* dst,
|
| +bool LinearSamplerImpl<DChCount, SType, SChCount>::Mix(
|
| + int32_t* dst,
|
| uint32_t dst_frames,
|
| uint32_t* dst_offset,
|
| const void* src,
|
| @@ -172,64 +168,48 @@ bool LinearSamplerImpl<DType, DChCount, SType, SChCount>::Mix(
|
|
|
| // Templates used to expand all of the different combinations of the possible
|
| // Linear Sampler Mixer configurations.
|
| -template <typename DType,
|
| - size_t DChCount,
|
| +template <size_t DChCount,
|
| typename SType,
|
| size_t SChCount>
|
| static inline MixerPtr SelectLSM(const LpcmMediaTypeDetailsPtr& src_format,
|
| const LpcmMediaTypeDetailsPtr& dst_format) {
|
| - return MixerPtr(new LinearSamplerImpl<DType, DChCount, SType, SChCount>());
|
| + return MixerPtr(new LinearSamplerImpl<DChCount, SType, SChCount>());
|
| }
|
|
|
| -template <typename DType,
|
| - size_t DChCount,
|
| +template <size_t DChCount,
|
| typename SType>
|
| static inline MixerPtr SelectLSM(const LpcmMediaTypeDetailsPtr& src_format,
|
| const LpcmMediaTypeDetailsPtr& dst_format) {
|
| switch (src_format->channels) {
|
| case 1:
|
| - return SelectLSM<DType, DChCount, SType, 1>(src_format, dst_format);
|
| + return SelectLSM<DChCount, SType, 1>(src_format, dst_format);
|
| case 2:
|
| - return SelectLSM<DType, DChCount, SType, 2>(src_format, dst_format);
|
| + return SelectLSM<DChCount, SType, 2>(src_format, dst_format);
|
| default:
|
| return nullptr;
|
| }
|
| }
|
|
|
| -template <typename DType,
|
| - size_t DChCount>
|
| +template <size_t DChCount>
|
| static inline MixerPtr SelectLSM(const LpcmMediaTypeDetailsPtr& src_format,
|
| const LpcmMediaTypeDetailsPtr& dst_format) {
|
| switch (src_format->sample_format) {
|
| case LpcmSampleFormat::UNSIGNED_8:
|
| - return SelectLSM<DType, DChCount, uint8_t>(src_format, dst_format);
|
| + return SelectLSM<DChCount, uint8_t>(src_format, dst_format);
|
| case LpcmSampleFormat::SIGNED_16:
|
| - return SelectLSM<DType, DChCount, int16_t>(src_format, dst_format);
|
| + return SelectLSM<DChCount, int16_t>(src_format, dst_format);
|
| default:
|
| return nullptr;
|
| }
|
| }
|
|
|
| -template <typename DType>
|
| -static inline MixerPtr SelectLSM(const LpcmMediaTypeDetailsPtr& src_format,
|
| - const LpcmMediaTypeDetailsPtr& dst_format) {
|
| +MixerPtr LinearSampler::Select(const LpcmMediaTypeDetailsPtr& src_format,
|
| + const LpcmMediaTypeDetailsPtr& dst_format) {
|
| switch (dst_format->channels) {
|
| case 1:
|
| - return SelectLSM<DType, 1>(src_format, dst_format);
|
| + return SelectLSM<1>(src_format, dst_format);
|
| case 2:
|
| - return SelectLSM<DType, 2>(src_format, dst_format);
|
| - default:
|
| - return nullptr;
|
| - }
|
| -}
|
| -
|
| -MixerPtr LinearSampler::Select(const LpcmMediaTypeDetailsPtr& src_format,
|
| - const LpcmMediaTypeDetailsPtr& dst_format) {
|
| - switch (dst_format->sample_format) {
|
| - case LpcmSampleFormat::UNSIGNED_8:
|
| - return SelectLSM<uint8_t>(src_format, dst_format);
|
| - case LpcmSampleFormat::SIGNED_16:
|
| - return SelectLSM<int16_t>(src_format, dst_format);
|
| + return SelectLSM<2>(src_format, dst_format);
|
| default:
|
| return nullptr;
|
| }
|
|
|