shithub: libvpx

Download patch

ref: 673cc21dfc6f9ee19f7e3134c49ffbe9a6c0ff78
parent: 80f99632328501a3d225e12f69a3716eb9580136
author: Dmitry Kovalev <[email protected]>
date: Wed May 8 09:39:16 EDT 2013

Using loop to iterate through YV12_BUFFER_CONFIG planes.

Change-Id: I22f1066eb0022c8d75f65a78435ee4ffecdfe0c9

--- a/vp9/common/vp9_reconinter.h
+++ b/vp9/common/vp9_reconinter.h
@@ -92,18 +92,15 @@
 static void setup_dst_planes(MACROBLOCKD *xd,
                              const YV12_BUFFER_CONFIG *src,
                              int mi_row, int mi_col) {
-  setup_pred_plane(&xd->plane[0].dst,
-                   src->y_buffer, src->y_stride,
-                   mi_row, mi_col, NULL,
-                   xd->plane[0].subsampling_x, xd->plane[0].subsampling_y);
-  setup_pred_plane(&xd->plane[1].dst,
-                   src->u_buffer, src->uv_stride,
-                   mi_row, mi_col, NULL,
-                   xd->plane[1].subsampling_x, xd->plane[1].subsampling_y);
-  setup_pred_plane(&xd->plane[2].dst,
-                   src->v_buffer, src->uv_stride,
-                   mi_row, mi_col, NULL,
-                   xd->plane[2].subsampling_x, xd->plane[2].subsampling_y);
+  uint8_t *buffers[3] = {src->y_buffer, src->u_buffer, src->v_buffer};
+  int strides[3] = {src->y_stride, src->uv_stride, src->uv_stride};
+  int i;
+
+  for (i = 0; i < MAX_MB_PLANE; ++i) {
+    struct macroblockd_plane *pd = &xd->plane[i];
+    setup_pred_plane(&pd->dst, buffers[i], strides[i], mi_row, mi_col, NULL,
+                     pd->subsampling_x, pd->subsampling_y);
+  }
 }
 
 static void setup_pre_planes(MACROBLOCKD *xd,
@@ -112,26 +109,24 @@
                              int mi_row, int mi_col,
                              const struct scale_factors *scale,
                              const struct scale_factors *scale_uv) {
-  int i;
+  const YV12_BUFFER_CONFIG *srcs[2] = {src0, src1};
+  int i, j;
 
-  for (i = 0; i < 2; i++) {
-    const YV12_BUFFER_CONFIG *src = i ? src1 : src0;
+  for (i = 0; i < 2; ++i) {
+    const YV12_BUFFER_CONFIG *src = srcs[i];
+    if (src) {
+      uint8_t* buffers[3] = {src->y_buffer, src->u_buffer, src->v_buffer};
+      int strides[3] = {src->y_stride, src->uv_stride, src->uv_stride};
 
-    if (!src)
-      continue;
-
-    setup_pred_plane(&xd->plane[0].pre[i],
-                     src->y_buffer, src->y_stride,
-                     mi_row, mi_col, scale ? scale + i : NULL,
-                     xd->plane[0].subsampling_x, xd->plane[0].subsampling_y);
-    setup_pred_plane(&xd->plane[1].pre[i],
-                     src->u_buffer, src->uv_stride,
-                     mi_row, mi_col, scale_uv ? scale_uv + i : NULL,
-                     xd->plane[1].subsampling_x, xd->plane[1].subsampling_y);
-    setup_pred_plane(&xd->plane[2].pre[i],
-                     src->v_buffer, src->uv_stride,
-                     mi_row, mi_col, scale_uv ? scale_uv + i : NULL,
-                     xd->plane[2].subsampling_x, xd->plane[2].subsampling_y);
+      for (j = 0; j < MAX_MB_PLANE; ++j) {
+        struct macroblockd_plane *pd = &xd->plane[j];
+        const struct scale_factors *sf = j ? scale_uv : scale;
+        setup_pred_plane(&pd->pre[i],
+                         buffers[j], strides[j],
+                         mi_row, mi_col, sf ? &sf[i] : NULL,
+                         pd->subsampling_x, pd->subsampling_y);
+      }
+    }
   }
 }