pcsx2 icon indicating copy to clipboard operation
pcsx2 copied to clipboard

Dolby Digital/DTS passthrough-decoding

Open mirh opened this issue 11 years ago • 27 comments

I have been lately discussing about PCSX2 and its multichannel audio support.

It seems it's not produced in realtime in-game (besides perhaps some experiments with 4.0 DTS?).. though some FMVs used to be encoded with 5.1

Now, I know pro logic is supported, but that's not real surround. I read rama once said we were waiting for proper decoders. Then I read gigaherz claiming we cannot license any encoders... But.. wtf? Why would we need to re-encode audio?

We would just need passthrough (just in case the user was indeed using S/PDIF) and decoding, for everybody else Afaik FOSS decoders already exist for both standards.

Any idea?

mirh avatar Jan 16 '15 14:01 mirh

I'd say it will be difficult to pass the proper bitstream to decoders (hardware more so than software). The source (PCSX2) will never deliver a steady stream so some kind of buffering will be required. If that's given at the decoder side, then it could be done, I guess. Such a decoder would need to have a compatible license and someone needs to include and attach it to the SPU2-X output. SPU2-X itself would need additions to properly detect a bitstream and pass it to the decoder.

ramapcsx2 avatar Jan 16 '15 16:01 ramapcsx2

I quickly found liba52 for DD and libdca for DTS. Ideally then, AC3Filter/Spdifer should support both (including passthrough). I'm not so apt to really know which could be more or less suitable for PCSX2's needs though. They are all licensed with GPL. So green light on that :)

Meanwhile, I even found a nice explanation about the process -including hardware offloading- under linux (I'm sure gregory38 will like this)

EDIT: ffmpeg also supports AC3

mirh avatar Jan 16 '15 17:01 mirh

Be aware that GPL doesn't protect from patents. Liba52 and libdca seems fine but I don't know for ffmpeg.

I would personally prefer a nice and working implementation ;) Sound is already erratic enough on linux unfortunately...

gregory38 avatar Jan 24 '15 22:01 gregory38

I just posted as much as open-source stuff I could find. Liba52 and libdca would be already enough for pcsx2. Ffmpeg is just another option (we don't need dts-hd or dolby truehd after all).

Said this, I barely know the difference between pulseaudio and alsa.. so do what you believe it's better

mirh avatar Jan 25 '15 00:01 mirh

Some insights on SPU2 accuracy here.

mirh avatar Jun 18 '16 13:06 mirh

Unfortunately using libdca may still violate DTS patents. Not sure how this affects ffmpeg

Found on VideoLan's website:

"Provisional Warning: DTS Inc. claims that use of libdca software, to decode DTS compressed sound data on a DVD could violate DTS's patent rights. If you are unsure about the legality of using and distributing this code in your country, in particular in the USA, please consult your lawyer before downloading it."

MrCK1 avatar Jun 18 '16 15:06 MrCK1

Ever heard of patent trolling? It's no different than the mp3, or libdvdcss situation or h264 situation. And even DMCA safeguards interoperability (and we aren't talking about encoding).

