shithub: libvpx

Download patch

ref: 20760254f6ec5990add6349308343fab0d86df50
parent: c08317e4f23776be898bfd2f56f8171c64e0960f
parent: 71701f3d40fb64a21420d0e0c15d4c204f5963cb
author: Ronald S. Bultje <rbultje@google.com>
date: Sat Jun 8 13:39:41 EDT 2013

Merge "Align frame size to 8 instead of 16." into experimental

--- a/vp9/common/vp9_alloccommon.c
+++ b/vp9/common/vp9_alloccommon.c
@@ -68,8 +68,8 @@
 }
 
 static void set_mb_mi(VP9_COMMON *cm, int aligned_width, int aligned_height) {
-  cm->mb_cols = aligned_width >> 4;
-  cm->mb_rows = aligned_height >> 4;
+  cm->mb_cols = (aligned_width + 8) >> 4;
+  cm->mb_rows = (aligned_height + 8) >> 4;
   cm->MBs = cm->mb_rows * cm->mb_cols;
 
   cm->mi_cols = aligned_width >> LOG2_MI_SIZE;
@@ -95,8 +95,8 @@
   int i, mi_cols;
 
   // Our internal buffers are always multiples of 16
-  const int aligned_width = multiple16(width);
-  const int aligned_height = multiple16(height);
+  const int aligned_width = multiple8(width);
+  const int aligned_height = multiple8(height);
   const int ss_x = oci->subsampling_x;
   const int ss_y = oci->subsampling_y;
 
@@ -224,8 +224,8 @@
 }
 
 void vp9_update_frame_size(VP9_COMMON *cm) {
-  const int aligned_width = multiple16(cm->width);
-  const int aligned_height = multiple16(cm->height);
+  const int aligned_width = multiple8(cm->width);
+  const int aligned_height = multiple8(cm->height);
 
   set_mb_mi(cm, aligned_width, aligned_height);
   setup_mi(cm);
--- a/vp9/common/vp9_common.h
+++ b/vp9/common/vp9_common.h
@@ -56,8 +56,8 @@
   return value < low ? low : (value > high ? high : value);
 }
 
