From bf5e9221d69eddbd77ca336c82a14a05c08e9ab8 Mon Sep 17 00:00:00 2001 From: Jingning Han <jingning@google.com> Date: Fri, 28 Feb 2014 09:15:36 -0800 Subject: [PATCH] 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 --- vp9/encoder/vp9_encodeframe.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 57865138df..6255a7f00e 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -995,7 +995,7 @@ static BLOCK_SIZE find_partition_size(BLOCK_SIZE bsize, 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 @@ static void nonrd_use_partition(VP9_COMP *cpi, const TileInfo *const tile, 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 @@ static void nonrd_use_partition(VP9_COMP *cpi, const TileInfo *const tile, 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 @@ static void nonrd_use_partition(VP9_COMP *cpi, const TileInfo *const tile, *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 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, const TileInfo *const tile, 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 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, const TileInfo *const tile, 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); } -- GitLab