Browse Source

LibVideo/VP9: Change all names containing tx_size to transform_size

Zaggy1024 2 years ago
parent
commit
c33d6fb028

+ 1 - 1
Userland/Libraries/LibVideo/VP9/Context.h

@@ -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 { Transform_4x4 };
+    TransformSize transform_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; }

+ 1 - 1
Userland/Libraries/LibVideo/VP9/ContextStorage.h

@@ -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 { Transform_4x4 };
+    TransformSize transform_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 };

+ 1 - 1
Userland/Libraries/LibVideo/VP9/Decoder.h

@@ -58,7 +58,7 @@ private:
 
 
     /* (8.5) Prediction Processes */
     /* (8.5) Prediction Processes */
     // (8.5.1) Intra prediction process
     // (8.5.1) Intra prediction process
-    DecoderErrorOr<void> predict_intra(u8 plane, BlockContext const& block_context, u32 x, u32 y, bool have_left, bool have_above, bool not_on_right, TransformSize tx_size, u32 block_index);
+    DecoderErrorOr<void> predict_intra(u8 plane, BlockContext const& block_context, u32 x, u32 y, bool have_left, bool have_above, bool not_on_right, TransformSize transform_size, u32 block_index);
 
 
     // (8.5.1) Inter prediction process
     // (8.5.1) Inter prediction process
     DecoderErrorOr<void> predict_inter(u8 plane, BlockContext const& block_context, u32 x, u32 y, u32 width, u32 height, u32 block_index);
     DecoderErrorOr<void> predict_inter(u8 plane, BlockContext const& block_context, u32 x, u32 y, u32 width, u32 height, u32 block_index);

+ 21 - 21
Userland/Libraries/LibVideo/VP9/Parser.cpp

@@ -643,7 +643,7 @@ u8 Parser::inv_recenter_nonneg(u8 v, u8 m)
 DecoderErrorOr<void> Parser::read_coef_probs(TransformMode transform_mode)
 DecoderErrorOr<void> Parser::read_coef_probs(TransformMode transform_mode)
 {
 {
     auto max_tx_size = tx_mode_to_biggest_tx_size[transform_mode];
     auto max_tx_size = tx_mode_to_biggest_tx_size[transform_mode];
-    for (u8 tx_size = 0; tx_size <= max_tx_size; tx_size++) {
+    for (u8 transform_size = 0; transform_size <= max_tx_size; transform_size++) {
         auto update_probs = TRY_READ(m_bit_stream->read_literal(1));
         auto update_probs = TRY_READ(m_bit_stream->read_literal(1));
         if (update_probs == 1) {
         if (update_probs == 1) {
             for (auto i = 0; i < 2; i++) {
             for (auto i = 0; i < 2; i++) {
@@ -652,7 +652,7 @@ DecoderErrorOr<void> Parser::read_coef_probs(TransformMode transform_mode)
                         auto max_l = (k == 0) ? 3 : 6;
                         auto max_l = (k == 0) ? 3 : 6;
                         for (auto l = 0; l < max_l; l++) {
                         for (auto l = 0; l < max_l; l++) {
                             for (auto m = 0; m < 3; m++) {
                             for (auto m = 0; m < 3; m++) {
-                                auto& prob = m_probability_tables->coef_probs()[tx_size][i][j][k][l][m];
+                                auto& prob = m_probability_tables->coef_probs()[transform_size][i][j][k][l][m];
                                 prob = TRY(diff_update_prob(prob));
                                 prob = TRY(diff_update_prob(prob));
                             }
                             }
                         }
                         }
@@ -981,9 +981,9 @@ DecoderErrorOr<void> Parser::decode_block(TileContext& tile_context, u32 row, u3
 
 
     for (size_t y = 0; y < block_context.contexts_view.height(); y++) {
     for (size_t y = 0; y < block_context.contexts_view.height(); y++) {
         for (size_t x = 0; x < block_context.contexts_view.width(); x++) {
         for (size_t x = 0; x < block_context.contexts_view.width(); x++) {
-            auto sub_block_context = FrameBlockContext { true, block_context.should_skip_residuals, block_context.tx_size, block_context.y_prediction_mode(), block_context.sub_block_prediction_modes, block_context.interpolation_filter, block_context.reference_frame_types, block_context.sub_block_motion_vectors, block_context.segment_id };
+            auto sub_block_context = FrameBlockContext { true, block_context.should_skip_residuals, block_context.transform_size, block_context.y_prediction_mode(), block_context.sub_block_prediction_modes, block_context.interpolation_filter, block_context.reference_frame_types, block_context.sub_block_motion_vectors, block_context.segment_id };
             block_context.contexts_view.at(y, x) = sub_block_context;
             block_context.contexts_view.at(y, x) = sub_block_context;
-            VERIFY(block_context.frame_block_contexts().at(row + y, column + x).tx_size == sub_block_context.tx_size);
+            VERIFY(block_context.frame_block_contexts().at(row + y, column + x).transform_size == sub_block_context.transform_size);
         }
         }
     }
     }
     return {};
     return {};
@@ -1004,7 +1004,7 @@ DecoderErrorOr<void> Parser::intra_frame_mode_info(BlockContext& block_context,
     VERIFY(!block_context.is_inter_predicted());
     VERIFY(!block_context.is_inter_predicted());
     TRY(set_intra_segment_id(block_context));
     TRY(set_intra_segment_id(block_context));
     block_context.should_skip_residuals = TRY(read_should_skip_residuals(block_context, above_context, left_context));
     block_context.should_skip_residuals = TRY(read_should_skip_residuals(block_context, above_context, left_context));
-    block_context.tx_size = TRY(read_tx_size(block_context, above_context, left_context, true));
+    block_context.transform_size = TRY(read_tx_size(block_context, above_context, left_context, true));
     // FIXME: This if statement is also present in parse_default_intra_mode. The selection of parameters for
     // FIXME: This if statement is also present in parse_default_intra_mode. The selection of parameters for
     //        the probability table lookup should be inlined here.
     //        the probability table lookup should be inlined here.
     if (block_context.size >= Block_8x8) {
     if (block_context.size >= Block_8x8) {
@@ -1064,7 +1064,7 @@ DecoderErrorOr<void> Parser::inter_frame_mode_info(BlockContext& block_context,
     TRY(set_inter_segment_id(block_context));
     TRY(set_inter_segment_id(block_context));
     block_context.should_skip_residuals = TRY(read_should_skip_residuals(block_context, above_context, left_context));
     block_context.should_skip_residuals = TRY(read_should_skip_residuals(block_context, above_context, left_context));
     auto is_inter = TRY(read_is_inter(block_context, above_context, left_context));
     auto is_inter = TRY(read_is_inter(block_context, above_context, left_context));
-    block_context.tx_size = TRY(read_tx_size(block_context, above_context, left_context, !block_context.should_skip_residuals || !is_inter));
+    block_context.transform_size = TRY(read_tx_size(block_context, above_context, left_context, !block_context.should_skip_residuals || !is_inter));
     if (is_inter) {
     if (is_inter) {
         TRY(inter_block_mode_info(block_context, above_context, left_context));
         TRY(inter_block_mode_info(block_context, above_context, left_context));
     } else {
     } else {
@@ -1331,16 +1331,16 @@ Gfx::Size<size_t> Parser::get_decoded_size_for_plane(FrameContext const& frame_c
     return { point.x(), point.y() };
     return { point.x(), point.y() };
 }
 }
 
 
-static TransformSize get_uv_tx_size(TransformSize tx_size, BlockSubsize size_for_plane)
+static TransformSize get_uv_transform_size(TransformSize transform_size, BlockSubsize size_for_plane)
 {
 {
-    return min(tx_size, max_txsize_lookup[size_for_plane]);
+    return min(transform_size, max_txsize_lookup[size_for_plane]);
 }
 }
 
 
-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 transform_size, u32 block_index)
 {
 {
-    if (plane > 0 || tx_size == Transform_32x32)
+    if (plane > 0 || transform_size == Transform_32x32)
         return TransformSet { TransformType::DCT, TransformType::DCT };
         return TransformSet { TransformType::DCT, TransformType::DCT };
-    if (tx_size == Transform_4x4) {
+    if (transform_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 };
 
 
@@ -1357,7 +1357,7 @@ DecoderErrorOr<bool> Parser::residual(BlockContext& block_context, bool has_bloc
         auto plane_subsampling_x = (plane > 0) ? block_context.frame_context.color_config.subsampling_x : 0;
         auto plane_subsampling_x = (plane > 0) ? block_context.frame_context.color_config.subsampling_x : 0;
         auto plane_subsampling_y = (plane > 0) ? block_context.frame_context.color_config.subsampling_y : 0;
         auto plane_subsampling_y = (plane > 0) ? block_context.frame_context.color_config.subsampling_y : 0;
         auto plane_size = ss_size_lookup[block_context.size < Block_8x8 ? Block_8x8 : block_context.size][plane_subsampling_x][plane_subsampling_y];
         auto plane_size = ss_size_lookup[block_context.size < Block_8x8 ? Block_8x8 : block_context.size][plane_subsampling_x][plane_subsampling_y];
-        auto transform_size = get_uv_tx_size(block_context.tx_size, plane_size);
+        auto transform_size = get_uv_transform_size(block_context.transform_size, plane_size);
         auto transform_size_in_sub_blocks = transform_size_to_sub_blocks(transform_size);
         auto transform_size_in_sub_blocks = transform_size_to_sub_blocks(transform_size);
         auto block_size_in_sub_blocks = block_size_to_sub_blocks(plane_size);
         auto block_size_in_sub_blocks = block_size_to_sub_blocks(plane_size);
 
 
@@ -1415,26 +1415,26 @@ DecoderErrorOr<bool> Parser::residual(BlockContext& block_context, bool has_bloc
     return block_had_non_zero_tokens;
     return block_had_non_zero_tokens;
 }
 }
 
 
-static u16 const* get_scan(TransformSize tx_size, TransformSet transform_set)
+static u16 const* get_scan(TransformSize transform_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 == Transform_4x4) {
+    if (transform_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 == Transform_8x8) {
+    if (transform_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 == Transform_16x16) {
+    if (transform_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)
@@ -1444,16 +1444,16 @@ static u16 const* get_scan(TransformSize tx_size, TransformSet transform_set)
     return default_scan_32x32;
     return default_scan_32x32;
 }
 }
 
 
-DecoderErrorOr<bool> Parser::tokens(BlockContext& block_context, size_t plane, u32 start_x, u32 start_y, TransformSize tx_size, TransformSet transform_set)
+DecoderErrorOr<bool> Parser::tokens(BlockContext& block_context, size_t plane, u32 start_x, u32 start_y, TransformSize transform_size, TransformSet transform_set)
 {
 {
-    u16 segment_eob = 16 << (tx_size << 1);
-    auto const* scan = get_scan(tx_size, transform_set);
+    u16 segment_eob = 16 << (transform_size << 1);
+    auto const* scan = get_scan(transform_size, transform_set);
     auto check_eob = true;
     auto check_eob = true;
     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 == 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 band = (transform_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, transform_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));
             if (!more_coefs)
             if (!more_coefs)

+ 1 - 1
Userland/Libraries/LibVideo/VP9/Parser.h

@@ -122,7 +122,7 @@ private:
     DecoderErrorOr<MotionVector> read_motion_vector(BlockContext const&, BlockMotionVectorCandidates const&, ReferenceIndex);
     DecoderErrorOr<MotionVector> read_motion_vector(BlockContext const&, BlockMotionVectorCandidates const&, ReferenceIndex);
     DecoderErrorOr<i32> read_single_motion_vector_component(u8 component);
     DecoderErrorOr<i32> read_single_motion_vector_component(u8 component);
     DecoderErrorOr<bool> residual(BlockContext&, bool has_block_above, bool has_block_left);
     DecoderErrorOr<bool> residual(BlockContext&, bool has_block_above, bool has_block_left);
-    DecoderErrorOr<bool> tokens(BlockContext&, size_t plane, u32 x, u32 y, TransformSize tx_size, TransformSet);
+    DecoderErrorOr<bool> tokens(BlockContext&, size_t plane, u32 x, u32 y, TransformSize, TransformSet);
     DecoderErrorOr<i32> read_coef(u8 bit_depth, Token token);
     DecoderErrorOr<i32> read_coef(u8 bit_depth, Token token);
 
 
     /* (6.5) Motion Vector Prediction */
     /* (6.5) Motion Vector Prediction */

+ 6 - 6
Userland/Libraries/LibVideo/VP9/TreeParser.cpp

@@ -244,9 +244,9 @@ ErrorOr<TransformSize> TreeParser::parse_tx_size(BitStream& bit_stream, Probabil
     auto above_context = max_tx_size;
     auto above_context = max_tx_size;
     auto left_context = max_tx_size;
     auto left_context = max_tx_size;
     if (above.is_available && !above.skip_coefficients)
     if (above.is_available && !above.skip_coefficients)
-        above_context = above.tx_size;
+        above_context = above.transform_size;
     if (left.is_available && !left.skip_coefficients)
     if (left.is_available && !left.skip_coefficients)
-        left_context = left.tx_size;
+        left_context = left.transform_size;
     if (!left.is_available)
     if (!left.is_available)
         left_context = above_context;
         left_context = above_context;
     if (!above.is_available)
     if (!above.is_available)
@@ -624,7 +624,7 @@ ErrorOr<bool> TreeParser::parse_motion_vector_hp(BitStream& bit_stream, Probabil
     return value;
     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], TransformSize tx_size, TransformSet transform_set, u8 plane, u32 start_x, u32 start_y, u16 position, bool is_inter, u8 band, u16 coef_index)
+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], TransformSize transform_size, TransformSet transform_set, u8 plane, u32 start_x, u32 start_y, u16 position, bool is_inter, u8 band, u16 coef_index)
 {
 {
     u8 context;
     u8 context;
     if (coef_index == 0) {
     if (coef_index == 0) {
@@ -632,7 +632,7 @@ TokensContext TreeParser::get_tokens_context(bool subsampling_x, bool subsamplin
         auto sy = plane > 0 ? subsampling_y : false;
         auto sy = plane > 0 ? subsampling_y : false;
         auto max_x = (2 * columns) >> sx;
         auto max_x = (2 * columns) >> sx;
         auto max_y = (2 * rows) >> sy;
         auto max_y = (2 * rows) >> sy;
-        u8 numpts = 1 << tx_size;
+        u8 numpts = 1 << transform_size;
         auto x4 = start_x >> 2;
         auto x4 = start_x >> 2;
         auto y4 = start_y >> 2;
         auto y4 = start_y >> 2;
         u32 above = 0;
         u32 above = 0;
@@ -646,7 +646,7 @@ TokensContext TreeParser::get_tokens_context(bool subsampling_x, bool subsamplin
         context = above + left;
         context = above + left;
     } else {
     } else {
         u32 neighbor_0, neighbor_1;
         u32 neighbor_0, neighbor_1;
-        auto n = 4 << tx_size;
+        auto n = 4 << transform_size;
         auto i = position / n;
         auto i = position / n;
         auto j = position % n;
         auto j = position % n;
         auto a = i > 0 ? (i - 1) * n + j : 0;
         auto a = i > 0 ? (i - 1) * n + j : 0;
@@ -672,7 +672,7 @@ TokensContext TreeParser::get_tokens_context(bool subsampling_x, bool subsamplin
         context = (1 + token_cache[neighbor_0] + token_cache[neighbor_1]) >> 1;
         context = (1 + token_cache[neighbor_0] + token_cache[neighbor_1]) >> 1;
     }
     }
 
 
-    return TokensContext { tx_size, plane > 0, is_inter, band, context };
+    return TokensContext { transform_size, plane > 0, is_inter, band, context };
 }
 }
 
 
 ErrorOr<bool> TreeParser::parse_more_coefficients(BitStream& bit_stream, ProbabilityTables const& probability_table, SyntaxElementCounter& counter, TokensContext const& context)
 ErrorOr<bool> TreeParser::parse_more_coefficients(BitStream& bit_stream, ProbabilityTables const& probability_table, SyntaxElementCounter& counter, TokensContext const& context)