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
48 assert(MAXQ <= 255);48 assert(MAXQ <= 255);
49 memset(cr->last_coded_q_map, MAXQ, last_coded_q_map_size);49 memset(cr->last_coded_q_map, MAXQ, last_coded_q_map_size);
50 cr->counter_encode_maxq_scene_change = 0;50 cr->counter_encode_maxq_scene_change = 0;
51 cr->content_mode = 1;
51 return cr;52 return cr;
52}53}
53 54
@@ -326,7 +327,8 @@ void vp9_cyclic_refresh_set_golden_update(VP9_COMP *const cpi) { · 272 unmodified lines
326 else327 else
327 rc->baseline_gf_interval = 40;328 rc->baseline_gf_interval = 40;
328 if (cpi->oxcf.rc_mode == VPX_VBR) rc->baseline_gf_interval = 20;329 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)
330 rc->baseline_gf_interval = 10;332 rc->baseline_gf_interval = 10;
331}333}
332 334
@@ -388,7 +390,8 @@ static void cyclic_refresh_update_map(VP9_COMP *const cpi) { · 55 unmodified lines
388 ? vp9_get_qindex(&cm->seg, CR_SEGMENT_ID_BOOST2, cm->base_qindex)390 ? vp9_get_qindex(&cm->seg, CR_SEGMENT_ID_BOOST2, cm->base_qindex)
389 : vp9_get_qindex(&cm->seg, CR_SEGMENT_ID_BOOST1, cm->base_qindex);391 : vp9_get_qindex(&cm->seg, CR_SEGMENT_ID_BOOST1, cm->base_qindex);
390 // More aggressive settings for noisy content.392 // 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) {
392 consec_zero_mv_thresh = 60;395 consec_zero_mv_thresh = 60;
393 qindex_thresh =396 qindex_thresh =
394 VPXMAX(vp9_get_qindex(&cm->seg, CR_SEGMENT_ID_BOOST1, cm->base_qindex),397 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
409#if CONFIG_VP9_HIGHBITDEPTH412#if CONFIG_VP9_HIGHBITDEPTH
410 if (cpi->common.use_highbitdepth) compute_content = 0;413 if (cpi->common.use_highbitdepth) compute_content = 0;
411#endif414#endif
412 if (cpi->Last_Source == NULL ||415 if (cr->content_mode == 0 || cpi->Last_Source == NULL ||
413 cpi->Last_Source->y_width != cpi->Source->y_width ||416 cpi->Last_Source->y_width != cpi->Source->y_width ||
414 cpi->Last_Source->y_height != cpi->Source->y_height)417 cpi->Last_Source->y_height != cpi->Source->y_height)
415 compute_content = 0;418 compute_content = 0;
@@ -430,7 +433,8 @@ static void cyclic_refresh_update_map(VP9_COMP *const cpi) { · 14 unmodified lines
430 // reset to 0 later depending on the coding mode.433 // reset to 0 later depending on the coding mode.
431 if (cr->map[bl_index2] == 0) {434 if (cr->map[bl_index2] == 0) {
432 count_tot++;435 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 ||
434 cpi->consec_zero_mv[bl_index2] < consec_zero_mv_thresh_block) {438 cpi->consec_zero_mv[bl_index2] < consec_zero_mv_thresh_block) {
435 sum_map++;439 sum_map++;
436 count_sel++;440 count_sel++;
@@ -489,7 +493,8 @@ void vp9_cyclic_refresh_update_parameters(VP9_COMP *const cpi) { · 52 unmodified lines
489 rc->avg_frame_qindex[INTER_FRAME] < qp_thresh ||493 rc->avg_frame_qindex[INTER_FRAME] < qp_thresh ||
490 (cpi->use_svc &&494 (cpi->use_svc &&
491 cpi->svc.layer_context[cpi->svc.temporal_layer_id].is_key_frame) ||495 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 &&
493 rc->frames_since_key > 40) ||498 rc->frames_since_key > 40) ||
494 (!cpi->use_svc && rc->avg_frame_qindex[INTER_FRAME] > qp_max_thresh &&499 (!cpi->use_svc && rc->avg_frame_qindex[INTER_FRAME] > qp_max_thresh &&
495 rc->frames_since_key > 20)) {500 rc->frames_since_key > 20)) {
@@ -528,7 +533,7 @@ void vp9_cyclic_refresh_update_parameters(VP9_COMP *const cpi) { · 32 unmodified lines
528 cr->percent_refresh = (cr->skip_flat_static_blocks) ? 5 : 10;533 cr->percent_refresh = (cr->skip_flat_static_blocks) ? 5 : 10;
529 // Increase the amount of refresh on scene change that is encoded at max Q,534 // Increase the amount of refresh on scene change that is encoded at max Q,
530 // increase for a few cycles of the refresh period (~100 / percent_refresh).535 // 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)
532 cr->percent_refresh = (cr->skip_flat_static_blocks) ? 10 : 15;537 cr->percent_refresh = (cr->skip_flat_static_blocks) ? 10 : 15;
533 cr->rate_ratio_qdelta = 2.0;538 cr->rate_ratio_qdelta = 2.0;
534 cr->rate_boost_fac = 10;539 cr->rate_boost_fac = 10;
@@ -575,6 +580,12 @@ void vp9_cyclic_refresh_update_parameters(VP9_COMP *const cpi) { · 40 unmodified lines
575 (double)(cr->actual_num_seg1_blocks + cr->actual_num_seg2_blocks) /580 (double)(cr->actual_num_seg1_blocks + cr->actual_num_seg2_blocks) /
576 num8x8bl;581 num8x8bl;
577 cr->weight_segment = weight_segment;582 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 }
578}589}
579 590
580// Setup cyclic background refresh: set delta q and segmentation map.591// 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
70 int apply_cyclic_refresh;70 int apply_cyclic_refresh;
71 int counter_encode_maxq_scene_change;71 int counter_encode_maxq_scene_change;
72 int skip_flat_static_blocks;72 int skip_flat_static_blocks;
73 int content_mode;
73};74};
74 75
75struct VP9_COMP;76struct 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
1842 }1842 }
1843 // Else for cyclic refresh mode update the segment map, set the segment id1843 // Else for cyclic refresh mode update the segment map, set the segment id
1844 // and then update the quantizer.1844 // 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) {
1846 vp9_cyclic_refresh_update_segment(cpi, xd->mi[0], mi_row, mi_col, bsize,1847 vp9_cyclic_refresh_update_segment(cpi, xd->mi[0], mi_row, mi_col, bsize,
1847 ctx->rate, ctx->dist, x->skip, p);1848 ctx->rate, ctx->dist, x->skip, p);
1848 }1849 }
@@ -2539,7 +2540,8 @@ static void update_state_rt(VP9_COMP *cpi, ThreadData *td, · 690 unmodified lines
2539 2540
2540 if (seg->enabled && (cpi->oxcf.aq_mode != NO_AQ || cpi->roi.enabled)) {2541 if (seg->enabled && (cpi->oxcf.aq_mode != NO_AQ || cpi->roi.enabled)) {
2541 // Setting segmentation map for cyclic_refresh.2542 // 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) {
2543 vp9_cyclic_refresh_update_segment(cpi, mi, mi_row, mi_col, bsize,2545 vp9_cyclic_refresh_update_segment(cpi, mi, mi_row, mi_col, bsize,
2544 ctx->rate, ctx->dist, x->skip, p);2546 ctx->rate, ctx->dist, x->skip, p);
2545 } else {2547 } else {
@@ -6716,7 +6718,8 @@ static void encode_superblock(VP9_COMP *cpi, ThreadData *td, TOKENEXTRA **t, · 4170 unmodified lines
6716 6718
6717 ++td->counts->tx.tx_totals[mi->tx_size];6719 ++td->counts->tx.tx_totals[mi->tx_size];
6718 ++td->counts->tx.tx_totals[get_uv_tx_size(mi, &xd->plane[1])];6720 ++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)
6720 vp9_cyclic_refresh_update_sb_postencode(cpi, mi, mi_row, mi_col, bsize);6723 vp9_cyclic_refresh_update_sb_postencode(cpi, mi, mi_row, mi_col, bsize);
6721 if (cpi->oxcf.pass == 0 && cpi->svc.temporal_layer_id == 0 &&6724 if (cpi->oxcf.pass == 0 && cpi->svc.temporal_layer_id == 0 &&
6722 (!cpi->use_svc ||6725 (!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
4208 4208
4209 // Update some stats from cyclic refresh, and check for golden frame update.4209 // Update some stats from cyclic refresh, and check for golden frame update.
4210 if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled &&4210 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)
4212 vp9_cyclic_refresh_postencode(cpi);4212 vp9_cyclic_refresh_postencode(cpi);
4213 4213
4214 // Update the skip mb flag probabilities based on the distribution4214 // 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