Commit d56b3eb0 authored by Jingning Han's avatar Jingning Han
Browse files

Refactor encoder tile data structure

Make the common tile info as one element in the encoder tile data
struct.

Change-Id: I8c474b4ba67ee3e2c86ab164f353ff71ea9992be
parent 192010d2
......@@ -929,13 +929,11 @@ static int get_refresh_mask(VP9_COMP *cpi) {
static size_t encode_tiles(VP9_COMP *cpi, uint8_t *data_ptr) {
VP9_COMMON *const cm = &cpi->common;
vp9_writer residual_bc;
int tile_row, tile_col;
TOKENEXTRA *tok[4][1 << 6], *tok_end;
size_t total_size = 0;
const int tile_cols = 1 << cm->log2_tile_cols;
const int tile_rows = 1 << cm->log2_tile_rows;
TileInfo tile[4][1 << 6];
TOKENEXTRA *pre_tok = cpi->tok;
int tile_tok = 0;
......@@ -944,18 +942,16 @@ static size_t encode_tiles(VP9_COMP *cpi, uint8_t *data_ptr) {
for (tile_row = 0; tile_row < tile_rows; ++tile_row) {
for (tile_col = 0; tile_col < tile_cols; ++tile_col) {
vp9_tile_init(&tile[tile_row][tile_col], cm, tile_row, tile_col);
int tile_idx = tile_row * tile_cols + tile_col;
tok[tile_row][tile_col] = pre_tok + tile_tok;
pre_tok = tok[tile_row][tile_col];
tile_tok = allocated_tokens(tile[tile_row][tile_col]);
tile_tok = allocated_tokens(cpi->tile_data[tile_idx].tile_info);
}
}
for (tile_row = 0; tile_row < tile_rows; tile_row++) {
for (tile_col = 0; tile_col < tile_cols; tile_col++) {
const TileInfo * const ptile = &tile[tile_row][tile_col];
int tile_idx = tile_row * tile_cols + 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)
......@@ -963,7 +959,8 @@ 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, ptile, &residual_bc, &tok[tile_row][tile_col], tok_end);
write_modes(cpi, &cpi->tile_data[tile_idx].tile_info,
&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.
......@@ -229,6 +229,7 @@ static INLINE int is_lossless_requested(const VP9EncoderConfig *cfg) {
// TODO(jingning) All spatially adaptive variables should go to TileDataEnc.
typedef struct TileDataEnc {
TileInfo tile_info;
int thresh_freq_fact[BLOCK_SIZES][MAX_MODES];
int mode_map[BLOCK_SIZES][MAX_MODES];
} TileDataEnc;
......
......@@ -459,10 +459,11 @@ static const THR_MODES mode_idx[MAX_REF_FRAMES - 1][INTER_MODES] = {
// TODO(jingning) placeholder for inter-frame non-RD mode decision.
// this needs various further optimizations. to be continued..
void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
const TileInfo *const tile, TileDataEnc *tile_data,
TileDataEnc *tile_data,
int mi_row, int mi_col, RD_COST *rd_cost,
BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx) {
VP9_COMMON *const cm = &cpi->common;
TileInfo *const tile_info = &tile_data->tile_info;
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi;
struct macroblockd_plane *const pd = &xd->plane[0];
......@@ -571,10 +572,11 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
sf, sf);
if (!cm->error_resilient_mode)
vp9_find_mv_refs(cm, xd, tile, xd->mi[0].src_mi, ref_frame,
vp9_find_mv_refs(cm, xd, tile_info, xd->mi[0].src_mi, ref_frame,
candidates, mi_row, mi_col);
else
const_motion[ref_frame] = mv_refs_rt(cm, xd, tile, xd->mi[0].src_mi,
const_motion[ref_frame] = mv_refs_rt(cm, xd, tile_info,
xd->mi[0].src_mi,
ref_frame, candidates,
mi_row, mi_col);
......
......@@ -18,7 +18,6 @@ extern "C" {
#endif
void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
const struct TileInfo *const tile,
TileDataEnc *tile_data,
int mi_row, int mi_col, RD_COST *rd_cost,
BLOCK_SIZE bsize,
......
......@@ -2791,12 +2791,12 @@ static void update_rd_thresh_fact(VP9_COMP *cpi, TileDataEnc *tile_data,
void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi,
TileDataEnc *tile_data,
MACROBLOCK *x,
const TileInfo *const tile,
int mi_row, int mi_col,
RD_COST *rd_cost, BLOCK_SIZE bsize,
PICK_MODE_CONTEXT *ctx,
int64_t best_rd_so_far) {
VP9_COMMON *const cm = &cpi->common;
TileInfo *const tile_info = &tile_data->tile_info;
RD_OPT *const rd_opt = &cpi->rd;
SPEED_FEATURES *const sf = &cpi->sf;
MACROBLOCKD *const xd = &x->e_mbd;
......@@ -2872,7 +2872,7 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi,
for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
x->pred_mv_sad[ref_frame] = INT_MAX;
if (cpi->ref_frame_flags & flag_list[ref_frame]) {
setup_buffer_inter(cpi, x, tile, ref_frame, bsize, mi_row, mi_col,
setup_buffer_inter(cpi, x, tile_info, ref_frame, bsize, mi_row, mi_col,
frame_mv[NEARESTMV], frame_mv[NEARMV], yv12_mb);
}
frame_mv[NEWMV][ref_frame].as_int = INVALID_MV;
......@@ -3026,9 +3026,9 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi,
if (sf->motion_field_mode_search) {
const int mi_width = MIN(num_8x8_blocks_wide_lookup[bsize],
tile->mi_col_end - mi_col);
tile_info->mi_col_end - mi_col);
const int mi_height = MIN(num_8x8_blocks_high_lookup[bsize],
tile->mi_row_end - mi_row);
tile_info->mi_row_end - mi_row);
const int bsl = mi_width_log2_lookup[bsize];
int cb_partition_search_ctrl = (((mi_row + mi_col) >> bsl)
+ get_chessboard_index(cm->current_video_frame)) & 0x1;
......@@ -3039,7 +3039,7 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi,
int_mv ref_mv;
ref_mv.as_int = INVALID_MV;
if ((mi_row - 1) >= tile->mi_row_start) {
if ((mi_row - 1) >= tile_info->mi_row_start) {
ref_mv = xd->mi[-xd->mi_stride].src_mi->mbmi.mv[0];
rf = xd->mi[-xd->mi_stride].src_mi->mbmi.ref_frame[0];
for (i = 0; i < mi_width; ++i) {
......@@ -3050,7 +3050,7 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi,
}
}
if ((mi_col - 1) >= tile->mi_col_start) {
if ((mi_col - 1) >= tile_info->mi_col_start) {
if (ref_mv.as_int == INVALID_MV)
ref_mv = xd->mi[-1].src_mi->mbmi.mv[0];
if (rf == NONE)
......@@ -3593,13 +3593,13 @@ void vp9_rd_pick_inter_mode_sb_seg_skip(VP9_COMP *cpi,
void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi,
TileDataEnc *tile_data,
MACROBLOCK *x,
const TileInfo *const tile,
int mi_row, int mi_col,
RD_COST *rd_cost,
BLOCK_SIZE bsize,
PICK_MODE_CONTEXT *ctx,
int64_t best_rd_so_far) {
VP9_COMMON *const cm = &cpi->common;
TileInfo *const tile_info = &tile_data->tile_info;
RD_OPT *const rd_opt = &cpi->rd;
SPEED_FEATURES *const sf = &cpi->sf;
MACROBLOCKD *const xd = &x->e_mbd;
......@@ -3658,7 +3658,7 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi,
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, tile,
setup_buffer_inter(cpi, x, tile_info,
ref_frame, bsize, mi_row, mi_col,
frame_mv[NEARESTMV], frame_mv[NEARMV],
yv12_mb);
......@@ -3852,7 +3852,7 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi,
int newbest, rs;
int64_t rs_rd;
mbmi->interp_filter = switchable_filter_index;
tmp_rd = rd_pick_best_sub8x8_mode(cpi, x, tile,
tmp_rd = rd_pick_best_sub8x8_mode(cpi, x, tile_info,
&mbmi->ref_mvs[ref_frame][0],
second_ref, best_yrd, &rate,
&rate_y, &distortion,
......@@ -3918,7 +3918,7 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi,
if (!pred_exists) {
// Handles the special case when a filter that is not in the
// switchable list (bilinear, 6-tap) is indicated at the frame level
tmp_rd = rd_pick_best_sub8x8_mode(cpi, x, tile,
tmp_rd = rd_pick_best_sub8x8_mode(cpi, x, tile_info,
&mbmi->ref_mvs[ref_frame][0],
second_ref, best_yrd, &rate, &rate_y,
&distortion, &skippable, &total_sse,
......
......@@ -32,7 +32,6 @@ void vp9_rd_pick_intra_mode_sb(struct VP9_COMP *cpi, struct macroblock *x,
void vp9_rd_pick_inter_mode_sb(struct VP9_COMP *cpi,
struct TileDataEnc *tile_data,
struct macroblock *x,
const struct TileInfo *const tile,
int mi_row, int mi_col,
struct RD_COST *rd_cost,
BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx,
......@@ -49,7 +48,6 @@ void vp9_rd_pick_inter_mode_sb_seg_skip(struct VP9_COMP *cpi,
void vp9_rd_pick_inter_mode_sub8x8(struct VP9_COMP *cpi,
struct TileDataEnc *tile_data,
struct macroblock *x,
const struct TileInfo *const tile,
int mi_row, int mi_col,
struct RD_COST *rd_cost,
BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment