1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 19:47:34 +00:00

LibVideo/VP9: Move the above non-zero tokens context into decode_tiles

We can store this context in the stack of Parser::decode_tiles and use
spans to give access to the sections of the context for each tile and
subsequently each block.
This commit is contained in:
Zaggy1024 2022-11-28 01:01:11 -06:00 committed by Andreas Kling
parent 4e7e9d8479
commit 2f043a0bd4
5 changed files with 27 additions and 20 deletions

View file

@ -626,14 +626,12 @@ ErrorOr<bool> TreeParser::parse_motion_vector_hp(BitStream& bit_stream, Probabil
return value;
}
TokensContext TreeParser::get_context_for_first_token(BlockContext const& block_context, Array<Vector<bool>, 3> const& above_non_zero_tokens, NonZeroTokensView left_non_zero_tokens_in_block, TransformSize transform_size, u8 plane, u32 sub_block_column, u32 sub_block_row, bool is_inter, u8 band)
TokensContext TreeParser::get_context_for_first_token(NonZeroTokensView above_non_zero_tokens, NonZeroTokensView left_non_zero_tokens_in_block, TransformSize transform_size, u8 plane, u32 sub_block_column, u32 sub_block_row, bool is_inter, u8 band)
{
auto subsampling_x = plane > 0 ? block_context.frame_context.color_config.subsampling_x : false;
auto transform_left_in_sub_blocks = (blocks_to_sub_blocks(block_context.column) >> subsampling_x) + sub_block_column;
u8 transform_size_in_sub_blocks = transform_size_to_sub_blocks(transform_size);
bool above_has_non_zero_tokens = false;
for (u8 x = 0; x < transform_size_in_sub_blocks && x < above_non_zero_tokens[plane].size() - transform_left_in_sub_blocks; x++) {
if (above_non_zero_tokens[plane][transform_left_in_sub_blocks + x]) {
for (u8 x = 0; x < transform_size_in_sub_blocks && x < above_non_zero_tokens[plane].size() - sub_block_column; x++) {
if (above_non_zero_tokens[plane][sub_block_column + x]) {
above_has_non_zero_tokens = true;
break;
}