Commit 1a46b30e authored by Ronald S. Bultje's avatar Ronald S. Bultje

Grow MODE_INFO array to use an 8x8 basis.

Change-Id: I087e08e7909a406b71715b8525c104208daa6889
parent eea1fecd
......@@ -27,7 +27,7 @@ void vp9_update_mode_info_border(VP9_COMMON *cpi, MODE_INFO *mi) {
vpx_memset(mi, 0, sizeof(MODE_INFO) * stride);
// Clear left border column
for (i = 1; i < cpi->mb_rows + 1; i++)
for (i = 1; i < cpi->mi_rows + 1; i++)
vpx_memset(&mi[i * stride], 0, sizeof(MODE_INFO));
}
......@@ -36,9 +36,9 @@ void vp9_update_mode_info_in_image(VP9_COMMON *cpi, MODE_INFO *mi) {
MODE_INFO *ptr;
// For each in image mode_info element set the in image flag to 1
for (i = 0; i < cpi->mb_rows; i++) {
for (i = 0; i < cpi->mi_rows; i++) {
ptr = mi;
for (j = 0; j < cpi->mb_cols; j++) {
for (j = 0; j < cpi->mi_cols; j++) {
ptr->mbmi.mb_in_image = 1;
ptr++; // Next element in the row
}
......@@ -110,10 +110,13 @@ int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) {
}
oci->mb_rows = aligned_height >> 4;
oci->mi_rows = aligned_height >> LOG2_MI_SIZE;
oci->mb_cols = aligned_width >> 4;
oci->mi_cols = aligned_width >> LOG2_MI_SIZE;
oci->MBs = oci->mb_rows * oci->mb_cols;
oci->mode_info_stride = oci->mb_cols + 1;
oci->mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_INFO));
oci->mode_info_stride = oci->mi_cols + 1;
oci->mip = vpx_calloc(oci->mode_info_stride * (oci->mi_rows + 1),
sizeof(MODE_INFO));
if (!oci->mip) {
vp9_free_frame_buffers(oci);
......@@ -124,7 +127,8 @@ int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) {
/* allocate memory for last frame MODE_INFO array */
oci->prev_mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_INFO));
oci->prev_mip = vpx_calloc(oci->mode_info_stride * (oci->mi_rows + 1),
sizeof(MODE_INFO));
if (!oci->prev_mip) {
vp9_free_frame_buffers(oci);
......
......@@ -205,39 +205,49 @@ typedef enum {
MAX_REF_FRAMES = 4
} MV_REFERENCE_FRAME;
static INLINE int mb_width_log2(BLOCK_SIZE_TYPE sb_type) {
static INLINE int mi_width_log2(BLOCK_SIZE_TYPE sb_type) {
switch (sb_type) {
#if CONFIG_SB8X8
case BLOCK_SIZE_SB8X16:
case BLOCK_SIZE_SB8X8: return 0;
case BLOCK_SIZE_SB16X8:
#endif
case BLOCK_SIZE_MB16X16:
case BLOCK_SIZE_SB16X32: return 0;
case BLOCK_SIZE_SB16X32: return 0 + CONFIG_SB8X8;
case BLOCK_SIZE_SB32X16:
case BLOCK_SIZE_SB32X64:
case BLOCK_SIZE_SB32X32: return 1;
case BLOCK_SIZE_SB32X32: return 1 + CONFIG_SB8X8;
case BLOCK_SIZE_SB64X32:
case BLOCK_SIZE_SB64X64: return 2;
case BLOCK_SIZE_SB64X64: return 2 + CONFIG_SB8X8;
default: assert(0);
}
}
static INLINE int mb_height_log2(BLOCK_SIZE_TYPE sb_type) {
static INLINE int mi_height_log2(BLOCK_SIZE_TYPE sb_type) {
switch (sb_type) {
#if CONFIG_SB8X8
case BLOCK_SIZE_SB16X8:
case BLOCK_SIZE_SB8X8: return 0;
case BLOCK_SIZE_SB8X16:
#endif
case BLOCK_SIZE_MB16X16:
case BLOCK_SIZE_SB32X16: return 0;
case BLOCK_SIZE_SB32X16: return 0 + CONFIG_SB8X8;
case BLOCK_SIZE_SB16X32:
case BLOCK_SIZE_SB64X32:
case BLOCK_SIZE_SB32X32: return 1;
case BLOCK_SIZE_SB32X32: return 1 + CONFIG_SB8X8;
case BLOCK_SIZE_SB32X64:
case BLOCK_SIZE_SB64X64: return 2;
case BLOCK_SIZE_SB64X64: return 2 + CONFIG_SB8X8;
default: assert(0);
}
}
// parse block dimension in the unit of 4x4 blocks
static INLINE int b_width_log2(BLOCK_SIZE_TYPE sb_type) {
return mb_width_log2(sb_type) + 2;
return mi_width_log2(sb_type) + 2 - CONFIG_SB8X8;
}
static INLINE int b_height_log2(BLOCK_SIZE_TYPE sb_type) {
return mb_height_log2(sb_type) + 2;
return mi_height_log2(sb_type) + 2 - CONFIG_SB8X8;
}
typedef struct {
......@@ -426,10 +436,10 @@ typedef struct macroblockd {
static INLINE void update_partition_context(MACROBLOCKD *xd,
BLOCK_SIZE_TYPE sb_type,
BLOCK_SIZE_TYPE sb_size) {
int bsl = mb_width_log2(sb_size), bs = 1 << bsl;
int bwl = mb_width_log2(sb_type);
int bhl = mb_height_log2(sb_type);
int boffset = mb_width_log2(BLOCK_SIZE_SB64X64) - bsl;
int bsl = mi_width_log2(sb_size) - CONFIG_SB8X8, bs = 1 << bsl;
int bwl = mi_width_log2(sb_type) - CONFIG_SB8X8;
int bhl = mi_height_log2(sb_type) - CONFIG_SB8X8;
int boffset = mi_width_log2(BLOCK_SIZE_SB64X64) - CONFIG_SB8X8 - bsl;
int i;
// skip macroblock partition
if (bsl == 0)
......@@ -465,11 +475,11 @@ static INLINE void update_partition_context(MACROBLOCKD *xd,
static INLINE int partition_plane_context(MACROBLOCKD *xd,
BLOCK_SIZE_TYPE sb_type) {
int bsl = mb_width_log2(sb_type), bs = 1 << bsl;
int bsl = mi_width_log2(sb_type) - CONFIG_SB8X8, bs = 1 << bsl;
int above = 0, left = 0, i;
int boffset = mb_width_log2(BLOCK_SIZE_SB64X64) - bsl;
int boffset = mi_width_log2(BLOCK_SIZE_SB64X64) - bsl - CONFIG_SB8X8;
assert(mb_width_log2(sb_type) == mb_height_log2(sb_type));
assert(mi_width_log2(sb_type) == mi_height_log2(sb_type));
assert(bsl >= 0);
assert(boffset >= 0);
......
......@@ -119,7 +119,8 @@ void vp9_adapt_coef_probs(struct VP9Common *);
static INLINE void vp9_reset_sb_tokens_context(MACROBLOCKD* const xd,
BLOCK_SIZE_TYPE bsize) {
/* Clear entropy contexts */
const int bw = 1 << mb_width_log2(bsize), bh = 1 << mb_height_log2(bsize);
const int bw = 1 << (b_width_log2(bsize) - 2);
const int bh = 1 << (b_height_log2(bsize) - 2);
vpx_memset(xd->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) * bw);
vpx_memset(xd->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) * bh);
}
......
......@@ -683,7 +683,7 @@ void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) {
vp9_clearall_segfeatures(xd);
xd->mb_segment_abs_delta = SEGMENT_DELTADATA;
if (cm->last_frame_seg_map)
vpx_memset(cm->last_frame_seg_map, 0, (cm->mb_rows * cm->mb_cols));
vpx_memset(cm->last_frame_seg_map, 0, (cm->mi_rows * cm->mi_cols));
// Reset the mode ref deltas for loop filter
vpx_memset(xd->last_ref_lf_deltas, 0, sizeof(xd->last_ref_lf_deltas));
......@@ -705,9 +705,9 @@ void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) {
vpx_memcpy(&cm->frame_contexts[i], &cm->fc, sizeof(cm->fc));
vpx_memset(cm->prev_mip, 0,
cm->mode_info_stride * (cm->mb_rows + 1)* sizeof(MODE_INFO));
cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO));
vpx_memset(cm->mip, 0,
cm->mode_info_stride * (cm->mb_rows + 1)* sizeof(MODE_INFO));
cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO));
vp9_update_mode_info_border(cm, cm->mip);
vp9_update_mode_info_in_image(cm, cm->mi);
......
......@@ -13,6 +13,15 @@
#include "./vpx_config.h"
#if CONFIG_SB8X8
#define LOG2_MI_SIZE 3
#else
#define LOG2_MI_SIZE 4
#endif
#define MI_SIZE (1 << LOG2_MI_SIZE)
#define MI_UV_SIZE (1 << (LOG2_MI_SIZE - 1))
typedef enum BLOCK_SIZE_TYPE {
#if CONFIG_SB8X8
BLOCK_SIZE_SB8X8,
......
......@@ -304,7 +304,7 @@ static void lpf_sb32(VP9_COMMON *cm, const MODE_INFO *mode_info_context,
y_only? 0 : v_ptr,
y_stride, uv_stride, dering);
// process 2nd MB top-right
mi = mode_info_context + 1;
mi = mode_info_context + (1 << CONFIG_SB8X8);
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);
......@@ -320,7 +320,7 @@ static void lpf_sb32(VP9_COMMON *cm, const MODE_INFO *mode_info_context,
y_stride, uv_stride, dering);
// process 3rd MB bottom-left
mi = mode_info_context + mis;
mi = mode_info_context + (mis << CONFIG_SB8X8);
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)));
......@@ -336,15 +336,15 @@ static void lpf_sb32(VP9_COMMON *cm, const MODE_INFO *mode_info_context,
y_stride, uv_stride, dering);
// process 4th MB bottom right
mi = mode_info_context + mis + 1;
mi = mode_info_context + ((mis + 1) << CONFIG_SB8X8);
do_left_v = !(wbl >= 3 /* 32x16 or >=32x32 */ && (tx_size >= TX_32X32 ||
sb_mb_lf_skip(mi - 1, mi)));
sb_mb_lf_skip(mi - (1 << CONFIG_SB8X8), mi)));
do_above_h = !(hbl >= 3 /* 16x32 or >=32x32 */ && (tx_size >= TX_32X32 ||
sb_mb_lf_skip(mode_info_context + 1, mi)));
sb_mb_lf_skip(mode_info_context + (1 << CONFIG_SB8X8), mi)));
do_left_v_mbuv = (wbl >= 3 /* 32x16 or >=32x32 */ && (tx_size >= TX_16X16 ||
sb_mb_lf_skip(mi - 1, mi)));
sb_mb_lf_skip(mi - (1 << CONFIG_SB8X8), mi)));
do_above_h_mbuv = !(hbl >= 3 /* 16x32 or >=32x32 */ && (tx_size >= TX_16X16 ||
sb_mb_lf_skip(mode_info_context + 1, mi)));
sb_mb_lf_skip(mode_info_context + (1 << CONFIG_SB8X8), mi)));
lpf_mb(cm, mi, do_left_v, do_above_h,
do_left_v_mbuv, do_above_h_mbuv,
y_ptr + 16 * y_stride + 16,
......@@ -361,16 +361,17 @@ static void lpf_sb64(VP9_COMMON *cm, const MODE_INFO *mode_info_context,
lpf_sb32(cm, mode_info_context, mb_row, mb_col,
y_ptr, u_ptr, v_ptr,
y_stride, uv_stride, y_only, dering);
lpf_sb32(cm, mode_info_context + 2, mb_row, mb_col + 2,
lpf_sb32(cm, mode_info_context + (2 << CONFIG_SB8X8), mb_row, mb_col + 2,
y_ptr + 32, u_ptr + 16, v_ptr + 16,
y_stride, uv_stride, y_only, dering);
lpf_sb32(cm, mode_info_context + cm->mode_info_stride * 2,
lpf_sb32(cm, mode_info_context + cm->mode_info_stride * (2 << CONFIG_SB8X8),
mb_row + 2, mb_col,
y_ptr + 32 * y_stride,
u_ptr + 16 * uv_stride,
v_ptr + 16 * uv_stride,
y_stride, uv_stride, y_only, dering);
lpf_sb32(cm, mode_info_context + cm->mode_info_stride * 2 + 2,
lpf_sb32(cm, mode_info_context + cm->mode_info_stride *
(2 << CONFIG_SB8X8) + (2 << CONFIG_SB8X8),
mb_row + 2, mb_col + 2,
y_ptr + 32 * y_stride + 32,
u_ptr + 16 * uv_stride + 16,
......@@ -440,14 +441,14 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_ptr += 64;
u_ptr = y_only? 0 : u_ptr + 32;
v_ptr = y_only? 0 : v_ptr + 32;
mode_info_context += 4; // step to next SB64
mode_info_context += 4 << CONFIG_SB8X8; // step to next SB64
}
if (extra_sb32_col) {
// process 2 SB32s in the extra SB32 col
lpf_sb32(cm, mode_info_context, mb_row, mb_col,
y_ptr, u_ptr, v_ptr,
y_stride, uv_stride, y_only, dering);
lpf_sb32(cm, mode_info_context + mis * 2,
lpf_sb32(cm, mode_info_context + mis * (2 << CONFIG_SB8X8),
mb_row + 2, mb_col,
y_ptr + 32 * y_stride,
u_ptr + 16 * uv_stride,
......@@ -456,7 +457,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_ptr += 32;
u_ptr = y_only? 0 : u_ptr + 16;
v_ptr = y_only? 0 : v_ptr + 16;
mode_info_context += 2; // step to next SB32
mode_info_context += 2 << CONFIG_SB8X8; // step to next SB32
mb_col += 2;
}
if (extra_mb_col) {
......@@ -474,7 +475,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_only? 0 : v_ptr,
y_stride, uv_stride, dering);
// process 2nd MB
mi = mode_info_context + mis;
mi = mode_info_context + (mis << CONFIG_SB8X8);
do_left_v = (mb_col > 0);
do_above_h = 1;
do_left_v_mbuv = 1;
......@@ -486,7 +487,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_only ? 0 : (v_ptr + 8 * uv_stride),
y_stride, uv_stride, dering);
// process 3nd MB
mi = mode_info_context + mis * 2;
mi = mode_info_context + (mis << CONFIG_SB8X8) * 2;
do_left_v = (mb_col > 0);
do_above_h = 1;
do_left_v_mbuv = 1;
......@@ -498,7 +499,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_only ? 0 : (v_ptr + 16 * uv_stride),
y_stride, uv_stride, dering);
// process 4th MB
mi = mode_info_context + mis * 3;
mi = mode_info_context + (mis << CONFIG_SB8X8) * 3;
do_left_v = (mb_col > 0);
do_above_h = 1;
do_left_v_mbuv = 1;
......@@ -512,7 +513,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_ptr += 16;
u_ptr = y_only? 0 : u_ptr + 8;
v_ptr = y_only? 0 : v_ptr + 8;
mode_info_context++; // step to next MB
mode_info_context += 1 << CONFIG_SB8X8; // step to next MB
}
// move pointers to the begining of next sb64 row
y_ptr += y_stride * 64 - post->y_width;
......@@ -521,7 +522,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
v_ptr += uv_stride * 32 - post->uv_width;
}
/* skip to next SB64 row */
mode_info_context += mis * 4 - cm->mb_cols;
mode_info_context += mis * (4 << CONFIG_SB8X8) - cm->mi_cols;
}
if (extra_sb32_row) {
const int sb32_cols = sb64_cols * 2 + extra_sb32_col;
......@@ -532,7 +533,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_ptr += 32;
u_ptr = y_only? 0 : u_ptr + 16;
v_ptr = y_only? 0 : v_ptr + 16;
mode_info_context += 2; // step to next SB32
mode_info_context += 2 << CONFIG_SB8X8; // step to next SB32
}
if (extra_mb_col) {
// process 1st MB
......@@ -548,7 +549,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_only? NULL : v_ptr,
y_stride, uv_stride, dering);
// process 2nd MB
mi = mode_info_context + mis;
mi = mode_info_context + (mis << CONFIG_SB8X8);
do_left_v = (mb_col > 0);
do_above_h = 1;
do_left_v_mbuv = 1;
......@@ -562,14 +563,14 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_ptr += 16;
u_ptr = y_only? 0 : u_ptr + 8;
v_ptr = y_only? 0 : v_ptr + 8;
mode_info_context++; /* step to next MB */
mode_info_context += 1 << CONFIG_SB8X8; /* step to next MB */
}
// move pointers to the beginning of next sb64 row
y_ptr += y_stride * 32 - post->y_width;
u_ptr += y_only? 0 : uv_stride * 16 - post->uv_width;
v_ptr += y_only? 0 : uv_stride * 16 - post->uv_width;
// skip to next MB row if exist
mode_info_context += mis * 2 - cm->mb_cols;
mode_info_context += mis * (2 << CONFIG_SB8X8) - cm->mi_cols;
mb_row += 2;
}
if (extra_mb_row) {
......@@ -588,7 +589,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_ptr += 16;
u_ptr = y_only? 0 : u_ptr + 8;
v_ptr = y_only? 0 : v_ptr + 8;
mode_info_context++; // step to next MB
mode_info_context += 1 << CONFIG_SB8X8; // step to next MB
}
}
}
......@@ -12,21 +12,37 @@
#define MVREF_NEIGHBOURS 8
#if CONFIG_SB8X8
static int mb_mv_ref_search[MVREF_NEIGHBOURS][2] = {
{0, -1}, {-1, 0}, {-1, -1}, {0, -2},
{-2, 0}, {-1, -2}, {-2, -1}, {-2, -2}
{0, -1}, {-1, 0}, {-1, -1}, {0, -3},
{-3, 0}, {-1, -3}, {-3, -1}, {-3, -3}
};
static int sb_mv_ref_search[MVREF_NEIGHBOURS][2] = {
{0, -1}, {-1, 0}, {1, -1}, {-1, 1},
{-1, -1}, {0, -2}, {-2, 0}, {-1, -2}
{0, -1}, {-1, 0}, {2, -1}, {-1, 2},
{-1, -1}, {0, -3}, {-3, 0}, {-1, -3}
};
static int sb64_mv_ref_search[MVREF_NEIGHBOURS][2] = {
{0, -1}, {-1, 0}, {1, -1}, {-1, 1},
{2, -1}, {-1, 2}, {3, -1}, {-1,-1}
{0, -1}, {-1, 0}, {2, -1}, {-1, 2},
{4, -1}, {-1, 4}, {6, -1}, {-1, -1}
};
#else
static int mb_mv_ref_search[MVREF_NEIGHBOURS][2] = {
{0, -1}, {-1, 0}, {-1, -1}, {0, -2},
{-2, 0}, {-1, -2}, {-2, -1}, {-2, -2}
};
static int sb_mv_ref_search[MVREF_NEIGHBOURS][2] = {
{0, -1}, {-1, 0}, {1, -1}, {-1, 1},
{-1, -1}, {0, -2}, {-2, 0}, {-1, -2}
};
static int sb64_mv_ref_search[MVREF_NEIGHBOURS][2] = {
{0, -1}, {-1, 0}, {1, -1}, {-1, 1},
{2, -1}, {-1, 2}, {3, -1}, {-1, -1}
};
#endif
// clamp_mv_ref
#define MV_BORDER (16 << 3) // Allow 16 pels in 1/8th pel units
......@@ -160,7 +176,7 @@ void vp9_find_mv_refs(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
int refmv_count = 0;
int split_count = 0;
int (*mv_ref_search)[2];
const int mb_col = (-xd->mb_to_left_edge) >> 7;
const int mi_col = get_mi_col(xd);
// Blank the reference vector lists and other local structures.
vpx_memset(mv_ref_list, 0, sizeof(int_mv) * MAX_MV_REF_CANDIDATES);
vpx_memset(candidate_scores, 0, sizeof(candidate_scores));
......@@ -176,11 +192,11 @@ void vp9_find_mv_refs(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
// We first scan for candidate vectors that match the current reference frame
// Look at nearest neigbours
for (i = 0; i < 2; ++i) {
const int mb_search_col = mb_col + mv_ref_search[i][0];
const int mi_search_col = mi_col + mv_ref_search[i][0];
if ((mb_search_col >= cm->cur_tile_mb_col_start) &&
(mb_search_col < cm->cur_tile_mb_col_end) &&
((mv_ref_search[i][1] << 7) >= xd->mb_to_top_edge)) {
if ((mi_search_col >= cm->cur_tile_mi_col_start) &&
(mi_search_col < cm->cur_tile_mi_col_end) &&
((mv_ref_search[i][1] << (7 - CONFIG_SB8X8)) >= xd->mb_to_top_edge)) {
candidate_mi = here + mv_ref_search[i][0] +
(mv_ref_search[i][1] * xd->mode_info_stride);
......@@ -196,11 +212,11 @@ void vp9_find_mv_refs(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
// More distant neigbours
for (i = 2; (i < MVREF_NEIGHBOURS) &&
(refmv_count < MAX_MV_REF_CANDIDATES); ++i) {
const int mb_search_col = mb_col + mv_ref_search[i][0];
const int mi_search_col = mi_col + mv_ref_search[i][0];
if ((mb_search_col >= cm->cur_tile_mb_col_start) &&
(mb_search_col < cm->cur_tile_mb_col_end) &&
((mv_ref_search[i][1] << 7) >= xd->mb_to_top_edge)) {
if ((mi_search_col >= cm->cur_tile_mi_col_start) &&
(mi_search_col < cm->cur_tile_mi_col_end) &&
((mv_ref_search[i][1] << (7 - CONFIG_SB8X8)) >= xd->mb_to_top_edge)) {
candidate_mi = here + mv_ref_search[i][0] +
(mv_ref_search[i][1] * xd->mode_info_stride);
......@@ -226,11 +242,11 @@ void vp9_find_mv_refs(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
// Look first at spatial neighbours
for (i = 0; (i < MVREF_NEIGHBOURS) &&
(refmv_count < MAX_MV_REF_CANDIDATES); ++i) {
const int mb_search_col = mb_col + mv_ref_search[i][0];
const int mi_search_col = mi_col + mv_ref_search[i][0];
if ((mb_search_col >= cm->cur_tile_mb_col_start) &&
(mb_search_col < cm->cur_tile_mb_col_end) &&
((mv_ref_search[i][1] << 7) >= xd->mb_to_top_edge)) {
if ((mi_search_col >= cm->cur_tile_mi_col_start) &&
(mi_search_col < cm->cur_tile_mi_col_end) &&
((mv_ref_search[i][1] << (7 - CONFIG_SB8X8)) >= xd->mb_to_top_edge)) {
candidate_mi = here + mv_ref_search[i][0] +
(mv_ref_search[i][1] * xd->mode_info_stride);
......
......@@ -201,9 +201,12 @@ typedef struct VP9Common {
int last_show_frame;
int frame_flags;
// MBs, mb_rows/cols is in 16-pixel units; mi_rows/cols is in
// MODE_INFO units (depending on CONFIG_SB8X8, that is either
// 16-pixel or 8-pixel)
int MBs;
int mb_rows;
int mb_cols;
int mb_rows, mi_rows;
int mb_cols, mi_cols;
int mode_info_stride;
/* profile settings */
......@@ -314,9 +317,9 @@ typedef struct VP9Common {
int frame_parallel_decoding_mode;
int tile_columns, log2_tile_columns;
int cur_tile_mb_col_start, cur_tile_mb_col_end, cur_tile_col_idx;
int cur_tile_mi_col_start, cur_tile_mi_col_end, cur_tile_col_idx;
int tile_rows, log2_tile_rows;
int cur_tile_mb_row_start, cur_tile_mb_row_end, cur_tile_row_idx;
int cur_tile_mi_row_start, cur_tile_mi_row_end, cur_tile_row_idx;
} VP9_COMMON;
static int get_free_fb(VP9_COMMON *cm) {
......@@ -343,26 +346,26 @@ static int mb_cols_aligned_to_sb(VP9_COMMON *cm) {
return (cm->mb_cols + 3) & ~3;
}
static void set_mb_row_col(VP9_COMMON *cm, MACROBLOCKD *xd,
int mb_row, int bh,
int mb_col, int bw) {
xd->mb_to_top_edge = -((mb_row * 16) << 3);
xd->mb_to_bottom_edge = ((cm->mb_rows - bh - mb_row) * 16) << 3;
xd->mb_to_left_edge = -((mb_col * 16) << 3);
xd->mb_to_right_edge = ((cm->mb_cols - bw - mb_col) * 16) << 3;
static void set_mi_row_col(VP9_COMMON *cm, MACROBLOCKD *xd,
int mi_row, int bh,
int mi_col, int bw) {
xd->mb_to_top_edge = -((mi_row * MI_SIZE) << 3);
xd->mb_to_bottom_edge = ((cm->mi_rows - bh - mi_row) * MI_SIZE) << 3;
xd->mb_to_left_edge = -((mi_col * MI_SIZE) << 3);
xd->mb_to_right_edge = ((cm->mi_cols - bw - mi_col) * MI_SIZE) << 3;
// Are edges available for intra prediction?
xd->up_available = (mb_row != 0);
xd->left_available = (mb_col > cm->cur_tile_mb_col_start);
xd->right_available = (mb_col + bw < cm->cur_tile_mb_col_end);
xd->up_available = (mi_row != 0);
xd->left_available = (mi_col > cm->cur_tile_mi_col_start);
xd->right_available = (mi_col + bw < cm->cur_tile_mi_col_end);
}
static int get_mb_row(const MACROBLOCKD *xd) {
return ((-xd->mb_to_top_edge) >> 7);
static int get_mi_row(const MACROBLOCKD *xd) {
return ((-xd->mb_to_top_edge) >> (3 + LOG2_MI_SIZE));
}
static int get_mb_col(const MACROBLOCKD *xd) {
return ((-xd->mb_to_left_edge) >> 7);
static int get_mi_col(const MACROBLOCKD *xd) {
return ((-xd->mb_to_left_edge) >> (3 + LOG2_MI_SIZE));
}
static int get_token_alloc(int mb_rows, int mb_cols) {
......
......@@ -169,35 +169,34 @@ void vp9_set_pred_flag(MACROBLOCKD *const xd,
unsigned char pred_flag) {
const int mis = xd->mode_info_stride;
BLOCK_SIZE_TYPE bsize = xd->mode_info_context->mbmi.sb_type;
const int bh = 1 << mb_height_log2(bsize);
const int bw = 1 << mb_width_log2(bsize);
const int bh = 1 << mi_height_log2(bsize);
const int bw = 1 << mi_width_log2(bsize);
#define sub(a, b) (b) < 0 ? (a) + (b) : (a)
const int x_mbs = sub(bw, xd->mb_to_right_edge >> 7);
const int y_mbs = sub(bh, xd->mb_to_bottom_edge >> 7);
const int x_mis = sub(bw, xd->mb_to_right_edge >> (3 + LOG2_MI_SIZE));
const int y_mis = sub(bh, xd->mb_to_bottom_edge >> (3 + LOG2_MI_SIZE));
#undef sub
int x, y;
switch (pred_id) {
case PRED_SEG_ID:
for (y = 0; y < y_mbs; y++) {
for (x = 0; x < x_mbs; x++) {
xd->mode_info_context[y * mis + x].mbmi.seg_id_predicted =
pred_flag;
for (y = 0; y < y_mis; y++) {
for (x = 0; x < x_mis; x++) {
xd->mode_info_context[y * mis + x].mbmi.seg_id_predicted = pred_flag;
}
}
break;
case PRED_REF:
for (y = 0; y < y_mbs; y++) {
for (x = 0; x < x_mbs; x++) {
for (y = 0; y < y_mis; y++) {
for (x = 0; x < x_mis; x++) {
xd->mode_info_context[y * mis + x].mbmi.ref_predicted = pred_flag;
}
}
break;
case PRED_MBSKIP:
for (y = 0; y < y_mbs; y++) {
for (x = 0; x < x_mbs; x++) {
for (y = 0; y < y_mis; y++) {
for (x = 0; x < x_mis; x++) {
xd->mode_info_context[y * mis + x].mbmi.mb_skip_coeff = pred_flag;
}
}
......@@ -214,27 +213,23 @@ void vp9_set_pred_flag(MACROBLOCKD *const xd,
// peredict various bitstream signals.
// Macroblock segment id prediction function
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 > 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);
const int xmbs = MIN(cm->mb_cols - mb_col, bw);
int segment_id = INT_MAX;
int x, y;
for (y = 0; y < ymbs; y++) {
for (x = 0; x < xmbs; x++) {
const int index = mb_index + (y * cm->mb_cols + x);
segment_id = MIN(segment_id, cm->last_frame_seg_map[index]);
}
int vp9_get_pred_mi_segid(VP9_COMMON *cm, BLOCK_SIZE_TYPE sb_type,
int mi_row, int mi_col) {
const int mi_index = mi_row * cm->mi_cols + mi_col;
const int bw = 1 << mi_width_log2(sb_type);
const int bh = 1 << mi_height_log2(sb_type);
const int ymis = MIN(cm->mi_rows - mi_row, bh);
const int xmis = MIN(cm->mi_cols - mi_col, bw);
int segment_id = INT_MAX;
int x, y;
for (y = 0; y < ymis; y++) {
for (x = 0; x < xmis; x++) {
const int index = mi_index + (y * cm->mi_cols + x);
segment_id = MIN(segment_id, cm->last_frame_seg_map[index]);
}
return segment_id;
} else {
return cm->last_frame_seg_map[mb_index];
}
return segment_id;
}
MV_REFERENCE_FRAME vp9_get_pred_ref(const VP9_COMMON *const cm,
......
......@@ -43,8 +43,8 @@ void vp9_set_pred_flag(MACROBLOCKD *const xd,
unsigned char pred_flag);
int vp9_get_pred_mb_segid(VP9_COMMON *cm, BLOCK_SIZE_TYPE sb_type,
int mb_row, int mb_col);
int vp9_get_pred_mi_segid(VP9_COMMON *cm, BLOCK_SIZE_TYPE sb_type,
int mi_row, int mi_col);
MV_REFERENCE_FRAME vp9_get_pred_ref(const VP9_COMMON *const cm,
const MACROBLOCKD *const xd);
......
......@@ -387,11 +387,11 @@ static void build_inter_predictors(int plane, int block,
}
}
void vp9_build_inter_predictors_sby(MACROBLOCKD *xd,
int mb_row,
int mb_col,
int mi_row,
int mi_col,
BLOCK_SIZE_TYPE bsize) {
struct build_inter_predictors_args args = {
xd, mb_col * 16, mb_row * 16,
xd, mi_col * MI_SIZE, mi_row * MI_SIZE,
{xd->plane[0].dst.buf, NULL, NULL}, {xd->plane[0].dst.stride, 0, 0},
{{xd->plane[0].pre[0].buf, NULL, NULL},
{xd->plane[0].pre[1].buf, NULL, NULL}},
......@@ -401,11 +401,11 @@ void vp9_build_inter_predictors_sby(MACROBLOCKD *xd,
foreach_predicted_block_in_plane(xd, bsize, 0, build_inter_predictors, &args);
}
void vp9_build_inter_predictors_sbuv(MACROBLOCKD *xd,
int mb_row,
int mb_col,
int mi_row,
int mi_col,
BLOCK_SIZE_TYPE bsize) {
struct build_inter_predictors_args args = {
xd, mb_col * 16, mb_row * 16,
xd, mi_col * MI_SIZE, mi_row * MI_SIZE,
{NULL, xd->plane[1].dst.buf, xd->plane[2].dst.buf},
{0, xd->plane[1].dst.stride, xd->plane[1].dst.stride},
{{NULL, xd->plane[1].pre[0].buf, xd->plane[2].pre[0].buf},
......@@ -416,7 +416,7 @@ void vp9_build_inter_predictors_sbuv(MACROBLOCKD *xd,
foreach_predicted_block_uv(xd, bsize, build_inter_predictors, &args);
}
void vp9_build_inter_predictors_sb(MACROBLOCKD *xd,
int mb_row, int mb_col,
int mi_row, int mi_col,
BLOCK_SIZE_TYPE bsize) {
#if CONFIG_COMP_INTERINTRA_PRED
uint8_t *const y = xd->plane[0].dst.buf;
......@@ -426,8 +426,8 @@ void vp9_build_inter_predictors_sb(MACROBLOCKD *xd,
const int uv_stride = xd->plane[1].dst.stride;
#endif
vp9_build_inter_predictors_sby(xd, mb_row, mb_col, bsize);
vp9_build_inter_predictors_sbuv(xd, mb_row, mb_col, bsize);
vp9_build_inter_predictors_sby(xd, mi_row, mi_col, bsize);
vp9_build_inter_predictors_sbuv(xd, mi_row, mi_col, bsize);
#if CONFIG_COMP_INTERINTRA_PRED
if (xd->mode_info_context->mbmi.second_ref_frame == INTRA_FRAME)
......
......@@ -79,11 +79,11 @@ static int scaled_buffer_offset(int x_offset,