2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
14 #include "vpx_dsp/vpx_dsp_common.h"
15 #include "vpx_ports/system_state.h"
17 #include "vp9/encoder/vp9_aq_cyclicrefresh.h"
19 #include "vp9/common/vp9_seg_common.h"
21 #include "vp9/encoder/vp9_ratectrl.h"
22 #include "vp9/encoder/vp9_segmentation.h"
24 CYCLIC_REFRESH *vp9_cyclic_refresh_alloc(int mi_rows, int mi_cols) {
25 size_t last_coded_q_map_size;
26 CYCLIC_REFRESH *const cr = vpx_calloc(1, sizeof(*cr));
30 cr->map = vpx_calloc(mi_rows * mi_cols, sizeof(*cr->map));
31 if (cr->map == NULL) {
35 last_coded_q_map_size = mi_rows * mi_cols * sizeof(*cr->last_coded_q_map);
36 cr->last_coded_q_map = vpx_malloc(last_coded_q_map_size);
37 if (cr->last_coded_q_map == NULL) {
42 memset(cr->last_coded_q_map, MAXQ, last_coded_q_map_size);
47 void vp9_cyclic_refresh_free(CYCLIC_REFRESH *cr) {
49 vpx_free(cr->last_coded_q_map);
53 // Check if we should turn off cyclic refresh based on bitrate condition.
54 static int apply_cyclic_refresh_bitrate(const VP9_COMMON *cm,
55 const RATE_CONTROL *rc) {
56 // Turn off cyclic refresh if bits available per frame is not sufficiently
57 // larger than bit cost of segmentation. Segment map bit cost should scale
58 // with number of seg blocks, so compare available bits to number of blocks.
59 // Average bits available per frame = avg_frame_bandwidth
60 // Number of (8x8) blocks in frame = mi_rows * mi_cols;
61 const float factor = 0.25;
62 const int number_blocks = cm->mi_rows * cm->mi_cols;
63 // The condition below corresponds to turning off at target bitrates:
64 // (at 30fps), ~12kbps for CIF, 36kbps for VGA, 100kps for HD/720p.
65 // Also turn off at very small frame sizes, to avoid too large fraction of
66 // superblocks to be refreshed per frame. Threshold below is less than QCIF.
67 if (rc->avg_frame_bandwidth < factor * number_blocks ||
68 number_blocks / 64 < 5)
74 // Check if this coding block, of size bsize, should be considered for refresh
75 // (lower-qp coding). Decision can be based on various factors, such as
76 // size of the coding block (i.e., below min_block size rejected), coding
77 // mode, and rate/distortion.
78 static int candidate_refresh_aq(const CYCLIC_REFRESH *cr,
79 const MB_MODE_INFO *mbmi,
83 MV mv = mbmi->mv[0].as_mv;
84 // Reject the block for lower-qp coding if projected distortion
85 // is above the threshold, and any of the following is true:
86 // 1) mode uses large mv
87 // 2) mode is an intra-mode
88 // Otherwise accept for refresh.
89 if (dist > cr->thresh_dist_sb &&
90 (mv.row > cr->motion_thresh || mv.row < -cr->motion_thresh ||
91 mv.col > cr->motion_thresh || mv.col < -cr->motion_thresh ||
92 !is_inter_block(mbmi)))
93 return CR_SEGMENT_ID_BASE;
94 else if (bsize >= BLOCK_16X16 &&
95 rate < cr->thresh_rate_sb &&
96 is_inter_block(mbmi) &&
97 mbmi->mv[0].as_int == 0 &&
98 cr->rate_boost_fac > 10)
99 // More aggressive delta-q for bigger blocks with zero motion.
100 return CR_SEGMENT_ID_BOOST2;
102 return CR_SEGMENT_ID_BOOST1;
105 // Compute delta-q for the segment.
106 static int compute_deltaq(const VP9_COMP *cpi, int q, double rate_factor) {
107 const CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
108 const RATE_CONTROL *const rc = &cpi->rc;
109 int deltaq = vp9_compute_qdelta_by_rate(rc, cpi->common.frame_type,
111 cpi->common.bit_depth);
112 if ((-deltaq) > cr->max_qdelta_perc * q / 100) {
113 deltaq = -cr->max_qdelta_perc * q / 100;
118 // For the just encoded frame, estimate the bits, incorporating the delta-q
119 // from non-base segment. For now ignore effect of multiple segments
120 // (with different delta-q). Note this function is called in the postencode
121 // (called from rc_update_rate_correction_factors()).
122 int vp9_cyclic_refresh_estimate_bits_at_q(const VP9_COMP *cpi,
123 double correction_factor) {
124 const VP9_COMMON *const cm = &cpi->common;
125 const CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
128 int num8x8bl = mbs << 2;
129 // Weight for non-base segments: use actual number of blocks refreshed in
130 // previous/just encoded frame. Note number of blocks here is in 8x8 units.
131 double weight_segment1 = (double)cr->actual_num_seg1_blocks / num8x8bl;
132 double weight_segment2 = (double)cr->actual_num_seg2_blocks / num8x8bl;
133 // Take segment weighted average for estimated bits.
134 estimated_bits = (int)((1.0 - weight_segment1 - weight_segment2) *
135 vp9_estimate_bits_at_q(cm->frame_type, cm->base_qindex, mbs,
136 correction_factor, cm->bit_depth) +
138 vp9_estimate_bits_at_q(cm->frame_type,
139 cm->base_qindex + cr->qindex_delta[1], mbs,
140 correction_factor, cm->bit_depth) +
142 vp9_estimate_bits_at_q(cm->frame_type,
143 cm->base_qindex + cr->qindex_delta[2], mbs,
144 correction_factor, cm->bit_depth));
145 return estimated_bits;
148 // Prior to encoding the frame, estimate the bits per mb, for a given q = i and
149 // a corresponding delta-q (for segment 1). This function is called in the
150 // rc_regulate_q() to set the base qp index.
151 // Note: the segment map is set to either 0/CR_SEGMENT_ID_BASE (no refresh) or
152 // to 1/CR_SEGMENT_ID_BOOST1 (refresh) for each superblock, prior to encoding.
153 int vp9_cyclic_refresh_rc_bits_per_mb(const VP9_COMP *cpi, int i,
154 double correction_factor) {
155 const VP9_COMMON *const cm = &cpi->common;
156 CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
158 int num8x8bl = cm->MBs << 2;
159 // Weight for segment prior to encoding: take the average of the target
160 // number for the frame to be encoded and the actual from the previous frame.
161 double weight_segment = (double)((cr->target_num_seg_blocks +
162 cr->actual_num_seg1_blocks + cr->actual_num_seg2_blocks) >> 1) /
164 // Compute delta-q corresponding to qindex i.
165 int deltaq = compute_deltaq(cpi, i, cr->rate_ratio_qdelta);
166 // Take segment weighted average for bits per mb.
167 bits_per_mb = (int)((1.0 - weight_segment) *
168 vp9_rc_bits_per_mb(cm->frame_type, i, correction_factor, cm->bit_depth) +
170 vp9_rc_bits_per_mb(cm->frame_type, i + deltaq, correction_factor,
175 // Prior to coding a given prediction block, of size bsize at (mi_row, mi_col),
176 // check if we should reset the segment_id, and update the cyclic_refresh map
177 // and segmentation map.
178 void vp9_cyclic_refresh_update_segment(VP9_COMP *const cpi,
179 MB_MODE_INFO *const mbmi,
180 int mi_row, int mi_col,
185 const VP9_COMMON *const cm = &cpi->common;
186 CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
187 const int bw = num_8x8_blocks_wide_lookup[bsize];
188 const int bh = num_8x8_blocks_high_lookup[bsize];
189 const int xmis = VPXMIN(cm->mi_cols - mi_col, bw);
190 const int ymis = VPXMIN(cm->mi_rows - mi_row, bh);
191 const int block_index = mi_row * cm->mi_cols + mi_col;
192 const int refresh_this_block = candidate_refresh_aq(cr, mbmi, rate, dist,
194 // Default is to not update the refresh map.
195 int new_map_value = cr->map[block_index];
196 int x = 0; int y = 0;
198 // If this block is labeled for refresh, check if we should reset the
200 if (cyclic_refresh_segment_id_boosted(mbmi->segment_id)) {
201 mbmi->segment_id = refresh_this_block;
202 // Reset segment_id if will be skipped.
204 mbmi->segment_id = CR_SEGMENT_ID_BASE;
207 // Update the cyclic refresh map, to be used for setting segmentation map
208 // for the next frame. If the block will be refreshed this frame, mark it
209 // as clean. The magnitude of the -ve influences how long before we consider
210 // it for refresh again.
211 if (cyclic_refresh_segment_id_boosted(mbmi->segment_id)) {
212 new_map_value = -cr->time_for_refresh;
213 } else if (refresh_this_block) {
214 // Else if it is accepted as candidate for refresh, and has not already
215 // been refreshed (marked as 1) then mark it as a candidate for cleanup
216 // for future time (marked as 0), otherwise don't update it.
217 if (cr->map[block_index] == 1)
220 // Leave it marked as block that is not candidate for refresh.
224 // Update entries in the cyclic refresh map with new_map_value, and
225 // copy mbmi->segment_id into global segmentation map.
226 for (y = 0; y < ymis; y++)
227 for (x = 0; x < xmis; x++) {
228 int map_offset = block_index + y * cm->mi_cols + x;
229 cr->map[map_offset] = new_map_value;
230 cpi->segmentation_map[map_offset] = mbmi->segment_id;
231 // Inter skip blocks were clearly not coded at the current qindex, so
232 // don't update the map for them. For cases where motion is non-zero or
233 // the reference frame isn't the previous frame, the previous value in
234 // the map for this spatial location is not entirely correct.
235 if ((!is_inter_block(mbmi) || !skip) &&
236 mbmi->segment_id <= CR_SEGMENT_ID_BOOST2) {
237 cr->last_coded_q_map[map_offset] = clamp(
238 cm->base_qindex + cr->qindex_delta[mbmi->segment_id], 0, MAXQ);
239 } else if (is_inter_block(mbmi) && skip &&
240 mbmi->segment_id <= CR_SEGMENT_ID_BOOST2) {
241 cr->last_coded_q_map[map_offset] = VPXMIN(
242 clamp(cm->base_qindex + cr->qindex_delta[mbmi->segment_id],
244 cr->last_coded_q_map[map_offset]);
249 // Update the actual number of blocks that were applied the segment delta q.
250 void vp9_cyclic_refresh_postencode(VP9_COMP *const cpi) {
251 VP9_COMMON *const cm = &cpi->common;
252 CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
253 unsigned char *const seg_map = cpi->segmentation_map;
255 cr->actual_num_seg1_blocks = 0;
256 cr->actual_num_seg2_blocks = 0;
257 for (mi_row = 0; mi_row < cm->mi_rows; mi_row++)
258 for (mi_col = 0; mi_col < cm->mi_cols; mi_col++) {
259 if (cyclic_refresh_segment_id(
260 seg_map[mi_row * cm->mi_cols + mi_col]) == CR_SEGMENT_ID_BOOST1)
261 cr->actual_num_seg1_blocks++;
262 else if (cyclic_refresh_segment_id(
263 seg_map[mi_row * cm->mi_cols + mi_col]) == CR_SEGMENT_ID_BOOST2)
264 cr->actual_num_seg2_blocks++;
268 // Set golden frame update interval, for non-svc 1 pass CBR mode.
269 void vp9_cyclic_refresh_set_golden_update(VP9_COMP *const cpi) {
270 RATE_CONTROL *const rc = &cpi->rc;
271 CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
272 // Set minimum gf_interval for GF update to a multiple (== 2) of refresh
273 // period. Depending on past encoding stats, GF flag may be reset and update
274 // may not occur until next baseline_gf_interval.
275 if (cr->percent_refresh > 0)
276 rc->baseline_gf_interval = 4 * (100 / cr->percent_refresh);
278 rc->baseline_gf_interval = 40;
281 // Update some encoding stats (from the just encoded frame). If this frame's
282 // background has high motion, refresh the golden frame. Otherwise, if the
283 // golden reference is to be updated check if we should NOT update the golden
285 void vp9_cyclic_refresh_check_golden_update(VP9_COMP *const cpi) {
286 VP9_COMMON *const cm = &cpi->common;
287 CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
289 double fraction_low = 0.0;
290 int low_content_frame = 0;
292 MODE_INFO **mi = cm->mi_grid_visible;
293 RATE_CONTROL *const rc = &cpi->rc;
294 const int rows = cm->mi_rows, cols = cm->mi_cols;
295 int cnt1 = 0, cnt2 = 0;
296 int force_gf_refresh = 0;
298 for (mi_row = 0; mi_row < rows; mi_row++) {
299 for (mi_col = 0; mi_col < cols; mi_col++) {
300 int16_t abs_mvr = mi[0]->mbmi.mv[0].as_mv.row >= 0 ?
301 mi[0]->mbmi.mv[0].as_mv.row : -1 * mi[0]->mbmi.mv[0].as_mv.row;
302 int16_t abs_mvc = mi[0]->mbmi.mv[0].as_mv.col >= 0 ?
303 mi[0]->mbmi.mv[0].as_mv.col : -1 * mi[0]->mbmi.mv[0].as_mv.col;
305 // Calculate the motion of the background.
306 if (abs_mvr <= 16 && abs_mvc <= 16) {
308 if (abs_mvr == 0 && abs_mvc == 0)
313 // Accumulate low_content_frame.
314 if (cr->map[mi_row * cols + mi_col] < 1)
320 // For video conference clips, if the background has high motion in current
321 // frame because of the camera movement, set this frame as the golden frame.
322 // Use 70% and 5% as the thresholds for golden frame refreshing.
323 // Also, force this frame as a golden update frame if this frame will change
324 // the resolution (resize_pending != 0).
325 if (cpi->resize_pending != 0 ||
326 (cnt1 * 10 > (70 * rows * cols) && cnt2 * 20 < cnt1)) {
327 vp9_cyclic_refresh_set_golden_update(cpi);
328 rc->frames_till_gf_update_due = rc->baseline_gf_interval;
330 if (rc->frames_till_gf_update_due > rc->frames_to_key)
331 rc->frames_till_gf_update_due = rc->frames_to_key;
332 cpi->refresh_golden_frame = 1;
333 force_gf_refresh = 1;
337 (double)low_content_frame / (rows * cols);
339 cr->low_content_avg = (fraction_low + 3 * cr->low_content_avg) / 4;
340 if (!force_gf_refresh && cpi->refresh_golden_frame == 1) {
341 // Don't update golden reference if the amount of low_content for the
342 // current encoded frame is small, or if the recursive average of the
343 // low_content over the update interval window falls below threshold.
344 if (fraction_low < 0.8 || cr->low_content_avg < 0.7)
345 cpi->refresh_golden_frame = 0;
346 // Reset for next internal.
347 cr->low_content_avg = fraction_low;
351 // Update the segmentation map, and related quantities: cyclic refresh map,
352 // refresh sb_index, and target number of blocks to be refreshed.
353 // The map is set to either 0/CR_SEGMENT_ID_BASE (no refresh) or to
354 // 1/CR_SEGMENT_ID_BOOST1 (refresh) for each superblock.
355 // Blocks labeled as BOOST1 may later get set to BOOST2 (during the
356 // encoding of the superblock).
357 static void cyclic_refresh_update_map(VP9_COMP *const cpi) {
358 VP9_COMMON *const cm = &cpi->common;
359 CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
360 unsigned char *const seg_map = cpi->segmentation_map;
361 int i, block_count, bl_index, sb_rows, sb_cols, sbs_in_frame;
362 int xmis, ymis, x, y;
363 memset(seg_map, CR_SEGMENT_ID_BASE, cm->mi_rows * cm->mi_cols);
364 sb_cols = (cm->mi_cols + MI_BLOCK_SIZE - 1) / MI_BLOCK_SIZE;
365 sb_rows = (cm->mi_rows + MI_BLOCK_SIZE - 1) / MI_BLOCK_SIZE;
366 sbs_in_frame = sb_cols * sb_rows;
367 // Number of target blocks to get the q delta (segment 1).
368 block_count = cr->percent_refresh * cm->mi_rows * cm->mi_cols / 100;
369 // Set the segmentation map: cycle through the superblocks, starting at
370 // cr->mb_index, and stopping when either block_count blocks have been found
371 // to be refreshed, or we have passed through whole frame.
372 assert(cr->sb_index < sbs_in_frame);
374 cr->target_num_seg_blocks = 0;
377 // Get the mi_row/mi_col corresponding to superblock index i.
378 int sb_row_index = (i / sb_cols);
379 int sb_col_index = i - sb_row_index * sb_cols;
380 int mi_row = sb_row_index * MI_BLOCK_SIZE;
381 int mi_col = sb_col_index * MI_BLOCK_SIZE;
383 cpi->oxcf.content == VP9E_CONTENT_SCREEN
384 ? vp9_get_qindex(&cm->seg, CR_SEGMENT_ID_BOOST2, cm->base_qindex)
386 assert(mi_row >= 0 && mi_row < cm->mi_rows);
387 assert(mi_col >= 0 && mi_col < cm->mi_cols);
388 bl_index = mi_row * cm->mi_cols + mi_col;
389 // Loop through all 8x8 blocks in superblock and update map.
391 VPXMIN(cm->mi_cols - mi_col, num_8x8_blocks_wide_lookup[BLOCK_64X64]);
393 VPXMIN(cm->mi_rows - mi_row, num_8x8_blocks_high_lookup[BLOCK_64X64]);
394 for (y = 0; y < ymis; y++) {
395 for (x = 0; x < xmis; x++) {
396 const int bl_index2 = bl_index + y * cm->mi_cols + x;
397 // If the block is as a candidate for clean up then mark it
398 // for possible boost/refresh (segment 1). The segment id may get
399 // reset to 0 later if block gets coded anything other than ZEROMV.
400 if (cr->map[bl_index2] == 0) {
401 if (cr->last_coded_q_map[bl_index2] > qindex_thresh)
403 } else if (cr->map[bl_index2] < 0) {
404 cr->map[bl_index2]++;
408 // Enforce constant segment over superblock.
409 // If segment is at least half of superblock, set to 1.
410 if (sum_map >= xmis * ymis / 2) {
411 for (y = 0; y < ymis; y++)
412 for (x = 0; x < xmis; x++) {
413 seg_map[bl_index + y * cm->mi_cols + x] = CR_SEGMENT_ID_BOOST1;
415 cr->target_num_seg_blocks += xmis * ymis;
418 if (i == sbs_in_frame) {
421 } while (cr->target_num_seg_blocks < block_count && i != cr->sb_index);
425 // Set cyclic refresh parameters.
426 void vp9_cyclic_refresh_update_parameters(VP9_COMP *const cpi) {
427 const RATE_CONTROL *const rc = &cpi->rc;
428 const VP9_COMMON *const cm = &cpi->common;
429 CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
430 cr->percent_refresh = 10;
431 cr->max_qdelta_perc = 50;
432 cr->time_for_refresh = 0;
433 // Use larger delta-qp (increase rate_ratio_qdelta) for first few (~4)
434 // periods of the refresh cycle, after a key frame.
435 // Account for larger interval on base layer for temporal layers.
436 if (cr->percent_refresh > 0 &&
437 rc->frames_since_key < (4 * cpi->svc.number_temporal_layers) *
438 (100 / cr->percent_refresh))
439 cr->rate_ratio_qdelta = 3.0;
441 cr->rate_ratio_qdelta = 2.0;
442 // Adjust some parameters for low resolutions at low bitrates.
443 if (cm->width <= 352 &&
445 rc->avg_frame_bandwidth < 3400) {
446 cr->motion_thresh = 4;
447 cr->rate_boost_fac = 10;
449 cr->motion_thresh = 32;
450 cr->rate_boost_fac = 17;
452 if (cpi->svc.spatial_layer_id > 0) {
453 cr->motion_thresh = 4;
454 cr->rate_boost_fac = 12;
458 // Setup cyclic background refresh: set delta q and segmentation map.
459 void vp9_cyclic_refresh_setup(VP9_COMP *const cpi) {
460 VP9_COMMON *const cm = &cpi->common;
461 const RATE_CONTROL *const rc = &cpi->rc;
462 CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
463 struct segmentation *const seg = &cm->seg;
464 const int apply_cyclic_refresh = apply_cyclic_refresh_bitrate(cm, rc);
465 if (cm->current_video_frame == 0)
466 cr->low_content_avg = 0.0;
467 // Don't apply refresh on key frame or temporal enhancement layer frames.
468 if (!apply_cyclic_refresh ||
469 (cm->frame_type == KEY_FRAME) ||
470 (cpi->svc.temporal_layer_id > 0)) {
471 // Set segmentation map to 0 and disable.
472 unsigned char *const seg_map = cpi->segmentation_map;
473 memset(seg_map, 0, cm->mi_rows * cm->mi_cols);
474 vp9_disable_segmentation(&cm->seg);
475 if (cm->frame_type == KEY_FRAME) {
476 memset(cr->last_coded_q_map, MAXQ,
477 cm->mi_rows * cm->mi_cols * sizeof(*cr->last_coded_q_map));
482 int qindex_delta = 0;
484 const double q = vp9_convert_qindex_to_q(cm->base_qindex, cm->bit_depth);
485 vpx_clear_system_state();
486 // Set rate threshold to some multiple (set to 2 for now) of the target
487 // rate (target is given by sb64_target_rate and scaled by 256).
488 cr->thresh_rate_sb = ((int64_t)(rc->sb64_target_rate) << 8) << 2;
489 // Distortion threshold, quadratic in Q, scale factor to be adjusted.
490 // q will not exceed 457, so (q * q) is within 32bit; see:
491 // vp9_convert_qindex_to_q(), vp9_ac_quant(), ac_qlookup*[].
492 cr->thresh_dist_sb = ((int64_t)(q * q)) << 2;
494 // Set up segmentation.
495 // Clear down the segment map.
496 vp9_enable_segmentation(&cm->seg);
497 vp9_clearall_segfeatures(seg);
498 // Select delta coding method.
499 seg->abs_delta = SEGMENT_DELTADATA;
501 // Note: setting temporal_update has no effect, as the seg-map coding method
502 // (temporal or spatial) is determined in vp9_choose_segmap_coding_method(),
503 // based on the coding cost of each method. For error_resilient mode on the
504 // last_frame_seg_map is set to 0, so if temporal coding is used, it is
505 // relative to 0 previous map.
506 // seg->temporal_update = 0;
508 // Segment BASE "Q" feature is disabled so it defaults to the baseline Q.
509 vp9_disable_segfeature(seg, CR_SEGMENT_ID_BASE, SEG_LVL_ALT_Q);
510 // Use segment BOOST1 for in-frame Q adjustment.
511 vp9_enable_segfeature(seg, CR_SEGMENT_ID_BOOST1, SEG_LVL_ALT_Q);
512 // Use segment BOOST2 for more aggressive in-frame Q adjustment.
513 vp9_enable_segfeature(seg, CR_SEGMENT_ID_BOOST2, SEG_LVL_ALT_Q);
515 // Set the q delta for segment BOOST1.
516 qindex_delta = compute_deltaq(cpi, cm->base_qindex, cr->rate_ratio_qdelta);
517 cr->qindex_delta[1] = qindex_delta;
519 // Compute rd-mult for segment BOOST1.
520 qindex2 = clamp(cm->base_qindex + cm->y_dc_delta_q + qindex_delta, 0, MAXQ);
522 cr->rdmult = vp9_compute_rd_mult(cpi, qindex2);
524 vp9_set_segdata(seg, CR_SEGMENT_ID_BOOST1, SEG_LVL_ALT_Q, qindex_delta);
526 // Set a more aggressive (higher) q delta for segment BOOST2.
527 qindex_delta = compute_deltaq(
528 cpi, cm->base_qindex,
529 VPXMIN(CR_MAX_RATE_TARGET_RATIO,
530 0.1 * cr->rate_boost_fac * cr->rate_ratio_qdelta));
531 cr->qindex_delta[2] = qindex_delta;
532 vp9_set_segdata(seg, CR_SEGMENT_ID_BOOST2, SEG_LVL_ALT_Q, qindex_delta);
534 // Update the segmentation and refresh map.
535 cyclic_refresh_update_map(cpi);
539 int vp9_cyclic_refresh_get_rdmult(const CYCLIC_REFRESH *cr) {
543 void vp9_cyclic_refresh_reset_resize(VP9_COMP *const cpi) {
544 const VP9_COMMON *const cm = &cpi->common;
545 CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
546 memset(cr->map, 0, cm->mi_rows * cm->mi_cols);
548 cpi->refresh_golden_frame = 1;