mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +00:00
LibVideo/VP9: Convert token scan order indices to u16
They are directly taken from lookup tables that only need that bit precision, so may as well shrink them.
This commit is contained in:
parent
b6f41fe7d9
commit
062da60443
4 changed files with 22 additions and 22 deletions
File diff suppressed because one or more lines are too long
|
@ -1421,7 +1421,7 @@ DecoderErrorOr<bool> Parser::residual(BlockContext& block_context, bool has_bloc
|
|||
return had_residual_tokens;
|
||||
}
|
||||
|
||||
static u32 const* get_scan(TXSize tx_size, u8 transform_type)
|
||||
static u16 const* get_scan(TXSize tx_size, u8 transform_type)
|
||||
{
|
||||
if (tx_size == TX_4x4) {
|
||||
if (transform_type == ADST_DCT)
|
||||
|
@ -1449,14 +1449,14 @@ static u32 const* get_scan(TXSize tx_size, u8 transform_type)
|
|||
|
||||
DecoderErrorOr<bool> Parser::tokens(BlockContext& block_context, size_t plane, u32 start_x, u32 start_y, TXSize tx_size, u8 transform_type)
|
||||
{
|
||||
u32 segment_eob = 16 << (tx_size << 1);
|
||||
u16 segment_eob = 16 << (tx_size << 1);
|
||||
auto const* scan = get_scan(tx_size, transform_type);
|
||||
auto check_eob = true;
|
||||
u32 c = 0;
|
||||
for (; c < segment_eob; c++) {
|
||||
auto pos = scan[c];
|
||||
auto band = (tx_size == TX_4x4) ? coefband_4x4[c] : coefband_8x8plus[c];
|
||||
auto tokens_context = TreeParser::get_tokens_context(block_context.frame_context.color_config.subsampling_x, block_context.frame_context.color_config.subsampling_y, block_context.frame_context.rows(), block_context.frame_context.columns(), m_above_nonzero_context, m_left_nonzero_context, m_token_cache, tx_size, transform_type, plane, start_x, start_y, pos, block_context.is_inter_predicted(), band, c);
|
||||
u16 coef_index = 0;
|
||||
for (; coef_index < segment_eob; coef_index++) {
|
||||
auto pos = scan[coef_index];
|
||||
auto band = (tx_size == TX_4x4) ? coefband_4x4[coef_index] : coefband_8x8plus[coef_index];
|
||||
auto tokens_context = TreeParser::get_tokens_context(block_context.frame_context.color_config.subsampling_x, block_context.frame_context.color_config.subsampling_y, block_context.frame_context.rows(), block_context.frame_context.columns(), m_above_nonzero_context, m_left_nonzero_context, m_token_cache, tx_size, transform_type, plane, start_x, start_y, pos, block_context.is_inter_predicted(), band, coef_index);
|
||||
if (check_eob) {
|
||||
auto more_coefs = TRY_READ(TreeParser::parse_more_coefficients(*m_bit_stream, *m_probability_tables, *m_syntax_element_counter, tokens_context));
|
||||
if (!more_coefs)
|
||||
|
@ -1474,9 +1474,9 @@ DecoderErrorOr<bool> Parser::tokens(BlockContext& block_context, size_t plane, u
|
|||
check_eob = true;
|
||||
}
|
||||
}
|
||||
for (u32 i = c; i < segment_eob; i++)
|
||||
for (u16 i = coef_index; i < segment_eob; i++)
|
||||
m_tokens[scan[i]] = 0;
|
||||
return c > 0;
|
||||
return coef_index > 0;
|
||||
}
|
||||
|
||||
DecoderErrorOr<i32> Parser::read_coef(u8 bit_depth, Token token)
|
||||
|
|
|
@ -624,10 +624,10 @@ ErrorOr<bool> TreeParser::parse_motion_vector_hp(BitStream& bit_stream, Probabil
|
|||
return value;
|
||||
}
|
||||
|
||||
TokensContext TreeParser::get_tokens_context(bool subsampling_x, bool subsampling_y, u32 rows, u32 columns, Array<Vector<bool>, 3> const& above_nonzero_context, Array<Vector<bool>, 3> const& left_nonzero_context, u8 token_cache[1024], TXSize tx_size, u8 tx_type, u8 plane, u32 start_x, u32 start_y, u32 position, bool is_inter, u8 band, u32 c)
|
||||
TokensContext TreeParser::get_tokens_context(bool subsampling_x, bool subsampling_y, u32 rows, u32 columns, Array<Vector<bool>, 3> const& above_nonzero_context, Array<Vector<bool>, 3> const& left_nonzero_context, u8 token_cache[1024], TXSize tx_size, u8 tx_type, u8 plane, u32 start_x, u32 start_y, u16 position, bool is_inter, u8 band, u16 coef_index)
|
||||
{
|
||||
u8 context;
|
||||
if (c == 0) {
|
||||
if (coef_index == 0) {
|
||||
auto sx = plane > 0 ? subsampling_x : false;
|
||||
auto sy = plane > 0 ? subsampling_y : false;
|
||||
auto max_x = (2 * columns) >> sx;
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
static ErrorOr<u8> parse_motion_vector_fr(BitStream&, ProbabilityTables const&, SyntaxElementCounter&, u8 component);
|
||||
static ErrorOr<bool> parse_motion_vector_hp(BitStream&, ProbabilityTables const&, SyntaxElementCounter&, u8 component, bool use_hp);
|
||||
|
||||
static TokensContext get_tokens_context(bool subsampling_x, bool subsampling_y, u32 rows, u32 columns, Array<Vector<bool>, 3> const& above_nonzero_context, Array<Vector<bool>, 3> const& left_nonzero_context, u8 token_cache[1024], TXSize tx_size, u8 tx_type, u8 plane, u32 start_x, u32 start_y, u32 position, bool is_inter, u8 band, u32 c);
|
||||
static TokensContext get_tokens_context(bool subsampling_x, bool subsampling_y, u32 rows, u32 columns, Array<Vector<bool>, 3> const& above_nonzero_context, Array<Vector<bool>, 3> const& left_nonzero_context, u8 token_cache[1024], TXSize tx_size, u8 tx_type, u8 plane, u32 start_x, u32 start_y, u16 position, bool is_inter, u8 band, u16 coef_index);
|
||||
static ErrorOr<bool> parse_more_coefficients(BitStream&, ProbabilityTables const&, SyntaxElementCounter&, TokensContext const& context);
|
||||
static ErrorOr<Token> parse_token(BitStream&, ProbabilityTables const&, SyntaxElementCounter&, TokensContext const& context);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue