History

vp9-rtc: Extract content dependency in cyclic refresh

For usage in the external RC. When content_mode = 0, the cyclic refresh has no dependency on the content (motion, spatial variance, motion vectors, etc,). The content_mode = 0, when compared to content_mode = 1, on rtc set for speed 7: has some regression on some clips (~3-5%), but overall/average bdrate loss is about ~1-2%. Comparing aq_mode=3 with content_mode = 0, vs aq_mode=3: about ~14% avg/overall bdrate gain, but has ~3-7% regression on some hard motion clip (e.g.m street).

Marco Paniconi committed 5 years ago

Commit 67bfbcf1 parent eebc5cd4 files · +25 −10Browse files

Unified · Split

4 files
  1. vp9/encoder/vp9_aq_cyclicrefresh.c +17 −6
  2. vp9/encoder/vp9_aq_cyclicrefresh.h +1 −0
  3. vp9/encoder/vp9_encodeframe.c +6 −3
  4. vp9/encoder/vp9_encoder.c +1 −1
vp9/encoder/vp9_aq_cyclicrefresh.c+17−6
@@ -48,6 +48,7 @@ CYCLIC_REFRESH *vp9_cyclic_refresh_alloc(int mi_rows, int mi_cols) { · 47 unmodified lines
4848 assert(MAXQ <= 255);
4949 memset(cr->last_coded_q_map, MAXQ, last_coded_q_map_size);
5050 cr->counter_encode_maxq_scene_change = 0;
51+ cr->content_mode = 1;
5152 return cr;
5253 }
5354
@@ -326,7 +327,8 @@ void vp9_cyclic_refresh_set_golden_update(VP9_COMP *const cpi) { · 272 unmodified lines
326327 else
327328 rc->baseline_gf_interval = 40;
328329 if (cpi->oxcf.rc_mode == VPX_VBR) rc->baseline_gf_interval = 20;
329− if (rc->avg_frame_low_motion < 50 && rc->frames_since_key > 40)
330+ if (rc->avg_frame_low_motion < 50 && rc->frames_since_key > 40 &&
331+ cr->content_mode)
330332 rc->baseline_gf_interval = 10;
331333 }
332334
@@ -388,7 +390,8 @@ static void cyclic_refresh_update_map(VP9_COMP *const cpi) { · 55 unmodified lines
388390 ? vp9_get_qindex(&cm->seg, CR_SEGMENT_ID_BOOST2, cm->base_qindex)
389391 : vp9_get_qindex(&cm->seg, CR_SEGMENT_ID_BOOST1, cm->base_qindex);
390392 // More aggressive settings for noisy content.
391− if (cpi->noise_estimate.enabled && cpi->noise_estimate.level >= kMedium) {
393+ if (cpi->noise_estimate.enabled && cpi->noise_estimate.level >= kMedium &&
394+ cr->content_mode) {
392395 consec_zero_mv_thresh = 60;
393396 qindex_thresh =
394397 VPXMAX(vp9_get_qindex(&cm->seg, CR_SEGMENT_ID_BOOST1, cm->base_qindex),
@@ -409,7 +412,7 @@ static void cyclic_refresh_update_map(VP9_COMP *const cpi) { · 14 unmodified lines
409412 #if CONFIG_VP9_HIGHBITDEPTH
410413 if (cpi->common.use_highbitdepth) compute_content = 0;
411414 #endif
412− if (cpi->Last_Source == NULL ||
415+ if (cr->content_mode == 0 || cpi->Last_Source == NULL ||
413416 cpi->Last_Source->y_width != cpi->Source->y_width ||
414417 cpi->Last_Source->y_height != cpi->Source->y_height)
415418 compute_content = 0;
@@ -430,7 +433,8 @@ static void cyclic_refresh_update_map(VP9_COMP *const cpi) { · 14 unmodified lines
430433 // reset to 0 later depending on the coding mode.
431434 if (cr->map[bl_index2] == 0) {
432435 count_tot++;
433− if (cr->last_coded_q_map[bl_index2] > qindex_thresh ||
436+ if (cr->content_mode == 0 ||
437+ cr->last_coded_q_map[bl_index2] > qindex_thresh ||
434438 cpi->consec_zero_mv[bl_index2] < consec_zero_mv_thresh_block) {
435439 sum_map++;
436440 count_sel++;
@@ -489,7 +493,8 @@ void vp9_cyclic_refresh_update_parameters(VP9_COMP *const cpi) { · 52 unmodified lines
489493 rc->avg_frame_qindex[INTER_FRAME] < qp_thresh ||
490494 (cpi->use_svc &&
491495 cpi->svc.layer_context[cpi->svc.temporal_layer_id].is_key_frame) ||
492− (!cpi->use_svc && rc->avg_frame_low_motion < thresh_low_motion &&
496+ (!cpi->use_svc && cr->content_mode &&
497+ rc->avg_frame_low_motion < thresh_low_motion &&
493498 rc->frames_since_key > 40) ||
494499 (!cpi->use_svc && rc->avg_frame_qindex[INTER_FRAME] > qp_max_thresh &&
495500 rc->frames_since_key > 20)) {
@@ -528,7 +533,7 @@ void vp9_cyclic_refresh_update_parameters(VP9_COMP *const cpi) { · 32 unmodified lines
528533 cr->percent_refresh = (cr->skip_flat_static_blocks) ? 5 : 10;
529534 // Increase the amount of refresh on scene change that is encoded at max Q,
530535 // increase for a few cycles of the refresh period (~100 / percent_refresh).
531− if (cr->counter_encode_maxq_scene_change < 30)
536+ if (cr->content_mode && cr->counter_encode_maxq_scene_change < 30)
532537 cr->percent_refresh = (cr->skip_flat_static_blocks) ? 10 : 15;
533538 cr->rate_ratio_qdelta = 2.0;
534539 cr->rate_boost_fac = 10;
@@ -575,6 +580,12 @@ void vp9_cyclic_refresh_update_parameters(VP9_COMP *const cpi) { · 40 unmodified lines
575580 (double)(cr->actual_num_seg1_blocks + cr->actual_num_seg2_blocks) /
576581 num8x8bl;
577582 cr->weight_segment = weight_segment;
583+ if (cr->content_mode == 0) {
584+ cr->actual_num_seg1_blocks =
585+ cr->percent_refresh * cm->mi_rows * cm->mi_cols / 100;
586+ cr->actual_num_seg2_blocks = 0;
587+ cr->weight_segment = (double)(cr->actual_num_seg1_blocks) / num8x8bl;
588+ }
578589 }
579590
580591 // Setup cyclic background refresh: set delta q and segmentation map.
vp9/encoder/vp9_aq_cyclicrefresh.h+1−0
@@ -70,6 +70,7 @@ struct CYCLIC_REFRESH { · 69 unmodified lines
7070 int apply_cyclic_refresh;
7171 int counter_encode_maxq_scene_change;
7272 int skip_flat_static_blocks;
73+ int content_mode;
7374 };
7475
7576 struct VP9_COMP;
vp9/encoder/vp9_encodeframe.c+6−3
@@ -1842,7 +1842,8 @@ static void update_state(VP9_COMP *cpi, ThreadData *td, PICK_MODE_CONTEXT *ctx, · 1841 unmodified lines
18421842 }
18431843 // Else for cyclic refresh mode update the segment map, set the segment id
18441844 // and then update the quantizer.
1845− if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) {
1845+ if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ &&
1846+ cpi->cyclic_refresh->content_mode) {
18461847 vp9_cyclic_refresh_update_segment(cpi, xd->mi[0], mi_row, mi_col, bsize,
18471848 ctx->rate, ctx->dist, x->skip, p);
18481849 }
@@ -2539,7 +2540,8 @@ static void update_state_rt(VP9_COMP *cpi, ThreadData *td, · 690 unmodified lines
25392540
25402541 if (seg->enabled && (cpi->oxcf.aq_mode != NO_AQ || cpi->roi.enabled)) {
25412542 // Setting segmentation map for cyclic_refresh.
2542− if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) {
2543+ if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ &&
2544+ cpi->cyclic_refresh->content_mode) {
25432545 vp9_cyclic_refresh_update_segment(cpi, mi, mi_row, mi_col, bsize,
25442546 ctx->rate, ctx->dist, x->skip, p);
25452547 } else {
@@ -6716,7 +6718,8 @@ static void encode_superblock(VP9_COMP *cpi, ThreadData *td, TOKENEXTRA **t, · 4170 unmodified lines
67166718
67176719 ++td->counts->tx.tx_totals[mi->tx_size];
67186720 ++td->counts->tx.tx_totals[get_uv_tx_size(mi, &xd->plane[1])];
6719− if (cm->seg.enabled && cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ)
6721+ if (cm->seg.enabled && cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ &&
6722+ cpi->cyclic_refresh->content_mode)
67206723 vp9_cyclic_refresh_update_sb_postencode(cpi, mi, mi_row, mi_col, bsize);
67216724 if (cpi->oxcf.pass == 0 && cpi->svc.temporal_layer_id == 0 &&
67226725 (!cpi->use_svc ||
vp9/encoder/vp9_encoder.c+1−1
@@ -4208,7 +4208,7 @@ static int encode_without_recode_loop(VP9_COMP *cpi, size_t *size, · 4207 unmodified lines
42084208
42094209 // Update some stats from cyclic refresh, and check for golden frame update.
42104210 if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled &&
4211− !frame_is_intra_only(cm))
4211+ !frame_is_intra_only(cm) && cpi->cyclic_refresh->content_mode)
42124212 vp9_cyclic_refresh_postencode(cpi);
42134213
42144214 // Update the skip mb flag probabilities based on the distribution

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t