diff options
| -rw-r--r-- | src/video_core/command_classes/codecs/codec.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/command_classes/codecs/codec.h | 2 | ||||
| -rw-r--r-- | src/video_core/command_classes/codecs/h264.cpp | 28 | ||||
| -rw-r--r-- | src/video_core/command_classes/codecs/h264.h | 14 | ||||
| -rw-r--r-- | src/video_core/command_classes/codecs/vp9.cpp | 64 | ||||
| -rw-r--r-- | src/video_core/command_classes/codecs/vp9.h | 32 | ||||
| -rw-r--r-- | src/video_core/command_classes/codecs/vp9_types.h | 6 | ||||
| -rw-r--r-- | src/video_core/command_classes/host1x.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/command_classes/host1x.h | 2 | ||||
| -rw-r--r-- | src/video_core/command_classes/nvdec.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/command_classes/nvdec.h | 6 | ||||
| -rw-r--r-- | src/video_core/command_classes/vic.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/command_classes/vic.h | 4 |
13 files changed, 81 insertions, 88 deletions
diff --git a/src/video_core/command_classes/codecs/codec.cpp b/src/video_core/command_classes/codecs/codec.cpp index 2df410be8..1adf3cd13 100644 --- a/src/video_core/command_classes/codecs/codec.cpp +++ b/src/video_core/command_classes/codecs/codec.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #include <cstring> | 5 | #include <cstring> |
| 6 | #include <fstream> | 6 | #include <fstream> |
| 7 | #include <vector> | ||
| 7 | #include "common/assert.h" | 8 | #include "common/assert.h" |
| 8 | #include "video_core/command_classes/codecs/codec.h" | 9 | #include "video_core/command_classes/codecs/codec.h" |
| 9 | #include "video_core/command_classes/codecs/h264.h" | 10 | #include "video_core/command_classes/codecs/h264.h" |
diff --git a/src/video_core/command_classes/codecs/codec.h b/src/video_core/command_classes/codecs/codec.h index 2e56daf29..cb67094f6 100644 --- a/src/video_core/command_classes/codecs/codec.h +++ b/src/video_core/command_classes/codecs/codec.h | |||
| @@ -5,8 +5,6 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <vector> | ||
| 9 | #include "common/common_funcs.h" | ||
| 10 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 11 | #include "video_core/command_classes/nvdec_common.h" | 9 | #include "video_core/command_classes/nvdec_common.h" |
| 12 | 10 | ||
diff --git a/src/video_core/command_classes/codecs/h264.cpp b/src/video_core/command_classes/codecs/h264.cpp index 1a39f7b23..549a40f52 100644 --- a/src/video_core/command_classes/codecs/h264.cpp +++ b/src/video_core/command_classes/codecs/h264.cpp | |||
| @@ -18,12 +18,27 @@ | |||
| 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 19 | // | 19 | // |
| 20 | 20 | ||
| 21 | #include <array> | ||
| 21 | #include "common/bit_util.h" | 22 | #include "common/bit_util.h" |
| 22 | #include "video_core/command_classes/codecs/h264.h" | 23 | #include "video_core/command_classes/codecs/h264.h" |
| 23 | #include "video_core/gpu.h" | 24 | #include "video_core/gpu.h" |
| 24 | #include "video_core/memory_manager.h" | 25 | #include "video_core/memory_manager.h" |
| 25 | 26 | ||
| 26 | namespace Tegra::Decoder { | 27 | namespace Tegra::Decoder { |
| 28 | namespace { | ||
| 29 | // ZigZag LUTs from libavcodec. | ||
| 30 | constexpr std::array<u8, 64> zig_zag_direct{ | ||
| 31 | 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, | ||
| 32 | 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, | ||
| 33 | 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63, | ||
| 34 | }; | ||
| 35 | |||
| 36 | constexpr std::array<u8, 16> zig_zag_scan{ | ||
| 37 | 0 + 0 * 4, 1 + 0 * 4, 0 + 1 * 4, 0 + 2 * 4, 1 + 1 * 4, 2 + 0 * 4, 3 + 0 * 4, 2 + 1 * 4, | ||
| 38 | 1 + 2 * 4, 0 + 3 * 4, 1 + 3 * 4, 2 + 2 * 4, 3 + 1 * 4, 3 + 2 * 4, 2 + 3 * 4, 3 + 3 * 4, | ||
| 39 | }; | ||
| 40 | } // Anonymous namespace | ||
| 41 | |||
| 27 | H264::H264(GPU& gpu_) : gpu(gpu_) {} | 42 | H264::H264(GPU& gpu_) : gpu(gpu_) {} |
| 28 | 43 | ||
| 29 | H264::~H264() = default; | 44 | H264::~H264() = default; |
| @@ -48,7 +63,8 @@ std::vector<u8>& H264::ComposeFrameHeader(NvdecCommon::NvdecRegisters& state, bo | |||
| 48 | writer.WriteU(0, 8); | 63 | writer.WriteU(0, 8); |
| 49 | writer.WriteU(31, 8); | 64 | writer.WriteU(31, 8); |
| 50 | writer.WriteUe(0); | 65 | writer.WriteUe(0); |
| 51 | const s32 chroma_format_idc = (context.h264_parameter_set.flags >> 12) & 0x3; | 66 | const auto chroma_format_idc = |
| 67 | static_cast<u32>((context.h264_parameter_set.flags >> 12) & 3); | ||
| 52 | writer.WriteUe(chroma_format_idc); | 68 | writer.WriteUe(chroma_format_idc); |
| 53 | if (chroma_format_idc == 3) { | 69 | if (chroma_format_idc == 3) { |
| 54 | writer.WriteBit(false); | 70 | writer.WriteBit(false); |
| @@ -59,8 +75,8 @@ std::vector<u8>& H264::ComposeFrameHeader(NvdecCommon::NvdecRegisters& state, bo | |||
| 59 | writer.WriteBit(false); // QpprimeYZeroTransformBypassFlag | 75 | writer.WriteBit(false); // QpprimeYZeroTransformBypassFlag |
| 60 | writer.WriteBit(false); // Scaling matrix present flag | 76 | writer.WriteBit(false); // Scaling matrix present flag |
| 61 | 77 | ||
| 62 | const s32 order_cnt_type = static_cast<s32>((context.h264_parameter_set.flags >> 14) & 3); | 78 | const auto order_cnt_type = static_cast<u32>((context.h264_parameter_set.flags >> 14) & 3); |
| 63 | writer.WriteUe(static_cast<s32>((context.h264_parameter_set.flags >> 8) & 0xf)); | 79 | writer.WriteUe(static_cast<u32>((context.h264_parameter_set.flags >> 8) & 0xf)); |
| 64 | writer.WriteUe(order_cnt_type); | 80 | writer.WriteUe(order_cnt_type); |
| 65 | if (order_cnt_type == 0) { | 81 | if (order_cnt_type == 0) { |
| 66 | writer.WriteUe(context.h264_parameter_set.log2_max_pic_order_cnt); | 82 | writer.WriteUe(context.h264_parameter_set.log2_max_pic_order_cnt); |
| @@ -100,7 +116,7 @@ std::vector<u8>& H264::ComposeFrameHeader(NvdecCommon::NvdecRegisters& state, bo | |||
| 100 | writer.WriteUe(0); | 116 | writer.WriteUe(0); |
| 101 | writer.WriteUe(0); | 117 | writer.WriteUe(0); |
| 102 | 118 | ||
| 103 | writer.WriteBit(context.h264_parameter_set.entropy_coding_mode_flag); | 119 | writer.WriteBit(context.h264_parameter_set.entropy_coding_mode_flag != 0); |
| 104 | writer.WriteBit(false); | 120 | writer.WriteBit(false); |
| 105 | writer.WriteUe(0); | 121 | writer.WriteUe(0); |
| 106 | writer.WriteUe(context.h264_parameter_set.num_refidx_l0_default_active); | 122 | writer.WriteUe(context.h264_parameter_set.num_refidx_l0_default_active); |
| @@ -172,8 +188,8 @@ void H264BitWriter::WriteSe(s32 value) { | |||
| 172 | WriteExpGolombCodedInt(value); | 188 | WriteExpGolombCodedInt(value); |
| 173 | } | 189 | } |
| 174 | 190 | ||
| 175 | void H264BitWriter::WriteUe(s32 value) { | 191 | void H264BitWriter::WriteUe(u32 value) { |
| 176 | WriteExpGolombCodedUInt((u32)value); | 192 | WriteExpGolombCodedUInt(value); |
| 177 | } | 193 | } |
| 178 | 194 | ||
| 179 | void H264BitWriter::End() { | 195 | void H264BitWriter::End() { |
diff --git a/src/video_core/command_classes/codecs/h264.h b/src/video_core/command_classes/codecs/h264.h index 21752dd90..f2292fd2f 100644 --- a/src/video_core/command_classes/codecs/h264.h +++ b/src/video_core/command_classes/codecs/h264.h | |||
| @@ -38,7 +38,7 @@ public: | |||
| 38 | /// WriteSe and WriteUe write in the Exp-Golomb-coded syntax | 38 | /// WriteSe and WriteUe write in the Exp-Golomb-coded syntax |
| 39 | void WriteU(s32 value, s32 value_sz); | 39 | void WriteU(s32 value, s32 value_sz); |
| 40 | void WriteSe(s32 value); | 40 | void WriteSe(s32 value); |
| 41 | void WriteUe(s32 value); | 41 | void WriteUe(u32 value); |
| 42 | 42 | ||
| 43 | /// Finalize the bitstream | 43 | /// Finalize the bitstream |
| 44 | void End(); | 44 | void End(); |
| @@ -55,18 +55,6 @@ public: | |||
| 55 | const std::vector<u8>& GetByteArray() const; | 55 | const std::vector<u8>& GetByteArray() const; |
| 56 | 56 | ||
| 57 | private: | 57 | private: |
| 58 | // ZigZag LUTs from libavcodec. | ||
| 59 | static constexpr std::array<u8, 64> zig_zag_direct{ | ||
| 60 | 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, | ||
| 61 | 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, | ||
| 62 | 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63, | ||
| 63 | }; | ||
| 64 | |||
| 65 | static constexpr std::array<u8, 16> zig_zag_scan{ | ||
| 66 | 0 + 0 * 4, 1 + 0 * 4, 0 + 1 * 4, 0 + 2 * 4, 1 + 1 * 4, 2 + 0 * 4, 3 + 0 * 4, 2 + 1 * 4, | ||
| 67 | 1 + 2 * 4, 0 + 3 * 4, 1 + 3 * 4, 2 + 2 * 4, 3 + 1 * 4, 3 + 2 * 4, 2 + 3 * 4, 3 + 3 * 4, | ||
| 68 | }; | ||
| 69 | |||
| 70 | void WriteBits(s32 value, s32 bit_count); | 58 | void WriteBits(s32 value, s32 bit_count); |
| 71 | void WriteExpGolombCodedInt(s32 value); | 59 | void WriteExpGolombCodedInt(s32 value); |
| 72 | void WriteExpGolombCodedUInt(u32 value); | 60 | void WriteExpGolombCodedUInt(u32 value); |
diff --git a/src/video_core/command_classes/codecs/vp9.cpp b/src/video_core/command_classes/codecs/vp9.cpp index d205a8f5d..b3e98aa9f 100644 --- a/src/video_core/command_classes/codecs/vp9.cpp +++ b/src/video_core/command_classes/codecs/vp9.cpp | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include "video_core/memory_manager.h" | 9 | #include "video_core/memory_manager.h" |
| 10 | 10 | ||
| 11 | namespace Tegra::Decoder { | 11 | namespace Tegra::Decoder { |
| 12 | 12 | namespace { | |
| 13 | // Default compressed header probabilities once frame context resets | 13 | // Default compressed header probabilities once frame context resets |
| 14 | constexpr Vp9EntropyProbs default_probs{ | 14 | constexpr Vp9EntropyProbs default_probs{ |
| 15 | .y_mode_prob{ | 15 | .y_mode_prob{ |
| @@ -170,6 +170,35 @@ constexpr Vp9EntropyProbs default_probs{ | |||
| 170 | .high_precision{128, 128}, | 170 | .high_precision{128, 128}, |
| 171 | }; | 171 | }; |
| 172 | 172 | ||
| 173 | constexpr std::array<s32, 256> norm_lut{ | ||
| 174 | 0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, | ||
| 175 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 176 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 177 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 178 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 179 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 180 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 181 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 182 | }; | ||
| 183 | |||
| 184 | constexpr std::array<s32, 254> map_lut{ | ||
| 185 | 20, 21, 22, 23, 24, 25, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, | ||
| 186 | 1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 2, 50, 51, 52, 53, 54, | ||
| 187 | 55, 56, 57, 58, 59, 60, 61, 3, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, | ||
| 188 | 73, 4, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 5, 86, 87, 88, 89, | ||
| 189 | 90, 91, 92, 93, 94, 95, 96, 97, 6, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, | ||
| 190 | 108, 109, 7, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 8, 122, 123, 124, | ||
| 191 | 125, 126, 127, 128, 129, 130, 131, 132, 133, 9, 134, 135, 136, 137, 138, 139, 140, 141, 142, | ||
| 192 | 143, 144, 145, 10, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 11, 158, 159, | ||
| 193 | 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 12, 170, 171, 172, 173, 174, 175, 176, 177, | ||
| 194 | 178, 179, 180, 181, 13, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 14, 194, | ||
| 195 | 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 15, 206, 207, 208, 209, 210, 211, 212, | ||
| 196 | 213, 214, 215, 216, 217, 16, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 17, | ||
| 197 | 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 18, 242, 243, 244, 245, 246, 247, | ||
| 198 | 248, 249, 250, 251, 252, 253, 19, | ||
| 199 | }; | ||
| 200 | } // Anonymous namespace | ||
| 201 | |||
| 173 | VP9::VP9(GPU& gpu) : gpu(gpu) {} | 202 | VP9::VP9(GPU& gpu) : gpu(gpu) {} |
| 174 | 203 | ||
| 175 | VP9::~VP9() = default; | 204 | VP9::~VP9() = default; |
| @@ -379,14 +408,14 @@ Vp9FrameContainer VP9::GetCurrentFrame(const NvdecCommon::NvdecRegisters& state) | |||
| 379 | Vp9FrameContainer frame{}; | 408 | Vp9FrameContainer frame{}; |
| 380 | { | 409 | { |
| 381 | gpu.SyncGuestHost(); | 410 | gpu.SyncGuestHost(); |
| 382 | frame.info = std::move(GetVp9PictureInfo(state)); | 411 | frame.info = GetVp9PictureInfo(state); |
| 383 | 412 | ||
| 384 | frame.bit_stream.resize(frame.info.bitstream_size); | 413 | frame.bit_stream.resize(frame.info.bitstream_size); |
| 385 | gpu.MemoryManager().ReadBlock(state.frame_bitstream_offset, frame.bit_stream.data(), | 414 | gpu.MemoryManager().ReadBlock(state.frame_bitstream_offset, frame.bit_stream.data(), |
| 386 | frame.info.bitstream_size); | 415 | frame.info.bitstream_size); |
| 387 | } | 416 | } |
| 388 | // Buffer two frames, saving the last show frame info | 417 | // Buffer two frames, saving the last show frame info |
| 389 | if (next_next_frame.bit_stream.size() != 0) { | 418 | if (!next_next_frame.bit_stream.empty()) { |
| 390 | Vp9FrameContainer temp{ | 419 | Vp9FrameContainer temp{ |
| 391 | .info = frame.info, | 420 | .info = frame.info, |
| 392 | .bit_stream = frame.bit_stream, | 421 | .bit_stream = frame.bit_stream, |
| @@ -396,15 +425,15 @@ Vp9FrameContainer VP9::GetCurrentFrame(const NvdecCommon::NvdecRegisters& state) | |||
| 396 | frame.bit_stream = next_next_frame.bit_stream; | 425 | frame.bit_stream = next_next_frame.bit_stream; |
| 397 | next_next_frame = std::move(temp); | 426 | next_next_frame = std::move(temp); |
| 398 | 427 | ||
| 399 | if (next_frame.bit_stream.size() != 0) { | 428 | if (!next_frame.bit_stream.empty()) { |
| 400 | Vp9FrameContainer temp{ | 429 | Vp9FrameContainer temp2{ |
| 401 | .info = frame.info, | 430 | .info = frame.info, |
| 402 | .bit_stream = frame.bit_stream, | 431 | .bit_stream = frame.bit_stream, |
| 403 | }; | 432 | }; |
| 404 | next_frame.info.show_frame = frame.info.last_frame_shown; | 433 | next_frame.info.show_frame = frame.info.last_frame_shown; |
| 405 | frame.info = next_frame.info; | 434 | frame.info = next_frame.info; |
| 406 | frame.bit_stream = next_frame.bit_stream; | 435 | frame.bit_stream = next_frame.bit_stream; |
| 407 | next_frame = std::move(temp); | 436 | next_frame = std::move(temp2); |
| 408 | } else { | 437 | } else { |
| 409 | next_frame.info = frame.info; | 438 | next_frame.info = frame.info; |
| 410 | next_frame.bit_stream = frame.bit_stream; | 439 | next_frame.bit_stream = frame.bit_stream; |
| @@ -605,12 +634,6 @@ std::vector<u8> VP9::ComposeCompressedHeader() { | |||
| 605 | 634 | ||
| 606 | writer.End(); | 635 | writer.End(); |
| 607 | return writer.GetBuffer(); | 636 | return writer.GetBuffer(); |
| 608 | |||
| 609 | const auto writer_bytearray = writer.GetBuffer(); | ||
| 610 | |||
| 611 | std::vector<u8> compressed_header(writer_bytearray.size()); | ||
| 612 | std::memcpy(compressed_header.data(), writer_bytearray.data(), writer_bytearray.size()); | ||
| 613 | return compressed_header; | ||
| 614 | } | 637 | } |
| 615 | 638 | ||
| 616 | VpxBitStreamWriter VP9::ComposeUncompressedHeader() { | 639 | VpxBitStreamWriter VP9::ComposeUncompressedHeader() { |
| @@ -648,7 +671,6 @@ VpxBitStreamWriter VP9::ComposeUncompressedHeader() { | |||
| 648 | current_frame_info.intra_only = true; | 671 | current_frame_info.intra_only = true; |
| 649 | 672 | ||
| 650 | } else { | 673 | } else { |
| 651 | std::array<s32, 3> ref_frame_index; | ||
| 652 | 674 | ||
| 653 | if (!current_frame_info.show_frame) { | 675 | if (!current_frame_info.show_frame) { |
| 654 | uncomp_writer.WriteBit(current_frame_info.intra_only); | 676 | uncomp_writer.WriteBit(current_frame_info.intra_only); |
| @@ -663,9 +685,9 @@ VpxBitStreamWriter VP9::ComposeUncompressedHeader() { | |||
| 663 | } | 685 | } |
| 664 | 686 | ||
| 665 | // Last, Golden, Altref frames | 687 | // Last, Golden, Altref frames |
| 666 | ref_frame_index = std::array<s32, 3>{0, 1, 2}; | 688 | std::array<s32, 3> ref_frame_index{0, 1, 2}; |
| 667 | 689 | ||
| 668 | // set when next frame is hidden | 690 | // Set when next frame is hidden |
| 669 | // altref and golden references are swapped | 691 | // altref and golden references are swapped |
| 670 | if (swap_next_golden) { | 692 | if (swap_next_golden) { |
| 671 | ref_frame_index = std::array<s32, 3>{0, 2, 1}; | 693 | ref_frame_index = std::array<s32, 3>{0, 2, 1}; |
| @@ -754,17 +776,19 @@ VpxBitStreamWriter VP9::ComposeUncompressedHeader() { | |||
| 754 | for (std::size_t index = 0; index < current_frame_info.ref_deltas.size(); index++) { | 776 | for (std::size_t index = 0; index < current_frame_info.ref_deltas.size(); index++) { |
| 755 | const s8 old_deltas = loop_filter_ref_deltas[index]; | 777 | const s8 old_deltas = loop_filter_ref_deltas[index]; |
| 756 | const s8 new_deltas = current_frame_info.ref_deltas[index]; | 778 | const s8 new_deltas = current_frame_info.ref_deltas[index]; |
| 779 | const bool differing_delta = old_deltas != new_deltas; | ||
| 757 | 780 | ||
| 758 | loop_filter_delta_update |= | 781 | update_loop_filter_ref_deltas[index] = differing_delta; |
| 759 | (update_loop_filter_ref_deltas[index] = old_deltas != new_deltas); | 782 | loop_filter_delta_update |= differing_delta; |
| 760 | } | 783 | } |
| 761 | 784 | ||
| 762 | for (std::size_t index = 0; index < current_frame_info.mode_deltas.size(); index++) { | 785 | for (std::size_t index = 0; index < current_frame_info.mode_deltas.size(); index++) { |
| 763 | const s8 old_deltas = loop_filter_mode_deltas[index]; | 786 | const s8 old_deltas = loop_filter_mode_deltas[index]; |
| 764 | const s8 new_deltas = current_frame_info.mode_deltas[index]; | 787 | const s8 new_deltas = current_frame_info.mode_deltas[index]; |
| 788 | const bool differing_delta = old_deltas != new_deltas; | ||
| 765 | 789 | ||
| 766 | loop_filter_delta_update |= | 790 | update_loop_filter_mode_deltas[index] = differing_delta; |
| 767 | (update_loop_filter_mode_deltas[index] = old_deltas != new_deltas); | 791 | loop_filter_delta_update |= differing_delta; |
| 768 | } | 792 | } |
| 769 | 793 | ||
| 770 | uncomp_writer.WriteBit(loop_filter_delta_update); | 794 | uncomp_writer.WriteBit(loop_filter_delta_update); |
| @@ -829,7 +853,7 @@ std::vector<u8>& VP9::ComposeFrameHeader(NvdecCommon::NvdecRegisters& state) { | |||
| 829 | { | 853 | { |
| 830 | Vp9FrameContainer curr_frame = GetCurrentFrame(state); | 854 | Vp9FrameContainer curr_frame = GetCurrentFrame(state); |
| 831 | current_frame_info = curr_frame.info; | 855 | current_frame_info = curr_frame.info; |
| 832 | bitstream = curr_frame.bit_stream; | 856 | bitstream = std::move(curr_frame.bit_stream); |
| 833 | } | 857 | } |
| 834 | 858 | ||
| 835 | // The uncompressed header routine sets PrevProb parameters needed for the compressed header | 859 | // The uncompressed header routine sets PrevProb parameters needed for the compressed header |
diff --git a/src/video_core/command_classes/codecs/vp9.h b/src/video_core/command_classes/codecs/vp9.h index 748e11bae..dc52ddbde 100644 --- a/src/video_core/command_classes/codecs/vp9.h +++ b/src/video_core/command_classes/codecs/vp9.h | |||
| @@ -4,9 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <unordered_map> | 7 | #include <array> |
| 8 | #include <vector> | 8 | #include <vector> |
| 9 | #include "common/common_funcs.h" | 9 | |
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "common/stream.h" | 11 | #include "common/stream.h" |
| 12 | #include "video_core/command_classes/codecs/vp9_types.h" | 12 | #include "video_core/command_classes/codecs/vp9_types.h" |
| @@ -52,17 +52,6 @@ private: | |||
| 52 | u32 range{0xff}; | 52 | u32 range{0xff}; |
| 53 | s32 count{-24}; | 53 | s32 count{-24}; |
| 54 | s32 half_probability{128}; | 54 | s32 half_probability{128}; |
| 55 | static constexpr std::array<s32, 256> norm_lut{ | ||
| 56 | 0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, | ||
| 57 | 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 58 | 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 59 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 60 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 61 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 62 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 63 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 64 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 65 | }; | ||
| 66 | }; | 55 | }; |
| 67 | 56 | ||
| 68 | class VpxBitStreamWriter { | 57 | class VpxBitStreamWriter { |
| @@ -193,23 +182,6 @@ private: | |||
| 193 | 182 | ||
| 194 | s32 diff_update_probability = 252; | 183 | s32 diff_update_probability = 252; |
| 195 | s32 frame_sync_code = 0x498342; | 184 | s32 frame_sync_code = 0x498342; |
| 196 | static constexpr std::array<s32, 254> map_lut = { | ||
| 197 | 20, 21, 22, 23, 24, 25, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, | ||
| 198 | 36, 37, 1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 2, 50, | ||
| 199 | 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 3, 62, 63, 64, 65, 66, | ||
| 200 | 67, 68, 69, 70, 71, 72, 73, 4, 74, 75, 76, 77, 78, 79, 80, 81, 82, | ||
| 201 | 83, 84, 85, 5, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 6, | ||
| 202 | 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 7, 110, 111, 112, 113, | ||
| 203 | 114, 115, 116, 117, 118, 119, 120, 121, 8, 122, 123, 124, 125, 126, 127, 128, 129, | ||
| 204 | 130, 131, 132, 133, 9, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, | ||
| 205 | 10, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 11, 158, 159, 160, | ||
| 206 | 161, 162, 163, 164, 165, 166, 167, 168, 169, 12, 170, 171, 172, 173, 174, 175, 176, | ||
| 207 | 177, 178, 179, 180, 181, 13, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, | ||
| 208 | 193, 14, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 15, 206, 207, | ||
| 209 | 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 16, 218, 219, 220, 221, 222, 223, | ||
| 210 | 224, 225, 226, 227, 228, 229, 17, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, | ||
| 211 | 240, 241, 18, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 19, | ||
| 212 | }; | ||
| 213 | }; | 185 | }; |
| 214 | 186 | ||
| 215 | } // namespace Decoder | 187 | } // namespace Decoder |
diff --git a/src/video_core/command_classes/codecs/vp9_types.h b/src/video_core/command_classes/codecs/vp9_types.h index 8688fdac0..a50acf6e8 100644 --- a/src/video_core/command_classes/codecs/vp9_types.h +++ b/src/video_core/command_classes/codecs/vp9_types.h | |||
| @@ -4,13 +4,11 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <algorithm> | 7 | #include <array> |
| 8 | #include <list> | 8 | #include <cstring> |
| 9 | #include <vector> | 9 | #include <vector> |
| 10 | #include "common/cityhash.h" | ||
| 11 | #include "common/common_funcs.h" | 10 | #include "common/common_funcs.h" |
| 12 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 13 | #include "video_core/command_classes/nvdec_common.h" | ||
| 14 | 12 | ||
| 15 | namespace Tegra { | 13 | namespace Tegra { |
| 16 | class GPU; | 14 | class GPU; |
diff --git a/src/video_core/command_classes/host1x.cpp b/src/video_core/command_classes/host1x.cpp index a5234ee47..c4dd4881a 100644 --- a/src/video_core/command_classes/host1x.cpp +++ b/src/video_core/command_classes/host1x.cpp | |||
| @@ -15,7 +15,7 @@ void Tegra::Host1x::StateWrite(u32 offset, u32 arguments) { | |||
| 15 | std::memcpy(state_offset, &arguments, sizeof(u32)); | 15 | std::memcpy(state_offset, &arguments, sizeof(u32)); |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | void Tegra::Host1x::ProcessMethod(Host1x::Method method, const std::vector<u32>& arguments) { | 18 | void Tegra::Host1x::ProcessMethod(Method method, const std::vector<u32>& arguments) { |
| 19 | StateWrite(static_cast<u32>(method), arguments[0]); | 19 | StateWrite(static_cast<u32>(method), arguments[0]); |
| 20 | switch (method) { | 20 | switch (method) { |
| 21 | case Method::WaitSyncpt: | 21 | case Method::WaitSyncpt: |
diff --git a/src/video_core/command_classes/host1x.h b/src/video_core/command_classes/host1x.h index 501a5ed2e..013eaa0c1 100644 --- a/src/video_core/command_classes/host1x.h +++ b/src/video_core/command_classes/host1x.h | |||
| @@ -61,7 +61,7 @@ public: | |||
| 61 | ~Host1x(); | 61 | ~Host1x(); |
| 62 | 62 | ||
| 63 | /// Writes the method into the state, Invoke Execute() if encountered | 63 | /// Writes the method into the state, Invoke Execute() if encountered |
| 64 | void ProcessMethod(Host1x::Method method, const std::vector<u32>& arguments); | 64 | void ProcessMethod(Method method, const std::vector<u32>& arguments); |
| 65 | 65 | ||
| 66 | private: | 66 | private: |
| 67 | /// For Host1x, execute is waiting on a syncpoint previously written into the state | 67 | /// For Host1x, execute is waiting on a syncpoint previously written into the state |
diff --git a/src/video_core/command_classes/nvdec.cpp b/src/video_core/command_classes/nvdec.cpp index ede9466eb..8ca7a7b06 100644 --- a/src/video_core/command_classes/nvdec.cpp +++ b/src/video_core/command_classes/nvdec.cpp | |||
| @@ -2,13 +2,9 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <bitset> | ||
| 6 | #include "common/assert.h" | 5 | #include "common/assert.h" |
| 7 | #include "common/bit_util.h" | ||
| 8 | #include "core/memory.h" | ||
| 9 | #include "video_core/command_classes/nvdec.h" | 6 | #include "video_core/command_classes/nvdec.h" |
| 10 | #include "video_core/gpu.h" | 7 | #include "video_core/gpu.h" |
| 11 | #include "video_core/memory_manager.h" | ||
| 12 | 8 | ||
| 13 | namespace Tegra { | 9 | namespace Tegra { |
| 14 | 10 | ||
| @@ -16,7 +12,7 @@ Nvdec::Nvdec(GPU& gpu_) : gpu(gpu_), codec(std::make_unique<Codec>(gpu)) {} | |||
| 16 | 12 | ||
| 17 | Nvdec::~Nvdec() = default; | 13 | Nvdec::~Nvdec() = default; |
| 18 | 14 | ||
| 19 | void Nvdec::ProcessMethod(Nvdec::Method method, const std::vector<u32>& arguments) { | 15 | void Nvdec::ProcessMethod(Method method, const std::vector<u32>& arguments) { |
| 20 | if (method == Method::SetVideoCodec) { | 16 | if (method == Method::SetVideoCodec) { |
| 21 | codec->StateWrite(static_cast<u32>(method), arguments[0]); | 17 | codec->StateWrite(static_cast<u32>(method), arguments[0]); |
| 22 | } else { | 18 | } else { |
diff --git a/src/video_core/command_classes/nvdec.h b/src/video_core/command_classes/nvdec.h index c1a9d843e..af14f9857 100644 --- a/src/video_core/command_classes/nvdec.h +++ b/src/video_core/command_classes/nvdec.h | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | ||
| 7 | #include <vector> | 8 | #include <vector> |
| 8 | #include "common/common_funcs.h" | ||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "video_core/command_classes/codecs/codec.h" | 10 | #include "video_core/command_classes/codecs/codec.h" |
| 11 | 11 | ||
| @@ -23,7 +23,7 @@ public: | |||
| 23 | ~Nvdec(); | 23 | ~Nvdec(); |
| 24 | 24 | ||
| 25 | /// Writes the method into the state, Invoke Execute() if encountered | 25 | /// Writes the method into the state, Invoke Execute() if encountered |
| 26 | void ProcessMethod(Nvdec::Method method, const std::vector<u32>& arguments); | 26 | void ProcessMethod(Method method, const std::vector<u32>& arguments); |
| 27 | 27 | ||
| 28 | /// Return most recently decoded frame | 28 | /// Return most recently decoded frame |
| 29 | AVFrame* GetFrame(); | 29 | AVFrame* GetFrame(); |
| @@ -34,6 +34,6 @@ private: | |||
| 34 | void Execute(); | 34 | void Execute(); |
| 35 | 35 | ||
| 36 | GPU& gpu; | 36 | GPU& gpu; |
| 37 | std::unique_ptr<Tegra::Codec> codec; | 37 | std::unique_ptr<Codec> codec; |
| 38 | }; | 38 | }; |
| 39 | } // namespace Tegra | 39 | } // namespace Tegra |
diff --git a/src/video_core/command_classes/vic.cpp b/src/video_core/command_classes/vic.cpp index 66e15a1a8..5b52da277 100644 --- a/src/video_core/command_classes/vic.cpp +++ b/src/video_core/command_classes/vic.cpp | |||
| @@ -26,7 +26,7 @@ void Vic::VicStateWrite(u32 offset, u32 arguments) { | |||
| 26 | std::memcpy(state_offset, &arguments, sizeof(u32)); | 26 | std::memcpy(state_offset, &arguments, sizeof(u32)); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | void Vic::ProcessMethod(Vic::Method method, const std::vector<u32>& arguments) { | 29 | void Vic::ProcessMethod(Method method, const std::vector<u32>& arguments) { |
| 30 | LOG_DEBUG(HW_GPU, "Vic method 0x{:X}", static_cast<u32>(method)); | 30 | LOG_DEBUG(HW_GPU, "Vic method 0x{:X}", static_cast<u32>(method)); |
| 31 | VicStateWrite(static_cast<u32>(method), arguments[0]); | 31 | VicStateWrite(static_cast<u32>(method), arguments[0]); |
| 32 | const u64 arg = static_cast<u64>(arguments[0]) << 8; | 32 | const u64 arg = static_cast<u64>(arguments[0]) << 8; |
diff --git a/src/video_core/command_classes/vic.h b/src/video_core/command_classes/vic.h index dd0a2aed8..8c4e284a1 100644 --- a/src/video_core/command_classes/vic.h +++ b/src/video_core/command_classes/vic.h | |||
| @@ -63,11 +63,11 @@ public: | |||
| 63 | SetOutputSurfaceChromaVOffset = 0x1ca | 63 | SetOutputSurfaceChromaVOffset = 0x1ca |
| 64 | }; | 64 | }; |
| 65 | 65 | ||
| 66 | explicit Vic(GPU& gpu, std::shared_ptr<Tegra::Nvdec> nvdec_processor); | 66 | explicit Vic(GPU& gpu, std::shared_ptr<Nvdec> nvdec_processor); |
| 67 | ~Vic(); | 67 | ~Vic(); |
| 68 | 68 | ||
| 69 | /// Write to the device state. | 69 | /// Write to the device state. |
| 70 | void ProcessMethod(Vic::Method method, const std::vector<u32>& arguments); | 70 | void ProcessMethod(Method method, const std::vector<u32>& arguments); |
| 71 | 71 | ||
| 72 | private: | 72 | private: |
| 73 | void Execute(); | 73 | void Execute(); |