From b39b33b1fe1a396bb2f9841d48a1cb45cbfde806 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Fri, 12 Nov 2021 19:28:21 -0500 Subject: codecs: Add VP8 codec class --- src/video_core/command_classes/codecs/vp8.h | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/video_core/command_classes/codecs/vp8.h (limited to 'src/video_core/command_classes/codecs/vp8.h') diff --git a/src/video_core/command_classes/codecs/vp8.h b/src/video_core/command_classes/codecs/vp8.h new file mode 100644 index 000000000..70c75f414 --- /dev/null +++ b/src/video_core/command_classes/codecs/vp8.h @@ -0,0 +1,31 @@ +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include + +#include "common/common_types.h" +#include "video_core/command_classes/nvdec_common.h" + +namespace Tegra { +class GPU; +namespace Decoder { + +class VP8 { +public: + explicit VP8(GPU& gpu); + ~VP8(); + + /// Compose the VP8 header of the frame for FFmpeg decoding + [[nodiscard]] const std::vector& ComposeFrameHeader( + const NvdecCommon::NvdecRegisters& state, bool is_first_frame = false); + +private: + std::vector frame; + GPU& gpu; +}; + +} // namespace Decoder +} // namespace Tegra -- cgit v1.2.3 From d35391b9f43c5099b000940a83e795827cea35b8 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Fri, 12 Nov 2021 17:14:02 -0500 Subject: vp8: Implement header composition Enables frame decoding with FFmpeg --- src/video_core/command_classes/codecs/vp8.h | 46 ++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) (limited to 'src/video_core/command_classes/codecs/vp8.h') diff --git a/src/video_core/command_classes/codecs/vp8.h b/src/video_core/command_classes/codecs/vp8.h index 70c75f414..d71917596 100644 --- a/src/video_core/command_classes/codecs/vp8.h +++ b/src/video_core/command_classes/codecs/vp8.h @@ -4,8 +4,10 @@ #pragma once +#include #include +#include "common/common_funcs.h" #include "common/common_types.h" #include "video_core/command_classes/nvdec_common.h" @@ -20,11 +22,53 @@ public: /// Compose the VP8 header of the frame for FFmpeg decoding [[nodiscard]] const std::vector& ComposeFrameHeader( - const NvdecCommon::NvdecRegisters& state, bool is_first_frame = false); + const NvdecCommon::NvdecRegisters& state); private: std::vector frame; GPU& gpu; + + struct VP8PictureInfo { + INSERT_PADDING_WORDS_NOINIT(14); + u16 frame_width; // actual frame width + u16 frame_height; // actual frame height + u8 key_frame; + u8 version; + union { + u8 raw; + BitField<0, 2, u8> tile_format; + BitField<2, 3, u8> gob_height; + BitField<5, 3, u8> reserverd_surface_format; + }; + u8 error_conceal_on; // 1: error conceal on; 0: off + u32 first_part_size; // the size of first partition(frame header and mb header partition) + u32 hist_buffer_size; // in units of 256 + u32 vld_buffer_size; // in units of 1 + // Current frame buffers + std::array frame_stride; // [y_c] + u32 luma_top_offset; // offset of luma top field in units of 256 + u32 luma_bot_offset; // offset of luma bottom field in units of 256 + u32 luma_frame_offset; // offset of luma frame in units of 256 + u32 chroma_top_offset; // offset of chroma top field in units of 256 + u32 chroma_bot_offset; // offset of chroma bottom field in units of 256 + u32 chroma_frame_offset; // offset of chroma frame in units of 256 + + INSERT_PADDING_BYTES_NOINIT(0x1c); // NvdecDisplayParams + + // Decode picture buffer related + s8 current_output_memory_layout; + // output NV12/NV24 setting. index 0: golden; 1: altref; 2: last + std::array output_memory_layout; + + u8 segmentation_feature_data_update; + INSERT_PADDING_BYTES_NOINIT(3); + + // ucode return result + u32 result_value; + std::array partition_offset; + INSERT_PADDING_WORDS_NOINIT(3); + }; + static_assert(sizeof(VP8PictureInfo) == 0xc0, "PictureInfo is an invalid size"); }; } // namespace Decoder -- cgit v1.2.3 From c50f17059730dc0566e1355fead9ac00d3b60e02 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Fri, 12 Nov 2021 19:52:51 -0500 Subject: codes: Rename ComposeFrameHeader to ComposeFrame These functions were composing the entire frame, not just the headers. Rename to more accurately describe them. --- src/video_core/command_classes/codecs/vp8.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/video_core/command_classes/codecs/vp8.h') diff --git a/src/video_core/command_classes/codecs/vp8.h b/src/video_core/command_classes/codecs/vp8.h index d71917596..41fc7b403 100644 --- a/src/video_core/command_classes/codecs/vp8.h +++ b/src/video_core/command_classes/codecs/vp8.h @@ -20,9 +20,8 @@ public: explicit VP8(GPU& gpu); ~VP8(); - /// Compose the VP8 header of the frame for FFmpeg decoding - [[nodiscard]] const std::vector& ComposeFrameHeader( - const NvdecCommon::NvdecRegisters& state); + /// Compose the VP8 frame for FFmpeg decoding + [[nodiscard]] const std::vector& ComposeFrame(const NvdecCommon::NvdecRegisters& state); private: std::vector frame; -- cgit v1.2.3