https://bugs.freedesktop.org/show_bug.cgi?id=95738 https://bugs.freedesktop.org/attachment.cgi?id=124025 diff -up webrtc-audio-processing-0.2/webrtc/common_audio/wav_file.cc.than webrtc-audio-processing-0.2/webrtc/common_audio/wav_file.cc --- webrtc-audio-processing-0.2/webrtc/common_audio/wav_file.cc.than 2016-05-24 08:28:45.749940095 -0400 +++ webrtc-audio-processing-0.2/webrtc/common_audio/wav_file.cc 2016-05-24 08:50:30.361020010 -0400 @@ -64,9 +64,6 @@ WavReader::~WavReader() { } size_t WavReader::ReadSamples(size_t num_samples, int16_t* samples) { -#ifndef WEBRTC_ARCH_LITTLE_ENDIAN -#error "Need to convert samples to big-endian when reading from WAV file" -#endif // There could be metadata after the audio; ensure we don't read it. num_samples = std::min(rtc::checked_cast(num_samples), num_samples_remaining_); @@ -76,6 +73,12 @@ size_t WavReader::ReadSamples(size_t num RTC_CHECK(read == num_samples || feof(file_handle_)); RTC_CHECK_LE(read, num_samples_remaining_); num_samples_remaining_ -= rtc::checked_cast(read); +#ifndef WEBRTC_ARCH_LITTLE_ENDIAN + //convert to big-endian + for(size_t idx = 0; idx < num_samples; idx++) { + samples[idx] = (samples[idx]<<8) | (samples[idx]>>8); + } +#endif return read; } @@ -120,10 +123,17 @@ WavWriter::~WavWriter() { void WavWriter::WriteSamples(const int16_t* samples, size_t num_samples) { #ifndef WEBRTC_ARCH_LITTLE_ENDIAN -#error "Need to convert samples to little-endian when writing to WAV file" -#endif + int16_t * le_samples = new int16_t[num_samples]; + for(size_t idx = 0; idx < num_samples; idx++) { + le_samples[idx] = (samples[idx]<<8) | (samples[idx]>>8); + } + const size_t written = + fwrite(le_samples, sizeof(*le_samples), num_samples, file_handle_); + delete []le_samples; +#else const size_t written = fwrite(samples, sizeof(*samples), num_samples, file_handle_); +#endif RTC_CHECK_EQ(num_samples, written); num_samples_ += static_cast(written); RTC_CHECK(written <= std::numeric_limits::max() || diff -up webrtc-audio-processing-0.2/webrtc/common_audio/wav_header.cc.than webrtc-audio-processing-0.2/webrtc/common_audio/wav_header.cc --- webrtc-audio-processing-0.2/webrtc/common_audio/wav_header.cc.than 2016-05-24 08:50:52.591379263 -0400 +++ webrtc-audio-processing-0.2/webrtc/common_audio/wav_header.cc 2016-05-24 08:52:08.552606848 -0400 @@ -129,7 +129,39 @@ static inline std::string ReadFourCC(uin return std::string(reinterpret_cast(&x), 4); } #else -#error "Write be-to-le conversion functions" +static inline void WriteLE16(uint16_t* f, uint16_t x) { + *f = ((x << 8) & 0xff00) | ( ( x >> 8) & 0x00ff); +} + +static inline void WriteLE32(uint32_t* f, uint32_t x) { + *f = ( (x & 0x000000ff) << 24 ) + | ((x & 0x0000ff00) << 8) + | ((x & 0x00ff0000) >> 8) + | ((x & 0xff000000) >> 24 ); +} + +static inline void WriteFourCC(uint32_t* f, char a, char b, char c, char d) { + *f = (static_cast(a) << 24 ) + | (static_cast(b) << 16) + | (static_cast(c) << 8) + | (static_cast(d) ); +} + +static inline uint16_t ReadLE16(uint16_t x) { + return (( x & 0x00ff) << 8 )| ((x & 0xff00)>>8); +} + +static inline uint32_t ReadLE32(uint32_t x) { + return ( (x & 0x000000ff) << 24 ) + | ( (x & 0x0000ff00) << 8 ) + | ( (x & 0x00ff0000) >> 8) + | ( (x & 0xff000000) >> 24 ); +} + +static inline std::string ReadFourCC(uint32_t x) { + x = ReadLE32(x); + return std::string(reinterpret_cast(&x), 4); +} #endif static inline uint32_t RiffChunkSize(uint32_t bytes_in_payload) { gnu: nss: Graft with version 3.98 [security fixes]....Maxim Cournoyer 2024-04-26gnu: nss-3.98: Streamline source origin via inheritance....Maxim Cournoyer 2024-04-24gnu: nss: Fix cross-compilation....Zheng Junjie 2024-04-24gnu: nspr: Fix cross-compilation....Zheng Junjie 2024-04-12gnu: Add nss-3.98....Ian Eure