From 4bc6bfd51ff4d8789bea6343a97535cfd3021df7 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Mon, 28 Jan 2019 21:47:41 -0700 Subject: [PATCH] audio_core: hle: mf: re-arrange comments --- src/audio_core/hle/adts.h | 6 ++++-- src/audio_core/hle/adts_reader.cpp | 10 ++++++++-- src/audio_core/hle/wmf_decoder_utils.cpp | 15 +++++++-------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/audio_core/hle/adts.h b/src/audio_core/hle/adts.h index bd68422be..45d1add1c 100644 --- a/src/audio_core/hle/adts.h +++ b/src/audio_core/hle/adts.h @@ -17,6 +17,8 @@ struct ADTSData { u32 samplerate; }; -u32 ParseADTS(char* buffer, struct ADTSData* out); +u32 ParseADTS(char* buffer, ADTSData* out); + // last two bytes of MF AAC decoder user data -u16 MFGetAACTag(struct ADTSData input); +// see https://docs.microsoft.com/en-us/windows/desktop/medfound/aac-decoder#example-media-types +u16 MFGetAACTag(ADTSData input); diff --git a/src/audio_core/hle/adts_reader.cpp b/src/audio_core/hle/adts_reader.cpp index 1bb3b4c76..a2df93125 100644 --- a/src/audio_core/hle/adts_reader.cpp +++ b/src/audio_core/hle/adts_reader.cpp @@ -7,7 +7,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}; -u32 ParseADTS(char* buffer, struct ADTSData* out) { +u32 ParseADTS(char* buffer, ADTSData* out) { u32 tmp = 0; // sync word 0xfff @@ -40,7 +40,13 @@ u32 ParseADTS(char* buffer, struct ADTSData* out) { } // last two bytes of MF AAC decoder user data -u16 MFGetAACTag(struct ADTSData input) { +// Audio object type (5 bits) +// Sample rate profile (4 bits) +// Channel configuration profile (4 bits) +// Frame length flag (1 bit) +// Depends on core coder (1 bit) +// Extension flag (1 bit) +u16 MFGetAACTag(ADTSData input) { u16 tag = 0; tag |= input.profile << 11; diff --git a/src/audio_core/hle/wmf_decoder_utils.cpp b/src/audio_core/hle/wmf_decoder_utils.cpp index 4568a1147..5c1a3713c 100644 --- a/src/audio_core/hle/wmf_decoder_utils.cpp +++ b/src/audio_core/hle/wmf_decoder_utils.cpp @@ -134,14 +134,6 @@ bool SelectInputMediaType(IMFTransform* transform, int in_stream_id, const ADTSD t->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio); t->SetGUID(MF_MT_SUBTYPE, audio_format); - // see https://docs.microsoft.com/en-us/windows/desktop/medfound/aac-decoder#example-media-types - // and https://docs.microsoft.com/zh-cn/windows/desktop/api/mmreg/ns-mmreg-heaacwaveinfo_tag - // for the meaning of the byte array below - - // for integrate into a larger project, it is recommended to wrap the parameters into a struct - // and pass that struct into the function - // const UINT8 aac_data[] = { 0x01, 0x00, 0xfe, 00, 00, 00, 00, 00, 00, 00, 00, 00, 0x11, 0x90 - // }; 0: raw aac 1: adts 2: adif 3: latm/laos t->SetUINT32(MF_MT_AAC_PAYLOAD_TYPE, 1); t->SetUINT32(MF_MT_AUDIO_NUM_CHANNELS, adts.channels); t->SetUINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, adts.samplerate); @@ -211,6 +203,13 @@ int DetectMediaType(char* buffer, size_t len, ADTSData* output, char** aac_tag) } ADTSData tmp; + // see https://docs.microsoft.com/en-us/windows/desktop/api/mmreg/ns-mmreg-heaacwaveinfo_tag + // for the meaning of the byte array below + + // it might be a good idea to wrap the parameters into a struct + // and pass that struct into the function but this will lead to messier code + // const UINT8 aac_data[] = { 0x01, 0x00, 0xfe, 00, 00, 00, 00, 00, 00, 00, 00, 00, 0x11, 0x90 + // }; first byte: 0: raw aac 1: adts 2: adif 3: latm/laos UINT8 aac_tmp[] = {0x01, 0x00, 0xfe, 00, 00, 00, 00, 00, 00, 00, 00, 00, 0x00, 0x00}; uint16_t tag = 0;