summaryrefslogtreecommitdiffstats
path: root/src/video_core/command_classes/codecs/vp8.cpp
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-11-12 23:14:02 +0100
committerameerj <52414509+ameerj@users.noreply.github.com>2021-11-13 05:52:18 +0100
commitd35391b9f43c5099b000940a83e795827cea35b8 (patch)
tree046b1ee7b8ea4b3f6b3e3d2194d9ea948bd835bd /src/video_core/command_classes/codecs/vp8.cpp
parentcodecs: Add VP8 codec class (diff)
downloadyuzu-d35391b9f43c5099b000940a83e795827cea35b8.tar
yuzu-d35391b9f43c5099b000940a83e795827cea35b8.tar.gz
yuzu-d35391b9f43c5099b000940a83e795827cea35b8.tar.bz2
yuzu-d35391b9f43c5099b000940a83e795827cea35b8.tar.lz
yuzu-d35391b9f43c5099b000940a83e795827cea35b8.tar.xz
yuzu-d35391b9f43c5099b000940a83e795827cea35b8.tar.zst
yuzu-d35391b9f43c5099b000940a83e795827cea35b8.zip
Diffstat (limited to '')
-rw-r--r--src/video_core/command_classes/codecs/vp8.cpp41
1 files changed, 38 insertions, 3 deletions
diff --git a/src/video_core/command_classes/codecs/vp8.cpp b/src/video_core/command_classes/codecs/vp8.cpp
index 976e9f9b7..3ee269948 100644
--- a/src/video_core/command_classes/codecs/vp8.cpp
+++ b/src/video_core/command_classes/codecs/vp8.cpp
@@ -6,15 +6,50 @@
#include <vector>
#include "video_core/command_classes/codecs/vp8.h"
+#include "video_core/gpu.h"
+#include "video_core/memory_manager.h"
namespace Tegra::Decoder {
VP8::VP8(GPU& gpu_) : gpu(gpu_) {}
VP8::~VP8() = default;
-const std::vector<u8>& VP8::ComposeFrameHeader(const NvdecCommon::NvdecRegisters& state,
- bool is_first_frame) {
- return {};
+const std::vector<u8>& VP8::ComposeFrameHeader(const NvdecCommon::NvdecRegisters& state) {
+ VP8PictureInfo info;
+ gpu.MemoryManager().ReadBlock(state.picture_info_offset, &info, sizeof(VP8PictureInfo));
+
+ const bool is_key_frame = info.key_frame == 1u;
+ const auto bitstream_size = static_cast<size_t>(info.vld_buffer_size);
+ const size_t header_size = is_key_frame ? 10u : 3u;
+ frame.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
+
+ // 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);
+
+ if (is_key_frame) {
+ frame[3] = 0x9du;
+ frame[4] = 0x01u;
+ frame[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));
+ // 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));
+ }
+ const u64 bitstream_offset = state.frame_bitstream_offset;
+ gpu.MemoryManager().ReadBlock(bitstream_offset, frame.data() + header_size, bitstream_size);
+
+ return frame;
}
} // namespace Tegra::Decoder