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

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

Issue 478033002: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_ratectrl.c ('k') | source/libvpx/vp9/encoder/vp9_rdopt.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2010 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 8, 8, 4, 4, 2, 2, 1, 0 114 8, 8, 4, 4, 2, 2, 1, 0
115 }; 115 };
116 static const int rd_frame_type_factor[FRAME_UPDATE_TYPES] = { 116 static const int rd_frame_type_factor[FRAME_UPDATE_TYPES] = {
117 128, 144, 128, 128, 144 117 128, 144, 128, 128, 144
118 }; 118 };
119 119
120 int vp9_compute_rd_mult(const VP9_COMP *cpi, int qindex) { 120 int vp9_compute_rd_mult(const VP9_COMP *cpi, int qindex) {
121 const int q = vp9_dc_quant(qindex, 0); 121 const int q = vp9_dc_quant(qindex, 0);
122 int rdmult = 88 * q * q / 24; 122 int rdmult = 88 * q * q / 24;
123 123
124 if (cpi->pass == 2 && (cpi->common.frame_type != KEY_FRAME)) { 124 if (cpi->oxcf.pass == 2 && (cpi->common.frame_type != KEY_FRAME)) {
125 const GF_GROUP *const gf_group = &cpi->twopass.gf_group; 125 const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
126 const FRAME_UPDATE_TYPE frame_type = gf_group->update_type[gf_group->index]; 126 const FRAME_UPDATE_TYPE frame_type = gf_group->update_type[gf_group->index];
127 const int boost_index = MIN(15, (cpi->rc.gfu_boost / 100)); 127 const int boost_index = MIN(15, (cpi->rc.gfu_boost / 100));
128 128
129 rdmult = (rdmult * rd_frame_type_factor[frame_type]) >> 7; 129 rdmult = (rdmult * rd_frame_type_factor[frame_type]) >> 7;
130 rdmult += ((rdmult * rd_boost_factor[boost_index]) >> 7); 130 rdmult += ((rdmult * rd_boost_factor[boost_index]) >> 7);
131 } 131 }
132 return rdmult; 132 return rdmult;
133 } 133 }
134 134
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 : x->nmvcost, 213 : x->nmvcost,
214 &cm->fc.nmvc, cm->allow_high_precision_mv); 214 &cm->fc.nmvc, cm->allow_high_precision_mv);
215 215
216 for (i = 0; i < INTER_MODE_CONTEXTS; ++i) 216 for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
217 vp9_cost_tokens((int *)cpi->inter_mode_cost[i], 217 vp9_cost_tokens((int *)cpi->inter_mode_cost[i],
218 cm->fc.inter_mode_probs[i], vp9_inter_mode_tree); 218 cm->fc.inter_mode_probs[i], vp9_inter_mode_tree);
219 } 219 }
220 } 220 }
221 } 221 }
222 222
223 static const int MAX_XSQ_Q10 = 245727;
224
225 static void model_rd_norm(int xsq_q10, int *r_q10, int *d_q10) { 223 static void model_rd_norm(int xsq_q10, int *r_q10, int *d_q10) {
226 // NOTE: The tables below must be of the same size. 224 // NOTE: The tables below must be of the same size.
227 225
228 // The functions described below are sampled at the four most significant 226 // The functions described below are sampled at the four most significant
229 // bits of x^2 + 8 / 256. 227 // bits of x^2 + 8 / 256.
230 228
231 // Normalized rate: 229 // Normalized rate:
232 // This table models the rate for a Laplacian source with given variance 230 // This table models the rate for a Laplacian source with given variance
233 // when quantized with a uniform quantizer with given stepsize. The 231 // when quantized with a uniform quantizer with given stepsize. The
234 // closed form expression is: 232 // closed form expression is:
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // source with given variance when quantized with a uniform quantizer 302 // source with given variance when quantized with a uniform quantizer
305 // with given stepsize. The closed form expressions are in: 303 // with given stepsize. The closed form expressions are in:
306 // Hang and Chen, "Source Model for transform video coder and its 304 // Hang and Chen, "Source Model for transform video coder and its
307 // application - Part I: Fundamental Theory", IEEE Trans. Circ. 305 // application - Part I: Fundamental Theory", IEEE Trans. Circ.
308 // Sys. for Video Tech., April 1997. 306 // Sys. for Video Tech., April 1997.
309 if (var == 0) { 307 if (var == 0) {
310 *rate = 0; 308 *rate = 0;
311 *dist = 0; 309 *dist = 0;
312 } else { 310 } else {
313 int d_q10, r_q10; 311 int d_q10, r_q10;
312 static const uint32_t MAX_XSQ_Q10 = 245727;
314 const uint64_t xsq_q10_64 = 313 const uint64_t xsq_q10_64 =
315 ((((uint64_t)qstep * qstep * n) << 10) + (var >> 1)) / var; 314 ((((uint64_t)qstep * qstep * n) << 10) + (var >> 1)) / var;
316 const int xsq_q10 = xsq_q10_64 > MAX_XSQ_Q10 ? 315 const int xsq_q10 = (int)MIN(xsq_q10_64, MAX_XSQ_Q10);
317 MAX_XSQ_Q10 : (int)xsq_q10_64;
318 model_rd_norm(xsq_q10, &r_q10, &d_q10); 316 model_rd_norm(xsq_q10, &r_q10, &d_q10);
319 *rate = (n * r_q10 + 2) >> 2; 317 *rate = (n * r_q10 + 2) >> 2;
320 *dist = (var * (int64_t)d_q10 + 512) >> 10; 318 *dist = (var * (int64_t)d_q10 + 512) >> 10;
321 } 319 }
322 } 320 }
323 321
324 void vp9_get_entropy_contexts(BLOCK_SIZE bsize, TX_SIZE tx_size, 322 void vp9_get_entropy_contexts(BLOCK_SIZE bsize, TX_SIZE tx_size,
325 const struct macroblockd_plane *pd, 323 const struct macroblockd_plane *pd,
326 ENTROPY_CONTEXT t_above[16], 324 ENTROPY_CONTEXT t_above[16],
327 ENTROPY_CONTEXT t_left[16]) { 325 ENTROPY_CONTEXT t_left[16]) {
(...skipping 22 matching lines...) Expand all
350 t_left[i] = !!*(const uint32_t *)&left[i]; 348 t_left[i] = !!*(const uint32_t *)&left[i];
351 break; 349 break;
352 case TX_32X32: 350 case TX_32X32:
353 for (i = 0; i < num_4x4_w; i += 8) 351 for (i = 0; i < num_4x4_w; i += 8)
354 t_above[i] = !!*(const uint64_t *)&above[i]; 352 t_above[i] = !!*(const uint64_t *)&above[i];
355 for (i = 0; i < num_4x4_h; i += 8) 353 for (i = 0; i < num_4x4_h; i += 8)
356 t_left[i] = !!*(const uint64_t *)&left[i]; 354 t_left[i] = !!*(const uint64_t *)&left[i];
357 break; 355 break;
358 default: 356 default:
359 assert(0 && "Invalid transform size."); 357 assert(0 && "Invalid transform size.");
358 break;
360 } 359 }
361 } 360 }
362 361
363 void vp9_mv_pred(VP9_COMP *cpi, MACROBLOCK *x, 362 void vp9_mv_pred(VP9_COMP *cpi, MACROBLOCK *x,
364 uint8_t *ref_y_buffer, int ref_y_stride, 363 uint8_t *ref_y_buffer, int ref_y_stride,
365 int ref_frame, BLOCK_SIZE block_size) { 364 int ref_frame, BLOCK_SIZE block_size) {
366 MACROBLOCKD *xd = &x->e_mbd; 365 MACROBLOCKD *xd = &x->e_mbd;
367 MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; 366 MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
368 int_mv this_mv; 367 int_mv this_mv;
369 int i; 368 int i;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 rd->thresh_mult_sub8x8[THR_GOLD] = INT_MAX; 569 rd->thresh_mult_sub8x8[THR_GOLD] = INT_MAX;
571 if (!(cpi->ref_frame_flags & VP9_ALT_FLAG)) 570 if (!(cpi->ref_frame_flags & VP9_ALT_FLAG))
572 rd->thresh_mult_sub8x8[THR_ALTR] = INT_MAX; 571 rd->thresh_mult_sub8x8[THR_ALTR] = INT_MAX;
573 if ((cpi->ref_frame_flags & (VP9_LAST_FLAG | VP9_ALT_FLAG)) != 572 if ((cpi->ref_frame_flags & (VP9_LAST_FLAG | VP9_ALT_FLAG)) !=
574 (VP9_LAST_FLAG | VP9_ALT_FLAG)) 573 (VP9_LAST_FLAG | VP9_ALT_FLAG))
575 rd->thresh_mult_sub8x8[THR_COMP_LA] = INT_MAX; 574 rd->thresh_mult_sub8x8[THR_COMP_LA] = INT_MAX;
576 if ((cpi->ref_frame_flags & (VP9_GOLD_FLAG | VP9_ALT_FLAG)) != 575 if ((cpi->ref_frame_flags & (VP9_GOLD_FLAG | VP9_ALT_FLAG)) !=
577 (VP9_GOLD_FLAG | VP9_ALT_FLAG)) 576 (VP9_GOLD_FLAG | VP9_ALT_FLAG))
578 rd->thresh_mult_sub8x8[THR_COMP_GA] = INT_MAX; 577 rd->thresh_mult_sub8x8[THR_COMP_GA] = INT_MAX;
579 } 578 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_ratectrl.c ('k') | source/libvpx/vp9/encoder/vp9_rdopt.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698