Bug 1349658 - Use mozilla::BitwiseCast rather than reinterpret_cast
reinterpret_cast would be undefined behavior.
MozReview-Commit-ID: KQoEslFlYdM
--- a/dom/media/platforms/agnostic/WAVDecoder.cpp
+++ b/dom/media/platforms/agnostic/WAVDecoder.cpp
@@ -2,16 +2,17 @@
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "AudioSampleFormat.h"
#include "WAVDecoder.h"
#include "mozilla/SyncRunnable.h"
+#include "mozilla/Casting.h"
#include "VideoUtils.h"
using mp4_demuxer::ByteReader;
namespace mozilla {
int16_t
DecodeALawSample(uint8_t aValue)
@@ -87,17 +88,17 @@ WaveDataDecoder::ProcessDecode(MediaRawD
if (!buffer) {
return DecodePromise::CreateAndReject(
MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__), __func__);
}
for (int i = 0; i < frames; ++i) {
for (unsigned int j = 0; j < mInfo.mChannels; ++j) {
if (mInfo.mProfile == 3) { //IEEE float Data
uint32_t v = aReader.ReadU32();
- float decoded = reinterpret_cast<float&>(v);
+ float decoded = BitwiseCast<float>(v);
buffer[i * mInfo.mChannels + j] =
FloatToAudioSample<AudioDataValue>(decoded);
}
if (mInfo.mProfile == 6) { //ALAW Data
uint8_t v = aReader.ReadU8();
int16_t decoded = DecodeALawSample(v);
buffer[i * mInfo.mChannels + j] =
IntegerToAudioSample<AudioDataValue>(decoded);