aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/video_core/host1x/codecs/vp8.cpp
diff options
context:
space:
mode:
authoryuzubot <[email protected]>2024-03-04 00:57:21 +0000
committeryuzubot <[email protected]>2024-03-04 00:57:21 +0000
commit276ceb26d0c58a00a0e65e3bf4d9c4371428f82d (patch)
tree587c6b5415501f1b1a1795ddd6df8d3403252cb4 /src/video_core/host1x/codecs/vp8.cpp
parent15e6e48bef0216480661444a8d8b348c1cca47bb (diff)
downloadyuzu-android-276ceb26d0c58a00a0e65e3bf4d9c4371428f82d.tar.gz
yuzu-android-276ceb26d0c58a00a0e65e3bf4d9c4371428f82d.zip
Merge yuzu-emu#12461
Diffstat (limited to 'src/video_core/host1x/codecs/vp8.cpp')
-rw-r--r--src/video_core/host1x/codecs/vp8.cpp73
1 files changed, 48 insertions, 25 deletions
diff --git a/src/video_core/host1x/codecs/vp8.cpp b/src/video_core/host1x/codecs/vp8.cpp
index be97e3b00..6094f16e0 100644
--- a/src/video_core/host1x/codecs/vp8.cpp
+++ b/src/video_core/host1x/codecs/vp8.cpp
@@ -7,47 +7,70 @@
#include "video_core/host1x/host1x.h"
#include "video_core/memory_manager.h"
-namespace Tegra::Decoder {
-VP8::VP8(Host1x::Host1x& host1x_) : host1x{host1x_} {}
+namespace Tegra::Decoders {
+VP8::VP8(Host1x::Host1x& host1x_, const Host1x::NvdecCommon::NvdecRegisters& regs_, s32 id_,
+ Host1x::FrameQueue& frame_queue_)
+ : Decoder{host1x_, id_, regs_, frame_queue_} {
+ codec = Host1x::NvdecCommon::VideoCodec::VP8;
+ initialized = decode_api.Initialize(codec);
+}
VP8::~VP8() = default;
-std::span<const u8> VP8::ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters& state) {
- VP8PictureInfo info;
- host1x.GMMU().ReadBlock(state.picture_info_offset, &info, sizeof(VP8PictureInfo));
+std::tuple<u64, u64> VP8::GetProgressiveOffsets() {
+ auto luma{regs.surface_luma_offsets[static_cast<u32>(Vp8SurfaceIndex::Current)].Address()};
+ auto chroma{regs.surface_chroma_offsets[static_cast<u32>(Vp8SurfaceIndex::Current)].Address()};
+ return {luma, chroma};
+}
+
+std::tuple<u64, u64, u64, u64> VP8::GetInterlacedOffsets() {
+ auto luma_top{regs.surface_luma_offsets[static_cast<u32>(Vp8SurfaceIndex::Current)].Address()};
+ auto luma_bottom{
+ regs.surface_luma_offsets[static_cast<u32>(Vp8SurfaceIndex::Current)].Address()};
+ auto chroma_top{
+ regs.surface_chroma_offsets[static_cast<u32>(Vp8SurfaceIndex::Current)].Address()};
+ auto chroma_bottom{
+ regs.surface_chroma_offsets[static_cast<u32>(Vp8SurfaceIndex::Current)].Address()};
+ return {luma_top, luma_bottom, chroma_top, chroma_bottom};
+}
+
+std::span<const u8> VP8::ComposeFrame() {
+ memory_manager.ReadBlock(regs.picture_info_offset.Address(), &current_context,
+ sizeof(VP8PictureInfo));
- const bool is_key_frame = info.key_frame == 1u;
- const auto bitstream_size = static_cast<size_t>(info.vld_buffer_size);
+ const bool is_key_frame = current_context.key_frame == 1u;
+ const auto bitstream_size = static_cast<size_t>(current_context.vld_buffer_size);
const size_t header_size = is_key_frame ? 10u : 3u;
- frame.resize(header_size + bitstream_size);
+ frame_scratch.resize(header_size + bitstream_size);
// Based on page 30 of the VP8 specification.
// https://datatracker.ietf.org/doc/rfc6386/
- frame[0] = is_key_frame ? 0u : 1u; // 1-bit frame type (0: keyframe, 1: interframes).
- frame[0] |= static_cast<u8>((info.version & 7u) << 1u); // 3-bit version number
- frame[0] |= static_cast<u8>(1u << 4u); // 1-bit show_frame flag
+ frame_scratch[0] = is_key_frame ? 0u : 1u; // 1-bit frame type (0: keyframe, 1: interframes).
+ frame_scratch[0] |=
+ static_cast<u8>((current_context.version & 7u) << 1u); // 3-bit version number
+ frame_scratch[0] |= static_cast<u8>(1u << 4u); // 1-bit show_frame flag
// The next 19-bits are the first partition size
- frame[0] |= static_cast<u8>((info.first_part_size & 7u) << 5u);
- frame[1] = static_cast<u8>((info.first_part_size & 0x7f8u) >> 3u);
- frame[2] = static_cast<u8>((info.first_part_size & 0x7f800u) >> 11u);
+ frame_scratch[0] |= static_cast<u8>((current_context.first_part_size & 7u) << 5u);
+ frame_scratch[1] = static_cast<u8>((current_context.first_part_size & 0x7f8u) >> 3u);
+ frame_scratch[2] = static_cast<u8>((current_context.first_part_size & 0x7f800u) >> 11u);
if (is_key_frame) {
- frame[3] = 0x9du;
- frame[4] = 0x01u;
- frame[5] = 0x2au;
+ frame_scratch[3] = 0x9du;
+ frame_scratch[4] = 0x01u;
+ frame_scratch[5] = 0x2au;
// TODO(ameerj): Horizontal/Vertical Scale
// 16 bits: (2 bits Horizontal Scale << 14) | Width (14 bits)
- frame[6] = static_cast<u8>(info.frame_width & 0xff);
- frame[7] = static_cast<u8>(((info.frame_width >> 8) & 0x3f));
+ frame_scratch[6] = static_cast<u8>(current_context.frame_width & 0xff);
+ frame_scratch[7] = static_cast<u8>(((current_context.frame_width >> 8) & 0x3f));
// 16 bits:(2 bits Vertical Scale << 14) | Height (14 bits)
- frame[8] = static_cast<u8>(info.frame_height & 0xff);
- frame[9] = static_cast<u8>(((info.frame_height >> 8) & 0x3f));
+ frame_scratch[8] = static_cast<u8>(current_context.frame_height & 0xff);
+ frame_scratch[9] = static_cast<u8>(((current_context.frame_height >> 8) & 0x3f));
}
- const u64 bitstream_offset = state.frame_bitstream_offset;
- host1x.GMMU().ReadBlock(bitstream_offset, frame.data() + header_size, bitstream_size);
+ const u64 bitstream_offset = regs.frame_bitstream_offset.Address();
+ memory_manager.ReadBlock(bitstream_offset, frame_scratch.data() + header_size, bitstream_size);
- return frame;
+ return frame_scratch;
}
-} // namespace Tegra::Decoder
+} // namespace Tegra::Decoders