shithub: libvpx

Download patch

ref: e6509742028631e4a02014cf6fc684eebf39c5d8
parent: 5fb8d15a12a0b45a04940fb7fea5070cfdea687e
author: Jingning Han <jingning@google.com>
date: Mon Jul 23 10:02:29 EDT 2018

Refactor overlap area computation

Account for the variable operating block sizes.

Change-Id: I4eac4d0b84cf55fbf5c693007c991afe6171ca6a

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -5627,25 +5627,28 @@
 }
 
 int get_overlap_area(int grid_pos_row, int grid_pos_col, int ref_pos_row,
-                     int ref_pos_col, int block) {
+                     int ref_pos_col, int block, BLOCK_SIZE bsize) {
   int overlap_area;
   int width = 0, height = 0;
+  int bw = 4 << b_width_log2_lookup[bsize];
+  int bh = 4 << b_height_log2_lookup[bsize];
+
   switch (block) {
     case 0:
-      width = grid_pos_col + 4 * MI_SIZE - ref_pos_col;
-      height = grid_pos_row + 4 * MI_SIZE - ref_pos_row;
+      width = grid_pos_col + bw - ref_pos_col;
+      height = grid_pos_row + bh - ref_pos_row;
       break;
     case 1:
-      width = ref_pos_col + 4 * MI_SIZE - grid_pos_col;
-      height = grid_pos_row + 4 * MI_SIZE - ref_pos_row;
+      width = ref_pos_col + bw - grid_pos_col;
+      height = grid_pos_row + bh - ref_pos_row;
       break;
     case 2:
-      width = grid_pos_col + 4 * MI_SIZE - ref_pos_col;
-      height = ref_pos_row + 4 * MI_SIZE - grid_pos_row;
+      width = grid_pos_col + bw - ref_pos_col;
+      height = ref_pos_row + bh - grid_pos_row;
       break;
     case 3:
-      width = ref_pos_col + 4 * MI_SIZE - grid_pos_col;
-      height = ref_pos_row + 4 * MI_SIZE - grid_pos_row;
+      width = ref_pos_col + bw - grid_pos_col;
+      height = ref_pos_row + bh - grid_pos_row;
       break;
     default: assert(0);
   }
@@ -5691,8 +5694,8 @@
 
     if (grid_pos_row >= 0 && grid_pos_row < ref_tpl_frame->mi_rows * MI_SIZE &&
         grid_pos_col >= 0 && grid_pos_col < ref_tpl_frame->mi_cols * MI_SIZE) {
-      int overlap_area = get_overlap_area(grid_pos_row, grid_pos_col,
-                                          ref_pos_row, ref_pos_col, block);
+      int overlap_area = get_overlap_area(
+          grid_pos_row, grid_pos_col, ref_pos_row, ref_pos_col, block, bsize);
       int ref_mi_row = round_floor(grid_pos_row, bh) * mi_height;
       int ref_mi_col = round_floor(grid_pos_col, bw) * mi_width;