diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | src/common/logging/backend.cpp | 112 | ||||
| -rw-r--r-- | src/common/logging/filter.cpp | 1 | ||||
| -rw-r--r-- | src/common/logging/types.h | 1 | ||||
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/hle/service/ngct/ngct.cpp | 46 | ||||
| -rw-r--r-- | src/core/hle/service/ngct/ngct.h | 20 | ||||
| -rw-r--r-- | src/core/hle/service/service.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/command_classes/codecs/vp9.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/command_classes/codecs/vp9_types.h | 85 |
10 files changed, 103 insertions, 170 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 316c4dedc..57922b51c 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt | |||
| @@ -176,6 +176,3 @@ if (MSVC) | |||
| 176 | else() | 176 | else() |
| 177 | target_link_libraries(common PRIVATE zstd) | 177 | target_link_libraries(common PRIVATE zstd) |
| 178 | endif() | 178 | endif() |
| 179 | if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND CMAKE_CXX_COMPILER_ID STREQUAL GNU) | ||
| 180 | target_link_libraries(common PRIVATE backtrace) | ||
| 181 | endif() | ||
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 6f1d251e1..949384fd3 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp | |||
| @@ -13,14 +13,6 @@ | |||
| 13 | #include <windows.h> // For OutputDebugStringW | 13 | #include <windows.h> // For OutputDebugStringW |
| 14 | #endif | 14 | #endif |
| 15 | 15 | ||
| 16 | #if defined(__linux__) && defined(__GNUG__) && !defined(__clang__) | ||
| 17 | #define BOOST_STACKTRACE_USE_BACKTRACE | ||
| 18 | #include <boost/stacktrace.hpp> | ||
| 19 | #undef BOOST_STACKTRACE_USE_BACKTRACE | ||
| 20 | #include <signal.h> | ||
| 21 | #define YUZU_LINUX_GCC_BACKTRACE | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #include "common/fs/file.h" | 16 | #include "common/fs/file.h" |
| 25 | #include "common/fs/fs.h" | 17 | #include "common/fs/fs.h" |
| 26 | #include "common/fs/fs_paths.h" | 18 | #include "common/fs/fs_paths.h" |
| @@ -163,14 +155,6 @@ public: | |||
| 163 | 155 | ||
| 164 | bool initialization_in_progress_suppress_logging = true; | 156 | bool initialization_in_progress_suppress_logging = true; |
| 165 | 157 | ||
| 166 | #ifdef YUZU_LINUX_GCC_BACKTRACE | ||
| 167 | [[noreturn]] void SleepForever() { | ||
| 168 | while (true) { | ||
| 169 | pause(); | ||
| 170 | } | ||
| 171 | } | ||
| 172 | #endif | ||
| 173 | |||
| 174 | /** | 158 | /** |
| 175 | * Static state as a singleton. | 159 | * Static state as a singleton. |
| 176 | */ | 160 | */ |
| @@ -242,66 +226,9 @@ private: | |||
| 242 | while (max_logs_to_write-- && message_queue.Pop(entry)) { | 226 | while (max_logs_to_write-- && message_queue.Pop(entry)) { |
| 243 | write_logs(); | 227 | write_logs(); |
| 244 | } | 228 | } |
| 245 | })} { | 229 | })} {} |
| 246 | #ifdef YUZU_LINUX_GCC_BACKTRACE | ||
| 247 | int waker_pipefd[2]; | ||
| 248 | int done_printing_pipefd[2]; | ||
| 249 | if (pipe2(waker_pipefd, O_CLOEXEC) || pipe2(done_printing_pipefd, O_CLOEXEC)) { | ||
| 250 | abort(); | ||
| 251 | } | ||
| 252 | backtrace_thread_waker_fd = waker_pipefd[1]; | ||
| 253 | backtrace_done_printing_fd = done_printing_pipefd[0]; | ||
| 254 | std::thread([this, wait_fd = waker_pipefd[0], done_fd = done_printing_pipefd[1]] { | ||
| 255 | Common::SetCurrentThreadName("yuzu:Crash"); | ||
| 256 | for (u8 ignore = 0; read(wait_fd, &ignore, 1) != 1;) | ||
| 257 | ; | ||
| 258 | const int sig = received_signal; | ||
| 259 | if (sig <= 0) { | ||
| 260 | abort(); | ||
| 261 | } | ||
| 262 | StopBackendThread(); | ||
| 263 | const auto signal_entry = | ||
| 264 | CreateEntry(Class::Log, Level::Critical, "?", 0, "?", | ||
| 265 | fmt::vformat("Received signal {}", fmt::make_format_args(sig))); | ||
| 266 | ForEachBackend([&signal_entry](Backend& backend) { | ||
| 267 | backend.EnableForStacktrace(); | ||
| 268 | backend.Write(signal_entry); | ||
| 269 | }); | ||
| 270 | const auto backtrace = | ||
| 271 | boost::stacktrace::stacktrace::from_dump(backtrace_storage.data(), 4096); | ||
| 272 | for (const auto& frame : backtrace.as_vector()) { | ||
| 273 | auto line = boost::stacktrace::detail::to_string(&frame, 1); | ||
| 274 | if (line.empty()) { | ||
| 275 | abort(); | ||
| 276 | } | ||
| 277 | line.pop_back(); // Remove newline | ||
| 278 | const auto frame_entry = | ||
| 279 | CreateEntry(Class::Log, Level::Critical, "?", 0, "?", line); | ||
| 280 | ForEachBackend([&frame_entry](Backend& backend) { backend.Write(frame_entry); }); | ||
| 281 | } | ||
| 282 | using namespace std::literals; | ||
| 283 | const auto rip_entry = CreateEntry(Class::Log, Level::Critical, "?", 0, "?", "RIP"s); | ||
| 284 | ForEachBackend([&rip_entry](Backend& backend) { | ||
| 285 | backend.Write(rip_entry); | ||
| 286 | backend.Flush(); | ||
| 287 | }); | ||
| 288 | for (const u8 anything = 0; write(done_fd, &anything, 1) != 1;) | ||
| 289 | ; | ||
| 290 | // Abort on original thread to help debugging | ||
| 291 | SleepForever(); | ||
| 292 | }).detach(); | ||
| 293 | signal(SIGSEGV, &HandleSignal); | ||
| 294 | signal(SIGABRT, &HandleSignal); | ||
| 295 | #endif | ||
| 296 | } | ||
| 297 | 230 | ||
| 298 | ~Impl() { | 231 | ~Impl() { |
| 299 | #ifdef YUZU_LINUX_GCC_BACKTRACE | ||
| 300 | if (int zero_or_ignore = 0; | ||
| 301 | !received_signal.compare_exchange_strong(zero_or_ignore, SIGKILL)) { | ||
| 302 | SleepForever(); | ||
| 303 | } | ||
| 304 | #endif | ||
| 305 | StopBackendThread(); | 232 | StopBackendThread(); |
| 306 | } | 233 | } |
| 307 | 234 | ||
| @@ -340,36 +267,6 @@ private: | |||
| 340 | delete ptr; | 267 | delete ptr; |
| 341 | } | 268 | } |
| 342 | 269 | ||
| 343 | #ifdef YUZU_LINUX_GCC_BACKTRACE | ||
| 344 | [[noreturn]] static void HandleSignal(int sig) { | ||
| 345 | signal(SIGABRT, SIG_DFL); | ||
| 346 | signal(SIGSEGV, SIG_DFL); | ||
| 347 | if (sig <= 0) { | ||
| 348 | abort(); | ||
| 349 | } | ||
| 350 | instance->InstanceHandleSignal(sig); | ||
| 351 | } | ||
| 352 | |||
| 353 | [[noreturn]] void InstanceHandleSignal(int sig) { | ||
| 354 | if (int zero_or_ignore = 0; !received_signal.compare_exchange_strong(zero_or_ignore, sig)) { | ||
| 355 | if (received_signal == SIGKILL) { | ||
| 356 | abort(); | ||
| 357 | } | ||
| 358 | SleepForever(); | ||
| 359 | } | ||
| 360 | // Don't restart like boost suggests. We want to append to the log file and not lose dynamic | ||
| 361 | // symbols. This may segfault if it unwinds outside C/C++ code but we'll just have to fall | ||
| 362 | // back to core dumps. | ||
| 363 | boost::stacktrace::safe_dump_to(backtrace_storage.data(), 4096); | ||
| 364 | std::atomic_thread_fence(std::memory_order_seq_cst); | ||
| 365 | for (const int anything = 0; write(backtrace_thread_waker_fd, &anything, 1) != 1;) | ||
| 366 | ; | ||
| 367 | for (u8 ignore = 0; read(backtrace_done_printing_fd, &ignore, 1) != 1;) | ||
| 368 | ; | ||
| 369 | abort(); | ||
| 370 | } | ||
| 371 | #endif | ||
| 372 | |||
| 373 | static inline std::unique_ptr<Impl, decltype(&Deleter)> instance{nullptr, Deleter}; | 270 | static inline std::unique_ptr<Impl, decltype(&Deleter)> instance{nullptr, Deleter}; |
| 374 | 271 | ||
| 375 | Filter filter; | 272 | Filter filter; |
| @@ -380,13 +277,6 @@ private: | |||
| 380 | std::thread backend_thread; | 277 | std::thread backend_thread; |
| 381 | MPSCQueue<Entry> message_queue{}; | 278 | MPSCQueue<Entry> message_queue{}; |
| 382 | std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()}; | 279 | std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()}; |
| 383 | |||
| 384 | #ifdef YUZU_LINUX_GCC_BACKTRACE | ||
| 385 | std::atomic_int received_signal{0}; | ||
| 386 | std::array<u8, 4096> backtrace_storage{}; | ||
| 387 | int backtrace_thread_waker_fd; | ||
| 388 | int backtrace_done_printing_fd; | ||
| 389 | #endif | ||
| 390 | }; | 280 | }; |
| 391 | } // namespace | 281 | } // namespace |
| 392 | 282 | ||
diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index f055f0e11..42744c994 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp | |||
| @@ -111,6 +111,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) { | |||
| 111 | SUB(Service, NCM) \ | 111 | SUB(Service, NCM) \ |
| 112 | SUB(Service, NFC) \ | 112 | SUB(Service, NFC) \ |
| 113 | SUB(Service, NFP) \ | 113 | SUB(Service, NFP) \ |
| 114 | SUB(Service, NGCT) \ | ||
| 114 | SUB(Service, NIFM) \ | 115 | SUB(Service, NIFM) \ |
| 115 | SUB(Service, NIM) \ | 116 | SUB(Service, NIM) \ |
| 116 | SUB(Service, NPNS) \ | 117 | SUB(Service, NPNS) \ |
diff --git a/src/common/logging/types.h b/src/common/logging/types.h index 7ad0334fc..ddf9d27ca 100644 --- a/src/common/logging/types.h +++ b/src/common/logging/types.h | |||
| @@ -81,6 +81,7 @@ enum class Class : u8 { | |||
| 81 | Service_NCM, ///< The NCM service | 81 | Service_NCM, ///< The NCM service |
| 82 | Service_NFC, ///< The NFC (Near-field communication) service | 82 | Service_NFC, ///< The NFC (Near-field communication) service |
| 83 | Service_NFP, ///< The NFP service | 83 | Service_NFP, ///< The NFP service |
| 84 | Service_NGCT, ///< The NGCT (No Good Content for Terra) service | ||
| 84 | Service_NIFM, ///< The NIFM (Network interface) service | 85 | Service_NIFM, ///< The NIFM (Network interface) service |
| 85 | Service_NIM, ///< The NIM service | 86 | Service_NIM, ///< The NIM service |
| 86 | Service_NPNS, ///< The NPNS service | 87 | Service_NPNS, ///< The NPNS service |
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index f5cf5c16a..87d47e2e5 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -452,6 +452,8 @@ add_library(core STATIC | |||
| 452 | hle/service/nfp/nfp.h | 452 | hle/service/nfp/nfp.h |
| 453 | hle/service/nfp/nfp_user.cpp | 453 | hle/service/nfp/nfp_user.cpp |
| 454 | hle/service/nfp/nfp_user.h | 454 | hle/service/nfp/nfp_user.h |
| 455 | hle/service/ngct/ngct.cpp | ||
| 456 | hle/service/ngct/ngct.h | ||
| 455 | hle/service/nifm/nifm.cpp | 457 | hle/service/nifm/nifm.cpp |
| 456 | hle/service/nifm/nifm.h | 458 | hle/service/nifm/nifm.h |
| 457 | hle/service/nim/nim.cpp | 459 | hle/service/nim/nim.cpp |
diff --git a/src/core/hle/service/ngct/ngct.cpp b/src/core/hle/service/ngct/ngct.cpp new file mode 100644 index 000000000..deb3abb28 --- /dev/null +++ b/src/core/hle/service/ngct/ngct.cpp | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included | ||
| 4 | |||
| 5 | #include "common/string_util.h" | ||
| 6 | #include "core/core.h" | ||
| 7 | #include "core/hle/ipc_helpers.h" | ||
| 8 | #include "core/hle/service/ngct/ngct.h" | ||
| 9 | #include "core/hle/service/service.h" | ||
| 10 | |||
| 11 | namespace Service::NGCT { | ||
| 12 | |||
| 13 | class IService final : public ServiceFramework<IService> { | ||
| 14 | public: | ||
| 15 | explicit IService(Core::System& system_) : ServiceFramework{system_, "ngct:u"} { | ||
| 16 | // clang-format off | ||
| 17 | static const FunctionInfo functions[] = { | ||
| 18 | {0, nullptr, "Match"}, | ||
| 19 | {1, &IService::Filter, "Filter"}, | ||
| 20 | }; | ||
| 21 | // clang-format on | ||
| 22 | |||
| 23 | RegisterHandlers(functions); | ||
| 24 | } | ||
| 25 | |||
| 26 | private: | ||
| 27 | void Filter(Kernel::HLERequestContext& ctx) { | ||
| 28 | const auto buffer = ctx.ReadBuffer(); | ||
| 29 | const auto text = Common::StringFromFixedZeroTerminatedBuffer( | ||
| 30 | reinterpret_cast<const char*>(buffer.data()), buffer.size()); | ||
| 31 | |||
| 32 | LOG_WARNING(Service_NGCT, "(STUBBED) called, text={}", text); | ||
| 33 | |||
| 34 | // Return the same string since we don't censor anything | ||
| 35 | ctx.WriteBuffer(buffer); | ||
| 36 | |||
| 37 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 38 | rb.Push(ResultSuccess); | ||
| 39 | } | ||
| 40 | }; | ||
| 41 | |||
| 42 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | ||
| 43 | std::make_shared<IService>(system)->InstallAsService(system.ServiceManager()); | ||
| 44 | } | ||
| 45 | |||
| 46 | } // namespace Service::NGCT | ||
diff --git a/src/core/hle/service/ngct/ngct.h b/src/core/hle/service/ngct/ngct.h new file mode 100644 index 000000000..1f2a47b78 --- /dev/null +++ b/src/core/hle/service/ngct/ngct.h | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | namespace Core { | ||
| 8 | class System; | ||
| 9 | } | ||
| 10 | |||
| 11 | namespace Service::SM { | ||
| 12 | class ServiceManager; | ||
| 13 | } | ||
| 14 | |||
| 15 | namespace Service::NGCT { | ||
| 16 | |||
| 17 | /// Registers all NGCT services with the specified service manager. | ||
| 18 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | ||
| 19 | |||
| 20 | } // namespace Service::NGCT | ||
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index b3e50433b..065133166 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -46,6 +46,7 @@ | |||
| 46 | #include "core/hle/service/ncm/ncm.h" | 46 | #include "core/hle/service/ncm/ncm.h" |
| 47 | #include "core/hle/service/nfc/nfc.h" | 47 | #include "core/hle/service/nfc/nfc.h" |
| 48 | #include "core/hle/service/nfp/nfp.h" | 48 | #include "core/hle/service/nfp/nfp.h" |
| 49 | #include "core/hle/service/ngct/ngct.h" | ||
| 49 | #include "core/hle/service/nifm/nifm.h" | 50 | #include "core/hle/service/nifm/nifm.h" |
| 50 | #include "core/hle/service/nim/nim.h" | 51 | #include "core/hle/service/nim/nim.h" |
| 51 | #include "core/hle/service/npns/npns.h" | 52 | #include "core/hle/service/npns/npns.h" |
| @@ -271,6 +272,7 @@ Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system | |||
| 271 | NCM::InstallInterfaces(*sm, system); | 272 | NCM::InstallInterfaces(*sm, system); |
| 272 | NFC::InstallInterfaces(*sm, system); | 273 | NFC::InstallInterfaces(*sm, system); |
| 273 | NFP::InstallInterfaces(*sm, system); | 274 | NFP::InstallInterfaces(*sm, system); |
| 275 | NGCT::InstallInterfaces(*sm, system); | ||
| 274 | NIFM::InstallInterfaces(*sm, system); | 276 | NIFM::InstallInterfaces(*sm, system); |
| 275 | NIM::InstallInterfaces(*sm, system); | 277 | NIM::InstallInterfaces(*sm, system); |
| 276 | NPNS::InstallInterfaces(*sm, system); | 278 | NPNS::InstallInterfaces(*sm, system); |
diff --git a/src/video_core/command_classes/codecs/vp9.cpp b/src/video_core/command_classes/codecs/vp9.cpp index 70030066a..d7e749485 100644 --- a/src/video_core/command_classes/codecs/vp9.cpp +++ b/src/video_core/command_classes/codecs/vp9.cpp | |||
| @@ -742,6 +742,7 @@ VpxBitStreamWriter VP9::ComposeUncompressedHeader() { | |||
| 742 | uncomp_writer.WriteDeltaQ(current_frame_info.uv_dc_delta_q); | 742 | uncomp_writer.WriteDeltaQ(current_frame_info.uv_dc_delta_q); |
| 743 | uncomp_writer.WriteDeltaQ(current_frame_info.uv_ac_delta_q); | 743 | uncomp_writer.WriteDeltaQ(current_frame_info.uv_ac_delta_q); |
| 744 | 744 | ||
| 745 | ASSERT(!current_frame_info.segment_enabled); | ||
| 745 | uncomp_writer.WriteBit(false); // Segmentation enabled (TODO). | 746 | uncomp_writer.WriteBit(false); // Segmentation enabled (TODO). |
| 746 | 747 | ||
| 747 | const s32 min_tile_cols_log2 = CalcMinLog2TileCols(current_frame_info.frame_size.width); | 748 | const s32 min_tile_cols_log2 = CalcMinLog2TileCols(current_frame_info.frame_size.width); |
diff --git a/src/video_core/command_classes/codecs/vp9_types.h b/src/video_core/command_classes/codecs/vp9_types.h index 87eafdb03..3b1ed4b3a 100644 --- a/src/video_core/command_classes/codecs/vp9_types.h +++ b/src/video_core/command_classes/codecs/vp9_types.h | |||
| @@ -22,7 +22,7 @@ struct Vp9FrameDimensions { | |||
| 22 | }; | 22 | }; |
| 23 | static_assert(sizeof(Vp9FrameDimensions) == 0x8, "Vp9 Vp9FrameDimensions is an invalid size"); | 23 | static_assert(sizeof(Vp9FrameDimensions) == 0x8, "Vp9 Vp9FrameDimensions is an invalid size"); |
| 24 | 24 | ||
| 25 | enum FrameFlags : u32 { | 25 | enum class FrameFlags : u32 { |
| 26 | IsKeyFrame = 1 << 0, | 26 | IsKeyFrame = 1 << 0, |
| 27 | LastFrameIsKeyFrame = 1 << 1, | 27 | LastFrameIsKeyFrame = 1 << 1, |
| 28 | FrameSizeChanged = 1 << 2, | 28 | FrameSizeChanged = 1 << 2, |
| @@ -30,6 +30,7 @@ enum FrameFlags : u32 { | |||
| 30 | LastShowFrame = 1 << 4, | 30 | LastShowFrame = 1 << 4, |
| 31 | IntraOnly = 1 << 5, | 31 | IntraOnly = 1 << 5, |
| 32 | }; | 32 | }; |
| 33 | DECLARE_ENUM_FLAG_OPERATORS(FrameFlags) | ||
| 33 | 34 | ||
| 34 | enum class TxSize { | 35 | enum class TxSize { |
| 35 | Tx4x4 = 0, // 4x4 transform | 36 | Tx4x4 = 0, // 4x4 transform |
| @@ -92,44 +93,34 @@ struct Vp9EntropyProbs { | |||
| 92 | static_assert(sizeof(Vp9EntropyProbs) == 0x7B4, "Vp9EntropyProbs is an invalid size"); | 93 | static_assert(sizeof(Vp9EntropyProbs) == 0x7B4, "Vp9EntropyProbs is an invalid size"); |
| 93 | 94 | ||
| 94 | struct Vp9PictureInfo { | 95 | struct Vp9PictureInfo { |
| 95 | bool is_key_frame; | 96 | u32 bitstream_size; |
| 96 | bool intra_only; | 97 | std::array<u64, 4> frame_offsets; |
| 97 | bool last_frame_was_key; | ||
| 98 | bool frame_size_changed; | ||
| 99 | bool error_resilient_mode; | ||
| 100 | bool last_frame_shown; | ||
| 101 | bool show_frame; | ||
| 102 | std::array<s8, 4> ref_frame_sign_bias; | 98 | std::array<s8, 4> ref_frame_sign_bias; |
| 103 | s32 base_q_index; | 99 | s32 base_q_index; |
| 104 | s32 y_dc_delta_q; | 100 | s32 y_dc_delta_q; |
| 105 | s32 uv_dc_delta_q; | 101 | s32 uv_dc_delta_q; |
| 106 | s32 uv_ac_delta_q; | 102 | s32 uv_ac_delta_q; |
| 107 | bool lossless; | ||
| 108 | s32 transform_mode; | 103 | s32 transform_mode; |
| 109 | bool allow_high_precision_mv; | ||
| 110 | s32 interp_filter; | 104 | s32 interp_filter; |
| 111 | s32 reference_mode; | 105 | s32 reference_mode; |
| 112 | s8 comp_fixed_ref; | ||
| 113 | std::array<s8, 2> comp_var_ref; | ||
| 114 | s32 log2_tile_cols; | 106 | s32 log2_tile_cols; |
| 115 | s32 log2_tile_rows; | 107 | s32 log2_tile_rows; |
| 116 | bool segment_enabled; | ||
| 117 | bool segment_map_update; | ||
| 118 | bool segment_map_temporal_update; | ||
| 119 | s32 segment_abs_delta; | ||
| 120 | std::array<u32, 8> segment_feature_enable; | ||
| 121 | std::array<std::array<s16, 4>, 8> segment_feature_data; | ||
| 122 | bool mode_ref_delta_enabled; | ||
| 123 | bool use_prev_in_find_mv_refs; | ||
| 124 | std::array<s8, 4> ref_deltas; | 108 | std::array<s8, 4> ref_deltas; |
| 125 | std::array<s8, 2> mode_deltas; | 109 | std::array<s8, 2> mode_deltas; |
| 126 | Vp9EntropyProbs entropy; | 110 | Vp9EntropyProbs entropy; |
| 127 | Vp9FrameDimensions frame_size; | 111 | Vp9FrameDimensions frame_size; |
| 128 | u8 first_level; | 112 | u8 first_level; |
| 129 | u8 sharpness_level; | 113 | u8 sharpness_level; |
| 130 | u32 bitstream_size; | 114 | bool is_key_frame; |
| 131 | std::array<u64, 4> frame_offsets; | 115 | bool intra_only; |
| 132 | std::array<bool, 4> refresh_frame; | 116 | bool last_frame_was_key; |
| 117 | bool error_resilient_mode; | ||
| 118 | bool last_frame_shown; | ||
| 119 | bool show_frame; | ||
| 120 | bool lossless; | ||
| 121 | bool allow_high_precision_mv; | ||
| 122 | bool segment_enabled; | ||
| 123 | bool mode_ref_delta_enabled; | ||
| 133 | }; | 124 | }; |
| 134 | 125 | ||
| 135 | struct Vp9FrameContainer { | 126 | struct Vp9FrameContainer { |
| @@ -145,7 +136,7 @@ struct PictureInfo { | |||
| 145 | Vp9FrameDimensions golden_frame_size; ///< 0x50 | 136 | Vp9FrameDimensions golden_frame_size; ///< 0x50 |
| 146 | Vp9FrameDimensions alt_frame_size; ///< 0x58 | 137 | Vp9FrameDimensions alt_frame_size; ///< 0x58 |
| 147 | Vp9FrameDimensions current_frame_size; ///< 0x60 | 138 | Vp9FrameDimensions current_frame_size; ///< 0x60 |
| 148 | u32 vp9_flags; ///< 0x68 | 139 | FrameFlags vp9_flags; ///< 0x68 |
| 149 | std::array<s8, 4> ref_frame_sign_bias; ///< 0x6C | 140 | std::array<s8, 4> ref_frame_sign_bias; ///< 0x6C |
| 150 | u8 first_level; ///< 0x70 | 141 | u8 first_level; ///< 0x70 |
| 151 | u8 sharpness_level; ///< 0x71 | 142 | u8 sharpness_level; ///< 0x71 |
| @@ -158,60 +149,43 @@ struct PictureInfo { | |||
| 158 | u8 allow_high_precision_mv; ///< 0x78 | 149 | u8 allow_high_precision_mv; ///< 0x78 |
| 159 | u8 interp_filter; ///< 0x79 | 150 | u8 interp_filter; ///< 0x79 |
| 160 | u8 reference_mode; ///< 0x7A | 151 | u8 reference_mode; ///< 0x7A |
| 161 | s8 comp_fixed_ref; ///< 0x7B | 152 | INSERT_PADDING_BYTES_NOINIT(3); ///< 0x7B |
| 162 | std::array<s8, 2> comp_var_ref; ///< 0x7C | ||
| 163 | u8 log2_tile_cols; ///< 0x7E | 153 | u8 log2_tile_cols; ///< 0x7E |
| 164 | u8 log2_tile_rows; ///< 0x7F | 154 | u8 log2_tile_rows; ///< 0x7F |
| 165 | Segmentation segmentation; ///< 0x80 | 155 | Segmentation segmentation; ///< 0x80 |
| 166 | LoopFilter loop_filter; ///< 0xE4 | 156 | LoopFilter loop_filter; ///< 0xE4 |
| 167 | INSERT_PADDING_BYTES_NOINIT(5); ///< 0xEB | 157 | INSERT_PADDING_BYTES_NOINIT(21); ///< 0xEB |
| 168 | u32 surface_params; ///< 0xF0 | ||
| 169 | INSERT_PADDING_WORDS_NOINIT(3); ///< 0xF4 | ||
| 170 | 158 | ||
| 171 | [[nodiscard]] Vp9PictureInfo Convert() const { | 159 | [[nodiscard]] Vp9PictureInfo Convert() const { |
| 172 | return { | 160 | return { |
| 173 | .is_key_frame = (vp9_flags & FrameFlags::IsKeyFrame) != 0, | 161 | .bitstream_size = bitstream_size, |
| 174 | .intra_only = (vp9_flags & FrameFlags::IntraOnly) != 0, | 162 | .frame_offsets{}, |
| 175 | .last_frame_was_key = (vp9_flags & FrameFlags::LastFrameIsKeyFrame) != 0, | ||
| 176 | .frame_size_changed = (vp9_flags & FrameFlags::FrameSizeChanged) != 0, | ||
| 177 | .error_resilient_mode = (vp9_flags & FrameFlags::ErrorResilientMode) != 0, | ||
| 178 | .last_frame_shown = (vp9_flags & FrameFlags::LastShowFrame) != 0, | ||
| 179 | .show_frame = true, | ||
| 180 | .ref_frame_sign_bias = ref_frame_sign_bias, | 163 | .ref_frame_sign_bias = ref_frame_sign_bias, |
| 181 | .base_q_index = base_q_index, | 164 | .base_q_index = base_q_index, |
| 182 | .y_dc_delta_q = y_dc_delta_q, | 165 | .y_dc_delta_q = y_dc_delta_q, |
| 183 | .uv_dc_delta_q = uv_dc_delta_q, | 166 | .uv_dc_delta_q = uv_dc_delta_q, |
| 184 | .uv_ac_delta_q = uv_ac_delta_q, | 167 | .uv_ac_delta_q = uv_ac_delta_q, |
| 185 | .lossless = lossless != 0, | ||
| 186 | .transform_mode = tx_mode, | 168 | .transform_mode = tx_mode, |
| 187 | .allow_high_precision_mv = allow_high_precision_mv != 0, | ||
| 188 | .interp_filter = interp_filter, | 169 | .interp_filter = interp_filter, |
| 189 | .reference_mode = reference_mode, | 170 | .reference_mode = reference_mode, |
| 190 | .comp_fixed_ref = comp_fixed_ref, | ||
| 191 | .comp_var_ref = comp_var_ref, | ||
| 192 | .log2_tile_cols = log2_tile_cols, | 171 | .log2_tile_cols = log2_tile_cols, |
| 193 | .log2_tile_rows = log2_tile_rows, | 172 | .log2_tile_rows = log2_tile_rows, |
| 194 | .segment_enabled = segmentation.enabled != 0, | ||
| 195 | .segment_map_update = segmentation.update_map != 0, | ||
| 196 | .segment_map_temporal_update = segmentation.temporal_update != 0, | ||
| 197 | .segment_abs_delta = segmentation.abs_delta, | ||
| 198 | .segment_feature_enable = segmentation.feature_mask, | ||
| 199 | .segment_feature_data = segmentation.feature_data, | ||
| 200 | .mode_ref_delta_enabled = loop_filter.mode_ref_delta_enabled != 0, | ||
| 201 | .use_prev_in_find_mv_refs = !(vp9_flags == (FrameFlags::ErrorResilientMode)) && | ||
| 202 | !(vp9_flags == (FrameFlags::FrameSizeChanged)) && | ||
| 203 | !(vp9_flags == (FrameFlags::IntraOnly)) && | ||
| 204 | (vp9_flags == (FrameFlags::LastShowFrame)) && | ||
| 205 | !(vp9_flags == (FrameFlags::LastFrameIsKeyFrame)), | ||
| 206 | .ref_deltas = loop_filter.ref_deltas, | 173 | .ref_deltas = loop_filter.ref_deltas, |
| 207 | .mode_deltas = loop_filter.mode_deltas, | 174 | .mode_deltas = loop_filter.mode_deltas, |
| 208 | .entropy{}, | 175 | .entropy{}, |
| 209 | .frame_size = current_frame_size, | 176 | .frame_size = current_frame_size, |
| 210 | .first_level = first_level, | 177 | .first_level = first_level, |
| 211 | .sharpness_level = sharpness_level, | 178 | .sharpness_level = sharpness_level, |
| 212 | .bitstream_size = bitstream_size, | 179 | .is_key_frame = True(vp9_flags & FrameFlags::IsKeyFrame), |
| 213 | .frame_offsets{}, | 180 | .intra_only = True(vp9_flags & FrameFlags::IntraOnly), |
| 214 | .refresh_frame{}, | 181 | .last_frame_was_key = True(vp9_flags & FrameFlags::LastFrameIsKeyFrame), |
| 182 | .error_resilient_mode = True(vp9_flags & FrameFlags::ErrorResilientMode), | ||
| 183 | .last_frame_shown = True(vp9_flags & FrameFlags::LastShowFrame), | ||
| 184 | .show_frame = true, | ||
| 185 | .lossless = lossless != 0, | ||
| 186 | .allow_high_precision_mv = allow_high_precision_mv != 0, | ||
| 187 | .segment_enabled = segmentation.enabled != 0, | ||
| 188 | .mode_ref_delta_enabled = loop_filter.mode_ref_delta_enabled != 0, | ||
| 215 | }; | 189 | }; |
| 216 | } | 190 | } |
| 217 | }; | 191 | }; |
| @@ -316,7 +290,6 @@ ASSERT_POSITION(last_frame_size, 0x48); | |||
| 316 | ASSERT_POSITION(first_level, 0x70); | 290 | ASSERT_POSITION(first_level, 0x70); |
| 317 | ASSERT_POSITION(segmentation, 0x80); | 291 | ASSERT_POSITION(segmentation, 0x80); |
| 318 | ASSERT_POSITION(loop_filter, 0xE4); | 292 | ASSERT_POSITION(loop_filter, 0xE4); |
| 319 | ASSERT_POSITION(surface_params, 0xF0); | ||
| 320 | #undef ASSERT_POSITION | 293 | #undef ASSERT_POSITION |
| 321 | 294 | ||
| 322 | #define ASSERT_POSITION(field_name, position) \ | 295 | #define ASSERT_POSITION(field_name, position) \ |