Make cdef block offset scalable with mode_info size

Properly map the mode_info offset to pixel offset in cdef to
support cb4x4 mode.

Change-Id: I1f876387cb327cbf6c5689a4bc5ac41a1b1b0f34
diff --git a/av1/common/od_dering.c b/av1/common/od_dering.c
index 5b4df8d..d3856fd 100644
--- a/av1/common/od_dering.c
+++ b/av1/common/od_dering.c
@@ -222,20 +222,23 @@
                                 dering_list *dlist, int dering_count,
                                 BLOCK_SIZE bsize) {
   int bi, bx, by;
+  const int mi_size_l2 = (bsize == BLOCK_8X8) ? MI_SIZE_LOG2 : MI_SIZE_LOG2 - 1;
 
   if (bsize == BLOCK_8X8) {
     for (bi = 0; bi < dering_count; bi++) {
       by = dlist[bi].by;
       bx = dlist[bi].bx;
-      copy_8x8_16bit_to_16bit(&dst[(by << 3) * dstride + (bx << 3)], dstride,
-                              &src[bi << (2 * 3)], 8);
+      copy_8x8_16bit_to_16bit(
+          &dst[(by << mi_size_l2) * dstride + (bx << mi_size_l2)], dstride,
+          &src[bi << (2 * 3)], 8);
     }
   } else {
     for (bi = 0; bi < dering_count; bi++) {
       by = dlist[bi].by;
       bx = dlist[bi].bx;
-      copy_4x4_16bit_to_16bit(&dst[(by << 2) * dstride + (bx << 2)], dstride,
-                              &src[bi << (2 * 2)], 4);
+      copy_4x4_16bit_to_16bit(
+          &dst[(by << mi_size_l2) * dstride + (bx << mi_size_l2)], dstride,
+          &src[bi << (2 * 2)], 4);
     }
   }
 }
@@ -303,6 +306,7 @@
   };
 
   int threshold = (pli ? level_table_uv : level_table)[level] << coeff_shift;
+  const int mi_size_l2 = xdec ? MI_SIZE_LOG2 - 1 : MI_SIZE_LOG2;
   od_filter_dering_direction_func filter_dering_direction[OD_DERINGSIZES] = {
     od_filter_dering_direction_4x4, od_filter_dering_direction_8x8
   };
@@ -314,7 +318,7 @@
           by = dlist[bi].by;
           bx = dlist[bi].bx;
           dir[by][bx] =
-              od_dir_find8(&in[8 * by * OD_FILT_BSTRIDE + 8 * bx],
+              od_dir_find8(&in[MI_SIZE * by * OD_FILT_BSTRIDE + MI_SIZE * bx],
                            OD_FILT_BSTRIDE, &var[by][bx], coeff_shift);
         }
         if (dirinit) *dirinit = 1;
@@ -332,7 +336,7 @@
            get removed by the directional filtering. */
         (filter_dering_direction[bsize - OD_LOG_BSIZE0])(
             &y[bi << 2 * bsize], 1 << bsize,
-            &in[(by * OD_FILT_BSTRIDE << bsize) + (bx << bsize)],
+            &in[(by * OD_FILT_BSTRIDE << mi_size_l2) + (bx << mi_size_l2)],
             od_adjust_thresh(threshold, var[by][bx]), dir[by][bx]);
       }
     } else {
@@ -341,8 +345,8 @@
         bx = dlist[bi].bx;
         (filter_dering_direction[bsize - OD_LOG_BSIZE0])(
             &y[bi << 2 * bsize], 1 << bsize,
-            &in[(by * OD_FILT_BSTRIDE << bsize) + (bx << bsize)], threshold,
-            dir[by][bx]);
+            &in[(by * OD_FILT_BSTRIDE << mi_size_l2) + (bx << mi_size_l2)],
+            threshold, dir[by][bx]);
       }
     }
   }
@@ -358,8 +362,8 @@
       (!threshold || (dir[by][bx] < 4 && dir[by][bx]) ? aom_clpf_block_hbd
                                                       : aom_clpf_hblock_hbd)(
           in, &y[((bi - by) << 2 * bsize) - (bx << bsize)], OD_FILT_BSTRIDE,
-          1 << bsize, bx << bsize, by << bsize, 1 << bsize, 1 << bsize,
-          clpf_strength << coeff_shift, clpf_damping + coeff_shift);
+          1 << bsize, bx << mi_size_l2, by << mi_size_l2, 1 << bsize,
+          1 << bsize, clpf_strength << coeff_shift, clpf_damping + coeff_shift);
     }
   }
   if (dst) {
diff --git a/av1/common/od_dering.h b/av1/common/od_dering.h
index a5a5791..062614f 100644
--- a/av1/common/od_dering.h
+++ b/av1/common/od_dering.h
@@ -18,7 +18,11 @@
 
 #define OD_DERING_SIZE_LOG2 (3)
 
+#if CONFIG_CB4X4
+#define OD_DERING_NBLOCKS (OD_BSIZE_MAX / 4)
+#else
 #define OD_DERING_NBLOCKS (OD_BSIZE_MAX / 8)
+#endif
 
 /* We need to buffer three vertical lines. */
 #define OD_FILT_VBORDER (3)