From e379223633328394d796a518fad19e0c39a36927 Mon Sep 17 00:00:00 2001 From: Zaggy1024 Date: Tue, 22 Nov 2022 20:59:16 -0600 Subject: LibVideo/VP9: Don't store the default_intra_mode in a field The default intra prediction mode was only used to set the sub-block modes and the y prediction mode. Instead of storing it in a field, with the sub modes are stored in an Array, we can just pull the last element to set the y mode. --- Userland/Libraries/LibVideo/VP9/Parser.cpp | 9 ++++----- Userland/Libraries/LibVideo/VP9/Parser.h | 3 +-- Userland/Libraries/LibVideo/VP9/TreeParser.cpp | 2 +- Userland/Libraries/LibVideo/VP9/TreeParser.h | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) (limited to 'Userland') diff --git a/Userland/Libraries/LibVideo/VP9/Parser.cpp b/Userland/Libraries/LibVideo/VP9/Parser.cpp index 9aa1b972e1..c30ff64d4e 100644 --- a/Userland/Libraries/LibVideo/VP9/Parser.cpp +++ b/Userland/Libraries/LibVideo/VP9/Parser.cpp @@ -1031,9 +1031,8 @@ DecoderErrorOr Parser::intra_frame_mode_info() above_context = m_sub_modes[get_image_index(m_mi_row - 1, m_mi_col)]; if (m_available_l) left_context = m_sub_modes[get_image_index(m_mi_row, m_mi_col - 1)]; - m_default_intra_mode = TRY_READ(TreeParser::parse_default_intra_mode(*m_bit_stream, *m_probability_tables, m_mi_size, above_context, left_context, m_block_sub_modes, 0, 0)); - m_y_mode = m_default_intra_mode; + m_y_mode = TRY_READ(TreeParser::parse_default_intra_mode(*m_bit_stream, *m_probability_tables, m_mi_size, above_context, left_context, m_block_sub_modes, 0, 0)); for (auto& block_sub_mode : m_block_sub_modes) block_sub_mode = m_y_mode; } else { @@ -1048,17 +1047,17 @@ DecoderErrorOr Parser::intra_frame_mode_info() above_context = m_sub_modes[get_image_index(m_mi_row - 1, m_mi_col)]; if (m_available_l) left_context = m_sub_modes[get_image_index(m_mi_row, m_mi_col - 1)]; - m_default_intra_mode = TRY_READ(TreeParser::parse_default_intra_mode(*m_bit_stream, *m_probability_tables, m_mi_size, above_context, left_context, m_block_sub_modes, idx, idy)); + auto sub_mode = TRY_READ(TreeParser::parse_default_intra_mode(*m_bit_stream, *m_probability_tables, m_mi_size, above_context, left_context, m_block_sub_modes, idx, idy)); for (auto y = 0; y < m_num_4x4_h; y++) { for (auto x = 0; x < m_num_4x4_w; x++) { auto index = (idy + y) * 2 + idx + x; - m_block_sub_modes[index] = m_default_intra_mode; + m_block_sub_modes[index] = sub_mode; } } } } - m_y_mode = m_default_intra_mode; + m_y_mode = m_block_sub_modes.last(); } m_uv_mode = TRY_READ(TreeParser::parse_default_uv_mode(*m_bit_stream, *m_probability_tables, m_y_mode)); return {}; diff --git a/Userland/Libraries/LibVideo/VP9/Parser.h b/Userland/Libraries/LibVideo/VP9/Parser.h index f5dacf101a..3556ff74b2 100644 --- a/Userland/Libraries/LibVideo/VP9/Parser.h +++ b/Userland/Libraries/LibVideo/VP9/Parser.h @@ -236,9 +236,8 @@ private: TXSize m_tx_size { TX_4x4 }; ReferenceFramePair m_ref_frame; bool m_is_inter { false }; - PredictionMode m_default_intra_mode { PredictionMode::DcPred }; PredictionMode m_y_mode { 0 }; - PredictionMode m_block_sub_modes[4]; + Array m_block_sub_modes; u8 m_num_4x4_w { 0 }; u8 m_num_4x4_h { 0 }; PredictionMode m_uv_mode { 0 }; // FIXME: Is u8 the right size? diff --git a/Userland/Libraries/LibVideo/VP9/TreeParser.cpp b/Userland/Libraries/LibVideo/VP9/TreeParser.cpp index 57b7ab2311..c6ecf5b384 100644 --- a/Userland/Libraries/LibVideo/VP9/TreeParser.cpp +++ b/Userland/Libraries/LibVideo/VP9/TreeParser.cpp @@ -80,7 +80,7 @@ ErrorOr TreeParser::parse_partition(BitStream& bit_stream, Probabilit return value; } -ErrorOr TreeParser::parse_default_intra_mode(BitStream& bit_stream, ProbabilityTables const& probability_table, BlockSubsize mi_size, Optional const&> above_context, Optional const&> left_context, PredictionMode block_sub_modes[4], u8 index_x, u8 index_y) +ErrorOr TreeParser::parse_default_intra_mode(BitStream& bit_stream, ProbabilityTables const& probability_table, BlockSubsize mi_size, Optional const&> above_context, Optional const&> left_context, Array const& block_sub_modes, u8 index_x, u8 index_y) { // FIXME: This should use a struct for the above and left contexts. diff --git a/Userland/Libraries/LibVideo/VP9/TreeParser.h b/Userland/Libraries/LibVideo/VP9/TreeParser.h index 8d833602c4..6bc7db4d59 100644 --- a/Userland/Libraries/LibVideo/VP9/TreeParser.h +++ b/Userland/Libraries/LibVideo/VP9/TreeParser.h @@ -49,7 +49,7 @@ public: }; static ErrorOr parse_partition(BitStream&, ProbabilityTables const&, SyntaxElementCounter&, bool has_rows, bool has_columns, BlockSubsize block_subsize, u8 num_8x8, Vector const& above_partition_context, Vector const& left_partition_context, u32 row, u32 column, bool frame_is_intra); - static ErrorOr parse_default_intra_mode(BitStream&, ProbabilityTables const&, BlockSubsize mi_size, Optional const&> above_context, Optional const&> left_context, PredictionMode block_sub_modes[4], u8 index_x, u8 index_y); + static ErrorOr parse_default_intra_mode(BitStream&, ProbabilityTables const&, BlockSubsize mi_size, Optional const&> above_context, Optional const&> left_context, Array const& block_sub_modes, u8 index_x, u8 index_y); static ErrorOr parse_default_uv_mode(BitStream&, ProbabilityTables const&, PredictionMode y_mode); static ErrorOr parse_intra_mode(BitStream&, ProbabilityTables const&, SyntaxElementCounter&, BlockSubsize mi_size); static ErrorOr parse_sub_intra_mode(BitStream&, ProbabilityTables const&, SyntaxElementCounter&); -- cgit v1.2.3