Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: source/libvpx/vp9/common/vp9_reconintra.c

Issue 1169543007: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/libvpx/vp9/common/vp9_onyxc_int.h ('k') | source/libvpx/vp9/common/vp9_rtcd_defs.pl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/libvpx/vp9/common/vp9_reconintra.c
diff --git a/source/libvpx/vp9/common/vp9_reconintra.c b/source/libvpx/vp9/common/vp9_reconintra.c
index 07e5acf0fd6985e4f048beca2358fa55d9225cf9..3312f2977308e3a3d2078286a0443c2b0e5a9db5 100644
--- a/source/libvpx/vp9/common/vp9_reconintra.c
+++ b/source/libvpx/vp9/common/vp9_reconintra.c
@@ -79,6 +79,15 @@ static const uint8_t extend_modes[INTRA_MODES] = {
intra_pred_highbd_sized(type, 16) \
intra_pred_highbd_sized(type, 32)
+#define intra_pred_no_4x4(type) \
+ intra_pred_sized(type, 8) \
+ intra_pred_sized(type, 16) \
+ intra_pred_sized(type, 32) \
+ intra_pred_highbd_sized(type, 4) \
+ intra_pred_highbd_sized(type, 8) \
+ intra_pred_highbd_sized(type, 16) \
+ intra_pred_highbd_sized(type, 32)
+
#else
#define intra_pred_allsizes(type) \
@@ -86,8 +95,17 @@ static const uint8_t extend_modes[INTRA_MODES] = {
intra_pred_sized(type, 8) \
intra_pred_sized(type, 16) \
intra_pred_sized(type, 32)
+
+#define intra_pred_no_4x4(type) \
+ intra_pred_sized(type, 8) \
+ intra_pred_sized(type, 16) \
+ intra_pred_sized(type, 32)
#endif // CONFIG_VP9_HIGHBITDEPTH
+#define DST(x, y) dst[(x) + (y) * stride]
+#define AVG3(a, b, c) (((a) + 2 * (b) + (c) + 2) >> 2)
+#define AVG2(a, b) (((a) + (b) + 1) >> 1)
+
#if CONFIG_VP9_HIGHBITDEPTH
static INLINE void highbd_d207_predictor(uint16_t *dst, ptrdiff_t stride,
int bs, const uint16_t *above,
@@ -98,18 +116,16 @@ static INLINE void highbd_d207_predictor(uint16_t *dst, ptrdiff_t stride,
// First column.
for (r = 0; r < bs - 1; ++r) {
- dst[r * stride] = ROUND_POWER_OF_TWO(left[r] + left[r + 1], 1);
+ dst[r * stride] = AVG2(left[r], left[r + 1]);
}
dst[(bs - 1) * stride] = left[bs - 1];
dst++;
// Second column.
for (r = 0; r < bs - 2; ++r) {
- dst[r * stride] = ROUND_POWER_OF_TWO(left[r] + left[r + 1] * 2 +
- left[r + 2], 2);
+ dst[r * stride] = AVG3(left[r], left[r + 1], left[r + 2]);
}
- dst[(bs - 2) * stride] = ROUND_POWER_OF_TWO(left[bs - 2] +
- left[bs - 1] * 3, 2);
+ dst[(bs - 2) * stride] = AVG3(left[bs - 2], left[bs - 1], left[bs - 1]);
dst[(bs - 1) * stride] = left[bs - 1];
dst++;
@@ -131,11 +147,9 @@ static INLINE void highbd_d63_predictor(uint16_t *dst, ptrdiff_t stride,
(void) bd;
for (r = 0; r < bs; ++r) {
for (c = 0; c < bs; ++c) {
- dst[c] = r & 1 ? ROUND_POWER_OF_TWO(above[r/2 + c] +
- above[r/2 + c + 1] * 2 +
- above[r/2 + c + 2], 2)
- : ROUND_POWER_OF_TWO(above[r/2 + c] +
- above[r/2 + c + 1], 1);
+ dst[c] = r & 1 ? AVG3(above[(r >> 1) + c], above[(r >> 1) + c + 1],
+ above[(r >> 1) + c + 2])
+ : AVG2(above[(r >> 1) + c], above[(r >> 1) + c + 1]);
}
dst += stride;
}
@@ -149,9 +163,8 @@ static INLINE void highbd_d45_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
(void) bd;
for (r = 0; r < bs; ++r) {
for (c = 0; c < bs; ++c) {
- dst[c] = r + c + 2 < bs * 2 ? ROUND_POWER_OF_TWO(above[r + c] +
- above[r + c + 1] * 2 +
- above[r + c + 2], 2)
+ dst[c] = r + c + 2 < bs * 2 ? AVG3(above[r + c], above[r + c + 1],
+ above[r + c + 2])
: above[bs * 2 - 1];
}
dst += stride;
@@ -166,20 +179,19 @@ static INLINE void highbd_d117_predictor(uint16_t *dst, ptrdiff_t stride,
// first row
for (c = 0; c < bs; c++)
- dst[c] = ROUND_POWER_OF_TWO(above[c - 1] + above[c], 1);
+ dst[c] = AVG2(above[c - 1], above[c]);
dst += stride;
// second row
- dst[0] = ROUND_POWER_OF_TWO(left[0] + above[-1] * 2 + above[0], 2);
+ dst[0] = AVG3(left[0], above[-1], above[0]);
for (c = 1; c < bs; c++)
- dst[c] = ROUND_POWER_OF_TWO(above[c - 2] + above[c - 1] * 2 + above[c], 2);
+ dst[c] = AVG3(above[c - 2], above[c - 1], above[c]);
dst += stride;
// the rest of first col
- dst[0] = ROUND_POWER_OF_TWO(above[-1] + left[0] * 2 + left[1], 2);
+ dst[0] = AVG3(above[-1], left[0], left[1]);
for (r = 3; r < bs; ++r)
- dst[(r - 2) * stride] = ROUND_POWER_OF_TWO(left[r - 3] + left[r - 2] * 2 +
- left[r - 1], 2);
+ dst[(r - 2) * stride] = AVG3(left[r - 3], left[r - 2], left[r - 1]);
// the rest of the block
for (r = 2; r < bs; ++r) {
@@ -194,14 +206,13 @@ static INLINE void highbd_d135_predictor(uint16_t *dst, ptrdiff_t stride,
const uint16_t *left, int bd) {
int r, c;
(void) bd;
- dst[0] = ROUND_POWER_OF_TWO(left[0] + above[-1] * 2 + above[0], 2);
+ dst[0] = AVG3(left[0], above[-1], above[0]);
for (c = 1; c < bs; c++)
- dst[c] = ROUND_POWER_OF_TWO(above[c - 2] + above[c - 1] * 2 + above[c], 2);
+ dst[c] = AVG3(above[c - 2], above[c - 1], above[c]);
- dst[stride] = ROUND_POWER_OF_TWO(above[-1] + left[0] * 2 + left[1], 2);
+ dst[stride] = AVG3(above[-1], left[0], left[1]);
for (r = 2; r < bs; ++r)
- dst[r * stride] = ROUND_POWER_OF_TWO(left[r - 2] + left[r - 1] * 2 +
- left[r], 2);
+ dst[r * stride] = AVG3(left[r - 2], left[r - 1], left[r]);
dst += stride;
for (r = 1; r < bs; ++r) {
@@ -216,20 +227,19 @@ static INLINE void highbd_d153_predictor(uint16_t *dst, ptrdiff_t stride,
const uint16_t *left, int bd) {
int r, c;
(void) bd;
- dst[0] = ROUND_POWER_OF_TWO(above[-1] + left[0], 1);
+ dst[0] = AVG2(above[-1], left[0]);
for (r = 1; r < bs; r++)
- dst[r * stride] = ROUND_POWER_OF_TWO(left[r - 1] + left[r], 1);
+ dst[r * stride] = AVG2(left[r - 1], left[r]);
dst++;
- dst[0] = ROUND_POWER_OF_TWO(left[0] + above[-1] * 2 + above[0], 2);
- dst[stride] = ROUND_POWER_OF_TWO(above[-1] + left[0] * 2 + left[1], 2);
+ dst[0] = AVG3(left[0], above[-1], above[0]);
+ dst[stride] = AVG3(above[-1], left[0], left[1]);
for (r = 2; r < bs; r++)
- dst[r * stride] = ROUND_POWER_OF_TWO(left[r - 2] + left[r - 1] * 2 +
- left[r], 2);
+ dst[r * stride] = AVG3(left[r - 2], left[r - 1], left[r]);
dst++;
for (c = 0; c < bs - 2; c++)
- dst[c] = ROUND_POWER_OF_TWO(above[c - 1] + above[c] * 2 + above[c + 1], 2);
+ dst[c] = AVG3(above[c - 1], above[c], above[c + 1]);
dst += stride;
for (r = 1; r < bs; ++r) {
@@ -345,22 +355,37 @@ static INLINE void highbd_dc_predictor(uint16_t *dst, ptrdiff_t stride,
}
#endif // CONFIG_VP9_HIGHBITDEPTH
+void vp9_d207_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
+ const uint8_t *above, const uint8_t *left) {
+ const int I = left[0];
+ const int J = left[1];
+ const int K = left[2];
+ const int L = left[3];
+ (void)above;
+ DST(0, 0) = AVG2(I, J);
+ DST(2, 0) = DST(0, 1) = AVG2(J, K);
+ DST(2, 1) = DST(0, 2) = AVG2(K, L);
+ DST(1, 0) = AVG3(I, J, K);
+ DST(3, 0) = DST(1, 1) = AVG3(J, K, L);
+ DST(3, 1) = DST(1, 2) = AVG3(K, L, L);
+ DST(3, 2) = DST(2, 2) =
+ DST(0, 3) = DST(1, 3) = DST(2, 3) = DST(3, 3) = L;
+}
+
static INLINE void d207_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
const uint8_t *above, const uint8_t *left) {
int r, c;
(void) above;
// first column
for (r = 0; r < bs - 1; ++r)
- dst[r * stride] = ROUND_POWER_OF_TWO(left[r] + left[r + 1], 1);
+ dst[r * stride] = AVG2(left[r], left[r + 1]);
dst[(bs - 1) * stride] = left[bs - 1];
dst++;
// second column
for (r = 0; r < bs - 2; ++r)
- dst[r * stride] = ROUND_POWER_OF_TWO(left[r] + left[r + 1] * 2 +
- left[r + 2], 2);
- dst[(bs - 2) * stride] = ROUND_POWER_OF_TWO(left[bs - 2] +
- left[bs - 1] * 3, 2);
+ dst[r * stride] = AVG3(left[r], left[r + 1], left[r + 2]);
+ dst[(bs - 2) * stride] = AVG3(left[bs - 2], left[bs - 1], left[bs - 1]);
dst[(bs - 1) * stride] = left[bs - 1];
dst++;
@@ -372,38 +397,110 @@ static INLINE void d207_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
for (c = 0; c < bs - 2; ++c)
dst[r * stride + c] = dst[(r + 1) * stride + c - 2];
}
-intra_pred_allsizes(d207)
+intra_pred_no_4x4(d207)
+
+void vp9_d63_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
+ const uint8_t *above, const uint8_t *left) {
+ const int A = above[0];
+ const int B = above[1];
+ const int C = above[2];
+ const int D = above[3];
+ const int E = above[4];
+ const int F = above[5];
+ const int G = above[6];
+ (void)left;
+ DST(0, 0) = AVG2(A, B);
+ DST(1, 0) = DST(0, 2) = AVG2(B, C);
+ DST(2, 0) = DST(1, 2) = AVG2(C, D);
+ DST(3, 0) = DST(2, 2) = AVG2(D, E);
+ DST(3, 2) = AVG2(E, F); // differs from vp8
+
+ DST(0, 1) = AVG3(A, B, C);
+ DST(1, 1) = DST(0, 3) = AVG3(B, C, D);
+ DST(2, 1) = DST(1, 3) = AVG3(C, D, E);
+ DST(3, 1) = DST(2, 3) = AVG3(D, E, F);
+ DST(3, 3) = AVG3(E, F, G); // differs from vp8
+}
static INLINE void d63_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
const uint8_t *above, const uint8_t *left) {
int r, c;
- (void) left;
- for (r = 0; r < bs; ++r) {
- for (c = 0; c < bs; ++c)
- dst[c] = r & 1 ? ROUND_POWER_OF_TWO(above[r/2 + c] +
- above[r/2 + c + 1] * 2 +
- above[r/2 + c + 2], 2)
- : ROUND_POWER_OF_TWO(above[r/2 + c] +
- above[r/2 + c + 1], 1);
- dst += stride;
+ int size;
+ (void)left;
+ for (c = 0; c < bs; ++c) {
+ dst[c] = AVG2(above[c], above[c + 1]);
+ dst[stride + c] = AVG3(above[c], above[c + 1], above[c + 2]);
}
+ for (r = 2, size = bs - 2; r < bs; r += 2, --size) {
+ memcpy(dst + (r + 0) * stride, dst + (r >> 1), size);
+ memset(dst + (r + 0) * stride + size, above[bs - 1], bs - size);
+ memcpy(dst + (r + 1) * stride, dst + stride + (r >> 1), size);
+ memset(dst + (r + 1) * stride + size, above[bs - 1], bs - size);
+ }
+}
+intra_pred_no_4x4(d63)
+
+void vp9_d45_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
+ const uint8_t *above, const uint8_t *left) {
+ const int A = above[0];
+ const int B = above[1];
+ const int C = above[2];
+ const int D = above[3];
+ const int E = above[4];
+ const int F = above[5];
+ const int G = above[6];
+ const int H = above[7];
+ (void)stride;
+ (void)left;
+ DST(0, 0) = AVG3(A, B, C);
+ DST(1, 0) = DST(0, 1) = AVG3(B, C, D);
+ DST(2, 0) = DST(1, 1) = DST(0, 2) = AVG3(C, D, E);
+ DST(3, 0) = DST(2, 1) = DST(1, 2) = DST(0, 3) = AVG3(D, E, F);
+ DST(3, 1) = DST(2, 2) = DST(1, 3) = AVG3(E, F, G);
+ DST(3, 2) = DST(2, 3) = AVG3(F, G, H);
+ DST(3, 3) = H; // differs from vp8
}
-intra_pred_allsizes(d63)
static INLINE void d45_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
const uint8_t *above, const uint8_t *left) {
- int r, c;
- (void) left;
- for (r = 0; r < bs; ++r) {
- for (c = 0; c < bs; ++c)
- dst[c] = r + c + 2 < bs * 2 ? ROUND_POWER_OF_TWO(above[r + c] +
- above[r + c + 1] * 2 +
- above[r + c + 2], 2)
- : above[bs * 2 - 1];
+ const uint8_t above_right = above[bs - 1];
+ int x, size;
+ uint8_t avg[31]; // TODO(jzern): this could be block size specific
+ (void)left;
+
+ for (x = 0; x < bs - 1; ++x) {
+ avg[x] = AVG3(above[x], above[x + 1], above[x + 2]);
+ }
+ for (x = 0, size = bs - 1; x < bs; ++x, --size) {
+ memcpy(dst, avg + x, size);
+ memset(dst + size, above_right, x + 1);
dst += stride;
}
}
-intra_pred_allsizes(d45)
+intra_pred_no_4x4(d45)
+
+void vp9_d117_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
+ const uint8_t *above, const uint8_t *left) {
+ const int I = left[0];
+ const int J = left[1];
+ const int K = left[2];
+ const int X = above[-1];
+ const int A = above[0];
+ const int B = above[1];
+ const int C = above[2];
+ const int D = above[3];
+ DST(0, 0) = DST(1, 2) = AVG2(X, A);
+ DST(1, 0) = DST(2, 2) = AVG2(A, B);
+ DST(2, 0) = DST(3, 2) = AVG2(B, C);
+ DST(3, 0) = AVG2(C, D);
+
+ DST(0, 3) = AVG3(K, J, I);
+ DST(0, 2) = AVG3(J, I, X);
+ DST(0, 1) = DST(1, 3) = AVG3(I, X, A);
+ DST(1, 1) = DST(2, 3) = AVG3(X, A, B);
+ DST(2, 1) = DST(3, 3) = AVG3(A, B, C);
+ DST(3, 1) = AVG3(B, C, D);
+}
static INLINE void d117_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
const uint8_t *above, const uint8_t *left) {
@@ -411,20 +508,19 @@ static INLINE void d117_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
// first row
for (c = 0; c < bs; c++)
- dst[c] = ROUND_POWER_OF_TWO(above[c - 1] + above[c], 1);
+ dst[c] = AVG2(above[c - 1], above[c]);
dst += stride;
// second row
- dst[0] = ROUND_POWER_OF_TWO(left[0] + above[-1] * 2 + above[0], 2);
+ dst[0] = AVG3(left[0], above[-1], above[0]);
for (c = 1; c < bs; c++)
- dst[c] = ROUND_POWER_OF_TWO(above[c - 2] + above[c - 1] * 2 + above[c], 2);
+ dst[c] = AVG3(above[c - 2], above[c - 1], above[c]);
dst += stride;
// the rest of first col
- dst[0] = ROUND_POWER_OF_TWO(above[-1] + left[0] * 2 + left[1], 2);
+ dst[0] = AVG3(above[-1], left[0], left[1]);
for (r = 3; r < bs; ++r)
- dst[(r - 2) * stride] = ROUND_POWER_OF_TWO(left[r - 3] + left[r - 2] * 2 +
- left[r - 1], 2);
+ dst[(r - 2) * stride] = AVG3(left[r - 3], left[r - 2], left[r - 1]);
// the rest of the block
for (r = 2; r < bs; ++r) {
@@ -433,19 +529,39 @@ static INLINE void d117_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
dst += stride;
}
}
-intra_pred_allsizes(d117)
+intra_pred_no_4x4(d117)
+
+void vp9_d135_predictor_4x4(uint8_t *dst, ptrdiff_t stride,
+ const uint8_t *above, const uint8_t *left) {
+ const int I = left[0];
+ const int J = left[1];
+ const int K = left[2];
+ const int L = left[3];
+ const int X = above[-1];
+ const int A = above[0];
+ const int B = above[1];
+ const int C = above[2];
+ const int D = above[3];
+ (void)stride;
+ DST(0, 3) = AVG3(J, K, L);
+ DST(1, 3) = DST(0, 2) = AVG3(I, J, K);
+ DST(2, 3) = DST(1, 2) = DST(0, 1) = AVG3(X, I, J);
+ DST(3, 3) = DST(2, 2) = DST(1, 1) = DST(0, 0) = AVG3(A, X, I);
+ DST(3, 2) = DST(2, 1) = DST(1, 0) = AVG3(B, A, X);
+ DST(3, 1) = DST(2, 0) = AVG3(C, B, A);
+ DST(3, 0) = AVG3(D, C, B);
+}
static INLINE void d135_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
const uint8_t *above, const uint8_t *left) {
int r, c;
- dst[0] = ROUND_POWER_OF_TWO(left[0] + above[-1] * 2 + above[0], 2);
+ dst[0] = AVG3(left[0], above[-1], above[0]);
for (c = 1; c < bs; c++)
- dst[c] = ROUND_POWER_OF_TWO(above[c - 2] + above[c - 1] * 2 + above[c], 2);
+ dst[c] = AVG3(above[c - 2], above[c - 1], above[c]);
- dst[stride] = ROUND_POWER_OF_TWO(above[-1] + left[0] * 2 + left[1], 2);
+ dst[stride] = AVG3(above[-1], left[0], left[1]);
for (r = 2; r < bs; ++r)
- dst[r * stride] = ROUND_POWER_OF_TWO(left[r - 2] + left[r - 1] * 2 +
- left[r], 2);
+ dst[r * stride] = AVG3(left[r - 2], left[r - 1], left[r]);
dst += stride;
for (r = 1; r < bs; ++r) {
@@ -454,25 +570,48 @@ static INLINE void d135_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
dst += stride;
}
}
-intra_pred_allsizes(d135)
+intra_pred_no_4x4(d135)
+
+void vp9_d153_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
+ const uint8_t *above, const uint8_t *left) {
+ const int I = left[0];
+ const int J = left[1];
+ const int K = left[2];
+ const int L = left[3];
+ const int X = above[-1];
+ const int A = above[0];
+ const int B = above[1];
+ const int C = above[2];
+
+ DST(0, 0) = DST(2, 1) = AVG2(I, X);
+ DST(0, 1) = DST(2, 2) = AVG2(J, I);
+ DST(0, 2) = DST(2, 3) = AVG2(K, J);
+ DST(0, 3) = AVG2(L, K);
+
+ DST(3, 0) = AVG3(A, B, C);
+ DST(2, 0) = AVG3(X, A, B);
+ DST(1, 0) = DST(3, 1) = AVG3(I, X, A);
+ DST(1, 1) = DST(3, 2) = AVG3(J, I, X);
+ DST(1, 2) = DST(3, 3) = AVG3(K, J, I);
+ DST(1, 3) = AVG3(L, K, J);
+}
static INLINE void d153_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
const uint8_t *above, const uint8_t *left) {
int r, c;
- dst[0] = ROUND_POWER_OF_TWO(above[-1] + left[0], 1);
+ dst[0] = AVG2(above[-1], left[0]);
for (r = 1; r < bs; r++)
- dst[r * stride] = ROUND_POWER_OF_TWO(left[r - 1] + left[r], 1);
+ dst[r * stride] = AVG2(left[r - 1], left[r]);
dst++;
- dst[0] = ROUND_POWER_OF_TWO(left[0] + above[-1] * 2 + above[0], 2);
- dst[stride] = ROUND_POWER_OF_TWO(above[-1] + left[0] * 2 + left[1], 2);
+ dst[0] = AVG3(left[0], above[-1], above[0]);
+ dst[stride] = AVG3(above[-1], left[0], left[1]);
for (r = 2; r < bs; r++)
- dst[r * stride] = ROUND_POWER_OF_TWO(left[r - 2] + left[r - 1] * 2 +
- left[r], 2);
+ dst[r * stride] = AVG3(left[r - 2], left[r - 1], left[r]);
dst++;
for (c = 0; c < bs - 2; c++)
- dst[c] = ROUND_POWER_OF_TWO(above[c - 1] + above[c] * 2 + above[c + 1], 2);
+ dst[c] = AVG3(above[c - 1], above[c], above[c + 1]);
dst += stride;
for (r = 1; r < bs; ++r) {
@@ -481,7 +620,7 @@ static INLINE void d153_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
dst += stride;
}
}
-intra_pred_allsizes(d153)
+intra_pred_no_4x4(d153)
static INLINE void v_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
const uint8_t *above, const uint8_t *left) {
« no previous file with comments | « source/libvpx/vp9/common/vp9_onyxc_int.h ('k') | source/libvpx/vp9/common/vp9_rtcd_defs.pl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698