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

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

Issue 812033011: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 5 years, 11 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_rd.h ('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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 const int tmp = (xsq_q10 >> 2) + 8; 372 const int tmp = (xsq_q10 >> 2) + 8;
373 const int k = get_msb(tmp) - 3; 373 const int k = get_msb(tmp) - 3;
374 const int xq = (k << 3) + ((tmp >> k) & 0x7); 374 const int xq = (k << 3) + ((tmp >> k) & 0x7);
375 const int one_q10 = 1 << 10; 375 const int one_q10 = 1 << 10;
376 const int a_q10 = ((xsq_q10 - xsq_iq_q10[xq]) << 10) >> (2 + k); 376 const int a_q10 = ((xsq_q10 - xsq_iq_q10[xq]) << 10) >> (2 + k);
377 const int b_q10 = one_q10 - a_q10; 377 const int b_q10 = one_q10 - a_q10;
378 *r_q10 = (rate_tab_q10[xq] * b_q10 + rate_tab_q10[xq + 1] * a_q10) >> 10; 378 *r_q10 = (rate_tab_q10[xq] * b_q10 + rate_tab_q10[xq + 1] * a_q10) >> 10;
379 *d_q10 = (dist_tab_q10[xq] * b_q10 + dist_tab_q10[xq + 1] * a_q10) >> 10; 379 *d_q10 = (dist_tab_q10[xq] * b_q10 + dist_tab_q10[xq + 1] * a_q10) >> 10;
380 } 380 }
381 381
382 void vp9_model_rd_from_var_lapndz(unsigned int var, unsigned int n, 382 void vp9_model_rd_from_var_lapndz(unsigned int var, unsigned int n_log2,
383 unsigned int qstep, int *rate, 383 unsigned int qstep, int *rate,
384 int64_t *dist) { 384 int64_t *dist) {
385 // This function models the rate and distortion for a Laplacian 385 // This function models the rate and distortion for a Laplacian
386 // source with given variance when quantized with a uniform quantizer 386 // source with given variance when quantized with a uniform quantizer
387 // with given stepsize. The closed form expressions are in: 387 // with given stepsize. The closed form expressions are in:
388 // Hang and Chen, "Source Model for transform video coder and its 388 // Hang and Chen, "Source Model for transform video coder and its
389 // application - Part I: Fundamental Theory", IEEE Trans. Circ. 389 // application - Part I: Fundamental Theory", IEEE Trans. Circ.
390 // Sys. for Video Tech., April 1997. 390 // Sys. for Video Tech., April 1997.
391 if (var == 0) { 391 if (var == 0) {
392 *rate = 0; 392 *rate = 0;
393 *dist = 0; 393 *dist = 0;
394 } else { 394 } else {
395 int d_q10, r_q10; 395 int d_q10, r_q10;
396 static const uint32_t MAX_XSQ_Q10 = 245727; 396 static const uint32_t MAX_XSQ_Q10 = 245727;
397 const uint64_t xsq_q10_64 = 397 const uint64_t xsq_q10_64 =
398 ((((uint64_t)qstep * qstep * n) << 10) + (var >> 1)) / var; 398 (((uint64_t)qstep * qstep << (n_log2 + 10)) + (var >> 1)) / var;
399 const int xsq_q10 = (int)MIN(xsq_q10_64, MAX_XSQ_Q10); 399 const int xsq_q10 = (int)MIN(xsq_q10_64, MAX_XSQ_Q10);
400 model_rd_norm(xsq_q10, &r_q10, &d_q10); 400 model_rd_norm(xsq_q10, &r_q10, &d_q10);
401 *rate = (n * r_q10 + 2) >> 2; 401 *rate = ((r_q10 << n_log2) + 2) >> 2;
402 *dist = (var * (int64_t)d_q10 + 512) >> 10; 402 *dist = (var * (int64_t)d_q10 + 512) >> 10;
403 } 403 }
404 } 404 }
405 405
406 void vp9_get_entropy_contexts(BLOCK_SIZE bsize, TX_SIZE tx_size, 406 void vp9_get_entropy_contexts(BLOCK_SIZE bsize, TX_SIZE tx_size,
407 const struct macroblockd_plane *pd, 407 const struct macroblockd_plane *pd,
408 ENTROPY_CONTEXT t_above[16], 408 ENTROPY_CONTEXT t_above[16],
409 ENTROPY_CONTEXT t_left[16]) { 409 ENTROPY_CONTEXT t_left[16]) {
410 const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd); 410 const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
411 const int num_4x4_w = num_4x4_blocks_wide_lookup[plane_bsize]; 411 const int num_4x4_w = num_4x4_blocks_wide_lookup[plane_bsize];
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 dst[2].buf = src->v_buffer; 509 dst[2].buf = src->v_buffer;
510 dst[1].stride = dst[2].stride = src->uv_stride; 510 dst[1].stride = dst[2].stride = src->uv_stride;
511 511
512 for (i = 0; i < MAX_MB_PLANE; ++i) { 512 for (i = 0; i < MAX_MB_PLANE; ++i) {
513 setup_pred_plane(dst + i, dst[i].buf, dst[i].stride, mi_row, mi_col, 513 setup_pred_plane(dst + i, dst[i].buf, dst[i].stride, mi_row, mi_col,
514 i ? scale_uv : scale, 514 i ? scale_uv : scale,
515 xd->plane[i].subsampling_x, xd->plane[i].subsampling_y); 515 xd->plane[i].subsampling_x, xd->plane[i].subsampling_y);
516 } 516 }
517 } 517 }
518 518
519 int vp9_raster_block_offset(BLOCK_SIZE plane_bsize,
520 int raster_block, int stride) {
521 const int bw = b_width_log2_lookup[plane_bsize];
522 const int y = 4 * (raster_block >> bw);
523 const int x = 4 * (raster_block & ((1 << bw) - 1));
524 return y * stride + x;
525 }
526
527 int16_t* vp9_raster_block_offset_int16(BLOCK_SIZE plane_bsize,
528 int raster_block, int16_t *base) {
529 const int stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
530 return base + vp9_raster_block_offset(plane_bsize, raster_block, stride);
531 }
532
519 const YV12_BUFFER_CONFIG *vp9_get_scaled_ref_frame(const VP9_COMP *cpi, 533 const YV12_BUFFER_CONFIG *vp9_get_scaled_ref_frame(const VP9_COMP *cpi,
520 int ref_frame) { 534 int ref_frame) {
521 const VP9_COMMON *const cm = &cpi->common; 535 const VP9_COMMON *const cm = &cpi->common;
522 const int ref_idx = cm->ref_frame_map[get_ref_frame_idx(cpi, ref_frame)]; 536 const int ref_idx = cm->ref_frame_map[get_ref_frame_idx(cpi, ref_frame)];
523 const int scaled_idx = cpi->scaled_ref_idx[ref_frame - 1]; 537 const int scaled_idx = cpi->scaled_ref_idx[ref_frame - 1];
524 return (scaled_idx != ref_idx) ? &cm->frame_bufs[scaled_idx].buf : NULL; 538 return (scaled_idx != ref_idx) ? &cm->frame_bufs[scaled_idx].buf : NULL;
525 } 539 }
526 540
527 int vp9_get_switchable_rate(const VP9_COMP *cpi, const MACROBLOCKD *const xd) { 541 int vp9_get_switchable_rate(const VP9_COMP *cpi, const MACROBLOCKD *const xd) {
528 const MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; 542 const MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 return ROUND_POWER_OF_TWO(5 * q, 2); 648 return ROUND_POWER_OF_TWO(5 * q, 2);
635 default: 649 default:
636 assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12"); 650 assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12");
637 return -1; 651 return -1;
638 } 652 }
639 #else 653 #else
640 return 20 * q; 654 return 20 * q;
641 #endif // CONFIG_VP9_HIGHBITDEPTH 655 #endif // CONFIG_VP9_HIGHBITDEPTH
642 } 656 }
643 657
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_rd.h ('k') | source/libvpx/vp9/encoder/vp9_rdopt.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698