Skip to content

cellAdec implementation part 1: abstraction layer#16332

Merged
elad335 merged 7 commits intoRPCS3:masterfrom
capriots:cellAdec
Nov 23, 2024
Merged

cellAdec implementation part 1: abstraction layer#16332
elad335 merged 7 commits intoRPCS3:masterfrom
capriots:cellAdec

Conversation

@capriots
Copy link
Copy Markdown
Contributor

  • Implements the abstraction layer part of cellAdec (cellAdec also contains an LPCM int -> float converter)
  • Stubbed the exports of all the decoders to be able to access the LLE functions and variables
    • I defined the exports of all the decoders inside cellAdec.cpp for now. I didn't want to create new cpp files yet just for the stubs since a lot of the decoders seem very similar and can probably combined.
  • Also fixes stack arguments in PPUCallback.h

Here's my Ghidra program data export if anyone wants to look at the decompilation:
libadec.prx.xml.zip

[[noreturn]] error_code _SceAdecCorrectPtsValue_truehd(ppu_thread&, vm::ptr<void>, vm::ptr<CellCodecTimeStamp>){ fmt::throw_exception("Unreachable"); }
[[noreturn]] error_code _SceAdecCorrectPtsValue_wma(ppu_thread&, vm::ptr<void>, vm::ptr<CellCodecTimeStamp>){ fmt::throw_exception("Unreachable"); }
[[noreturn]] error_code _SceAdecCorrectPtsValue_WmaLsl(ppu_thread&, vm::ptr<void>, vm::ptr<CellCodecTimeStamp>){ fmt::throw_exception("Unreachable"); }
[[noreturn]] error_code _SceAdecCorrectPtsValue_WmaPro(ppu_thread&, vm::ptr<void>, vm::ptr<CellCodecTimeStamp>){ fmt::throw_exception("Unreachable"); }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it unreachable?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions are only called within the adecNotifyPcmOut() callback, which is called by the decoders, not the user. Since none of these decoders are implemented, we won't ever receive the callback.

Copy link
Copy Markdown
Contributor

@elad335 elad335 Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had refrrain from putting noreturn attribute on any guest function, you should replace it with UNIMPLEMENTED_FUNC(cellAdec);
It's technically reachable using imports.

{
AdecTask task;
if (!adec.job.peek(task, 0, &adec.is_closed))
case ADEC_CORRECT_PTS_VALUE_TYPE_EAC3: if (ppu_execute<&_SceAdecCorrectPtsValue_Ddp>(ppu, +core_handle, au_pts) != CELL_OK) { return CELL_ADEC_ERROR_FATAL; } else { return CELL_OK; }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't put it on the same line, also there are so many you may want to use a macro

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better now?

const be_t<u32> bitstream_info_size;

u64 mutex_attribute[5]{}; // sys_mutex_attribute_t
shared_mutex mutex; // sys_mutex_t
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use this type on PS3 structures, you can make it an index to some shared_index array or something

@elad335
Copy link
Copy Markdown
Contributor

elad335 commented Nov 22, 2024

You need to invalidate savestate version globally because of the additions of vm::gvar and modules, its in savestate_utls.cpp

vm::bcptr<CellAdecCoreOps> core_ops, s32 frames_num, vm::bptr<AdecFrame> frames, u32 bitstream_info_size, u32 bitstream_infos_addr)
: _this(_this), this_size(this_size), type(type), res(res), callback(callback), core_handle(core_handle), core_ops(core_ops), frames_num(frames_num), frames(frames), bitstream_info_size(bitstream_info_size)
{
ensure(this == _this.get_ptr());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to keep PS3 structures trivial (as std::is_trivial), you can make the constructor a static function instead.


for (s32 i = 0; i < pcm_handle_num; i++)
{
new (&frames[i]) AdecFrame(i, bitstream_infos_addr + bitstream_info_size * i);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, avoid using non-default constructor

@capriots
Copy link
Copy Markdown
Contributor Author

You need to invalidate savestate version globally because of the additions of vm::gvar and modules, its in savestate_utls.cpp

I'll need a new gvar + module for cellDmuxPamf as well, do you want me to add those in this PR so I won't have to invalidate savestates again?

@elad335
Copy link
Copy Markdown
Contributor

elad335 commented Nov 23, 2024

You need to invalidate savestate version globally because of the additions of vm::gvar and modules, its in savestate_utls.cpp

I'll need a new gvar + module for cellDmuxPamf as well, do you want me to add those in this PR so I won't have to invalidate savestates again?

Yes 👍

@elad335 elad335 merged commit e7fd422 into RPCS3:master Nov 23, 2024
@capriots capriots deleted the cellAdec branch November 23, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants