diff options
author | Zaggy1024 <zaggy1024@gmail.com> | 2022-11-22 20:59:16 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-11-30 08:28:30 +0100 |
commit | e379223633328394d796a518fad19e0c39a36927 (patch) | |
tree | eae06f8ea9e70d6c3fa84e77508e72ea013b89e0 /Userland | |
parent | 713b48cfe24b663c2aa98fc97032045202f20147 (diff) | |
download | serenity-e379223633328394d796a518fad19e0c39a36927.zip |
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.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/Parser.cpp | 9 | ||||
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/Parser.h | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/TreeParser.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/TreeParser.h | 2 |
4 files changed, 7 insertions, 9 deletions
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<void> 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<void> 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<PredictionMode, 4> 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<Partition> TreeParser::parse_partition(BitStream& bit_stream, Probabilit return value; } -ErrorOr<PredictionMode> TreeParser::parse_default_intra_mode(BitStream& bit_stream, ProbabilityTables const& probability_table, BlockSubsize mi_size, Optional<Array<PredictionMode, 4> const&> above_context, Optional<Array<PredictionMode, 4> const&> left_context, PredictionMode block_sub_modes[4], u8 index_x, u8 index_y) +ErrorOr<PredictionMode> TreeParser::parse_default_intra_mode(BitStream& bit_stream, ProbabilityTables const& probability_table, BlockSubsize mi_size, Optional<Array<PredictionMode, 4> const&> above_context, Optional<Array<PredictionMode, 4> const&> left_context, Array<PredictionMode, 4> 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<Partition> parse_partition(BitStream&, ProbabilityTables const&, SyntaxElementCounter&, bool has_rows, bool has_columns, BlockSubsize block_subsize, u8 num_8x8, Vector<u8> const& above_partition_context, Vector<u8> const& left_partition_context, u32 row, u32 column, bool frame_is_intra); - static ErrorOr<PredictionMode> parse_default_intra_mode(BitStream&, ProbabilityTables const&, BlockSubsize mi_size, Optional<Array<PredictionMode, 4> const&> above_context, Optional<Array<PredictionMode, 4> const&> left_context, PredictionMode block_sub_modes[4], u8 index_x, u8 index_y); + static ErrorOr<PredictionMode> parse_default_intra_mode(BitStream&, ProbabilityTables const&, BlockSubsize mi_size, Optional<Array<PredictionMode, 4> const&> above_context, Optional<Array<PredictionMode, 4> const&> left_context, Array<PredictionMode, 4> const& block_sub_modes, u8 index_x, u8 index_y); static ErrorOr<PredictionMode> parse_default_uv_mode(BitStream&, ProbabilityTables const&, PredictionMode y_mode); static ErrorOr<PredictionMode> parse_intra_mode(BitStream&, ProbabilityTables const&, SyntaxElementCounter&, BlockSubsize mi_size); static ErrorOr<PredictionMode> parse_sub_intra_mode(BitStream&, ProbabilityTables const&, SyntaxElementCounter&); |