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

LibVideo/VP9: Prefix TransformSize with Transform_ instead of TX_

This commit is contained in:
Zaggy1024 2022-11-26 10:59:00 -06:00 committed by Andreas Kling
parent f6e645a153
commit 1a2d8ac40c
7 changed files with 43 additions and 43 deletions

View file

@ -189,7 +189,7 @@ struct BlockContext {
u8 segment_id { 0 }; u8 segment_id { 0 };
bool should_skip_residuals { false }; bool should_skip_residuals { false };
TransformSize tx_size { TransformSize::TX_4x4 }; TransformSize tx_size { Transform_4x4 };
ReferenceFramePair reference_frame_types; ReferenceFramePair reference_frame_types;
bool is_inter_predicted() const { return reference_frame_types.primary != ReferenceFrameType::None; } bool is_inter_predicted() const { return reference_frame_types.primary != ReferenceFrameType::None; }

View file

@ -202,7 +202,7 @@ struct FrameBlockContext {
bool is_available { false }; bool is_available { false };
bool skip_coefficients { false }; bool skip_coefficients { false };
TransformSize tx_size { TransformSize::TX_4x4 }; TransformSize tx_size { Transform_4x4 };
PredictionMode y_mode { PredictionMode::DcPred }; PredictionMode y_mode { PredictionMode::DcPred };
Array<PredictionMode, 4> sub_modes { PredictionMode::DcPred, PredictionMode::DcPred, PredictionMode::DcPred, PredictionMode::DcPred }; Array<PredictionMode, 4> sub_modes { PredictionMode::DcPred, PredictionMode::DcPred, PredictionMode::DcPred, PredictionMode::DcPred };
InterpolationFilter interpolation_filter { InterpolationFilter::EightTap }; InterpolationFilter interpolation_filter { InterpolationFilter::EightTap };

View file

@ -303,9 +303,9 @@ DecoderErrorOr<void> Decoder::adapt_non_coef_probs(FrameContext const& frame_con
for (size_t i = 0; i < TX_SIZE_CONTEXTS; i++) { for (size_t i = 0; i < TX_SIZE_CONTEXTS; i++) {
auto& tx_probs = probs.tx_probs(); auto& tx_probs = probs.tx_probs();
auto& tx_counts = counter.m_counts_tx_size; auto& tx_counts = counter.m_counts_tx_size;
adapt_probs(tx_size_8_tree, tx_probs[TX_8x8][i], tx_counts[TX_8x8][i]); adapt_probs(tx_size_8_tree, tx_probs[Transform_8x8][i], tx_counts[Transform_8x8][i]);
adapt_probs(tx_size_16_tree, tx_probs[TX_16x16][i], tx_counts[TX_16x16][i]); adapt_probs(tx_size_16_tree, tx_probs[Transform_16x16][i], tx_counts[Transform_16x16][i]);
adapt_probs(tx_size_32_tree, tx_probs[TX_32x32][i], tx_counts[TX_32x32][i]); adapt_probs(tx_size_32_tree, tx_probs[Transform_32x32][i], tx_counts[Transform_32x32][i]);
} }
} }
adapt_probs(mv_joint_tree, probs.mv_joint_probs(), counter.m_counts_mv_joint); adapt_probs(mv_joint_tree, probs.mv_joint_probs(), counter.m_counts_mv_joint);
@ -413,7 +413,7 @@ DecoderErrorOr<void> Decoder::predict_intra(u8 plane, BlockContext const& block_
} }
// The array aboveRow[ i ] for i = size..2*size-1 is specified by: // The array aboveRow[ i ] for i = size..2*size-1 is specified by:
if (have_above && not_on_right && tx_size == TransformSize::TX_4x4) { if (have_above && not_on_right && tx_size == Transform_4x4) {
// 1. If haveAbove is equal to 1 and notOnRight is equal to 1 and txSz is equal to 0, // 1. If haveAbove is equal to 1 and notOnRight is equal to 1 and txSz is equal to 0,
// aboveRow[ i ] is set equal to CurrFrame[ plane ][ y-1 ][ Min(maxX, x+i) ]. // aboveRow[ i ] is set equal to CurrFrame[ plane ][ y-1 ][ Min(maxX, x+i) ].
for (auto i = block_size; i < block_size * 2; i++) for (auto i = block_size; i < block_size * 2; i++)
@ -1071,8 +1071,8 @@ DecoderErrorOr<void> Decoder::reconstruct(u8 plane, BlockContext const& block_co
{ {
// 8.6.2 Reconstruct process // 8.6.2 Reconstruct process
// The variable dqDenom is set equal to 2 if txSz is equal to TX_32X32, otherwise dqDenom is set equal to 1. // The variable dqDenom is set equal to 2 if txSz is equal to Transform_32X32, otherwise dqDenom is set equal to 1.
Intermediate dq_denominator = transform_block_size == TX_32x32 ? 2 : 1; Intermediate dq_denominator = transform_block_size == Transform_32x32 ? 2 : 1;
// The variable n (specifying the base 2 logarithm of the width of the transform block) is set equal to 2 + txSz. // The variable n (specifying the base 2 logarithm of the width of the transform block) is set equal to 2 + txSz.
u8 log2_of_block_size = 2u + transform_block_size; u8 log2_of_block_size = 2u + transform_block_size;
// The variable n0 (specifying the width of the transform block) is set equal to 1 << n. // The variable n0 (specifying the width of the transform block) is set equal to 1 << n.

View file

@ -54,10 +54,10 @@ enum TransformMode : u8 {
}; };
enum TransformSize : u8 { enum TransformSize : u8 {
TX_4x4 = 0, Transform_4x4 = 0,
TX_8x8 = 1, Transform_8x8 = 1,
TX_16x16 = 2, Transform_16x16 = 2,
TX_32x32 = 3, Transform_32x32 = 3,
}; };
enum class TransformType : u8 { enum class TransformType : u8 {

View file

@ -14,7 +14,7 @@
namespace Video::VP9 { namespace Video::VP9 {
static constexpr InterpolationFilter literal_to_type[4] = { EightTapSmooth, EightTap, EightTapSharp, Bilinear }; static constexpr InterpolationFilter literal_to_type[4] = { EightTapSmooth, EightTap, EightTapSharp, Bilinear };
static constexpr TransformSize tx_mode_to_biggest_tx_size[TX_MODES] = { TX_4x4, TX_8x8, TX_16x16, TX_32x32, TX_32x32 }; static constexpr TransformSize tx_mode_to_biggest_tx_size[TX_MODES] = { Transform_4x4, Transform_8x8, Transform_16x16, Transform_32x32, Transform_32x32 };
static constexpr u8 segmentation_feature_bits[SEG_LVL_MAX] = { 8, 6, 2, 0 }; static constexpr u8 segmentation_feature_bits[SEG_LVL_MAX] = { 8, 6, 2, 0 };
static constexpr bool segmentation_feature_signed[SEG_LVL_MAX] = { true, true, false, false }; static constexpr bool segmentation_feature_signed[SEG_LVL_MAX] = { true, true, false, false };
static constexpr u8 inv_map_table[MAX_PROB] = { static constexpr u8 inv_map_table[MAX_PROB] = {
@ -123,15 +123,15 @@ static constexpr int segment_tree[14] = {
}; };
static constexpr int binary_tree[2] = { 0, -1 }; static constexpr int binary_tree[2] = { 0, -1 };
static constexpr int tx_size_32_tree[6] = { static constexpr int tx_size_32_tree[6] = {
-TX_4x4, 2, -Transform_4x4, 2,
-TX_8x8, 4, -Transform_8x8, 4,
-TX_16x16, -TX_32x32 -Transform_16x16, -Transform_32x32
}; };
static constexpr int tx_size_16_tree[4] = { static constexpr int tx_size_16_tree[4] = {
-TX_4x4, 2, -Transform_4x4, 2,
-TX_8x8, -TX_16x16 -Transform_8x8, -Transform_16x16
}; };
static constexpr int tx_size_8_tree[2] = { -TX_4x4, -TX_8x8 }; static constexpr int tx_size_8_tree[2] = { -Transform_4x4, -Transform_8x8 };
static constexpr int inter_mode_tree[6] = { static constexpr int inter_mode_tree[6] = {
-to_underlying(PredictionMode::ZeroMv), 2, -to_underlying(PredictionMode::ZeroMv), 2,
-to_underlying(PredictionMode::NearestMv), 4, -to_underlying(PredictionMode::NearestMv), 4,
@ -187,19 +187,19 @@ static constexpr u8 num_8x8_blocks_high_lookup[BLOCK_SIZES] = { 1, 1, 1, 1, 2, 1
static constexpr u8 size_group_lookup[BLOCK_SIZES] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3 }; static constexpr u8 size_group_lookup[BLOCK_SIZES] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3 };
static constexpr TransformSize max_txsize_lookup[BLOCK_SIZES] = { static constexpr TransformSize max_txsize_lookup[BLOCK_SIZES] = {
TX_4x4, Transform_4x4,
TX_4x4, Transform_4x4,
TX_4x4, Transform_4x4,
TX_8x8, Transform_8x8,
TX_8x8, Transform_8x8,
TX_8x8, Transform_8x8,
TX_16x16, Transform_16x16,
TX_16x16, Transform_16x16,
TX_16x16, Transform_16x16,
TX_32x32, Transform_32x32,
TX_32x32, Transform_32x32,
TX_32x32, Transform_32x32,
TX_32x32, Transform_32x32,
}; };
static constexpr BlockSubsize ss_size_lookup[BLOCK_SIZES][2][2] = { static constexpr BlockSubsize ss_size_lookup[BLOCK_SIZES][2][2] = {

View file

@ -584,15 +584,15 @@ DecoderErrorOr<void> Parser::tx_mode_probs()
auto& tx_probs = m_probability_tables->tx_probs(); auto& tx_probs = m_probability_tables->tx_probs();
for (auto i = 0; i < TX_SIZE_CONTEXTS; i++) { for (auto i = 0; i < TX_SIZE_CONTEXTS; i++) {
for (auto j = 0; j < TX_SIZES - 3; j++) for (auto j = 0; j < TX_SIZES - 3; j++)
tx_probs[TX_8x8][i][j] = TRY(diff_update_prob(tx_probs[TX_8x8][i][j])); tx_probs[Transform_8x8][i][j] = TRY(diff_update_prob(tx_probs[Transform_8x8][i][j]));
} }
for (auto i = 0; i < TX_SIZE_CONTEXTS; i++) { for (auto i = 0; i < TX_SIZE_CONTEXTS; i++) {
for (auto j = 0; j < TX_SIZES - 2; j++) for (auto j = 0; j < TX_SIZES - 2; j++)
tx_probs[TX_16x16][i][j] = TRY(diff_update_prob(tx_probs[TX_16x16][i][j])); tx_probs[Transform_16x16][i][j] = TRY(diff_update_prob(tx_probs[Transform_16x16][i][j]));
} }
for (auto i = 0; i < TX_SIZE_CONTEXTS; i++) { for (auto i = 0; i < TX_SIZE_CONTEXTS; i++) {
for (auto j = 0; j < TX_SIZES - 1; j++) for (auto j = 0; j < TX_SIZES - 1; j++)
tx_probs[TX_32x32][i][j] = TRY(diff_update_prob(tx_probs[TX_32x32][i][j])); tx_probs[Transform_32x32][i][j] = TRY(diff_update_prob(tx_probs[Transform_32x32][i][j]));
} }
return {}; return {};
} }
@ -1338,9 +1338,9 @@ static TransformSize get_uv_tx_size(TransformSize tx_size, BlockSubsize size_for
static TransformSet select_transform_type(BlockContext const& block_context, u8 plane, TransformSize tx_size, u32 block_index) static TransformSet select_transform_type(BlockContext const& block_context, u8 plane, TransformSize tx_size, u32 block_index)
{ {
if (plane > 0 || tx_size == TX_32x32) if (plane > 0 || tx_size == Transform_32x32)
return TransformSet { TransformType::DCT, TransformType::DCT }; return TransformSet { TransformType::DCT, TransformType::DCT };
if (tx_size == TX_4x4) { if (tx_size == Transform_4x4) {
if (block_context.frame_context.is_lossless() || block_context.is_inter_predicted()) if (block_context.frame_context.is_lossless() || block_context.is_inter_predicted())
return TransformSet { TransformType::DCT, TransformType::DCT }; return TransformSet { TransformType::DCT, TransformType::DCT };
@ -1420,21 +1420,21 @@ static u16 const* get_scan(TransformSize tx_size, TransformSet transform_set)
constexpr TransformSet adst_dct { TransformType::ADST, TransformType::DCT }; constexpr TransformSet adst_dct { TransformType::ADST, TransformType::DCT };
constexpr TransformSet dct_adst { TransformType::DCT, TransformType::ADST }; constexpr TransformSet dct_adst { TransformType::DCT, TransformType::ADST };
if (tx_size == TX_4x4) { if (tx_size == Transform_4x4) {
if (transform_set == adst_dct) if (transform_set == adst_dct)
return row_scan_4x4; return row_scan_4x4;
if (transform_set == dct_adst) if (transform_set == dct_adst)
return col_scan_4x4; return col_scan_4x4;
return default_scan_4x4; return default_scan_4x4;
} }
if (tx_size == TX_8x8) { if (tx_size == Transform_8x8) {
if (transform_set == adst_dct) if (transform_set == adst_dct)
return row_scan_8x8; return row_scan_8x8;
if (transform_set == dct_adst) if (transform_set == dct_adst)
return col_scan_8x8; return col_scan_8x8;
return default_scan_8x8; return default_scan_8x8;
} }
if (tx_size == TX_16x16) { if (tx_size == Transform_16x16) {
if (transform_set == adst_dct) if (transform_set == adst_dct)
return row_scan_16x16; return row_scan_16x16;
if (transform_set == dct_adst) if (transform_set == dct_adst)
@ -1452,7 +1452,7 @@ DecoderErrorOr<bool> Parser::tokens(BlockContext& block_context, size_t plane, u
u16 coef_index = 0; u16 coef_index = 0;
for (; coef_index < segment_eob; coef_index++) { for (; coef_index < segment_eob; coef_index++) {
auto pos = scan[coef_index]; auto pos = scan[coef_index];
auto band = (tx_size == TX_4x4) ? coefband_4x4[coef_index] : coefband_8x8plus[coef_index]; auto band = (tx_size == Transform_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_set, plane, start_x, start_y, pos, block_context.is_inter_predicted(), band, 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_set, plane, start_x, start_y, pos, block_context.is_inter_predicted(), band, coef_index);
if (check_eob) { if (check_eob) {
auto more_coefs = TRY_READ(TreeParser::parse_more_coefficients(*m_bit_stream, *m_probability_tables, *m_syntax_element_counter, tokens_context)); auto more_coefs = TRY_READ(TreeParser::parse_more_coefficients(*m_bit_stream, *m_probability_tables, *m_syntax_element_counter, tokens_context));

View file

@ -235,9 +235,9 @@ ErrorOr<TransformSize> TreeParser::parse_tx_size(BitStream& bit_stream, Probabil
// Tree // Tree
TreeParser::TreeSelection tree { tx_size_8_tree }; TreeParser::TreeSelection tree { tx_size_8_tree };
if (max_tx_size == TX_16x16) if (max_tx_size == Transform_16x16)
tree = { tx_size_16_tree }; tree = { tx_size_16_tree };
if (max_tx_size == TX_32x32) if (max_tx_size == Transform_32x32)
tree = { tx_size_32_tree }; tree = { tx_size_32_tree };
// Probabilities // Probabilities