Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upCoreAudio::HLE: Add FFmpeg/WMF AAC decoder #4508
Conversation
zhaowenlan1779
reviewed
Dec 15, 2018
|
mostly looks okay to me. will check again soon. |
| return true; | ||
| } | ||
|
|
||
| #endif // _Win32 |
This comment has been minimized.
This comment has been minimized.
src/audio_core/hle/ffmpeg_dl.h Outdated
src/audio_core/CMakeLists.txt Outdated
src/audio_core/CMakeLists.txt Outdated
zhaowenlan1779
added
canary-merge
and removed
canary-merge
labels
Dec 15, 2018
B3n30
added
the
canary-merge
label
Dec 15, 2018
wwylele
reviewed
Dec 15, 2018
CMakeLists.txt Outdated
src/audio_core/hle/ffmpeg_dl.h Outdated
src/audio_core/hle/ffmpeg_dl.h Outdated
wwylele
reviewed
Dec 15, 2018
src/audio_core/hle/aac_decoder.cpp Outdated
src/audio_core/hle/aac_decoder.cpp Outdated
src/audio_core/hle/aac_decoder.cpp Outdated
src/audio_core/hle/aac_decoder.cpp Outdated
src/audio_core/hle/aac_decoder.cpp Outdated
MerryMage
reviewed
Dec 15, 2018
src/audio_core/hle/ffmpeg_dl.h Outdated
B3n30
force-pushed the
B3n30:dsp_aac
branch
from
2d798da
to
07c6424
Dec 15, 2018
This comment has been minimized.
This comment has been minimized.
benderscruffy
commented
Dec 16, 2018
•
|
Nintendo 3DS Guide - Louvre (Europe) |
zhaowenlan1779
reviewed
Dec 16, 2018
src/audio_core/hle/ffmpeg_dl.h Outdated
This comment has been minimized.
This comment has been minimized.
|
There is sound popping issue with the AAC decoder on Pokémon X/Y it seems. |
lioncash
reviewed
Dec 16, 2018
src/audio_core/hle/aac_decoder.cpp Outdated
src/audio_core/hle/ffmpeg_dl.h Outdated
src/audio_core/hle/decoder.h Outdated
src/audio_core/hle/decoder.cpp Outdated
src/audio_core/hle/decoder.cpp Outdated
src/audio_core/hle/ffmpeg_dl.h Outdated
src/audio_core/hle/ffmpeg_dl.h Outdated
src/audio_core/hle/ffmpeg_dl.h Outdated
src/audio_core/hle/ffmpeg_dl.h Outdated
src/audio_core/hle/ffmpeg_dl.h Outdated
This comment has been minimized.
This comment has been minimized.
|
@benderscruffy Can you please try again? |
This comment has been minimized.
This comment has been minimized.
|
@Danman3412 Yes I intentionally coded it that way that even if the dlls are missing the decoder would still return a valid response. This means the softlocks are fixed regardless of the dlls. The only issue you observe with missing dlls is that the audio is missing. But since the "Fake response" is based of the response from XY other games might still be broken due to missing dlls. The line in question here is: https://github.com/citra-emu/citra/pull/4508/files#diff-0f90696414f137a30c20616f52bdc1aaR151 |
This comment has been minimized.
This comment has been minimized.
Disciple3
commented
Dec 16, 2018
|
This patch fixes crash #3443 in Fire Emblem If, but voices in treehouse mini-game have wrong pitch. Switching audio to lle mode makes the issue go away. |
This comment has been minimized.
This comment has been minimized.
MojoJojoDojo
commented
Dec 16, 2018
|
On Rhythm Heaven Megamix the various minigames are too fast even though the game reports 60 FPS. |
lioncash
reviewed
Dec 16, 2018
| template <typename T> | ||
| struct FuncDL { | ||
| FuncDL() = default; | ||
| FuncDL(void* dll, const char* name) { |
This comment has been minimized.
This comment has been minimized.
lioncash
reviewed
Dec 16, 2018
src/audio_core/hle/ffmpeg_dl.cpp Outdated
src/audio_core/hle/ffmpeg_dl.cpp Outdated
src/audio_core/hle/decoder.cpp Outdated
src/audio_core/hle/ffmpeg_dl.cpp Outdated
ghost
reviewed
Dec 17, 2018
src/audio_core/hle/ffmpeg_dl.cpp Outdated
src/audio_core/hle/ffmpeg_dl.h Outdated
| typedef HMODULE pointer; | ||
| void operator()(HMODULE h) { | ||
| using pointer = HMODULE; | ||
| void operator()(HMODULE h) const { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
B3n30
force-pushed the
B3n30:dsp_aac
branch
from
ddb522d
to
42c0303
Dec 17, 2018
jroweboy
referenced this pull request
Dec 17, 2018
Closed
HLE AAC codec not found because avcodec_register_all is not called #4518
This comment has been minimized.
This comment has been minimized.
Zombie-Feynman
commented
Dec 17, 2018
|
On my system (Gentoo Linux, ffmpeg-3.3.6, fdk-aac-0.1.5), this fails to find the codec because A very quick-and-dirty patch fixes this, though I'm sure someone more familiar with Citra's code can figure out a better place to put the missing line:
|
This comment has been minimized.
This comment has been minimized.
|
@Zombie-Feynman |
This comment has been minimized.
This comment has been minimized.
saibotlive
commented
Dec 18, 2018
|
While playing Fire Emblem Echoes with the latest canary builds and using HLE, the game freezes whenever you try to talk to a character both in battle or outside battle. I have attached a screenshot and log file below. |
This comment has been minimized.
This comment has been minimized.
|
@saibotlive You probably didn't include the dlls according to https://github.com/citra-emu/citra/wiki/HLE-AAC-Decoder |
This comment has been minimized.
This comment has been minimized.
saibotlive
commented
Dec 18, 2018
|
@B3n30 I am on macOS Mojave, which doesn't need ffmpeg dll files. |
This comment has been minimized.
This comment has been minimized.
|
on macOS it is known that our current build doesn't include al dylibs necessary. There is already a PR #4517 open that should fix that. |
This comment has been minimized.
This comment has been minimized.
saibotlive
commented
Dec 18, 2018
|
@B3n30 that's great to hear. Is there a way I can checkout the open PR branch and build on my machine? |
This comment has been minimized.
This comment has been minimized.
|
this PR isn't a place to discuss this. Maybe you join discord for such questions |
B3n30
and others
added some commits
Jan 9, 2019
B3n30
force-pushed the
B3n30:dsp_aac
branch
from
89ca060
to
ab1f47e
Feb 9, 2019
wwylele
reviewed
Feb 9, 2019
|
|
||
| // 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(const ADTSData input); |
This comment has been minimized.
This comment has been minimized.
wwylele
Feb 9, 2019
Member
This const in function signature has no effect. Either remove it, or make it const reference const ADTSData&
| MFCoInit(); | ||
| } | ||
|
|
||
| WMFDecoder::Impl::~Impl() = default; |
This comment has been minimized.
This comment has been minimized.
wwylele
Feb 9, 2019
Member
The destructor should symmetrically do MFDeInit as opposite to the constructor
|
|
||
| // the following was taken from ffmpeg version of the decoder | ||
| f32 val_f32; | ||
| for (size_t i = 0; i < output_buffer->size();) { |
This comment has been minimized.
This comment has been minimized.
| return; | ||
| } | ||
| LPSTR err; | ||
| FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | |
This comment has been minimized.
This comment has been minimized.
wwylele
Feb 9, 2019
Member
- You should call
LocalFreeafter this function as you useFORMAT_MESSAGE_ALLOCATE_BUFFER - This is a windows API with variant string type. You should use one of the following combinations:
- Use
LPCTSTR/TCHAR*forerrand useFormatMessage - Use
LPCSTR/char*forerr, and useFormatMessageA - Use
LPCWSTR/wchar_t*forerr, and useFormatMessageW
- Use
| return nullptr; | ||
| } | ||
| CoTaskMemFree(activate); | ||
| return std::move(transform); |
This comment has been minimized.
This comment has been minimized.
| } | ||
|
|
||
| bool SelectInputMediaType(IMFTransform* transform, int in_stream_id, const ADTSData& adts, | ||
| UINT8* user_data, UINT32 user_data_len, GUID audio_format) { |
This comment has been minimized.
This comment has been minimized.
| return false; | ||
| } | ||
|
|
||
| std::optional<ADTSMeta> DetectMediaType(char* buffer, size_t len) { |
This comment has been minimized.
This comment has been minimized.
| bool SelectInputMediaType(IMFTransform* transform, int in_stream_id, const ADTSData& adts, | ||
| UINT8* user_data, UINT32 user_data_len, | ||
| GUID audio_format = MFAudioFormat_AAC); | ||
| std::optional<ADTSMeta> DetectMediaType(char* buffer, size_t len); |
This comment has been minimized.
This comment has been minimized.
| if (!dll_util) { | ||
| DWORD error_message_id = GetLastError(); | ||
| LPSTR message_buffer = nullptr; | ||
| size_t size = |
This comment has been minimized.
This comment has been minimized.
| if (!dll_codec) { | ||
| DWORD error_message_id = GetLastError(); | ||
| LPSTR message_buffer = nullptr; | ||
| size_t size = |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Mostly LGTM. Just some more nit above |
liushuyu
and others
added some commits
Feb 9, 2019
This comment has been minimized.
This comment has been minimized.
|
Merging this bulk PR first. Please do follow up PR for fixing nits |

B3n30 commentedDec 15, 2018
•
edited
Due to the DSP LLE and the research from @wwylele I was able to reconstruct the messages used in pipe3 to decode Audio. The encoded and decoded samples are transferred via DMA. So far this was only tested with XY and resolves all the softlocks but still keeps a good speed.
How to get the codec
Since AAC needs a license to distribute the compiled codec, we do not add the codec to the build.
This means for:
If the decoder is missing:
The decoder will still respond with proper responds but since no data gets decoded this will result in missing audio. Sotflocks shouldn't happen anymore though
Future plans:
Merry Christmas🎁 😁
This change is