diff options
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/Context.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/Decoder.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/Parser.cpp | 29 | ||||
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/Parser.h | 5 |
4 files changed, 19 insertions, 19 deletions
diff --git a/Userland/Libraries/LibVideo/VP9/Context.h b/Userland/Libraries/LibVideo/VP9/Context.h index 9e8d10a2af..6dbf6228d3 100644 --- a/Userland/Libraries/LibVideo/VP9/Context.h +++ b/Userland/Libraries/LibVideo/VP9/Context.h @@ -329,6 +329,8 @@ public: u16 header_size_in_bytes { 0 }; + TXMode transform_mode; + private: friend struct TileContext; diff --git a/Userland/Libraries/LibVideo/VP9/Decoder.cpp b/Userland/Libraries/LibVideo/VP9/Decoder.cpp index 4f194e21c2..790e003f4d 100644 --- a/Userland/Libraries/LibVideo/VP9/Decoder.cpp +++ b/Userland/Libraries/LibVideo/VP9/Decoder.cpp @@ -298,7 +298,7 @@ DecoderErrorOr<void> Decoder::adapt_non_coef_probs(FrameContext const& frame_con if (frame_context.interpolation_filter == Switchable) { ADAPT_TREE(interp_filter, interp_filter, interp_filter, INTERP_FILTER_CONTEXTS); } - if (m_parser->m_tx_mode == TXModeSelect) { + if (frame_context.transform_mode == TXModeSelect) { for (size_t i = 0; i < TX_SIZE_CONTEXTS; i++) { auto& tx_probs = probs.tx_probs(); auto& tx_counts = counter.m_counts_tx_size; diff --git a/Userland/Libraries/LibVideo/VP9/Parser.cpp b/Userland/Libraries/LibVideo/VP9/Parser.cpp index 34f5950a9f..fd803c93dc 100644 --- a/Userland/Libraries/LibVideo/VP9/Parser.cpp +++ b/Userland/Libraries/LibVideo/VP9/Parser.cpp @@ -542,10 +542,10 @@ void Parser::setup_past_independence() DecoderErrorOr<void> Parser::compressed_header(FrameContext& frame_context) { - TRY(read_tx_mode(frame_context)); - if (m_tx_mode == TXModeSelect) + frame_context.transform_mode = TRY(read_tx_mode(frame_context)); + if (frame_context.transform_mode == TXModeSelect) TRY(tx_mode_probs()); - TRY(read_coef_probs()); + TRY(read_coef_probs(frame_context.transform_mode)); TRY(read_skip_prob()); if (frame_context.is_inter_predicted()) { TRY(read_inter_mode_probs()); @@ -561,17 +561,16 @@ DecoderErrorOr<void> Parser::compressed_header(FrameContext& frame_context) return {}; } -DecoderErrorOr<void> Parser::read_tx_mode(FrameContext const& frame_context) +DecoderErrorOr<TXMode> Parser::read_tx_mode(FrameContext const& frame_context) { if (frame_context.is_lossless()) { - m_tx_mode = Only_4x4; - } else { - auto tx_mode = TRY_READ(m_bit_stream->read_literal(2)); - if (tx_mode == Allow_32x32) - tx_mode += TRY_READ(m_bit_stream->read_literal(1)); - m_tx_mode = static_cast<TXMode>(tx_mode); + return TXMode::Only_4x4; } - return {}; + + auto tx_mode = TRY_READ(m_bit_stream->read_literal(2)); + if (tx_mode == Allow_32x32) + tx_mode += TRY_READ(m_bit_stream->read_literal(1)); + return static_cast<TXMode>(tx_mode); } DecoderErrorOr<void> Parser::tx_mode_probs() @@ -635,9 +634,9 @@ u8 Parser::inv_recenter_nonneg(u8 v, u8 m) return m + (v >> 1u); } -DecoderErrorOr<void> Parser::read_coef_probs() +DecoderErrorOr<void> Parser::read_coef_probs(TXMode transform_mode) { - auto max_tx_size = tx_mode_to_biggest_tx_size[m_tx_mode]; + auto max_tx_size = tx_mode_to_biggest_tx_size[transform_mode]; for (u8 tx_size = 0; tx_size <= max_tx_size; tx_size++) { auto update_probs = TRY_READ(m_bit_stream->read_literal(1)); if (update_probs == 1) { @@ -1047,9 +1046,9 @@ bool Parser::seg_feature_active(BlockContext const& block_context, u8 feature) DecoderErrorOr<TXSize> Parser::read_tx_size(BlockContext& block_context, FrameBlockContext above_context, FrameBlockContext left_context, bool allow_select) { auto max_tx_size = max_txsize_lookup[block_context.size]; - if (allow_select && m_tx_mode == TXModeSelect && block_context.size >= Block_8x8) + if (allow_select && block_context.frame_context.transform_mode == TXModeSelect && block_context.size >= Block_8x8) return (TRY_READ(TreeParser::parse_tx_size(*m_bit_stream, *m_probability_tables, *m_syntax_element_counter, max_tx_size, above_context, left_context))); - return min(max_tx_size, tx_mode_to_biggest_tx_size[m_tx_mode]); + return min(max_tx_size, tx_mode_to_biggest_tx_size[block_context.frame_context.transform_mode]); } DecoderErrorOr<void> Parser::inter_frame_mode_info(BlockContext& block_context, FrameBlockContext above_context, FrameBlockContext left_context) diff --git a/Userland/Libraries/LibVideo/VP9/Parser.h b/Userland/Libraries/LibVideo/VP9/Parser.h index b572508530..be6abc78eb 100644 --- a/Userland/Libraries/LibVideo/VP9/Parser.h +++ b/Userland/Libraries/LibVideo/VP9/Parser.h @@ -74,13 +74,13 @@ private: /* (6.3) Compressed Header Syntax */ DecoderErrorOr<void> compressed_header(FrameContext&); - DecoderErrorOr<void> read_tx_mode(FrameContext const&); + DecoderErrorOr<TXMode> read_tx_mode(FrameContext const&); DecoderErrorOr<void> tx_mode_probs(); DecoderErrorOr<u8> diff_update_prob(u8 prob); DecoderErrorOr<u8> decode_term_subexp(); u8 inv_remap_prob(u8 delta_prob, u8 prob); u8 inv_recenter_nonneg(u8 v, u8 m); - DecoderErrorOr<void> read_coef_probs(); + DecoderErrorOr<void> read_coef_probs(TXMode); DecoderErrorOr<void> read_skip_prob(); DecoderErrorOr<void> read_inter_mode_probs(); DecoderErrorOr<void> read_interp_filter_probs(); @@ -169,7 +169,6 @@ private: u8 m_token_cache[1024]; i32 m_tokens[1024]; bool m_use_hp { false }; - TXMode m_tx_mode; ReferenceMode m_reference_mode; ReferenceFrameType m_comp_fixed_ref; ReferenceFramePair m_comp_var_ref; |