diff options
author | Deb Mukherjee <debargha@google.com> | 2013-03-16 09:26:52 -0700 |
---|---|---|
committer | Deb Mukherjee <debargha@google.com> | 2013-03-16 09:26:52 -0700 |
commit | b1921b2f089eaa2f74c2b0ac8e2b5ddcddd69e3c (patch) | |
tree | 73f1203dea5ff957455e37102fce7e0c761f9554 /vp9/common/vp9_reconintra4x4.c | |
parent | 76c12ab9c9d08a76f79e6b50af278ebf1e5f49ad (diff) | |
download | libvpx-b1921b2f089eaa2f74c2b0ac8e2b5ddcddd69e3c.tar libvpx-b1921b2f089eaa2f74c2b0ac8e2b5ddcddd69e3c.tar.gz libvpx-b1921b2f089eaa2f74c2b0ac8e2b5ddcddd69e3c.tar.bz2 libvpx-b1921b2f089eaa2f74c2b0ac8e2b5ddcddd69e3c.zip |
Context-pred fix to not use top/left on edges
This fix resolves some of the mismatch issues being seen
recently. While this is the right thing to do when tiling
is used for this experiment, it is not the underlying cause
of the the mismatches.
Something else is causing writing outside of the allowable
frame area in the encoder leading to this mismatch.
Change-Id: If52c6f67555aa18ab8762865384e323b47237277
Diffstat (limited to 'vp9/common/vp9_reconintra4x4.c')
-rw-r--r-- | vp9/common/vp9_reconintra4x4.c | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/vp9/common/vp9_reconintra4x4.c b/vp9/common/vp9_reconintra4x4.c index 7fbee7c32..eab5ab495 100644 --- a/vp9/common/vp9_reconintra4x4.c +++ b/vp9/common/vp9_reconintra4x4.c @@ -15,17 +15,17 @@ #include "vp9_rtcd.h" #if CONFIG_NEWBINTRAMODES -static int find_grad_measure(uint8_t *x, int stride, int n, int t, +static int find_grad_measure(uint8_t *x, int stride, int n, int tx, int ty, int dx, int dy) { int i, j; int count = 0, gsum = 0, gdiv; /* TODO: Make this code more efficient by breaking up into two loops */ - for (i = -t; i < n; ++i) - for (j = -t; j < n; ++j) { + for (i = -ty; i < n; ++i) + for (j = -tx; j < n; ++j) { int g; if (i >= 0 && j >= 0) continue; if (i + dy >= 0 && j + dx >= 0) continue; - if (i + dy < -t || i + dy >= n || j + dx < -t || j + dx >= n) continue; + if (i + dy < -ty || i + dy >= n || j + dx < -tx || j + dx >= n) continue; g = abs(x[(i + dy) * stride + j + dx] - x[i * stride + j]); gsum += g * g; count++; @@ -36,14 +36,15 @@ static int find_grad_measure(uint8_t *x, int stride, int n, int t, #if CONTEXT_PRED_REPLACEMENTS == 6 B_PREDICTION_MODE vp9_find_dominant_direction(uint8_t *ptr, - int stride, int n) { + int stride, int n, + int tx, int ty) { int g[8], i, imin, imax; - g[1] = find_grad_measure(ptr, stride, n, 4, 2, 1); - g[2] = find_grad_measure(ptr, stride, n, 4, 1, 1); - g[3] = find_grad_measure(ptr, stride, n, 4, 1, 2); - g[5] = find_grad_measure(ptr, stride, n, 4, -1, 2); - g[6] = find_grad_measure(ptr, stride, n, 4, -1, 1); - g[7] = find_grad_measure(ptr, stride, n, 4, -2, 1); + g[1] = find_grad_measure(ptr, stride, n, tx, ty, 2, 1); + g[2] = find_grad_measure(ptr, stride, n, tx, ty, 1, 1); + g[3] = find_grad_measure(ptr, stride, n, tx, ty, 1, 2); + g[5] = find_grad_measure(ptr, stride, n, tx, ty, -1, 2); + g[6] = find_grad_measure(ptr, stride, n, tx, ty, -1, 1); + g[7] = find_grad_measure(ptr, stride, n, tx, ty, -2, 1); imin = 1; for (i = 2; i < 8; i += 1 + (i == 3)) imin = (g[i] < g[imin] ? i : imin); @@ -73,12 +74,13 @@ B_PREDICTION_MODE vp9_find_dominant_direction(uint8_t *ptr, } #elif CONTEXT_PRED_REPLACEMENTS == 4 B_PREDICTION_MODE vp9_find_dominant_direction(uint8_t *ptr, - int stride, int n) { + int stride, int n, + int tx, int ty) { int g[8], i, imin, imax; - g[1] = find_grad_measure(ptr, stride, n, 4, 2, 1); - g[3] = find_grad_measure(ptr, stride, n, 4, 1, 2); - g[5] = find_grad_measure(ptr, stride, n, 4, -1, 2); - g[7] = find_grad_measure(ptr, stride, n, 4, -2, 1); + g[1] = find_grad_measure(ptr, stride, n, tx, ty, 2, 1); + g[3] = find_grad_measure(ptr, stride, n, tx, ty, 1, 2); + g[5] = find_grad_measure(ptr, stride, n, tx, ty, -1, 2); + g[7] = find_grad_measure(ptr, stride, n, tx, ty, -2, 1); imin = 1; for (i = 3; i < 8; i+=2) imin = (g[i] < g[imin] ? i : imin); @@ -104,16 +106,17 @@ B_PREDICTION_MODE vp9_find_dominant_direction(uint8_t *ptr, } #elif CONTEXT_PRED_REPLACEMENTS == 0 B_PREDICTION_MODE vp9_find_dominant_direction(uint8_t *ptr, - int stride, int n) { + int stride, int n, + int tx, int ty) { int g[8], i, imin, imax; - g[0] = find_grad_measure(ptr, stride, n, 4, 1, 0); - g[1] = find_grad_measure(ptr, stride, n, 4, 2, 1); - g[2] = find_grad_measure(ptr, stride, n, 4, 1, 1); - g[3] = find_grad_measure(ptr, stride, n, 4, 1, 2); - g[4] = find_grad_measure(ptr, stride, n, 4, 0, 1); - g[5] = find_grad_measure(ptr, stride, n, 4, -1, 2); - g[6] = find_grad_measure(ptr, stride, n, 4, -1, 1); - g[7] = find_grad_measure(ptr, stride, n, 4, -2, 1); + g[0] = find_grad_measure(ptr, stride, n, tx, ty, 1, 0); + g[1] = find_grad_measure(ptr, stride, n, tx, ty, 2, 1); + g[2] = find_grad_measure(ptr, stride, n, tx, ty, 1, 1); + g[3] = find_grad_measure(ptr, stride, n, tx, ty, 1, 2); + g[4] = find_grad_measure(ptr, stride, n, tx, ty, 0, 1); + g[5] = find_grad_measure(ptr, stride, n, tx, ty, -1, 2); + g[6] = find_grad_measure(ptr, stride, n, tx, ty, -1, 1); + g[7] = find_grad_measure(ptr, stride, n, tx, ty, -2, 1); imax = 0; for (i = 1; i < 8; i++) imax = (g[i] > g[imax] ? i : imax); @@ -144,10 +147,17 @@ B_PREDICTION_MODE vp9_find_dominant_direction(uint8_t *ptr, } #endif -B_PREDICTION_MODE vp9_find_bpred_context(BLOCKD *x) { +B_PREDICTION_MODE vp9_find_bpred_context(MACROBLOCKD *xd, BLOCKD *x) { + const int block_idx = x - xd->block; + const int have_top = (block_idx >> 2) || xd->up_available; + const int have_left = (block_idx & 3) || xd->left_available; uint8_t *ptr = *(x->base_dst) + x->dst; int stride = x->dst_stride; - return vp9_find_dominant_direction(ptr, stride, 4); + int tx = have_left ? 4 : 0; + int ty = have_top ? 4 : 0; + if (!have_left && !have_top) + return B_DC_PRED; + return vp9_find_dominant_direction(ptr, stride, 4, tx, ty); } #endif |