-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libav does not decode correct sample block size #95
Comments
Couple quick changes to zero out the uninitialized memory (for sanity) and clean up some of the sample-vs-frame math that was going on: This somewhat unintentionally fixes one case i found where the offsets were only off by 1... for a stereo stream. Not sure how that happened, but hopefully it won't happen again now that this is in. |
From Johan in the Discord...
So that... kind of explains why it's not 100% consistent each time? In any case, this is a pretty big problem; we've fixed our end of it but if we want this to work properly it'll have to be fixed in FFmpeg. |
Possible idea to explore: Take our existing WMA test program and add a DumpXAPO that's attached to the source; the idea is what we can run that XAPO against both XAudio2 and FAudio and compare the samples decoded (ideally not resampled) by both libraries. From there we can use XAudio2's output as a control and compare various attempts to fix this in FAudio and FFmpeg. |
I believe this is the same issue...? https://trac.ffmpeg.org/ticket/7473 |
@flibitijibibo I also built libfaudio from latest git, and tried compiling with ffmpeg aswell (Ubuntu 18.04 libavcodec-dev 7:3.4.4-0ubuntu0.18.04.1), but are not able to get any sounds during the WMA/XWMA part of the XAudio2BasicSound.exe demo.
Is it my ffmpeg "too old", or is there a issue? You can download the binaries i tested with here: https://github.com/SveSop/wine_patches/blob/master/xaudio.tar.xz Build log of libfaudio w/ffmpeg: https://launchpad.net/ |
If it’s older than 4.0 it’s too old. |
@flibitijibibo
If you want whole log, let me know. |
I think the error message speaks for itself... |
@flibitijibibo Things i have tested: Compiled latest faudio w/ Ofc i could have made the packages totally wrong, but since ffmpeg (ffplay) plays the file just fine when used for playing, i would kind of believe ffmpeg library is able to handle this? Or am i totally mistaken? I admit i am a total newb, and might just aswell have made (several) errors on my package setup. Tips are welcome :) PS. Or should i post this as a separate issue if you deem it warrants a "issue" to work on? |
I'll translate it:
TL;DR: This is FFmpeg's issue, not ours. |
Could it be a wine bug? |
No. It's either an FFmpeg issue (which I just said...) or the WAVEFORMATEXTENSIBLE data needs to be looked at. You would need to look at what the samples generate for those files. |
From the xwma.c file:
FFmpeg decodes and plays it, but something else might happen when "its coming from xaudio2". |
@flibitijibibo The XWMa file plays just fine with ffplay. 2 channel or mono XWMa files also play just fine, so something strange must happen when Xaudio2 sends this to libfaudio i think. I am not really sure how i should make a bugreport of this to FFmpeg team, since it is working fine tho. Do you want to experiment with the files? Attaching a .gz of the original .wav and the converted _xwma.wav. |
This is the spot you care about: https://github.com/FNA-XNA/FAudio/blob/master/src/FAudio_ffmpeg.c#L116 |
I have been toying around with this, and all i can really come up with is that when playing with ffplay, "some" of this "waveformatextensible" data is just ignored/cleared, but when FAudio copies this over for ffmpeg to play, there is some data that is "not supported" (ref. error msg). I have no clue what data this actually contains, or what bits i could/should clear out for ffmpeg to not throw this error. Commenting out the I dont know what |
Yeah, that memcpy should cover everything past the base WAVEFORMATEX structure. But that 'bits per sample' message is really strange, it implies the format doesn't provide a bit depth...? I would dump out the entire WAVEFORMATEXTENSIBLE struct and see what we're being sent in XAudio2 vs what the real header of the file says. Maybe we do have to deliberately throw out some stuff, not sure. |
I dont have any great ideas, and i have tried to fiddle a bit with it, but i come up short :) I wonder tho, is this some sort of conversion? Or does it not come into action when FFmpeg is used? I only ask, cos it seems as the only usable xWMA files i am able to produce using "wmapro" is multichannel audio, and if some sort of conversion would happen, perhaps there is some added bits from that causing this? (Regular pcm_s16le encoded wav's in 5.1 seems to work fine tho). |
I simplified the XAudio2BasicSound.exe file, so that it only loads the wmapro 5.1 wav "musicsurround_xwma.wav", so you can test it if you like? If you run it in Win10 it requires DirectXRedistJune2010 package (For XAudio2), and msvc140 (c++ redist). |
At the moment I can only test patches to FAudio directly; because of the licensing issues blocking us this is pretty low on the TODO list since there is other stuff I need to get working that doesn't have a patent blocking it. For reference, here's our xwma test program: https://github.com/FNA-XNA/FAudio/tree/master/utils/testxwma |
@flibitijibibo Oh, i was not aware of the testxwma "player" :) Nice! Atleast another testproggy to fiddle with in my spare time. Thx :) |
With the latest revision the decoding responsibility has been moved to GStreamer. We still have an issue when moving from one WMA buffer to the next, but this was present in the previous decoder as well. |
I don't understand, shouldn't WMA1/WMA2 US patents be expired by now if the formats were released in 1999? |
The patent portfolio that covers the various formats and their revisions over the years is several dozen pages long with countless companies with various expiration dates. If there was a straightforward date, it probably would have gotten its own website like S3TC did. |
Doing a bit of spring cleaning... Closing as NOTOURBUG - WMA issues with libav should be filed with that project; at this point my only real data is going to come from protonmediaconverter so this is effectively abandoned. |
I finally figured out what's causing all that racket with WMA/XMA streams. This one's for @aeikum (wrote the original FFmpeg work), @0x0ade (XMA), @GloriousEggroll (Warframe), and @JohanSmet (wrote the most recent FAudio FFmpeg work).
A quick overview of how the decoding system works: When a buffer is submitted we receive not just the data itself, but the amount of data we can get (measured in samples). So when we decode, we ask for exactly the number of samples we need based on the quantum size until the end, where the number will be a little bit smaller. In either case, the decoder always provides the exact number of samples we request because we always know how many samples are available without the decoder's assistance.
FFmpeg isn't playing by the rules. In particular, we're hitting this line which should never ever happen:
https://github.com/FNA-XNA/FAudio/blob/master/src/FAudio_ffmpeg.c#L382
Here's the quick version:
available
is 0, breakstodo
is less thansamples
, resulting in uninitialized memory at the endEggroll has it in Warframe, I have it in Skyrim SE. We need to figure out how to make FFmpeg cooperate and actually give us all the samples. We can't leave without the full size, because then you just get skipping, which is more pleasant-sounding but still very wrong.
Anyone have any ideas? I'm not terribly familiar with FFmpeg so I don't know if there's a trick to making decoding consistent. Sadly it's not 100% consistent, but it's very easy to reproduce with those two games.
The text was updated successfully, but these errors were encountered: