Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c

Issue 1029663003: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 12 matching lines...) Expand all
23 // for cyclic refresh. 23 // for cyclic refresh.
24 int percent_refresh; 24 int percent_refresh;
25 // Maximum q-delta as percentage of base q. 25 // Maximum q-delta as percentage of base q.
26 int max_qdelta_perc; 26 int max_qdelta_perc;
27 // Superblock starting index for cycling through the frame. 27 // Superblock starting index for cycling through the frame.
28 int sb_index; 28 int sb_index;
29 // Controls how long block will need to wait to be refreshed again, in 29 // Controls how long block will need to wait to be refreshed again, in
30 // excess of the cycle time, i.e., in the case of all zero motion, block 30 // excess of the cycle time, i.e., in the case of all zero motion, block
31 // will be refreshed every (100/percent_refresh + time_for_refresh) frames. 31 // will be refreshed every (100/percent_refresh + time_for_refresh) frames.
32 int time_for_refresh; 32 int time_for_refresh;
33 // // Target number of (8x8) blocks that are set for delta-q (segment 1). 33 // Target number of (8x8) blocks that are set for delta-q.
34 int target_num_seg_blocks; 34 int target_num_seg_blocks;
35 // Actual number of (8x8) blocks that were applied delta-q (segment 1). 35 // Actual number of (8x8) blocks that were applied delta-q.
36 int actual_num_seg_blocks; 36 int actual_num_seg1_blocks;
37 int actual_num_seg2_blocks;
37 // RD mult. parameters for segment 1. 38 // RD mult. parameters for segment 1.
38 int rdmult; 39 int rdmult;
39 // Cyclic refresh map. 40 // Cyclic refresh map.
40 signed char *map; 41 signed char *map;
41 // Thresholds applied to the projected rate/distortion of the coding block, 42 // Thresholds applied to the projected rate/distortion of the coding block,
42 // when deciding whether block should be refreshed. 43 // when deciding whether block should be refreshed.
43 int64_t thresh_rate_sb; 44 int64_t thresh_rate_sb;
44 int64_t thresh_dist_sb; 45 int64_t thresh_dist_sb;
45 // Threshold applied to the motion vector (in units of 1/8 pel) of the 46 // Threshold applied to the motion vector (in units of 1/8 pel) of the
46 // coding block, when deciding whether block should be refreshed. 47 // coding block, when deciding whether block should be refreshed.
47 int16_t motion_thresh; 48 int16_t motion_thresh;
48 // Rate target ratio to set q delta. 49 // Rate target ratio to set q delta.
49 double rate_ratio_qdelta; 50 double rate_ratio_qdelta;
50 double low_content_avg; 51 double low_content_avg;
52 int qindex_delta_seg1;
53 int qindex_delta_seg2;
51 }; 54 };
52 55
53 CYCLIC_REFRESH *vp9_cyclic_refresh_alloc(int mi_rows, int mi_cols) { 56 CYCLIC_REFRESH *vp9_cyclic_refresh_alloc(int mi_rows, int mi_cols) {
54 CYCLIC_REFRESH *const cr = vpx_calloc(1, sizeof(*cr)); 57 CYCLIC_REFRESH *const cr = vpx_calloc(1, sizeof(*cr));
55 if (cr == NULL) 58 if (cr == NULL)
56 return NULL; 59 return NULL;
57 60
58 cr->map = vpx_calloc(mi_rows * mi_cols, sizeof(*cr->map)); 61 cr->map = vpx_calloc(mi_rows * mi_cols, sizeof(*cr->map));
59 if (cr->map == NULL) { 62 if (cr->map == NULL) {
60 vpx_free(cr); 63 vpx_free(cr);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // Reject the block for lower-qp coding if projected distortion 106 // Reject the block for lower-qp coding if projected distortion
104 // is above the threshold, and any of the following is true: 107 // is above the threshold, and any of the following is true:
105 // 1) mode uses large mv 108 // 1) mode uses large mv
106 // 2) mode is an intra-mode 109 // 2) mode is an intra-mode
107 // Otherwise accept for refresh. 110 // Otherwise accept for refresh.
108 if (dist > cr->thresh_dist_sb && 111 if (dist > cr->thresh_dist_sb &&
109 (mv.row > cr->motion_thresh || mv.row < -cr->motion_thresh || 112 (mv.row > cr->motion_thresh || mv.row < -cr->motion_thresh ||
110 mv.col > cr->motion_thresh || mv.col < -cr->motion_thresh || 113 mv.col > cr->motion_thresh || mv.col < -cr->motion_thresh ||
111 !is_inter_block(mbmi))) 114 !is_inter_block(mbmi)))
112 return CR_SEGMENT_ID_BASE; 115 return CR_SEGMENT_ID_BASE;
113 else if (bsize >= BLOCK_32X32 && 116 else if (bsize >= BLOCK_16X16 &&
114 rate < cr->thresh_rate_sb && 117 rate < cr->thresh_rate_sb &&
115 is_inter_block(mbmi) && 118 is_inter_block(mbmi) &&
116 mbmi->mv[0].as_int == 0) 119 mbmi->mv[0].as_int == 0)
117 // More aggressive delta-q for bigger blocks with zero motion. 120 // More aggressive delta-q for bigger blocks with zero motion.
118 return CR_SEGMENT_ID_BOOST2; 121 return CR_SEGMENT_ID_BOOST2;
119 else 122 else
120 return CR_SEGMENT_ID_BOOST1; 123 return CR_SEGMENT_ID_BOOST1;
121 } 124 }
122 125
123 // Compute delta-q for the segment. 126 // Compute delta-q for the segment.
(...skipping 15 matching lines...) Expand all
139 // (called from rc_update_rate_correction_factors()). 142 // (called from rc_update_rate_correction_factors()).
140 int vp9_cyclic_refresh_estimate_bits_at_q(const VP9_COMP *cpi, 143 int vp9_cyclic_refresh_estimate_bits_at_q(const VP9_COMP *cpi,
141 double correction_factor) { 144 double correction_factor) {
142 const VP9_COMMON *const cm = &cpi->common; 145 const VP9_COMMON *const cm = &cpi->common;
143 const CYCLIC_REFRESH *const cr = cpi->cyclic_refresh; 146 const CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
144 int estimated_bits; 147 int estimated_bits;
145 int mbs = cm->MBs; 148 int mbs = cm->MBs;
146 int num8x8bl = mbs << 2; 149 int num8x8bl = mbs << 2;
147 // Weight for non-base segments: use actual number of blocks refreshed in 150 // Weight for non-base segments: use actual number of blocks refreshed in
148 // previous/just encoded frame. Note number of blocks here is in 8x8 units. 151 // previous/just encoded frame. Note number of blocks here is in 8x8 units.
149 double weight_segment = (double)cr->actual_num_seg_blocks / num8x8bl; 152 double weight_segment1 = (double)cr->actual_num_seg1_blocks / num8x8bl;
150 // Compute delta-q that was used in the just encoded frame. 153 double weight_segment2 = (double)cr->actual_num_seg2_blocks / num8x8bl;
151 int deltaq = compute_deltaq(cpi, cm->base_qindex, cr->rate_ratio_qdelta);
152 // Take segment weighted average for estimated bits. 154 // Take segment weighted average for estimated bits.
153 estimated_bits = (int)((1.0 - weight_segment) * 155 estimated_bits = (int)((1.0 - weight_segment1 - weight_segment2) *
154 vp9_estimate_bits_at_q(cm->frame_type, cm->base_qindex, mbs, 156 vp9_estimate_bits_at_q(cm->frame_type, cm->base_qindex, mbs,
155 correction_factor, cm->bit_depth) + 157 correction_factor, cm->bit_depth) +
156 weight_segment * 158 weight_segment1 *
157 vp9_estimate_bits_at_q(cm->frame_type, cm->base_qindex + deltaq, mbs, 159 vp9_estimate_bits_at_q(cm->frame_type,
160 cm->base_qindex + cr->qindex_delta_seg1, mbs,
161 correction_factor, cm->bit_depth) +
162 weight_segment2 *
163 vp9_estimate_bits_at_q(cm->frame_type,
164 cm->base_qindex + cr->qindex_delta_seg2, mbs,
158 correction_factor, cm->bit_depth)); 165 correction_factor, cm->bit_depth));
159 return estimated_bits; 166 return estimated_bits;
160 } 167 }
161 168
162 // Prior to encoding the frame, estimate the bits per mb, for a given q = i and 169 // Prior to encoding the frame, estimate the bits per mb, for a given q = i and
163 // a corresponding delta-q (for segment 1). This function is called in the 170 // a corresponding delta-q (for segment 1). This function is called in the
164 // rc_regulate_q() to set the base qp index. 171 // rc_regulate_q() to set the base qp index.
165 // Note: the segment map is set to either 0/CR_SEGMENT_ID_BASE (no refresh) or 172 // Note: the segment map is set to either 0/CR_SEGMENT_ID_BASE (no refresh) or
166 // to 1/CR_SEGMENT_ID_BOOST1 (refresh) for each superblock, prior to encoding. 173 // to 1/CR_SEGMENT_ID_BOOST1 (refresh) for each superblock, prior to encoding.
167 int vp9_cyclic_refresh_rc_bits_per_mb(const VP9_COMP *cpi, int i, 174 int vp9_cyclic_refresh_rc_bits_per_mb(const VP9_COMP *cpi, int i,
168 double correction_factor) { 175 double correction_factor) {
169 const VP9_COMMON *const cm = &cpi->common; 176 const VP9_COMMON *const cm = &cpi->common;
170 CYCLIC_REFRESH *const cr = cpi->cyclic_refresh; 177 CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
171 int bits_per_mb; 178 int bits_per_mb;
172 int num8x8bl = cm->MBs << 2; 179 int num8x8bl = cm->MBs << 2;
173 // Weight for segment 1 prior to encoding: take the target number for the 180 // Weight for segment prior to encoding: take the average of the target
174 // frame to be encoded. Number of blocks here is in 8x8 units. 181 // number for the frame to be encoded and the actual from the previous frame.
175 // Note that this is called in rc_regulate_q, which is called before the 182 double weight_segment = (double)((cr->target_num_seg_blocks +
176 // cyclic_refresh_setup (which sets cr->target_num_seg_blocks). So a mismatch 183 cr->actual_num_seg1_blocks + cr->actual_num_seg2_blocks) >> 1) /
177 // may occur between the cr->target_num_seg_blocks value here and the 184 num8x8bl;
178 // cr->target_num_seg_block set for encoding the frame. For the current use
179 // case of fixed cr->percent_refresh and cr->time_for_refresh = 0, mismatch
180 // does not occur/is very small.
181 double weight_segment = (double)cr->target_num_seg_blocks / num8x8bl;
182 // Compute delta-q corresponding to qindex i. 185 // Compute delta-q corresponding to qindex i.
183 int deltaq = compute_deltaq(cpi, i, cr->rate_ratio_qdelta); 186 int deltaq = compute_deltaq(cpi, i, cr->rate_ratio_qdelta);
184 // Take segment weighted average for bits per mb. 187 // Take segment weighted average for bits per mb.
185 bits_per_mb = (int)((1.0 - weight_segment) * 188 bits_per_mb = (int)((1.0 - weight_segment) *
186 vp9_rc_bits_per_mb(cm->frame_type, i, correction_factor, cm->bit_depth) + 189 vp9_rc_bits_per_mb(cm->frame_type, i, correction_factor, cm->bit_depth) +
187 weight_segment * 190 weight_segment *
188 vp9_rc_bits_per_mb(cm->frame_type, i + deltaq, correction_factor, 191 vp9_rc_bits_per_mb(cm->frame_type, i + deltaq, correction_factor,
189 cm->bit_depth)); 192 cm->bit_depth));
190 return bits_per_mb; 193 return bits_per_mb;
191 } 194 }
192 195
193 // Prior to coding a given prediction block, of size bsize at (mi_row, mi_col), 196 // Prior to coding a given prediction block, of size bsize at (mi_row, mi_col),
194 // check if we should reset the segment_id, and update the cyclic_refresh map 197 // check if we should reset the segment_id, and update the cyclic_refresh map
195 // and segmentation map. 198 // and segmentation map.
196 void vp9_cyclic_refresh_update_segment(VP9_COMP *const cpi, 199 void vp9_cyclic_refresh_update_segment(VP9_COMP *const cpi,
197 MB_MODE_INFO *const mbmi, 200 MB_MODE_INFO *const mbmi,
198 int mi_row, int mi_col, 201 int mi_row, int mi_col,
199 BLOCK_SIZE bsize, 202 BLOCK_SIZE bsize,
200 int64_t rate, 203 int64_t rate,
201 int64_t dist) { 204 int64_t dist,
205 int skip) {
202 const VP9_COMMON *const cm = &cpi->common; 206 const VP9_COMMON *const cm = &cpi->common;
203 CYCLIC_REFRESH *const cr = cpi->cyclic_refresh; 207 CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
204 const int bw = num_8x8_blocks_wide_lookup[bsize]; 208 const int bw = num_8x8_blocks_wide_lookup[bsize];
205 const int bh = num_8x8_blocks_high_lookup[bsize]; 209 const int bh = num_8x8_blocks_high_lookup[bsize];
206 const int xmis = MIN(cm->mi_cols - mi_col, bw); 210 const int xmis = MIN(cm->mi_cols - mi_col, bw);
207 const int ymis = MIN(cm->mi_rows - mi_row, bh); 211 const int ymis = MIN(cm->mi_rows - mi_row, bh);
208 const int block_index = mi_row * cm->mi_cols + mi_col; 212 const int block_index = mi_row * cm->mi_cols + mi_col;
209 const int refresh_this_block = candidate_refresh_aq(cr, mbmi, rate, dist, 213 const int refresh_this_block = candidate_refresh_aq(cr, mbmi, rate, dist,
210 bsize); 214 bsize);
211 // Default is to not update the refresh map. 215 // Default is to not update the refresh map.
212 int new_map_value = cr->map[block_index]; 216 int new_map_value = cr->map[block_index];
213 int x = 0; int y = 0; 217 int x = 0; int y = 0;
214 218
215 // If this block is labeled for refresh, check if we should reset the 219 // If this block is labeled for refresh, check if we should reset the
216 // segment_id. 220 // segment_id.
217 if (cyclic_refresh_segment_id_boosted(mbmi->segment_id)) 221 if (cyclic_refresh_segment_id_boosted(mbmi->segment_id)) {
218 mbmi->segment_id = refresh_this_block; 222 mbmi->segment_id = refresh_this_block;
223 // Reset segment_id if will be skipped.
224 if (skip)
225 mbmi->segment_id = CR_SEGMENT_ID_BASE;
226 }
219 227
220 // Update the cyclic refresh map, to be used for setting segmentation map 228 // Update the cyclic refresh map, to be used for setting segmentation map
221 // for the next frame. If the block will be refreshed this frame, mark it 229 // for the next frame. If the block will be refreshed this frame, mark it
222 // as clean. The magnitude of the -ve influences how long before we consider 230 // as clean. The magnitude of the -ve influences how long before we consider
223 // it for refresh again. 231 // it for refresh again.
224 if (cyclic_refresh_segment_id_boosted(mbmi->segment_id)) { 232 if (cyclic_refresh_segment_id_boosted(mbmi->segment_id)) {
225 new_map_value = -cr->time_for_refresh; 233 new_map_value = -cr->time_for_refresh;
226 } else if (refresh_this_block) { 234 } else if (refresh_this_block) {
227 // Else if it is accepted as candidate for refresh, and has not already 235 // Else if it is accepted as candidate for refresh, and has not already
228 // been refreshed (marked as 1) then mark it as a candidate for cleanup 236 // been refreshed (marked as 1) then mark it as a candidate for cleanup
(...skipping 14 matching lines...) Expand all
243 mbmi->segment_id; 251 mbmi->segment_id;
244 } 252 }
245 } 253 }
246 254
247 // Update the actual number of blocks that were applied the segment delta q. 255 // Update the actual number of blocks that were applied the segment delta q.
248 void vp9_cyclic_refresh_postencode(VP9_COMP *const cpi) { 256 void vp9_cyclic_refresh_postencode(VP9_COMP *const cpi) {
249 VP9_COMMON *const cm = &cpi->common; 257 VP9_COMMON *const cm = &cpi->common;
250 CYCLIC_REFRESH *const cr = cpi->cyclic_refresh; 258 CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
251 unsigned char *const seg_map = cpi->segmentation_map; 259 unsigned char *const seg_map = cpi->segmentation_map;
252 int mi_row, mi_col; 260 int mi_row, mi_col;
253 cr->actual_num_seg_blocks = 0; 261 cr->actual_num_seg1_blocks = 0;
262 cr->actual_num_seg2_blocks = 0;
254 for (mi_row = 0; mi_row < cm->mi_rows; mi_row++) 263 for (mi_row = 0; mi_row < cm->mi_rows; mi_row++)
255 for (mi_col = 0; mi_col < cm->mi_cols; mi_col++) { 264 for (mi_col = 0; mi_col < cm->mi_cols; mi_col++) {
256 if (cyclic_refresh_segment_id_boosted( 265 if (cyclic_refresh_segment_id(
257 seg_map[mi_row * cm->mi_cols + mi_col])) 266 seg_map[mi_row * cm->mi_cols + mi_col]) == CR_SEGMENT_ID_BOOST1)
258 cr->actual_num_seg_blocks++; 267 cr->actual_num_seg1_blocks++;
268 else if (cyclic_refresh_segment_id(
269 seg_map[mi_row * cm->mi_cols + mi_col]) == CR_SEGMENT_ID_BOOST2)
270 cr->actual_num_seg2_blocks++;
259 } 271 }
260 } 272 }
261 273
262 // Set golden frame update interval, for non-svc 1 pass CBR mode. 274 // Set golden frame update interval, for non-svc 1 pass CBR mode.
263 void vp9_cyclic_refresh_set_golden_update(VP9_COMP *const cpi) { 275 void vp9_cyclic_refresh_set_golden_update(VP9_COMP *const cpi) {
264 RATE_CONTROL *const rc = &cpi->rc; 276 RATE_CONTROL *const rc = &cpi->rc;
265 CYCLIC_REFRESH *const cr = cpi->cyclic_refresh; 277 CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
266 // Set minimum gf_interval for GF update to a multiple (== 2) of refresh 278 // Set minimum gf_interval for GF update to a multiple (== 2) of refresh
267 // period. Depending on past encoding stats, GF flag may be reset and update 279 // period. Depending on past encoding stats, GF flag may be reset and update
268 // may not occur until next baseline_gf_interval. 280 // may not occur until next baseline_gf_interval.
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 return; 418 return;
407 } else { 419 } else {
408 int qindex_delta = 0; 420 int qindex_delta = 0;
409 int qindex2; 421 int qindex2;
410 const double q = vp9_convert_qindex_to_q(cm->base_qindex, cm->bit_depth); 422 const double q = vp9_convert_qindex_to_q(cm->base_qindex, cm->bit_depth);
411 vp9_clear_system_state(); 423 vp9_clear_system_state();
412 cr->max_qdelta_perc = 50; 424 cr->max_qdelta_perc = 50;
413 cr->time_for_refresh = 0; 425 cr->time_for_refresh = 0;
414 // Set rate threshold to some multiple (set to 2 for now) of the target 426 // Set rate threshold to some multiple (set to 2 for now) of the target
415 // rate (target is given by sb64_target_rate and scaled by 256). 427 // rate (target is given by sb64_target_rate and scaled by 256).
416 cr->thresh_rate_sb = ((int64_t)(rc->sb64_target_rate) << 8) << 1; 428 cr->thresh_rate_sb = ((int64_t)(rc->sb64_target_rate) << 8) << 2;
417 // Distortion threshold, quadratic in Q, scale factor to be adjusted. 429 // Distortion threshold, quadratic in Q, scale factor to be adjusted.
418 // q will not exceed 457, so (q * q) is within 32bit; see: 430 // q will not exceed 457, so (q * q) is within 32bit; see:
419 // vp9_convert_qindex_to_q(), vp9_ac_quant(), ac_qlookup*[]. 431 // vp9_convert_qindex_to_q(), vp9_ac_quant(), ac_qlookup*[].
420 cr->thresh_dist_sb = ((int64_t)(q * q)) << 2; 432 cr->thresh_dist_sb = ((int64_t)(q * q)) << 2;
421 cr->motion_thresh = 32; 433 cr->motion_thresh = 32;
422 // Set up segmentation. 434 // Set up segmentation.
423 // Clear down the segment map. 435 // Clear down the segment map.
424 vp9_enable_segmentation(&cm->seg); 436 vp9_enable_segmentation(&cm->seg);
425 vp9_clearall_segfeatures(seg); 437 vp9_clearall_segfeatures(seg);
426 // Select delta coding method. 438 // Select delta coding method.
427 seg->abs_delta = SEGMENT_DELTADATA; 439 seg->abs_delta = SEGMENT_DELTADATA;
428 440
429 // Note: setting temporal_update has no effect, as the seg-map coding method 441 // Note: setting temporal_update has no effect, as the seg-map coding method
430 // (temporal or spatial) is determined in vp9_choose_segmap_coding_method(), 442 // (temporal or spatial) is determined in vp9_choose_segmap_coding_method(),
431 // based on the coding cost of each method. For error_resilient mode on the 443 // based on the coding cost of each method. For error_resilient mode on the
432 // last_frame_seg_map is set to 0, so if temporal coding is used, it is 444 // last_frame_seg_map is set to 0, so if temporal coding is used, it is
433 // relative to 0 previous map. 445 // relative to 0 previous map.
434 // seg->temporal_update = 0; 446 // seg->temporal_update = 0;
435 447
436 // Segment BASE "Q" feature is disabled so it defaults to the baseline Q. 448 // Segment BASE "Q" feature is disabled so it defaults to the baseline Q.
437 vp9_disable_segfeature(seg, CR_SEGMENT_ID_BASE, SEG_LVL_ALT_Q); 449 vp9_disable_segfeature(seg, CR_SEGMENT_ID_BASE, SEG_LVL_ALT_Q);
438 // Use segment BOOST1 for in-frame Q adjustment. 450 // Use segment BOOST1 for in-frame Q adjustment.
439 vp9_enable_segfeature(seg, CR_SEGMENT_ID_BOOST1, SEG_LVL_ALT_Q); 451 vp9_enable_segfeature(seg, CR_SEGMENT_ID_BOOST1, SEG_LVL_ALT_Q);
440 // Use segment BOOST2 for more aggressive in-frame Q adjustment. 452 // Use segment BOOST2 for more aggressive in-frame Q adjustment.
441 vp9_enable_segfeature(seg, CR_SEGMENT_ID_BOOST2, SEG_LVL_ALT_Q); 453 vp9_enable_segfeature(seg, CR_SEGMENT_ID_BOOST2, SEG_LVL_ALT_Q);
442 454
443 // Set the q delta for segment BOOST1. 455 // Set the q delta for segment BOOST1.
444 qindex_delta = compute_deltaq(cpi, cm->base_qindex, cr->rate_ratio_qdelta); 456 qindex_delta = compute_deltaq(cpi, cm->base_qindex, cr->rate_ratio_qdelta);
457 cr->qindex_delta_seg1 = qindex_delta;
445 458
446 // Compute rd-mult for segment BOOST1. 459 // Compute rd-mult for segment BOOST1.
447 qindex2 = clamp(cm->base_qindex + cm->y_dc_delta_q + qindex_delta, 0, MAXQ); 460 qindex2 = clamp(cm->base_qindex + cm->y_dc_delta_q + qindex_delta, 0, MAXQ);
461
448 cr->rdmult = vp9_compute_rd_mult(cpi, qindex2); 462 cr->rdmult = vp9_compute_rd_mult(cpi, qindex2);
449 463
450 vp9_set_segdata(seg, CR_SEGMENT_ID_BOOST1, SEG_LVL_ALT_Q, qindex_delta); 464 vp9_set_segdata(seg, CR_SEGMENT_ID_BOOST1, SEG_LVL_ALT_Q, qindex_delta);
451 465
452 // Set a more aggressive (higher) q delta for segment BOOST2. 466 // Set a more aggressive (higher) q delta for segment BOOST2.
453 qindex_delta = compute_deltaq(cpi, cm->base_qindex, 467 qindex_delta = compute_deltaq(cpi, cm->base_qindex,
454 MIN(CR_MAX_RATE_TARGET_RATIO, 468 MIN(CR_MAX_RATE_TARGET_RATIO,
455 CR_BOOST2_FAC * cr->rate_ratio_qdelta)); 469 CR_BOOST2_FAC * cr->rate_ratio_qdelta));
470 cr->qindex_delta_seg2 = qindex_delta;
456 vp9_set_segdata(seg, CR_SEGMENT_ID_BOOST2, SEG_LVL_ALT_Q, qindex_delta); 471 vp9_set_segdata(seg, CR_SEGMENT_ID_BOOST2, SEG_LVL_ALT_Q, qindex_delta);
457 472
458 // Update the segmentation and refresh map. 473 // Update the segmentation and refresh map.
459 vp9_cyclic_refresh_update_map(cpi); 474 vp9_cyclic_refresh_update_map(cpi);
460 } 475 }
461 } 476 }
462 477
463 int vp9_cyclic_refresh_get_rdmult(const CYCLIC_REFRESH *cr) { 478 int vp9_cyclic_refresh_get_rdmult(const CYCLIC_REFRESH *cr) {
464 return cr->rdmult; 479 return cr->rdmult;
465 } 480 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.h ('k') | source/libvpx/vp9/encoder/vp9_encodeframe.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698