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));
}
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
}
}
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);
/* 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);
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 {
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)
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);
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);
}
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));
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);
#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,
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);
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)));
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,
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,
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,
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) {
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;
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;
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;
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;
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;
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
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;
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) {
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
}
}
}
#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
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));
// 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);
// 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);
// 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);
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 */
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) {
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) {
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;
}
}
// 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,
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);
}
}
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}},
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},
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;
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)
static void setup_pred_plane(struct buf_2d *dst,
uint8_t *src, int stride,
- int mb_row, int mb_col,
+ int mi_row, int mi_col,
const struct scale_factors *scale,
int subsampling_x, int subsampling_y) {
- const int x = (16 * mb_col) >> subsampling_x;
- const int y = (16 * mb_row) >> subsampling_y;
+ const int x = (MI_SIZE * mi_col) >> subsampling_x;
+ const int y = (MI_SIZE * mi_row) >> subsampling_y;
dst->buf = src + scaled_buffer_offset(x, y, stride, scale);
dst->stride = stride;
}
// TODO(jkoleszar): audit all uses of this that don't set mb_row, mb_col
static void setup_dst_planes(MACROBLOCKD *xd,
const YV12_BUFFER_CONFIG *src,
- int mb_row, int mb_col) {
+ int mi_row, int mi_col) {
setup_pred_plane(&xd->plane[0].dst,
src->y_buffer, src->y_stride,
- mb_row, mb_col, NULL,
+ mi_row, mi_col, NULL,
xd->plane[0].subsampling_x, xd->plane[0].subsampling_y);
setup_pred_plane(&xd->plane[1].dst,
src->u_buffer, src->uv_stride,
- mb_row, mb_col, NULL,
+ mi_row, mi_col, NULL,
xd->plane[1].subsampling_x, xd->plane[1].subsampling_y);
setup_pred_plane(&xd->plane[2].dst,
src->v_buffer, src->uv_stride,
- mb_row, mb_col, NULL,
+ mi_row, mi_col, NULL,
xd->plane[2].subsampling_x, xd->plane[2].subsampling_y);
}
static void setup_pre_planes(MACROBLOCKD *xd,
const YV12_BUFFER_CONFIG *src0,
const YV12_BUFFER_CONFIG *src1,
- int mb_row, int mb_col,
+ int mi_row, int mi_col,
const struct scale_factors *scale,
const struct scale_factors *scale_uv) {
int i;
setup_pred_plane(&xd->plane[0].pre[i],
src->y_buffer, src->y_stride,
- mb_row, mb_col, scale ? scale + i : NULL,
+ mi_row, mi_col, scale ? scale + i : NULL,
xd->plane[0].subsampling_x, xd->plane[0].subsampling_y);
setup_pred_plane(&xd->plane[1].pre[i],
src->u_buffer, src->uv_stride,
- mb_row, mb_col, scale_uv ? scale_uv + i : NULL,
+ mi_row, mi_col, scale_uv ? scale_uv + i : NULL,
xd->plane[1].subsampling_x, xd->plane[1].subsampling_y);
setup_pred_plane(&xd->plane[2].pre[i],
src->v_buffer, src->uv_stride,
- mb_row, mb_col, scale_uv ? scale_uv + i : NULL,
+ mi_row, mi_col, scale_uv ? scale_uv + i : NULL,
xd->plane[2].subsampling_x, xd->plane[2].subsampling_y);
}
}
static void setup_pred_block(YV12_BUFFER_CONFIG *dst,
const YV12_BUFFER_CONFIG *src,
- int mb_row, int mb_col,
+ int mi_row, int mi_col,
const struct scale_factors *scale,
const struct scale_factors *scale_uv) {
const int recon_y_stride = src->y_stride;
int recon_uvoffset;
if (scale) {
- recon_yoffset = scaled_buffer_offset(16 * mb_col, 16 * mb_row,
+ recon_yoffset = scaled_buffer_offset(MI_SIZE * mi_col, MI_SIZE * mi_row,
recon_y_stride, scale);
- recon_uvoffset = scaled_buffer_offset(8 * mb_col, 8 * mb_row,
+ recon_uvoffset = scaled_buffer_offset(MI_UV_SIZE * mi_col,
+ MI_UV_SIZE * mi_row,
recon_uv_stride, scale_uv);
} else {
- recon_yoffset = 16 * mb_row * recon_y_stride + 16 * mb_col;
- recon_uvoffset = 8 * mb_row * recon_uv_stride + 8 * mb_col;
+ recon_yoffset = MI_SIZE * mi_row * recon_y_stride + MI_SIZE * mi_col;
+ recon_uvoffset = MI_UV_SIZE * mi_row * recon_uv_stride +
+ MI_UV_SIZE * mi_col;
}
*dst = *src;
uint8_t *ypred,
int ystride,
BLOCK_SIZE_TYPE bsize) {
- int bwl = mb_width_log2(bsize), bw = 16 << bwl;
- int bhl = mb_height_log2(bsize), bh = 16 << bhl;
+ int bwl = mi_width_log2(bsize), bw = MI_SIZE << bwl;
+ int bhl = mi_height_log2(bsize), bh = MI_SIZE << bhl;
uint8_t intrapredictor[4096];
vp9_build_intra_predictors(
xd->plane[0].dst.buf, xd->plane[0].dst.stride,
uint8_t *vpred,
int uvstride,
BLOCK_SIZE_TYPE bsize) {
- int bwl = mb_width_log2(bsize), bw = 8 << bwl;
- int bhl = mb_height_log2(bsize), bh = 8 << bhl;
+ int bwl = mi_width_log2(bsize), bw = MI_UV_SIZE << bwl;
+ int bhl = mi_height_log2(bsize), bh = MI_UV_SIZE << bhl;
uint8_t uintrapredictor[1024];
uint8_t vintrapredictor[1024];
vp9_build_intra_predictors(
void vp9_build_intra_predictors_sby_s(MACROBLOCKD *xd,
BLOCK_SIZE_TYPE bsize) {
- const int bwl = b_width_log2(bsize), bw = 4 << bwl;
- const int bhl = b_height_log2(bsize), bh = 4 << bhl;
+ const int bwl = mi_width_log2(bsize), bw = MI_SIZE << bwl;
+ const int bhl = mi_height_log2(bsize), bh = MI_SIZE << bhl;
vp9_build_intra_predictors(xd->plane[0].dst.buf, xd->plane[0].dst.stride,
xd->plane[0].dst.buf, xd->plane[0].dst.stride,
void vp9_build_intra_predictors_sbuv_s(MACROBLOCKD *xd,
BLOCK_SIZE_TYPE bsize) {
- const int bwl = b_width_log2(bsize) - 1, bw = 4 << bwl;
- const int bhl = b_height_log2(bsize) - 1, bh = 4 << bhl;
+ const int bwl = mi_width_log2(bsize), bw = MI_UV_SIZE << bwl;
+ const int bhl = mi_height_log2(bsize), bh = MI_UV_SIZE << bhl;
vp9_build_intra_predictors(xd->plane[1].dst.buf, xd->plane[1].dst.stride,
xd->plane[1].dst.buf, xd->plane[1].dst.stride,
static void vp9_get_tile_offsets(VP9_COMMON *cm, int *min_tile_off,
int *max_tile_off, int tile_idx,
- int log2_n_tiles, int n_mbs) {
- const int n_sbs = (n_mbs + 3) >> 2;
+ int log2_n_tiles, int n_mis) {
+#if CONFIG_SB8X8
+ const int n_sbs = (n_mis + 7) >> 3;
+#else
+ const int n_sbs = (n_mis + 3) >> 2;
+#endif
const int sb_off1 = (tile_idx * n_sbs) >> log2_n_tiles;
const int sb_off2 = ((tile_idx + 1) * n_sbs) >> log2_n_tiles;
- *min_tile_off = MIN(sb_off1 << 2, n_mbs);
- *max_tile_off = MIN(sb_off2 << 2, n_mbs);
+ *min_tile_off = MIN(sb_off1 << (2 + CONFIG_SB8X8), n_mis);
+ *max_tile_off = MIN(sb_off2 << (2 + CONFIG_SB8X8), n_mis);
}
void vp9_get_tile_col_offsets(VP9_COMMON *cm, int tile_col_idx) {
cm->cur_tile_col_idx = tile_col_idx;
- vp9_get_tile_offsets(cm, &cm->cur_tile_mb_col_start,
- &cm->cur_tile_mb_col_end, tile_col_idx,
- cm->log2_tile_columns, cm->mb_cols);
+ vp9_get_tile_offsets(cm, &cm->cur_tile_mi_col_start,
+ &cm->cur_tile_mi_col_end, tile_col_idx,
+ cm->log2_tile_columns, cm->mi_cols);
}
void vp9_get_tile_row_offsets(VP9_COMMON *cm, int tile_row_idx) {
cm->cur_tile_row_idx = tile_row_idx;
- vp9_get_tile_offsets(cm, &cm->cur_tile_mb_row_start,
- &cm->cur_tile_mb_row_end, tile_row_idx,
- cm->log2_tile_rows, cm->mb_rows);
+ vp9_get_tile_offsets(cm, &cm->cur_tile_mi_row_start,
+ &cm->cur_tile_mi_row_end, tile_row_idx,
+ cm->log2_tile_rows, cm->mi_rows);
}
}
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;
+ int mi_row, int mi_col, int segment_id) {
+ const int mi_index = mi_row * cm->mi_cols + mi_col;
const BLOCK_SIZE_TYPE sb_type = mbmi->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);
- const int xmbs = MIN(cm->mb_cols - mb_col, bw);
- 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);
- cm->last_frame_seg_map[index] = segment_id;
- }
+ 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 x, y;
+
+ for (y = 0; y < ymis; y++) {
+ for (x = 0; x < xmis; x++) {
+ const int index = mi_index + (y * cm->mi_cols + x);
+ cm->last_frame_seg_map[index] = segment_id;
}
- } else {
- cm->last_frame_seg_map[mb_index] = segment_id;
}
}
extern const int vp9_i8x8_block[4];
static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m,
- int mb_row, int mb_col,
+ int mi_row, int mi_col,
vp9_reader *r) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
m->mbmi.segment_id = 0;
if (xd->segmentation_enabled && xd->update_mb_segmentation_map) {
m->mbmi.segment_id = read_mb_segid(r, xd);
- set_segment_id(cm, &m->mbmi, mb_row, mb_col, m->mbmi.segment_id);
+ set_segment_id(cm, &m->mbmi, mi_row, mi_col, m->mbmi.segment_id);
}
m->mbmi.mb_skip_coeff = vp9_segfeature_active(xd, m->mbmi.segment_id,
// This function either reads the segment id for the current macroblock from
// the bitstream or if the value is temporally predicted asserts the predicted
// value
-static int read_mb_segment_id(VP9D_COMP *pbi, int mb_row, int mb_col,
+static int read_mb_segment_id(VP9D_COMP *pbi, int mi_row, int mi_col,
vp9_reader *r) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
// If the value is flagged as correctly predicted
// then use the predicted value, otherwise decode it explicitly
- segment_id = pred_flag ? vp9_get_pred_mb_segid(cm, mbmi->sb_type,
- mb_row, mb_col)
+ segment_id = pred_flag ? vp9_get_pred_mi_segid(cm, mbmi->sb_type,
+ mi_row, mi_col)
: read_mb_segid(r, xd);
} else {
segment_id = read_mb_segid(r, xd); // Normal unpredicted coding mode
}
- set_segment_id(cm, mbmi, mb_row, mb_col, segment_id); // Side effect
+ set_segment_id(cm, mbmi, mi_row, mi_col, segment_id); // Side effect
return segment_id;
} else {
- return vp9_get_pred_mb_segid(cm, mbmi->sb_type, mb_row, mb_col);
+ return vp9_get_pred_mi_segid(cm, mbmi->sb_type, mi_row, mi_col);
}
}
static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
MODE_INFO *prev_mi,
- int mb_row, int mb_col,
+ int mi_row, int mi_col,
vp9_reader *r) {
VP9_COMMON *const cm = &pbi->common;
nmv_context *const nmvc = &cm->fc.nmvc;
int_mv *const mv0 = &mbmi->mv[0];
int_mv *const mv1 = &mbmi->mv[1];
- const int bw = 1 << mb_width_log2(mi->mbmi.sb_type);
- const int bh = 1 << mb_height_log2(mi->mbmi.sb_type);
+ const int bw = 1 << mi_width_log2(mi->mbmi.sb_type);
+ const int bh = 1 << mi_height_log2(mi->mbmi.sb_type);
const int use_prev_in_find_mv_refs = cm->width == cm->last_width &&
cm->height == cm->last_height &&
// Distance of Mb to the various image edges.
// These specified to 8th pel as they are always compared to MV values
// that are in 1/8th pel units
- set_mb_row_col(cm, xd, mb_row, bh, mb_col, bw);
+ set_mi_row_col(cm, xd, mi_row, bh, mi_col, bw);
mb_to_top_edge = xd->mb_to_top_edge - LEFT_TOP_MARGIN;
mb_to_bottom_edge = xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN;
mb_to_right_edge = xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN;
// Read the macroblock segment id.
- mbmi->segment_id = read_mb_segment_id(pbi, mb_row, mb_col, r);
+ mbmi->segment_id = read_mb_segment_id(pbi, mi_row, mi_col, r);
mbmi->mb_skip_coeff = vp9_segfeature_active(xd, mbmi->segment_id,
SEG_LVL_SKIP);
const int ref_fb_idx = cm->active_ref_idx[ref_frame - 1];
setup_pre_planes(xd, &cm->yv12_fb[ref_fb_idx], NULL,
- mb_row, mb_col, xd->scale_factor, xd->scale_factor_uv);
+ mi_row, mi_col, xd->scale_factor, xd->scale_factor_uv);
#ifdef DEC_DEBUG
if (dec_debug)
*sf1 = cm->active_ref_scale[second_ref_frame - 1];
setup_pre_planes(xd, NULL, &cm->yv12_fb[second_ref_fb_idx],
- mb_row, mb_col, xd->scale_factor, xd->scale_factor_uv);
+ mi_row, mi_col, xd->scale_factor, xd->scale_factor_uv);
vp9_find_mv_refs(cm, xd, mi,
use_prev_in_find_mv_refs ? prev_mi : NULL,
void vp9_decode_mb_mode_mv(VP9D_COMP* const pbi,
MACROBLOCKD* const xd,
- int mb_row,
- int mb_col,
+ int mi_row,
+ int mi_col,
vp9_reader *r) {
VP9_COMMON *const cm = &pbi->common;
MODE_INFO *mi = xd->mode_info_context;
MB_MODE_INFO *const mbmi = &mi->mbmi;
if (cm->frame_type == KEY_FRAME) {
- kfread_modes(pbi, mi, mb_row, mb_col, r);
+ kfread_modes(pbi, mi, mi_row, mi_col, r);
} else {
- read_mb_modes_mv(pbi, mi, &mi->mbmi, prev_mi, mb_row, mb_col, r);
+ read_mb_modes_mv(pbi, mi, &mi->mbmi, prev_mi, mi_row, mi_col, r);
set_scale_factors(xd,
mi->mbmi.ref_frame - 1, mi->mbmi.second_ref_frame - 1,
cm->active_ref_scale);
}
- 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);
- const int x_mbs = MIN(bw, cm->mb_cols - mb_col);
+ if (1) {
+ const int bw = 1 << mi_width_log2(mbmi->sb_type);
+ const int bh = 1 << mi_height_log2(mbmi->sb_type);
+ const int y_mis = MIN(bh, cm->mi_rows - mi_row);
+ const int x_mis = MIN(bw, cm->mi_cols - mi_col);
const int mis = cm->mode_info_stride;
int x, y;
- for (y = 0; y < y_mbs; y++)
- for (x = !y; x < x_mbs; x++)
+ for (y = 0; y < y_mis; y++)
+ for (x = !y; x < x_mis; x++)
mi[y * mis + x] = *mi;
}
}
decode_sbuv_8x8(mb, bsize);
}
-static void decode_sb(VP9D_COMP *pbi, MACROBLOCKD *xd, int mb_row, int mb_col,
+static void decode_sb(VP9D_COMP *pbi, MACROBLOCKD *xd, int mi_row, int mi_col,
vp9_reader *r, BLOCK_SIZE_TYPE bsize) {
- const int bwl = mb_width_log2(bsize), bhl = mb_height_log2(bsize);
+ const int bwl = mi_width_log2(bsize), bhl = mi_height_log2(bsize);
const int bw = 1 << bwl, bh = 1 << bhl;
int n, eobtotal;
VP9_COMMON *const pc = &pbi->common;
vp9_build_intra_predictors_sby_s(xd, bsize);
vp9_build_intra_predictors_sbuv_s(xd, bsize);
} else {
- vp9_build_inter_predictors_sb(xd, mb_row, mb_col, bsize);
+ vp9_build_inter_predictors_sb(xd, mi_row, mi_col, bsize);
}
if (mbmi->mb_skip_coeff) {
for (n = 0; n < bw * bh; n++) {
const int x_idx = n & (bw - 1), y_idx = n >> bwl;
- if (mb_col + x_idx < pc->mb_cols && mb_row + y_idx < pc->mb_rows)
+ if (mi_col + x_idx < pc->mi_cols && mi_row + y_idx < pc->mi_rows)
mi[y_idx * mis + x_idx].mbmi.mb_skip_coeff = 1;
}
} else {
// TODO(jingning): Need to merge SB and MB decoding. The MB decoding currently
// couples special handles on I8x8, B_PRED, and splitmv modes.
static void decode_mb(VP9D_COMP *pbi, MACROBLOCKD *xd,
- int mb_row, int mb_col,
+ int mi_row, int mi_col,
vp9_reader *r) {
int eobtotal = 0;
MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi;
xd->mode_info_context->mbmi.mode, tx_size,
xd->mode_info_context->mbmi.interp_filter);
#endif
- vp9_build_inter_predictors_sb(xd, mb_row, mb_col, BLOCK_SIZE_MB16X16);
+ vp9_build_inter_predictors_sb(xd, mi_row, mi_col, BLOCK_SIZE_MB16X16);
}
if (mbmi->mb_skip_coeff) {
}
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);
- const int bw = 1 << mb_width_log2(bsize);
+ int mi_row, int mi_col) {
+ const int bh = 1 << mi_height_log2(bsize);
+ const int bw = 1 << mi_width_log2(bsize);
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
- const int mb_idx = mb_row * cm->mode_info_stride + mb_col;
+ const int mi_idx = mi_row * cm->mode_info_stride + mi_col;
const YV12_BUFFER_CONFIG *dst_fb = &cm->yv12_fb[cm->new_fb_idx];
- const int recon_yoffset = (16 * mb_row) * dst_fb->y_stride + (16 * mb_col);
- const int recon_uvoffset = (8 * mb_row) * dst_fb->uv_stride + (8 * mb_col);
+ const int recon_yoffset =
+ (MI_SIZE * mi_row) * dst_fb->y_stride + (MI_SIZE * mi_col);
+ const int recon_uvoffset =
+ (MI_UV_SIZE * mi_row) * dst_fb->uv_stride + (MI_UV_SIZE * mi_col);
- xd->mode_info_context = cm->mi + mb_idx;
+ xd->mode_info_context = cm->mi + mi_idx;
xd->mode_info_context->mbmi.sb_type = bsize;
- xd->prev_mode_info_context = cm->prev_mi + mb_idx;
- xd->above_context = cm->above_context + mb_col;
- xd->left_context = cm->left_context + mb_row % 4;
- xd->above_seg_context = cm->above_seg_context + mb_col;
- xd->left_seg_context = cm->left_seg_context + (mb_row & 3);
+ xd->prev_mode_info_context = cm->prev_mi + mi_idx;
+
+ xd->above_context = cm->above_context + (mi_col >> CONFIG_SB8X8);
+ xd->left_context = cm->left_context + ((mi_row >> CONFIG_SB8X8) & 3);
+ xd->above_seg_context = cm->above_seg_context + (mi_col >> CONFIG_SB8X8);
+ xd->left_seg_context = cm->left_seg_context + ((mi_row >> CONFIG_SB8X8) & 3);
// Distance of Mb to the various image edges. These are specified to 8th pel
// as they are always compared to values that are in 1/8th pel units
- set_mb_row_col(cm, xd, mb_row, bh, mb_col, bw);
+ set_mi_row_col(cm, xd, mi_row, bh, mi_col, bw);
xd->plane[0].dst.buf = dst_fb->y_buffer + recon_yoffset;
xd->plane[1].dst.buf = dst_fb->u_buffer + recon_uvoffset;
xd->plane[2].dst.buf = dst_fb->v_buffer + recon_uvoffset;
}
-static void set_refs(VP9D_COMP *pbi, int mb_row, int mb_col) {
+static void set_refs(VP9D_COMP *pbi, int mi_row, int mi_col) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi;
const YV12_BUFFER_CONFIG *cfg = &cm->yv12_fb[fb_idx];
xd->scale_factor[0] = cm->active_ref_scale[mbmi->ref_frame - 1];
xd->scale_factor_uv[0] = cm->active_ref_scale[mbmi->ref_frame - 1];
- setup_pre_planes(xd, cfg, NULL, mb_row, mb_col,
+ setup_pre_planes(xd, cfg, NULL, mi_row, mi_col,
xd->scale_factor, xd->scale_factor_uv);
xd->corrupted |= cfg->corrupted;
const YV12_BUFFER_CONFIG *second_cfg = &cm->yv12_fb[second_fb_idx];
xd->scale_factor[1] = cm->active_ref_scale[mbmi->second_ref_frame - 1];
xd->scale_factor_uv[1] = cm->active_ref_scale[mbmi->second_ref_frame - 1];
- setup_pre_planes(xd, NULL, second_cfg, mb_row, mb_col,
+ setup_pre_planes(xd, NULL, second_cfg, mi_row, mi_col,
xd->scale_factor, xd->scale_factor_uv);
xd->corrupted |= second_cfg->corrupted;
}
}
}
-static void decode_modes_b(VP9D_COMP *pbi, int mb_row, int mb_col,
+static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col,
vp9_reader *r, BLOCK_SIZE_TYPE bsize) {
MACROBLOCKD *const xd = &pbi->mb;
- set_offsets(pbi, bsize, mb_row, mb_col);
- vp9_decode_mb_mode_mv(pbi, xd, mb_row, mb_col, r);
- set_refs(pbi, mb_row, mb_col);
+ set_offsets(pbi, bsize, mi_row, mi_col);
+ vp9_decode_mb_mode_mv(pbi, xd, mi_row, mi_col, r);
+ set_refs(pbi, mi_row, mi_col);
// TODO(jingning): merge decode_sb_ and decode_mb_
if (bsize > BLOCK_SIZE_MB16X16)
- decode_sb(pbi, xd, mb_row, mb_col, r, bsize);
+ decode_sb(pbi, xd, mi_row, mi_col, r, bsize);
else
- decode_mb(pbi, xd, mb_row, mb_col, r);
+ decode_mb(pbi, xd, mi_row, mi_col, r);
xd->corrupted |= vp9_reader_has_error(r);
}
-static void decode_modes_sb(VP9D_COMP *pbi, int mb_row, int mb_col,
+static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col,
vp9_reader* r, BLOCK_SIZE_TYPE bsize) {
VP9_COMMON *const pc = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
- int bsl = mb_width_log2(bsize), bs = (1 << bsl) / 2;
+ int bsl = mi_width_log2(bsize), bs = (1 << bsl) / 2;
int n;
PARTITION_TYPE partition = PARTITION_NONE;
BLOCK_SIZE_TYPE subsize;
- if (mb_row >= pc->mb_rows || mb_col >= pc->mb_cols)
+ if (mi_row >= pc->mi_rows || mi_col >= pc->mi_cols)
return;
if (bsize > BLOCK_SIZE_MB16X16) {
int pl;
// read the partition information
- xd->left_seg_context = pc->left_seg_context + (mb_row & 3);
- xd->above_seg_context = pc->above_seg_context + mb_col;
+ xd->left_seg_context =
+ pc->left_seg_context + ((mi_row >> CONFIG_SB8X8) & 3);
+ xd->above_seg_context = pc->above_seg_context + (mi_col >> CONFIG_SB8X8);
pl = partition_plane_context(xd, bsize);
partition = treed_read(r, vp9_partition_tree,
pc->fc.partition_prob[pl]);
switch (partition) {
case PARTITION_NONE:
subsize = bsize;
- decode_modes_b(pbi, mb_row, mb_col, r, subsize);
+ decode_modes_b(pbi, mi_row, mi_col, r, subsize);
break;
case PARTITION_HORZ:
subsize = (bsize == BLOCK_SIZE_SB64X64) ? BLOCK_SIZE_SB64X32 :
BLOCK_SIZE_SB32X16;
- decode_modes_b(pbi, mb_row, mb_col, r, subsize);
- if ((mb_row + bs) < pc->mb_rows)
- decode_modes_b(pbi, mb_row + bs, mb_col, r, subsize);
+ decode_modes_b(pbi, mi_row, mi_col, r, subsize);
+ if ((mi_row + bs) < pc->mi_rows)
+ decode_modes_b(pbi, mi_row + bs, mi_col, r, subsize);
break;
case PARTITION_VERT:
subsize = (bsize == BLOCK_SIZE_SB64X64) ? BLOCK_SIZE_SB32X64 :
BLOCK_SIZE_SB16X32;
- decode_modes_b(pbi, mb_row, mb_col, r, subsize);
- if ((mb_col + bs) < pc->mb_cols)
- decode_modes_b(pbi, mb_row, mb_col + bs, r, subsize);
+ decode_modes_b(pbi, mi_row, mi_col, r, subsize);
+ if ((mi_col + bs) < pc->mi_cols)
+ decode_modes_b(pbi, mi_row, mi_col + bs, r, subsize);
break;
case PARTITION_SPLIT:
subsize = (bsize == BLOCK_SIZE_SB64X64) ? BLOCK_SIZE_SB32X32 :
xd->sb_index = n;
else
xd->mb_index = n;
- decode_modes_sb(pbi, mb_row + j * bs, mb_col + i * bs, r, subsize);
+ decode_modes_sb(pbi, mi_row + j * bs, mi_col + i * bs, r, subsize);
}
break;
default:
if ((partition == PARTITION_SPLIT) && (bsize > BLOCK_SIZE_SB32X32))
return;
- xd->left_seg_context = pc->left_seg_context + (mb_row & 3);
- xd->above_seg_context = pc->above_seg_context + mb_col;
+ xd->left_seg_context = pc->left_seg_context + ((mi_row >> CONFIG_SB8X8) & 3);
+ xd->above_seg_context = pc->above_seg_context + (mi_col >> CONFIG_SB8X8);
update_partition_context(xd, subsize, bsize);
}
const int height = multiple16(cm->height);
cm->mb_rows = height / 16;
+ cm->mi_rows = height >> LOG2_MI_SIZE;
cm->mb_cols = width / 16;
+ cm->mi_cols = width >> LOG2_MI_SIZE;
cm->MBs = cm->mb_rows * cm->mb_cols;
- cm->mode_info_stride = cm->mb_cols + 1;
+ cm->mode_info_stride = cm->mi_cols + 1;
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_border(cm, cm->prev_mip);
static void decode_tile(VP9D_COMP *pbi, vp9_reader *r) {
VP9_COMMON *const pc = &pbi->common;
- int mb_row, mb_col;
+ int mi_row, mi_col;
- for (mb_row = pc->cur_tile_mb_row_start;
- mb_row < pc->cur_tile_mb_row_end; mb_row += 4) {
+ for (mi_row = pc->cur_tile_mi_row_start;
+ mi_row < pc->cur_tile_mi_row_end; mi_row += (4 << CONFIG_SB8X8)) {
// For a SB there are 2 left contexts, each pertaining to a MB row within
vpx_memset(pc->left_context, 0, sizeof(pc->left_context));
vpx_memset(pc->left_seg_context, 0, sizeof(pc->left_seg_context));
- for (mb_col = pc->cur_tile_mb_col_start;
- mb_col < pc->cur_tile_mb_col_end; mb_col += 4) {
- decode_modes_sb(pbi, mb_row, mb_col, r, BLOCK_SIZE_SB64X64);
+ for (mi_col = pc->cur_tile_mi_col_start;
+ mi_col < pc->cur_tile_mi_col_end; mi_col += (4 << CONFIG_SB8X8)) {
+ decode_modes_sb(pbi, mi_row, mi_col, r, BLOCK_SIZE_SB64X64);
}
}
}
// Create the segmentation map structure and set to 0
if (!pc->last_frame_seg_map)
CHECK_MEM_ERROR(pc->last_frame_seg_map,
- vpx_calloc((pc->mb_rows * pc->mb_cols), 1));
+ vpx_calloc((pc->mi_rows * pc->mi_cols), 1));
// set up frame new frame for intra coded blocks
vp9_setup_intra_recon(new_fb);
}
static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
- vp9_writer *bc,
- int mb_rows_left, int mb_cols_left) {
+ vp9_writer *bc, int mi_row, int mi_col) {
VP9_COMMON *const pc = &cpi->common;
const nmv_context *nmvc = &pc->fc.nmvc;
MACROBLOCK *const x = &cpi->mb;
const MV_REFERENCE_FRAME rf = mi->ref_frame;
const MB_PREDICTION_MODE mode = mi->mode;
const int segment_id = mi->segment_id;
- const int bw = 1 << mb_width_log2(mi->sb_type);
- const int bh = 1 << mb_height_log2(mi->sb_type);
int skip_coeff;
- int mb_row = pc->mb_rows - mb_rows_left;
- int mb_col = pc->mb_cols - mb_cols_left;
xd->prev_mode_info_context = pc->prev_mi + (m - pc->mi);
x->partition_info = x->pi + (m - pc->mi);
- // Distance of Mb to the various image edges.
- // These specified to 8th pel as they are always compared to MV
- // values that are in 1/8th pel units
-
- set_mb_row_col(pc, xd, mb_row, bh, mb_col, bw);
-
#ifdef ENTROPY_STATS
active_section = 9;
#endif
static void write_mb_modes_kf(const VP9_COMP *cpi,
MODE_INFO *m,
- vp9_writer *bc,
- int mb_rows_left, int mb_cols_left) {
+ vp9_writer *bc, int mi_row, int mi_col) {
const VP9_COMMON *const c = &cpi->common;
const MACROBLOCKD *const xd = &cpi->mb.e_mbd;
const int mis = c->mode_info_stride;
static void write_modes_b(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc,
TOKENEXTRA **tok, TOKENEXTRA *tok_end,
- int mb_row, int mb_col) {
+ int mi_row, int mi_col) {
VP9_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &cpi->mb.e_mbd;
xd->mode_info_context = m;
- set_mb_row_col(&cpi->common, xd, mb_row,
- 1 << mb_height_log2(m->mbmi.sb_type),
- mb_col, 1 << mb_width_log2(m->mbmi.sb_type));
+ set_mi_row_col(&cpi->common, xd, mi_row,
+ 1 << mi_height_log2(m->mbmi.sb_type),
+ mi_col, 1 << mi_width_log2(m->mbmi.sb_type));
if (cm->frame_type == KEY_FRAME) {
- write_mb_modes_kf(cpi, m, bc,
- cm->mb_rows - mb_row, cm->mb_cols - mb_col);
+ write_mb_modes_kf(cpi, m, bc, mi_row, mi_col);
#ifdef ENTROPY_STATS
active_section = 8;
#endif
} else {
- pack_inter_mode_mvs(cpi, m, bc,
- cm->mb_rows - mb_row, cm->mb_cols - mb_col);
+ pack_inter_mode_mvs(cpi, m, bc, mi_row, mi_col);
#ifdef ENTROPY_STATS
active_section = 1;
#endif
static void write_modes_sb(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc,
TOKENEXTRA **tok, TOKENEXTRA *tok_end,
- int mb_row, int mb_col,
+ int mi_row, int mi_col,
BLOCK_SIZE_TYPE bsize) {
VP9_COMMON *const cm = &cpi->common;
MACROBLOCKD *xd = &cpi->mb.e_mbd;
const int mis = cm->mode_info_stride;
int bwl, bhl;
int bw, bh;
- int bsl = mb_width_log2(bsize), bs = (1 << bsl) / 2;
+ int bsl = mi_width_log2(bsize), bs = (1 << bsl) / 2;
int n;
PARTITION_TYPE partition;
BLOCK_SIZE_TYPE subsize;
- if (mb_row >= cm->mb_rows || mb_col >= cm->mb_cols)
+ if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols)
return;
- bwl = mb_width_log2(m->mbmi.sb_type);
- bhl = mb_height_log2(m->mbmi.sb_type);
+ bwl = mi_width_log2(m->mbmi.sb_type);
+ bhl = mi_height_log2(m->mbmi.sb_type);
bw = 1 << bwl;
bh = 1 << bhl;
if (bsize > BLOCK_SIZE_MB16X16) {
int pl;
- xd->left_seg_context = cm->left_seg_context + (mb_row & 3);
- xd->above_seg_context = cm->above_seg_context + mb_col;
+ xd->left_seg_context =
+ cm->left_seg_context + ((mi_row >> CONFIG_SB8X8) & 3);
+ xd->above_seg_context = cm->above_seg_context + (mi_col >> CONFIG_SB8X8);
pl = partition_plane_context(xd, bsize);
// encode the partition information
write_token(bc, vp9_partition_tree, cm->fc.partition_prob[pl],
switch (partition) {
case PARTITION_NONE:
subsize = bsize;
- write_modes_b(cpi, m, bc, tok, tok_end, mb_row, mb_col);
+ write_modes_b(cpi, m, bc, tok, tok_end, mi_row, mi_col);
break;
case PARTITION_HORZ:
subsize = (bsize == BLOCK_SIZE_SB64X64) ? BLOCK_SIZE_SB64X32 :
BLOCK_SIZE_SB32X16;
- write_modes_b(cpi, m, bc, tok, tok_end, mb_row, mb_col);
- if ((mb_row + bh) < cm->mb_rows)
- write_modes_b(cpi, m + bh * mis, bc, tok, tok_end, mb_row + bh, mb_col);
+ write_modes_b(cpi, m, bc, tok, tok_end, mi_row, mi_col);
+ if ((mi_row + bh) < cm->mi_rows)
+ write_modes_b(cpi, m + bh * mis, bc, tok, tok_end, mi_row + bh, mi_col);
break;
case PARTITION_VERT:
subsize = (bsize == BLOCK_SIZE_SB64X64) ? BLOCK_SIZE_SB32X64 :
BLOCK_SIZE_SB16X32;
- write_modes_b(cpi, m, bc, tok, tok_end, mb_row, mb_col);
- if ((mb_col + bw) < cm->mb_cols)
- write_modes_b(cpi, m + bw, bc, tok, tok_end, mb_row, mb_col + bw);
+ write_modes_b(cpi, m, bc, tok, tok_end, mi_row, mi_col);
+ if ((mi_col + bw) < cm->mi_cols)
+ write_modes_b(cpi, m + bw, bc, tok, tok_end, mi_row, mi_col + bw);
break;
case PARTITION_SPLIT:
// TODO(jingning): support recursive partitioning down to 16x16 as for
for (n = 0; n < 4; n++) {
int j = n >> 1, i = n & 0x01;
write_modes_sb(cpi, m + j * bs * mis + i * bs, bc, tok, tok_end,
- mb_row + j * bs, mb_col + i * bs, subsize);
+ mi_row + j * bs, mi_col + i * bs, subsize);
}
break;
default:
if ((partition == PARTITION_SPLIT) && (bsize > BLOCK_SIZE_SB32X32))
return;
- xd->left_seg_context = cm->left_seg_context + (mb_row & 3);
- xd->above_seg_context = cm->above_seg_context + mb_col;
+ xd->left_seg_context = cm->left_seg_context + ((mi_row >> CONFIG_SB8X8) & 3);
+ xd->above_seg_context = cm->above_seg_context + (mi_col >> CONFIG_SB8X8);
update_partition_context(xd, subsize, bsize);
}
VP9_COMMON *const c = &cpi->common;
const int mis = c->mode_info_stride;
MODE_INFO *m, *m_ptr = c->mi;
- int mb_row, mb_col;
+ int mi_row, mi_col;
- m_ptr += c->cur_tile_mb_col_start + c->cur_tile_mb_row_start * mis;
+ m_ptr += c->cur_tile_mi_col_start + c->cur_tile_mi_row_start * mis;
vpx_memset(c->above_seg_context, 0, sizeof(PARTITION_CONTEXT) *
- mb_cols_aligned_to_sb(c));
+ mb_cols_aligned_to_sb(c));
- for (mb_row = c->cur_tile_mb_row_start;
- mb_row < c->cur_tile_mb_row_end; mb_row += 4, m_ptr += 4 * mis) {
+ for (mi_row = c->cur_tile_mi_row_start;
+ mi_row < c->cur_tile_mi_row_end;
+ mi_row += (4 << CONFIG_SB8X8), m_ptr += (4 << CONFIG_SB8X8) * mis) {
m = m_ptr;
vpx_memset(c->left_seg_context, 0, sizeof(c->left_seg_context));
- for (mb_col = c->cur_tile_mb_col_start;
- mb_col < c->cur_tile_mb_col_end; mb_col += 4, m += 4)
- write_modes_sb(cpi, m, bc, tok, tok_end, mb_row, mb_col,
+ for (mi_col = c->cur_tile_mi_col_start;
+ mi_col < c->cur_tile_mi_col_end;
+ mi_col += (4 << CONFIG_SB8X8), m += (4 << CONFIG_SB8X8))
+ write_modes_sb(cpi, m, bc, tok, tok_end, mi_row, mi_col,
BLOCK_SIZE_SB64X64);
}
}
void vp9_select_interp_filter_type(VP9_COMP *cpi);
static void encode_macroblock(VP9_COMP *cpi, TOKENEXTRA **t,
- int output_enabled, int mb_row, int mb_col);
+ int output_enabled, int mi_row, int mi_col);
static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t,
- int output_enabled, int mb_row, int mb_col,
+ int output_enabled, int mi_row, int mi_col,
BLOCK_SIZE_TYPE bsize);
static void adjust_act_zbin(VP9_COMP *cpi, MACROBLOCK *x);
int mb_mode = mi->mbmi.mode;
int mb_mode_index = ctx->best_mode_index;
const int mis = cpi->common.mode_info_stride;
- const int bh = 1 << mb_height_log2(bsize), bw = 1 << mb_width_log2(bsize);
+ const int bh = 1 << mi_height_log2(bsize), bw = 1 << mi_width_log2(bsize);
#if CONFIG_DEBUG
assert(mb_mode < MB_MODE_COUNT);
// when the mode was picked for it
for (y = 0; y < bh; y++) {
for (x_idx = 0; x_idx < bw; x_idx++) {
- if ((xd->mb_to_right_edge >> 7) + bw > x_idx &&
- (xd->mb_to_bottom_edge >> 7) + bh > y) {
+ if ((xd->mb_to_right_edge >> (3 + LOG2_MI_SIZE)) + bw > x_idx &&
+ (xd->mb_to_bottom_edge >> (3 + LOG2_MI_SIZE)) + bh > y) {
MODE_INFO *mi_addr = xd->mode_info_context + x_idx + y * mis;
vpx_memcpy(mi_addr, mi, sizeof(MODE_INFO));
mbmi->mv[0].as_int = x->partition_info->bmi[15].mv.as_int;
mbmi->mv[1].as_int = x->partition_info->bmi[15].second_mv.as_int;
+#if CONFIG_SB8X8
+ vpx_memcpy(x->partition_info + mis, &ctx->partition_info,
+ sizeof(PARTITION_INFO));
+ vpx_memcpy(x->partition_info + 1, &ctx->partition_info,
+ sizeof(PARTITION_INFO));
+ vpx_memcpy(x->partition_info + mis + 1, &ctx->partition_info,
+ sizeof(PARTITION_INFO));
+ xd->mode_info_context[1].mbmi =
+ xd->mode_info_context[mis].mbmi =
+ xd->mode_info_context[1 + mis].mbmi = *mbmi;
+#endif
}
x->skip = ctx->skip;
mbmi->best_mv.as_int = best_mv.as_int;
mbmi->best_second_mv.as_int = best_second_mv.as_int;
vp9_update_nmv_count(cpi, x, &best_mv, &best_second_mv);
+#if CONFIG_SB8X8
+ xd->mode_info_context[1].mbmi =
+ xd->mode_info_context[mis].mbmi =
+ xd->mode_info_context[1 + mis].mbmi = *mbmi;
+#endif
}
#if CONFIG_COMP_INTERINTRA_PRED
if (mbmi->mode >= NEARESTMV && mbmi->mode < SPLITMV &&
static unsigned find_seg_id(uint8_t *buf, BLOCK_SIZE_TYPE bsize,
int start_y, int height, int start_x, int width) {
- const int bw = 1 << mb_width_log2(bsize), bh = 1 << mb_height_log2(bsize);
+ const int bw = 1 << mi_width_log2(bsize), bh = 1 << mi_height_log2(bsize);
const int end_x = MIN(start_x + bw, width);
const int end_y = MIN(start_y + bh, height);
int x, y;
}
static void set_offsets(VP9_COMP *cpi,
- int mb_row, int mb_col, BLOCK_SIZE_TYPE bsize) {
+ int mi_row, int mi_col, BLOCK_SIZE_TYPE bsize) {
MACROBLOCK *const x = &cpi->mb;
VP9_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *mbmi;
const int dst_fb_idx = cm->new_fb_idx;
+ const int idx_str = xd->mode_info_stride * mi_row + mi_col;
+ const int bw = 1 << mi_width_log2(bsize), bh = 1 << mi_height_log2(bsize);
+ const int mb_row = mi_row >> CONFIG_SB8X8;
+ const int mb_col = mi_col >> CONFIG_SB8X8;
const int idx_map = mb_row * cm->mb_cols + mb_col;
- const int idx_str = xd->mode_info_stride * mb_row + mb_col;
- const int bw = 1 << mb_width_log2(bsize), bh = 1 << mb_height_log2(bsize);
// entropy context structures
xd->above_context = cm->above_context + mb_col;
xd->prev_mode_info_context = cm->prev_mi + idx_str;
// Set up destination pointers
- setup_dst_planes(xd, &cm->yv12_fb[dst_fb_idx], mb_row, mb_col);
+ setup_dst_planes(xd, &cm->yv12_fb[dst_fb_idx], mi_row, mi_col);
/* Set up limit values for MV components to prevent them from
* extending beyond the UMV borders assuming 16x16 block size */
- x->mv_row_min = -((mb_row * 16) + VP9BORDERINPIXELS - VP9_INTERP_EXTEND);
- x->mv_col_min = -((mb_col * 16) + VP9BORDERINPIXELS - VP9_INTERP_EXTEND);
- x->mv_row_max = ((cm->mb_rows - mb_row) * 16 +
- (VP9BORDERINPIXELS - 16 * bh - VP9_INTERP_EXTEND));
- x->mv_col_max = ((cm->mb_cols - mb_col) * 16 +
- (VP9BORDERINPIXELS - 16 * bw - VP9_INTERP_EXTEND));
+ x->mv_row_min = -((mi_row * MI_SIZE) + VP9BORDERINPIXELS - VP9_INTERP_EXTEND);
+ x->mv_col_min = -((mi_col * MI_SIZE) + VP9BORDERINPIXELS - VP9_INTERP_EXTEND);
+ x->mv_row_max = ((cm->mi_rows - mi_row) * MI_SIZE +
+ (VP9BORDERINPIXELS - MI_SIZE * bh - VP9_INTERP_EXTEND));
+ x->mv_col_max = ((cm->mi_cols - mi_col) * MI_SIZE +
+ (VP9BORDERINPIXELS - MI_SIZE * bw - VP9_INTERP_EXTEND));
// Set up distance of MB to edge of frame in 1/8th pel units
- assert(!(mb_col & (bw - 1)) && !(mb_row & (bh - 1)));
- set_mb_row_col(cm, xd, mb_row, bh, mb_col, bw);
+ assert(!(mi_col & (bw - 1)) && !(mi_row & (bh - 1)));
+ set_mi_row_col(cm, xd, mi_row, bh, mi_col, bw);
/* set up source buffers */
- vp9_setup_src_planes(x, cpi->Source, mb_row, mb_col);
+ vp9_setup_src_planes(x, cpi->Source, mi_row, mi_col);
/* R/D setup */
x->rddiv = cpi->RDDIV;
if (xd->segmentation_enabled) {
if (xd->update_mb_segmentation_map) {
mbmi->segment_id = find_seg_id(cpi->segmentation_map, bsize,
- mb_row, cm->mb_rows, mb_col, cm->mb_cols);
+ mi_row, cm->mi_rows, mi_col, cm->mi_cols);
} else {
mbmi->segment_id = find_seg_id(cm->last_frame_seg_map, bsize,
- mb_row, cm->mb_rows, mb_col, cm->mb_cols);
+ mi_row, cm->mi_rows, mi_col, cm->mi_cols);
}
assert(mbmi->segment_id <= (MAX_MB_SEGMENTS-1));
vp9_mb_init_quantizer(cpi, x);
const int x = mb_col & ~3;
const int p16 = ((mb_row & 1) << 1) + (mb_col & 1);
const int p32 = ((mb_row & 2) << 2) + ((mb_col & 2) << 1);
- const int tile_progress = cm->cur_tile_mb_col_start * cm->mb_rows;
- const int mb_cols = cm->cur_tile_mb_col_end - cm->cur_tile_mb_col_start;
+ const int tile_progress =
+ cm->cur_tile_mi_col_start * cm->mb_rows >> CONFIG_SB8X8;
+ const int mb_cols =
+ (cm->cur_tile_mi_col_end - cm->cur_tile_mi_col_start) >> CONFIG_SB8X8;
cpi->seg0_progress =
((y * mb_cols + x * 4 + p32 + p16 + tile_progress) << 16) / cm->MBs;
}
static int pick_mb_mode(VP9_COMP *cpi,
- int mb_row,
- int mb_col,
+ int mi_row,
+ int mi_col,
TOKENEXTRA **tp,
int *totalrate,
int *totaldist) {
int splitmodes_used = 0;
MB_MODE_INFO *mbmi;
- set_offsets(cpi, mb_row, mb_col, BLOCK_SIZE_MB16X16);
+ set_offsets(cpi, mi_row, mi_col, BLOCK_SIZE_MB16X16);
if (cpi->oxcf.tuning == VP8_TUNE_SSIM)
vp9_activity_masking(cpi, x);
vpx_memcpy(&x->mb_context[xd->sb_index][xd->mb_index].mic,
xd->mode_info_context, sizeof(MODE_INFO));
} else {
- vp9_pick_mode_inter_macroblock(cpi, x, mb_row, mb_col,
+ vp9_pick_mode_inter_macroblock(cpi, x, mi_row, mi_col,
totalrate, totaldist);
splitmodes_used += (mbmi->mode == SPLITMV);
return splitmodes_used;
}
-static void pick_sb_modes(VP9_COMP *cpi, int mb_row, int mb_col,
+static void pick_sb_modes(VP9_COMP *cpi, int mi_row, int mi_col,
TOKENEXTRA **tp, int *totalrate, int *totaldist,
BLOCK_SIZE_TYPE bsize, PICK_MODE_CONTEXT *ctx) {
VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
- set_offsets(cpi, mb_row, mb_col, bsize);
+ set_offsets(cpi, mi_row, mi_col, bsize);
xd->mode_info_context->mbmi.sb_type = bsize;
if (cpi->oxcf.tuning == VP8_TUNE_SSIM)
vp9_activity_masking(cpi, x);
if (cm->frame_type == KEY_FRAME) {
vp9_rd_pick_intra_mode_sb(cpi, x, totalrate, totaldist, bsize, ctx);
} else {
- vp9_rd_pick_inter_mode_sb(cpi, x, mb_row, mb_col, totalrate, totaldist,
+ vp9_rd_pick_inter_mode_sb(cpi, x, mi_row, mi_col, totalrate, totaldist,
bsize, ctx);
}
}
-static void update_stats(VP9_COMP *cpi, int mb_row, int mb_col) {
+static void update_stats(VP9_COMP *cpi, int mi_row, int mi_col) {
VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
}
static void encode_sb(VP9_COMP *cpi,
- int mb_row,
- int mb_col,
+ int mi_row,
+ int mi_col,
int output_enabled,
TOKENEXTRA **tp, BLOCK_SIZE_TYPE is_sb) {
VP9_COMMON *const cm = &cpi->common;
BLOCK_SIZE_TYPE bsize = BLOCK_SIZE_SB32X32;
int pl;
- xd->left_seg_context = cm->left_seg_context + (mb_row & 0x03);
- xd->above_seg_context = cm->above_seg_context + mb_col;
+ xd->left_seg_context =
+ cm->left_seg_context + ((mi_row >> CONFIG_SB8X8) & 0x03);
+ xd->above_seg_context =
+ cm->above_seg_context + (mi_col >> CONFIG_SB8X8);
pl = partition_plane_context(xd, bsize);
if (is_sb == BLOCK_SIZE_SB32X32) {
- set_offsets(cpi, mb_row, mb_col, bsize);
+ set_offsets(cpi, mi_row, mi_col, bsize);
update_state(cpi, &x->sb32_context[xd->sb_index],
bsize, output_enabled);
encode_superblock(cpi, tp,
- output_enabled, mb_row, mb_col, bsize);
+ output_enabled, mi_row, mi_col, bsize);
if (output_enabled) {
- update_stats(cpi, mb_row, mb_col);
+ update_stats(cpi, mi_row, mi_col);
cpi->partition_count[pl][PARTITION_NONE]++;
(*tp)->token = EOSB_TOKEN;
if (output_enabled)
cpi->partition_count[pl][PARTITION_VERT]++;
- for (i = 0; i < 2 && mb_col + i != cm->mb_cols; i++) {
- set_offsets(cpi, mb_row, mb_col + i, BLOCK_SIZE_SB16X32);
+ for (i = 0; i < 2 && mi_col + (i << CONFIG_SB8X8) != cm->mi_cols; i++) {
+ set_offsets(cpi, mi_row, mi_col + (i << CONFIG_SB8X8),
+ BLOCK_SIZE_SB16X32);
update_state(cpi, &x->sb16x32_context[xd->sb_index][i],
BLOCK_SIZE_SB16X32, output_enabled);
encode_superblock(cpi, tp,
- output_enabled, mb_row, mb_col + i, BLOCK_SIZE_SB16X32);
+ output_enabled, mi_row, mi_col + (i << CONFIG_SB8X8),
+ BLOCK_SIZE_SB16X32);
if (output_enabled) {
- update_stats(cpi, mb_row, mb_col + i);
+ update_stats(cpi, mi_row, mi_col + i);
(*tp)->token = EOSB_TOKEN;
(*tp)++;
if (output_enabled)
cpi->partition_count[pl][PARTITION_HORZ]++;
- for (i = 0; i < 2 && mb_row + i != cm->mb_rows; i++) {
- set_offsets(cpi, mb_row + i, mb_col, BLOCK_SIZE_SB32X16);
+ for (i = 0; i < 2 && mi_row + (i << CONFIG_SB8X8) != cm->mi_rows; i++) {
+ set_offsets(cpi, mi_row + (i << CONFIG_SB8X8), mi_col,
+ BLOCK_SIZE_SB32X16);
update_state(cpi, &x->sb32x16_context[xd->sb_index][i],
BLOCK_SIZE_SB32X16, output_enabled);
encode_superblock(cpi, tp,
- output_enabled, mb_row + i, mb_col, BLOCK_SIZE_SB32X16);
+ output_enabled, mi_row + (i << CONFIG_SB8X8), mi_col,
+ BLOCK_SIZE_SB32X16);
if (output_enabled) {
- update_stats(cpi, mb_row + i, mb_col);
+ update_stats(cpi, mi_row + (i << CONFIG_SB8X8), mi_col);
(*tp)->token = EOSB_TOKEN;
(*tp)++;
cpi->partition_count[pl][PARTITION_SPLIT]++;
for (i = 0; i < 4; i++) {
- const int x_idx = i & 1, y_idx = i >> 1;
+ const int x_idx = (i & 1) << CONFIG_SB8X8;
+ const int y_idx = (i >> 1) << CONFIG_SB8X8;
- if ((mb_row + y_idx >= cm->mb_rows) || (mb_col + x_idx >= cm->mb_cols)) {
+ if ((mi_row + y_idx >= cm->mi_rows) || (mi_col + x_idx >= cm->mi_cols)) {
// MB lies outside frame, move on
continue;
}
- set_offsets(cpi, mb_row + y_idx, mb_col + x_idx, BLOCK_SIZE_MB16X16);
+ set_offsets(cpi, mi_row + y_idx, mi_col + x_idx, BLOCK_SIZE_MB16X16);
xd->mb_index = i;
update_state(cpi, &x->mb_context[xd->sb_index][i],
BLOCK_SIZE_MB16X16, output_enabled);
vp9_activity_masking(cpi, x);
encode_macroblock(cpi, tp,
- output_enabled, mb_row + y_idx, mb_col + x_idx);
+ output_enabled, mi_row + y_idx, mi_col + x_idx);
if (output_enabled) {
- update_stats(cpi, mb_row + y_idx, mb_col + x_idx);
+ update_stats(cpi, mi_row + y_idx, mi_col + x_idx);
(*tp)->token = EOSB_TOKEN;
(*tp)++;
}
}
- xd->above_seg_context = cm->above_seg_context + mb_col;
- xd->left_seg_context = cm->left_seg_context + (mb_row & 3);
+ xd->above_seg_context = cm->above_seg_context + (mi_col >> CONFIG_SB8X8);
+ xd->left_seg_context = cm->left_seg_context + ((mi_row >> CONFIG_SB8X8) & 3);
update_partition_context(xd, is_sb, BLOCK_SIZE_SB32X32);
// debug output
}
static void encode_sb64(VP9_COMP *cpi,
- int mb_row,
- int mb_col,
+ int mi_row,
+ int mi_col,
TOKENEXTRA **tp, BLOCK_SIZE_TYPE is_sb[4]) {
VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb;
BLOCK_SIZE_TYPE bsize = BLOCK_SIZE_SB64X64;
int pl;
- xd->left_seg_context = cm->left_seg_context + (mb_row & 3);
- xd->above_seg_context = cm->above_seg_context + mb_col;
+ xd->left_seg_context = cm->left_seg_context + ((mi_row >> CONFIG_SB8X8) & 3);
+ xd->above_seg_context = cm->above_seg_context + (mi_col >> CONFIG_SB8X8);
pl = partition_plane_context(xd, bsize);
if (is_sb[0] == BLOCK_SIZE_SB64X64) {
- set_offsets(cpi, mb_row, mb_col, bsize);
+ set_offsets(cpi, mi_row, mi_col, bsize);
update_state(cpi, &x->sb64_context, bsize, 1);
encode_superblock(cpi, tp,
- 1, mb_row, mb_col, bsize);
- update_stats(cpi, mb_row, mb_col);
+ 1, mi_row, mi_col, bsize);
+ update_stats(cpi, mi_row, mi_col);
(*tp)->token = EOSB_TOKEN;
(*tp)++;
int i;
cpi->partition_count[pl][PARTITION_VERT]++;
- for (i = 0; i < 2 && mb_col + i * 2 != cm->mb_cols; i++) {
- set_offsets(cpi, mb_row, mb_col + i * 2, BLOCK_SIZE_SB32X64);
+ for (i = 0; i < 2 && mi_col + (i * 2 << CONFIG_SB8X8) != cm->mi_cols; i++) {
+ set_offsets(cpi, mi_row, mi_col + (i * 2 << CONFIG_SB8X8),
+ BLOCK_SIZE_SB32X64);
update_state(cpi, &x->sb32x64_context[i], BLOCK_SIZE_SB32X64, 1);
encode_superblock(cpi, tp,
- 1, mb_row, mb_col + i * 2, BLOCK_SIZE_SB32X64);
- update_stats(cpi, mb_row, mb_col + i * 2);
+ 1, mi_row, mi_col + (i * 2 << CONFIG_SB8X8),
+ BLOCK_SIZE_SB32X64);
+ update_stats(cpi, mi_row, mi_col + (i * 2 << CONFIG_SB8X8));
(*tp)->token = EOSB_TOKEN;
(*tp)++;
int i;
cpi->partition_count[pl][PARTITION_HORZ]++;
- for (i = 0; i < 2 && mb_row + i * 2 != cm->mb_rows; i++) {
- set_offsets(cpi, mb_row + i * 2, mb_col, BLOCK_SIZE_SB64X32);
+ for (i = 0; i < 2 && mi_row + (i * 2 << CONFIG_SB8X8) != cm->mi_rows; i++) {
+ set_offsets(cpi, mi_row + (i * 2 << CONFIG_SB8X8), mi_col,
+ BLOCK_SIZE_SB64X32);
update_state(cpi, &x->sb64x32_context[i], BLOCK_SIZE_SB64X32, 1);
encode_superblock(cpi, tp,
- 1, mb_row + i * 2, mb_col, BLOCK_SIZE_SB64X32);
- update_stats(cpi, mb_row + i * 2, mb_col);
+ 1, mi_row + (i * 2 << CONFIG_SB8X8), mi_col,
+ BLOCK_SIZE_SB64X32);
+ update_stats(cpi, mi_row + (i * 2 << CONFIG_SB8X8), mi_col);
(*tp)->token = EOSB_TOKEN;
(*tp)++;
int i;
cpi->partition_count[pl][PARTITION_SPLIT]++;
for (i = 0; i < 4; i++) {
- const int x_idx = i & 1, y_idx = i >> 1;
+ const int x_idx = (i & 1) << (1 + CONFIG_SB8X8);
+ const int y_idx = (i & 2) << CONFIG_SB8X8;
- if (mb_row + y_idx * 2 >= cm->mb_rows ||
- mb_col + x_idx * 2 >= cm->mb_cols) {
+ if (mi_row + y_idx >= cm->mi_rows || mi_col + x_idx >= cm->mi_cols) {
// MB lies outside frame, move on
continue;
}
xd->sb_index = i;
- encode_sb(cpi, mb_row + 2 * y_idx, mb_col + 2 * x_idx, 1, tp,
+ encode_sb(cpi, mi_row + y_idx, mi_col + x_idx, 1, tp,
is_sb[i]);
}
}
if (is_sb[0] > BLOCK_SIZE_SB32X32) {
- xd->above_seg_context = cm->above_seg_context + mb_col;
- xd->left_seg_context = cm->left_seg_context + (mb_row & 3);
+ xd->above_seg_context = cm->above_seg_context + (mi_col >> CONFIG_SB8X8);
+ xd->left_seg_context =
+ cm->left_seg_context + ((mi_row >> CONFIG_SB8X8) & 3);
update_partition_context(xd, is_sb[0], BLOCK_SIZE_SB64X64);
}
}
static void encode_sb_row(VP9_COMP *cpi,
- int mb_row,
+ int mi_row,
TOKENEXTRA **tp,
int *totalrate) {
VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
- int mb_col, pl;
+ int mi_col, pl;
// Initialize the left context for the new SB row
vpx_memset(cm->left_context, 0, sizeof(cm->left_context));
vpx_memset(cm->left_seg_context, 0, sizeof(cm->left_seg_context));
// Code each SB in the row
- for (mb_col = cm->cur_tile_mb_col_start;
- mb_col < cm->cur_tile_mb_col_end; mb_col += 4) {
+ for (mi_col = cm->cur_tile_mi_col_start;
+ mi_col < cm->cur_tile_mi_col_end; mi_col += (4 << CONFIG_SB8X8)) {
int i;
BLOCK_SIZE_TYPE sb_partitioning[4];
int sb64_rate = 0, sb64_dist = 0;
PARTITION_CONTEXT seg_l[4], seg_a[4];
TOKENEXTRA *tp_orig = *tp;
- memcpy(&a, cm->above_context + mb_col, sizeof(a));
+ memcpy(&a, cm->above_context + (mi_col >> CONFIG_SB8X8), sizeof(a));
memcpy(&l, cm->left_context, sizeof(l));
- memcpy(&seg_a, cm->above_seg_context + mb_col, sizeof(seg_a));
+ memcpy(&seg_a, cm->above_seg_context + (mi_col >> CONFIG_SB8X8),
+ sizeof(seg_a));
memcpy(&seg_l, cm->left_seg_context, sizeof(seg_l));
for (i = 0; i < 4; i++) {
- const int x_idx = (i & 1) << 1, y_idx = i & 2;
+ const int x_idx = (i & 1) << (1 + CONFIG_SB8X8);
+ const int y_idx = (i & 2) << CONFIG_SB8X8;
int sb32_rate = 0, sb32_dist = 0;
int splitmodes_used = 0;
int sb32_skip = 0;
int j;
ENTROPY_CONTEXT_PLANES l2[2], a2[2];
- if (mb_row + y_idx >= cm->mb_rows || mb_col + x_idx >= cm->mb_cols)
+ if (mi_row + y_idx >= cm->mi_rows || mi_col + x_idx >= cm->mi_cols)
continue;
xd->sb_index = i;
/* Function should not modify L & A contexts; save and restore on exit */
- vpx_memcpy(l2, cm->left_context + y_idx, sizeof(l2));
- vpx_memcpy(a2, cm->above_context + mb_col + x_idx, sizeof(a2));
+ vpx_memcpy(l2, cm->left_context + (y_idx >> CONFIG_SB8X8), sizeof(l2));
+ vpx_memcpy(a2, cm->above_context + ((mi_col + x_idx) >> CONFIG_SB8X8),
+ sizeof(a2));
/* Encode MBs in raster order within the SB */
sb_partitioning[i] = BLOCK_SIZE_MB16X16;
for (j = 0; j < 4; j++) {
- const int x_idx_m = x_idx + (j & 1), y_idx_m = y_idx + (j >> 1);
+ const int x_idx_m = x_idx + ((j & 1) << CONFIG_SB8X8);
+ const int y_idx_m = y_idx + ((j >> 1) << CONFIG_SB8X8);
int r, d;
- if (mb_row + y_idx_m >= cm->mb_rows ||
- mb_col + x_idx_m >= cm->mb_cols) {
+ if (mi_row + y_idx_m >= cm->mi_rows ||
+ mi_col + x_idx_m >= cm->mi_cols) {
// MB lies outside frame, move on
continue;
}
// Index of the MB in the SB 0..3
xd->mb_index = j;
- splitmodes_used += pick_mb_mode(cpi, mb_row + y_idx_m,
- mb_col + x_idx_m, tp, &r, &d);
+ splitmodes_used += pick_mb_mode(cpi, mi_row + y_idx_m,
+ mi_col + x_idx_m, tp, &r, &d);
sb32_rate += r;
sb32_dist += d;
// Dummy encode, do not do the tokenization
- encode_macroblock(cpi, tp, 0, mb_row + y_idx_m,
- mb_col + x_idx_m);
+#if CONFIG_SB8X8
+ update_state(cpi, &x->mb_context[xd->sb_index][xd->mb_index],
+ BLOCK_SIZE_MB16X16, 0);
+#endif
+ encode_macroblock(cpi, tp, 0, mi_row + y_idx_m,
+ mi_col + x_idx_m);
}
/* Restore L & A coding context to those in place on entry */
- vpx_memcpy(cm->left_context + y_idx, l2, sizeof(l2));
- vpx_memcpy(cm->above_context + mb_col + x_idx, a2, sizeof(a2));
+ vpx_memcpy(cm->left_context + (y_idx >> CONFIG_SB8X8), l2, sizeof(l2));
+ vpx_memcpy(cm->above_context + ((mi_col + x_idx) >> CONFIG_SB8X8), a2,
+ sizeof(a2));
- xd->left_seg_context = cm->left_seg_context + (y_idx & 3);
- xd->above_seg_context = cm->above_seg_context + mb_col + x_idx;
+ xd->left_seg_context = cm->left_seg_context + (y_idx >> CONFIG_SB8X8);
+ xd->above_seg_context =
+ cm->above_seg_context + ((mi_col + x_idx) >> CONFIG_SB8X8);
pl = partition_plane_context(xd, BLOCK_SIZE_SB32X32);
sb32_rate += x->partition_cost[pl][PARTITION_SPLIT];
}
// check 32x16
- if (mb_col + x_idx + 1 < cm->mb_cols) {
+ if (mi_col + x_idx + (2 << CONFIG_SB8X8) <= cm->mi_cols) {
int r, d;
xd->mb_index = 0;
- pick_sb_modes(cpi, mb_row + y_idx, mb_col + x_idx,
+ pick_sb_modes(cpi, mi_row + y_idx, mi_col + x_idx,
tp, &r, &d, BLOCK_SIZE_SB32X16,
&x->sb32x16_context[xd->sb_index][xd->mb_index]);
- if (mb_row + y_idx + 1 < cm->mb_rows) {
+ if (mi_row + y_idx + (1 << CONFIG_SB8X8) < cm->mi_rows) {
int r2, d2;
update_state(cpi, &x->sb32x16_context[xd->sb_index][xd->mb_index],
BLOCK_SIZE_SB32X16, 0);
encode_superblock(cpi, tp,
- 0, mb_row + y_idx, mb_col + x_idx,
+ 0, mi_row + y_idx, mi_col + x_idx,
BLOCK_SIZE_SB32X16);
xd->mb_index = 1;
- pick_sb_modes(cpi, mb_row + y_idx + 1, mb_col + x_idx,
- tp, &r2, &d2, BLOCK_SIZE_SB32X16,
+ pick_sb_modes(cpi, mi_row + y_idx + (1 << CONFIG_SB8X8),
+ mi_col + x_idx, tp, &r2, &d2, BLOCK_SIZE_SB32X16,
&x->sb32x16_context[xd->sb_index][xd->mb_index]);
r += r2;
d += d2;
}
- xd->left_seg_context = cm->left_seg_context + (y_idx & 3);
- xd->above_seg_context = cm->above_seg_context + mb_col + x_idx;
+ xd->left_seg_context = cm->left_seg_context + (y_idx >> CONFIG_SB8X8);
+ xd->above_seg_context =
+ cm->above_seg_context + ((mi_col + x_idx) >> CONFIG_SB8X8);
pl = partition_plane_context(xd, BLOCK_SIZE_SB32X32);
r += x->partition_cost[pl][PARTITION_HORZ];
sb_partitioning[i] = BLOCK_SIZE_SB32X16;
}
- vpx_memcpy(cm->left_context + y_idx, l2, sizeof(l2));
- vpx_memcpy(cm->above_context + mb_col + x_idx, a2, sizeof(a2));
+ vpx_memcpy(cm->left_context + (y_idx >> CONFIG_SB8X8), l2, sizeof(l2));
+ vpx_memcpy(cm->above_context + ((mi_col + x_idx) >> CONFIG_SB8X8), a2,
+ sizeof(a2));
}
// check 16x32
- if (mb_row + y_idx + 1 < cm->mb_rows) {
+ if (mi_row + y_idx + (2 << CONFIG_SB8X8) <= cm->mi_rows) {
int r, d;
xd->mb_index = 0;
- pick_sb_modes(cpi, mb_row + y_idx, mb_col + x_idx,
+ pick_sb_modes(cpi, mi_row + y_idx, mi_col + x_idx,
tp, &r, &d, BLOCK_SIZE_SB16X32,
&x->sb16x32_context[xd->sb_index][xd->mb_index]);
- if (mb_col + x_idx + 1 < cm->mb_cols) {
+ if (mi_col + x_idx + (1 << CONFIG_SB8X8) < cm->mi_cols) {
int r2, d2;
update_state(cpi, &x->sb16x32_context[xd->sb_index][xd->mb_index],
BLOCK_SIZE_SB16X32, 0);
encode_superblock(cpi, tp,
- 0, mb_row + y_idx, mb_col + x_idx,
+ 0, mi_row + y_idx, mi_col + x_idx,
BLOCK_SIZE_SB16X32);
xd->mb_index = 1;
- pick_sb_modes(cpi, mb_row + y_idx, mb_col + x_idx + 1,
+ pick_sb_modes(cpi, mi_row + y_idx,
+ mi_col + x_idx + (1 << CONFIG_SB8X8),
tp, &r2, &d2, BLOCK_SIZE_SB16X32,
&x->sb16x32_context[xd->sb_index][xd->mb_index]);
r += r2;
d += d2;
}
- xd->left_seg_context = cm->left_seg_context + (y_idx & 3);
- xd->above_seg_context = cm->above_seg_context + mb_col + x_idx;
+ xd->left_seg_context =
+ cm->left_seg_context + (y_idx >> CONFIG_SB8X8);
+ xd->above_seg_context =
+ cm->above_seg_context + ((mi_col + x_idx) >> CONFIG_SB8X8);
pl = partition_plane_context(xd, BLOCK_SIZE_SB32X32);
r += x->partition_cost[pl][PARTITION_VERT];
sb_partitioning[i] = BLOCK_SIZE_SB16X32;
}
- vpx_memcpy(cm->left_context + y_idx, l2, sizeof(l2));
- vpx_memcpy(cm->above_context + mb_col + x_idx, a2, sizeof(a2));
+ vpx_memcpy(cm->left_context + (y_idx >> CONFIG_SB8X8), l2, sizeof(l2));
+ vpx_memcpy(cm->above_context + ((mi_col + x_idx) >> CONFIG_SB8X8), a2,
+ sizeof(a2));
}
- if (!sb32_skip && !(mb_col + x_idx + 1 >= cm->mb_cols ||
- mb_row + y_idx + 1 >= cm->mb_rows)) {
+ if (!sb32_skip &&
+ mi_col + x_idx + (2 << CONFIG_SB8X8) <= cm->mi_cols &&
+ mi_row + y_idx + (2 << CONFIG_SB8X8) <= cm->mi_rows) {
int r, d;
/* Pick a mode assuming that it applies to all 4 of the MBs in the SB */
- pick_sb_modes(cpi, mb_row + y_idx, mb_col + x_idx,
+ pick_sb_modes(cpi, mi_row + y_idx, mi_col + x_idx,
tp, &r, &d, BLOCK_SIZE_SB32X32,
&x->sb32_context[xd->sb_index]);
- xd->left_seg_context = cm->left_seg_context + (y_idx & 3);
- xd->above_seg_context = cm->above_seg_context + mb_col + x_idx;
+ xd->left_seg_context = cm->left_seg_context + (y_idx >> CONFIG_SB8X8);
+ xd->above_seg_context =
+ cm->above_seg_context + ((mi_col + x_idx) >> CONFIG_SB8X8);
pl = partition_plane_context(xd, BLOCK_SIZE_SB32X32);
r += x->partition_cost[pl][PARTITION_NONE];
// pixels of the lower level; also, inverting SB/MB order (big->small
// instead of small->big) means we can use as threshold for small, which
// may enable breakouts if RD is not good enough (i.e. faster)
- encode_sb(cpi, mb_row + y_idx, mb_col + x_idx, 0, tp,
+ encode_sb(cpi, mi_row + y_idx, mi_col + x_idx, 0, tp,
sb_partitioning[i]);
}
- memcpy(cm->above_context + mb_col, &a, sizeof(a));
+ memcpy(cm->above_context + (mi_col >> CONFIG_SB8X8), &a, sizeof(a));
memcpy(cm->left_context, &l, sizeof(l));
- memcpy(cm->above_seg_context + mb_col, &seg_a, sizeof(seg_a));
+ memcpy(cm->above_seg_context + (mi_col >> CONFIG_SB8X8), &seg_a,
+ sizeof(seg_a));
memcpy(cm->left_seg_context, &seg_l, sizeof(seg_l));
xd->left_seg_context = cm->left_seg_context;
- xd->above_seg_context = cm->above_seg_context + mb_col;
+ xd->above_seg_context = cm->above_seg_context + (mi_col >> CONFIG_SB8X8);
pl = partition_plane_context(xd, BLOCK_SIZE_SB64X64);
sb64_rate += x->partition_cost[pl][PARTITION_SPLIT];
// check 64x32
- if (mb_col + 3 < cm->mb_cols && !(cm->mb_rows & 1)) {
+ if (mi_col + (4 << CONFIG_SB8X8) <= cm->mi_cols && !(cm->mb_rows & 1)) {
int r, d;
xd->sb_index = 0;
- pick_sb_modes(cpi, mb_row, mb_col,
+ pick_sb_modes(cpi, mi_row, mi_col,
tp, &r, &d, BLOCK_SIZE_SB64X32,
&x->sb64x32_context[xd->sb_index]);
- if (mb_row + 2 != cm->mb_rows) {
+ if (mi_row + (2 << CONFIG_SB8X8) != cm->mi_rows) {
int r2, d2;
update_state(cpi, &x->sb64x32_context[xd->sb_index],
BLOCK_SIZE_SB64X32, 0);
encode_superblock(cpi, tp,
- 0, mb_row, mb_col, BLOCK_SIZE_SB64X32);
+ 0, mi_row, mi_col, BLOCK_SIZE_SB64X32);
xd->sb_index = 1;
- pick_sb_modes(cpi, mb_row + 2, mb_col,
+ pick_sb_modes(cpi, mi_row + (2 << CONFIG_SB8X8), mi_col,
tp, &r2, &d2, BLOCK_SIZE_SB64X32,
&x->sb64x32_context[xd->sb_index]);
r += r2;
}
xd->left_seg_context = cm->left_seg_context;
- xd->above_seg_context = cm->above_seg_context + mb_col;
+ xd->above_seg_context = cm->above_seg_context + (mi_col >> CONFIG_SB8X8);
pl = partition_plane_context(xd, BLOCK_SIZE_SB64X64);
r += x->partition_cost[pl][PARTITION_HORZ];
}
vpx_memcpy(cm->left_context, l, sizeof(l));
- vpx_memcpy(cm->above_context + mb_col, a, sizeof(a));
+ vpx_memcpy(cm->above_context + (mi_col >> CONFIG_SB8X8), a, sizeof(a));
}
// check 32x64
- if (mb_row + 3 < cm->mb_rows && !(cm->mb_cols & 1)) {
+ if (mi_row + (4 << CONFIG_SB8X8) <= cm->mi_rows && !(cm->mb_cols & 1)) {
int r, d;
xd->sb_index = 0;
- pick_sb_modes(cpi, mb_row, mb_col,
+ pick_sb_modes(cpi, mi_row, mi_col,
tp, &r, &d, BLOCK_SIZE_SB32X64,
&x->sb32x64_context[xd->sb_index]);
- if (mb_col + 2 != cm->mb_cols) {
+ if (mi_col + (2 << CONFIG_SB8X8) != cm->mi_cols) {
int r2, d2;
update_state(cpi, &x->sb32x64_context[xd->sb_index],
BLOCK_SIZE_SB32X64, 0);
encode_superblock(cpi, tp,
- 0, mb_row, mb_col, BLOCK_SIZE_SB32X64);
+ 0, mi_row, mi_col, BLOCK_SIZE_SB32X64);
xd->sb_index = 1;
- pick_sb_modes(cpi, mb_row, mb_col + 2,
+ pick_sb_modes(cpi, mi_row, mi_col + (2 << CONFIG_SB8X8),
tp, &r2, &d2, BLOCK_SIZE_SB32X64,
&x->sb32x64_context[xd->sb_index]);
r += r2;
}
xd->left_seg_context = cm->left_seg_context;
- xd->above_seg_context = cm->above_seg_context + mb_col;
+ xd->above_seg_context = cm->above_seg_context + (mi_col >> CONFIG_SB8X8);
pl = partition_plane_context(xd, BLOCK_SIZE_SB64X64);
r += x->partition_cost[pl][PARTITION_VERT];
}
vpx_memcpy(cm->left_context, l, sizeof(l));
- vpx_memcpy(cm->above_context + mb_col, a, sizeof(a));
+ vpx_memcpy(cm->above_context + (mi_col >> CONFIG_SB8X8), a, sizeof(a));
}
- if (!sb64_skip && !(mb_col + 3 >= cm->mb_cols ||
- mb_row + 3 >= cm->mb_rows)) {
+ if (!sb64_skip &&
+ mi_col + (4 << CONFIG_SB8X8) <= cm->mi_cols &&
+ mi_row + (4 << CONFIG_SB8X8) <= cm->mi_rows) {
int r, d;
- pick_sb_modes(cpi, mb_row, mb_col, tp, &r, &d,
+ pick_sb_modes(cpi, mi_row, mi_col, tp, &r, &d,
BLOCK_SIZE_SB64X64, &x->sb64_context);
xd->left_seg_context = cm->left_seg_context;
- xd->above_seg_context = cm->above_seg_context + mb_col;
+ xd->above_seg_context = cm->above_seg_context + (mi_col >> CONFIG_SB8X8);
pl = partition_plane_context(xd, BLOCK_SIZE_SB64X64);
r += x->partition_cost[pl][PARTITION_NONE];
}
assert(tp_orig == *tp);
- encode_sb64(cpi, mb_row, mb_col, tp, sb_partitioning);
+ encode_sb64(cpi, mi_row, mi_col, tp, sb_partitioning);
assert(tp_orig < *tp);
}
}
static void encode_frame_internal(VP9_COMP *cpi) {
- int mb_row;
+ int mi_row;
MACROBLOCK *const x = &cpi->mb;
VP9_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &x->e_mbd;
// For each row of SBs in the frame
vp9_get_tile_col_offsets(cm, tile_col);
- for (mb_row = cm->cur_tile_mb_row_start;
- mb_row < cm->cur_tile_mb_row_end; mb_row += 4) {
- encode_sb_row(cpi, mb_row, &tp, &totalrate);
+ for (mi_row = cm->cur_tile_mi_row_start;
+ mi_row < cm->cur_tile_mi_row_end;
+ mi_row += (4 << CONFIG_SB8X8)) {
+ encode_sb_row(cpi, mi_row, &tp, &totalrate);
}
cpi->tok_count[tile_col] = (unsigned int)(tp - tp_old);
assert(tp - cpi->tok <=
static void reset_skip_txfm_size_sb(VP9_COMP *cpi, MODE_INFO *mi,
int mis, TX_SIZE txfm_max,
- int mb_rows_left, int mb_cols_left,
+ int mi_rows_left, int mi_cols_left,
BLOCK_SIZE_TYPE bsize) {
MB_MODE_INFO *const mbmi = &mi->mbmi;
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
const int segment_id = mbmi->segment_id;
- const int bh = 1 << mb_height_log2(bsize), bw = 1 << mb_width_log2(bsize);
- const int ymbs = MIN(bh, mb_rows_left);
- const int xmbs = MIN(bw, mb_cols_left);
+ const int bh = 1 << mi_height_log2(bsize), bw = 1 << mi_width_log2(bsize);
+ const int ymbs = MIN(bh, mi_rows_left);
+ const int xmbs = MIN(bw, mi_cols_left);
xd->mode_info_context = mi;
assert(vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP) ||
static void reset_skip_txfm_size(VP9_COMP *cpi, TX_SIZE txfm_max) {
VP9_COMMON *const cm = &cpi->common;
- int mb_row, mb_col;
+ int mi_row, mi_col;
const int mis = cm->mode_info_stride;
MODE_INFO *mi, *mi_ptr = cm->mi;
- for (mb_row = 0; mb_row < cm->mb_rows; mb_row += 4, mi_ptr += 4 * mis) {
+ for (mi_row = 0; mi_row < cm->mi_rows;
+ mi_row += (4 << CONFIG_SB8X8), mi_ptr += (4 << CONFIG_SB8X8) * mis) {
mi = mi_ptr;
- for (mb_col = 0; mb_col < cm->mb_cols; mb_col += 4, mi += 4) {
+ for (mi_col = 0; mi_col < cm->mi_cols;
+ mi_col += (4 << CONFIG_SB8X8), mi += (4 << CONFIG_SB8X8)) {
if (mi->mbmi.sb_type == BLOCK_SIZE_SB64X64) {
reset_skip_txfm_size_sb(cpi, mi, mis, txfm_max,
- cm->mb_rows - mb_row, cm->mb_cols - mb_col,
+ cm->mi_rows - mi_row, cm->mi_cols - mi_col,
BLOCK_SIZE_SB64X64);
} else if (mi->mbmi.sb_type == BLOCK_SIZE_SB64X32) {
reset_skip_txfm_size_sb(cpi, mi, mis, txfm_max,
- cm->mb_rows - mb_row, cm->mb_cols - mb_col,
+ cm->mi_rows - mi_row, cm->mi_cols - mi_col,
BLOCK_SIZE_SB64X32);
- if (mb_row + 2 != cm->mb_rows)
- reset_skip_txfm_size_sb(cpi, mi + 2 * mis, mis, txfm_max,
- cm->mb_rows - mb_row - 2,
- cm->mb_cols - mb_col,
+ if (mi_row + (2 << CONFIG_SB8X8) != cm->mi_rows)
+ reset_skip_txfm_size_sb(cpi, mi + (2 << CONFIG_SB8X8) * mis, mis,
+ txfm_max,
+ cm->mi_rows - mi_row - (2 << CONFIG_SB8X8),
+ cm->mi_cols - mi_col,
BLOCK_SIZE_SB64X32);
} else if (mi->mbmi.sb_type == BLOCK_SIZE_SB32X64) {
reset_skip_txfm_size_sb(cpi, mi, mis, txfm_max,
- cm->mb_rows - mb_row, cm->mb_cols - mb_col,
+ cm->mi_rows - mi_row, cm->mi_cols - mi_col,
BLOCK_SIZE_SB32X64);
- if (mb_col + 2 != cm->mb_cols)
- reset_skip_txfm_size_sb(cpi, mi + 2, mis, txfm_max,
- cm->mb_rows - mb_row,
- cm->mb_cols - mb_col - 2,
+ if (mi_col + (2 << CONFIG_SB8X8) != cm->mi_cols)
+ reset_skip_txfm_size_sb(cpi, mi + (2 << CONFIG_SB8X8), mis, txfm_max,
+ cm->mi_rows - mi_row,
+ cm->mi_cols - mi_col - (2 << CONFIG_SB8X8),
BLOCK_SIZE_SB32X64);
} else {
int i;
for (i = 0; i < 4; i++) {
- const int x_idx_sb = (i & 1) << 1, y_idx_sb = i & 2;
+ const int x_idx_sb = (i & 1) << (1 + CONFIG_SB8X8);
+ const int y_idx_sb = (i & 2) << CONFIG_SB8X8;
MODE_INFO *sb_mi = mi + y_idx_sb * mis + x_idx_sb;
- if (mb_row + y_idx_sb >= cm->mb_rows ||
- mb_col + x_idx_sb >= cm->mb_cols)
+ if (mi_row + y_idx_sb >= cm->mi_rows ||
+ mi_col + x_idx_sb >= cm->mi_cols)
continue;
if (sb_mi->mbmi.sb_type == BLOCK_SIZE_SB32X32) {
reset_skip_txfm_size_sb(cpi, sb_mi, mis, txfm_max,
- cm->mb_rows - mb_row - y_idx_sb,
- cm->mb_cols - mb_col - x_idx_sb,
+ cm->mi_rows - mi_row - y_idx_sb,
+ cm->mi_cols - mi_col - x_idx_sb,
BLOCK_SIZE_SB32X32);
} else if (sb_mi->mbmi.sb_type == BLOCK_SIZE_SB32X16) {
reset_skip_txfm_size_sb(cpi, sb_mi, mis, txfm_max,
- cm->mb_rows - mb_row - y_idx_sb,
- cm->mb_cols - mb_col - x_idx_sb,
+ cm->mi_rows - mi_row - y_idx_sb,
+ cm->mi_cols - mi_col - x_idx_sb,
BLOCK_SIZE_SB32X16);
- if (mb_row + y_idx_sb + 1 != cm->mb_rows)
- reset_skip_txfm_size_sb(cpi, sb_mi + mis, mis, txfm_max,
- cm->mb_rows - mb_row - y_idx_sb - 1,
- cm->mb_cols - mb_col - x_idx_sb,
+ if (mi_row + y_idx_sb + (1 << CONFIG_SB8X8) != cm->mi_rows)
+ reset_skip_txfm_size_sb(cpi, sb_mi + (mis << CONFIG_SB8X8), mis,
+ txfm_max,
+ cm->mi_rows - mi_row - y_idx_sb -
+ (1 << CONFIG_SB8X8),
+ cm->mi_cols - mi_col - x_idx_sb,
BLOCK_SIZE_SB32X16);
} else if (sb_mi->mbmi.sb_type == BLOCK_SIZE_SB16X32) {
reset_skip_txfm_size_sb(cpi, sb_mi, mis, txfm_max,
- cm->mb_rows - mb_row - y_idx_sb,
- cm->mb_cols - mb_col - x_idx_sb,
+ cm->mi_rows - mi_row - y_idx_sb,
+ cm->mi_cols - mi_col - x_idx_sb,
BLOCK_SIZE_SB16X32);
- if (mb_col + x_idx_sb + 1 != cm->mb_cols)
- reset_skip_txfm_size_sb(cpi, sb_mi + 1, mis, txfm_max,
- cm->mb_rows - mb_row - y_idx_sb,
- cm->mb_cols - mb_col - x_idx_sb - 1,
+ if (mi_col + x_idx_sb + (1 << CONFIG_SB8X8) != cm->mi_cols)
+ reset_skip_txfm_size_sb(cpi, sb_mi + (1 << CONFIG_SB8X8), mis,
+ txfm_max,
+ cm->mi_rows - mi_row - y_idx_sb,
+ cm->mi_cols - mi_col - x_idx_sb -
+ (1 << CONFIG_SB8X8),
BLOCK_SIZE_SB16X32);
} else {
int m;
for (m = 0; m < 4; m++) {
- const int x_idx = x_idx_sb + (m & 1), y_idx = y_idx_sb + (m >> 1);
+ const int x_idx = x_idx_sb + ((m & 1) << CONFIG_SB8X8);
+ const int y_idx = y_idx_sb + ((m >> 1) << CONFIG_SB8X8);
MODE_INFO *mb_mi;
- if (mb_col + x_idx >= cm->mb_cols ||
- mb_row + y_idx >= cm->mb_rows)
+ if (mi_col + x_idx >= cm->mi_cols ||
+ mi_row + y_idx >= cm->mi_rows)
continue;
mb_mi = mi + y_idx * mis + x_idx;
assert(mb_mi->mbmi.sb_type == BLOCK_SIZE_MB16X16);
reset_skip_txfm_size_sb(cpi, mb_mi, mis, txfm_max,
- cm->mb_rows - mb_row - y_idx,
- cm->mb_cols - mb_col - x_idx,
+ cm->mi_rows - mi_row - y_idx,
+ cm->mi_cols - mi_col - x_idx,
BLOCK_SIZE_MB16X16);
}
}
static void encode_macroblock(VP9_COMP *cpi, TOKENEXTRA **t,
int output_enabled,
- int mb_row, int mb_col) {
+ int mi_row, int mi_col) {
VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
MODE_INFO *mi = xd->mode_info_context;
MB_MODE_INFO *const mbmi = &mi->mbmi;
const int mis = cm->mode_info_stride;
+#if CONFIG_SB8X8
+ int n;
+#endif
assert(xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_MB16X16);
&cpi->common.yv12_fb[ref_fb_idx],
mbmi->second_ref_frame > 0 ? &cpi->common.yv12_fb[second_ref_fb_idx]
: NULL,
- mb_row, mb_col, xd->scale_factor, xd->scale_factor_uv);
+ mi_row, mi_col, xd->scale_factor, xd->scale_factor_uv);
if (!x->skip) {
- vp9_encode_inter16x16(cm, x, mb_row, mb_col);
+ vp9_encode_inter16x16(cm, x, mi_row, mi_col);
} else {
- vp9_build_inter_predictors_sb(xd, mb_row, mb_col, BLOCK_SIZE_MB16X16);
+ vp9_build_inter_predictors_sb(xd, mi_row, mi_col, BLOCK_SIZE_MB16X16);
#if CONFIG_COMP_INTERINTRA_PRED
if (xd->mode_info_context->mbmi.second_ref_frame == INTRA_FRAME) {
vp9_build_interintra_predictors(xd,
vp9_reset_sb_tokens_context(xd, BLOCK_SIZE_MB16X16);
}
+#if CONFIG_SB8X8
+ // copy skip flag on all mb_mode_info contexts in this SB
+ // if this was a skip at this txfm size
+ for (n = 1; n < 4; n++) {
+ const int x_idx = n & 1, y_idx = n >> 1;
+ if (mi_col + x_idx < cm->mi_cols && mi_row + y_idx < cm->mi_rows)
+ mi[x_idx + y_idx * mis].mbmi.mb_skip_coeff = mi->mbmi.mb_skip_coeff;
+ }
+#endif
+
if (output_enabled) {
int segment_id = mbmi->segment_id;
if (cpi->common.txfm_mode == TX_MODE_SELECT &&
mbmi->partitioning != PARTITIONING_4X4)) {
cpi->txfm_count_8x8p[mbmi->txfm_size]++;
}
- } else if (mbmi->mode != I4X4_PRED && mbmi->mode != I8X8_PRED &&
- mbmi->mode != SPLITMV && cpi->common.txfm_mode >= ALLOW_16X16) {
- mbmi->txfm_size = TX_16X16;
- } else if (mbmi->mode != I4X4_PRED &&
- !(mbmi->mode == SPLITMV &&
- mbmi->partitioning == PARTITIONING_4X4) &&
- cpi->common.txfm_mode >= ALLOW_8X8) {
- mbmi->txfm_size = TX_8X8;
} else {
- mbmi->txfm_size = TX_4X4;
+#if CONFIG_SB8X8
+ int y, x;
+#endif
+
+ if (mbmi->mode != I4X4_PRED && mbmi->mode != I8X8_PRED &&
+ mbmi->mode != SPLITMV && cpi->common.txfm_mode >= ALLOW_16X16) {
+ mbmi->txfm_size = TX_16X16;
+ } else if (mbmi->mode != I4X4_PRED &&
+ !(mbmi->mode == SPLITMV &&
+ mbmi->partitioning == PARTITIONING_4X4) &&
+ cpi->common.txfm_mode >= ALLOW_8X8) {
+ mbmi->txfm_size = TX_8X8;
+ } else {
+ mbmi->txfm_size = TX_4X4;
+ }
+
+#if CONFIG_SB8X8
+ for (y = 0; y < 2; y++) {
+ for (x = !y; x < 2; x++) {
+ if (mi_col + x < cm->mi_cols && mi_row + y < cm->mi_rows) {
+ mi[mis * y + x].mbmi.txfm_size = mbmi->txfm_size;
+ }
+ }
+ }
+#endif
}
}
}
static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t,
- int output_enabled, int mb_row, int mb_col,
+ int output_enabled, int mi_row, int mi_col,
BLOCK_SIZE_TYPE bsize) {
VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb;
MODE_INFO *mi = x->e_mbd.mode_info_context;
unsigned int segment_id = mi->mbmi.segment_id;
const int mis = cm->mode_info_stride;
- const int bwl = mb_width_log2(bsize);
- const int bw = 1 << bwl, bh = 1 << mb_height_log2(bsize);
+ const int bwl = mi_width_log2(bsize);
+ const int bw = 1 << bwl, bh = 1 << mi_height_log2(bsize);
if (cm->frame_type == KEY_FRAME) {
if (cpi->oxcf.tuning == VP8_TUNE_SSIM) {
&cpi->common.yv12_fb[ref_fb_idx],
xd->mode_info_context->mbmi.second_ref_frame > 0
? &cpi->common.yv12_fb[second_ref_fb_idx] : NULL,
- mb_row, mb_col, xd->scale_factor, xd->scale_factor_uv);
+ mi_row, mi_col, xd->scale_factor, xd->scale_factor_uv);
- vp9_build_inter_predictors_sb(xd, mb_row, mb_col, bsize);
+ vp9_build_inter_predictors_sb(xd, mi_row, mi_col, bsize);
}
if (!x->skip) {
// if this was a skip at this txfm size
for (n = 1; n < bw * bh; n++) {
const int x_idx = n & (bw - 1), y_idx = n >> bwl;
- if (mb_col + x_idx < cm->mb_cols && mb_row + y_idx < cm->mb_rows)
+ if (mi_col + x_idx < cm->mi_cols && mi_row + y_idx < cm->mi_rows)
mi[x_idx + y_idx * mis].mbmi.mb_skip_coeff = mi->mbmi.mb_skip_coeff;
}
for (y = 0; y < bh; y++) {
for (x = 0; x < bw; x++) {
- if (mb_col + x < cm->mb_cols && mb_row + y < cm->mb_rows) {
+ if (mi_col + x < cm->mi_cols && mi_row + y < cm->mi_rows) {
mi[mis * y + x].mbmi.txfm_size = sz;
}
}
}
void vp9_encode_inter16x16(VP9_COMMON *const cm, MACROBLOCK *x,
- int mb_row, int mb_col) {
+ int mi_row, int mi_col) {
MACROBLOCKD *const xd = &x->e_mbd;
- vp9_build_inter_predictors_sb(xd, mb_row, mb_col, BLOCK_SIZE_MB16X16);
+ vp9_build_inter_predictors_sb(xd, mi_row, mi_col, BLOCK_SIZE_MB16X16);
vp9_subtract_sb(x, BLOCK_SIZE_MB16X16);
vp9_fidct_mb(cm, x);
vp9_recon_sb(xd, BLOCK_SIZE_MB16X16);
}
/* this function is used by first pass only */
-void vp9_encode_inter16x16y(MACROBLOCK *x, int mb_row, int mb_col) {
+void vp9_encode_inter16x16y(MACROBLOCK *x, int mi_row, int mi_col) {
MACROBLOCKD *xd = &x->e_mbd;
- vp9_build_inter_predictors_sby(xd, mb_row, mb_col, BLOCK_SIZE_MB16X16);
+ vp9_build_inter_predictors_sby(xd, mi_row, mi_col, BLOCK_SIZE_MB16X16);
vp9_subtract_sby(x, BLOCK_SIZE_MB16X16);
vp9_transform_sby_4x4(x, BLOCK_SIZE_MB16X16);
int gf_motion_error = INT_MAX;
int use_dc_pred = (mb_col || mb_row) && (!mb_col || !mb_row);
- set_mb_row_col(cm, xd,
- mb_row, 1 << mb_height_log2(BLOCK_SIZE_MB16X16),
- mb_col, 1 << mb_height_log2(BLOCK_SIZE_MB16X16));
+ set_mi_row_col(cm, xd,
+ mb_row << CONFIG_SB8X8,
+ 1 << mi_height_log2(BLOCK_SIZE_MB16X16),
+ mb_col << CONFIG_SB8X8,
+ 1 << mi_height_log2(BLOCK_SIZE_MB16X16));
+
xd->plane[0].dst.buf = new_yv12->y_buffer + recon_yoffset;
xd->plane[1].dst.buf = new_yv12->u_buffer + recon_uvoffset;
xd->plane[2].dst.buf = new_yv12->v_buffer + recon_uvoffset;
// goes in segment 0
if (arf_not_zz[offset + mb_col]) {
ncnt[0]++;
+#if CONFIG_SB8X8
+ cpi->segmentation_map[offset * 4 + 2 * mb_col] = 0;
+ cpi->segmentation_map[offset * 4 + 2 * mb_col + 1] = 0;
+ cpi->segmentation_map[offset * 4 + 2 * mb_col + cm->mi_cols] = 0;
+ cpi->segmentation_map[offset * 4 + 2 * mb_col + cm->mi_cols + 1] = 0;
+ } else {
+ cpi->segmentation_map[offset * 4 + 2 * mb_col] = 1;
+ cpi->segmentation_map[offset * 4 + 2 * mb_col + 1] = 1;
+ cpi->segmentation_map[offset * 4 + 2 * mb_col + cm->mi_cols] = 1;
+ cpi->segmentation_map[offset * 4 + 2 * mb_col + cm->mi_cols + 1] = 1;
+#else
cpi->segmentation_map[offset + mb_col] = 0;
} else {
- ncnt[1]++;
cpi->segmentation_map[offset + mb_col] = 1;
+#endif
+ ncnt[1]++;
}
}
}
// Disable and clear down for KF
if (cm->frame_type == KEY_FRAME) {
// Clear down the global segmentation map
- vpx_memset(cpi->segmentation_map, 0, (cm->mb_rows * cm->mb_cols));
+ vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols);
xd->update_mb_segmentation_map = 0;
xd->update_mb_segmentation_data = 0;
#if CONFIG_IMPLICIT_SEGMENTATION
} else if (cpi->refresh_alt_ref_frame) {
// If this is an alt ref frame
// Clear down the global segmentation map
- vpx_memset(cpi->segmentation_map, 0, (cm->mb_rows * cm->mb_cols));
+ vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols);
xd->update_mb_segmentation_map = 0;
xd->update_mb_segmentation_data = 0;
#if CONFIG_IMPLICIT_SEGMENTATION
else {
vp9_disable_segmentation((VP9_PTR)cpi);
- vpx_memset(cpi->segmentation_map, 0,
- (cm->mb_rows * cm->mb_cols));
+ vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols);
xd->update_mb_segmentation_map = 0;
xd->update_mb_segmentation_data = 0;
fprintf(statsfile, "%10d\n", cm->current_video_frame);
- for (row = 0; row < cpi->common.mb_rows; row++) {
- for (col = 0; col < cpi->common.mb_cols; col++) {
+ for (row = 0; row < cpi->common.mi_rows; row++) {
+ for (col = 0; col < cpi->common.mi_cols; col++) {
fprintf(statsfile, "%10d", cpi->segmentation_map[map_index]);
map_index++;
}
MODE_INFO *mi, *mi_ptr = cm->mi;
uint8_t *cache_ptr = cm->last_frame_seg_map, *cache;
- for (row = 0; row < cm->mb_rows; row++) {
+ for (row = 0; row < cm->mi_rows; row++) {
mi = mi_ptr;
cache = cache_ptr;
- for (col = 0; col < cm->mb_cols; col++, mi++, cache++)
+ for (col = 0; col < cm->mi_cols; col++, mi++, cache++)
cache[0] = mi->mbmi.segment_id;
mi_ptr += cm->mode_info_stride;
- cache_ptr += cm->mb_cols;
+ cache_ptr += cm->mi_cols;
}
}
vpx_free(cpi->mb.pip);
cpi->mb.pip = vpx_calloc((cpi->common.mode_info_stride) *
- (cpi->common.mb_rows + 1),
+ (cpi->common.mi_rows + 1),
sizeof(PARTITION_INFO));
if (!cpi->mb.pip)
return 1;
const int aligned_height = multiple16(cm->height);
cm->mb_rows = aligned_height >> 4;
+ cm->mi_rows = aligned_height >> LOG2_MI_SIZE;
cm->mb_cols = aligned_width >> 4;
+ cm->mi_cols = aligned_width >> LOG2_MI_SIZE;
cm->MBs = cm->mb_rows * cm->mb_cols;
- cm->mode_info_stride = cm->mb_cols + 1;
+ cm->mode_info_stride = cm->mi_cols + 1;
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);
cm->mi = cm->mip + cm->mode_info_stride + 1;
cpi->gold_is_alt = 0;
// Create the encoder segmentation map and set all entries to 0
- CHECK_MEM_ERROR(cpi->segmentation_map, vpx_calloc((cpi->common.mb_rows * cpi->common.mb_cols), 1));
+ CHECK_MEM_ERROR(cpi->segmentation_map,
+ vpx_calloc(cpi->common.mi_rows * cpi->common.mi_cols, 1));
// And a copy in common for temporal coding
CHECK_MEM_ERROR(cm->last_frame_seg_map,
- vpx_calloc((cpi->common.mb_rows * cpi->common.mb_cols), 1));
+ vpx_calloc(cpi->common.mi_rows * cpi->common.mi_cols, 1));
// And a place holder structure is the coding context
// for use if we want to save and restore it
CHECK_MEM_ERROR(cpi->coding_context.last_frame_seg_map_copy,
- vpx_calloc((cpi->common.mb_rows * cpi->common.mb_cols), 1));
+ vpx_calloc(cpi->common.mi_rows * cpi->common.mi_cols, 1));
CHECK_MEM_ERROR(cpi->active_map, vpx_calloc(cpi->common.mb_rows * cpi->common.mb_cols, 1));
vpx_memset(cpi->active_map, 1, (cpi->common.mb_rows * cpi->common.mb_cols));
vp9_adapt_zpc_probs(&cpi->common);
#endif
}
+
if (cpi->common.frame_type != KEY_FRAME) {
vp9_copy(cpi->common.fc.sb_ymode_counts, cpi->sb_ymode_count);
vp9_copy(cpi->common.fc.ymode_counts, cpi->ymode_count);
if (cm->show_frame) {
vpx_memcpy(cm->prev_mip, cm->mip,
- cm->mode_info_stride * (cm->mb_rows + 1) * sizeof(MODE_INFO));
+ cm->mode_info_stride * (cm->mi_rows + 1) *
+ sizeof(MODE_INFO));
} else {
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));
}
}
vp9_copy(cc->prob_comppred, cm->prob_comppred);
vpx_memcpy(cpi->coding_context.last_frame_seg_map_copy,
- cm->last_frame_seg_map, (cm->mb_rows * cm->mb_cols));
+ cm->last_frame_seg_map, (cm->mi_rows * cm->mi_cols));
vp9_copy(cc->last_ref_lf_deltas, xd->last_ref_lf_deltas);
vp9_copy(cc->last_mode_lf_deltas, xd->last_mode_lf_deltas);
vpx_memcpy(cm->last_frame_seg_map,
cpi->coding_context.last_frame_seg_map_copy,
- (cm->mb_rows * cm->mb_cols));
+ (cm->mi_rows * cm->mi_cols));
vp9_copy(xd->last_ref_lf_deltas, cc->last_ref_lf_deltas);
vp9_copy(xd->last_mode_lf_deltas, cc->last_mode_lf_deltas);
int_mv seg_mvs[MAX_REF_FRAMES - 1],
int_mv *best_ref_mv,
int_mv *second_best_ref_mv,
- int *mvjcost, int *mvcost[2]) {
+ int *mvjcost, int *mvcost[2], VP9_COMP *cpi) {
MACROBLOCKD *const xd = &x->e_mbd;
MODE_INFO *const mic = xd->mode_info_context;
MB_MODE_INFO * mbmi = &mic->mbmi;
rate = labels2mode(x, labels, i, this_mode, &mode_mv[this_mode],
&second_mode_mv[this_mode], seg_mvs[i],
bsi->ref_mv, bsi->second_ref_mv, x->nmvjointcost,
- x->mvcost);
+ x->mvcost, cpi);
// Trap vectors that reach beyond the UMV borders
if (((mode_mv[this_mode].as_mv.row >> 3) < x->mv_row_min) ||
labels2mode(x, labels, i, mode_selected, &mode_mv[mode_selected],
&second_mode_mv[mode_selected], seg_mvs[i],
- bsi->ref_mv, bsi->second_ref_mv, x->nmvjointcost, x->mvcost);
+ bsi->ref_mv, bsi->second_ref_mv, x->nmvjointcost,
+ x->mvcost, cpi);
br += sbr;
bd += sbd;
static void setup_buffer_inter(VP9_COMP *cpi, MACROBLOCK *x,
int idx, MV_REFERENCE_FRAME frame_type,
enum BlockSize block_size,
- int mb_row, int mb_col,
+ int mi_row, int mi_col,
int_mv frame_nearest_mv[MAX_REF_FRAMES],
int_mv frame_near_mv[MAX_REF_FRAMES],
int frame_mdcounts[4][4],
// set up scaling factors
scale[frame_type] = cpi->common.active_ref_scale[frame_type - 1];
scale[frame_type].x_offset_q4 =
- (mb_col * 16 * scale[frame_type].x_num / scale[frame_type].x_den) & 0xf;
+ (mi_col * MI_SIZE * scale[frame_type].x_num /
+ scale[frame_type].x_den) & 0xf;
scale[frame_type].y_offset_q4 =
- (mb_row * 16 * scale[frame_type].y_num / scale[frame_type].y_den) & 0xf;
+ (mi_row * MI_SIZE * scale[frame_type].y_num /
+ scale[frame_type].y_den) & 0xf;
// TODO(jkoleszar): Is the UV buffer ever used here? If so, need to make this
// use the UV scaling factors.
- setup_pred_block(&yv12_mb[frame_type], yv12, mb_row, mb_col,
+ setup_pred_block(&yv12_mb[frame_type], yv12, mi_row, mi_col,
&scale[frame_type], &scale[frame_type]);
// Gets an initial list of candidate vectors from neighbours and orders them
int_mv frame_mv[MB_MODE_COUNT]
[MAX_REF_FRAMES],
YV12_BUFFER_CONFIG *scaled_ref_frame,
- int mb_row, int mb_col) {
- const int bw = 1 << mb_width_log2(bsize), bh = 1 << mb_height_log2(bsize);
+ int mi_row, int mi_col) {
+ const int bw = 1 << mi_width_log2(bsize), bh = 1 << mi_height_log2(bsize);
const enum BlockSize block_size = y_bsizet_to_block_size(bsize);
const enum BlockSize uv_block_size = y_to_uv_block_size(block_size);
VP9_COMMON *cm = &cpi->common;
for (i = 0; i < MAX_MB_PLANE; i++)
backup_yv12[i] = xd->plane[i].pre[0];
- setup_pre_planes(xd, scaled_ref_frame, NULL, mb_row, mb_col,
+ setup_pre_planes(xd, scaled_ref_frame, NULL, mi_row, mi_col,
NULL, NULL);
}
unsigned int sse, var;
int tmp_rate_y, tmp_rate_u, tmp_rate_v;
int tmp_dist_y, tmp_dist_u, tmp_dist_v;
- vp9_build_inter_predictors_sb(xd, mb_row, mb_col, bsize);
+ vp9_build_inter_predictors_sb(xd, mi_row, mi_col, bsize);
var = cpi->fn_ptr[block_size].vf(x->plane[0].src.buf,
x->plane[0].src.stride,
xd->plane[0].dst.buf,
// Note our transform coeffs are 8 times an orthogonal transform.
// Hence quantizer step is also 8 times. To get effective quantizer
// we need to divide by 8 before sending to modeling function.
- model_rd_from_var_lapndz(var, 16 * bw * 16 * bh,
+ model_rd_from_var_lapndz(var, MI_SIZE * bw * MI_SIZE * bh,
xd->plane[0].dequant[1] >> 3,
&tmp_rate_y, &tmp_dist_y);
var = cpi->fn_ptr[uv_block_size].vf(x->plane[1].src.buf,
xd->plane[1].dst.buf,
xd->plane[1].dst.stride,
&sse);
- model_rd_from_var_lapndz(var, 8 * bw * 8 * bh,
+ model_rd_from_var_lapndz(var, MI_UV_SIZE * bw * MI_UV_SIZE * bh,
xd->plane[1].dequant[1] >> 3,
&tmp_rate_u, &tmp_dist_u);
var = cpi->fn_ptr[uv_block_size].vf(x->plane[2].src.buf,
xd->plane[2].dst.buf,
xd->plane[1].dst.stride,
&sse);
- model_rd_from_var_lapndz(var, 8 * bw * 8 * bh,
+ model_rd_from_var_lapndz(var, MI_UV_SIZE * bw * MI_UV_SIZE * bh,
xd->plane[2].dequant[1] >> 3,
&tmp_rate_v, &tmp_dist_v);
rd = RDCOST(x->rdmult, x->rddiv,
(cm->mcomp_filter_type != SWITCHABLE &&
cm->mcomp_filter_type == mbmi->interp_filter)) {
int i;
- for (i = 0; i < 16 * bh; ++i)
- vpx_memcpy(tmp_ybuf + i * 16 * bw,
+ for (i = 0; i < MI_SIZE * bh; ++i)
+ vpx_memcpy(tmp_ybuf + i * MI_SIZE * bw,
xd->plane[0].dst.buf + i * xd->plane[0].dst.stride,
- sizeof(unsigned char) * 16 * bw);
- for (i = 0; i < 8 * bh; ++i)
- vpx_memcpy(tmp_ubuf + i * 8 * bw,
+ sizeof(unsigned char) * MI_SIZE * bw);
+ for (i = 0; i < MI_UV_SIZE * bh; ++i)
+ vpx_memcpy(tmp_ubuf + i * MI_UV_SIZE * bw,
xd->plane[1].dst.buf + i * xd->plane[1].dst.stride,
- sizeof(unsigned char) * 8 * bw);
- for (i = 0; i < 8 * bh; ++i)
- vpx_memcpy(tmp_vbuf + i * 8 * bw,
+ sizeof(unsigned char) * MI_UV_SIZE * bw);
+ for (i = 0; i < MI_UV_SIZE * bh; ++i)
+ vpx_memcpy(tmp_vbuf + i * MI_UV_SIZE * bw,
xd->plane[2].dst.buf + i * xd->plane[1].dst.stride,
- sizeof(unsigned char) * 8 * bw);
+ sizeof(unsigned char) * MI_UV_SIZE * bw);
pred_exists = 1;
}
interpolating_intpel_seen |=
if (pred_exists) {
// FIXME(rbultje): mb code still predicts into xd->predictor
- for (i = 0; i < bh * 16; ++i)
+ for (i = 0; i < bh * MI_SIZE; ++i)
vpx_memcpy(xd->plane[0].dst.buf + i * xd->plane[0].dst.stride,
- tmp_ybuf + i * bw * 16, sizeof(unsigned char) * bw * 16);
- for (i = 0; i < bh * 8; ++i)
+ tmp_ybuf + i * bw * MI_SIZE,
+ sizeof(unsigned char) * bw * MI_SIZE);
+ for (i = 0; i < bh * MI_UV_SIZE; ++i)
vpx_memcpy(xd->plane[1].dst.buf + i * xd->plane[1].dst.stride,
- tmp_ubuf + i * bw * 8, sizeof(unsigned char) * bw * 8);
- for (i = 0; i < bh * 8; ++i)
+ tmp_ubuf + i * bw * MI_UV_SIZE,
+ sizeof(unsigned char) * bw * MI_UV_SIZE);
+ for (i = 0; i < bh * MI_UV_SIZE; ++i)
vpx_memcpy(xd->plane[2].dst.buf + i * xd->plane[1].dst.stride,
- tmp_vbuf + i * bw * 8, sizeof(unsigned char) * bw * 8);
+ tmp_vbuf + i * bw * MI_UV_SIZE,
+ sizeof(unsigned char) * bw * MI_UV_SIZE);
} else {
// Handles the special case when a filter that is not in the
// switchable list (ex. bilinear, 6-tap) is indicated at the frame level
- vp9_build_inter_predictors_sb(xd, mb_row, mb_col, bsize);
+ vp9_build_inter_predictors_sb(xd, mi_row, mi_col, bsize);
}
if (cpi->common.mcomp_filter_type == SWITCHABLE) {
}
static void rd_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
- int mb_row, int mb_col,
+ int mi_row, int mi_col,
int *returnrate, int *returndistortion,
int64_t *returnintra) {
static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG,
if (cpi->ref_frame_flags & VP9_LAST_FLAG) {
setup_buffer_inter(cpi, x, cpi->lst_fb_idx,
- LAST_FRAME, BLOCK_16X16, mb_row, mb_col,
+ LAST_FRAME, BLOCK_16X16, mi_row, mi_col,
frame_mv[NEARESTMV], frame_mv[NEARMV],
frame_mdcounts, yv12_mb, scale_factor);
}
if (cpi->ref_frame_flags & VP9_GOLD_FLAG) {
setup_buffer_inter(cpi, x, cpi->gld_fb_idx,
- GOLDEN_FRAME, BLOCK_16X16, mb_row, mb_col,
+ GOLDEN_FRAME, BLOCK_16X16, mi_row, mi_col,
frame_mv[NEARESTMV], frame_mv[NEARMV],
frame_mdcounts, yv12_mb, scale_factor);
}
if (cpi->ref_frame_flags & VP9_ALT_FLAG) {
setup_buffer_inter(cpi, x, cpi->alt_fb_idx,
- ALTREF_FRAME, BLOCK_16X16, mb_row, mb_col,
+ ALTREF_FRAME, BLOCK_16X16, mi_row, mi_col,
frame_mv[NEARESTMV], frame_mv[NEARMV],
frame_mdcounts, yv12_mb, scale_factor);
}
if (tmp_rd < best_yrd) {
int uv_skippable;
- vp9_build_inter_predictors_sbuv(&x->e_mbd, mb_row, mb_col,
+ vp9_build_inter_predictors_sbuv(&x->e_mbd, mi_row, mi_col,
BLOCK_SIZE_MB16X16);
vp9_subtract_sbuv(x, BLOCK_SIZE_MB16X16);
&rate_uv, &distortion_uv,
&mode_excluded, &disable_skip,
mode_index, &tmp_best_filter, frame_mv,
- scaled_ref_frame, mb_row, mb_col);
+ scaled_ref_frame, mi_row, mi_col);
if (this_rd == INT64_MAX)
continue;
}
}
int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
- int mb_row, int mb_col,
+ int mi_row, int mi_col,
int *returnrate,
int *returndistortion,
BLOCK_SIZE_TYPE bsize,
for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ref_frame++) {
if (cpi->ref_frame_flags & flag_list[ref_frame]) {
setup_buffer_inter(cpi, x, idx_list[ref_frame], ref_frame, block_size,
- mb_row, mb_col, frame_mv[NEARESTMV], frame_mv[NEARMV],
+ mi_row, mi_col, frame_mv[NEARESTMV], frame_mv[NEARMV],
frame_mdcounts, yv12_mb, scale_factor);
}
frame_mv[NEWMV][ref_frame].as_int = INVALID_MV;
&rate_uv, &distortion_uv,
&mode_excluded, &disable_skip,
mode_index, &tmp_best_filter, frame_mv,
- scaled_ref_frame, mb_row, mb_col);
+ scaled_ref_frame, mi_row, mi_col);
if (this_rd == INT64_MAX)
continue;
}
}
void vp9_pick_mode_inter_macroblock(VP9_COMP *cpi, MACROBLOCK *x,
- int mb_row, int mb_col,
+ int mi_row, int mi_col,
int *totalrate, int *totaldist) {
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO * mbmi = &x->e_mbd.mode_info_context->mbmi;
{
int zbin_mode_boost_enabled = cpi->zbin_mode_boost_enabled;
- rd_pick_inter_mode(cpi, x, mb_row, mb_col, &rate,
+ rd_pick_inter_mode(cpi, x, mi_row, mi_col, &rate,
&distortion, &intra_error);
/* restore cpi->zbin_mode_boost_enabled */
PICK_MODE_CONTEXT *ctx);
void vp9_pick_mode_inter_macroblock(VP9_COMP *cpi, MACROBLOCK *x,
- int mb_row, int mb_col,
+ int mi_row, int mi_col,
int *r, int *d);
int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
- int mb_row, int mb_col,
+ int mi_row, int mi_col,
int *r, int *d, BLOCK_SIZE_TYPE bsize,
PICK_MODE_CONTEXT *ctx);
// Copy in the new segmentation map
vpx_memcpy(cpi->segmentation_map, segmentation_map,
- (cpi->common.mb_rows * cpi->common.mb_cols));
+ (cpi->common.mi_rows * cpi->common.mi_cols));
// Signal that the map should be updated.
cpi->mb.e_mbd.update_mb_segmentation_map = 1;
int *no_pred_segcounts,
int (*temporal_predictor_count)[2],
int *t_unpred_seg_counts,
- int bw, int bh, int mb_row, int mb_col) {
+ int bw, int bh, int mi_row, int mi_col) {
VP9_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &cpi->mb.e_mbd;
const int segment_id = mi->mbmi.segment_id;
xd->mode_info_context = mi;
- set_mb_row_col(cm, xd, mb_row, bh, mb_col, bw);
+ set_mi_row_col(cm, xd, mi_row, bh, mi_col, bw);
// Count the number of hits on each segment with no prediction
no_pred_segcounts[segment_id]++;
// Temporal prediction not allowed on key frames
if (cm->frame_type != KEY_FRAME) {
// Test to see if the segment id matches the predicted value.
- const int pred_seg_id = vp9_get_pred_mb_segid(cm, mi->mbmi.sb_type,
- mb_row, mb_col);
+ const int pred_seg_id = vp9_get_pred_mi_segid(cm, mi->mbmi.sb_type,
+ mi_row, mi_col);
const int seg_predicted = (segment_id == pred_seg_id);
// Get the segment id prediction context
int t_pred_cost = INT_MAX;
int i;
- int tile_col, mb_row, mb_col;
+ int tile_col, mi_row, mi_col;
int temporal_predictor_count[PREDICTION_PROBS][2];
int no_pred_segcounts[MAX_MB_SEGMENTS];
for (tile_col = 0; tile_col < cm->tile_columns; tile_col++) {
vp9_get_tile_col_offsets(cm, tile_col);
- mi_ptr = cm->mi + cm->cur_tile_mb_col_start;
- for (mb_row = 0; mb_row < cm->mb_rows; mb_row += 4, mi_ptr += 4 * mis) {
+ mi_ptr = cm->mi + cm->cur_tile_mi_col_start;
+ for (mi_row = 0; mi_row < cm->mi_rows;
+ mi_row += (4 << CONFIG_SB8X8), mi_ptr += (4 << CONFIG_SB8X8) * mis) {
mi = mi_ptr;
- for (mb_col = cm->cur_tile_mb_col_start;
- mb_col < cm->cur_tile_mb_col_end; mb_col += 4, mi += 4) {
+ for (mi_col = cm->cur_tile_mi_col_start;
+ mi_col < cm->cur_tile_mi_col_end;
+ mi_col += (4 << CONFIG_SB8X8), mi += (4 << CONFIG_SB8X8)) {
if (mi->mbmi.sb_type == BLOCK_SIZE_SB64X64) {
count_segs(cpi, mi, no_pred_segcounts, temporal_predictor_count,
- t_unpred_seg_counts, 4, 4, mb_row, mb_col);
+ t_unpred_seg_counts, 4 << CONFIG_SB8X8,
+ 4 << CONFIG_SB8X8, mi_row, mi_col);
} else if (mi->mbmi.sb_type == BLOCK_SIZE_SB64X32) {
count_segs(cpi, mi, no_pred_segcounts, temporal_predictor_count,
- t_unpred_seg_counts, 4, 2, mb_row, mb_col);
- if (mb_row + 2 != cm->mb_rows)
- count_segs(cpi, mi + 2 * mis, no_pred_segcounts,
+ t_unpred_seg_counts, 4 << CONFIG_SB8X8,
+ 2 << CONFIG_SB8X8, mi_row, mi_col);
+ if (mi_row + (2 << CONFIG_SB8X8) != cm->mi_rows)
+ count_segs(cpi, mi + (2 << CONFIG_SB8X8) * mis, no_pred_segcounts,
temporal_predictor_count,
- t_unpred_seg_counts, 4, 2, mb_row + 2, mb_col);
+ t_unpred_seg_counts, 4 << CONFIG_SB8X8,
+ 2 << CONFIG_SB8X8, mi_row + (2 << CONFIG_SB8X8), mi_col);
} else if (mi->mbmi.sb_type == BLOCK_SIZE_SB32X64) {
count_segs(cpi, mi, no_pred_segcounts, temporal_predictor_count,
- t_unpred_seg_counts, 2, 4, mb_row, mb_col);
- if (mb_col + 2 != cm->mb_cols)
- count_segs(cpi, mi + 2, no_pred_segcounts, temporal_predictor_count,
- t_unpred_seg_counts, 2, 4, mb_row, mb_col + 2);
+ t_unpred_seg_counts, 2 << CONFIG_SB8X8,
+ 4 << CONFIG_SB8X8, mi_row, mi_col);
+ if (mi_col + (2 << CONFIG_SB8X8) != cm->mi_cols)
+ count_segs(cpi, mi + (2 << CONFIG_SB8X8), no_pred_segcounts,
+ temporal_predictor_count,
+ t_unpred_seg_counts, 2 << CONFIG_SB8X8,
+ 4 << CONFIG_SB8X8, mi_row, mi_col + (2 << CONFIG_SB8X8));
} else {
for (i = 0; i < 4; i++) {
- int x_idx = (i & 1) << 1, y_idx = i & 2;
+ const int x_idx = (i & 1) << (1 + CONFIG_SB8X8);
+ const int y_idx = (i & 2) << CONFIG_SB8X8;
MODE_INFO *sb_mi = mi + y_idx * mis + x_idx;
- if (mb_col + x_idx >= cm->mb_cols ||
- mb_row + y_idx >= cm->mb_rows) {
+ if (mi_col + x_idx >= cm->mi_cols ||
+ mi_row + y_idx >= cm->mi_rows) {
continue;
}
if (sb_mi->mbmi.sb_type == BLOCK_SIZE_SB32X32) {
count_segs(cpi, sb_mi, no_pred_segcounts,
- temporal_predictor_count, t_unpred_seg_counts, 2, 2,
- mb_row + y_idx, mb_col + x_idx);
+ temporal_predictor_count, t_unpred_seg_counts,
+ 2 << CONFIG_SB8X8, 2 << CONFIG_SB8X8,
+ mi_row + y_idx, mi_col + x_idx);
} else if (sb_mi->mbmi.sb_type == BLOCK_SIZE_SB32X16) {
count_segs(cpi, sb_mi, no_pred_segcounts,
temporal_predictor_count,
- t_unpred_seg_counts, 2, 1,
- mb_row + y_idx, mb_col + x_idx);
- if (mb_row + y_idx + 1 != cm->mb_rows)
- count_segs(cpi, sb_mi + mis, no_pred_segcounts,
- temporal_predictor_count,
- t_unpred_seg_counts, 2, 1,
- mb_row + y_idx + 1, mb_col + x_idx);
+ t_unpred_seg_counts, 2 << CONFIG_SB8X8,
+ 1 << CONFIG_SB8X8,
+ mi_row + y_idx, mi_col + x_idx);
+ if (mi_row + y_idx + (1 << CONFIG_SB8X8) != cm->mi_rows)
+ count_segs(cpi, sb_mi + (mis << CONFIG_SB8X8),
+ no_pred_segcounts, temporal_predictor_count,
+ t_unpred_seg_counts, 2 << CONFIG_SB8X8,
+ 1 << CONFIG_SB8X8,
+ mi_row + y_idx + (1 << CONFIG_SB8X8),
+ mi_col + x_idx);
} else if (sb_mi->mbmi.sb_type == BLOCK_SIZE_SB16X32) {
count_segs(cpi, sb_mi, no_pred_segcounts,
temporal_predictor_count,
- t_unpred_seg_counts, 1, 2,
- mb_row + y_idx, mb_col + x_idx);
- if (mb_col + x_idx + 1 != cm->mb_cols)
- count_segs(cpi, sb_mi + 1, no_pred_segcounts,
+ t_unpred_seg_counts, 1 << CONFIG_SB8X8,
+ 2 << CONFIG_SB8X8,
+ mi_row + y_idx, mi_col + x_idx);
+ if (mi_col + x_idx + (1 << CONFIG_SB8X8) != cm->mi_cols)
+ count_segs(cpi, sb_mi + (1 << CONFIG_SB8X8), no_pred_segcounts,
temporal_predictor_count,
- t_unpred_seg_counts, 1, 2,
- mb_row + y_idx, mb_col + x_idx + 1);
+ t_unpred_seg_counts, 1 << CONFIG_SB8X8,
+ 2 << CONFIG_SB8X8,
+ mi_row + y_idx,
+ mi_col + x_idx + (1 << CONFIG_SB8X8));
} else {
int j;
for (j = 0; j < 4; j++) {
- const int x_idx_mb = x_idx + (j & 1);
- const int y_idx_mb = y_idx + (j >> 1);
+ const int x_idx_mb = x_idx + ((j & 1) << CONFIG_SB8X8);
+ const int y_idx_mb = y_idx + ((j >> 1) << CONFIG_SB8X8);
MODE_INFO *mb_mi = mi + x_idx_mb + y_idx_mb * mis;
- if (mb_col + x_idx_mb >= cm->mb_cols ||
- mb_row + y_idx_mb >= cm->mb_rows) {
+ if (mi_col + x_idx_mb >= cm->mi_cols ||
+ mi_row + y_idx_mb >= cm->mi_rows) {
continue;
}
assert(mb_mi->mbmi.sb_type == BLOCK_SIZE_MB16X16);
count_segs(cpi, mb_mi, no_pred_segcounts,
temporal_predictor_count, t_unpred_seg_counts,
- 1, 1, mb_row + y_idx_mb, mb_col + x_idx_mb);
+ 1 << CONFIG_SB8X8, 1 << CONFIG_SB8X8,
+ mi_row + y_idx_mb, mi_col + x_idx_mb);
}
}
}