-static INLINE int multiple16(int value) {
-  return (value + 15) & ~15;
+static INLINE int multiple8(int value) {
+  return (value + 7) & ~7;
 }
 
 #define SYNC_CODE_0 0x49
--- a/vp9/common/vp9_loopfilter.c
+++ b/vp9/common/vp9_loopfilter.c
@@ -180,6 +180,7 @@
 static void lpf_mb(VP9_COMMON *cm, const MODE_INFO *mi,
                    int do_left_mb_v, int do_above_mb_h,
                    int do_left_mbuv_v, int do_above_mbuv_h,
+                   int mb_row, int mb_col,
                    uint8_t *y_ptr, uint8_t *u_ptr, uint8_t *v_ptr,
                    int y_stride, int uv_stride) {
   loop_filter_info_n *lfi_n = &cm->lf_info;
@@ -209,7 +210,7 @@
         vp9_loop_filter_mbh(y_ptr, u_ptr, v_ptr, y_stride, uv_stride, &lfi);
     }
 
-    if (!skip_lf) {
+    if (!skip_lf && mb_row * 2 + 1 < cm->mi_rows) {
       if (tx_size >= TX_8X8) {
         if (tx_size == TX_8X8 &&
             mi->mbmi.sb_type < BLOCK_SIZE_MB16X16)
@@ -234,7 +235,7 @@
         vp9_loop_filter_mbv(y_ptr, u_ptr, v_ptr, y_stride, uv_stride, &lfi);
     }
 
-    if (!skip_lf) {
+    if (!skip_lf && mb_col * 2 + 1 < cm->mi_cols) {
       if (tx_size >= TX_8X8) {
         if (tx_size == TX_8X8 &&
             mi->mbmi.sb_type < BLOCK_SIZE_MB16X16)
@@ -274,6 +275,7 @@
       tx_size >= TX_32X32 && (mb_row & 2));
   lpf_mb(cm, mi, do_left_v, do_above_h,
       do_left_v_mbuv, do_above_h_mbuv,
+      mb_row, mb_col,
       y_ptr,
       y_only? 0 : u_ptr,
       y_only? 0 : v_ptr,
@@ -289,6 +291,7 @@
       tx_size >= TX_32X32 && (mb_row & 2));
   lpf_mb(cm, mi, do_left_v, do_above_h,
       do_left_v_mbuv, do_above_h_mbuv,
+      mb_row, mb_col + 1,
       y_ptr + 16,
       y_only ? 0 : (u_ptr + 8),
       y_only ? 0 : (v_ptr + 8),
@@ -305,6 +308,7 @@
       sb_mb_lf_skip(mode_info_context, mi)));
   lpf_mb(cm, mi, do_left_v, do_above_h,
       do_left_v_mbuv, do_above_h_mbuv,
+      mb_row + 1, mb_col,
       y_ptr + 16 * y_stride,
       y_only ? 0 : (u_ptr + 8 * uv_stride),
       y_only ? 0 : (v_ptr + 8 * uv_stride),
@@ -322,6 +326,7 @@
       sb_mb_lf_skip(mode_info_context + 2, mi)));
   lpf_mb(cm, mi, do_left_v, do_above_h,
       do_left_v_mbuv, do_above_h_mbuv,
+      mb_row + 1, mb_col + 1,
       y_ptr + 16 * y_stride + 16,
       y_only ? 0 : (u_ptr + 8 * uv_stride + 8),
       y_only ? 0 : (v_ptr + 8 * uv_stride + 8),
@@ -444,6 +449,7 @@
         do_above_h_mbuv = 1;
         lpf_mb(cm, mi, do_left_v, do_above_h,
                do_left_v_mbuv, do_above_h_mbuv,
+               mb_row + k, mb_col,
                y_ptr + (k * 16) * y_stride,
                y_only ? 0 : (u_ptr + (k * 8) * uv_stride),
                y_only ? 0 : (v_ptr + (k * 8) * uv_stride),
@@ -456,13 +462,13 @@
       mode_info_context += 2;       // step to next MB
     }
     // move pointers to the begining of next sb64 row
-    y_ptr += y_stride  * 64 - post->y_width;
+    y_ptr += y_stride  * 64 - cm->mb_cols * 16;
     if (!y_only) {
-      u_ptr += uv_stride *  32 - post->uv_width;
-      v_ptr += uv_stride *  32 - post->uv_width;
+      u_ptr += uv_stride *  32 - cm->mb_cols * 8;
+      v_ptr += uv_stride *  32 - cm->mb_cols * 8;
     }
     /* skip to next SB64 row */
-    mode_info_context += mis * 8 - cm->mi_cols;
+    mode_info_context += mis * 8 - cm->mb_cols * 2;
   }
   if (extra_sb32_row) {
     const int sb32_cols = sb64_cols * 2 + extra_sb32_col;
@@ -484,6 +490,7 @@
       do_above_h_mbuv = 1;
       lpf_mb(cm, mi, do_left_v, do_above_h,
              do_left_v_mbuv, do_above_h_mbuv,
+             mb_row, mb_col,
              y_ptr,
              y_only? NULL : u_ptr,
              y_only? NULL : v_ptr,
@@ -496,6 +503,7 @@
       do_above_h_mbuv = 1;
       lpf_mb(cm, mi, do_left_v, do_above_h,
              do_left_v_mbuv, do_above_h_mbuv,
+             mb_row + 1, mb_col,
              y_ptr + 16 * y_stride,
              y_only ? NULL : (u_ptr + 8 * uv_stride),
              y_only ? NULL : (v_ptr + 8 * uv_stride),
@@ -506,11 +514,11 @@
       mode_info_context += 2;       /* step to next MB */
     }
     // move pointers to the beginning of next sb64 row
-    y_ptr += y_stride * 32 - post->y_width;
-    u_ptr += y_only? 0 : uv_stride *  16 - post->uv_width;
-    v_ptr += y_only? 0 : uv_stride *  16 - post->uv_width;
+    y_ptr += y_stride * 32 - cm->mb_cols * 16;
+    u_ptr += y_only? 0 : uv_stride *  16 - cm->mb_cols * 8;
+    v_ptr += y_only? 0 : uv_stride *  16 - cm->mb_cols * 8;
     // skip to next MB row if exist
-    mode_info_context += mis * 4 - cm->mi_cols;
+    mode_info_context += mis * 4 - cm->mb_cols * 2;
     mb_row += 2;
   }
   if (extra_mb_row) {
@@ -522,6 +530,7 @@
       do_above_h_mbuv = 1;
       lpf_mb(cm, mi, do_left_v, do_above_h,
              do_left_v_mbuv, do_above_h_mbuv,
+             mb_row, mb_col,
              y_ptr,
              y_only? 0 : u_ptr,
              y_only? 0 : v_ptr,
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -2369,8 +2369,8 @@
   int64_t mcomp_filter_cost[4];
 
   /* Scale the source buffer, if required */
-  if (cm->mb_cols * 16 != cpi->un_scaled_source->y_width ||
-      cm->mb_rows * 16 != cpi->un_scaled_source->y_height) {
+  if (cm->mi_cols * 8 != cpi->un_scaled_source->y_width ||
+      cm->mi_rows * 8 != cpi->un_scaled_source->y_height) {
     scale_and_extend_frame(cpi->un_scaled_source, &cpi->scaled_source);
     cpi->Source = &cpi->scaled_source;
   } else {
--- a/vp9/vp9_iface_common.h
+++ b/vp9/vp9_iface_common.h
@@ -29,7 +29,7 @@
     img->fmt = VPX_IMG_FMT_I420;
   }
   img->w = yv12->y_stride;
-  img->h = multiple16(yv12->y_height + 2 * VP9BORDERINPIXELS);
+  img->h = multiple8(yv12->y_height + 2 * VP9BORDERINPIXELS);
   img->d_w = yv12->y_crop_width;
   img->d_h = yv12->y_crop_height;
   img->x_chroma_shift = yv12->uv_width < yv12->y_width;
--- a/vpx_scale/generic/yv12config.c
+++ b/vpx_scale/generic/yv12config.c
@@ -125,8 +125,8 @@
                              int width, int height,
                              int ss_x, int ss_y, int border) {
   if (ybf) {
-    const int aligned_width = (width + 15) & ~15;
-    const int aligned_height = (height + 15) & ~15;
+    const int aligned_width = (width + 7) & ~7;
+    const int aligned_height = (height + 7) & ~7;
     const int y_stride = ((aligned_width + 2 * border) + 31) & ~31;
     const int yplane_size = (aligned_height + 2 * border) * y_stride;
     const int uv_width = aligned_width >> ss_x;
--