shithub: libvpx

Download patch

ref: fbf2ac111e2bf104cefe6080e822c626f65753f2
parent: 2c4f616a6183e9d2ff0fcb2dabd3b111c2bae4d3
author: Ronald S. Bultje <rbultje@google.com>
date: Thu Oct 25 08:05:37 EDT 2012

Fix 4x4 intra prediction on the edge of SB rows.

Change-Id: I87d571008c73f0a8514e0a864405aadb82fd1bc0

--- a/vp8/common/reconintra4x4.c
+++ b/vp8/common/reconintra4x4.c
@@ -295,7 +295,7 @@
 /* copy 4 bytes from the above right down so that the 4x4 prediction modes using pixels above and
  * to the right prediction have filled in pixels to use.
  */
-void vp8_intra_prediction_down_copy(MACROBLOCKD *xd) {
+void vp8_intra_prediction_down_copy(MACROBLOCKD *xd, int extend_edge) {
   unsigned char *above_right = *(xd->block[0].base_dst) + xd->block[0].dst -
                                xd->block[0].dst_stride + 16;
   unsigned int *src_ptr = (unsigned int *)
@@ -308,6 +308,10 @@
     (unsigned int *)(above_right + 8 * xd->block[0].dst_stride);
   unsigned int *dst_ptr3 =
     (unsigned int *)(above_right + 12 * xd->block[0].dst_stride);
+
+  if (extend_edge) {
+    *src_ptr = ((uint8_t *) src_ptr)[-1] * 0x01010101U;
+  }
 
   *dst_ptr0 = *src_ptr;
   *dst_ptr1 = *src_ptr;
--- a/vp8/common/reconintra4x4.h
+++ b/vp8/common/reconintra4x4.h
@@ -12,6 +12,6 @@
 #ifndef __INC_RECONINTRA4x4_H
 #define __INC_RECONINTRA4x4_H
 
-extern void vp8_intra_prediction_down_copy(MACROBLOCKD *xd);
+extern void vp8_intra_prediction_down_copy(MACROBLOCKD *xd, int extend_edge);
 
 #endif
--- a/vp8/decoder/decodframe.c
+++ b/vp8/decoder/decodframe.c
@@ -202,7 +202,7 @@
 }
 
 static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd,
-                              unsigned int mb_col,
+                              int mb_row, unsigned int mb_col,
                               BOOL_DECODER* const bc) {
   int eobtotal = 0;
   MB_PREDICTION_MODE mode;
@@ -209,8 +209,8 @@
   int i;
   int tx_size;
   TX_TYPE tx_type;
-#if CONFIG_SUPERBLOCKS
   VP8_COMMON *pc = &pbi->common;
+#if CONFIG_SUPERBLOCKS
   int orig_skip_flag = xd->mode_info_context->mbmi.mb_skip_coeff;
 #endif
 
@@ -355,7 +355,8 @@
                                               b->dst_stride);
     }
   } else if (mode == B_PRED) {
-    vp8_intra_prediction_down_copy(xd);
+    vp8_intra_prediction_down_copy(xd, mb_col == pc->mb_cols - 1 &&
+                                       !(mb_row & 1));
     for (i = 0; i < 16; i++) {
       BLOCKD *b = &xd->block[i];
       int b_mode = xd->mode_info_context->bmi[i].as_mode.first;
@@ -659,7 +660,7 @@
         mi[pc->mode_info_stride + 1] = mi[0];
       }
 #endif
-      decode_macroblock(pbi, xd, mb_col, bc);
+      decode_macroblock(pbi, xd, mb_row, mb_col, bc);
 #if CONFIG_SUPERBLOCKS
       if (xd->mode_info_context->mbmi.encoded_as_sb) {
         mi[1].mbmi.txfm_size = mi[0].mbmi.txfm_size;
--- a/vp8/encoder/encodeframe.c
+++ b/vp8/encoder/encodeframe.c
@@ -19,6 +19,7 @@
 #include "vp8/common/quant_common.h"
 #include "segmentation.h"
 #include "vp8/common/setupintrarecon.h"
+#include "vp8/common/reconintra4x4.h"
 #include "encodeintra.h"
 #include "vp8/common/reconinter.h"
 #include "vp8/common/invtrans.h"
@@ -614,6 +615,9 @@
 
     cpi->update_context = 0;    // TODO Do we need this now??
 
+    vp8_intra_prediction_down_copy(xd, mb_col == cm->mb_cols - 1 &&
+                                       (mb_row & 1) == 0);
+
     // Find best coding mode & reconstruct the MB so it is available
     // as a predictor for MBs that follow in the SB
     if (cm->frame_type == KEY_FRAME) {
@@ -1911,7 +1915,6 @@
     vp8_encode_intra8x8mby(IF_RTCD(&cpi->rtcd), x);
     vp8_encode_intra8x8mbuv(IF_RTCD(&cpi->rtcd), x);
   } else if (mbmi->mode == B_PRED) {
-    vp8_intra_prediction_down_copy(&x->e_mbd);
     vp8_encode_intra4x4mby(IF_RTCD(&cpi->rtcd), x);
   } else {
     vp8_encode_intra16x16mby(IF_RTCD(&cpi->rtcd), x);
@@ -2009,7 +2012,6 @@
 
   if (mbmi->ref_frame == INTRA_FRAME) {
     if (mbmi->mode == B_PRED) {
-      vp8_intra_prediction_down_copy(xd);
       vp8_encode_intra16x16mbuv(IF_RTCD(&cpi->rtcd), x);
       vp8_encode_intra4x4mby(IF_RTCD(&cpi->rtcd), x);
     } else if (mbmi->mode == I8X8_PRED) {
--- a/vp8/encoder/rdopt.c
+++ b/vp8/encoder/rdopt.c
@@ -1212,8 +1212,6 @@
   xd->mode_info_context->mbmi.mode = B_PRED;
   bmode_costs = mb->inter_bmode_costs;
 
-  vp8_intra_prediction_down_copy(xd);
-
   for (i = 0; i < 16; i++) {
     MODE_INFO *const mic = xd->mode_info_context;
     const int mis = xd->mode_info_stride;