| Index: services/media/framework/lpcm_util.cc
|
| diff --git a/services/media/framework/lpcm_util.cc b/services/media/framework/lpcm_util.cc
|
| index 3b9278166ed22ed2ff86c73a56ba66072da5fde6..bc94ce271f32e5c71c95ab0f1389e0b401a6bf3f 100644
|
| --- a/services/media/framework/lpcm_util.cc
|
| +++ b/services/media/framework/lpcm_util.cc
|
| @@ -10,7 +10,7 @@ namespace mojo {
|
| namespace media {
|
|
|
| // LpcmUtil implementation that processes samples of type T.
|
| -template<typename T>
|
| +template <typename T>
|
| class LpcmUtilImpl : public LpcmUtil {
|
| public:
|
| ~LpcmUtilImpl();
|
| @@ -21,11 +21,10 @@ class LpcmUtilImpl : public LpcmUtil {
|
|
|
| void Mix(const void* in, void* out, size_t frame_count) const override;
|
|
|
| - void Interleave(
|
| - const void* in,
|
| - size_t in_byte_count,
|
| - void* out,
|
| - size_t frame_count) const override;
|
| + void Interleave(const void* in,
|
| + size_t in_byte_count,
|
| + void* out,
|
| + size_t frame_count) const override;
|
|
|
| private:
|
| LpcmUtilImpl(const LpcmStreamType& stream_type);
|
| @@ -52,8 +51,8 @@ std::unique_ptr<LpcmUtil> LpcmUtil::Create(const LpcmStreamType& stream_type) {
|
| result = new LpcmUtilImpl<float>(stream_type);
|
| break;
|
| default:
|
| - NOTREACHED()
|
| - << "unsupported sample format " << stream_type.sample_format();
|
| + NOTREACHED() << "unsupported sample format "
|
| + << stream_type.sample_format();
|
| result = nullptr;
|
| break;
|
| }
|
| @@ -61,70 +60,65 @@ std::unique_ptr<LpcmUtil> LpcmUtil::Create(const LpcmStreamType& stream_type) {
|
| return std::unique_ptr<LpcmUtil>(result);
|
| }
|
|
|
| -template<typename T>
|
| -LpcmUtilImpl<T>::LpcmUtilImpl(const LpcmStreamType& stream_type) :
|
| - stream_type_(stream_type) {}
|
| +template <typename T>
|
| +LpcmUtilImpl<T>::LpcmUtilImpl(const LpcmStreamType& stream_type)
|
| + : stream_type_(stream_type) {}
|
|
|
| -template<typename T>
|
| +template <typename T>
|
| LpcmUtilImpl<T>::~LpcmUtilImpl() {}
|
|
|
| -template<typename T>
|
| +template <typename T>
|
| void LpcmUtilImpl<T>::Silence(void* buffer, size_t frame_count) const {
|
| T* sample = reinterpret_cast<T*>(buffer);
|
| - for (
|
| - size_t sample_countdown = frame_count * stream_type_.channels();
|
| - sample_countdown != 0;
|
| - --sample_countdown) {
|
| + for (size_t sample_countdown = frame_count * stream_type_.channels();
|
| + sample_countdown != 0; --sample_countdown) {
|
| *sample = 0;
|
| sample++;
|
| }
|
| }
|
|
|
| -template<>
|
| +template <>
|
| void LpcmUtilImpl<uint8_t>::Silence(void* buffer, size_t frame_count) const {
|
| std::memset(buffer, 0x80, frame_count * stream_type_.bytes_per_frame());
|
| }
|
|
|
| -template<>
|
| +template <>
|
| void LpcmUtilImpl<int16_t>::Silence(void* buffer, size_t frame_count) const {
|
| std::memset(buffer, 0, frame_count * stream_type_.bytes_per_frame());
|
| }
|
|
|
| -template<>
|
| +template <>
|
| void LpcmUtilImpl<int32_t>::Silence(void* buffer, size_t frame_count) const {
|
| std::memset(buffer, 0, frame_count * stream_type_.bytes_per_frame());
|
| }
|
|
|
| -template<typename T>
|
| -void LpcmUtilImpl<T>::Copy(const void* in, void* out, size_t frame_count)
|
| - const {
|
| +template <typename T>
|
| +void LpcmUtilImpl<T>::Copy(const void* in,
|
| + void* out,
|
| + size_t frame_count) const {
|
| std::memcpy(out, in, stream_type_.min_buffer_size(frame_count));
|
| }
|
|
|
| -template<typename T>
|
| -void LpcmUtilImpl<T>::Mix(const void* in, void* out, size_t frame_count)
|
| - const {
|
| +template <typename T>
|
| +void LpcmUtilImpl<T>::Mix(const void* in, void* out, size_t frame_count) const {
|
| const T* in_sample = reinterpret_cast<const T*>(in);
|
| T* out_sample = reinterpret_cast<T*>(out);
|
| - for (
|
| - size_t sample_countdown = frame_count * stream_type_.channels();
|
| - sample_countdown != 0;
|
| - --sample_countdown) {
|
| - *out_sample += *in_sample; // TODO(dalesat): Limit.
|
| + for (size_t sample_countdown = frame_count * stream_type_.channels();
|
| + sample_countdown != 0; --sample_countdown) {
|
| + *out_sample += *in_sample; // TODO(dalesat): Limit.
|
| out_sample++;
|
| in_sample++;
|
| }
|
| }
|
|
|
| -template<>
|
| -void LpcmUtilImpl<uint8_t>::Mix(const void* in, void* out, size_t frame_count)
|
| - const {
|
| +template <>
|
| +void LpcmUtilImpl<uint8_t>::Mix(const void* in,
|
| + void* out,
|
| + size_t frame_count) const {
|
| const uint8_t* in_sample = reinterpret_cast<const uint8_t*>(in);
|
| uint8_t* out_sample = reinterpret_cast<uint8_t*>(out);
|
| - for (
|
| - size_t sample_countdown = frame_count * stream_type_.channels();
|
| - sample_countdown != 0;
|
| - --sample_countdown) {
|
| + for (size_t sample_countdown = frame_count * stream_type_.channels();
|
| + sample_countdown != 0; --sample_countdown) {
|
| *out_sample = uint8_t(uint16_t(*out_sample) + uint16_t(*in_sample) - 0x80);
|
| // TODO(dalesat): Limit.
|
| out_sample++;
|
| @@ -132,12 +126,11 @@ void LpcmUtilImpl<uint8_t>::Mix(const void* in, void* out, size_t frame_count)
|
| }
|
| }
|
|
|
| -template<typename T>
|
| -void LpcmUtilImpl<T>::Interleave(
|
| - const void* in,
|
| - size_t in_byte_count,
|
| - void* out,
|
| - size_t frame_count) const {
|
| +template <typename T>
|
| +void LpcmUtilImpl<T>::Interleave(const void* in,
|
| + size_t in_byte_count,
|
| + void* out,
|
| + size_t frame_count) const {
|
| DCHECK(in);
|
| DCHECK(in_byte_count);
|
| DCHECK(out);
|
|
|