Commit 58a0f6db authored by James Zern's avatar James Zern

vp9: add TileInfo

replaces use of cur_tile_mi_(row|col)_(start|end) by VP9_COMMON, making
it less stateful and more reusable for parallel tile decoding

Change-Id: I1df09382b4567a0e5f4434825d47c79afe2399be
parent f0eabfd4
......@@ -35,6 +35,7 @@ void vp9_find_best_ref_mvs(MACROBLOCKD *xd, int allow_hp,
}
void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
const TileInfo *const tile,
int_mv *dst_nearest,
int_mv *dst_near,
int block_idx, int ref_idx,
......@@ -46,7 +47,7 @@ void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
assert(ref_idx == 0 || ref_idx == 1);
assert(MAX_MV_REF_CANDIDATES == 2); // makes code here slightly easier
vp9_find_mv_refs_idx(cm, xd, mi, xd->last_mi,
vp9_find_mv_refs_idx(cm, xd, tile, mi, xd->last_mi,
mi->mbmi.ref_frame[ref_idx],
mv_list, block_idx, mi_row, mi_col);
......
......@@ -34,8 +34,8 @@ static void clamp_mv2(MV *mv, const MACROBLOCKD *xd) {
xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN);
}
void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm,
MACROBLOCKD *xd,
void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
const TileInfo *const tile,
int_mv *dst_nearest,
int_mv *dst_near,
int block_idx, int ref_idx,
......
......@@ -170,17 +170,19 @@ static INLINE int_mv scale_mv(const MB_MODE_INFO *mbmi, int ref,
// Checks that the given mi_row, mi_col and search point
// are inside the borders of the tile.
static INLINE int is_inside(const VP9_COMMON *cm, int mi_col, int mi_row,
static INLINE int is_inside(const TileInfo *const tile,
int mi_col, int mi_row, int mi_rows,
const MV *mv) {
return !(mi_row + mv->row < 0 ||
mi_col + mv->col < cm->cur_tile_mi_col_start ||
mi_row + mv->row >= cm->mi_rows ||
mi_col + mv->col >= cm->cur_tile_mi_col_end);
mi_col + mv->col < tile->mi_col_start ||
mi_row + mv->row >= mi_rows ||
mi_col + mv->col >= tile->mi_col_end);
}
// This function searches the neighbourhood of a given MB/SB
// to try and find candidate reference vectors.
void vp9_find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd,
const TileInfo *const tile,
MODE_INFO *mi, const MODE_INFO *prev_mi,
MV_REFERENCE_FRAME ref_frame,
int_mv *mv_ref_list,
......@@ -201,7 +203,7 @@ void vp9_find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd,
// and we also need to keep a mode count.
for (i = 0; i < 2; ++i) {
const MV *const mv_ref = &mv_ref_search[i];
if (is_inside(cm, mi_col, mi_row, mv_ref)) {
if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) {
const MODE_INFO *const candidate_mi = xd->mi_8x8[mv_ref->col + mv_ref->row
* xd->mode_info_stride];
const MB_MODE_INFO *const candidate = &candidate_mi->mbmi;
......@@ -228,7 +230,7 @@ void vp9_find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd,
// mode counts.
for (; i < MVREF_NEIGHBOURS; ++i) {
const MV *const mv_ref = &mv_ref_search[i];
if (is_inside(cm, mi_col, mi_row, mv_ref)) {
if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) {
const MB_MODE_INFO *const candidate = &xd->mi_8x8[mv_ref->col +
mv_ref->row
* xd->mode_info_stride]->mbmi;
......@@ -258,7 +260,7 @@ void vp9_find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd,
if (different_ref_found) {
for (i = 0; i < MVREF_NEIGHBOURS; ++i) {
const MV *mv_ref = &mv_ref_search[i];
if (is_inside(cm, mi_col, mi_row, mv_ref)) {
if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) {
const MB_MODE_INFO *const candidate = &xd->mi_8x8[mv_ref->col +
mv_ref->row
* xd->mode_info_stride]->mbmi;
......
......@@ -15,6 +15,7 @@
#define VP9_COMMON_VP9_MVREF_COMMON_H_
void vp9_find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd,
const TileInfo *const tile,
MODE_INFO *mi, const MODE_INFO *prev_mi,
MV_REFERENCE_FRAME ref_frame,
int_mv *mv_ref_list,
......@@ -22,11 +23,12 @@ void vp9_find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd,
int mi_row, int mi_col);
static INLINE void vp9_find_mv_refs(const VP9_COMMON *cm, const MACROBLOCKD *xd,
const TileInfo *const tile,
MODE_INFO *mi, const MODE_INFO *prev_mi,
MV_REFERENCE_FRAME ref_frame,
int_mv *mv_ref_list,
int mi_row, int mi_col) {
vp9_find_mv_refs_idx(cm, xd, mi, prev_mi, ref_frame,
vp9_find_mv_refs_idx(cm, xd, tile, mi, prev_mi, ref_frame,
mv_ref_list, -1, mi_row, mi_col);
}
......
......@@ -19,6 +19,7 @@
#include "vp9/common/vp9_entropy.h"
#include "vp9/common/vp9_entropymode.h"
#include "vp9/common/vp9_quant_common.h"
#include "vp9/common/vp9_tile_common.h"
#if CONFIG_VP9_POSTPROC
#include "vp9/common/vp9_postproc.h"
......@@ -207,8 +208,6 @@ typedef struct VP9Common {
int frame_parallel_decoding_mode;
int log2_tile_cols, log2_tile_rows;
int cur_tile_mi_col_start, cur_tile_mi_col_end;
int cur_tile_mi_row_start, cur_tile_mi_row_end;
} VP9_COMMON;
// ref == 0 => LAST_FRAME
......@@ -279,17 +278,18 @@ static int check_bsize_coverage(int bs, int mi_rows, int mi_cols,
return -1;
}
static void set_mi_row_col(VP9_COMMON *cm, MACROBLOCKD *xd,
int mi_row, int bh,
int mi_col, int bw) {
static void set_mi_row_col(MACROBLOCKD *xd, const TileInfo *const tile,
int mi_row, int bh,
int mi_col, int bw,
int mi_rows, int mi_cols) {
xd->mb_to_top_edge = -((mi_row * MI_SIZE) * 8);
xd->mb_to_bottom_edge = ((cm->mi_rows - bh - mi_row) * MI_SIZE) * 8;
xd->mb_to_bottom_edge = ((mi_rows - bh - mi_row) * MI_SIZE) * 8;
xd->mb_to_left_edge = -((mi_col * MI_SIZE) * 8);
xd->mb_to_right_edge = ((cm->mi_cols - bw - mi_col) * MI_SIZE) * 8;
xd->mb_to_right_edge = ((mi_cols - bw - mi_col) * MI_SIZE) * 8;
// Are edges available for intra prediction?
xd->up_available = (mi_row != 0);
xd->left_available = (mi_col > cm->cur_tile_mi_col_start);
xd->left_available = (mi_col > tile->mi_col_start);
}
static void set_prev_mi(VP9_COMMON *cm) {
......
......@@ -10,6 +10,8 @@
#include "vp9/common/vp9_tile_common.h"
#include "vp9/common/vp9_onyxc_int.h"
#define MIN_TILE_WIDTH_B64 4
#define MAX_TILE_WIDTH_B64 64
......@@ -17,8 +19,8 @@ static int to_sbs(n_mis) {
return mi_cols_aligned_to_sb(n_mis) >> MI_BLOCK_SIZE_LOG2;
}
static void vp9_get_tile_offsets(int *min_tile_off, int *max_tile_off,
int tile_idx, int log2_n_tiles, int n_mis) {
static void get_tile_offsets(int *min_tile_off, int *max_tile_off,
int tile_idx, int log2_n_tiles, int n_mis) {
const int n_sbs = to_sbs(n_mis);
const int sb_off1 = (tile_idx * n_sbs) >> log2_n_tiles;
const int sb_off2 = ((tile_idx + 1) * n_sbs) >> log2_n_tiles;
......@@ -27,17 +29,14 @@ static void vp9_get_tile_offsets(int *min_tile_off, int *max_tile_off,
*max_tile_off = MIN(sb_off2 << 3, n_mis);
}
void vp9_get_tile_col_offsets(VP9_COMMON *cm, int tile_col_idx) {
vp9_get_tile_offsets(&cm->cur_tile_mi_col_start, &cm->cur_tile_mi_col_end,
tile_col_idx, cm->log2_tile_cols, cm->mi_cols);
}
void vp9_get_tile_row_offsets(VP9_COMMON *cm, int tile_row_idx) {
vp9_get_tile_offsets(&cm->cur_tile_mi_row_start, &cm->cur_tile_mi_row_end,
tile_row_idx, cm->log2_tile_rows, cm->mi_rows);
void vp9_tile_init(TileInfo *tile, const VP9_COMMON *cm,
int row_idx, int col_idx) {
get_tile_offsets(&tile->mi_row_start, &tile->mi_row_end,
row_idx, cm->log2_tile_rows, cm->mi_rows);
get_tile_offsets(&tile->mi_col_start, &tile->mi_col_end,
col_idx, cm->log2_tile_cols, cm->mi_cols);
}
void vp9_get_tile_n_bits(int mi_cols,
int *min_log2_tile_cols, int *max_log2_tile_cols) {
const int sb_cols = to_sbs(mi_cols);
......
......@@ -11,11 +11,17 @@
#ifndef VP9_COMMON_VP9_TILE_COMMON_H_
#define VP9_COMMON_VP9_TILE_COMMON_H_
#include "vp9/common/vp9_onyxc_int.h"
struct VP9Common;
void vp9_get_tile_col_offsets(VP9_COMMON *cm, int tile_col_idx);
typedef struct TileInfo {
int mi_row_start, mi_row_end;
int mi_col_start, mi_col_end;
} TileInfo;
void vp9_get_tile_row_offsets(VP9_COMMON *cm, int tile_row_idx);
// initializes 'tile->mi_(row|col)_(start|end)' for (row_idx, col_idx) based on
// 'cm->log2_tile_(rows|cols)' & 'cm->mi_(rows|cols)'
void vp9_tile_init(TileInfo *tile, const struct VP9Common *cm,
int row_idx, int col_idx);
void vp9_get_tile_n_bits(int mi_cols,
int *min_log2_tile_cols, int *max_log2_tile_cols);
......
......@@ -414,6 +414,7 @@ static int read_is_inter_block(VP9_COMMON *const cm, MACROBLOCKD *const xd,
static void read_inter_block_mode_info(VP9_COMMON *const cm,
MACROBLOCKD *const xd,
const TileInfo *const tile,
MODE_INFO *const mi,
int mi_row, int mi_col, vp9_reader *r) {
MB_MODE_INFO *const mbmi = &mi->mbmi;
......@@ -430,7 +431,7 @@ static void read_inter_block_mode_info(VP9_COMMON *const cm,
ref0 = mbmi->ref_frame[0];
is_compound = has_second_ref(mbmi);
vp9_find_mv_refs(cm, xd, mi, xd->last_mi, ref0, mbmi->ref_mvs[ref0],
vp9_find_mv_refs(cm, xd, tile, mi, xd->last_mi, ref0, mbmi->ref_mvs[ref0],
mi_row, mi_col);
inter_mode_ctx = mbmi->mode_context[ref0];
......@@ -456,7 +457,7 @@ static void read_inter_block_mode_info(VP9_COMMON *const cm,
if (is_compound) {
const MV_REFERENCE_FRAME ref1 = mbmi->ref_frame[1];
vp9_find_mv_refs(cm, xd, mi, xd->last_mi,
vp9_find_mv_refs(cm, xd, tile, mi, xd->last_mi,
ref1, mbmi->ref_mvs[ref1], mi_row, mi_col);
if (bsize < BLOCK_8X8 || mbmi->mode != ZEROMV) {
......@@ -482,12 +483,12 @@ static void read_inter_block_mode_info(VP9_COMMON *const cm,
b_mode = read_inter_mode(cm, r, inter_mode_ctx);
if (b_mode == NEARESTMV || b_mode == NEARMV) {
vp9_append_sub8x8_mvs_for_idx(cm, xd, &nearest[0],
vp9_append_sub8x8_mvs_for_idx(cm, xd, tile, &nearest[0],
&nearmv[0], j, 0,
mi_row, mi_col);
if (is_compound)
vp9_append_sub8x8_mvs_for_idx(cm, xd, &nearest[1],
vp9_append_sub8x8_mvs_for_idx(cm, xd, tile, &nearest[1],
&nearmv[1], j, 1,
mi_row, mi_col);
}
......@@ -523,6 +524,7 @@ static void read_inter_block_mode_info(VP9_COMMON *const cm,
static void read_inter_frame_mode_info(VP9_COMMON *const cm,
MACROBLOCKD *const xd,
const TileInfo *const tile,
MODE_INFO *const mi,
int mi_row, int mi_col, vp9_reader *r) {
MB_MODE_INFO *const mbmi = &mi->mbmi;
......@@ -537,12 +539,13 @@ static void read_inter_frame_mode_info(VP9_COMMON *const cm,
!mbmi->skip_coeff || !inter_block, r);
if (inter_block)
read_inter_block_mode_info(cm, xd, mi, mi_row, mi_col, r);
read_inter_block_mode_info(cm, xd, tile, mi, mi_row, mi_col, r);
else
read_intra_block_mode_info(cm, mi, r);
}
void vp9_read_mode_info(VP9_COMMON *cm, MACROBLOCKD *xd,
const TileInfo *const tile,
int mi_row, int mi_col, vp9_reader *r) {
MODE_INFO *const mi = xd->mi_8x8[0];
const BLOCK_SIZE bsize = mi->mbmi.sb_type;
......@@ -555,7 +558,7 @@ void vp9_read_mode_info(VP9_COMMON *cm, MACROBLOCKD *xd,
if (frame_is_intra_only(cm))
read_intra_frame_mode_info(cm, xd, mi, mi_row, mi_col, r);
else
read_inter_frame_mode_info(cm, xd, mi, mi_row, mi_col, r);
read_inter_frame_mode_info(cm, xd, tile, mi, mi_row, mi_col, r);
for (y = 0, z = 0; y < y_mis; y++, z += cm->mode_info_stride) {
for (x = !y; x < x_mis; x++) {
......
......@@ -14,7 +14,10 @@
#include "vp9/decoder/vp9_onyxd_int.h"
#include "vp9/decoder/vp9_dboolhuff.h"
struct TileInfo;
void vp9_read_mode_info(VP9_COMMON *cm, MACROBLOCKD *xd,
const struct TileInfo *const tile,
int mi_row, int mi_col, vp9_reader *r);
#endif // VP9_DECODER_VP9_DECODEMV_H_
......@@ -211,9 +211,11 @@ static void alloc_tile_storage(VP9D_COMP *pbi, int tile_cols) {
vpx_realloc(pbi->mi_streams, tile_cols *
sizeof(*pbi->mi_streams)));
for (tile_col = 0; tile_col < tile_cols; ++tile_col) {
vp9_get_tile_col_offsets(cm, tile_col);
TileInfo tile;
vp9_tile_init(&tile, cm, 0, tile_col);
pbi->mi_streams[tile_col] =
&cm->mi[cm->mi_rows * cm->cur_tile_mi_col_start];
&cm->mi[cm->mi_rows * tile.mi_col_start];
}
// 2 contexts per 'mi unit', so that we have one context per 4x4 txfm
......@@ -327,6 +329,7 @@ static int decode_tokens(VP9_COMMON *const cm, MACROBLOCKD *const xd,
}
static void set_offsets(VP9_COMMON *const cm, MACROBLOCKD *const xd,
const TileInfo *const tile,
BLOCK_SIZE bsize, int mi_row, int mi_col) {
const int bh = num_8x8_blocks_high_lookup[bsize];
const int bw = num_8x8_blocks_wide_lookup[bsize];
......@@ -350,7 +353,7 @@ static void set_offsets(VP9_COMMON *const cm, MACROBLOCKD *const xd,
// 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_mi_row_col(cm, xd, mi_row, bh, mi_col, bw);
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols);
setup_dst_planes(xd, get_frame_new_buffer(cm), mi_row, mi_col);
}
......@@ -371,6 +374,7 @@ static void set_ref(VP9_COMMON *const cm, MACROBLOCKD *const xd,
}
static void decode_modes_b(VP9_COMMON *const cm, MACROBLOCKD *const xd,
const TileInfo *const tile,
int mi_row, int mi_col,
vp9_reader *r, BLOCK_SIZE bsize, int index) {
const int less8x8 = bsize < BLOCK_8X8;
......@@ -381,8 +385,8 @@ static void decode_modes_b(VP9_COMMON *const cm, MACROBLOCKD *const xd,
if (index > 0)
return;
set_offsets(cm, xd, bsize, mi_row, mi_col);
vp9_read_mode_info(cm, xd, mi_row, mi_col, r);
set_offsets(cm, xd, tile, bsize, mi_row, mi_col);
vp9_read_mode_info(cm, xd, tile, mi_row, mi_col, r);
if (less8x8)
bsize = BLOCK_8X8;
......@@ -419,6 +423,7 @@ static void decode_modes_b(VP9_COMMON *const cm, MACROBLOCKD *const xd,
}
static void decode_modes_sb(VP9_COMMON *const cm, MACROBLOCKD *const xd,
const TileInfo *const tile,
int mi_row, int mi_col,
vp9_reader* r, BLOCK_SIZE bsize, int index) {
const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2;
......@@ -455,23 +460,23 @@ static void decode_modes_sb(VP9_COMMON *const cm, MACROBLOCKD *const xd,
switch (partition) {
case PARTITION_NONE:
decode_modes_b(cm, xd, mi_row, mi_col, r, subsize, 0);
decode_modes_b(cm, xd, tile, mi_row, mi_col, r, subsize, 0);
break;
case PARTITION_HORZ:
decode_modes_b(cm, xd, mi_row, mi_col, r, subsize, 0);
decode_modes_b(cm, xd, tile, mi_row, mi_col, r, subsize, 0);
if (mi_row + hbs < cm->mi_rows)
decode_modes_b(cm, xd, mi_row + hbs, mi_col, r, subsize, 1);
decode_modes_b(cm, xd, tile, mi_row + hbs, mi_col, r, subsize, 1);
break;
case PARTITION_VERT:
decode_modes_b(cm, xd, mi_row, mi_col, r, subsize, 0);
decode_modes_b(cm, xd, tile, mi_row, mi_col, r, subsize, 0);
if (mi_col + hbs < cm->mi_cols)
decode_modes_b(cm, xd, mi_row, mi_col + hbs, r, subsize, 1);
decode_modes_b(cm, xd, tile, mi_row, mi_col + hbs, r, subsize, 1);
break;
case PARTITION_SPLIT: {
int n;
for (n = 0; n < 4; n++) {
const int j = n >> 1, i = n & 1;
decode_modes_sb(cm, xd, mi_row + j * hbs, mi_col + i * hbs,
decode_modes_sb(cm, xd, tile, mi_row + j * hbs, mi_col + i * hbs,
r, subsize, n);
}
} break;
......@@ -737,7 +742,8 @@ static void setup_tile_context(VP9D_COMP *const pbi, MACROBLOCKD *const xd,
xd->above_seg_context = pbi->above_seg_context;
}
static void decode_tile(VP9D_COMP *pbi, vp9_reader *r) {
static void decode_tile(VP9D_COMP *pbi, const TileInfo *const tile,
vp9_reader *r) {
const int num_threads = pbi->oxcf.max_threads;
VP9_COMMON *const cm = &pbi->common;
int mi_row, mi_col;
......@@ -753,14 +759,14 @@ static void decode_tile(VP9D_COMP *pbi, vp9_reader *r) {
vp9_loop_filter_frame_init(cm, cm->lf.filter_level);
}
for (mi_row = cm->cur_tile_mi_row_start; mi_row < cm->cur_tile_mi_row_end;
for (mi_row = tile->mi_row_start; mi_row < tile->mi_row_end;
mi_row += MI_BLOCK_SIZE) {
// For a SB there are 2 left contexts, each pertaining to a MB row within
vp9_zero(xd->left_context);
vp9_zero(xd->left_seg_context);
for (mi_col = cm->cur_tile_mi_col_start; mi_col < cm->cur_tile_mi_col_end;
for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end;
mi_col += MI_BLOCK_SIZE)
decode_modes_sb(cm, xd, mi_row, mi_col, r, BLOCK_64X64, 0);
decode_modes_sb(cm, xd, tile, mi_row, mi_col, r, BLOCK_64X64, 0);
if (pbi->do_loopfilter_inline) {
const int lf_start = mi_row - MI_BLOCK_SIZE;
......@@ -770,7 +776,7 @@ static void decode_tile(VP9D_COMP *pbi, vp9_reader *r) {
if (lf_start < 0) continue;
// decoding has completed: finish up the loop filter in this thread.
if (mi_row + MI_BLOCK_SIZE >= cm->cur_tile_mi_row_end) continue;
if (mi_row + MI_BLOCK_SIZE >= tile->mi_row_end) continue;
vp9_worker_sync(&pbi->lf_worker);
lf_data->start = lf_start;
......@@ -852,14 +858,15 @@ static const uint8_t *decode_tiles(VP9D_COMP *pbi, const uint8_t *data) {
}
for (tile_row = 0; tile_row < tile_rows; tile_row++) {
vp9_get_tile_row_offsets(cm, tile_row);
for (tile_col = tile_cols - 1; tile_col >= 0; tile_col--) {
vp9_get_tile_col_offsets(cm, tile_col);
TileInfo tile;
vp9_tile_init(&tile, cm, tile_row, tile_col);
setup_token_decoder(data_ptr2[tile_row][tile_col], data_end,
data_end - data_ptr2[tile_row][tile_col],
&cm->error, &residual_bc);
setup_tile_context(pbi, xd, tile_col);
decode_tile(pbi, &residual_bc);
decode_tile(pbi, &tile, &residual_bc);
if (tile_row == tile_rows - 1 && tile_col == tile_cols - 1)
bc_bak = residual_bc;
}
......@@ -869,11 +876,11 @@ static const uint8_t *decode_tiles(VP9D_COMP *pbi, const uint8_t *data) {
int has_more;
for (tile_row = 0; tile_row < tile_rows; tile_row++) {
vp9_get_tile_row_offsets(cm, tile_row);
for (tile_col = 0; tile_col < tile_cols; tile_col++) {
TileInfo tile;
size_t size;
vp9_get_tile_col_offsets(cm, tile_col);
vp9_tile_init(&tile, cm, tile_row, tile_col);
has_more = tile_col < tile_cols - 1 || tile_row < tile_rows - 1;
if (has_more) {
......@@ -889,7 +896,7 @@ static const uint8_t *decode_tiles(VP9D_COMP *pbi, const uint8_t *data) {
setup_token_decoder(data, data_end, size, &cm->error, &residual_bc);
setup_tile_context(pbi, xd, tile_col);
decode_tile(pbi, &residual_bc);
decode_tile(pbi, &tile, &residual_bc);
data += size;
}
}
......
......@@ -561,7 +561,8 @@ static void write_mb_modes_kf(const VP9_COMP *cpi, MODE_INFO **mi_8x8,
write_intra_mode(bc, m->mbmi.uv_mode, vp9_kf_uv_mode_prob[ym]);
}
static void write_modes_b(VP9_COMP *cpi, MODE_INFO **mi_8x8, vp9_writer *bc,
static void write_modes_b(VP9_COMP *cpi, const TileInfo *const tile,
MODE_INFO **mi_8x8, vp9_writer *bc,
TOKENEXTRA **tok, TOKENEXTRA *tok_end,
int mi_row, int mi_col, int index) {
VP9_COMMON *const cm = &cpi->common;
......@@ -574,9 +575,10 @@ static void write_modes_b(VP9_COMP *cpi, MODE_INFO **mi_8x8, vp9_writer *bc,
xd->mi_8x8 = mi_8x8;
set_mi_row_col(&cpi->common, xd,
set_mi_row_col(xd, tile,
mi_row, num_8x8_blocks_high_lookup[m->mbmi.sb_type],
mi_col, num_8x8_blocks_wide_lookup[m->mbmi.sb_type]);
mi_col, num_8x8_blocks_wide_lookup[m->mbmi.sb_type],
cm->mi_rows, cm->mi_cols);
if (frame_is_intra_only(cm)) {
write_mb_modes_kf(cpi, mi_8x8, bc);
#ifdef ENTROPY_STATS
......@@ -593,7 +595,8 @@ static void write_modes_b(VP9_COMP *cpi, MODE_INFO **mi_8x8, vp9_writer *bc,
pack_mb_tokens(bc, tok, tok_end);
}
static void write_modes_sb(VP9_COMP *cpi, MODE_INFO **mi_8x8, vp9_writer *bc,
static void write_modes_sb(VP9_COMP *cpi, const TileInfo *const tile,
MODE_INFO **mi_8x8, vp9_writer *bc,
TOKENEXTRA **tok, TOKENEXTRA *tok_end,
int mi_row, int mi_col, BLOCK_SIZE bsize,
int index) {
......@@ -634,24 +637,25 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO **mi_8x8, vp9_writer *bc,
switch (partition) {
case PARTITION_NONE:
write_modes_b(cpi, mi_8x8, bc, tok, tok_end, mi_row, mi_col, 0);
write_modes_b(cpi, tile, mi_8x8, bc, tok, tok_end, mi_row, mi_col, 0);
break;
case PARTITION_HORZ:
write_modes_b(cpi, mi_8x8, bc, tok, tok_end, mi_row, mi_col, 0);
write_modes_b(cpi, tile, mi_8x8, bc, tok, tok_end, mi_row, mi_col, 0);
if ((mi_row + bs) < cm->mi_rows)
write_modes_b(cpi, mi_8x8 + bs * mis, bc, tok, tok_end, mi_row + bs,
mi_col, 1);
write_modes_b(cpi, tile, mi_8x8 + bs * mis, bc, tok, tok_end,
mi_row + bs, mi_col, 1);
break;
case PARTITION_VERT:
write_modes_b(cpi, mi_8x8, bc, tok, tok_end, mi_row, mi_col, 0);
write_modes_b(cpi, tile, mi_8x8, bc, tok, tok_end, mi_row, mi_col, 0);
if ((mi_col + bs) < cm->mi_cols)
write_modes_b(cpi, mi_8x8 + bs, bc, tok, tok_end, mi_row, mi_col + bs,
1);
write_modes_b(cpi, tile, mi_8x8 + bs, bc, tok, tok_end,
mi_row, mi_col + bs, 1);
break;
case PARTITION_SPLIT:
for (n = 0; n < 4; n++) {
const int j = n >> 1, i = n & 1;
write_modes_sb(cpi, mi_8x8 + j * bs * mis + i * bs, bc, tok, tok_end,
write_modes_sb(cpi, tile, mi_8x8 + j * bs * mis + i * bs, bc,
tok, tok_end,
mi_row + j * bs, mi_col + i * bs, subsize, n);
}
break;
......@@ -666,7 +670,8 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO **mi_8x8, vp9_writer *bc,
mi_row, mi_col, subsize, bsize);
}
static void write_modes(VP9_COMP *cpi, vp9_writer* const bc,
static void write_modes(VP9_COMP *cpi, const TileInfo *const tile,
vp9_writer* const bc,
TOKENEXTRA **tok, TOKENEXTRA *tok_end) {
VP9_COMMON *const cm = &cpi->common;
const int mis = cm->mode_info_stride;
......@@ -674,15 +679,15 @@ static void write_modes(VP9_COMP *cpi, vp9_writer* const bc,
MODE_INFO **mi_8x8 = cm->mi_grid_visible;
MODE_INFO **m_8x8;
mi_8x8 += cm->cur_tile_mi_col_start + cm->cur_tile_mi_row_start * mis;
mi_8x8 += tile->mi_col_start + tile->mi_row_start * mis;
for (mi_row = cm->cur_tile_mi_row_start; mi_row < cm->cur_tile_mi_row_end;
for (mi_row = tile->mi_row_start; mi_row < tile->mi_row_end;
mi_row += 8, mi_8x8 += 8 * mis) {
m_8x8 = mi_8x8;
vp9_zero(cpi->left_seg_context);
for (mi_col = cm->cur_tile_mi_col_start; mi_col < cm->cur_tile_mi_col_end;
for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end;
mi_col += MI_BLOCK_SIZE, m_8x8 += MI_BLOCK_SIZE) {
write_modes_sb(cpi, m_8x8, bc, tok, tok_end, mi_row, mi_col,
write_modes_sb(cpi, tile, m_8x8, bc, tok, tok_end, mi_row, mi_col,
BLOCK_64X64, 0);
}
}
......@@ -1218,9 +1223,10 @@ static size_t encode_tiles(VP9_COMP *cpi, uint8_t *data_ptr) {
}
for (tile_row = 0; tile_row < tile_rows; tile_row++) {
vp9_get_tile_row_offsets(cm, tile_row);
for (tile_col = 0; tile_col < tile_cols; tile_col++) {
vp9_get_tile_col_offsets(cm, tile_col);
TileInfo tile;
vp9_tile_init(&tile, cm, 0, tile_col);
tok_end = tok[tile_row][tile_col] + cpi->tok_count[tile_row][tile_col];
if (tile_col < tile_cols - 1 || tile_row < tile_rows - 1)
......@@ -1228,7 +1234,7 @@ static size_t encode_tiles(VP9_COMP *cpi, uint8_t *data_ptr) {
else
vp9_start_encode(&residual_bc, data_ptr + total_size);
write_modes(cpi, &residual_bc, &tok[tile_row][tile_col], tok_end);
write_modes(cpi, &tile, &residual_bc, &tok[tile_row][tile_col], tok_end);
assert(tok[tile_row][tile_col] == tok_end);
vp9_stop_encode(&residual_bc);
if (tile_col < tile_cols - 1 || tile_row < tile_rows - 1) {
......
This diff is collapsed.
......@@ -481,6 +481,7 @@ void vp9_first_pass(VP9_COMP *cpi) {
MACROBLOCK *const x = &cpi->mb;
VP9_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &x->e_mbd;
TileInfo tile;
int recon_yoffset, recon_uvoffset;
const int lst_yv12_idx = cm->ref_frame_map[cpi->lst_fb_idx];
......@@ -532,6 +533,9 @@ void vp9_first_pass(VP9_COMP *cpi) {
vp9_initialize_rd_consts(cpi);
}
// tiling is ignored in the first pass
vp9_tile_init(&tile, cm, 0, 0);
// for each macroblock row in image
for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) {
int_mv best_ref_mv;
......@@ -578,11 +582,12 @@ void vp9_first_pass(VP9_COMP *cpi) {
}
}
xd->mi_8x8[0]->mbmi.ref_frame[0] = INTRA_FRAME;
set_mi_row_col(cm, xd,
set_mi_row_col(xd, &tile,
mb_row << 1,
1 << mi_height_log2(xd->mi_8x8[0]->mbmi.sb_type),
mb_col << 1,
1 << mi_width_log2(xd->mi_8x8[0]->mbmi.sb_type));
1 << mi_width_log2(xd->mi_8x8[0]->mbmi.sb_type),
cm->mi_rows, cm->mi_cols);
if (cpi->sf.variance_adaptive_quantization) {
int energy = vp9_block_energy(cpi, x, xd->mi_8x8[0]->mbmi.sb_type);
......
......@@ -1432,10 +1432,6 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
int mi_row, int mi_col,
int_mv single_newmv[MAX_REF_FRAMES],
int *rate_mv);
static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
BLOCK_SIZE bsize,
int mi_row, int mi_col,
int_mv *tmp_mv, int *rate_mv);
static int labels2mode(MACROBLOCK *x, int i,
MB_PREDICTION_MODE this_mode,
......@@ -1646,6 +1642,7 @@ static INLINE void mi_buf_restore(MACROBLOCK *x, struct buf_2d orig_src,