Skip to content

cellDmuxPamf - #18218

Merged
elad335 merged 12 commits into
RPCS3:masterfrom
capriots:cellDmuxPamf
Mar 7, 2026
Merged

elad335 merged 12 commits into
RPCS3:masterfrom
capriots:cellDmuxPamf

Conversation

@capriots

Copy link
Copy Markdown
Contributor

In addition to the previous commits:

  • Fixed the PS3 memory management as discussed here cellDmuxPamf #18181
  • Fixed that the lv2 mutex and cond weren't destroyed in DmuxPamfContext::close
  • Enabled the tests since we now have gmock

Comment thread rpcs3/Emu/Cell/Modules/cellDmuxPamf.cpp Outdated
case state::initial:
{
// Search for the next pack start code or prog end code
std::span<const u8, PACK_SIZE> pack{ static_cast<const u8*>(nullptr), PACK_SIZE }; // This initial value is not used, can't be default constructed

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.

This is a UB, you will have to use another solution. (span range must be valid)
You can refer an uninitialized buffer from the stack for example.

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.

I actually had to fix a bit more here, streams can be smaller than 0x800 bytes. In dmux_pamf_base::set_stream, I used to assert that streams are a multiple of 0x800 bytes in size (PACK_SIZE), that's why I gave the span static extend

Comment thread rpcs3/Emu/Cell/Modules/cellDmuxPamf.cpp Outdated
if (pts_dts_flag < 0)
{
// The timestamps should be unsigned, but are sign-extended from s32 to u64 on LLE. They probably forgot about integer promotion
const s32 PTS_32_30 = read_from_ptr<u8>(current_pes_packet.begin() + 9) >> 1;

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.

read_from_ptr allow indexing using the second argument

Comment thread rpcs3/Emu/Cell/Modules/cellDmuxPamf.cpp Outdated
{
// The timestamps should be unsigned, but are sign-extended from s32 to u64 on LLE. They probably forgot about integer promotion
const s32 PTS_32_30 = read_from_ptr<u8>(current_pes_packet.begin() + 9) >> 1;
const s32 PTS_29_15 = read_from_ptr<be_t<u16>>(current_pes_packet.begin() + 10) >> 1;

@elad335 elad335 Feb 22, 2026 •

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.

At this point maybe you can use something like:
bf_t<be_t<u32>, 1, 15> so the shift can be more explicit also for the others.

Comment thread rpcs3/Emu/Cell/Modules/cellDmuxPamf.cpp Outdated

if (sys_mutex_lock(ppu, mutex, 0) != CELL_OK)
{
SEND_FATAL_ERR_AND_CONTINUE();

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.

The use of macros here is a bit excessive, you can raise a flag that you can check at the start of the loop, then use continue; so it would jump back to check it. (I approve the use of the second macro RETURN_ON_CPU_FLAG_AGAIN though)

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