shithub: libvpx

Download patch

ref: d7310797815c54bee0b3b98bbad8a8cbf00f18a7
parent: 38f6232118a7aebdcc062ae0a10e59a32b6fdef8
parent: 27533fa245c2ea4a8fb52ca498ed7165e28c79c5
author: Dmitry Kovalev <dkovalev@google.com>
date: Thu Apr 18 10:25:52 EDT 2013

Merge "Transforming decode_sb_row to decode_tile function." into experimental

--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -868,16 +868,18 @@
 }
 
 /* Decode a row of Superblocks (4x4 region of MBs) */
-static void decode_sb_row(VP9D_COMP *pbi, int mb_row, vp9_reader* r) {
+static void decode_tile(VP9D_COMP *pbi, vp9_reader* r) {
   VP9_COMMON *const pc = &pbi->common;
-  int mb_col;
+  int mb_row, mb_col;
 
-  // For a SB there are 2 left contexts, each pertaining to a MB row within
-  vpx_memset(pc->left_context, 0, sizeof(pc->left_context));
-
-  for (mb_col = pc->cur_tile_mb_col_start;
-       mb_col < pc->cur_tile_mb_col_end; mb_col += 4) {
-    decode_modes_sb(pbi, mb_row, mb_col, r, BLOCK_SIZE_SB64X64);
+  for (mb_row = pc->cur_tile_mb_row_start;
+       mb_row < pc->cur_tile_mb_row_end; mb_row += 4) {
+    // For a SB there are 2 left contexts, each pertaining to a MB row within
+    vpx_memset(pc->left_context, 0, sizeof(pc->left_context));
+    for (mb_col = pc->cur_tile_mb_col_start;
+         mb_col < pc->cur_tile_mb_col_end; mb_col += 4) {
+      decode_modes_sb(pbi, mb_row, mb_col, r, BLOCK_SIZE_SB64X64);
+    }
   }
 }
 
@@ -1215,8 +1217,17 @@
                                       const uint8_t *data_end,
                                       int *width, int *height) {
   if (data + 4 < data_end) {
-    *width = read_le16(data);
-    *height = read_le16(data + 2);
+    const int w = read_le16(data);
+    const int h = read_le16(data + 2);
+    if (w <= 0)
+      vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
+                         "Invalid frame width");
+
+    if (h <= 0)
+      vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
+                         "Invalid frame height");
+    *width = w;
+    *height = h;
     data += 4;
   } else {
     vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
@@ -1242,14 +1253,6 @@
   data = read_frame_size(pc, data, data_end, &width, &height);
 
   if (pc->width != width || pc->height != height) {
-    if (width <= 0)
-      vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
-                         "Invalid frame width");
-
-    if (height <= 0)
-      vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
-                         "Invalid frame height");
-
     if (!pbi->initial_width || !pbi->initial_height) {
       if (vp9_alloc_frame_buffers(pc, width, height))
         vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR,
@@ -1342,7 +1345,6 @@
 
   const uint8_t *data_ptr = data + first_partition_size;
   int tile_row, tile_col, delta_log2_tiles;
-  int mb_row;
 
   vp9_get_tile_n_bits(pc, &pc->log2_tile_columns, &delta_log2_tiles);
   while (delta_log2_tiles--) {
@@ -1388,13 +1390,7 @@
       for (tile_col = n_cols - 1; tile_col >= 0; tile_col--) {
         vp9_get_tile_col_offsets(pc, tile_col);
         setup_token_decoder(pbi, data_ptr2[tile_row][tile_col], residual_bc);
-
-        // Decode a row of superblocks
-        for (mb_row = pc->cur_tile_mb_row_start;
-             mb_row < pc->cur_tile_mb_row_end; mb_row += 4) {
-          decode_sb_row(pbi, mb_row, residual_bc);
-        }
-
+        decode_tile(pbi, residual_bc);
         if (tile_row == pc->tile_rows - 1 && tile_col == n_cols - 1)
           bc_bak = *residual_bc;
       }
@@ -1411,14 +1407,8 @@
         has_more = tile_col < pc->tile_columns - 1 ||
                    tile_row < pc->tile_rows - 1;
 
-        // Setup decoder
         setup_token_decoder(pbi, data_ptr + (has_more ? 4 : 0), residual_bc);
-
-        // Decode a row of superblocks
-        for (mb_row = pc->cur_tile_mb_row_start;
-             mb_row < pc->cur_tile_mb_row_end; mb_row += 4) {
-          decode_sb_row(pbi, mb_row, residual_bc);
-        }
+        decode_tile(pbi, residual_bc);
 
         if (has_more) {
           const int size = read_le32(data_ptr);