Grow MODE_INFO array to use an 8x8 basis.

Change-Id: I087e08e7909a406b71715b8525c104208daa6889
This commit is contained in:
Ronald S. Bultje 2013-04-26 11:57:17 -07:00
Родитель eea1fecd06
Коммит 1a46b30ebe
26 изменённых файлов: 789 добавлений и 619 удалений

Просмотреть файл

@ -27,7 +27,7 @@ void vp9_update_mode_info_border(VP9_COMMON *cpi, MODE_INFO *mi) {
vpx_memset(mi, 0, sizeof(MODE_INFO) * stride);
// Clear left border column
for (i = 1; i < cpi->mb_rows + 1; i++)
for (i = 1; i < cpi->mi_rows + 1; i++)
vpx_memset(&mi[i * stride], 0, sizeof(MODE_INFO));
}
@ -36,9 +36,9 @@ void vp9_update_mode_info_in_image(VP9_COMMON *cpi, MODE_INFO *mi) {
MODE_INFO *ptr;
// For each in image mode_info element set the in image flag to 1
for (i = 0; i < cpi->mb_rows; i++) {
for (i = 0; i < cpi->mi_rows; i++) {
ptr = mi;
for (j = 0; j < cpi->mb_cols; j++) {
for (j = 0; j < cpi->mi_cols; j++) {
ptr->mbmi.mb_in_image = 1;
ptr++; // Next element in the row
}
@ -110,10 +110,13 @@ int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) {
}
oci->mb_rows = aligned_height >> 4;
oci->mi_rows = aligned_height >> LOG2_MI_SIZE;
oci->mb_cols = aligned_width >> 4;
oci->mi_cols = aligned_width >> LOG2_MI_SIZE;
oci->MBs = oci->mb_rows * oci->mb_cols;
oci->mode_info_stride = oci->mb_cols + 1;
oci->mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_INFO));
oci->mode_info_stride = oci->mi_cols + 1;
oci->mip = vpx_calloc(oci->mode_info_stride * (oci->mi_rows + 1),
sizeof(MODE_INFO));
if (!oci->mip) {
vp9_free_frame_buffers(oci);
@ -124,7 +127,8 @@ int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) {
/* allocate memory for last frame MODE_INFO array */
oci->prev_mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_INFO));
oci->prev_mip = vpx_calloc(oci->mode_info_stride * (oci->mi_rows + 1),
sizeof(MODE_INFO));
if (!oci->prev_mip) {
vp9_free_frame_buffers(oci);

Просмотреть файл

@ -205,39 +205,49 @@ typedef enum {
MAX_REF_FRAMES = 4
} MV_REFERENCE_FRAME;
static INLINE int mb_width_log2(BLOCK_SIZE_TYPE sb_type) {
static INLINE int mi_width_log2(BLOCK_SIZE_TYPE sb_type) {
switch (sb_type) {
#if CONFIG_SB8X8
case BLOCK_SIZE_SB8X16:
case BLOCK_SIZE_SB8X8: return 0;
case BLOCK_SIZE_SB16X8:
#endif
case BLOCK_SIZE_MB16X16:
case BLOCK_SIZE_SB16X32: return 0;
case BLOCK_SIZE_SB16X32: return 0 + CONFIG_SB8X8;
case BLOCK_SIZE_SB32X16:
case BLOCK_SIZE_SB32X64:
case BLOCK_SIZE_SB32X32: return 1;
case BLOCK_SIZE_SB32X32: return 1 + CONFIG_SB8X8;
case BLOCK_SIZE_SB64X32:
case BLOCK_SIZE_SB64X64: return 2;
case BLOCK_SIZE_SB64X64: return 2 + CONFIG_SB8X8;
default: assert(0);
}
}
static INLINE int mb_height_log2(BLOCK_SIZE_TYPE sb_type) {
static INLINE int mi_height_log2(BLOCK_SIZE_TYPE sb_type) {
switch (sb_type) {
#if CONFIG_SB8X8
case BLOCK_SIZE_SB16X8:
case BLOCK_SIZE_SB8X8: return 0;
case BLOCK_SIZE_SB8X16:
#endif
case BLOCK_SIZE_MB16X16:
case BLOCK_SIZE_SB32X16: return 0;
case BLOCK_SIZE_SB32X16: return 0 + CONFIG_SB8X8;
case BLOCK_SIZE_SB16X32:
case BLOCK_SIZE_SB64X32:
case BLOCK_SIZE_SB32X32: return 1;
case BLOCK_SIZE_SB32X32: return 1 + CONFIG_SB8X8;
case BLOCK_SIZE_SB32X64:
case BLOCK_SIZE_SB64X64: return 2;
case BLOCK_SIZE_SB64X64: return 2 + CONFIG_SB8X8;
default: assert(0);
}
}
// parse block dimension in the unit of 4x4 blocks
static INLINE int b_width_log2(BLOCK_SIZE_TYPE sb_type) {
return mb_width_log2(sb_type) + 2;
return mi_width_log2(sb_type) + 2 - CONFIG_SB8X8;
}
static INLINE int b_height_log2(BLOCK_SIZE_TYPE sb_type) {
return mb_height_log2(sb_type) + 2;
return mi_height_log2(sb_type) + 2 - CONFIG_SB8X8;
}
typedef struct {
@ -426,10 +436,10 @@ typedef struct macroblockd {
static INLINE void update_partition_context(MACROBLOCKD *xd,
BLOCK_SIZE_TYPE sb_type,
BLOCK_SIZE_TYPE sb_size) {
int bsl = mb_width_log2(sb_size), bs = 1 << bsl;
int bwl = mb_width_log2(sb_type);
int bhl = mb_height_log2(sb_type);
int boffset = mb_width_log2(BLOCK_SIZE_SB64X64) - bsl;
int bsl = mi_width_log2(sb_size) - CONFIG_SB8X8, bs = 1 << bsl;
int bwl = mi_width_log2(sb_type) - CONFIG_SB8X8;
int bhl = mi_height_log2(sb_type) - CONFIG_SB8X8;
int boffset = mi_width_log2(BLOCK_SIZE_SB64X64) - CONFIG_SB8X8 - bsl;
int i;
// skip macroblock partition
if (bsl == 0)
@ -465,11 +475,11 @@ static INLINE void update_partition_context(MACROBLOCKD *xd,
static INLINE int partition_plane_context(MACROBLOCKD *xd,
BLOCK_SIZE_TYPE sb_type) {
int bsl = mb_width_log2(sb_type), bs = 1 << bsl;
int bsl = mi_width_log2(sb_type) - CONFIG_SB8X8, bs = 1 << bsl;
int above = 0, left = 0, i;
int boffset = mb_width_log2(BLOCK_SIZE_SB64X64) - bsl;
int boffset = mi_width_log2(BLOCK_SIZE_SB64X64) - bsl - CONFIG_SB8X8;
assert(mb_width_log2(sb_type) == mb_height_log2(sb_type));
assert(mi_width_log2(sb_type) == mi_height_log2(sb_type));
assert(bsl >= 0);
assert(boffset >= 0);

Просмотреть файл

@ -119,7 +119,8 @@ void vp9_adapt_coef_probs(struct VP9Common *);
static INLINE void vp9_reset_sb_tokens_context(MACROBLOCKD* const xd,
BLOCK_SIZE_TYPE bsize) {
/* Clear entropy contexts */
const int bw = 1 << mb_width_log2(bsize), bh = 1 << mb_height_log2(bsize);
const int bw = 1 << (b_width_log2(bsize) - 2);
const int bh = 1 << (b_height_log2(bsize) - 2);
vpx_memset(xd->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) * bw);
vpx_memset(xd->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) * bh);
}

Просмотреть файл

@ -683,7 +683,7 @@ void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) {
vp9_clearall_segfeatures(xd);
xd->mb_segment_abs_delta = SEGMENT_DELTADATA;
if (cm->last_frame_seg_map)
vpx_memset(cm->last_frame_seg_map, 0, (cm->mb_rows * cm->mb_cols));
vpx_memset(cm->last_frame_seg_map, 0, (cm->mi_rows * cm->mi_cols));
// Reset the mode ref deltas for loop filter
vpx_memset(xd->last_ref_lf_deltas, 0, sizeof(xd->last_ref_lf_deltas));
@ -705,9 +705,9 @@ void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) {
vpx_memcpy(&cm->frame_contexts[i], &cm->fc, sizeof(cm->fc));
vpx_memset(cm->prev_mip, 0,
cm->mode_info_stride * (cm->mb_rows + 1)* sizeof(MODE_INFO));
cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO));
vpx_memset(cm->mip, 0,
cm->mode_info_stride * (cm->mb_rows + 1)* sizeof(MODE_INFO));
cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO));
vp9_update_mode_info_border(cm, cm->mip);
vp9_update_mode_info_in_image(cm, cm->mi);

Просмотреть файл

@ -13,6 +13,15 @@
#include "./vpx_config.h"
#if CONFIG_SB8X8
#define LOG2_MI_SIZE 3
#else
#define LOG2_MI_SIZE 4
#endif
#define MI_SIZE (1 << LOG2_MI_SIZE)
#define MI_UV_SIZE (1 << (LOG2_MI_SIZE - 1))
typedef enum BLOCK_SIZE_TYPE {
#if CONFIG_SB8X8
BLOCK_SIZE_SB8X8,

Просмотреть файл

@ -304,7 +304,7 @@ static void lpf_sb32(VP9_COMMON *cm, const MODE_INFO *mode_info_context,
y_only? 0 : v_ptr,
y_stride, uv_stride, dering);
// process 2nd MB top-right
mi = mode_info_context + 1;
mi = mode_info_context + (1 << CONFIG_SB8X8);
do_left_v = !(wbl >= 3 /* 32x16 or >=32x32 */ && (tx_size >= TX_32X32 ||
sb_mb_lf_skip(mode_info_context, mi)));
do_above_h = (mb_row > 0);
@ -320,7 +320,7 @@ static void lpf_sb32(VP9_COMMON *cm, const MODE_INFO *mode_info_context,
y_stride, uv_stride, dering);
// process 3rd MB bottom-left
mi = mode_info_context + mis;
mi = mode_info_context + (mis << CONFIG_SB8X8);
do_left_v = (mb_col > 0);
do_above_h = !(hbl >= 3 /* 16x32 or >=32x32 */ && (tx_size >= TX_32X32 ||
sb_mb_lf_skip(mode_info_context, mi)));
@ -336,15 +336,15 @@ static void lpf_sb32(VP9_COMMON *cm, const MODE_INFO *mode_info_context,
y_stride, uv_stride, dering);
// process 4th MB bottom right
mi = mode_info_context + mis + 1;
mi = mode_info_context + ((mis + 1) << CONFIG_SB8X8);
do_left_v = !(wbl >= 3 /* 32x16 or >=32x32 */ && (tx_size >= TX_32X32 ||
sb_mb_lf_skip(mi - 1, mi)));
sb_mb_lf_skip(mi - (1 << CONFIG_SB8X8), mi)));
do_above_h = !(hbl >= 3 /* 16x32 or >=32x32 */ && (tx_size >= TX_32X32 ||
sb_mb_lf_skip(mode_info_context + 1, mi)));
sb_mb_lf_skip(mode_info_context + (1 << CONFIG_SB8X8), mi)));
do_left_v_mbuv = (wbl >= 3 /* 32x16 or >=32x32 */ && (tx_size >= TX_16X16 ||
sb_mb_lf_skip(mi - 1, mi)));
sb_mb_lf_skip(mi - (1 << CONFIG_SB8X8), mi)));
do_above_h_mbuv = !(hbl >= 3 /* 16x32 or >=32x32 */ && (tx_size >= TX_16X16 ||
sb_mb_lf_skip(mode_info_context + 1, mi)));
sb_mb_lf_skip(mode_info_context + (1 << CONFIG_SB8X8), mi)));
lpf_mb(cm, mi, do_left_v, do_above_h,
do_left_v_mbuv, do_above_h_mbuv,
y_ptr + 16 * y_stride + 16,
@ -361,16 +361,17 @@ static void lpf_sb64(VP9_COMMON *cm, const MODE_INFO *mode_info_context,
lpf_sb32(cm, mode_info_context, mb_row, mb_col,
y_ptr, u_ptr, v_ptr,
y_stride, uv_stride, y_only, dering);
lpf_sb32(cm, mode_info_context + 2, mb_row, mb_col + 2,
lpf_sb32(cm, mode_info_context + (2 << CONFIG_SB8X8), mb_row, mb_col + 2,
y_ptr + 32, u_ptr + 16, v_ptr + 16,
y_stride, uv_stride, y_only, dering);
lpf_sb32(cm, mode_info_context + cm->mode_info_stride * 2,
lpf_sb32(cm, mode_info_context + cm->mode_info_stride * (2 << CONFIG_SB8X8),
mb_row + 2, mb_col,
y_ptr + 32 * y_stride,
u_ptr + 16 * uv_stride,
v_ptr + 16 * uv_stride,
y_stride, uv_stride, y_only, dering);
lpf_sb32(cm, mode_info_context + cm->mode_info_stride * 2 + 2,
lpf_sb32(cm, mode_info_context + cm->mode_info_stride *
(2 << CONFIG_SB8X8) + (2 << CONFIG_SB8X8),
mb_row + 2, mb_col + 2,
y_ptr + 32 * y_stride + 32,
u_ptr + 16 * uv_stride + 16,
@ -440,14 +441,14 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_ptr += 64;
u_ptr = y_only? 0 : u_ptr + 32;
v_ptr = y_only? 0 : v_ptr + 32;
mode_info_context += 4; // step to next SB64
mode_info_context += 4 << CONFIG_SB8X8; // step to next SB64
}
if (extra_sb32_col) {
// process 2 SB32s in the extra SB32 col
lpf_sb32(cm, mode_info_context, mb_row, mb_col,
y_ptr, u_ptr, v_ptr,
y_stride, uv_stride, y_only, dering);
lpf_sb32(cm, mode_info_context + mis * 2,
lpf_sb32(cm, mode_info_context + mis * (2 << CONFIG_SB8X8),
mb_row + 2, mb_col,
y_ptr + 32 * y_stride,
u_ptr + 16 * uv_stride,
@ -456,7 +457,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_ptr += 32;
u_ptr = y_only? 0 : u_ptr + 16;
v_ptr = y_only? 0 : v_ptr + 16;
mode_info_context += 2; // step to next SB32
mode_info_context += 2 << CONFIG_SB8X8; // step to next SB32
mb_col += 2;
}
if (extra_mb_col) {
@ -474,7 +475,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_only? 0 : v_ptr,
y_stride, uv_stride, dering);
// process 2nd MB
mi = mode_info_context + mis;
mi = mode_info_context + (mis << CONFIG_SB8X8);
do_left_v = (mb_col > 0);
do_above_h = 1;
do_left_v_mbuv = 1;
@ -486,7 +487,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_only ? 0 : (v_ptr + 8 * uv_stride),
y_stride, uv_stride, dering);
// process 3nd MB
mi = mode_info_context + mis * 2;
mi = mode_info_context + (mis << CONFIG_SB8X8) * 2;
do_left_v = (mb_col > 0);
do_above_h = 1;
do_left_v_mbuv = 1;
@ -498,7 +499,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_only ? 0 : (v_ptr + 16 * uv_stride),
y_stride, uv_stride, dering);
// process 4th MB
mi = mode_info_context + mis * 3;
mi = mode_info_context + (mis << CONFIG_SB8X8) * 3;
do_left_v = (mb_col > 0);
do_above_h = 1;
do_left_v_mbuv = 1;
@ -512,7 +513,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_ptr += 16;
u_ptr = y_only? 0 : u_ptr + 8;
v_ptr = y_only? 0 : v_ptr + 8;
mode_info_context++; // step to next MB
mode_info_context += 1 << CONFIG_SB8X8; // step to next MB
}
// move pointers to the begining of next sb64 row
y_ptr += y_stride * 64 - post->y_width;
@ -521,7 +522,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
v_ptr += uv_stride * 32 - post->uv_width;
}
/* skip to next SB64 row */
mode_info_context += mis * 4 - cm->mb_cols;
mode_info_context += mis * (4 << CONFIG_SB8X8) - cm->mi_cols;
}
if (extra_sb32_row) {
const int sb32_cols = sb64_cols * 2 + extra_sb32_col;
@ -532,7 +533,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_ptr += 32;
u_ptr = y_only? 0 : u_ptr + 16;
v_ptr = y_only? 0 : v_ptr + 16;
mode_info_context += 2; // step to next SB32
mode_info_context += 2 << CONFIG_SB8X8; // step to next SB32
}
if (extra_mb_col) {
// process 1st MB
@ -548,7 +549,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_only? NULL : v_ptr,
y_stride, uv_stride, dering);
// process 2nd MB
mi = mode_info_context + mis;
mi = mode_info_context + (mis << CONFIG_SB8X8);
do_left_v = (mb_col > 0);
do_above_h = 1;
do_left_v_mbuv = 1;
@ -562,14 +563,14 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_ptr += 16;
u_ptr = y_only? 0 : u_ptr + 8;
v_ptr = y_only? 0 : v_ptr + 8;
mode_info_context++; /* step to next MB */
mode_info_context += 1 << CONFIG_SB8X8; /* step to next MB */
}
// move pointers to the beginning of next sb64 row
y_ptr += y_stride * 32 - post->y_width;
u_ptr += y_only? 0 : uv_stride * 16 - post->uv_width;
v_ptr += y_only? 0 : uv_stride * 16 - post->uv_width;
// skip to next MB row if exist
mode_info_context += mis * 2 - cm->mb_cols;
mode_info_context += mis * (2 << CONFIG_SB8X8) - cm->mi_cols;
mb_row += 2;
}
if (extra_mb_row) {
@ -588,7 +589,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_ptr += 16;
u_ptr = y_only? 0 : u_ptr + 8;
v_ptr = y_only? 0 : v_ptr + 8;
mode_info_context++; // step to next MB
mode_info_context += 1 << CONFIG_SB8X8; // step to next MB
}
}
}

