Skip to content
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

Keep separate track of ffmpeg pos and decode pos #7635

Merged
merged 2 commits into from
Mar 27, 2015

Conversation

unknownbrackets
Copy link
Collaborator

FFmpeg buffers, so forcing the pos only makes FFmpeg read in garbage because it doesn't know that you seeked in the bytestream on it.

The code before was basically overwriting the seek pos after FFmpeg read it, and so when FFmpeg tried to continue reading, it ended up reading in a different place than it was aware of. The old method of force seeking all the time (which causes early packets to get scrambled or something, so isn't good) "worked around" this problem because it made FFmpeg resend the seek position each time.

This might fix problems of bad data that existed before, when FFmpeg didn't decide to send the seek pos or otherwise got confused by its seek position getting mistreated.

Fixes #7633 and Grand Theft Auto.

-[Unknown]

FFmpeg buffers, so forcing the pos only makes FFmpeg read in garbage
because it doesn't know that you seeked in the bytestream on it.
@daniel229
Copy link
Collaborator

Great,fixes #7633

@daniel229
Copy link
Collaborator

Urakata Hakuouki lose BGM,before was fine.

@daniel229
Copy link
Collaborator

Seems like there is a problem with atrac3 stereo/mono audio (low level)
Digimon Adventure and Grand Knights History lose music.

Since in this case we're tricking it into reading the same buffer area.
@unknownbrackets
Copy link
Collaborator Author

Okay, right, overriding the seek position is intentional for low level. Should work now.

Does Urakata Hakuouki also use low level audio, or what does it use?

-[Unknown]

@daniel229
Copy link
Collaborator

Yes,Urakata Hakuouki works now.

@daniel229
Copy link
Collaborator

Fixes the bgm in #6963 ,This is very old issue.

@daniel229
Copy link
Collaborator

Fixes silent bgm in Capcom Classics Collection Remixed

@DonelBueno
Copy link

So this PR basically fixes all the audio problems in games? Is there any game that will stil have audio problems after this PR?

@unknownbrackets
Copy link
Collaborator Author

Surely there are other games which have audio problems, many of the sceAtrac functions still behave incorrectly. This just fixes a number of issues. Progress is good.

-[Unknown]

@hrydgard
Copy link
Owner

Ah, this makes sense, good call!

hrydgard added a commit that referenced this pull request Mar 27, 2015
Keep separate track of ffmpeg pos and decode pos
@hrydgard hrydgard merged commit 0978500 into hrydgard:master Mar 27, 2015
@unknownbrackets unknownbrackets deleted the atrac-minor branch March 27, 2015 23:34
@daniel229
Copy link
Collaborator

The radio in GTA did not work sometime.

@unknownbrackets
Copy link
Collaborator Author

Hmm, did it always work before? Does it still give invalid data sometimes? I thought it did that before too.

-[Unknown]

@daniel229
Copy link
Collaborator

It seems always works before,not just the radio,the title bgm also got the following error sometimes.What invalid data? I don't see it.

58:25:764 mix sound th E[ME]: HLE\sceAtrac.cpp:422 avcodec_decode_audio4: Error decoding audio -1094995529 / bebbb1b7

@unknownbrackets
Copy link
Collaborator Author

bebbb1b7 is FFmpeg's code for "invalid data". It means the bytes in the atrac3 stream are wrong.

For example, it could mean we're telling the game to write data to the wrong place or anything. Somehow it's constructing a bad atrac3 stream.

-[Unknown]

@daniel229
Copy link
Collaborator

I see.
I found out how to reproduce the error in the title BGM.
Open ppsspp,load GTA game,reset the game(don't exit ppsspp),then get the error in title.
The radio problem seems different from the title BGM.

@unknownbrackets
Copy link
Collaborator Author

Does it happen if you save a state after resetting, quit PPSSPP, start again and load that state? Or also not then, and still requires the reset?

-[Unknown]

@daniel229
Copy link
Collaborator

save a state after resetting,quit or not quit,it got the error after loading the state.
save a state before resetting,quit or not quit,it won't get the error after loading the state.

@unknownbrackets
Copy link
Collaborator Author

Neat, let's compare the savestates.

In Common/ChunkFile.cpp, find this line:

bool compress = true;

And make it:

bool compress = false;

Then make both savestates again. This just makes it easier to compare them, since you'll be looking at raw data.

Then you can compare them. Here's a program to compare two binary files:
http://www.cjmweb.net/vbindiff/

Every section has a marker and the name near it, so the difference should be between two markers, which will tell us what data it is.

Really, a savestate before and after a reset should be identical EXCEPT for the rtc timestamp.

Or if you just want to upload the two savestates I can compare them, just thought you might be interested in trying it.

-[Unknown]

@daniel229
Copy link
Collaborator

ULJM05297_1.01_2 is before resetting

ULJM05297_1.01_3 is after resetting

savestate download
http://1drv.ms/1BClcwn

@daniel229
Copy link
Collaborator

Seems not so many different,I just pressing the ENTER,and then the red highlight thing disappear,I don't know what to find.
01

@unknownbrackets
Copy link
Collaborator Author

Hmm, it just says it can't scan for viruses and won't let me download.

You're looking for the red sections, and the text around the red sections. If you pass one, you can just hit q to start over.

-[Unknown]

@daniel229
Copy link
Collaborator

upload to git.(rename jpg to 7z)
ppsspp_state

@daniel229
Copy link
Collaborator

Just change the 00BA EB40 secsion,then it works like another savestate.
01

@unknownbrackets
Copy link
Collaborator Author

Hmm, that looks like PSP ram, I'm not sure why it's affected by reset. Does turning off jit and replacements affect it at all?

-[Unknown]

@daniel229
Copy link
Collaborator

Turning off jit and replacements is not affected.
On PSP,it would play back 2 difference songs randomly in that title.
On PPSSPP,it only play song a when without the error. When get the error,It skip song a and then 1 or seconds later play song b.
On old PPSSPP,It acts it like when get the error,and it just not report error,still do thing wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

List some games got "Error decoding audio" since #6976
4 participants