Skip to content

cellAdec implementation part 2: LPCM decoder#16381

Merged
elad335 merged 7 commits intoRPCS3:masterfrom
capriots:cellAdec
Dec 18, 2024
Merged

cellAdec implementation part 2: LPCM decoder#16381
elad335 merged 7 commits intoRPCS3:masterfrom
capriots:cellAdec

Conversation

@capriots
Copy link
Copy Markdown
Contributor

@capriots capriots commented Dec 8, 2024

  • Implements the LPCM decoder part of cellAdec
  • The decoder takes 16/20/24-bit big-endian integer samples using either the Blu-ray (also used in PAMF files) or DVD-Video packing format (without the extra header you would usually find in those streams) and converts them to float samples
  • Fully vectorized
  • Produces identical output to LLE for valid parameters (like sample_num % channel_num == 0 , access_unit_size % sample_size == 0)
    • For invalid parameters, only the end of the output, where the samples are cut off, is different, depending on the memory contents
    • There is basically no checking of user inputs on LLE
  • Set cellAdec to HLE by default since it is fully implemented with this

Comment thread rpcs3/util/simd.hpp
Comment thread rpcs3/util/simd.hpp
Comment thread rpcs3/util/simd.hpp
Comment thread rpcs3/Emu/Cell/Modules/cellAdec.cpp Outdated
Comment thread rpcs3/Emu/Cell/Modules/cellAdec.cpp
Comment thread rpcs3/Emu/Cell/Modules/cellAdec.cpp Outdated
Comment thread rpcs3/util/v128.hpp Outdated

constexpr v128(const v128&) noexcept = default;

constexpr v128(const normal_array_t<u8>& _u8) noexcept : _u8(_u8){}
Copy link
Copy Markdown
Contributor

@elad335 elad335 Dec 8, 2024

Choose a reason for hiding this comment

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

You can use a template here, and do std::bit_cast<v128> for all masked_array_t

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.

Bit casting to union types isn't constexpr. But changing the existing constructor to this would work:

template <Vector128 T>
constexpr v128(const T& rhs) noexcept
	: _u(std::bit_cast<u128>(rhs))
{
}

However, it would technically be UB to access the vector through any member other than _u afterwards.
Or do you mean something different?

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.

I rather it not be constexpr than, for constexpr stuff you can do the trick with masked_array_t as you have done earlier.

Comment thread rpcs3/util/simd.hpp Outdated
inline v128 gv_loadfs(const void* ptr)
{
#if defined(ARCH_X64)
return _mm_load_ps(static_cast<const f32*>(ptr));
Copy link
Copy Markdown
Contributor

@elad335 elad335 Dec 9, 2024

Choose a reason for hiding this comment

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

There is no significant performance difference between them in modern CPUs, hence why MSVC doed not emit it. Nor should we as the risks outweigh the advantage.

Suggested change
return _mm_load_ps(static_cast<const f32*>(ptr));
return _mm_loadu_ps(static_cast<const f32*>(ptr));

Comment thread rpcs3/util/simd.hpp Outdated
inline v128 gv_load(const void* ptr)
{
#if defined(ARCH_X64)
return _mm_load_si128(static_cast<const __m128i*>(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.

Suggested change
return _mm_load_si128(static_cast<const __m128i*>(ptr));
return _mm_loadu_si128(static_cast<const __m128i*>(ptr));

@elad335 elad335 merged commit 9d4ff13 into RPCS3:master Dec 18, 2024
@capriots capriots deleted the cellAdec branch December 18, 2024 19:11
Xcedf pushed a commit to Xcedf/rpcs3 that referenced this pull request Jan 19, 2025
* cellAdec: savestate fixup

* simd.hpp: add some intrinsics

* cellAdec implementation part 2: LPCM decoder

* cellAdec: set to HLE by default

* cellAdec: review fixes

---------

Co-authored-by: Elad <18193363+elad335@users.noreply.github.com>
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