shithub: libvpx

Download patch

ref: bf5e9221d69eddbd77ca336c82a14a05c08e9ab8
parent: edcbbf2ee3a0acbe5162655bc128b3ac5340729a
author: Jingning Han <jingning@google.com>
date: Fri Feb 28 04:15:36 EST 2014

Fix potential invalid partition size use

For blocks at frame boundary, the selected block size sometimes needs
to be smaller than that was first given. This commit forces such block
size change only between square blocks, so as to avoid the potential
use case containing 32x16 + 16x8 + 16x8, for 1080p sequences.

Local test suggested no visible coding speed difference. Borg test
reveals no difference in terms of compression performance.

Change-Id: Ie8de87f3c6febc3acf11b4cbfdf2077f9f6def52

--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -995,7 +995,7 @@
   if (rows_left <= 0 || cols_left <= 0) {
     return MIN(bsize, BLOCK_8X8);
   } else {
-    for (; bsize > 0; --bsize) {
+    for (; bsize > 0; bsize -= 3) {
       *bh = num_8x8_blocks_high_lookup[bsize];
       *bw = num_8x8_blocks_wide_lookup[bsize];
       if ((*bh <= rows_left) && (*bw <= cols_left)) {
@@ -2332,8 +2332,6 @@
   int mis = cm->mode_info_stride;
   int br, bc;
   int i, j;
-  int chosen_rate = INT_MAX;
-  int64_t chosen_dist = INT64_MAX;
   MB_PREDICTION_MODE mode = DC_PRED;
   int rows = MIN(MI_BLOCK_SIZE, tile->mi_row_end - mi_row);
   int cols = MIN(MI_BLOCK_SIZE, tile->mi_col_end - mi_col);
@@ -2354,6 +2352,7 @@
 
       BLOCK_SIZE bs = find_partition_size(bsize, rows - br, cols - bc,
                                           &bh, &bw);
+
       set_offsets(cpi, tile, row, col, bs);
 
       if (cm->frame_type != KEY_FRAME)
@@ -2365,16 +2364,10 @@
       *dist += bdist;
 
       for (j = 0; j < bh; ++j)
-        for (i = 0; i < bw; ++i) {
+        for (i = 0; i < bw; ++i)
           xd->mi_8x8[j * mis + i] = xd->mi_8x8[0];
-        }
     }
   }
-
-  *rate = chosen_rate;
-  *dist = chosen_dist;
-
-  encode_sb_rt(cpi, tile, tp, mi_row, mi_col, 1, BLOCK_64X64);
 }
 
 static void encode_nonrd_sb_row(VP9_COMP *cpi, const TileInfo *const tile,
@@ -2397,6 +2390,7 @@
       nonrd_use_partition(cpi, tile, tp, mi_row, mi_col,
                           cpi->sf.always_this_block_size,
                           &dummy_rate, &dummy_dist);
+      encode_sb_rt(cpi, tile, tp, mi_row, mi_col, 1, BLOCK_64X64);
     } else if (cpi->sf.partition_search_type == VAR_BASED_FIXED_PARTITION ||
                cpi->sf.partition_search_type == VAR_BASED_PARTITION) {
       // TODO(debargha): Implement VAR_BASED_PARTITION as a separate case.
@@ -2407,6 +2401,7 @@
                                                              mi_col);
       nonrd_use_partition(cpi, tile, tp, mi_row, mi_col,
                           bsize, &dummy_rate, &dummy_dist);
+      encode_sb_rt(cpi, tile, tp, mi_row, mi_col, 1, BLOCK_64X64);
     } else {
       assert(0);
     }