summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
Diffstat (limited to 'vp9')
-rw-r--r--vp9/common/vp9_alloccommon.c3
-rw-r--r--vp9/common/vp9_blockd.h4
-rw-r--r--vp9/common/vp9_convolve.c474
-rw-r--r--vp9/common/vp9_convolve.h44
-rw-r--r--vp9/common/vp9_entropy.c1
-rw-r--r--vp9/common/vp9_entropy.h33
-rw-r--r--vp9/common/vp9_entropymode.c3
-rw-r--r--vp9/common/vp9_loopfilter.c71
-rw-r--r--vp9/common/vp9_onyxc_int.h1
-rw-r--r--vp9/common/vp9_pred_common.c2
-rw-r--r--vp9/common/vp9_reconinter.c762
-rw-r--r--vp9/common/vp9_reconintra.c222
-rw-r--r--vp9/common/vp9_reconintra.h47
-rw-r--r--vp9/common/vp9_rtcd_defs.sh56
-rw-r--r--vp9/decoder/vp9_decodemv.c49
-rw-r--r--vp9/decoder/vp9_decodframe.c47
-rw-r--r--vp9/decoder/vp9_detokenize.c36
-rw-r--r--vp9/decoder/vp9_onyxd_if.c19
-rw-r--r--vp9/encoder/vp9_bitstream.c10
-rw-r--r--vp9/encoder/vp9_block.h9
-rw-r--r--vp9/encoder/vp9_encodeframe.c17
-rw-r--r--vp9/encoder/vp9_encodemb.c24
-rw-r--r--vp9/encoder/vp9_quantize.c42
-rw-r--r--vp9/encoder/vp9_rdopt.c132
-rw-r--r--vp9/encoder/vp9_temporal_filter.c9
-rw-r--r--vp9/encoder/vp9_tokenize.c266
-rw-r--r--vp9/encoder/vp9_tokenize.h5
27 files changed, 321 insertions, 2067 deletions
diff --git a/vp9/common/vp9_alloccommon.c b/vp9/common/vp9_alloccommon.c
index e142362b2..8d75c4db0 100644
--- a/vp9/common/vp9_alloccommon.c
+++ b/vp9/common/vp9_alloccommon.c
@@ -137,9 +137,6 @@ int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) {
return 1;
}
- vp9_update_mode_info_border(oci, oci->mip);
- vp9_update_mode_info_in_image(oci, oci->mi);
-
return 0;
}
diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h
index 76f80d4d7..e79046899 100644
--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -326,11 +326,7 @@ struct scale_factors {
int den,
int offset_q4);
-#if CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT
- convolve_fn_t predict[2][2][8]; // horiz, vert, weight (0 - 7)
-#else
convolve_fn_t predict[2][2][2]; // horiz, vert, avg
-#endif
};
enum { MAX_MB_PLANE = 3 };
diff --git a/vp9/common/vp9_convolve.c b/vp9/common/vp9_convolve.c
index a27ca6f5d..46ae50349 100644
--- a/vp9/common/vp9_convolve.c
+++ b/vp9/common/vp9_convolve.c
@@ -122,78 +122,6 @@ static void convolve_avg_horiz_c(const uint8_t *src, int src_stride,
}
}
-#if CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT
-
-static inline uint8_t combine_qtr(uint8_t a, uint8_t b) {
- return (((a) + (b) * 3 + 2) >> 2);
-}
-
-static inline uint8_t combine_3qtr(uint8_t a, uint8_t b) {
- return (((a) * 3 + (b) + 2) >> 2);
-}
-
-static inline uint8_t combine_1by8(uint8_t a, uint8_t b) {
- return (((a) * 1 + (b) * 7 + 4) >> 3);
-}
-
-static inline uint8_t combine_3by8(uint8_t a, uint8_t b) {
- return (((a) * 3 + (b) * 5 + 4) >> 3);
-}
-
-static inline uint8_t combine_5by8(uint8_t a, uint8_t b) {
- return (((a) * 5 + (b) * 3 + 4) >> 3);
-}
-
-static inline uint8_t combine_7by8(uint8_t a, uint8_t b) {
- return (((a) * 7 + (b) * 1 + 4) >> 3);
-}
-
-// TODO(debargha): Implment with a separate weight parameter
-static void convolve_wtd_horiz_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x0, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h, int taps,
- uint8_t (*combine)(uint8_t a, uint8_t b)) {
- int x, y, k, sum;
- const int16_t *filter_x_base = filter_x0;
-
-#if ALIGN_FILTERS_256
- filter_x_base = (const int16_t *)(((intptr_t)filter_x0) & ~(intptr_t)0xff);
-#endif
-
- /* Adjust base pointer address for this source line */
- src -= taps / 2 - 1;
-
- for (y = 0; y < h; ++y) {
- /* Pointer to filter to use */
- const int16_t *filter_x = filter_x0;
-
- /* Initial phase offset */
- int x0_q4 = (filter_x - filter_x_base) / taps;
- int x_q4 = x0_q4;
-
- for (x = 0; x < w; ++x) {
- /* Per-pixel src offset */
- int src_x = (x_q4 - x0_q4) >> 4;
-
- for (sum = 0, k = 0; k < taps; ++k) {
- sum += src[src_x + k] * filter_x[k];
- }
- sum += (VP9_FILTER_WEIGHT >> 1);
- dst[x] = combine(dst[x], clip_pixel(sum >> VP9_FILTER_SHIFT));
-
- /* Adjust source and filter to use for the next pixel */
- x_q4 += x_step_q4;
- filter_x = filter_x_base + (x_q4 & 0xf) * taps;
- }
- src += src_stride;
- dst += dst_stride;
- }
-}
-
-#endif
-
static void convolve_vert_c(const uint8_t *src, int src_stride,
uint8_t *dst, int dst_stride,
const int16_t *filter_x, int x_step_q4,
@@ -279,52 +207,6 @@ static void convolve_avg_vert_c(const uint8_t *src, int src_stride,
}
}
-#if CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT
-static void convolve_wtd_vert_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y0, int y_step_q4,
- int w, int h, int taps,
- uint8_t (*combine)(uint8_t a, uint8_t b)) {
- int x, y, k, sum;
-
- const int16_t *filter_y_base = filter_y0;
-
-#if ALIGN_FILTERS_256
- filter_y_base = (const int16_t *)(((intptr_t)filter_y0) & ~(intptr_t)0xff);
-#endif
-
- /* Adjust base pointer address for this source column */
- src -= src_stride * (taps / 2 - 1);
- for (x = 0; x < w; ++x) {
- /* Pointer to filter to use */
- const int16_t *filter_y = filter_y0;
-
- /* Initial phase offset */
- int y0_q4 = (filter_y - filter_y_base) / taps;
- int y_q4 = y0_q4;
-
- for (y = 0; y < h; ++y) {
- /* Per-pixel src offset */
- int src_y = (y_q4 - y0_q4) >> 4;
-
- for (sum = 0, k = 0; k < taps; ++k) {
- sum += src[(src_y + k) * src_stride] * filter_y[k];
- }
- sum += (VP9_FILTER_WEIGHT >> 1);
- dst[y * dst_stride] = combine(dst[y * dst_stride],
- clip_pixel(sum >> VP9_FILTER_SHIFT));
-
- /* Adjust source and filter to use for the next pixel */
- y_q4 += y_step_q4;
- filter_y = filter_y_base + (y_q4 & 0xf) * taps;
- }
- ++src;
- ++dst;
- }
-}
-#endif
-
static void convolve_c(const uint8_t *src, int src_stride,
uint8_t *dst, int dst_stride,
const int16_t *filter_x, int x_step_q4,
@@ -403,68 +285,6 @@ void vp9_convolve8_avg_horiz_c(const uint8_t *src, int src_stride,
w, h, 8);
}
-#if CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT
-void vp9_convolve8_1by8_horiz_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h) {
- convolve_wtd_horiz_c(src, src_stride, dst, dst_stride,
- filter_x, x_step_q4, filter_y, y_step_q4,
- w, h, 8, combine_1by8);
-}
-
-void vp9_convolve8_qtr_horiz_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h) {
- convolve_wtd_horiz_c(src, src_stride, dst, dst_stride,
- filter_x, x_step_q4, filter_y, y_step_q4,
- w, h, 8, combine_qtr);
-}
-
-void vp9_convolve8_3by8_horiz_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h) {
- convolve_wtd_horiz_c(src, src_stride, dst, dst_stride,
- filter_x, x_step_q4, filter_y, y_step_q4,
- w, h, 8, combine_3by8);
-}
-
-void vp9_convolve8_5by8_horiz_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h) {
- convolve_wtd_horiz_c(src, src_stride, dst, dst_stride,
- filter_x, x_step_q4, filter_y, y_step_q4,
- w, h, 8, combine_5by8);
-}
-
-void vp9_convolve8_3qtr_horiz_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h) {
- convolve_wtd_horiz_c(src, src_stride, dst, dst_stride,
- filter_x, x_step_q4, filter_y, y_step_q4,
- w, h, 8, combine_3qtr);
-}
-
-void vp9_convolve8_7by8_horiz_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h) {
- convolve_wtd_horiz_c(src, src_stride, dst, dst_stride,
- filter_x, x_step_q4, filter_y, y_step_q4,
- w, h, 8, combine_7by8);
-}
-#endif
-
void vp9_convolve8_vert_c(const uint8_t *src, int src_stride,
uint8_t *dst, int dst_stride,
const int16_t *filter_x, int x_step_q4,
@@ -485,68 +305,6 @@ void vp9_convolve8_avg_vert_c(const uint8_t *src, int src_stride,
w, h, 8);
}
-#if CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT
-void vp9_convolve8_1by8_vert_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h) {
- convolve_wtd_vert_c(src, src_stride, dst, dst_stride,
- filter_x, x_step_q4, filter_y, y_step_q4,
- w, h, 8, combine_1by8);
-}
-
-void vp9_convolve8_qtr_vert_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h) {
- convolve_wtd_vert_c(src, src_stride, dst, dst_stride,
- filter_x, x_step_q4, filter_y, y_step_q4,
- w, h, 8, combine_qtr);
-}
-
-void vp9_convolve8_3by8_vert_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h) {
- convolve_wtd_vert_c(src, src_stride, dst, dst_stride,
- filter_x, x_step_q4, filter_y, y_step_q4,
- w, h, 8, combine_3by8);
-}
-
-void vp9_convolve8_5by8_vert_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h) {
- convolve_wtd_vert_c(src, src_stride, dst, dst_stride,
- filter_x, x_step_q4, filter_y, y_step_q4,
- w, h, 8, combine_5by8);
-}
-
-void vp9_convolve8_3qtr_vert_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h) {
- convolve_wtd_vert_c(src, src_stride, dst, dst_stride,
- filter_x, x_step_q4, filter_y, y_step_q4,
- w, h, 8, combine_3qtr);
-}
-
-void vp9_convolve8_7by8_vert_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h) {
- convolve_wtd_vert_c(src, src_stride, dst, dst_stride,
- filter_x, x_step_q4, filter_y, y_step_q4,
- w, h, 8, combine_7by8);
-}
-#endif
-
void vp9_convolve8_c(const uint8_t *src, int src_stride,
uint8_t *dst, int dst_stride,
const int16_t *filter_x, int x_step_q4,
@@ -579,140 +337,6 @@ void vp9_convolve8_avg_c(const uint8_t *src, int src_stride,
w, h);
}
-#if CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT
-void vp9_convolve8_1by8_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h) {
- /* Fixed size intermediate buffer places limits on parameters. */
- DECLARE_ALIGNED_ARRAY(16, uint8_t, temp, 16 * 16);
- assert(w <= 16);
- assert(h <= 16);
-
- vp9_convolve8(src, src_stride,
- temp, 16,
- filter_x, x_step_q4,
- filter_y, y_step_q4,
- w, h);
- vp9_convolve_1by8(temp, 16,
- dst, dst_stride,
- NULL, 0, /* These unused parameter should be removed! */
- NULL, 0, /* These unused parameter should be removed! */
- w, h);
-}
-
-void vp9_convolve8_qtr_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h) {
- /* Fixed size intermediate buffer places limits on parameters. */
- DECLARE_ALIGNED_ARRAY(16, uint8_t, temp, 16 * 16);
- assert(w <= 16);
- assert(h <= 16);
-
- vp9_convolve8(src, src_stride,
- temp, 16,
- filter_x, x_step_q4,
- filter_y, y_step_q4,
- w, h);
- vp9_convolve_qtr(temp, 16,
- dst, dst_stride,
- NULL, 0, /* These unused parameter should be removed! */
- NULL, 0, /* These unused parameter should be removed! */
- w, h);
-}
-
-void vp9_convolve8_3by8_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h) {
- /* Fixed size intermediate buffer places limits on parameters. */
- DECLARE_ALIGNED_ARRAY(16, uint8_t, temp, 16 * 16);
- assert(w <= 16);
- assert(h <= 16);
-
- vp9_convolve8(src, src_stride,
- temp, 16,
- filter_x, x_step_q4,
- filter_y, y_step_q4,
- w, h);
- vp9_convolve_3by8(temp, 16,
- dst, dst_stride,
- NULL, 0, /* These unused parameter should be removed! */
- NULL, 0, /* These unused parameter should be removed! */
- w, h);
-}
-
-void vp9_convolve8_5by8_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h) {
- /* Fixed size intermediate buffer places limits on parameters. */
- DECLARE_ALIGNED_ARRAY(16, uint8_t, temp, 16 * 16);
- assert(w <= 16);
- assert(h <= 16);
-
- vp9_convolve8(src, src_stride,
- temp, 16,
- filter_x, x_step_q4,
- filter_y, y_step_q4,
- w, h);
- vp9_convolve_5by8(temp, 16,
- dst, dst_stride,
- NULL, 0, /* These unused parameter should be removed! */
- NULL, 0, /* These unused parameter should be removed! */
- w, h);
-}
-
-void vp9_convolve8_3qtr_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h) {
- /* Fixed size intermediate buffer places limits on parameters. */
- DECLARE_ALIGNED_ARRAY(16, uint8_t, temp, 16 * 16);
- assert(w <= 16);
- assert(h <= 16);
-
- vp9_convolve8(src, src_stride,
- temp, 16,
- filter_x, x_step_q4,
- filter_y, y_step_q4,
- w, h);
- vp9_convolve_3qtr(temp, 16,
- dst, dst_stride,
- NULL, 0, /* These unused parameter should be removed! */
- NULL, 0, /* These unused parameter should be removed! */
- w, h);
-}
-
-void vp9_convolve8_7by8_c(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h) {
- /* Fixed size intermediate buffer places limits on parameters. */
- DECLARE_ALIGNED_ARRAY(16, uint8_t, temp, 16 * 16);
- assert(w <= 16);
- assert(h <= 16);
-
- vp9_convolve8(src, src_stride,
- temp, 16,
- filter_x, x_step_q4,
- filter_y, y_step_q4,
- w, h);
- vp9_convolve_7by8(temp, 16,
- dst, dst_stride,
- NULL, 0, /* These unused parameter should be removed! */
- NULL, 0, /* These unused parameter should be removed! */
- w, h);
-}
-#endif
-
void vp9_convolve_copy(const uint8_t *src, int src_stride,
uint8_t *dst, int dst_stride,
const int16_t *filter_x, int filter_x_stride,
@@ -750,101 +374,3 @@ void vp9_convolve_avg(const uint8_t *src, int src_stride,
dst += dst_stride;
}
}
-
-#if CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT
-void vp9_convolve_1by8(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int filter_x_stride,
- const int16_t *filter_y, int filter_y_stride,
- int w, int h) {
- int x, y;
-
- for (y = 0; y < h; ++y) {
- for (x = 0; x < w; ++x) {
- dst[x] = combine_1by8(dst[x], src[x]);
- }
- src += src_stride;
- dst += dst_stride;
- }
-}
-
-void vp9_convolve_qtr(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int filter_x_stride,
- const int16_t *filter_y, int filter_y_stride,
- int w, int h) {
- int x, y;
-
- for (y = 0; y < h; ++y) {
- for (x = 0; x < w; ++x) {
- dst[x] = combine_qtr(dst[x], src[x]);
- }
- src += src_stride;
- dst += dst_stride;
- }
-}
-
-void vp9_convolve_3by8(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int filter_x_stride,
- const int16_t *filter_y, int filter_y_stride,
- int w, int h) {
- int x, y;
-
- for (y = 0; y < h; ++y) {
- for (x = 0; x < w; ++x) {
- dst[x] = combine_3by8(dst[x], src[x]);
- }
- src += src_stride;
- dst += dst_stride;
- }
-}
-
-void vp9_convolve_5by8(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int filter_x_stride,
- const int16_t *filter_y, int filter_y_stride,
- int w, int h) {
- int x, y;
-
- for (y = 0; y < h; ++y) {
- for (x = 0; x < w; ++x) {
- dst[x] = combine_5by8(dst[x], src[x]);
- }
- src += src_stride;
- dst += dst_stride;
- }
-}
-
-void vp9_convolve_3qtr(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int filter_x_stride,
- const int16_t *filter_y, int filter_y_stride,
- int w, int h) {
- int x, y;
-
- for (y = 0; y < h; ++y) {
- for (x = 0; x < w; ++x) {
- dst[x] = combine_3qtr(dst[x], src[x]);
- }
- src += src_stride;
- dst += dst_stride;
- }
-}
-
-void vp9_convolve_7by8(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int filter_x_stride,
- const int16_t *filter_y, int filter_y_stride,
- int w, int h) {
- int x, y;
-
- for (y = 0; y < h; ++y) {
- for (x = 0; x < w; ++x) {
- dst[x] = combine_7by8(dst[x], src[x]);
- }
- src += src_stride;
- dst += dst_stride;
- }
-}
-#endif
diff --git a/vp9/common/vp9_convolve.h b/vp9/common/vp9_convolve.h
index bef2d8564..0596080c0 100644
--- a/vp9/common/vp9_convolve.h
+++ b/vp9/common/vp9_convolve.h
@@ -33,50 +33,6 @@ void vp9_convolve_avg(const uint8_t *src, int src_stride,
const int16_t *filter_y, int y_step_q4,
int w, int h);
-#if CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT
-// Not a convolution, a block wtd (1/8, 7/8) average for (dst, src)
-void vp9_convolve_1by8(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h);
-
-// Not a convolution, a block wtd (1/4, 3/4) average for (dst, src)
-void vp9_convolve_qtr(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h);
-
-// Not a convolution, a block wtd (3/8, 5/8) average for (dst, src)
-void vp9_convolve_3by8(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h);
-
-// Not a convolution, a block wtd (5/8, 3/8) average for (dst, src)
-void vp9_convolve_5by8(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h);
-
-// Not a convolution, a block wtd (3/4, 1/4) average for (dst, src)
-void vp9_convolve_3qtr(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h);
-
-// Not a convolution, a block wtd (7/8, 1/8) average for (dst, src)
-void vp9_convolve_7by8(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- const int16_t *filter_x, int x_step_q4,
- const int16_t *filter_y, int y_step_q4,
- int w, int h);
-#endif
-
struct subpix_fn_table {
const int16_t (*filter_x)[8];
const int16_t (*filter_y)[8];
diff --git a/vp9/common/vp9_entropy.c b/vp9/common/vp9_entropy.c
index a5437d889..16ef14fec 100644
--- a/vp9/common/vp9_entropy.c
+++ b/vp9/common/vp9_entropy.c
@@ -12,7 +12,6 @@
#include <stdio.h>
#include "vp9/common/vp9_entropy.h"
-#include "string.h"
#include "vp9/common/vp9_blockd.h"
#include "vp9/common/vp9_onyxc_int.h"
#include "vp9/common/vp9_entropymode.h"
diff --git a/vp9/common/vp9_entropy.h b/vp9/common/vp9_entropy.h
index 123b5e289..07b07a7e7 100644
--- a/vp9/common/vp9_entropy.h
+++ b/vp9/common/vp9_entropy.h
@@ -223,6 +223,39 @@ void vp9_adapt_zpc_probs(struct VP9Common *cm);
#endif // CONFIG_CODE_ZEROGROUP
+static INLINE const int* get_scan_4x4(TX_TYPE tx_type) {
+ switch (tx_type) {
+ case ADST_DCT:
+ return vp9_row_scan_4x4;
+ case DCT_ADST:
+ return vp9_col_scan_4x4;
+ default:
+ return vp9_default_zig_zag1d_4x4;
+ }
+}
+
+static INLINE const int* get_scan_8x8(TX_TYPE tx_type) {
+ switch (tx_type) {
+ case ADST_DCT:
+ return vp9_row_scan_8x8;
+ case DCT_ADST:
+ return vp9_col_scan_8x8;
+ default:
+ return vp9_default_zig_zag1d_8x8;
+ }
+}
+
+static INLINE const int* get_scan_16x16(TX_TYPE tx_type) {
+ switch (tx_type) {
+ case ADST_DCT:
+ return vp9_row_scan_16x16;
+ case DCT_ADST:
+ return vp9_col_scan_16x16;
+ default:
+ return vp9_default_zig_zag1d_16x16;
+ }
+}
+
#include "vp9/common/vp9_coefupdateprobs.h"
#endif // VP9_COMMON_VP9_ENTROPY_H_
diff --git a/vp9/common/vp9_entropymode.c b/vp9/common/vp9_entropymode.c
index f19dc12d3..9cb1d2b86 100644
--- a/vp9/common/vp9_entropymode.c
+++ b/vp9/common/vp9_entropymode.c
@@ -718,6 +718,9 @@ void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) {
vp9_update_mode_info_border(cm, cm->mip);
vp9_update_mode_info_in_image(cm, cm->mi);
+ vp9_update_mode_info_border(cm, cm->prev_mip);
+ vp9_update_mode_info_in_image(cm, cm->prev_mi);
+
cm->ref_frame_sign_bias[GOLDEN_FRAME] = 0;
cm->ref_frame_sign_bias[ALTREF_FRAME] = 0;
diff --git a/vp9/common/vp9_loopfilter.c b/vp9/common/vp9_loopfilter.c
index 4943e42af..8d8a8df92 100644
--- a/vp9/common/vp9_loopfilter.c
+++ b/vp9/common/vp9_loopfilter.c
@@ -281,66 +281,67 @@ static void lpf_sb32(VP9_COMMON *cm, const MODE_INFO *mode_info_context,
uint8_t *y_ptr, uint8_t *u_ptr, uint8_t *v_ptr,
int y_stride, int uv_stride,
int y_only, int dering) {
- BLOCK_SIZE_TYPE sb_type = mode_info_context->mbmi.sb_type;
- TX_SIZE tx_size = mode_info_context->mbmi.txfm_size;
- int do_left_v, do_above_h;
- int do_left_v_mbuv, do_above_h_mbuv;
- int mis = cm->mode_info_stride;
- const MODE_INFO *mi;
-
- // process 1st MB top-left
- mi = mode_info_context;
- do_left_v = (mb_col > 0);
- do_above_h = (mb_row > 0);
- do_left_v_mbuv = !(sb_type >= BLOCK_SIZE_SB64X64 &&
+ BLOCK_SIZE_TYPE sb_type = mode_info_context->mbmi.sb_type;
+ const int wbl = b_width_log2(sb_type), hbl = b_height_log2(sb_type);
+ TX_SIZE tx_size = mode_info_context->mbmi.txfm_size;
+ int do_left_v, do_above_h;
+ int do_left_v_mbuv, do_above_h_mbuv;
+ int mis = cm->mode_info_stride;
+ const MODE_INFO *mi;
+
+ // process 1st MB top-left
+ mi = mode_info_context;
+ do_left_v = (mb_col > 0);
+ do_above_h = (mb_row > 0);
+ do_left_v_mbuv = !(sb_type >= BLOCK_SIZE_SB64X64 &&
tx_size >= TX_32X32 && (mb_col & 2));
- do_above_h_mbuv = !(sb_type >= BLOCK_SIZE_SB64X64 &&
+ do_above_h_mbuv = !(sb_type >= BLOCK_SIZE_SB64X64 &&
tx_size >= TX_32X32 && (mb_row & 2));
- lpf_mb(cm, mi, do_left_v, do_above_h,
+ lpf_mb(cm, mi, do_left_v, do_above_h,
do_left_v_mbuv, do_above_h_mbuv,
y_ptr,
y_only? 0 : u_ptr,
y_only? 0 : v_ptr,
y_stride, uv_stride, dering);
- // process 2nd MB top-right
- mi = mode_info_context + 1;
- do_left_v = !(sb_type && (tx_size >= TX_32X32 ||
+ // process 2nd MB top-right
+ mi = mode_info_context + 1;
+ do_left_v = !(wbl >= 3 /* 32x16 or >=32x32 */ && (tx_size >= TX_32X32 ||
sb_mb_lf_skip(mode_info_context, mi)));
- do_above_h = (mb_row > 0);
- do_left_v_mbuv = do_left_v;
- do_above_h_mbuv = !(sb_type >= BLOCK_SIZE_SB64X64 &&
+ do_above_h = (mb_row > 0);
+ do_left_v_mbuv = do_left_v;
+ do_above_h_mbuv = !(sb_type >= BLOCK_SIZE_SB64X64 &&
tx_size >= TX_32X32 && (mb_row & 2));
- lpf_mb(cm, mi, do_left_v, do_above_h,
+ lpf_mb(cm, mi, do_left_v, do_above_h,
do_left_v_mbuv, do_above_h_mbuv,
y_ptr + 16,
y_only ? 0 : (u_ptr + 8),
y_only ? 0 : (v_ptr + 8),
y_stride, uv_stride, dering);
- // process 3rd MB bottom-left
- mi = mode_info_context + mis;
- do_left_v = (mb_col > 0);
- do_above_h =!(sb_type && (tx_size >= TX_32X32 ||
+ // process 3rd MB bottom-left
+ mi = mode_info_context + mis;
+ do_left_v = (mb_col > 0);
+ do_above_h = !(hbl >= 3 /* 16x32 or >=32x32 */ && (tx_size >= TX_32X32 ||
sb_mb_lf_skip(mode_info_context, mi)));
- do_left_v_mbuv = !(sb_type >= BLOCK_SIZE_SB64X64 &&
+ do_left_v_mbuv = !(sb_type >= BLOCK_SIZE_SB64X64 &&
tx_size >= TX_32X32 && (mb_col & 2));
- do_above_h_mbuv = do_above_h;
- lpf_mb(cm, mi, do_left_v, do_above_h,
+ do_above_h_mbuv = do_above_h;
+ lpf_mb(cm, mi, do_left_v, do_above_h,
do_left_v_mbuv, do_above_h_mbuv,
y_ptr + 16 * y_stride,
y_only ? 0 : (u_ptr + 8 * uv_stride),
y_only ? 0 : (v_ptr + 8 * uv_stride),
y_stride, uv_stride, dering);
- // process 4th MB bottom right
- mi = mode_info_context + mis + 1;
- do_left_v = !(sb_type && (tx_size >= TX_32X32 ||
+ // process 4th MB bottom right
+ mi = mode_info_context + mis + 1;
+ do_left_v = !(wbl >= 3 /* 32x16 or >=32x32 */ && (tx_size >= TX_32X32 ||
sb_mb_lf_skip(mi - 1, mi)));
- do_above_h =!(sb_type && (tx_size >= TX_32X32 ||
+ do_above_h = !(hbl >= 3 /* 16x32 or >=32x32 */ && (tx_size >= TX_32X32 ||
sb_mb_lf_skip(mode_info_context + 1, mi)));
- do_left_v_mbuv = do_left_v;
- do_above_h_mbuv = do_above_h;
- lpf_mb(cm, mi, do_left_v, do_above_h,
+ do_left_v_mbuv = do_left_v;
+ do_above_h_mbuv = do_above_h;
+ lpf_mb(cm, mi, do_left_v, do_above_h,
do_left_v_mbuv, do_above_h_mbuv,
y_ptr + 16 * y_stride + 16,
y_only ? 0 : (u_ptr + 8 * uv_stride + 8),
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index 8f957345d..f9d02e3ca 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -196,6 +196,7 @@ typedef struct VP9Common {
FRAME_TYPE frame_type;
int show_frame;
+ int last_show_frame;
int frame_flags;
int MBs;
diff --git a/vp9/common/vp9_pred_common.c b/vp9/common/vp9_pred_common.c
index e110cff44..581049169 100644
--- a/vp9/common/vp9_pred_common.c
+++ b/vp9/common/vp9_pred_common.c
@@ -230,7 +230,7 @@ void vp9_set_pred_flag(MACROBLOCKD *const xd,
int vp9_get_pred_mb_segid(VP9_COMMON *cm, BLOCK_SIZE_TYPE sb_type,
int mb_row, int mb_col) {
const int mb_index = mb_row * cm->mb_cols + mb_col;
- if (sb_type) {
+ if (sb_type > BLOCK_SIZE_MB16X16) {
const int bw = 1 << mb_width_log2(sb_type);
const int bh = 1 << mb_height_log2(sb_type);
const int ymbs = MIN(cm->mb_rows - mb_row, bh);
diff --git a/vp9/common/vp9_reconinter.c b/vp9/common/vp9_reconinter.c
index 2697bd25c..c2e0f2ff9 100644
--- a/vp9/common/vp9_reconinter.c
+++ b/vp9/common/vp9_reconinter.c
@@ -57,127 +57,6 @@ void vp9_setup_scale_factors_for_frame(struct scale_factors *scale,
// applied in one direction only, and not at all for 0,0, seems to give the
// best quality, but it may be worth trying an additional mode that does
// do the filtering on full-pel.
-#if CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT
- if (scale->x_step_q4 == 16) {
- if (scale->y_step_q4 == 16) {
- // No scaling in either direction.
- scale->predict[0][0][0] = vp9_convolve_copy;
- scale->predict[0][0][1] = vp9_convolve_1by8;
- scale->predict[0][0][2] = vp9_convolve_qtr;
- scale->predict[0][0][3] = vp9_convolve_3by8;
- scale->predict[0][0][4] = vp9_convolve_avg;
- scale->predict[0][0][5] = vp9_convolve_5by8;
- scale->predict[0][0][6] = vp9_convolve_3qtr;
- scale->predict[0][0][7] = vp9_convolve_7by8;
- scale->predict[0][1][0] = vp9_convolve8_vert;
- scale->predict[0][1][1] = vp9_convolve8_1by8_vert;
- scale->predict[0][1][2] = vp9_convolve8_qtr_vert;
- scale->predict[0][1][3] = vp9_convolve8_3by8_vert;
- scale->predict[0][1][4] = vp9_convolve8_avg_vert;
- scale->predict[0][1][5] = vp9_convolve8_5by8_vert;
- scale->predict[0][1][6] = vp9_convolve8_3qtr_vert;
- scale->predict[0][1][7] = vp9_convolve8_7by8_vert;
- scale->predict[1][0][0] = vp9_convolve8_horiz;
- scale->predict[1][0][1] = vp9_convolve8_1by8_horiz;
- scale->predict[1][0][2] = vp9_convolve8_qtr_horiz;
- scale->predict[1][0][3] = vp9_convolve8_3by8_horiz;
- scale->predict[1][0][4] = vp9_convolve8_avg_horiz;
- scale->predict[1][0][5] = vp9_convolve8_5by8_horiz;
- scale->predict[1][0][6] = vp9_convolve8_3qtr_horiz;
- scale->predict[1][0][7] = vp9_convolve8_7by8_horiz;
- } else {
- // No scaling in x direction. Must always scale in the y direction.
- scale->predict[0][0][0] = vp9_convolve8_vert;
- scale->predict[0][0][1] = vp9_convolve8_1by8_vert;
- scale->predict[0][0][2] = vp9_convolve8_qtr_vert;
- scale->predict[0][0][3] = vp9_convolve8_3by8_vert;
- scale->predict[0][0][4] = vp9_convolve8_avg_vert;
- scale->predict[0][0][5] = vp9_convolve8_5by8_vert;
- scale->predict[0][0][6] = vp9_convolve8_3qtr_vert;
- scale->predict[0][0][7] = vp9_convolve8_7by8_vert;
- scale->predict[0][1][0] = vp9_convolve8_vert;
- scale->predict[0][1][1] = vp9_convolve8_1by8_vert;
- scale->predict[0][1][2] = vp9_convolve8_qtr_vert;
- scale->predict[0][1][3] = vp9_convolve8_3by8_vert;
- scale->predict[0][1][4] = vp9_convolve8_avg_vert;
- scale->predict[0][1][5] = vp9_convolve8_5by8_vert;
- scale->predict[0][1][6] = vp9_convolve8_3qtr_vert;
- scale->predict[0][1][7] = vp9_convolve8_7by8_vert;
- scale->predict[1][0][0] = vp9_convolve8;
- scale->predict[1][0][1] = vp9_convolve8_1by8;
- scale->predict[1][0][2] = vp9_convolve8_qtr;
- scale->predict[1][0][3] = vp9_convolve8_3by8;
- scale->predict[1][0][4] = vp9_convolve8_avg;
- scale->predict[1][0][5] = vp9_convolve8_5by8;
- scale->predict[1][0][6] = vp9_convolve8_3qtr;
- scale->predict[1][0][7] = vp9_convolve8_7by8;
- }
- } else {
- if (scale->y_step_q4 == 16) {
- // No scaling in the y direction. Must always scale in the x direction.
- scale->predict[0][0][0] = vp9_convolve8_horiz;
- scale->predict[0][0][1] = vp9_convolve8_1by8_horiz;
- scale->predict[0][0][2] = vp9_convolve8_qtr_horiz;
- scale->predict[0][0][3] = vp9_convolve8_3by8_horiz;
- scale->predict[0][0][4] = vp9_convolve8_avg_horiz;
- scale->predict[0][0][5] = vp9_convolve8_5by8_horiz;
- scale->predict[0][0][6] = vp9_convolve8_3qtr_horiz;
- scale->predict[0][0][7] = vp9_convolve8_7by8_horiz;
- scale->predict[0][1][0] = vp9_convolve8;
- scale->predict[0][1][1] = vp9_convolve8_1by8;
- scale->predict[0][1][2] = vp9_convolve8_qtr;
- scale->predict[0][1][3] = vp9_convolve8_3by8;
- scale->predict[0][1][4] = vp9_convolve8_avg;
- scale->predict[0][1][5] = vp9_convolve8_5by8;
- scale->predict[0][1][6] = vp9_convolve8_3qtr;
- scale->predict[0][1][7] = vp9_convolve8_7by8;
- scale->predict[1][0][0] = vp9_convolve8_horiz;
- scale->predict[1][0][1] = vp9_convolve8_1by8_horiz;
- scale->predict[1][0][2] = vp9_convolve8_qtr_horiz;
- scale->predict[1][0][3] = vp9_convolve8_3by8_horiz;
- scale->predict[1][0][4] = vp9_convolve8_avg_horiz;
- scale->predict[1][0][5] = vp9_convolve8_5by8_horiz;
- scale->predict[1][0][6] = vp9_convolve8_3qtr_horiz;
- scale->predict[1][0][7] = vp9_convolve8_7by8_horiz;
- } else {
- // Must always scale in both directions.
- scale->predict[0][0][0] = vp9_convolve8;
- scale->predict[0][0][1] = vp9_convolve8_1by8;
- scale->predict[0][0][2] = vp9_convolve8_qtr;
- scale->predict[0][0][3] = vp9_convolve8_3by8;
- scale->predict[0][0][4] = vp9_convolve8_avg;
- scale->predict[0][0][5] = vp9_convolve8_5by8;
- scale->predict[0][0][6] = vp9_convolve8_3qtr;
- scale->predict[0][0][7] = vp9_convolve8_7by8;
- scale->predict[0][1][0] = vp9_convolve8;
- scale->predict[0][1][1] = vp9_convolve8_1by8;
- scale->predict[0][1][2] = vp9_convolve8_qtr;
- scale->predict[0][1][3] = vp9_convolve8_3by8;
- scale->predict[0][1][4] = vp9_convolve8_avg;
- scale->predict[0][1][5] = vp9_convolve8_5by8;
- scale->predict[0][1][6] = vp9_convolve8_3qtr;
- scale->predict[0][1][7] = vp9_convolve8_7by8;
- scale->predict[1][0][0] = vp9_convolve8;
- scale->predict[1][0][1] = vp9_convolve8_1by8;
- scale->predict[1][0][2] = vp9_convolve8_qtr;
- scale->predict[1][0][3] = vp9_convolve8_3by8;
- scale->predict[1][0][4] = vp9_convolve8_avg;
- scale->predict[1][0][5] = vp9_convolve8_5by8;
- scale->predict[1][0][6] = vp9_convolve8_3qtr;
- scale->predict[1][0][7] = vp9_convolve8_7by8;
- }
- }
- // 2D subpel motion always gets filtered in both directions
- scale->predict[1][1][0] = vp9_convolve8;
- scale->predict[1][1][1] = vp9_convolve8_1by8;
- scale->predict[1][1][2] = vp9_convolve8_qtr;
- scale->predict[1][1][3] = vp9_convolve8_3by8;
- scale->predict[1][1][4] = vp9_convolve8_avg;
- scale->predict[1][1][5] = vp9_convolve8_5by8;
- scale->predict[1][1][6] = vp9_convolve8_3qtr;
- scale->predict[1][1][7] = vp9_convolve8_7by8;
-}
-#else
if (scale->x_step_q4 == 16) {
if (scale->y_step_q4 == 16) {
// No scaling in either direction.
@@ -219,7 +98,6 @@ void vp9_setup_scale_factors_for_frame(struct scale_factors *scale,
scale->predict[1][1][0] = vp9_convolve8;
scale->predict[1][1][1] = vp9_convolve8_avg;
}
-#endif
void vp9_setup_interp_filters(MACROBLOCKD *xd,
INTERPOLATIONFILTERTYPE mcomp_filter_type,
@@ -383,60 +261,6 @@ void vp9_build_inter_predictor_q4(const uint8_t *src, int src_stride,
w, h);
}
-static void build_2x1_inter_predictor_wh(const BLOCKD *d0, const BLOCKD *d1,
- struct scale_factors *s,
- uint8_t *predictor,
- int block_size, int stride,
- int which_mv, int weight,
- int width, int height,
- const struct subpix_fn_table *subpix,
- int row, int col) {
- struct scale_factors * scale = &s[which_mv];
-
- assert(d1->dst - d0->dst == block_size);
- assert(d1->pre == d0->pre + block_size);
-
- scale->set_scaled_offsets(scale, row, col);
-
- if (d0->bmi.as_mv[which_mv].as_int == d1->bmi.as_mv[which_mv].as_int) {
- uint8_t **base_pre = which_mv ? d0->base_second_pre : d0->base_pre;
-
- vp9_build_inter_predictor(*base_pre + d0->pre,
- d0->pre_stride,
- predictor, stride,
- &d0->bmi.as_mv[which_mv],
- scale,
- width, height,
- weight, subpix);
-
- } else {
- uint8_t **base_pre0 = which_mv ? d0->base_second_pre : d0->base_pre;
- uint8_t **base_pre1 = which_mv ? d1->base_second_pre : d1->base_pre;
-
- vp9_build_inter_predictor(*base_pre0 + d0->pre,
- d0->pre_stride,
- predictor, stride,
- &d0->bmi.as_mv[which_mv],
- scale,
- width > block_size ? block_size : width, height,
- weight, subpix);
-
- if (width <= block_size) return;
-
- scale->set_scaled_offsets(scale, row, col + block_size);
-
- vp9_build_inter_predictor(*base_pre1 + d1->pre,
- d1->pre_stride,
- predictor + block_size, stride,
- &d1->bmi.as_mv[which_mv],
- scale,
- width - block_size, height,
- weight, subpix);
- }
-}
-
-#if !CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT
-
static INLINE int round_mv_comp_q4(int value) {
return (value < 0 ? value - 2 : value + 2) / 4;
}
@@ -623,590 +447,12 @@ void vp9_build_inter_predictors_sb(MACROBLOCKD *xd,
vp9_build_inter_predictors_sbuv(xd, mb_row, mb_col, bsize);
#if CONFIG_COMP_INTERINTRA_PRED
- if (xd->mode_info_context->mbmi.second_ref_frame == INTRA_FRAME) {
- if (bsize == BLOCK_SIZE_SB32X32)
- vp9_build_interintra_32x32_predictors_sb(xd, y, u, v,
- y_stride, uv_stride);
- else
- vp9_build_interintra_64x64_predictors_sb(xd, y, u, v,
- y_stride, uv_stride);
- }
-#endif
-}
-#endif // !CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT
-
-#define AVERAGE_WEIGHT (1 << (2 * CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT))
-
-#if CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT
-
-static void clamp_mv_to_umv_border(MV *mv, const MACROBLOCKD *xd) {
- /* If the MV points so far into the UMV border that no visible pixels
- * are used for reconstruction, the subpel part of the MV can be
- * discarded and the MV limited to 16 pixels with equivalent results.
- *
- * This limit kicks in at 19 pixels for the top and left edges, for
- * the 16 pixels plus 3 taps right of the central pixel when subpel
- * filtering. The bottom and right edges use 16 pixels plus 2 pixels
- * left of the central pixel when filtering.
- */
- if (mv->col < (xd->mb_to_left_edge - ((16 + VP9_INTERP_EXTEND) << 3)))
- mv->col = xd->mb_to_left_edge - (16 << 3);
- else if (mv->col > xd->mb_to_right_edge + ((15 + VP9_INTERP_EXTEND) << 3))
- mv->col = xd->mb_to_right_edge + (16 << 3);
-
- if (mv->row < (xd->mb_to_top_edge - ((16 + VP9_INTERP_EXTEND) << 3)))
- mv->row = xd->mb_to_top_edge - (16 << 3);
- else if (mv->row > xd->mb_to_bottom_edge + ((15 + VP9_INTERP_EXTEND) << 3))
- mv->row = xd->mb_to_bottom_edge + (16 << 3);
-}
-
-// Whether to use implicit weighting for UV
-#define USE_IMPLICIT_WEIGHT_UV
-
-// Whether to use implicit weighting for SplitMV
-// #define USE_IMPLICIT_WEIGHT_SPLITMV
-
-// #define SEARCH_MIN3
-static int64_t get_consistency_metric(MACROBLOCKD *xd,
- uint8_t *tmp_y, int tmp_ystride) {
- int block_size = 16 << xd->mode_info_context->mbmi.sb_type;
- uint8_t *rec_y = xd->plane[0].dst.buf;
- int rec_ystride = xd->plane[0].dst.stride;
- int64_t metric = 0;
- int i;
- if (xd->up_available) {
- for (i = 0; i < block_size; ++i) {
- int diff = abs(*(rec_y - rec_ystride + i) -
- *(tmp_y + i));
-#ifdef SEARCH_MIN3
- // Searches for the min abs diff among 3 pixel neighbors in the border
- int diff1 = xd->left_available ?
- abs(*(rec_y - rec_ystride + i - 1) - *(tmp_y + i)) : diff;
- int diff2 = i < block_size - 1 ?
- abs(*(rec_y - rec_ystride + i + 1) - *(tmp_y + i)) : diff;
- diff = diff <= diff1 ? diff : diff1;
- diff = diff <= diff2 ? diff : diff2;
-#endif
- metric += diff;
- }
- }
- if (xd->left_available) {
- for (i = 0; i < block_size; ++i) {
- int diff = abs(*(rec_y - 1 + i * rec_ystride) -
- *(tmp_y + i * tmp_ystride));
-#ifdef SEARCH_MIN3
- // Searches for the min abs diff among 3 pixel neighbors in the border
- int diff1 = xd->up_available ?
- abs(*(rec_y - 1 + (i - 1) * rec_ystride) -
- *(tmp_y + i * tmp_ystride)) : diff;
- int diff2 = i < block_size - 1 ?
- abs(*(rec_y - 1 + (i + 1) * rec_ystride) -
- *(tmp_y + i * tmp_ystride)) : diff;
- diff = diff <= diff1 ? diff : diff1;
- diff = diff <= diff2 ? diff : diff2;
-#endif
- metric += diff;
- }
- }
- return metric;
-}
-
-static int get_weight(MACROBLOCKD *xd, int64_t metric_1, int64_t metric_2) {
- int weight = AVERAGE_WEIGHT;
- if (2 * metric_1 < metric_2)
- weight = 6;
- else if (4 * metric_1 < 3 * metric_2)
- weight = 5;
- else if (2 * metric_2 < metric_1)
- weight = 2;
- else if (4 * metric_2 < 3 * metric_1)
- weight = 3;
- return weight;
-}
-
-#ifdef USE_IMPLICIT_WEIGHT_SPLITMV
-static int get_implicit_compoundinter_weight_splitmv(
- MACROBLOCKD *xd, int mb_row, int mb_col) {
- MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi;
- BLOCKD *blockd = xd->block;
- const int use_second_ref = mbmi->second_ref_frame > 0;
- int64_t metric_2 = 0, metric_1 = 0;
- int i, which_mv, weight;
- uint8_t tmp_y[256];
- const int tmp_ystride = 16;
-
- if (!use_second_ref) return 0;
- if (!(xd->up_available || xd->left_available))
- return AVERAGE_WEIGHT;
-
- assert(xd->mode_info_context->mbmi.mode == SPLITMV);
-
- which_mv = 1; // second predictor
- if (xd->mode_info_context->mbmi.partitioning != PARTITIONING_4X4) {
- for (i = 0; i < 16; i += 8) {
- BLOCKD *d0 = &blockd[i];
- BLOCKD *d1 = &blockd[i + 2];
- const int y = i & 8;
-
- blockd[i + 0].bmi = xd->mode_info_context->bmi[i + 0];
- blockd[i + 2].bmi = xd->mode_info_context->bmi[i + 2];
-
- if (mbmi->need_to_clamp_mvs) {
- clamp_mv_to_umv_border(&blockd[i + 0].bmi.as_mv[which_mv].as_mv, xd);
- clamp_mv_to_umv_border(&blockd[i + 2].bmi.as_mv[which_mv].as_mv, xd);
- }
- if (i == 0) {
- build_2x1_inter_predictor_wh(d0, d1, xd->scale_factor, tmp_y, 8, 16,
- which_mv, 0, 16, 1,
- &xd->subpix, mb_row * 16 + y, mb_col * 16);
- build_2x1_inter_predictor_wh(d0, d1, xd->scale_factor, tmp_y, 8, 16,
- which_mv, 0, 1, 8,
- &xd->subpix, mb_row * 16 + y, mb_col * 16);
- } else {
- build_2x1_inter_predictor_wh(d0, d1, xd->scale_factor, tmp_y + 8 * 16,
- 8, 16, which_mv, 0, 1, 8,
- &xd->subpix, mb_row * 16 + y, mb_col * 16);
- }
- }
- } else {
- for (i = 0; i < 16; i += 2) {
- BLOCKD *d0 = &blockd[i];
- BLOCKD *d1 = &blockd[i + 1];
- const int x = (i & 3) * 4;
- const int y = (i >> 2) * 4;
-
- blockd[i + 0].bmi = xd->mode_info_context->bmi[i + 0];
- blockd[i + 1].bmi = xd->mode_info_context->bmi[i + 1];
-
- if (i >= 4 && (i & 3) != 0) continue;
-
- if (i == 0) {
- build_2x1_inter_predictor_wh(d0, d1, xd->scale_factor, tmp_y, 4, 16,
- which_mv, 0, 8, 1, &xd->subpix,
- mb_row * 16 + y, mb_col * 16 + x);
- build_2x1_inter_predictor_wh(d0, d1, xd->scale_factor, tmp_y, 4, 16,
- which_mv, 0, 1, 4, &xd->subpix,
- mb_row * 16 + y, mb_col * 16 + x);
- } else if (i < 4) {
- build_2x1_inter_predictor_wh(d0, d1, xd->scale_factor, tmp_y + x, 4, 16,
- which_mv, 0, 8, 1, &xd->subpix,
- mb_row * 16 + y, mb_col * 16 + x);
- } else {
- build_2x1_inter_predictor_wh(d0, d1, xd->scale_factor, tmp_y + y * 16,
- 4, 16, which_mv, 0, 1, 4, &xd->subpix,
- mb_row * 16 + y, mb_col * 16 + x);
- }
- }
- }
- metric_2 = get_consistency_metric(xd, tmp_y, tmp_ystride);
-
- which_mv = 0; // first predictor
- if (xd->mode_info_context->mbmi.partitioning != PARTITIONING_4X4) {
- for (i = 0; i < 16; i += 8) {
- BLOCKD *d0 = &blockd[i];
- BLOCKD *d1 = &blockd[i + 2];
- const int y = i & 8;
-
- blockd[i + 0].bmi = xd->mode_info_context->bmi[i + 0];
- blockd[i + 2].bmi = xd->mode_info_context->bmi[i + 2];
-
- if (mbmi->need_to_clamp_mvs) {
- clamp_mv_to_umv_border(&blockd[i + 0].bmi.as_mv[which_mv].as_mv, xd);
- clamp_mv_to_umv_border(&blockd[i + 2].bmi.as_mv[which_mv].as_mv, xd);
- }
- if (i == 0) {
- build_2x1_inter_predictor_wh(d0, d1, xd->scale_factor, tmp_y, 8, 16,
- which_mv, 0, 16, 1,
- &xd->subpix, mb_row * 16 + y, mb_col * 16);
- build_2x1_inter_predictor_wh(d0, d1, xd->scale_factor, tmp_y, 8, 16,
- which_mv, 0, 1, 8,
- &xd->subpix, mb_row * 16 + y, mb_col * 16);
- } else {
- build_2x1_inter_predictor_wh(d0, d1, xd->scale_factor, tmp_y + 8 * 16,
- 8, 16, which_mv, 0, 1, 8,
- &xd->subpix, mb_row * 16 + y, mb_col * 16);
- }
- }
- } else {
- for (i = 0; i < 16; i += 2) {
- BLOCKD *d0 = &blockd[i];
- BLOCKD *d1 = &blockd[i + 1];
- const int x = (i & 3) * 4;
- const int y = (i >> 2) * 4;
-
- blockd[i + 0].bmi = xd->mode_info_context->bmi[i + 0];
- blockd[i + 1].bmi = xd->mode_info_context->bmi[i + 1];
-
- if (i >= 4 && (i & 3) != 0) continue;
-
- if (i == 0) {
- build_2x1_inter_predictor_wh(d0, d1, xd->scale_factor, tmp_y, 4, 16,
- which_mv, 0, 8, 1, &xd->subpix,
- mb_row * 16 + y, mb_col * 16 + x);
- build_2x1_inter_predictor_wh(d0, d1, xd->scale_factor, tmp_y, 4, 16,
- which_mv, 0, 1, 4, &xd->subpix,
- mb_row * 16 + y, mb_col * 16 + x);
- } else if (i < 4) {
- build_2x1_inter_predictor_wh(d0, d1, xd->scale_factor, tmp_y + x, 4, 16,
- which_mv, 0, 8, 1, &xd->subpix,
- mb_row * 16 + y, mb_col * 16 + x);
- } else {
- build_2x1_inter_predictor_wh(d0, d1, xd->scale_factor, tmp_y + y * 16,
- 4, 16, which_mv, 0, 1, 4, &xd->subpix,
- mb_row * 16 + y, mb_col * 16 + x);
- }
- }
- }
- metric_1 = get_consistency_metric(xd, tmp_y, tmp_ystride);
-
- // Choose final weight for averaging
- weight = get_weight(xd, metric_1, metric_2);
- return weight;
-}
-#endif
-
-static int get_implicit_compoundinter_weight(MACROBLOCKD *xd,
- int mb_row,
- int mb_col) {
- const int use_second_ref = xd->mode_info_context->mbmi.second_ref_frame > 0;
- int64_t metric_2 = 0, metric_1 = 0;
- int n, clamp_mvs, pre_stride;
- uint8_t *base_pre;
- int_mv ymv;
- uint8_t tmp_y[4096];
- const int tmp_ystride = 64;
- int weight;
- int edge[4];
- int block_size = 16 << xd->mode_info_context->mbmi.sb_type;
- struct scale_factors *scale;
-
- if (!use_second_ref) return 0;
- if (!(xd->up_available || xd->left_available))
- return AVERAGE_WEIGHT;
-
- edge[0] = xd->mb_to_top_edge;
- edge[1] = xd->mb_to_bottom_edge;
- edge[2] = xd->mb_to_left_edge;
- edge[3] = xd->mb_to_right_edge;
-
- clamp_mvs = xd->mode_info_context->mbmi.need_to_clamp_secondmv;
- base_pre = xd->plane[0].pre[1].buf;
- pre_stride = xd->plane[0].pre[1].stride;
- ymv.as_int = xd->mode_info_context->mbmi.mv[1].as_int;
- // First generate the second predictor
- scale = &xd->scale_factor[1];
- for (n = 0; n < block_size; n += 16) {
- xd->mb_to_left_edge = edge[2] - (n << 3);
- xd->mb_to_right_edge = edge[3] + ((16 - n) << 3);
- if (clamp_mvs)
- clamp_mv_to_umv_border(&ymv.as_mv, xd);
- scale->set_scaled_offsets(scale, mb_row * 16, mb_col * 16 + n);
- // predict a single row of pixels
- vp9_build_inter_predictor(base_pre +
- scaled_buffer_offset(n, 0, pre_stride, scale),
- pre_stride, tmp_y + n, tmp_ystride, &ymv, scale, 16, 1, 0, &xd->subpix);
- }
- xd->mb_to_left_edge = edge[2];
- xd->mb_to_right_edge = edge[3];
- for (n = 0; n < block_size; n += 16) {
- xd->mb_to_top_edge = edge[0] - (n << 3);
- xd->mb_to_bottom_edge = edge[1] + ((16 - n) << 3);
- if (clamp_mvs)
- clamp_mv_to_umv_border(&ymv.as_mv, xd);
- scale->set_scaled_offsets(scale, mb_row * 16 + n, mb_col * 16);
- // predict a single col of pixels
- vp9_build_inter_predictor(base_pre +
- scaled_buffer_offset(0, n, pre_stride, scale),
- pre_stride, tmp_y + n * tmp_ystride, tmp_ystride, &ymv,
- scale, 1, 16, 0, &xd->subpix);
- }
- xd->mb_to_top_edge = edge[0];
- xd->mb_to_bottom_edge = edge[1];
- // Compute consistency metric
- metric_2 = get_consistency_metric(xd, tmp_y, tmp_ystride);
-
- clamp_mvs = xd->mode_info_context->mbmi.need_to_clamp_mvs;
- base_pre = xd->plane[0].pre[0].buf;
- pre_stride = xd->plane[0].pre[0].stride;
- ymv.as_int = xd->mode_info_context->mbmi.mv[0].as_int;
- // Now generate the first predictor
- scale = &xd->scale_factor[0];
- for (n = 0; n < block_size; n += 16) {
- xd->mb_to_left_edge = edge[2] - (n << 3);
- xd->mb_to_right_edge = edge[3] + ((16 - n) << 3);
- if (clamp_mvs)
- clamp_mv_to_umv_border(&ymv.as_mv, xd);
- scale->set_scaled_offsets(scale, mb_row * 16, mb_col * 16 + n);
- // predict a single row of pixels
- vp9_build_inter_predictor(base_pre +
- scaled_buffer_offset(n, 0, pre_stride, scale),
- pre_stride, tmp_y + n, tmp_ystride, &ymv, scale, 16, 1, 0, &xd->subpix);
- }
- xd->mb_to_left_edge = edge[2];
- xd->mb_to_right_edge = edge[3];
- for (n = 0; n < block_size; n += 16) {
- xd->mb_to_top_edge = edge[0] - (n << 3);
- xd->mb_to_bottom_edge = edge[1] + ((16 - n) << 3);
- if (clamp_mvs)
- clamp_mv_to_umv_border(&ymv.as_mv, xd);
- scale->set_scaled_offsets(scale, mb_row * 16 + n, mb_col * 16);
- // predict a single col of pixels
- vp9_build_inter_predictor(base_pre +
- scaled_buffer_offset(0, n, pre_stride, scale),
- pre_stride, tmp_y + n * tmp_ystride, tmp_ystride, &ymv,
- scale, 1, 16, 0, &xd->subpix);
- }
- xd->mb_to_top_edge = edge[0];
- xd->mb_to_bottom_edge = edge[1];
- metric_1 = get_consistency_metric(xd, tmp_y, tmp_ystride);
-
- // Choose final weight for averaging
- weight = get_weight(xd, metric_1, metric_2);
- return weight;
-}
-
-static void build_inter16x16_predictors_mby_w(MACROBLOCKD *xd,
- uint8_t *dst_y,
- int dst_ystride,
- int weight,
- int mb_row,
- int mb_col) {
- const int use_second_ref = xd->mode_info_context->mbmi.second_ref_frame > 0;
- int which_mv;
-
- for (which_mv = 0; which_mv < 1 + use_second_ref; ++which_mv) {
- const int clamp_mvs = which_mv ?
- xd->mode_info_context->mbmi.need_to_clamp_secondmv :
- xd->mode_info_context->mbmi.need_to_clamp_mvs;
-
- uint8_t *base_pre = xd->plane[0].pre[which_mv].buf;
- int pre_stride = xd->plane[0].pre[which_mv].stride;
- int_mv ymv;
- struct scale_factors *scale = &xd->scale_factor[which_mv];
-
- ymv.as_int = xd->mode_info_context->mbmi.mv[which_mv].as_int;
-
- if (clamp_mvs)
- clamp_mv_to_umv_border(&ymv.as_mv, xd);
-
- scale->set_scaled_offsets(scale, mb_row * 16, mb_col * 16);
-
- vp9_build_inter_predictor(base_pre, pre_stride, dst_y, dst_ystride,
- &ymv, scale, 16, 16,
- which_mv ? weight : 0, &xd->subpix);
- }
-}
-
-static void build_inter16x16_predictors_mbuv_w(MACROBLOCKD *xd,
- uint8_t *dst_u,
- uint8_t *dst_v,
- int dst_uvstride,
- int weight,
- int mb_row,
- int mb_col) {
- const int use_second_ref = xd->mode_info_context->mbmi.second_ref_frame > 0;
- int which_mv;
-
- for (which_mv = 0; which_mv < 1 + use_second_ref; ++which_mv) {
- const int clamp_mvs =
- which_mv ? xd->mode_info_context->mbmi.need_to_clamp_secondmv
- : xd->mode_info_context->mbmi.need_to_clamp_mvs;
- uint8_t *uptr, *vptr;
- int pre_stride = which_mv ? xd->plane[1].pre[1].stride
- : xd->plane[1].pre[0].stride;
- int_mv mv;
-
- struct scale_factors *scale = &xd->scale_factor_uv[which_mv];
- mv.as_int = xd->mode_info_context->mbmi.mv[which_mv].as_int;
-
-
- if (clamp_mvs)
- clamp_mv_to_umv_border(&mv.as_mv, xd);
-
- uptr = (which_mv ? xd->plane[1].pre[1].buf : xd->plane[1].pre[0].buf);
- vptr = (which_mv ? xd->plane[2].pre[1].buf : xd->plane[2].pre[0].buf);
-
- scale->set_scaled_offsets(scale, mb_row * 16, mb_col * 16);
-
- vp9_build_inter_predictor_q4(
- uptr, pre_stride, dst_u, dst_uvstride, &mv,
- scale, 8, 8, which_mv ? weight : 0, &xd->subpix);
-
- vp9_build_inter_predictor_q4(
- vptr, pre_stride, dst_v, dst_uvstride, &mv,
- scale, 8, 8, which_mv ? weight : 0, &xd->subpix);
- }
-}
-static void build_inter_predictors_sby_w(MACROBLOCKD *x,
- uint8_t *dst_y,
- int dst_ystride,
- int weight,
- int mb_row,
- int mb_col,
- BLOCK_SIZE_TYPE bsize) {
- const int bwl = mb_width_log2(bsize), bw = 1 << bwl;
- const int bhl = mb_height_log2(bsize), bh = 1 << bhl;
- uint8_t *y1 = x->plane[0].pre[0].buf;
- uint8_t *y2 = x->plane[0].pre[1].buf;
- int edge[4], n;
-
- edge[0] = x->mb_to_top_edge;
- edge[1] = x->mb_to_bottom_edge;
- edge[2] = x->mb_to_left_edge;
- edge[3] = x->mb_to_right_edge;
-
- for (n = 0; n < bw * bh; n++) {
- const int x_idx = n & (bw - 1), y_idx = n >> bwl;
-
- x->mb_to_top_edge = edge[0] - ((y_idx * 16) << 3);
- x->mb_to_bottom_edge = edge[1] + (((bh - 1 - y_idx) * 16) << 3);
- x->mb_to_left_edge = edge[2] - ((x_idx * 16) << 3);
- x->mb_to_right_edge = edge[3] + (((bw - 1 - x_idx) * 16) << 3);
-
- x->plane[0].pre[0].buf = y1 + scaled_buffer_offset(x_idx * 16,
- y_idx * 16,
- x->plane[0].pre[0].stride,
- &x->scale_factor[0]);
- if (x->mode_info_context->mbmi.second_ref_frame > 0) {
- x->plane[0].pre[1].buf = y2 +
- scaled_buffer_offset(x_idx * 16,
- y_idx * 16,
- x->plane[0].pre[1].stride,
- &x->scale_factor[1]);
- }
- build_inter16x16_predictors_mby_w(x,
- dst_y + y_idx * 16 * dst_ystride + x_idx * 16,
- dst_ystride, weight, mb_row + y_idx, mb_col + x_idx);
- }
- x->mb_to_top_edge = edge[0];
- x->mb_to_bottom_edge = edge[1];
- x->mb_to_left_edge = edge[2];
- x->mb_to_right_edge = edge[3];
-
- x->plane[0].pre[0].buf = y1;
- if (x->mode_info_context->mbmi.second_ref_frame > 0) {
- x->plane[0].pre[1].buf = y2;
- }
-}
-
-void vp9_build_inter_predictors_sby(MACROBLOCKD *x,
- int mb_row,
- int mb_col,
- BLOCK_SIZE_TYPE bsize) {
- uint8_t * const dst_y = x->plane[0].dst.buf;
- const int dst_ystride = x->plane[0].dst.stride;
-
- int weight = get_implicit_compoundinter_weight(x, mb_row, mb_col);
- build_inter_predictors_sby_w(x, dst_y, dst_ystride, weight,
- mb_row, mb_col, bsize);
-}
-
-static void build_inter_predictors_sbuv_w(MACROBLOCKD *x,
- uint8_t *dst_u,
- uint8_t *dst_v,
- int dst_uvstride,
- int weight,
- int mb_row,
- int mb_col,
- BLOCK_SIZE_TYPE bsize) {
- const int bwl = mb_width_log2(bsize), bw = 1 << bwl;
- const int bhl = mb_height_log2(bsize), bh = 1 << bhl;
- uint8_t *u1 = x->plane[1].pre[0].buf, *v1 = x->plane[2].pre[0].buf;
- uint8_t *u2 = x->plane[1].pre[1].buf, *v2 = x->plane[2].pre[1].buf;
- int edge[4], n;
-
- edge[0] = x->mb_to_top_edge;
- edge[1] = x->mb_to_bottom_edge;
- edge[2] = x->mb_to_left_edge;
- edge[3] = x->mb_to_right_edge;
-
- for (n = 0; n < bw * bh; n++) {
- int scaled_uv_offset;
- const int x_idx = n & (bw - 1), y_idx = n >> bwl;
-
- x->mb_to_top_edge = edge[0] - ((y_idx * 16) << 3);
- x->mb_to_bottom_edge = edge[1] + (((bh - 1 - y_idx) * 16) << 3);
- x->mb_to_left_edge = edge[2] - ((x_idx * 16) << 3);
- x->mb_to_right_edge = edge[3] + (((bw - 1 - x_idx) * 16) << 3);
-
- scaled_uv_offset = scaled_buffer_offset(x_idx * 8,
- y_idx * 8,
- x->plane[1].pre[0].stride,
- &x->scale_factor_uv[0]);
- x->plane[1].pre[0].buf = u1 + scaled_uv_offset;
- x->plane[2].pre[0].buf = v1 + scaled_uv_offset;
-
- if (x->mode_info_context->mbmi.second_ref_frame > 0) {
- scaled_uv_offset = scaled_buffer_offset(x_idx * 8,
- y_idx * 8,
- x->plane[1].pre[1].stride,
- &x->scale_factor_uv[1]);
- x->plane[1].pre[1].buf = u2 + scaled_uv_offset;
- x->plane[2].pre[1].buf = v2 + scaled_uv_offset;
- }
-
- build_inter16x16_predictors_mbuv_w(x,
- dst_u + y_idx * 8 * dst_uvstride + x_idx * 8,
- dst_v + y_idx * 8 * dst_uvstride + x_idx * 8,
- dst_uvstride, weight, mb_row + y_idx, mb_col + x_idx);
- }
- x->mb_to_top_edge = edge[0];
- x->mb_to_bottom_edge = edge[1];
- x->mb_to_left_edge = edge[2];
- x->mb_to_right_edge = edge[3];
-
- x->plane[1].pre[0].buf = u1;
- x->plane[2].pre[0].buf = v1;
-
- if (x->mode_info_context->mbmi.second_ref_frame > 0) {
- x->plane[1].pre[1].buf = u2;
- x->plane[2].pre[1].buf = v2;
- }
-}
-
-void vp9_build_inter_predictors_sbuv(MACROBLOCKD *xd,
- int mb_row,
- int mb_col,
- BLOCK_SIZE_TYPE bsize) {
- uint8_t *const dst_u = xd->plane[1].dst.buf;
- uint8_t *const dst_v = xd->plane[2].dst.buf;
- const int dst_uvstride = xd->plane[1].dst.stride;
-
-#ifdef USE_IMPLICIT_WEIGHT_UV
- int weight = get_implicit_compoundinter_weight(xd, mb_row, mb_col);
-#else
- int weight = AVERAGE_WEIGHT;
-#endif
- build_inter_predictors_sbuv_w(xd, dst_u, dst_v, dst_uvstride,
- weight, mb_row, mb_col, bsize);
-}
-
-void vp9_build_inter_predictors_sb(MACROBLOCKD *mb,
- int mb_row, int mb_col,
- BLOCK_SIZE_TYPE bsize) {
-#if CONFIG_COMP_INTERINTRA_PRED
- uint8_t *const y = mb->plane[0].dst.buf;
- uint8_t *const u = mb->plane[1].dst.buf;
- uint8_t *const v = mb->plane[2].dst.buf;
- const int y_stride = mb->plane[0].dst.stride;
- const int uv_stride = mb->plane[1].dst.stride;
-#endif
-
- vp9_build_inter_predictors_sby(mb, mb_row, mb_col, bsize);
- vp9_build_inter_predictors_sbuv(mb, mb_row, mb_col, bsize);
-
-#if CONFIG_COMP_INTERINTRA_PRED
- if (mb->mode_info_context->mbmi.second_ref_frame == INTRA_FRAME) {
- if (bsize == BLOCK_SIZE_SB32X32)
- vp9_build_interintra_32x32_predictors_sb(mb, y, u, v,
- y_stride, uv_stride);
- else
- vp9_build_interintra_64x64_predictors_sb(mb, y, u, v,
- y_stride, uv_stride);
- }
+ if (xd->mode_info_context->mbmi.second_ref_frame == INTRA_FRAME)
+ vp9_build_interintra_predictors(xd, y, u, v,
+ y_stride, uv_stride,
+ bsize);
#endif
}
-#endif // CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT
static INLINE int round_mv_comp(int value) {
return (value < 0 ? value - 2 : value + 2) / 4;
diff --git a/vp9/common/vp9_reconintra.c b/vp9/common/vp9_reconintra.c
index 6caebd784..4e786b0f8 100644
--- a/vp9/common/vp9_reconintra.c
+++ b/vp9/common/vp9_reconintra.c
@@ -227,61 +227,6 @@ static void d153_predictor(uint8_t *ypred_ptr, int y_stride,
}
}
-static void corner_predictor(uint8_t *ypred_ptr, int y_stride, int n,
- uint8_t *yabove_row,
- uint8_t *yleft_col) {
- int mh, mv, maxgradh, maxgradv, x, y, nx, ny;
- int i, j;
- int top_left = yabove_row[-1];
- mh = mv = 0;
- maxgradh = yabove_row[1] - top_left;
- maxgradv = yleft_col[1] - top_left;
- for (i = 2; i < n; ++i) {
- int gh = yabove_row[i] - yabove_row[i - 2];
- int gv = yleft_col[i] - yleft_col[i - 2];
- if (gh > maxgradh) {
- maxgradh = gh;
- mh = i - 1;
- }
- if (gv > maxgradv) {
- maxgradv = gv;
- mv = i - 1;
- }
- }
- nx = mh + mv + 3;
- ny = 2 * n + 1 - nx;
-
- x = top_left;
- for (i = 0; i <= mh; ++i) x += yabove_row[i];
- for (i = 0; i <= mv; ++i) x += yleft_col[i];
- x += (nx >> 1);
- x /= nx;
- y = 0;
- for (i = mh + 1; i < n; ++i) y += yabove_row[i];
- for (i = mv + 1; i < n; ++i) y += yleft_col[i];
- y += (ny >> 1);
- y /= ny;
-
- for (i = 0; i < n; ++i) {
- for (j = 0; j < n; ++j)
- ypred_ptr[j] = (i <= mh && j <= mv ? x : y);
- ypred_ptr += y_stride;
- }
-}
-
-static INLINE int log2_minus_1(int n) {
- switch (n) {
- case 4: return 1;
- case 8: return 2;
- case 16: return 3;
- case 32: return 4;
- case 64: return 5;
- default:
- assert(0);
- return 0;
- }
-}
-
void vp9_build_intra_predictors(uint8_t *src, int src_stride,
uint8_t *ypred_ptr,
int y_stride, int mode,
@@ -465,7 +410,7 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
int interstride,
uint8_t *intrapred,
int intrastride,
- int size) {
+ int bw, int bh) {
// TODO(debargha): Explore different ways of combining predictors
// or designing the tables below
static const int scale_bits = 8;
@@ -483,6 +428,7 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
68, 68, 68, 67, 67, 67, 67, 67,
};
+ int size = MAX(bw, bh);
int size_scale = (size >= 64 ? 1:
size == 32 ? 2 :
size == 16 ? 4 :
@@ -490,8 +436,8 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
int i, j;
switch (mode) {
case V_PRED:
- for (i = 0; i < size; ++i) {
- for (j = 0; j < size; ++j) {
+ for (i = 0; i < bh; ++i) {
+ for (j = 0; j < bw; ++j) {
int k = i * interstride + j;
int scale = weights1d[i * size_scale];
interpred[k] =
@@ -503,8 +449,8 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
break;
case H_PRED:
- for (i = 0; i < size; ++i) {
- for (j = 0; j < size; ++j) {
+ for (i = 0; i < bh; ++i) {
+ for (j = 0; j < bw; ++j) {
int k = i * interstride + j;
int scale = weights1d[j * size_scale];
interpred[k] =
@@ -517,8 +463,8 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
case D63_PRED:
case D117_PRED:
- for (i = 0; i < size; ++i) {
- for (j = 0; j < size; ++j) {
+ for (i = 0; i < bh; ++i) {
+ for (j = 0; j < bw; ++j) {
int k = i * interstride + j;
int scale = (weights1d[i * size_scale] * 3 +
weights1d[j * size_scale]) >> 2;
@@ -532,8 +478,8 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
case D27_PRED:
case D153_PRED:
- for (i = 0; i < size; ++i) {
- for (j = 0; j < size; ++j) {
+ for (i = 0; i < bh; ++i) {
+ for (j = 0; j < bw; ++j) {
int k = i * interstride + j;
int scale = (weights1d[j * size_scale] * 3 +
weights1d[i * size_scale]) >> 2;
@@ -546,8 +492,8 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
break;
case D135_PRED:
- for (i = 0; i < size; ++i) {
- for (j = 0; j < size; ++j) {
+ for (i = 0; i < bh; ++i) {
+ for (j = 0; j < bw; ++j) {
int k = i * interstride + j;
int scale = weights1d[(i < j ? i : j) * size_scale];
interpred[k] =
@@ -559,8 +505,8 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
break;
case D45_PRED:
- for (i = 0; i < size; ++i) {
- for (j = 0; j < size; ++j) {
+ for (i = 0; i < bh; ++i) {
+ for (j = 0; j < bw; ++j) {
int k = i * interstride + j;
int scale = (weights1d[i * size_scale] +
weights1d[j * size_scale]) >> 1;
@@ -576,8 +522,8 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
case DC_PRED:
default:
// simple average
- for (i = 0; i < size; ++i) {
- for (j = 0; j < size; ++j) {
+ for (i = 0; i < bh; ++i) {
+ for (j = 0; j < bw; ++j) {
int k = i * interstride + j;
interpred[k] = (interpred[k] + intrapred[i * intrastride + j]) >> 1;
}
@@ -586,137 +532,55 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
}
}
-void vp9_build_interintra_16x16_predictors_mb(MACROBLOCKD *xd,
+void vp9_build_interintra_predictors(MACROBLOCKD *xd,
uint8_t *ypred,
uint8_t *upred,
uint8_t *vpred,
- int ystride, int uvstride) {
- vp9_build_interintra_16x16_predictors_mby(xd, ypred, ystride);
- vp9_build_interintra_16x16_predictors_mbuv(xd, upred, vpred, uvstride);
+ int ystride, int uvstride,
+ BLOCK_SIZE_TYPE bsize) {
+ vp9_build_interintra_predictors_sby(xd, ypred, ystride, bsize);
+ vp9_build_interintra_predictors_sbuv(xd, upred, vpred, uvstride, bsize);
}
-void vp9_build_interintra_16x16_predictors_mby(MACROBLOCKD *xd,
+void vp9_build_interintra_predictors_sby(MACROBLOCKD *xd,
uint8_t *ypred,
- int ystride) {
- uint8_t intrapredictor[256];
- vp9_build_intra_predictors(
- xd->plane[0].dst.buf, xd->plane[0].dst.stride,
- intrapredictor, 16,
- xd->mode_info_context->mbmi.interintra_mode, 16, 16,
- xd->up_available, xd->left_available, xd->right_available);
- combine_interintra(xd->mode_info_context->mbmi.interintra_mode,
- ypred, ystride, intrapredictor, 16, 16);
-}
-
-void vp9_build_interintra_16x16_predictors_mbuv(MACROBLOCKD *xd,
- uint8_t *upred,
- uint8_t *vpred,
- int uvstride) {
- uint8_t uintrapredictor[64];
- uint8_t vintrapredictor[64];
- vp9_build_intra_predictors(
- xd->plane[1].dst.buf, xd->plane[1].dst.stride,
- uintrapredictor, 8,
- xd->mode_info_context->mbmi.interintra_uv_mode, 8, 8,
- xd->up_available, xd->left_available, xd->right_available);
- vp9_build_intra_predictors(
- xd->plane[2].dst.buf, xd->plane[1].dst.stride,
- vintrapredictor, 8,
- xd->mode_info_context->mbmi.interintra_uv_mode, 8, 8,
- xd->up_available, xd->left_available, xd->right_available);
- combine_interintra(xd->mode_info_context->mbmi.interintra_uv_mode,
- upred, uvstride, uintrapredictor, 8, 8);
- combine_interintra(xd->mode_info_context->mbmi.interintra_uv_mode,
- vpred, uvstride, vintrapredictor, 8, 8);
-}
-
-void vp9_build_interintra_32x32_predictors_sby(MACROBLOCKD *xd,
- uint8_t *ypred,
- int ystride) {
- uint8_t intrapredictor[1024];
+ int ystride,
+ BLOCK_SIZE_TYPE bsize) {
+ int bwl = mb_width_log2(bsize), bw = 16 << bwl;
+ int bhl = mb_height_log2(bsize), bh = 16 << bhl;
+ uint8_t intrapredictor[4096];
vp9_build_intra_predictors(
xd->plane[0].dst.buf, xd->plane[0].dst.stride,
- intrapredictor, 32,
- xd->mode_info_context->mbmi.interintra_mode, 32, 32,
+ intrapredictor, bw,
+ xd->mode_info_context->mbmi.interintra_mode, bw, bh,
xd->up_available, xd->left_available, xd->right_available);
combine_interintra(xd->mode_info_context->mbmi.interintra_mode,
- ypred, ystride, intrapredictor, 32, 32);
+ ypred, ystride, intrapredictor, bw, bw, bh);
}
-void vp9_build_interintra_32x32_predictors_sbuv(MACROBLOCKD *xd,
+void vp9_build_interintra_predictors_sbuv(MACROBLOCKD *xd,
uint8_t *upred,
uint8_t *vpred,
- int uvstride) {
- uint8_t uintrapredictor[256];
- uint8_t vintrapredictor[256];
+ int uvstride,
+ BLOCK_SIZE_TYPE bsize) {
+ int bwl = mb_width_log2(bsize), bw = 8 << bwl;
+ int bhl = mb_height_log2(bsize), bh = 8 << bhl;
+ uint8_t uintrapredictor[1024];
+ uint8_t vintrapredictor[1024];
vp9_build_intra_predictors(
xd->plane[1].dst.buf, xd->plane[1].dst.stride,
- uintrapredictor, 16,
- xd->mode_info_context->mbmi.interintra_uv_mode, 16, 16,
+ uintrapredictor, bw,
+ xd->mode_info_context->mbmi.interintra_uv_mode, bw, bh,
xd->up_available, xd->left_available, xd->right_available);
vp9_build_intra_predictors(
xd->plane[2].dst.buf, xd->plane[1].dst.stride,
- vintrapredictor, 16,
- xd->mode_info_context->mbmi.interintra_uv_mode, 16, 16,
+ vintrapredictor, bw,
+ xd->mode_info_context->mbmi.interintra_uv_mode, bw, bh,
xd->up_available, xd->left_available, xd->right_available);
combine_interintra(xd->mode_info_context->mbmi.interintra_uv_mode,
- upred, uvstride, uintrapredictor, 16, 16);
+ upred, uvstride, uintrapredictor, bw, bw, bh);
combine_interintra(xd->mode_info_context->mbmi.interintra_uv_mode,
- vpred, uvstride, vintrapredictor, 16, 16);
-}
-
-void vp9_build_interintra_32x32_predictors_sb(MACROBLOCKD *xd,
- uint8_t *ypred,
- uint8_t *upred,
- uint8_t *vpred,
- int ystride,
- int uvstride) {
- vp9_build_interintra_32x32_predictors_sby(xd, ypred, ystride);
- vp9_build_interintra_32x32_predictors_sbuv(xd, upred, vpred, uvstride);
-}
-
-void vp9_build_interintra_64x64_predictors_sby(MACROBLOCKD *xd,
- uint8_t *ypred,
- int ystride) {
- uint8_t intrapredictor[4096];
- const int mode = xd->mode_info_context->mbmi.interintra_mode;
- vp9_build_intra_predictors(xd->plane[0].dst.buf, xd->plane[0].dst.stride,
- intrapredictor, 64, mode, 64, 64,
- xd->up_available, xd->left_available,
- xd->right_available);
- combine_interintra(xd->mode_info_context->mbmi.interintra_mode,
- ypred, ystride, intrapredictor, 64, 64);
-}
-
-void vp9_build_interintra_64x64_predictors_sbuv(MACROBLOCKD *xd,
- uint8_t *upred,
- uint8_t *vpred,
- int uvstride) {
- uint8_t uintrapredictor[1024];
- uint8_t vintrapredictor[1024];
- const int mode = xd->mode_info_context->mbmi.interintra_uv_mode;
- vp9_build_intra_predictors(xd->plane[1].dst.buf, xd->plane[1].dst.stride,
- uintrapredictor, 32, mode, 32, 32,
- xd->up_available, xd->left_available,
- xd->right_available);
- vp9_build_intra_predictors(xd->plane[2].dst.buf, xd->plane[1].dst.stride,
- vintrapredictor, 32, mode, 32, 32,
- xd->up_available, xd->left_available,
- xd->right_available);
- combine_interintra(xd->mode_info_context->mbmi.interintra_uv_mode,
- upred, uvstride, uintrapredictor, 32, 32);
- combine_interintra(xd->mode_info_context->mbmi.interintra_uv_mode,
- vpred, uvstride, vintrapredictor, 32, 32);
-}
-
-void vp9_build_interintra_64x64_predictors_sb(MACROBLOCKD *xd,
- uint8_t *ypred,
- uint8_t *upred,
- uint8_t *vpred,
- int ystride,
- int uvstride) {
- vp9_build_interintra_64x64_predictors_sby(xd, ypred, ystride);
- vp9_build_interintra_64x64_predictors_sbuv(xd, upred, vpred, uvstride);
+ vpred, uvstride, vintrapredictor, bw, bw, bh);
}
#endif // CONFIG_COMP_INTERINTRA_PRED
diff --git a/vp9/common/vp9_reconintra.h b/vp9/common/vp9_reconintra.h
index 1e0cfa42d..e94359683 100644
--- a/vp9/common/vp9_reconintra.h
+++ b/vp9/common/vp9_reconintra.h
@@ -21,35 +21,24 @@ B_PREDICTION_MODE vp9_find_dominant_direction(uint8_t *ptr,
B_PREDICTION_MODE vp9_find_bpred_context(MACROBLOCKD *xd, BLOCKD *x);
#if CONFIG_COMP_INTERINTRA_PRED
-void vp9_build_interintra_16x16_predictors_mb(MACROBLOCKD *xd,
- uint8_t *ypred,
- uint8_t *upred,
- uint8_t *vpred,
- int ystride,
- int uvstride);
-
-void vp9_build_interintra_16x16_predictors_mby(MACROBLOCKD *xd,
- uint8_t *ypred,
- int ystride);
-
-void vp9_build_interintra_16x16_predictors_mbuv(MACROBLOCKD *xd,
- uint8_t *upred,
- uint8_t *vpred,
- int uvstride);
+void vp9_build_interintra_predictors(MACROBLOCKD *xd,
+ uint8_t *ypred,
+ uint8_t *upred,
+ uint8_t *vpred,
+ int ystride,
+ int uvstride,
+ BLOCK_SIZE_TYPE bsize);
+
+void vp9_build_interintra_predictors_sby(MACROBLOCKD *xd,
+ uint8_t *ypred,
+ int ystride,
+ BLOCK_SIZE_TYPE bsize);
+
+void vp9_build_interintra_predictors_sbuv(MACROBLOCKD *xd,
+ uint8_t *upred,
+ uint8_t *vpred,
+ int uvstride,
+ BLOCK_SIZE_TYPE bsize);
#endif // CONFIG_COMP_INTERINTRA_PRED
-void vp9_build_interintra_32x32_predictors_sb(MACROBLOCKD *xd,
- uint8_t *ypred,
- uint8_t *upred,
- uint8_t *vpred,
- int ystride,
- int uvstride);
-
-void vp9_build_interintra_64x64_predictors_sb(MACROBLOCKD *xd,
- uint8_t *ypred,
- uint8_t *upred,
- uint8_t *vpred,
- int ystride,
- int uvstride);
-
#endif // VP9_COMMON_VP9_RECONINTRA_H_
diff --git a/vp9/common/vp9_rtcd_defs.sh b/vp9/common/vp9_rtcd_defs.sh
index 020841c42..61a2de45f 100644
--- a/vp9/common/vp9_rtcd_defs.sh
+++ b/vp9/common/vp9_rtcd_defs.sh
@@ -230,62 +230,6 @@ specialize vp9_convolve8_avg_horiz ssse3
prototype void vp9_convolve8_avg_vert "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"
specialize vp9_convolve8_avg_vert ssse3
-#if CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT
-prototype void vp9_convolve8_1by8 "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"
-specialize vp9_convolve8_1by8
-
-prototype void vp9_convolve8_qtr "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"
-specialize vp9_convolve8_qtr
-
-prototype void vp9_convolve8_3by8 "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"
-specialize vp9_convolve8_3by8
-
-prototype void vp9_convolve8_5by8 "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"
-specialize vp9_convolve8_5by8
-
-prototype void vp9_convolve8_3qtr "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"
-specialize vp9_convolve8_3qtr
-
-prototype void vp9_convolve8_7by8 "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"
-specialize vp9_convolve8_7by8
-
-prototype void vp9_convolve8_1by8_horiz "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"
-specialize vp9_convolve8_1by8_horiz
-
-prototype void vp9_convolve8_qtr_horiz "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"
-specialize vp9_convolve8_qtr_horiz
-
-prototype void vp9_convolve8_3by8_horiz "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"
-specialize vp9_convolve8_3by8_horiz
-
-prototype void vp9_convolve8_5by8_horiz "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"
-specialize vp9_convolve8_5by8_horiz
-
-prototype void vp9_convolve8_3qtr_horiz "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"
-specialize vp9_convolve8_3qtr_horiz
-
-prototype void vp9_convolve8_7by8_horiz "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"
-specialize vp9_convolve8_7by8_horiz
-
-prototype void vp9_convolve8_1by8_vert "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"
-specialize vp9_convolve8_1by8_vert
-
-prototype void vp9_convolve8_qtr_vert "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"
-specialize vp9_convolve8_qtr_vert
-
-prototype void vp9_convolve8_3by8_vert "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"
-specialize vp9_convolve8_3by8_vert
-
-prototype void vp9_convolve8_5by8_vert "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"
-specialize vp9_convolve8_5by8_vert
-
-prototype void vp9_convolve8_3qtr_vert "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"
-specialize vp9_convolve8_3qtr_vert
-
-prototype void vp9_convolve8_7by8_vert "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"
-specialize vp9_convolve8_7by8_vert
-#endif
-
#
# dct
#
diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c
index 0df2e079f..f1d0e7a79 100644
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -98,7 +98,7 @@ static void set_segment_id(VP9_COMMON *cm, MB_MODE_INFO *mbmi,
int mb_row, int mb_col, int segment_id) {
const int mb_index = mb_row * cm->mb_cols + mb_col;
const BLOCK_SIZE_TYPE sb_type = mbmi->sb_type;
- if (sb_type) {
+ if (sb_type > BLOCK_SIZE_MB16X16) {
const int bw = 1 << mb_width_log2(sb_type);
const int bh = 1 << mb_height_log2(sb_type);
const int ymbs = MIN(cm->mb_rows - mb_row, bh);
@@ -116,6 +116,17 @@ static void set_segment_id(VP9_COMMON *cm, MB_MODE_INFO *mbmi,
}
}
+static TX_SIZE select_txfm_size(VP9_COMMON *cm, vp9_reader *r,
+ int allow_16x16, int allow_32x32) {
+ TX_SIZE txfm_size = vp9_read(r, cm->prob_tx[0]); // TX_4X4 or >TX_4X4
+ if (txfm_size != TX_4X4 && allow_16x16) {
+ txfm_size += vp9_read(r, cm->prob_tx[1]); // TX_8X8 or >TX_8X8
+ if (txfm_size != TX_8X8 && allow_32x32)
+ txfm_size += vp9_read(r, cm->prob_tx[2]); // TX_16X16 or >TX_16X16
+ }
+ return txfm_size;
+}
+
extern const int vp9_i8x8_block[4];
static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m,
int mb_row, int mb_col,
@@ -138,7 +149,7 @@ static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m,
m->mbmi.mb_skip_coeff = vp9_read(r, vp9_get_pred_prob(cm, xd, PRED_MBSKIP));
// luma mode
- m->mbmi.mode = m->mbmi.sb_type ?
+ m->mbmi.mode = m->mbmi.sb_type > BLOCK_SIZE_MB16X16 ?
read_kf_sb_ymode(r, cm->sb_kf_ymode_prob[cm->kf_ymode_probs_index]):
read_kf_mb_ymode(r, cm->kf_ymode_prob[cm->kf_ymode_probs_index]);
@@ -174,15 +185,11 @@ static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m,
}
if (cm->txfm_mode == TX_MODE_SELECT &&
- m->mbmi.mb_skip_coeff == 0 &&
+ !m->mbmi.mb_skip_coeff &&
m->mbmi.mode <= I8X8_PRED) {
- // FIXME(rbultje) code ternary symbol once all experiments are merged
- m->mbmi.txfm_size = vp9_read(r, cm->prob_tx[0]);
- if (m->mbmi.txfm_size != TX_4X4 && m->mbmi.mode != I8X8_PRED) {
- m->mbmi.txfm_size += vp9_read(r, cm->prob_tx[1]);
- if (m->mbmi.txfm_size != TX_8X8 && m->mbmi.sb_type >= BLOCK_SIZE_SB32X32)
- m->mbmi.txfm_size += vp9_read(r, cm->prob_tx[2]);
- }
+ const int allow_16x16 = m->mbmi.mode != I8X8_PRED;
+ const int allow_32x32 = m->mbmi.sb_type >= BLOCK_SIZE_SB32X32;
+ m->mbmi.txfm_size = select_txfm_size(cm, r, allow_16x16, allow_32x32);
} else if (cm->txfm_mode >= ALLOW_32X32 &&
m->mbmi.sb_type >= BLOCK_SIZE_SB32X32) {
m->mbmi.txfm_size = TX_32X32;
@@ -195,6 +202,7 @@ static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m,
}
}
+
static int read_nmv_component(vp9_reader *r,
int rv,
const nmv_component *mvcomp) {
@@ -601,7 +609,8 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
const int use_prev_in_find_mv_refs = cm->width == cm->last_width &&
cm->height == cm->last_height &&
- !cm->error_resilient_mode;
+ !cm->error_resilient_mode &&
+ cm->last_show_frame;
int mb_to_left_edge, mb_to_right_edge, mb_to_top_edge, mb_to_bottom_edge;
@@ -668,7 +677,8 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
if (vp9_segfeature_active(xd, mbmi->segment_id, SEG_LVL_SKIP)) {
mbmi->mode = ZEROMV;
} else {
- mbmi->mode = mbmi->sb_type ? read_sb_mv_ref(r, mv_ref_p)
+ mbmi->mode = mbmi->sb_type > BLOCK_SIZE_MB16X16 ?
+ read_sb_mv_ref(r, mv_ref_p)
: read_mv_ref(r, mv_ref_p);
vp9_accum_mv_refs(cm, mbmi->mode, mbmi->mb_mode_context[ref_frame]);
}
@@ -932,7 +942,7 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
// required for left and above block mv
mv0->as_int = 0;
- if (mbmi->sb_type) {
+ if (mbmi->sb_type > BLOCK_SIZE_MB16X16) {
mbmi->mode = read_sb_ymode(r, cm->fc.sb_ymode_prob);
cm->fc.sb_ymode_counts[mbmi->mode]++;
} else {
@@ -979,14 +989,9 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
((mbmi->ref_frame == INTRA_FRAME && mbmi->mode <= I8X8_PRED) ||
(mbmi->ref_frame != INTRA_FRAME && !(mbmi->mode == SPLITMV &&
mbmi->partitioning == PARTITIONING_4X4)))) {
- // FIXME(rbultje) code ternary symbol once all experiments are merged
- mbmi->txfm_size = vp9_read(r, cm->prob_tx[0]);
- if (mbmi->txfm_size != TX_4X4 && mbmi->mode != I8X8_PRED &&
- mbmi->mode != SPLITMV) {
- mbmi->txfm_size += vp9_read(r, cm->prob_tx[1]);
- if (mbmi->sb_type >= BLOCK_SIZE_SB32X32 && mbmi->txfm_size != TX_8X8)
- mbmi->txfm_size += vp9_read(r, cm->prob_tx[2]);
- }
+ const int allow_16x16 = mbmi->mode != I8X8_PRED && mbmi->mode != SPLITMV;
+ const int allow_32x32 = mbmi->sb_type >= BLOCK_SIZE_SB32X32;
+ mbmi->txfm_size = select_txfm_size(cm, r, allow_16x16, allow_32x32);
} else if (mbmi->sb_type >= BLOCK_SIZE_SB32X32 &&
cm->txfm_mode >= ALLOW_32X32) {
mbmi->txfm_size = TX_32X32;
@@ -1035,7 +1040,7 @@ void vp9_decode_mb_mode_mv(VP9D_COMP* const pbi,
cm->active_ref_scale);
}
- if (mbmi->sb_type) {
+ if (mbmi->sb_type > BLOCK_SIZE_MB16X16) {
const int bw = 1 << mb_width_log2(mbmi->sb_type);
const int bh = 1 << mb_height_log2(mbmi->sb_type);
const int y_mbs = MIN(bh, cm->mb_rows - mb_row);
diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c
index 91aca6f54..c1c0d23ab 100644
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -663,7 +663,7 @@ static void decode_mb(VP9D_COMP *pbi, MACROBLOCKD *xd,
const MB_PREDICTION_MODE mode = xd->mode_info_context->mbmi.mode;
const int tx_size = xd->mode_info_context->mbmi.txfm_size;
- assert(!xd->mode_info_context->mbmi.sb_type);
+ assert(xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_MB16X16);
//mode = xd->mode_info_context->mbmi.mode;
if (pbi->common.frame_type != KEY_FRAME)
@@ -771,11 +771,6 @@ static int get_delta_q(vp9_reader *r, int *dq) {
return old_value != *dq;
}
-#ifdef PACKET_TESTING
-#include <stdio.h>
-FILE *vpxlog = 0;
-#endif
-
static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE_TYPE bsize,
int mb_row, int mb_col) {
const int bh = 1 << mb_height_log2(bsize);
@@ -1001,7 +996,7 @@ static void read_zpc_probs_common(VP9_COMMON *cm,
static void read_zpc_probs(VP9_COMMON *cm,
vp9_reader* bc) {
read_zpc_probs_common(cm, bc, TX_4X4);
- if (cm->txfm_mode != ONLY_4X4)
+ if (cm->txfm_mode > ONLY_4X4)
read_zpc_probs_common(cm, bc, TX_8X8);
if (cm->txfm_mode > ALLOW_8X8)
read_zpc_probs_common(cm, bc, TX_16X16);
@@ -1055,7 +1050,7 @@ static void read_coef_probs(VP9D_COMP *pbi, vp9_reader *r) {
read_coef_probs_common(pbi, r, fc->coef_probs_4x4, TX_4X4);
- if (mode != ONLY_4X4)
+ if (mode > ONLY_4X4)
read_coef_probs_common(pbi, r, fc->coef_probs_8x8, TX_8X8);
if (mode > ALLOW_8X8)
@@ -1078,10 +1073,12 @@ static void update_frame_size(VP9D_COMP *pbi) {
memset(cm->mip, 0,
(cm->mb_cols + 1) * (cm->mb_rows + 1) * sizeof(MODE_INFO));
vp9_update_mode_info_border(cm, cm->mip);
+ vp9_update_mode_info_border(cm, cm->prev_mip);
cm->mi = cm->mip + cm->mode_info_stride + 1;
cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1;
vp9_update_mode_info_in_image(cm, cm->mi);
+ vp9_update_mode_info_in_image(cm, cm->prev_mi);
}
static void setup_segmentation(VP9_COMMON *pc, MACROBLOCKD *xd, vp9_reader *r) {
@@ -1421,7 +1418,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
const uint8_t *data = pbi->source;
const uint8_t *data_end = data + pbi->source_sz;
size_t first_partition_size = 0;
- int i, corrupt_tokens = 0;
+ int i;
// printf("Decoding frame %d\n", pc->current_video_frame);
@@ -1481,6 +1478,8 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
pc->clamp_type = (CLAMP_TYPE)vp9_read_bit(&header_bc);
pc->error_resilient_mode = vp9_read_bit(&header_bc);
+ xd->lossless = vp9_read_bit(&header_bc);
+
setup_loopfilter(pc, xd, &header_bc);
// Dummy read for now
@@ -1549,7 +1548,6 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
setup_pred_probs(pc, &header_bc);
- xd->lossless = vp9_read_bit(&header_bc);
pc->txfm_mode = xd->lossless ? ONLY_4X4 : read_txfm_mode(&header_bc);
if (pc->txfm_mode == TX_MODE_SELECT) {
pc->prob_tx[0] = vp9_read_prob(&header_bc);
@@ -1571,16 +1569,6 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
}
#endif
- if (0) {
- FILE *z = fopen("decodestats.stt", "a");
- fprintf(z, "%6d F:%d,R:%d,Q:%d\n",
- pc->current_video_frame,
- pc->frame_type,
- pbi->refresh_frame_flags,
- pc->base_qindex);
- fclose(z);
- }
-
update_frame_context(pbi);
read_coef_probs(pbi, &header_bc);
@@ -1614,7 +1602,6 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
vp9_decode_mode_mvs_init(pbi, &header_bc);
decode_tiles(pbi, data, first_partition_size, &header_bc, &residual_bc);
- corrupt_tokens |= xd->corrupted;
// keep track of the last coded dimensions
pc->last_width = pc->width;
@@ -1624,7 +1611,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
// 1. Check first boolean decoder for errors.
// 2. Check the macroblock information
pc->yv12_fb[pc->new_fb_idx].corrupted = vp9_reader_has_error(&header_bc) |
- corrupt_tokens;
+ xd->corrupted;
if (!pbi->decoded_key_frame) {
if (pc->frame_type == KEY_FRAME && !pc->yv12_fb[pc->new_fb_idx].corrupted)
@@ -1634,15 +1621,13 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
"A stream must start with a complete key frame");
}
+ // Adaptation
if (!pc->error_resilient_mode && !pc->frame_parallel_decoding_mode) {
vp9_adapt_coef_probs(pc);
#if CONFIG_CODE_ZEROGROUP
vp9_adapt_zpc_probs(pc);
#endif
- }
-
- if (pc->frame_type != KEY_FRAME) {
- if (!pc->error_resilient_mode && !pc->frame_parallel_decoding_mode) {
+ if (pc->frame_type != KEY_FRAME) {
vp9_adapt_mode_probs(pc);
vp9_adapt_nmv_probs(pc, xd->allow_high_precision_mv);
vp9_adapt_mode_context(&pbi->common);
@@ -1654,16 +1639,6 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
sizeof(pc->fc));
}
-#ifdef PACKET_TESTING
- {
- FILE *f = fopen("decompressor.VP8", "ab");
- unsigned int size = residual_bc.pos + header_bc.pos + 8;
- fwrite((void *) &size, 4, 1, f);
- fwrite((void *) pbi->Source, size, 1, f);
- fclose(f);
- }
-#endif
-
*p_data_end = vp9_reader_find_end(&residual_bc);
return 0;
}
diff --git a/vp9/decoder/vp9_detokenize.c b/vp9/decoder/vp9_detokenize.c
index 18ef51ace..02ee7c3d6 100644
--- a/vp9/decoder/vp9_detokenize.c
+++ b/vp9/decoder/vp9_detokenize.c
@@ -165,17 +165,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
case TX_4X4: {
tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type_4x4(xd, block_idx) : DCT_DCT;
- switch (tx_type) {
- default:
- scan = vp9_default_zig_zag1d_4x4;
- break;
- case ADST_DCT:
- scan = vp9_row_scan_4x4;
- break;
- case DCT_ADST:
- scan = vp9_col_scan_4x4;
- break;
- }
+ scan = get_scan_4x4(tx_type);
above_ec = A0[aidx] != 0;
left_ec = L0[lidx] != 0;
coef_probs = fc->coef_probs_4x4;
@@ -194,17 +184,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
const int y = block_idx - x;
tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type_8x8(xd, y + (x >> 1)) : DCT_DCT;
- switch (tx_type) {
- default:
- scan = vp9_default_zig_zag1d_8x8;
- break;
- case ADST_DCT:
- scan = vp9_row_scan_8x8;
- break;
- case DCT_ADST:
- scan = vp9_col_scan_8x8;
- break;
- }
+ scan = get_scan_8x8(tx_type);
coef_probs = fc->coef_probs_8x8;
coef_counts = fc->coef_counts_8x8;
above_ec = (A0[aidx] + A0[aidx + 1]) != 0;
@@ -223,17 +203,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
const int y = block_idx - x;
tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type_16x16(xd, y + (x >> 2)) : DCT_DCT;
- switch (tx_type) {
- default:
- scan = vp9_default_zig_zag1d_16x16;
- break;
- case ADST_DCT:
- scan = vp9_row_scan_16x16;
- break;
- case DCT_ADST:
- scan = vp9_col_scan_16x16;
- break;
- }
+ scan = get_scan_16x16(tx_type);
coef_probs = fc->coef_probs_16x16;
coef_counts = fc->coef_counts_16x16;
if (type == PLANE_TYPE_UV) {
diff --git a/vp9/decoder/vp9_onyxd_if.c b/vp9/decoder/vp9_onyxd_if.c
index b64b7e4dc..a07a8fd45 100644
--- a/vp9/decoder/vp9_onyxd_if.c
+++ b/vp9/decoder/vp9_onyxd_if.c
@@ -365,20 +365,23 @@ int vp9_receive_compressed_data(VP9D_PTR ptr,
vp9_clear_system_state();
+ cm->last_show_frame = cm->show_frame;
if (cm->show_frame) {
- vpx_memcpy(cm->prev_mip, cm->mip,
- (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO));
- } else {
- vpx_memset(cm->prev_mip, 0,
- (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO));
+ // current mip will be the prev_mip for the next frame
+ MODE_INFO *temp = cm->prev_mip;
+ cm->prev_mip = cm->mip;
+ cm->mip = temp;
+
+ // update the upper left visible macroblock ptrs
+ cm->mi = cm->mip + cm->mode_info_stride + 1;
+ cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1;
+
+ cm->current_video_frame++;
}
/*vp9_print_modes_and_motion_vectors(cm->mi, cm->mb_rows,cm->mb_cols,
cm->current_video_frame);*/
- if (cm->show_frame)
- cm->current_video_frame++;
-
pbi->ready_for_new_data = 0;
pbi->last_time_stamp = time_stamp;
pbi->source_sz = 0;
diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c
index 952a99f64..22316217c 100644
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -748,7 +748,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
active_section = 6;
#endif
- if (m->mbmi.sb_type)
+ if (m->mbmi.sb_type > BLOCK_SIZE_MB16X16)
write_sb_ymode(bc, mode, pc->fc.sb_ymode_prob);
else
write_ymode(bc, mode, pc->fc.ymode_prob);
@@ -784,7 +784,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
// If segment skip is not enabled code the mode.
if (!vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP)) {
- if (mi->sb_type) {
+ if (mi->sb_type > BLOCK_SIZE_MB16X16) {
write_sb_mv_ref(bc, mode, mv_ref_p);
} else {
write_mv_ref(bc, mode, mv_ref_p);
@@ -945,7 +945,7 @@ static void write_mb_modes_kf(const VP9_COMP *cpi,
vp9_get_pred_prob(c, xd, PRED_MBSKIP));
}
- if (m->mbmi.sb_type) {
+ if (m->mbmi.sb_type > BLOCK_SIZE_MB16X16) {
sb_kfwrite_ymode(bc, ym,
c->sb_kf_ymode_prob[c->kf_ymode_probs_index]);
} else {
@@ -1803,6 +1803,9 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
// error resilient mode
vp9_write_bit(&header_bc, pc->error_resilient_mode);
+ // lossless mode: note this needs to be before loopfilter
+ vp9_write_bit(&header_bc, cpi->mb.e_mbd.lossless);
+
// Encode the loop filter level and type
vp9_write_bit(&header_bc, pc->filter_type);
vp9_write_literal(&header_bc, pc->filter_level, 6);
@@ -2072,7 +2075,6 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
}
}
- vp9_write_bit(&header_bc, cpi->mb.e_mbd.lossless);
if (cpi->mb.e_mbd.lossless) {
pc->txfm_mode = ONLY_4X4;
} else {
diff --git a/vp9/encoder/vp9_block.h b/vp9/encoder/vp9_block.h
index 206ddff1a..c32b18530 100644
--- a/vp9/encoder/vp9_block.h
+++ b/vp9/encoder/vp9_block.h
@@ -77,6 +77,12 @@ typedef struct {
int comp_pred_diff;
int single_pred_diff;
int64_t txfm_rd_diff[NB_TXFM_MODES];
+
+ // Bit flag for each mode whether it has high error in comparison to others.
+ unsigned int modes_with_high_error;
+
+ // Bit flag for each ref frame whether it has high error compared to others.
+ unsigned int frames_with_high_error;
} PICK_MODE_CONTEXT;
struct macroblock_plane {
@@ -145,9 +151,6 @@ struct macroblock {
int encode_breakout;
- // char * gf_active_ptr;
- signed char *gf_active_ptr;
-
unsigned char *active_ptr;
vp9_coeff_count token_costs[TX_SIZE_MAX_SB][BLOCK_TYPES];
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index c410d3fd7..0837931e5 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -1802,7 +1802,7 @@ static void sum_intra_stats(VP9_COMP *cpi, MACROBLOCK *x) {
}
#endif
- if (xd->mode_info_context->mbmi.sb_type) {
+ if (xd->mode_info_context->mbmi.sb_type > BLOCK_SIZE_MB16X16) {
++cpi->sb_ymode_count[m];
} else {
++cpi->ymode_count[m];
@@ -1858,7 +1858,7 @@ static void encode_macroblock(VP9_COMP *cpi, TOKENEXTRA **t,
MB_MODE_INFO *const mbmi = &mi->mbmi;
const int mis = cm->mode_info_stride;
- assert(!xd->mode_info_context->mbmi.sb_type);
+ assert(xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_MB16X16);
#ifdef ENC_DEBUG
enc_debug = (cpi->common.current_video_frame == 11 && cm->show_frame &&
@@ -1963,12 +1963,13 @@ static void encode_macroblock(VP9_COMP *cpi, TOKENEXTRA **t,
vp9_build_inter_predictors_sb(xd, mb_row, mb_col, BLOCK_SIZE_MB16X16);
#if CONFIG_COMP_INTERINTRA_PRED
if (xd->mode_info_context->mbmi.second_ref_frame == INTRA_FRAME) {
- vp9_build_interintra_16x16_predictors_mb(xd,
- xd->plane[0].dst.buf,
- xd->plane[1].dst.buf,
- xd->plane[2].dst.buf,
- xd->plane[0].dst.stride,
- xd->plane[1].dst.stride);
+ vp9_build_interintra_predictors(xd,
+ xd->plane[0].dst.buf,
+ xd->plane[1].dst.buf,
+ xd->plane[2].dst.buf,
+ xd->plane[0].dst.stride,
+ xd->plane[1].dst.stride,
+ BLOCK_SIZE_MB16X16);
}
#endif
}
diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c
index 1994bb2ec..d8893b6e5 100644
--- a/vp9/encoder/vp9_encodemb.c
+++ b/vp9/encoder/vp9_encodemb.c
@@ -284,13 +284,7 @@ static void optimize_b(VP9_COMMON *const cm,
case TX_4X4: {
const TX_TYPE tx_type = get_tx_type_4x4(xd, ib);
default_eob = 16;
- if (tx_type == DCT_ADST) {
- scan = vp9_col_scan_4x4;
- } else if (tx_type == ADST_DCT) {
- scan = vp9_row_scan_4x4;
- } else {
- scan = vp9_default_zig_zag1d_4x4;
- }
+ scan = get_scan_4x4(tx_type);
break;
}
case TX_8X8: {
@@ -298,13 +292,7 @@ static void optimize_b(VP9_COMMON *const cm,
const int sz = 3 + mb_width_log2(sb_type);
const int x = ib & ((1 << sz) - 1), y = ib - x;
const TX_TYPE tx_type = get_tx_type_8x8(xd, y + (x >> 1));
- if (tx_type == DCT_ADST) {
- scan = vp9_col_scan_8x8;
- } else if (tx_type == ADST_DCT) {
- scan = vp9_row_scan_8x8;
- } else {
- scan = vp9_default_zig_zag1d_8x8;
- }
+ scan = get_scan_8x8(tx_type);
default_eob = 64;
break;
}
@@ -313,13 +301,7 @@ static void optimize_b(VP9_COMMON *const cm,
const int sz = 4 + mb_width_log2(sb_type);
const int x = ib & ((1 << sz) - 1), y = ib - x;
const TX_TYPE tx_type = get_tx_type_16x16(xd, y + (x >> 2));
- if (tx_type == DCT_ADST) {
- scan = vp9_col_scan_16x16;
- } else if (tx_type == ADST_DCT) {
- scan = vp9_row_scan_16x16;
- } else {
- scan = vp9_default_zig_zag1d_16x16;
- }
+ scan = get_scan_16x16(tx_type);
default_eob = 256;
break;
}
diff --git a/vp9/encoder/vp9_quantize.c b/vp9/encoder/vp9_quantize.c
index 2ae74543e..a96525a43 100644
--- a/vp9/encoder/vp9_quantize.c
+++ b/vp9/encoder/vp9_quantize.c
@@ -44,19 +44,7 @@ void vp9_ht_quantize_b_4x4(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type) {
uint8_t *quant_shift_ptr = b->quant_shift;
int16_t *dequant_ptr = d->dequant;
int zbin_oq_value = b->zbin_extra;
- const int *pt_scan;
-
- switch (tx_type) {
- case ADST_DCT:
- pt_scan = vp9_row_scan_4x4;
- break;
- case DCT_ADST:
- pt_scan = vp9_col_scan_4x4;
- break;
- default:
- pt_scan = vp9_default_zig_zag1d_4x4;
- break;
- }
+ const int *pt_scan = get_scan_4x4(tx_type);
vpx_memset(qcoeff_ptr, 0, 32);
vpx_memset(dqcoeff_ptr, 0, 32);
@@ -168,19 +156,7 @@ void vp9_regular_quantize_b_8x8(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type,
pb_idx.block, 16);
BLOCK *const b = &mb->block[c_idx];
BLOCKD *const d = &xd->block[c_idx];
- const int *pt_scan;
-
- switch (tx_type) {
- case ADST_DCT:
- pt_scan = vp9_row_scan_8x8;
- break;
- case DCT_ADST:
- pt_scan = vp9_col_scan_8x8;
- break;
- default:
- pt_scan = vp9_default_zig_zag1d_8x8;
- break;
- }
+ const int *pt_scan = get_scan_8x8(tx_type);
if (c_idx == 0) assert(pb_idx.plane == 0);
if (c_idx == 16) assert(pb_idx.plane == 1);
@@ -315,19 +291,7 @@ void vp9_regular_quantize_b_16x16(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type,
const int c_idx = plane_idx(pb_idx.plane);
BLOCK *const b = &mb->block[c_idx];
BLOCKD *const d = &xd->block[c_idx];
- const int *pt_scan;
-
- switch (tx_type) {
- case ADST_DCT:
- pt_scan = vp9_row_scan_16x16;
- break;
- case DCT_ADST:
- pt_scan = vp9_col_scan_16x16;
- break;
- default:
- pt_scan = vp9_default_zig_zag1d_16x16;
- break;
- }
+ const int *pt_scan = get_scan_16x16(tx_type);
if (c_idx == 0) assert(pb_idx.plane == 0);
if (c_idx == 16) assert(pb_idx.plane == 1);
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index 1ecae0b5e..626769718 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -352,13 +352,7 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
l_ec = *l;
coef_probs = cm->fc.coef_probs_4x4;
seg_eob = 16;
- if (tx_type == ADST_DCT) {
- scan = vp9_row_scan_4x4;
- } else if (tx_type == DCT_ADST) {
- scan = vp9_col_scan_4x4;
- } else {
- scan = vp9_default_zig_zag1d_4x4;
- }
+ scan = get_scan_4x4(tx_type);
#if CONFIG_CODE_ZEROGROUP
zpc_probs = &cm->fc.zpc_probs_4x4;
#endif
@@ -372,13 +366,7 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
get_tx_type_8x8(xd, y + (x >> 1)) : DCT_DCT;
a_ec = (a[0] + a[1]) != 0;
l_ec = (l[0] + l[1]) != 0;
- if (tx_type == ADST_DCT) {
- scan = vp9_row_scan_8x8;
- } else if (tx_type == DCT_ADST) {
- scan = vp9_col_scan_8x8;
- } else {
- scan = vp9_default_zig_zag1d_8x8;
- }
+ scan = get_scan_8x8(tx_type);
coef_probs = cm->fc.coef_probs_8x8;
seg_eob = 64;
#if CONFIG_CODE_ZEROGROUP
@@ -392,13 +380,7 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
const int x = ib & ((1 << sz) - 1), y = ib - x;
TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type_16x16(xd, y + (x >> 2)) : DCT_DCT;
- if (tx_type == ADST_DCT) {
- scan = vp9_row_scan_16x16;
- } else if (tx_type == DCT_ADST) {
- scan = vp9_col_scan_16x16;
- } else {
- scan = vp9_default_zig_zag1d_16x16;
- }
+ scan = get_scan_16x16(tx_type);
coef_probs = cm->fc.coef_probs_16x16;
seg_eob = 256;
if (type == PLANE_TYPE_UV) {
@@ -1748,8 +1730,7 @@ static int64_t encode_inter_mb_segment(VP9_COMMON *const cm,
vp9_build_inter_predictor(
*(bd->base_second_pre) + bd->pre, bd->pre_stride,
*(bd->base_dst) + bd->dst, bd->dst_stride,
- &bd->bmi.as_mv[1], &xd->scale_factor[1], 4, 4,
- 1 << (2 * CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT) /* avg */,
+ &bd->bmi.as_mv[1], &xd->scale_factor[1], 4, 4, 1,
&xd->subpix);
}
@@ -1821,8 +1802,7 @@ static int64_t encode_inter_mb_segment_8x8(VP9_COMMON *const cm,
*base_pre + bd->pre, bd->pre_stride,
*(bd->base_dst) + bd->dst, bd->dst_stride,
&bd->bmi.as_mv[which_mv], &xd->scale_factor[which_mv], 8, 8,
- which_mv << (2 * CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT),
- &xd->subpix);
+ which_mv, &xd->subpix);
}
vp9_subtract_block(8, 8, src_diff, 16,
@@ -3385,6 +3365,9 @@ static void rd_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
int intra_cost_penalty = 20 * vp9_dc_quant(cpi->common.base_qindex,
cpi->common.y_dc_delta_q);
+ int64_t mode_distortions[MB_MODE_COUNT] = {-1};
+ int64_t frame_distortions[MAX_REF_FRAMES] = {-1};
+ int ref_frame;
struct scale_factors scale_factor[4];
@@ -3395,6 +3378,9 @@ static void rd_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
vpx_memset(&x->mb_context[xd->sb_index][xd->mb_index], 0,
sizeof(PICK_MODE_CONTEXT));
+ x->mb_context[xd->sb_index][xd->mb_index].frames_with_high_error = 0;
+ x->mb_context[xd->sb_index][xd->mb_index].modes_with_high_error = 0;
+
for (i = 0; i < MAX_REF_FRAMES; i++)
frame_mv[NEWMV][i].as_int = INVALID_MV;
for (i = 0; i < NB_PREDICTION_TYPES; ++i)
@@ -3934,6 +3920,17 @@ static void rd_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
#endif
}
+ // Store the respective mode distortions for later use.
+ // Store the respective mode distortions for later use.
+ if (mode_distortions[this_mode] == -1
+ || distortion2 < mode_distortions[this_mode]) {
+ mode_distortions[this_mode] = distortion2;
+ }
+ if (frame_distortions[mbmi->ref_frame] == -1 ||
+ distortion2 < frame_distortions[mbmi->ref_frame]) {
+ frame_distortions[mbmi->ref_frame] = distortion2;
+ }
+
// Did this mode help.. i.e. is it the new best mode
if (this_rd < best_rd || x->skip) {
if (!mode_excluded) {
@@ -4142,6 +4139,29 @@ static void rd_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
}
end:
+
+ // Flag all modes that have a distortion thats > 2x the best we found at
+ // this level.
+ for (mode_index = 0; mode_index < MB_MODE_COUNT; ++mode_index) {
+ if (mode_index == NEARESTMV || mode_index == NEARMV || mode_index == NEWMV
+ || mode_index == SPLITMV)
+ continue;
+
+ if (mode_distortions[mode_index] > 2 * *returndistortion) {
+ x->mb_context[xd->sb_index][xd->mb_index].modes_with_high_error |= (1
+ << mode_index);
+ }
+ }
+
+ // Flag all ref frames that have a distortion thats > 2x the best we found at
+ // this level.
+ for (ref_frame = INTRA_FRAME; ref_frame <= ALTREF_FRAME; ref_frame++) {
+ if (frame_distortions[ref_frame] > 2 * *returndistortion) {
+ x->mb_context[xd->sb_index][xd->mb_index].frames_with_high_error |= (1
+ << ref_frame);
+ }
+ }
+
set_scale_factors(xd, mbmi->ref_frame, mbmi->second_ref_frame,
scale_factor);
store_coding_context(x, &x->mb_context[xd->sb_index][xd->mb_index],
@@ -4368,6 +4388,12 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
struct scale_factors scale_factor[4];
unsigned int ref_frame_mask = 0;
unsigned int mode_mask = 0;
+ int64_t mode_distortions[MB_MODE_COUNT] = {-1};
+ int64_t frame_distortions[MAX_REF_FRAMES] = {-1};
+
+ // Everywhere the flag is set the error is much higher than its neighbors.
+ ctx->frames_with_high_error = 0;
+ ctx->modes_with_high_error = 0;
xd->mode_info_context->mbmi.segment_id = segment_id;
estimate_ref_frame_costs(cpi, segment_id, ref_costs);
@@ -4378,34 +4404,36 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
for (i = 0; i < NB_TXFM_MODES; i++)
best_txfm_rd[i] = INT64_MAX;
- // Create a mask set to 1 for each frame used by a smaller resolution.p
+ // Create a mask set to 1 for each frame used by a smaller resolution.
if (cpi->Speed > 0) {
switch (block_size) {
case BLOCK_64X64:
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
- ref_frame_mask |= (1 << x->mb_context[i][j].mic.mbmi.ref_frame);
- mode_mask |= (1 << x->mb_context[i][j].mic.mbmi.mode);
+ ref_frame_mask |= x->mb_context[i][j].frames_with_high_error;
+ mode_mask |= x->mb_context[i][j].modes_with_high_error;
}
}
for (i = 0; i < 4; i++) {
- ref_frame_mask |= (1 << x->sb32_context[i].mic.mbmi.ref_frame);
- mode_mask |= (1 << x->sb32_context[i].mic.mbmi.mode);
+ ref_frame_mask |= x->sb32_context[i].frames_with_high_error;
+ mode_mask |= x->sb32_context[i].modes_with_high_error;
}
break;
case BLOCK_32X32:
for (i = 0; i < 4; i++) {
- ref_frame_mask |= (1
- << x->mb_context[xd->sb_index][i].mic.mbmi.ref_frame);
- mode_mask |= (1 << x->mb_context[xd->sb_index][i].mic.mbmi.mode);
+ ref_frame_mask |=
+ x->mb_context[xd->sb_index][i].frames_with_high_error;
+ mode_mask |= x->mb_context[xd->sb_index][i].modes_with_high_error;
}
break;
default:
// Until we handle all block sizes set it to present;
- ref_frame_mask = 0xff;
- mode_mask = 0xff;
+ ref_frame_mask = 0;
+ mode_mask = 0;
break;
}
+ ref_frame_mask = ~ref_frame_mask;
+ mode_mask = ~mode_mask;
}
for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ref_frame++) {
@@ -4460,6 +4488,9 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
if (!(ref_frame_mask & (1 << ref_frame))) {
continue;
}
+ if (!(mode_mask & (1 << this_mode))) {
+ continue;
+ }
if (vp9_mode_order[mode_index].second_ref_frame != NONE
&& !(ref_frame_mask
& (1 << vp9_mode_order[mode_index].second_ref_frame))) {
@@ -4701,6 +4732,16 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
#endif
}
+ // Store the respective mode distortions for later use.
+ if (mode_distortions[this_mode] == -1
+ || distortion2 < mode_distortions[this_mode]) {
+ mode_distortions[this_mode] = distortion2;
+ }
+ if (frame_distortions[mbmi->ref_frame] == -1
+ || distortion2 < frame_distortions[mbmi->ref_frame]) {
+ frame_distortions[mbmi->ref_frame] = distortion2;
+ }
+
// Did this mode help.. i.e. is it the new best mode
if (this_rd < best_rd || x->skip) {
if (!mode_excluded) {
@@ -4786,6 +4827,27 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
if (x->skip && !mode_excluded)
break;
}
+ // Flag all modes that have a distortion thats > 2x the best we found at
+ // this level.
+ for (mode_index = 0; mode_index < MB_MODE_COUNT; ++mode_index) {
+ if (mode_index == NEARESTMV || mode_index == NEARMV || mode_index == NEWMV
+ || mode_index == SPLITMV)
+ continue;
+
+ if (mode_distortions[mode_index] > 2 * *returndistortion) {
+ ctx->modes_with_high_error |= (1 << mode_index);
+ }
+ }
+
+ // Flag all ref frames that have a distortion thats > 2x the best we found at
+ // this level.
+ for (ref_frame = INTRA_FRAME; ref_frame <= ALTREF_FRAME; ref_frame++) {
+ if (frame_distortions[ref_frame] > 2 * *returndistortion) {
+ ctx->frames_with_high_error |= (1 << ref_frame);
+ }
+ }
+
+
assert((cm->mcomp_filter_type == SWITCHABLE) ||
(cm->mcomp_filter_type == best_mbmode.interp_filter) ||
diff --git a/vp9/encoder/vp9_temporal_filter.c b/vp9/encoder/vp9_temporal_filter.c
index be3875ad6..a6c5f7179 100644
--- a/vp9/encoder/vp9_temporal_filter.c
+++ b/vp9/encoder/vp9_temporal_filter.c
@@ -51,8 +51,7 @@ static void temporal_filter_predictors_mb_c(MACROBLOCKD *xd,
&mv,
&xd->scale_factor[which_mv],
16, 16,
- which_mv <<
- (2 * CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT),
+ which_mv,
&xd->subpix);
stride = (stride + 1) >> 1;
@@ -62,8 +61,7 @@ static void temporal_filter_predictors_mb_c(MACROBLOCKD *xd,
&mv,
&xd->scale_factor_uv[which_mv],
8, 8,
- which_mv <<
- (2 * CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT),
+ which_mv,
&xd->subpix);
vp9_build_inter_predictor_q4(v_mb_ptr, stride,
@@ -71,8 +69,7 @@ static void temporal_filter_predictors_mb_c(MACROBLOCKD *xd,
&mv,
&xd->scale_factor_uv[which_mv],
8, 8,
- which_mv <<
- (2 * CONFIG_IMPLICIT_COMPOUNDINTER_WEIGHT),
+ which_mv,
&xd->subpix);
}
diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c
index f6a720651..6f2cbbf24 100644
--- a/vp9/encoder/vp9_tokenize.c
+++ b/vp9/encoder/vp9_tokenize.c
@@ -204,14 +204,7 @@ static void tokenize_b(VP9_COMP *cpi,
a_ec = *a;
l_ec = *l;
seg_eob = 16;
- scan = vp9_default_zig_zag1d_4x4;
- if (tx_type != DCT_DCT) {
- if (tx_type == ADST_DCT) {
- scan = vp9_row_scan_4x4;
- } else if (tx_type == DCT_ADST) {
- scan = vp9_col_scan_4x4;
- }
- }
+ scan = get_scan_4x4(tx_type);
counts = cpi->coef_counts_4x4;
coef_probs = cpi->common.fc.coef_probs_4x4;
#if CONFIG_CODE_ZEROGROUP
@@ -228,14 +221,7 @@ static void tokenize_b(VP9_COMP *cpi,
a_ec = (a[0] + a[1]) != 0;
l_ec = (l[0] + l[1]) != 0;
seg_eob = 64;
- scan = vp9_default_zig_zag1d_8x8;
- if (tx_type != DCT_DCT) {
- if (tx_type == ADST_DCT) {
- scan = vp9_row_scan_8x8;
- } else if (tx_type == DCT_ADST) {
- scan = vp9_col_scan_8x8;
- }
- }
+ scan = get_scan_8x8(tx_type);
counts = cpi->coef_counts_8x8;
coef_probs = cpi->common.fc.coef_probs_8x8;
#if CONFIG_CODE_ZEROGROUP
@@ -257,14 +243,7 @@ static void tokenize_b(VP9_COMP *cpi,
l_ec = (l[0] + l[1] + l1[0] + l1[1]) != 0;
}
seg_eob = 256;
- scan = vp9_default_zig_zag1d_16x16;
- if (tx_type != DCT_DCT) {
- if (tx_type == ADST_DCT) {
- scan = vp9_row_scan_16x16;
- } else if (tx_type == DCT_ADST) {
- scan = vp9_col_scan_16x16;
- }
- }
+ scan = get_scan_16x16(tx_type);
counts = cpi->coef_counts_16x16;
coef_probs = cpi->common.fc.coef_probs_16x16;
#if CONFIG_CODE_ZEROGROUP
@@ -802,242 +781,3 @@ void print_context_counters() {
void vp9_tokenize_initialize() {
fill_value_tokens();
}
-
-static void stuff_b(VP9_COMP *cpi,
- MACROBLOCKD *xd,
- const int ib,
- TOKENEXTRA **tp,
- PLANE_TYPE type,
- TX_SIZE tx_size,
- int dry_run) {
- MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi;
- const BLOCK_SIZE_TYPE sb_type = mbmi->sb_type;
- vp9_coeff_count *counts;
- vp9_coeff_probs *probs;
- int pt, band;
- TOKENEXTRA *t = *tp;
- const int ref = mbmi->ref_frame != INTRA_FRAME;
- ENTROPY_CONTEXT *a, *l, *a1, *l1, *a2, *l2, *a3, *l3, a_ec, l_ec;
-
- if (sb_type == BLOCK_SIZE_SB64X64) {
- a = (ENTROPY_CONTEXT *)xd->above_context +
- vp9_block2above_sb64[tx_size][ib];
- l = (ENTROPY_CONTEXT *)xd->left_context + vp9_block2left_sb64[tx_size][ib];
- a1 = a + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT);
- l1 = l + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT);
- a2 = a1 + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT);
- l2 = l1 + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT);
- a3 = a2 + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT);
- l3 = l2 + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT);
- } else if (sb_type == BLOCK_SIZE_SB32X32) {
- a = (ENTROPY_CONTEXT *)xd->above_context + vp9_block2above_sb[tx_size][ib];
- l = (ENTROPY_CONTEXT *)xd->left_context + vp9_block2left_sb[tx_size][ib];
- a1 = a + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT);
- l1 = l + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT);
- a2 = l2 = a3 = l3 = NULL;
- } else {
- a = (ENTROPY_CONTEXT *)xd->above_context + vp9_block2above[tx_size][ib];
- l = (ENTROPY_CONTEXT *)xd->left_context + vp9_block2left[tx_size][ib];
- a1 = l1 = a2 = l2 = a3 = l3 = NULL;
- }
-
- switch (tx_size) {
- default:
- case TX_4X4:
- a_ec = a[0];
- l_ec = l[0];
- counts = cpi->coef_counts_4x4;
- probs = cpi->common.fc.coef_probs_4x4;
- break;
- case TX_8X8:
- a_ec = (a[0] + a[1]) != 0;
- l_ec = (l[0] + l[1]) != 0;
- counts = cpi->coef_counts_8x8;
- probs = cpi->common.fc.coef_probs_8x8;
- break;
- case TX_16X16:
- if (type != PLANE_TYPE_UV) {
- a_ec = (a[0] + a[1] + a[2] + a[3]) != 0;
- l_ec = (l[0] + l[1] + l[2] + l[3]) != 0;
- } else {
- a_ec = (a[0] + a[1] + a1[0] + a1[1]) != 0;
- l_ec = (l[0] + l[1] + l1[0] + l1[1]) != 0;
- }
- counts = cpi->coef_counts_16x16;
- probs = cpi->common.fc.coef_probs_16x16;
- break;
- case TX_32X32:
- if (type != PLANE_TYPE_UV) {
- a_ec = (a[0] + a[1] + a[2] + a[3] +
- a1[0] + a1[1] + a1[2] + a1[3]) != 0;
- l_ec = (l[0] + l[1] + l[2] + l[3] +
- l1[0] + l1[1] + l1[2] + l1[3]) != 0;
- } else {
- a_ec = (a[0] + a[1] + a1[0] + a1[1] +
- a2[0] + a2[1] + a3[0] + a3[1]) != 0;
- l_ec = (l[0] + l[1] + l1[0] + l1[1] +
- l2[0] + l2[1] + l3[0] + l3[1]) != 0;
- }
- counts = cpi->coef_counts_32x32;
- probs = cpi->common.fc.coef_probs_32x32;
- break;
- }
-
- pt = combine_entropy_contexts(a_ec, l_ec);
- band = 0;
- t->token = DCT_EOB_TOKEN;
- t->context_tree = probs[type][ref][band][pt];
- t->skip_eob_node = 0;
-#if CONFIG_CODE_ZEROGROUP
- t->skip_coef_val = 0;
-#endif
- ++t;
- *tp = t;
- if (!dry_run) {
- ++counts[type][ref][band][pt][DCT_EOB_TOKEN];
- }
- *a = *l = 0;
- if (tx_size == TX_8X8) {
- a[1] = 0;
- l[1] = 0;
- } else if (tx_size == TX_16X16) {
- if (type != PLANE_TYPE_UV) {
- a[1] = a[2] = a[3] = 0;
- l[1] = l[2] = l[3] = 0;
- } else {
- a1[0] = a1[1] = a[1] = a_ec;
- l1[0] = l1[1] = l[1] = l_ec;
- }
- } else if (tx_size == TX_32X32) {
- if (type != PLANE_TYPE_Y_WITH_DC) {
- a[1] = a[2] = a[3] = a_ec;
- l[1] = l[2] = l[3] = l_ec;
- a1[0] = a1[1] = a1[2] = a1[3] = a_ec;
- l1[0] = l1[1] = l1[2] = l1[3] = l_ec;
- } else {
- a[1] = a1[0] = a1[1] = a_ec;
- l[1] = l1[0] = l1[1] = l_ec;
- a2[0] = a2[1] = a3[0] = a3[1] = a_ec;
- l2[0] = l2[1] = l3[0] = l3[1] = l_ec;
- }
- }
-}
-
-static void stuff_mb_8x8(VP9_COMP *cpi, MACROBLOCKD *xd,
- TOKENEXTRA **t, int dry_run) {
- int b;
-
- for (b = 0; b < 16; b += 4)
- stuff_b(cpi, xd, b, t, PLANE_TYPE_Y_WITH_DC, TX_8X8, dry_run);
- for (b = 16; b < 24; b += 4)
- stuff_b(cpi, xd, b, t, PLANE_TYPE_UV, TX_8X8, dry_run);
-}
-
-static void stuff_mb_16x16(VP9_COMP *cpi, MACROBLOCKD *xd,
- TOKENEXTRA **t, int dry_run) {
- int b;
- stuff_b(cpi, xd, 0, t, PLANE_TYPE_Y_WITH_DC, TX_16X16, dry_run);
-
- for (b = 16; b < 24; b += 4) {
- stuff_b(cpi, xd, b, t, PLANE_TYPE_UV, TX_8X8, dry_run);
- }
-}
-
-static void stuff_mb_4x4(VP9_COMP *cpi, MACROBLOCKD *xd,
- TOKENEXTRA **t, int dry_run) {
- int b;
-
- for (b = 0; b < 16; b++)
- stuff_b(cpi, xd, b, t, PLANE_TYPE_Y_WITH_DC, TX_4X4, dry_run);
- for (b = 16; b < 24; b++)
- stuff_b(cpi, xd, b, t, PLANE_TYPE_UV, TX_4X4, dry_run);
-}
-
-static void stuff_mb_8x8_4x4uv(VP9_COMP *cpi, MACROBLOCKD *xd,
- TOKENEXTRA **t, int dry_run) {
- int b;
-
- for (b = 0; b < 16; b += 4)
- stuff_b(cpi, xd, b, t, PLANE_TYPE_Y_WITH_DC, TX_8X8, dry_run);
- for (b = 16; b < 24; b++)
- stuff_b(cpi, xd, b, t, PLANE_TYPE_UV, TX_4X4, dry_run);
-}
-
-void vp9_stuff_mb(VP9_COMP *cpi, MACROBLOCKD *xd, TOKENEXTRA **t, int dry_run) {
- TX_SIZE tx_size = xd->mode_info_context->mbmi.txfm_size;
- TOKENEXTRA * const t_backup = *t;
-
- if (tx_size == TX_16X16) {
- stuff_mb_16x16(cpi, xd, t, dry_run);
- } else if (tx_size == TX_8X8) {
- if (xd->mode_info_context->mbmi.mode == I8X8_PRED ||
- xd->mode_info_context->mbmi.mode == SPLITMV) {
- stuff_mb_8x8_4x4uv(cpi, xd, t, dry_run);
- } else {
- stuff_mb_8x8(cpi, xd, t, dry_run);
- }
- } else {
- stuff_mb_4x4(cpi, xd, t, dry_run);
- }
-
- if (dry_run) {
- *t = t_backup;
- }
-}
-
-void vp9_stuff_sb(VP9_COMP *cpi, MACROBLOCKD *xd, TOKENEXTRA **t, int dry_run,
- BLOCK_SIZE_TYPE bsize) {
- MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi;
- const int bwl = mb_width_log2(bsize) + 2, bhl = mb_height_log2(bsize) + 2;
- const TX_SIZE txfm_size = mbmi->txfm_size;
- const TX_SIZE uv_txfm_size = (bsize < BLOCK_SIZE_SB32X32 &&
- txfm_size == TX_16X16) ? TX_8X8 :
- (bsize < BLOCK_SIZE_SB64X64 &&
- txfm_size == TX_32X32) ? TX_16X16 : txfm_size;
- int b;
- const int n_y = (1 << (bwl + bhl)), n_uv = (n_y * 3) >> 1;
- TOKENEXTRA * const t_backup = *t;
-
- switch (txfm_size) {
- case TX_32X32:
- for (b = 0; b < n_y; b += 64)
- stuff_b(cpi, xd, b, t, PLANE_TYPE_Y_WITH_DC, TX_32X32, dry_run);
- if (uv_txfm_size == TX_32X32) {
- assert(bsize == BLOCK_SIZE_SB64X64);
- stuff_b(cpi, xd, 256, t, PLANE_TYPE_UV, TX_32X32, dry_run);
- stuff_b(cpi, xd, 320, t, PLANE_TYPE_UV, TX_32X32, dry_run);
- } else {
- for (; b < n_uv; b += 16)
- stuff_b(cpi, xd, b, t, PLANE_TYPE_UV, TX_16X16, dry_run);
- }
- break;
- case TX_16X16:
- for (b = 0; b < n_y; b += 16)
- stuff_b(cpi, xd, b, t, PLANE_TYPE_Y_WITH_DC, TX_16X16, dry_run);
- if (uv_txfm_size == TX_16X16) {
- for (; b < n_uv; b += 16)
- stuff_b(cpi, xd, b, t, PLANE_TYPE_UV, TX_16X16, dry_run);
- } else {
- for (; b < n_uv; b += 4)
- stuff_b(cpi, xd, b, t, PLANE_TYPE_UV, TX_8X8, dry_run);
- }
- break;
- case TX_8X8:
- for (b = 0; b < n_y; b += 4)
- stuff_b(cpi, xd, b, t, PLANE_TYPE_Y_WITH_DC, TX_8X8, dry_run);
- for (; b < n_uv; b += 4)
- stuff_b(cpi, xd, b, t, PLANE_TYPE_UV, TX_8X8, dry_run);
- break;
- case TX_4X4:
- for (b = 0; b < n_y; b++)
- stuff_b(cpi, xd, b, t, PLANE_TYPE_Y_WITH_DC, TX_4X4, dry_run);
- for (; b < n_uv; b++)
- stuff_b(cpi, xd, b, t, PLANE_TYPE_UV, TX_4X4, dry_run);
- break;
- default: assert(0);
- }
-
- if (dry_run) {
- *t = t_backup;
- }
-}
diff --git a/vp9/encoder/vp9_tokenize.h b/vp9/encoder/vp9_tokenize.h
index da1c817a2..816534830 100644
--- a/vp9/encoder/vp9_tokenize.h
+++ b/vp9/encoder/vp9_tokenize.h
@@ -44,11 +44,6 @@ void vp9_tokenize_mb(struct VP9_COMP *cpi, MACROBLOCKD *xd,
void vp9_tokenize_sb(struct VP9_COMP *cpi, MACROBLOCKD *xd,
TOKENEXTRA **t, int dry_run, BLOCK_SIZE_TYPE bsize);
-void vp9_stuff_mb(struct VP9_COMP *cpi, MACROBLOCKD *xd,
- TOKENEXTRA **t, int dry_run);
-void vp9_stuff_sb(struct VP9_COMP *cpi, MACROBLOCKD *xd,
- TOKENEXTRA **t, int dry_run, BLOCK_SIZE_TYPE bsize);
-
#ifdef ENTROPY_STATS
void init_context_counters();
void print_context_counters();