Просмотреть файл

@ -12,21 +12,37 @@
#define MVREF_NEIGHBOURS 8
#if CONFIG_SB8X8
static int mb_mv_ref_search[MVREF_NEIGHBOURS][2] = {
{0, -1}, {-1, 0}, {-1, -1}, {0, -2},
{-2, 0}, {-1, -2}, {-2, -1}, {-2, -2}
{0, -1}, {-1, 0}, {-1, -1}, {0, -3},
{-3, 0}, {-1, -3}, {-3, -1}, {-3, -3}
};
static int sb_mv_ref_search[MVREF_NEIGHBOURS][2] = {
{0, -1}, {-1, 0}, {1, -1}, {-1, 1},
{-1, -1}, {0, -2}, {-2, 0}, {-1, -2}
{0, -1}, {-1, 0}, {2, -1}, {-1, 2},
{-1, -1}, {0, -3}, {-3, 0}, {-1, -3}
};
static int sb64_mv_ref_search[MVREF_NEIGHBOURS][2] = {
{0, -1}, {-1, 0}, {1, -1}, {-1, 1},
{2, -1}, {-1, 2}, {3, -1}, {-1,-1}
{0, -1}, {-1, 0}, {2, -1}, {-1, 2},
{4, -1}, {-1, 4}, {6, -1}, {-1, -1}
};
#else
static int mb_mv_ref_search[MVREF_NEIGHBOURS][2] = {
{0, -1}, {-1, 0}, {-1, -1}, {0, -2},
{-2, 0}, {-1, -2}, {-2, -1}, {-2, -2}
};
static int sb_mv_ref_search[MVREF_NEIGHBOURS][2] = {
{0, -1}, {-1, 0}, {1, -1}, {-1, 1},
{-1, -1}, {0, -2}, {-2, 0}, {-1, -2}
};
static int sb64_mv_ref_search[MVREF_NEIGHBOURS][2] = {
{0, -1}, {-1, 0}, {1, -1}, {-1, 1},
{2, -1}, {-1, 2}, {3, -1}, {-1, -1}
};
#endif
// clamp_mv_ref
#define MV_BORDER (16 << 3) // Allow 16 pels in 1/8th pel units
@ -160,7 +176,7 @@ void vp9_find_mv_refs(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
int refmv_count = 0;
int split_count = 0;
int (*mv_ref_search)[2];
const int mb_col = (-xd->mb_to_left_edge) >> 7;
const int mi_col = get_mi_col(xd);
// Blank the reference vector lists and other local structures.
vpx_memset(mv_ref_list, 0, sizeof(int_mv) * MAX_MV_REF_CANDIDATES);
vpx_memset(candidate_scores, 0, sizeof(candidate_scores));
@ -176,11 +192,11 @@ void vp9_find_mv_refs(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
// We first scan for candidate vectors that match the current reference frame
// Look at nearest neigbours
for (i = 0; i < 2; ++i) {
const int mb_search_col = mb_col + mv_ref_search[i][0];
const int mi_search_col = mi_col + mv_ref_search[i][0];
if ((mb_search_col >= cm->cur_tile_mb_col_start) &&
(mb_search_col < cm->cur_tile_mb_col_end) &&
((mv_ref_search[i][1] << 7) >= xd->mb_to_top_edge)) {
if ((mi_search_col >= cm->cur_tile_mi_col_start) &&
(mi_search_col < cm->cur_tile_mi_col_end) &&
((mv_ref_search[i][1] << (7 - CONFIG_SB8X8)) >= xd->mb_to_top_edge)) {
candidate_mi = here + mv_ref_search[i][0] +
(mv_ref_search[i][1] * xd->mode_info_stride);
@ -196,11 +212,11 @@ void vp9_find_mv_refs(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
// More distant neigbours
for (i = 2; (i < MVREF_NEIGHBOURS) &&
(refmv_count < MAX_MV_REF_CANDIDATES); ++i) {
const int mb_search_col = mb_col + mv_ref_search[i][0];
const int mi_search_col = mi_col + mv_ref_search[i][0];
if ((mb_search_col >= cm->cur_tile_mb_col_start) &&
(mb_search_col < cm->cur_tile_mb_col_end) &&
((mv_ref_search[i][1] << 7) >= xd->mb_to_top_edge)) {
if ((mi_search_col >= cm->cur_tile_mi_col_start) &&
(mi_search_col < cm->cur_tile_mi_col_end) &&
((mv_ref_search[i][1] << (7 - CONFIG_SB8X8)) >= xd->mb_to_top_edge)) {
candidate_mi = here + mv_ref_search[i][0] +
(mv_ref_search[i][1] * xd->mode_info_stride);
@ -226,11 +242,11 @@ void vp9_find_mv_refs(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
// Look first at spatial neighbours
for (i = 0; (i < MVREF_NEIGHBOURS) &&
(refmv_count < MAX_MV_REF_CANDIDATES); ++i) {
const int mb_search_col = mb_col + mv_ref_search[i][0];
const int mi_search_col = mi_col + mv_ref_search[i][0];
if ((mb_search_col >= cm->cur_tile_mb_col_start) &&
(mb_search_col < cm->cur_tile_mb_col_end) &&
((mv_ref_search[i][1] << 7) >= xd->mb_to_top_edge)) {
if ((mi_search_col >= cm->cur_tile_mi_col_start) &&
(mi_search_col < cm->cur_tile_mi_col_end) &&
((mv_ref_search[i][1] << (7 - CONFIG_SB8X8)) >= xd->mb_to_top_edge)) {
candidate_mi = here + mv_ref_search[i][0] +
(mv_ref_search[i][1] * xd->mode_info_stride);

Просмотреть файл

@ -201,9 +201,12 @@ typedef struct VP9Common {
int last_show_frame;
int frame_flags;
// MBs, mb_rows/cols is in 16-pixel units; mi_rows/cols is in
// MODE_INFO units (depending on CONFIG_SB8X8, that is either
// 16-pixel or 8-pixel)
int MBs;
int mb_rows;
int mb_cols;
int mb_rows, mi_rows;
int mb_cols, mi_cols;
int mode_info_stride;
/* profile settings */
@ -314,9 +317,9 @@ typedef struct VP9Common {
int frame_parallel_decoding_mode;
int tile_columns, log2_tile_columns;
int cur_tile_mb_col_start, cur_tile_mb_col_end, cur_tile_col_idx;
int cur_tile_mi_col_start, cur_tile_mi_col_end, cur_tile_col_idx;
int tile_rows, log2_tile_rows;
int cur_tile_mb_row_start, cur_tile_mb_row_end, cur_tile_row_idx;
int cur_tile_mi_row_start, cur_tile_mi_row_end, cur_tile_row_idx;
} VP9_COMMON;
static int get_free_fb(VP9_COMMON *cm) {
@ -343,26 +346,26 @@ static int mb_cols_aligned_to_sb(VP9_COMMON *cm) {
return (cm->mb_cols + 3) & ~3;
}
static void set_mb_row_col(VP9_COMMON *cm, MACROBLOCKD *xd,
int mb_row, int bh,
int mb_col, int bw) {
xd->mb_to_top_edge = -((mb_row * 16) << 3);
xd->mb_to_bottom_edge = ((cm->mb_rows - bh - mb_row) * 16) << 3;
xd->mb_to_left_edge = -((mb_col * 16) << 3);
xd->mb_to_right_edge = ((cm->mb_cols - bw - mb_col) * 16) << 3;
static void set_mi_row_col(VP9_COMMON *cm, MACROBLOCKD *xd,
int mi_row, int bh,
int mi_col, int bw) {
xd->mb_to_top_edge = -((mi_row * MI_SIZE) << 3);
xd->mb_to_bottom_edge = ((cm->mi_rows - bh - mi_row) * MI_SIZE) << 3;
xd->mb_to_left_edge = -((mi_col * MI_SIZE) << 3);
xd->mb_to_right_edge = ((cm->mi_cols - bw - mi_col) * MI_SIZE) << 3;
// Are edges available for intra prediction?
xd->up_available = (mb_row != 0);
xd->left_available = (mb_col > cm->cur_tile_mb_col_start);
xd->right_available = (mb_col + bw < cm->cur_tile_mb_col_end);
xd->up_available = (mi_row != 0);
xd->left_available = (mi_col > cm->cur_tile_mi_col_start);
xd->right_available = (mi_col + bw < cm->cur_tile_mi_col_end);
}
static int get_mb_row(const MACROBLOCKD *xd) {
return ((-xd->mb_to_top_edge) >> 7);
static int get_mi_row(const MACROBLOCKD *xd) {
return ((-xd->mb_to_top_edge) >> (3 + LOG2_MI_SIZE));
}
static int get_mb_col(const MACROBLOCKD *xd) {
return ((-xd->mb_to_left_edge) >> 7);
static int get_mi_col(const MACROBLOCKD *xd) {
return ((-xd->mb_to_left_edge) >> (3 + LOG2_MI_SIZE));
}
static int get_token_alloc(int mb_rows, int mb_cols) {

Просмотреть файл

@ -169,35 +169,34 @@ void vp9_set_pred_flag(MACROBLOCKD *const xd,
unsigned char pred_flag) {
const int mis = xd->mode_info_stride;
BLOCK_SIZE_TYPE bsize = xd->mode_info_context->mbmi.sb_type;
const int bh = 1 << mb_height_log2(bsize);
const int bw = 1 << mb_width_log2(bsize);
const int bh = 1 << mi_height_log2(bsize);
const int bw = 1 << mi_width_log2(bsize);
#define sub(a, b) (b) < 0 ? (a) + (b) : (a)
const int x_mbs = sub(bw, xd->mb_to_right_edge >> 7);
const int y_mbs = sub(bh, xd->mb_to_bottom_edge >> 7);
const int x_mis = sub(bw, xd->mb_to_right_edge >> (3 + LOG2_MI_SIZE));
const int y_mis = sub(bh, xd->mb_to_bottom_edge >> (3 + LOG2_MI_SIZE));
#undef sub
int x, y;
switch (pred_id) {
case PRED_SEG_ID:
for (y = 0; y < y_mbs; y++) {
for (x = 0; x < x_mbs; x++) {
xd->mode_info_context[y * mis + x].mbmi.seg_id_predicted =
pred_flag;
for (y = 0; y < y_mis; y++) {
for (x = 0; x < x_mis; x++) {
xd->mode_info_context[y * mis + x].mbmi.seg_id_predicted = pred_flag;
}
}
break;
case PRED_REF:
for (y = 0; y < y_mbs; y++) {
for (x = 0; x < x_mbs; x++) {
for (y = 0; y < y_mis; y++) {
for (x = 0; x < x_mis; x++) {
xd->mode_info_context[y * mis + x].mbmi.ref_predicted = pred_flag;
}
}
break;
case PRED_MBSKIP:
for (y = 0; y < y_mbs; y++) {
for (x = 0; x < x_mbs; x++) {
for (y = 0; y < y_mis; y++) {
for (x = 0; x < x_mis; x++) {
xd->mode_info_context[y * mis + x].mbmi.mb_skip_coeff = pred_flag;
}
}
@ -214,27 +213,23 @@ void vp9_set_pred_flag(MACROBLOCKD *const xd,
// peredict various bitstream signals.
// Macroblock segment id prediction function
int vp9_get_pred_mb_segid(VP9_COMMON *cm, BLOCK_SIZE_TYPE sb_type,
int mb_row, int mb_col) {
const int mb_index = mb_row * cm->mb_cols + mb_col;
if (sb_type > BLOCK_SIZE_MB16X16) {
const int bw = 1 << mb_width_log2(sb_type);
const int bh = 1 << mb_height_log2(sb_type);
const int ymbs = MIN(cm->mb_rows - mb_row, bh);
const int xmbs = MIN(cm->mb_cols - mb_col, bw);
int segment_id = INT_MAX;
int x, y;
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 < 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]);
}
for (y = 0; y < ymis; y++) {
for (x = 0; x < xmis; x++) {
const int index = mi_index + (y * cm->mi_cols + x);
segment_id = MIN(segment_id, cm->last_frame_seg_map[index]);
}
return segment_id;
} else {
return cm->last_frame_seg_map[mb_index];
}
return segment_id;
}
MV_REFERENCE_FRAME vp9_get_pred_ref(const VP9_COMMON *const cm,

Просмотреть файл

@ -43,8 +43,8 @@ void vp9_set_pred_flag(MACROBLOCKD *const xd,
unsigned char pred_flag);
int vp9_get_pred_mb_segid(VP9_COMMON *cm, BLOCK_SIZE_TYPE sb_type,
int mb_row, int mb_col);
int vp9_get_pred_mi_segid(VP9_COMMON *cm, BLOCK_SIZE_TYPE sb_type,
int mi_row, int mi_col);
MV_REFERENCE_FRAME vp9_get_pred_ref(const VP9_COMMON *const cm,
const MACROBLOCKD *const xd);

Просмотреть файл

@ -387,11 +387,11 @@ static void build_inter_predictors(int plane, int block,
}
}
void vp9_build_inter_predictors_sby(MACROBLOCKD *xd,
int mb_row,
int mb_col,
int mi_row,
int mi_col,
BLOCK_SIZE_TYPE bsize) {
struct build_inter_predictors_args args = {
xd, mb_col * 16, mb_row * 16,
xd, mi_col * MI_SIZE, mi_row * MI_SIZE,
{xd->plane[0].dst.buf, NULL, NULL}, {xd->plane[0].dst.stride, 0, 0},
{{xd->plane[0].pre[0].buf, NULL, NULL},
{xd->plane[0].pre[1].buf, NULL, NULL}},
@ -401,11 +401,11 @@ void vp9_build_inter_predictors_sby(MACROBLOCKD *xd,
foreach_predicted_block_in_plane(xd, bsize, 0, build_inter_predictors, &args);
}
void vp9_build_inter_predictors_sbuv(MACROBLOCKD *xd,
int mb_row,
int mb_col,
int mi_row,
int mi_col,
BLOCK_SIZE_TYPE bsize) {
struct build_inter_predictors_args args = {
xd, mb_col * 16, mb_row * 16,
xd, mi_col * MI_SIZE, mi_row * MI_SIZE,
{NULL, xd->plane[1].dst.buf, xd->plane[2].dst.buf},
{0, xd->plane[1].dst.stride, xd->plane[1].dst.stride},
{{NULL, xd->plane[1].pre[0].buf, xd->plane[2].pre[0].buf},
@ -416,7 +416,7 @@ void vp9_build_inter_predictors_sbuv(MACROBLOCKD *xd,
foreach_predicted_block_uv(xd, bsize, build_inter_predictors, &args);
}
void vp9_build_inter_predictors_sb(MACROBLOCKD *xd,
int mb_row, int mb_col,
int mi_row, int mi_col,
BLOCK_SIZE_TYPE bsize) {
#if CONFIG_COMP_INTERINTRA_PRED
uint8_t *const y = xd->plane[0].dst.buf;
@ -426,8 +426,8 @@ void vp9_build_inter_predictors_sb(MACROBLOCKD *xd,
const int uv_stride = xd->plane[1].dst.stride;
#endif
vp9_build_inter_predictors_sby(xd, mb_row, mb_col, bsize);
vp9_build_inter_predictors_sbuv(xd, mb_row, mb_col, bsize);
vp9_build_inter_predictors_sby(xd, mi_row, mi_col, bsize);
vp9_build_inter_predictors_sbuv(xd, mi_row, mi_col, bsize);
#if CONFIG_COMP_INTERINTRA_PRED
if (xd->mode_info_context->mbmi.second_ref_frame == INTRA_FRAME)

Просмотреть файл

@ -79,11 +79,11 @@ static int scaled_buffer_offset(int x_offset,
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;
}
@ -91,25 +91,25 @@ static void setup_pred_plane(struct buf_2d *dst,
// 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;
@ -122,22 +122,22 @@ static void setup_pre_planes(MACROBLOCKD *xd,
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;
@ -146,13 +146,15 @@ static void setup_pred_block(YV12_BUFFER_CONFIG *dst,
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;

Просмотреть файл

@ -542,8 +542,8 @@ void vp9_build_interintra_predictors_sby(MACROBLOCKD *xd,
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,
@ -559,8 +559,8 @@ void vp9_build_interintra_predictors_sbuv(MACROBLOCKD *xd,
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(
@ -582,8 +582,8 @@ void vp9_build_interintra_predictors_sbuv(MACROBLOCKD *xd,
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,
@ -595,8 +595,8 @@ void vp9_build_intra_predictors_sby_s(MACROBLOCKD *xd,
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,

Просмотреть файл

@ -17,27 +17,31 @@
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);
}

Просмотреть файл

@ -94,24 +94,20 @@ static int read_mb_segid(vp9_reader *r, MACROBLOCKD *xd) {
}
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;
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 < 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;
}
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;
}
}
@ -128,7 +124,7 @@ static TX_SIZE select_txfm_size(VP9_COMMON *cm, vp9_reader *r,
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;
@ -139,7 +135,7 @@ static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m,
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,
@ -520,7 +516,7 @@ static void mb_mode_mv_init(VP9D_COMP *pbi, vp9_reader *r) {
// 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;
@ -543,17 +539,17 @@ static int read_mb_segment_id(VP9D_COMP *pbi, int mb_row, int mb_col,
// 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);
}
}
@ -589,7 +585,7 @@ static INLINE INTERPOLATIONFILTERTYPE read_switchable_filter_type(
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;
@ -598,8 +594,8 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
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 &&
@ -620,7 +616,7 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
// 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;
@ -628,7 +624,7 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
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);
@ -653,7 +649,7 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
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)
@ -718,7 +714,7 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
*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,
@ -1016,8 +1012,8 @@ void vp9_decode_mode_mvs_init(VP9D_COMP* const pbi, vp9_reader *r) {
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;
@ -1025,24 +1021,24 @@ void vp9_decode_mb_mode_mv(VP9D_COMP* const pbi,
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;
}
}

Просмотреть файл

@ -560,9 +560,9 @@ static void decode_sb_16x16(MACROBLOCKD *mb, BLOCK_SIZE_TYPE bsize) {
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;
@ -580,7 +580,7 @@ static void decode_sb(VP9D_COMP *pbi, MACROBLOCKD *xd, int mb_row, int mb_col,
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) {
@ -596,7 +596,7 @@ static void decode_sb(VP9D_COMP *pbi, MACROBLOCKD *xd, int mb_row, int mb_col,
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 {
@ -624,7 +624,7 @@ static void decode_sb(VP9D_COMP *pbi, MACROBLOCKD *xd, int mb_row, int mb_col,
// 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;
@ -651,7 +651,7 @@ static void decode_mb(VP9D_COMP *pbi, MACROBLOCKD *xd,
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) {
@ -737,35 +737,38 @@ static int get_delta_q(vp9_reader *r, int *dq) {
}
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;
@ -776,7 +779,7 @@ static void set_refs(VP9D_COMP *pbi, int mb_row, int mb_col) {
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;
@ -786,47 +789,48 @@ static void set_refs(VP9D_COMP *pbi, int mb_row, int mb_col) {
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]);
@ -836,21 +840,21 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mb_row, int mb_col,
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 :
@ -861,7 +865,7 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mb_row, int mb_col,
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:
@ -871,8 +875,8 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mb_row, int mb_col,
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);
}
@ -1024,11 +1028,13 @@ static void update_frame_size(VP9D_COMP *pbi) {
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);
@ -1286,16 +1292,16 @@ static void update_frame_context(FRAME_CONTEXT *fc) {
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);
}
}
}
@ -1552,7 +1558,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
// 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);

Просмотреть файл

@ -686,8 +686,7 @@ static void update_ref_probs(VP9_COMP *const cpi) {
}
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;
@ -697,21 +696,11 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
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
@ -926,8 +915,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
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;
@ -1145,23 +1133,21 @@ void print_zpcstats() {
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
@ -1173,23 +1159,23 @@ static void write_modes_b(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc,
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;
@ -1207,8 +1193,9 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc,
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],
@ -1218,21 +1205,21 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc,
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
@ -1246,7 +1233,7 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc,
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:
@ -1257,8 +1244,8 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc,
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);
}
@ -1267,19 +1254,21 @@ static void write_modes(VP9_COMP *cpi, vp9_writer* const bc,
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);
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -764,20 +764,20 @@ void vp9_fidct_mb(VP9_COMMON *const cm, MACROBLOCK *x) {
}
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);

Просмотреть файл

@ -520,9 +520,12 @@ void vp9_first_pass(VP9_COMP *cpi) {
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;

Просмотреть файл

@ -386,10 +386,22 @@ static void separate_arf_mbs(VP9_COMP *cpi) {
// 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]++;
}
}
}

Просмотреть файл

@ -379,7 +379,7 @@ static void configure_static_seg_features(VP9_COMP *cpi) {
// 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
@ -395,7 +395,7 @@ static void configure_static_seg_features(VP9_COMP *cpi) {
} 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
@ -460,8 +460,7 @@ static void configure_static_seg_features(VP9_COMP *cpi) {
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;
@ -549,8 +548,8 @@ static void print_seg_map(VP9_COMP *cpi) {
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++;
}
@ -567,13 +566,13 @@ static void update_reference_segmentation_map(VP9_COMP *cpi) {
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;
}
}
@ -907,7 +906,7 @@ static int alloc_partition_data(VP9_COMP *cpi) {
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;
@ -987,11 +986,13 @@ static void update_frame_size(VP9_COMP *cpi) {
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;
@ -1434,16 +1435,17 @@ VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) {
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));
@ -3336,6 +3338,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
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);
@ -3668,10 +3671,12 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
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));
}
}

Просмотреть файл

@ -159,7 +159,7 @@ void vp9_save_coding_context(VP9_COMP *cpi) {
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);
@ -221,7 +221,7 @@ void vp9_restore_coding_context(VP9_COMP *cpi) {
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);

Просмотреть файл

@ -1606,7 +1606,7 @@ static int labels2mode(
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;
@ -2167,7 +2167,7 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
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) ||
@ -2226,7 +2226,8 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
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;
@ -2735,7 +2736,7 @@ static void store_coding_context(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx,
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],
@ -2750,13 +2751,15 @@ static void setup_buffer_inter(VP9_COMP *cpi, MACROBLOCK *x,
// 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
@ -2873,8 +2876,8 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
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;
@ -2939,7 +2942,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
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);
}
@ -3075,7 +3078,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
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,
@ -3084,7 +3087,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
// 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,
@ -3092,7 +3095,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
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,
@ -3100,7 +3103,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
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,
@ -3125,18 +3128,18 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
(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 |=
@ -3153,19 +3156,22 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
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) {
@ -3276,7 +3282,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
}
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,
@ -3363,21 +3369,21 @@ static void rd_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
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);
}
@ -3742,7 +3748,7 @@ static void rd_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
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);
@ -3791,7 +3797,7 @@ static void rd_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
&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;
}
@ -4302,7 +4308,7 @@ void vp9_rd_pick_intra_mode(VP9_COMP *cpi, MACROBLOCK *x,
}
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,
@ -4403,7 +4409,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
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;
@ -4603,7 +4609,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
&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;
}
@ -4898,7 +4904,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
}
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;
@ -4916,7 +4922,7 @@ void vp9_pick_mode_inter_macroblock(VP9_COMP *cpi, MACROBLOCK *x,
{
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 */

Просмотреть файл

@ -27,11 +27,11 @@ void vp9_rd_pick_intra_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
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);

Просмотреть файл

@ -37,7 +37,7 @@ void vp9_set_segmentation_map(VP9_PTR ptr,
// 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;
@ -127,13 +127,13 @@ static void count_segs(VP9_COMP *cpi,
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]++;
@ -141,8 +141,8 @@ static void count_segs(VP9_COMP *cpi,
// 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
@ -167,7 +167,7 @@ void vp9_choose_segmap_coding_method(VP9_COMP *cpi) {
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];
@ -196,78 +196,95 @@ void vp9_choose_segmap_coding_method(VP9_COMP *cpi) {
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);
}
}
}