Said this, it seems libdca is quite outdated compared to libdcadec (for as much as PS2 emu shouldn't need anything past core DTS). This in turns looks now totally merged in ffmpeg.

So.. if just @gigaherz had time :p (I know, I'm mentioning him too much today) EDIT: patents expired

mirh avatar Jun 18 '16 16:06 mirh

Doesn't matter -- I tried once, and failed epicly. My attempt not only failed to decode any audio, but it prevented all the dolby-enabled games I had from booting. I simply could not figure out the right bit rate that the spdif passthrough works at, or at least my attempts at doing so caused games to stop working. And either way, the data I managed to dump, was never accepted by the lib.

Also, I do have time, I just don't have the brainpower. working a full-time programming job leaves me braindead for the rest of the day. The only moments I have when I can think, are the weekends, and I don't really want to spend those in something like dolby. ;P

gigaherz avatar Jun 18 '16 17:06 gigaherz

Well, given you would now have a reference implementation to compare, it should be quite easier (prolly still not easy).

Said this, we know the story, it's all in the logs I posted on the forums :)

mirh avatar Jun 18 '16 17:06 mirh

Reference implementations? Where? Did I miss something?

gigaherz avatar Jun 18 '16 18:06 gigaherz

Not in the sense "specific to playstation 2", but as I said AC3 and DTS are pretty thoroughly documented standards. And I believe it's far easier to make stuff work, when you don't have to decrypt an audio compression algorithm too, among other things.

mirh avatar Jun 18 '16 20:06 mirh

Yeah I never attempted to -- I did use liba52 in my attempt, I just failed at being able to provide liba52 with any sort of meaningful bitstream. Maybe things have changed, but I'm not really interested in trying again. ;P

gigaherz avatar Jun 18 '16 20:06 gigaherz

https://github.com/kodi-adsp/adsp.freesurround

An open source implementation that seems to be useable outside of Kodi.

https://github.com/dolphin-emu/dolphin/blob/326d72728c0b4b47db4d36ba57ab3ba9984978a6/Externals/FreeSurround/include/FreeSurround/FreeSurroundDecoder.h

A reference to it in Dolphin

weirdbeardgame avatar Mar 04 '20 21:03 weirdbeardgame

For your information, I'm reworking DPLII on Dolphin, and it's not been easy (I made some changes and fixes to FreeSurround). https://github.com/Filoppi/dolphin/blob/audio-input-fixes/Externals/FreeSurround/include/FreeSurround/FreeSurroundDecoder.h The dolphin decoder was taken from https://hydrogenaud.io/index.php?topic=52235.0 but adsp.freesurround is based on the same source, though it's probably cleaner and better.

Filoppi avatar Dec 13 '20 21:12 Filoppi

I second FreeSurround, hands down It's miles better than any alternative I've tested, even compared to the PCSX2 decoder setup (Audio Expansion Mode=Surround + SPU2-X.ini [OUTPUT] DplDecodingLevel=0). In the meantime, there's EqualizerAPO/HeSuVi decoders that do an okay job, though. Here's some footage I recorded using them.

IMAGE ALT TEXT

IMAGE ALT TEXT

ThreeDeeJay avatar Oct 11 '21 00:10 ThreeDeeJay

It's been a while, and I know there's not a lot activity here, but since it's relevant, here's another, recent test: https://youtu.be/a5w-DzR0Xlg IMAGE ALT TEXT

Still hoping for a FreeSurround implementation 👀🤞

ThreeDeeJay avatar Feb 17 '23 04:02 ThreeDeeJay

Ok its owrking only in rpcs3 . I thought it works for pcsx2 also .

ISuckGood avatar Feb 21 '23 19:02 ISuckGood

@ISuckGood I think PS3 games use Dolby Digital/DTS, which output discrete 5.1 surround channels, as opposed to Dolby Pro-Logic II in PS2, where surround channels have to be extracted from a stereo signal. I read some PS2 games use Dolby Digital, but apparently PCSX2 doesn't support it at all.

ThreeDeeJay avatar Feb 22 '23 13:02 ThreeDeeJay

Any news?

MatiasMGz avatar Dec 28 '23 15:12 MatiasMGz

No

F0bes avatar Dec 28 '23 15:12 F0bes

@MMatiasMG please stop bumping issues, if there is anything to be seen, it's clearly visible.

stenzek avatar Dec 28 '23 15:12 stenzek

For those worried about patents. Patents only last 20 years.

seta-san avatar Feb 22 '24 09:02 seta-san

We are aware. I've brought the AC3/DTS patent situation up internally.

AFAIK it's still unknown how the bitstream is handled by the SPU. Someone would need to reverse that.

stenzek avatar Feb 22 '24 09:02 stenzek

But the Dolby Prologic II decoding has nothing to do with the bitstream, right? Have you guys also been discussing using the aforementioned FreeSurround implementation in PCSX2?

After all, I think, it's somewhat more important than having a couple of cutscenes in surround sound that happen to have AC3 or DTS encoding? Some NFS games (including the exclusive version of NFS:HP2) and others, like Star Ocean, would greatly benefit from decoded DPLII. Especially in the light of the fact that this specific decoder nowadays falls more and more into obscurity.

Zoomer1988 avatar Mar 03 '24 21:03 Zoomer1988

But the Dolby Prologic II decoding has nothing to do with the bitstream, right?

Right, the freesurround discussion was off topic to this issue in the first place, this issue is about decoding the digital formats.

Ziemas avatar Mar 03 '24 23:03 Ziemas

Yeah, fair enough. I've re-read the issue, and it's "Not a real surround" apparently.

It seems, though, that this is the only place, where DPLII is being actively and properly discussed at all with examples and the FreeSurround foobar DSP (the Dolphin implementation) is even mentioned.

Still, has nothing to do with digital stream decoding indeed. My bad, sorry.

Zoomer1988 avatar Mar 04 '24 08:03 Zoomer1988

Yeah, usually DPL decoding discussions were redirected here. And in defense of DPL, while I agree matrix-encoded surround in stereo is inferior to raw/discrete channels because of inherent quality loss, I don't think it's fair or even accurate to say it's "not real surround" given it's decoded properly, like it does now after this update: https://youtu.be/fWIUJqPfpNA (Just a heads up for anyone finding/watching this thread for DPL decoding. I'll refrain from discussing this here any further to let discussion focus on passthrough)

ThreeDeeJay avatar May 10 '24 09:05 ThreeDeeJay