assert(MAXQ <= 255);
memset(cr->last_coded_q_map, MAXQ, last_coded_q_map_size);
cr->counter_encode_maxq_scene_change = 0;
+ cr->content_mode = 1;
return cr;
}
else
rc->baseline_gf_interval = 40;
if (cpi->oxcf.rc_mode == VPX_VBR) rc->baseline_gf_interval = 20;
- if (rc->avg_frame_low_motion < 50 && rc->frames_since_key > 40)
+ if (rc->avg_frame_low_motion < 50 && rc->frames_since_key > 40 &&
+ cr->content_mode)
rc->baseline_gf_interval = 10;
}
? vp9_get_qindex(&cm->seg, CR_SEGMENT_ID_BOOST2, cm->base_qindex)
: vp9_get_qindex(&cm->seg, CR_SEGMENT_ID_BOOST1, cm->base_qindex);
// More aggressive settings for noisy content.
- if (cpi->noise_estimate.enabled && cpi->noise_estimate.level >= kMedium) {
+ if (cpi->noise_estimate.enabled && cpi->noise_estimate.level >= kMedium &&
+ cr->content_mode) {
consec_zero_mv_thresh = 60;
qindex_thresh =
VPXMAX(vp9_get_qindex(&cm->seg, CR_SEGMENT_ID_BOOST1, cm->base_qindex),
#if CONFIG_VP9_HIGHBITDEPTH
if (cpi->common.use_highbitdepth) compute_content = 0;
#endif
- if (cpi->Last_Source == NULL ||
+ if (cr->content_mode == 0 || cpi->Last_Source == NULL ||
cpi->Last_Source->y_width != cpi->Source->y_width ||
cpi->Last_Source->y_height != cpi->Source->y_height)
compute_content = 0;
// reset to 0 later depending on the coding mode.
if (cr->map[bl_index2] == 0) {
count_tot++;
- if (cr->last_coded_q_map[bl_index2] > qindex_thresh ||
+ if (cr->content_mode == 0 ||
+ cr->last_coded_q_map[bl_index2] > qindex_thresh ||
cpi->consec_zero_mv[bl_index2] < consec_zero_mv_thresh_block) {
sum_map++;
count_sel++;
rc->avg_frame_qindex[INTER_FRAME] < qp_thresh ||
(cpi->use_svc &&
cpi->svc.layer_context[cpi->svc.temporal_layer_id].is_key_frame) ||
- (!cpi->use_svc && rc->avg_frame_low_motion < thresh_low_motion &&
+ (!cpi->use_svc && cr->content_mode &&
+ rc->avg_frame_low_motion < thresh_low_motion &&
rc->frames_since_key > 40) ||
(!cpi->use_svc && rc->avg_frame_qindex[INTER_FRAME] > qp_max_thresh &&
rc->frames_since_key > 20)) {
cr->percent_refresh = (cr->skip_flat_static_blocks) ? 5 : 10;
// Increase the amount of refresh on scene change that is encoded at max Q,
// increase for a few cycles of the refresh period (~100 / percent_refresh).
- if (cr->counter_encode_maxq_scene_change < 30)
+ if (cr->content_mode && cr->counter_encode_maxq_scene_change < 30)
cr->percent_refresh = (cr->skip_flat_static_blocks) ? 10 : 15;
cr->rate_ratio_qdelta = 2.0;
cr->rate_boost_fac = 10;
(double)(cr->actual_num_seg1_blocks + cr->actual_num_seg2_blocks) /
num8x8bl;
cr->weight_segment = weight_segment;
+ if (cr->content_mode == 0) {
+ cr->actual_num_seg1_blocks =
+ cr->percent_refresh * cm->mi_rows * cm->mi_cols / 100;
+ cr->actual_num_seg2_blocks = 0;
+ cr->weight_segment = (double)(cr->actual_num_seg1_blocks) / num8x8bl;
+ }
}
// Setup cyclic background refresh: set delta q and segmentation map.
}
// 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) {
+ if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ &&
+ cpi->cyclic_refresh->content_mode) {
vp9_cyclic_refresh_update_segment(cpi, xd->mi[0], mi_row, mi_col, bsize,
ctx->rate, ctx->dist, x->skip, p);
}
if (seg->enabled && (cpi->oxcf.aq_mode != NO_AQ || cpi->roi.enabled)) {
// Setting segmentation map for cyclic_refresh.
- if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) {
+ if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ &&
+ cpi->cyclic_refresh->content_mode) {
vp9_cyclic_refresh_update_segment(cpi, mi, mi_row, mi_col, bsize,
ctx->rate, ctx->dist, x->skip, p);
} else {
++td->counts->tx.tx_totals[mi->tx_size];
++td->counts->tx.tx_totals[get_uv_tx_size(mi, &xd->plane[1])];
- if (cm->seg.enabled && cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ)
+ if (cm->seg.enabled && cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ &&
+ cpi->cyclic_refresh->content_mode)
vp9_cyclic_refresh_update_sb_postencode(cpi, mi, mi_row, mi_col, bsize);
if (cpi->oxcf.pass == 0 && cpi->svc.temporal_layer_id == 0 &&
(!cpi->use_svc ||