mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
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.
This commit is contained in:
parent
10d207959d
commit
9da432f4d6
Notes:
sideshowbarker
2024-07-17 03:55:20 +09:00
Author: https://github.com/Zaggy1024 Commit: https://github.com/SerenityOS/serenity/commit/9da432f4d6 Pull-request: https://github.com/SerenityOS/serenity/pull/16238
2 changed files with 10 additions and 12 deletions
|
@ -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)
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in a new issue