diff options
author | Zaggy1024 <zaggy1024@gmail.com> | 2022-11-20 17:55:19 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-11-30 08:28:30 +0100 |
commit | 9da432f4d6a9352bc460c0e155cd06527fd82cc6 (patch) | |
tree | d8a0c2a9662ee13741fcb4b89fdb2ea8ce25e3bd /Userland/Libraries/LibVideo | |
parent | 10d207959d0faf8a9fcdeca7273b25a7b1a40023 (diff) | |
download | serenity-9da432f4d6a9352bc460c0e155cd06527fd82cc6.zip |
LibVideo/VP9: Remove m_eob_total field from parser
The field was only used once to track whether residual tokens were
present in the block. Parser::tokens() now returns a bool indicating
whether they were present.
Diffstat (limited to 'Userland/Libraries/LibVideo')
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/Parser.cpp | 19 | ||||
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/Parser.h | 3 |
2 files changed, 10 insertions, 12 deletions
diff --git a/Userland/Libraries/LibVideo/VP9/Parser.cpp b/Userland/Libraries/LibVideo/VP9/Parser.cpp index 05f666b9cc..da8fb7311b 100644 --- a/Userland/Libraries/LibVideo/VP9/Parser.cpp +++ b/Userland/Libraries/LibVideo/VP9/Parser.cpp @@ -935,9 +935,8 @@ DecoderErrorOr<void> Parser::decode_block(u32 row, u32 column, BlockSubsize subs auto above_context = row > 0 ? m_frame_block_contexts.at(row - 1, column) : FrameBlockContext(); auto left_context = column > m_mi_col_start ? m_frame_block_contexts.at(row, column - 1) : FrameBlockContext(); TRY(mode_info(row, column, above_context, left_context)); - m_eob_total = 0; - TRY(residual(row, column, above_context.is_available, left_context.is_available)); - if (m_is_inter && subsize >= Block_8x8 && m_eob_total == 0) + auto had_residual_tokens = TRY(residual(row, column, above_context.is_available, left_context.is_available)); + if (m_is_inter && subsize >= Block_8x8 && !had_residual_tokens) m_skip = true; // Spec doesn't specify whether it might index outside the frame here, but it seems that it can. Ensure that we don't @@ -1291,8 +1290,9 @@ Gfx::Size<size_t> Parser::get_decoded_size_for_plane(u8 plane) return { point.x(), point.y() }; } -DecoderErrorOr<void> Parser::residual(u32 row, u32 column, bool has_block_above, bool has_block_left) +DecoderErrorOr<bool> Parser::residual(u32 row, u32 column, bool has_block_above, bool has_block_left) { + bool had_residual_tokens = false; auto block_size = m_mi_size < Block_8x8 ? Block_8x8 : static_cast<BlockSubsize>(m_mi_size); for (u8 plane = 0; plane < 3; plane++) { auto tx_size = (plane > 0) ? get_uv_tx_size() : m_tx_size; @@ -1328,6 +1328,7 @@ DecoderErrorOr<void> Parser::residual(u32 row, u32 column, bool has_block_above, TRY(m_decoder.predict_intra(plane, start_x, start_y, has_block_left || x > 0, has_block_above || y > 0, (x + step) < num_4x4_w, tx_size, block_index)); if (!m_skip) { non_zero = TRY(tokens(plane, start_x, start_y, tx_size, block_index)); + had_residual_tokens = had_residual_tokens || non_zero; TRY(m_decoder.reconstruct(plane, start_x, start_y, tx_size)); } } @@ -1348,7 +1349,7 @@ DecoderErrorOr<void> Parser::residual(u32 row, u32 column, bool has_block_above, } } } - return {}; + return had_residual_tokens; } TXSize Parser::get_uv_tx_size() @@ -1368,7 +1369,7 @@ BlockSubsize Parser::get_plane_block_size(u32 subsize, u8 plane) DecoderErrorOr<bool> Parser::tokens(size_t plane, u32 start_x, u32 start_y, TXSize tx_size, u32 block_index) { u32 segment_eob = 16 << (tx_size << 1); - auto scan = get_scan(plane, tx_size, block_index); + auto const* scan = get_scan(plane, tx_size, block_index); auto check_eob = true; u32 c = 0; for (; c < segment_eob; c++) { @@ -1387,16 +1388,14 @@ DecoderErrorOr<bool> Parser::tokens(size_t plane, u32 start_x, u32 start_y, TXSi check_eob = false; } else { i32 coef = TRY(read_coef(token)); - auto sign_bit = TRY_READ(m_bit_stream->read_literal(1)); + bool sign_bit = TRY_READ(m_bit_stream->read_literal(1)); m_tokens[pos] = sign_bit ? -coef : coef; check_eob = true; } } - auto non_zero = c > 0; - m_eob_total += non_zero; for (u32 i = c; i < segment_eob; i++) m_tokens[scan[i]] = 0; - return non_zero; + return c > 0; } u32 const* Parser::get_scan(size_t plane, TXSize tx_size, u32 block_index) diff --git a/Userland/Libraries/LibVideo/VP9/Parser.h b/Userland/Libraries/LibVideo/VP9/Parser.h index d37f7a4b03..5dd6e7772b 100644 --- a/Userland/Libraries/LibVideo/VP9/Parser.h +++ b/Userland/Libraries/LibVideo/VP9/Parser.h @@ -120,7 +120,7 @@ private: DecoderErrorOr<void> assign_mv(bool is_compound); DecoderErrorOr<void> read_mv(u8 ref); DecoderErrorOr<i32> read_mv_component(u8 component); - DecoderErrorOr<void> residual(u32 row, u32 column, bool has_block_above, bool has_block_left); + DecoderErrorOr<bool> residual(u32 row, u32 column, bool has_block_above, bool has_block_left); TXSize get_uv_tx_size(); BlockSubsize get_plane_block_size(u32 subsize, u8 plane); DecoderErrorOr<bool> tokens(size_t plane, u32 x, u32 y, TXSize tx_size, u32 block_index); @@ -242,7 +242,6 @@ private: Vector<u16> m_frame_store[NUM_REF_FRAMES][3]; - u32 m_eob_total { 0 }; u8 m_tx_type { 0 }; u8 m_token_cache[1024]; i32 m_tokens[1024]; |