Commit 807885b5 authored by Yunqing Wang's avatar Yunqing Wang Committed by Gerrit Code Review

Merge "vp9_ethread: modify the cyclic refresh struct"

parents e4e85ad4 8ee605f1
......@@ -38,9 +38,6 @@ struct CYCLIC_REFRESH {
int rdmult;
// Cyclic refresh map.
signed char *map;
// Projected rate and distortion for the current superblock.
int64_t projected_rate_sb;
int64_t projected_dist_sb;
// Thresholds applied to projected rate/distortion of the superblock.
int64_t thresh_rate_sb;
int64_t thresh_dist_sb;
......@@ -92,12 +89,13 @@ static int apply_cyclic_refresh_bitrate(const VP9_COMMON *cm,
// mode, and rate/distortion.
static int candidate_refresh_aq(const CYCLIC_REFRESH *cr,
const MB_MODE_INFO *mbmi,
BLOCK_SIZE bsize, int use_rd) {
BLOCK_SIZE bsize, int use_rd,
int64_t rate_sb) {
if (use_rd) {
MV mv = mbmi->mv[0].as_mv;
// If projected rate is below the thresh_rate (well below target,
// so undershoot expected), accept it for lower-qp coding.
if (cr->projected_rate_sb < cr->thresh_rate_sb)
if (rate_sb < cr->thresh_rate_sb)
return 1;
// Otherwise, reject the block for lower-qp coding if any of the following:
// 1) mode uses large mv
......@@ -125,7 +123,8 @@ static int candidate_refresh_aq(const CYCLIC_REFRESH *cr,
void vp9_cyclic_refresh_update_segment(VP9_COMP *const cpi,
MB_MODE_INFO *const mbmi,
int mi_row, int mi_col,
BLOCK_SIZE bsize, int use_rd) {
BLOCK_SIZE bsize, int use_rd,
int64_t rate_sb) {
const VP9_COMMON *const cm = &cpi->common;
CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
const int bw = num_8x8_blocks_wide_lookup[bsize];
......@@ -133,7 +132,8 @@ void vp9_cyclic_refresh_update_segment(VP9_COMP *const cpi,
const int xmis = MIN(cm->mi_cols - mi_col, bw);
const int ymis = MIN(cm->mi_rows - mi_row, bh);
const int block_index = mi_row * cm->mi_cols + mi_col;
const int refresh_this_block = candidate_refresh_aq(cr, mbmi, bsize, use_rd);
const int refresh_this_block = candidate_refresh_aq(cr, mbmi, bsize, use_rd,
rate_sb);
// Default is to not update the refresh map.
int new_map_value = cr->map[block_index];
int x = 0; int y = 0;
......@@ -311,12 +311,6 @@ void vp9_cyclic_refresh_setup(VP9_COMP *const cpi) {
}
}
void vp9_cyclic_refresh_set_rate_and_dist_sb(CYCLIC_REFRESH *cr,
int64_t rate_sb, int64_t dist_sb) {
cr->projected_rate_sb = rate_sb;
cr->projected_dist_sb = dist_sb;
}
int vp9_cyclic_refresh_get_rdmult(const CYCLIC_REFRESH *cr) {
return cr->rdmult;
}
......@@ -33,14 +33,12 @@ void vp9_cyclic_refresh_free(CYCLIC_REFRESH *cr);
void vp9_cyclic_refresh_update_segment(struct VP9_COMP *const cpi,
MB_MODE_INFO *const mbmi,
int mi_row, int mi_col,
BLOCK_SIZE bsize, int use_rd);
BLOCK_SIZE bsize, int use_rd,
int64_t rate_sb);
// Setup cyclic background refresh: set delta q and segmentation map.
void vp9_cyclic_refresh_setup(struct VP9_COMP *const cpi);
void vp9_cyclic_refresh_set_rate_and_dist_sb(CYCLIC_REFRESH *cr,
int64_t rate_sb, int64_t dist_sb);
int vp9_cyclic_refresh_get_rdmult(const CYCLIC_REFRESH *cr);
#ifdef __cplusplus
......
......@@ -641,11 +641,8 @@ static void update_state(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx,
// Else for cyclic refresh mode update the segment map, set the segment id
// and then update the quantizer.
if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) {
vp9_cyclic_refresh_set_rate_and_dist_sb(cpi->cyclic_refresh,
ctx->rate, ctx->dist);
vp9_cyclic_refresh_update_segment(cpi, &xd->mi[0].src_mi->mbmi,
mi_row, mi_col, bsize, 1);
mi_row, mi_col, bsize, 1, ctx->rate);
}
}
......@@ -1310,10 +1307,9 @@ static void update_state_rt(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx,
: cm->last_frame_seg_map;
mbmi->segment_id = vp9_get_segment_id(cm, map, bsize, mi_row, mi_col);
} else {
vp9_cyclic_refresh_set_rate_and_dist_sb(cpi->cyclic_refresh,
ctx->rate, ctx->dist);
// Setting segmentation map for cyclic_refresh
vp9_cyclic_refresh_update_segment(cpi, mbmi, mi_row, mi_col, bsize, 1);
vp9_cyclic_refresh_update_segment(cpi, mbmi, mi_row, mi_col, bsize, 1,
ctx->rate);
}
vp9_init_plane_quantizers(cpi, x);
}
......
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