Browse Source

LibVideo/VP9: Change fields within decode_partition() to variables

Zaggy1024 2 years ago
parent
commit
9b6ab1d4e5
2 changed files with 28 additions and 38 deletions
  1. 27 30
      Userland/Libraries/LibVideo/VP9/Parser.cpp
  2. 1 8
      Userland/Libraries/LibVideo/VP9/Parser.h

+ 27 - 30
Userland/Libraries/LibVideo/VP9/Parser.cpp

@@ -908,41 +908,38 @@ void Parser::clear_left_context()
     clear_context(m_left_partition_context, m_sb64_rows * 8);
 }
 
-DecoderErrorOr<void> Parser::decode_partition(u32 row, u32 col, BlockSubsize block_subsize)
+DecoderErrorOr<void> Parser::decode_partition(u32 row, u32 column, BlockSubsize subsize)
 {
-    if (row >= m_mi_rows || col >= m_mi_cols)
+    if (row >= m_mi_rows || column >= m_mi_cols)
         return {};
-    m_block_subsize = block_subsize;
-    m_num_8x8 = num_8x8_blocks_wide_lookup[block_subsize];
-    auto half_block_8x8 = m_num_8x8 >> 1;
-    m_has_rows = (row + half_block_8x8) < m_mi_rows;
-    m_has_cols = (col + half_block_8x8) < m_mi_cols;
-    m_row = row;
-    m_col = col;
-    auto partition = TRY_READ(TreeParser::parse_partition(*m_bit_stream, *m_probability_tables, *m_syntax_element_counter, m_has_rows, m_has_cols, m_block_subsize, m_num_8x8, m_above_partition_context, m_left_partition_context, row, col, m_frame_is_intra));
-
-    auto subsize = subsize_lookup[partition][block_subsize];
-    if (subsize < Block_8x8 || partition == PartitionNone) {
-        TRY(decode_block(row, col, subsize));
+    u8 num_8x8 = num_8x8_blocks_wide_lookup[subsize];
+    auto half_block_8x8 = num_8x8 >> 1;
+    bool has_rows = (row + half_block_8x8) < m_mi_rows;
+    bool has_cols = (column + half_block_8x8) < m_mi_cols;
+    auto partition = TRY_READ(TreeParser::parse_partition(*m_bit_stream, *m_probability_tables, *m_syntax_element_counter, has_rows, has_cols, subsize, num_8x8, m_above_partition_context, m_left_partition_context, row, column, m_frame_is_intra));
+
+    auto child_subsize = subsize_lookup[partition][subsize];
+    if (child_subsize < Block_8x8 || partition == PartitionNone) {
+        TRY(decode_block(row, column, child_subsize));
     } else if (partition == PartitionHorizontal) {
-        TRY(decode_block(row, col, subsize));
-        if (m_has_rows)
-            TRY(decode_block(row + half_block_8x8, col, subsize));
+        TRY(decode_block(row, column, child_subsize));
+        if (has_rows)
+            TRY(decode_block(row + half_block_8x8, column, child_subsize));
     } else if (partition == PartitionVertical) {
-        TRY(decode_block(row, col, subsize));
-        if (m_has_cols)
-            TRY(decode_block(row, col + half_block_8x8, subsize));
+        TRY(decode_block(row, column, child_subsize));
+        if (has_cols)
+            TRY(decode_block(row, column + half_block_8x8, child_subsize));
     } else {
-        TRY(decode_partition(row, col, subsize));
-        TRY(decode_partition(row, col + half_block_8x8, subsize));
-        TRY(decode_partition(row + half_block_8x8, col, subsize));
-        TRY(decode_partition(row + half_block_8x8, col + half_block_8x8, subsize));
-    }
-    if (block_subsize == Block_8x8 || partition != PartitionSplit) {
-        auto above_context = 15 >> b_width_log2_lookup[subsize];
-        auto left_context = 15 >> b_height_log2_lookup[subsize];
-        for (size_t i = 0; i < m_num_8x8; i++) {
-            m_above_partition_context[col + i] = above_context;
+        TRY(decode_partition(row, column, child_subsize));
+        TRY(decode_partition(row, column + half_block_8x8, child_subsize));
+        TRY(decode_partition(row + half_block_8x8, column, child_subsize));
+        TRY(decode_partition(row + half_block_8x8, column + half_block_8x8, child_subsize));
+    }
+    if (subsize == Block_8x8 || partition != PartitionSplit) {
+        auto above_context = 15 >> b_width_log2_lookup[child_subsize];
+        auto left_context = 15 >> b_height_log2_lookup[child_subsize];
+        for (size_t i = 0; i < num_8x8; i++) {
+            m_above_partition_context[column + i] = above_context;
             m_left_partition_context[row + i] = left_context;
         }
     }

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

@@ -104,7 +104,7 @@ private:
     u32 get_tile_offset(u32 tile_num, u32 mis, u32 tile_size_log2);
     DecoderErrorOr<void> decode_tile();
     void clear_left_context();
-    DecoderErrorOr<void> decode_partition(u32 row, u32 col, BlockSubsize block_subsize);
+    DecoderErrorOr<void> decode_partition(u32 row, u32 column, BlockSubsize subsize);
     DecoderErrorOr<void> decode_block(u32 row, u32 col, BlockSubsize subsize);
     DecoderErrorOr<void> mode_info();
     DecoderErrorOr<void> intra_frame_mode_info();
@@ -224,15 +224,8 @@ private:
     //
     // skip may be set to 0 even if transform blocks contain immediate end of block markers.
     bool m_skip { false };
-    u8 m_num_8x8 { 0 };
-    bool m_has_rows { false };
-    bool m_has_cols { false };
     TXSize m_max_tx_size { TX_4x4 };
     BlockSubsize m_block_subsize { BlockSubsize::Block_4x4 };
-    // The row to use for getting partition tree probability lookups.
-    u32 m_row { 0 };
-    // The column to use for getting partition tree probability lookups.
-    u32 m_col { 0 };
     TXSize m_tx_size { TX_4x4 };
     ReferenceFramePair m_ref_frame;
     bool m_is_inter { false };