| OLD | NEW |
| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 if (cm->frame_type == KEY_FRAME) | 193 if (cm->frame_type == KEY_FRAME) |
| 194 cr->sb_index = 0; | 194 cr->sb_index = 0; |
| 195 return; | 195 return; |
| 196 } else { | 196 } else { |
| 197 int qindex_delta = 0; | 197 int qindex_delta = 0; |
| 198 int i, block_count, bl_index, sb_rows, sb_cols, sbs_in_frame; | 198 int i, block_count, bl_index, sb_rows, sb_cols, sbs_in_frame; |
| 199 int xmis, ymis, x, y, qindex2; | 199 int xmis, ymis, x, y, qindex2; |
| 200 | 200 |
| 201 // Rate target ratio to set q delta. | 201 // Rate target ratio to set q delta. |
| 202 const float rate_ratio_qdelta = 2.0; | 202 const float rate_ratio_qdelta = 2.0; |
| 203 const double q = vp9_convert_qindex_to_q(cm->base_qindex); | 203 const double q = vp9_convert_qindex_to_q(cm->base_qindex, cm->bit_depth); |
| 204 vp9_clear_system_state(); | 204 vp9_clear_system_state(); |
| 205 // Some of these parameters may be set via codec-control function later. | 205 // Some of these parameters may be set via codec-control function later. |
| 206 cr->max_sbs_perframe = 10; | 206 cr->max_sbs_perframe = 10; |
| 207 cr->max_qdelta_perc = 50; | 207 cr->max_qdelta_perc = 50; |
| 208 cr->min_block_size = BLOCK_8X8; | 208 cr->min_block_size = BLOCK_8X8; |
| 209 cr->time_for_refresh = 1; | 209 cr->time_for_refresh = 1; |
| 210 // Set rate threshold to some fraction of target (and scaled by 256). | 210 // Set rate threshold to some fraction of target (and scaled by 256). |
| 211 cr->thresh_rate_sb = (rc->sb64_target_rate * 256) >> 2; | 211 cr->thresh_rate_sb = (rc->sb64_target_rate * 256) >> 2; |
| 212 // Distortion threshold, quadratic in Q, scale factor to be adjusted. | 212 // Distortion threshold, quadratic in Q, scale factor to be adjusted. |
| 213 cr->thresh_dist_sb = 8 * (int)(q * q); | 213 cr->thresh_dist_sb = 8 * (int)(q * q); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 235 // seg->temporal_update = 0; | 235 // seg->temporal_update = 0; |
| 236 | 236 |
| 237 // Segment 0 "Q" feature is disabled so it defaults to the baseline Q. | 237 // Segment 0 "Q" feature is disabled so it defaults to the baseline Q. |
| 238 vp9_disable_segfeature(seg, 0, SEG_LVL_ALT_Q); | 238 vp9_disable_segfeature(seg, 0, SEG_LVL_ALT_Q); |
| 239 // Use segment 1 for in-frame Q adjustment. | 239 // Use segment 1 for in-frame Q adjustment. |
| 240 vp9_enable_segfeature(seg, 1, SEG_LVL_ALT_Q); | 240 vp9_enable_segfeature(seg, 1, SEG_LVL_ALT_Q); |
| 241 | 241 |
| 242 // Set the q delta for segment 1. | 242 // Set the q delta for segment 1. |
| 243 qindex_delta = vp9_compute_qdelta_by_rate(rc, cm->frame_type, | 243 qindex_delta = vp9_compute_qdelta_by_rate(rc, cm->frame_type, |
| 244 cm->base_qindex, | 244 cm->base_qindex, |
| 245 rate_ratio_qdelta); | 245 rate_ratio_qdelta, |
| 246 cm->bit_depth); |
| 246 // TODO(marpan): Incorporate the actual-vs-target rate over/undershoot from | 247 // TODO(marpan): Incorporate the actual-vs-target rate over/undershoot from |
| 247 // previous encoded frame. | 248 // previous encoded frame. |
| 248 if (-qindex_delta > cr->max_qdelta_perc * cm->base_qindex / 100) | 249 if (-qindex_delta > cr->max_qdelta_perc * cm->base_qindex / 100) |
| 249 qindex_delta = -cr->max_qdelta_perc * cm->base_qindex / 100; | 250 qindex_delta = -cr->max_qdelta_perc * cm->base_qindex / 100; |
| 250 | 251 |
| 251 // Compute rd-mult for segment 1. | 252 // Compute rd-mult for segment 1. |
| 252 qindex2 = clamp(cm->base_qindex + cm->y_dc_delta_q + qindex_delta, 0, MAXQ); | 253 qindex2 = clamp(cm->base_qindex + cm->y_dc_delta_q + qindex_delta, 0, MAXQ); |
| 253 cr->rdmult = vp9_compute_rd_mult(cpi, qindex2); | 254 cr->rdmult = vp9_compute_rd_mult(cpi, qindex2); |
| 254 | 255 |
| 255 vp9_set_segdata(seg, 1, SEG_LVL_ALT_Q, qindex_delta); | 256 vp9_set_segdata(seg, 1, SEG_LVL_ALT_Q, qindex_delta); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 | 315 |
| 315 void vp9_cyclic_refresh_set_rate_and_dist_sb(CYCLIC_REFRESH *cr, | 316 void vp9_cyclic_refresh_set_rate_and_dist_sb(CYCLIC_REFRESH *cr, |
| 316 int64_t rate_sb, int64_t dist_sb) { | 317 int64_t rate_sb, int64_t dist_sb) { |
| 317 cr->projected_rate_sb = rate_sb; | 318 cr->projected_rate_sb = rate_sb; |
| 318 cr->projected_dist_sb = dist_sb; | 319 cr->projected_dist_sb = dist_sb; |
| 319 } | 320 } |
| 320 | 321 |
| 321 int vp9_cyclic_refresh_get_rdmult(const CYCLIC_REFRESH *cr) { | 322 int vp9_cyclic_refresh_get_rdmult(const CYCLIC_REFRESH *cr) { |
| 322 return cr->rdmult; | 323 return cr->rdmult; |
| 323 } | 324 } |
| OLD | NEW |