Optimizes precalculated decoder block ptrs&offs
authorAttila Nagy <attilanagy@google.com>
Mon, 23 Apr 2012 12:20:07 +0000 (15:20 +0300)
committerAttila Nagy <attilanagy@google.com>
Mon, 23 Apr 2012 12:33:04 +0000 (15:33 +0300)
The block pointers and offset do not need to be calculated for every
frame. Block internal predictors can be update once when decoder is
allocated. Destination and previous buffer offsets have to be updated
just when frame size is changing.

Change-Id: I92ca8df0e6aaac4cc35ab890751d446760bf82e2

vp8/decoder/decodframe.c
vp8/decoder/onyxd_if.c
vp8/decoder/threading.c

index f2d58bd..4d9a0a3 100644 (file)
@@ -737,6 +737,8 @@ int vp8_decode_frame(VP8D_COMP *pbi)
     int corrupt_tokens = 0;
     int prev_independent_partitions = pbi->independent_partitions;
 
+    int frame_size_change = 0;
+
     /* start with no corruption of current frame */
     xd->corrupted = 0;
     pc->yv12_fb[pc->new_fb_idx].corrupted = 0;
@@ -840,6 +842,7 @@ int vp8_decode_frame(VP8D_COMP *pbi)
                 if (pbi->b_multithreaded_rd)
                     vp8mt_alloc_temp_buffers(pbi, pc->Width, prev_mb_rows);
 #endif
+                frame_size_change = 1;
             }
         }
     }
@@ -1103,9 +1106,17 @@ int vp8_decode_frame(VP8D_COMP *pbi)
 #endif
         vp8_setup_intra_recon(&pc->yv12_fb[pc->new_fb_idx]);
 
-    vp8_setup_block_dptrs(xd);
-
-    vp8_build_block_doffsets(xd);
+    if(frame_size_change)
+    {
+#if CONFIG_MULTITHREAD
+        for (i = 0; i < pbi->allocated_decoding_thread_count; i++)
+        {
+            pbi->mb_row_di[i].mbd.dst = pc->yv12_fb[pc->new_fb_idx];
+            vp8_build_block_doffsets(&pbi->mb_row_di[i].mbd);
+        }
+#endif
+        vp8_build_block_doffsets(&pbi->mb);
+    }
 
     /* clear out the coeff buffer */
     vpx_memset(xd->qcoeff, 0, sizeof(xd->qcoeff));
index c59ce25..d835953 100644 (file)
@@ -99,6 +99,8 @@ struct VP8D_COMP * vp8dx_create_decompressor(VP8D_CONFIG *oxcf)
      */
     pbi->independent_partitions = 0;
 
+    vp8_setup_block_dptrs(&pbi->mb);
+
     return pbi;
 }
 
index 845228b..befdbde 100644 (file)
@@ -50,8 +50,6 @@ static void setup_decoding_thread_data(VP8D_COMP *pbi, MACROBLOCKD *xd, MB_ROW_D
         mbd->pre = pc->yv12_fb[pc->lst_fb_idx];
         mbd->dst = pc->yv12_fb[pc->new_fb_idx];
 
-        vp8_setup_block_dptrs(mbd);
-        vp8_build_block_doffsets(mbd);
         mbd->segmentation_enabled    = xd->segmentation_enabled;
         mbd->mb_segement_abs_delta     = xd->mb_segement_abs_delta;
         vpx_memcpy(mbd->segment_feature_data, xd->segment_feature_data, sizeof(xd->segment_feature_data));
@@ -694,6 +692,8 @@ void vp8_decoder_create_threads(VP8D_COMP *pbi)
         {
             sem_init(&pbi->h_event_start_decoding[ithread], 0, 0);
 
+            vp8_setup_block_dptrs(&pbi->mb_row_di[ithread].mbd);
+
             pbi->de_thread_data[ithread].ithread  = ithread;
             pbi->de_thread_data[ithread].ptr1     = (void *)pbi;
             pbi->de_thread_data[ithread].ptr2     = (void *) &pbi->mb_row_di[ithread];