From c91f5029ffa817a99860d2406152df8b6288c8ca Mon Sep 17 00:00:00 2001 From: liushuyu Date: Fri, 8 Feb 2019 21:22:14 -0700 Subject: [PATCH] audio_core: hle: mf: fix a regression... ... where the sample copying logic is incorrect due to the wrong usage of `std::array` --- src/audio_core/hle/adts.h | 4 ++-- src/audio_core/hle/adts_reader.cpp | 4 ++-- src/audio_core/hle/wmf_decoder.cpp | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/audio_core/hle/adts.h b/src/audio_core/hle/adts.h index fd11555a9..11c736986 100644 --- a/src/audio_core/hle/adts.h +++ b/src/audio_core/hle/adts.h @@ -16,8 +16,8 @@ struct ADTSData { u32 samplerate; }; -ADTSData ParseADTS(char* buffer); +ADTSData ParseADTS(const char* buffer); // last two bytes of MF AAC decoder user data // see https://docs.microsoft.com/en-us/windows/desktop/medfound/aac-decoder#example-media-types -u16 MFGetAACTag(ADTSData input); +u16 MFGetAACTag(const ADTSData input); diff --git a/src/audio_core/hle/adts_reader.cpp b/src/audio_core/hle/adts_reader.cpp index 42ac4afa2..93118f887 100644 --- a/src/audio_core/hle/adts_reader.cpp +++ b/src/audio_core/hle/adts_reader.cpp @@ -8,7 +8,7 @@ constexpr std::array freq_table = {96000, 88200, 64000, 48000, 44100, 3 16000, 12000, 11025, 8000, 7350, 0, 0, 0}; constexpr std::array channel_table = {0, 1, 2, 3, 4, 5, 6, 8}; -ADTSData ParseADTS(char* buffer) { +ADTSData ParseADTS(const char* buffer) { u32 tmp = 0; ADTSData out; @@ -50,7 +50,7 @@ ADTSData ParseADTS(char* buffer) { // Frame length flag (1 bit) // Depends on core coder (1 bit) // Extension flag (1 bit) -u16 MFGetAACTag(ADTSData input) { +u16 MFGetAACTag(const ADTSData input) { u16 tag = 0; tag |= input.profile << 11; diff --git a/src/audio_core/hle/wmf_decoder.cpp b/src/audio_core/hle/wmf_decoder.cpp index 2d448a216..06d458899 100644 --- a/src/audio_core/hle/wmf_decoder.cpp +++ b/src/audio_core/hle/wmf_decoder.cpp @@ -116,12 +116,14 @@ MFOutputState WMFDecoder::Impl::DecodingLoop(ADTSData adts_header, // the following was taken from ffmpeg version of the decoder f32 val_f32; - for (size_t i = 0; i < output_buffer->size(); i++) { + for (size_t i = 0; i < output_buffer->size(); ) { for (std::size_t channel = 0; channel < adts_header.channels; channel++) { val_f32 = output_buffer->at(i); s16 val = static_cast(0x7FFF * val_f32); out_streams[channel].push_back(val & 0xFF); out_streams[channel].push_back(val >> 8); + // i is incremented on per channel basis + i++; } } }