| Index: source/libvpx/vp9/encoder/vp9_rd.c
|
| ===================================================================
|
| --- source/libvpx/vp9/encoder/vp9_rd.c (revision 292608)
|
| +++ source/libvpx/vp9/encoder/vp9_rd.c (working copy)
|
| @@ -44,6 +44,18 @@
|
| // Factor to weigh the rate for switchable interp filters.
|
| #define SWITCHABLE_INTERP_RATE_FACTOR 1
|
|
|
| +void vp9_rd_cost_reset(RD_COST *rd_cost) {
|
| + rd_cost->rate = INT_MAX;
|
| + rd_cost->dist = INT64_MAX;
|
| + rd_cost->rdcost = INT64_MAX;
|
| +}
|
| +
|
| +void vp9_rd_cost_init(RD_COST *rd_cost) {
|
| + rd_cost->rate = 0;
|
| + rd_cost->dist = 0;
|
| + rd_cost->rdcost = 0;
|
| +}
|
| +
|
| // The baseline rd thresholds for breaking out of the rd loop for
|
| // certain modes are assumed to be based on 8x8 blocks.
|
| // This table is used to correct for block size.
|
| @@ -136,9 +148,9 @@
|
| };
|
|
|
| int vp9_compute_rd_mult(const VP9_COMP *cpi, int qindex) {
|
| - const int q = vp9_dc_quant(qindex, 0, cpi->common.bit_depth);
|
| + const int64_t q = vp9_dc_quant(qindex, 0, cpi->common.bit_depth);
|
| #if CONFIG_VP9_HIGHBITDEPTH
|
| - int rdmult = 0;
|
| + int64_t rdmult = 0;
|
| switch (cpi->common.bit_depth) {
|
| case VPX_BITS_8:
|
| rdmult = 88 * q * q / 24;
|
| @@ -154,8 +166,8 @@
|
| return -1;
|
| }
|
| #else
|
| - int rdmult = 88 * q * q / 24;
|
| -#endif
|
| + int64_t rdmult = 88 * q * q / 24;
|
| +#endif // CONFIG_VP9_HIGHBITDEPTH
|
| if (cpi->oxcf.pass == 2 && (cpi->common.frame_type != KEY_FRAME)) {
|
| const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
|
| const FRAME_UPDATE_TYPE frame_type = gf_group->update_type[gf_group->index];
|
| @@ -164,7 +176,7 @@
|
| rdmult = (rdmult * rd_frame_type_factor[frame_type]) >> 7;
|
| rdmult += ((rdmult * rd_boost_factor[boost_index]) >> 7);
|
| }
|
| - return rdmult;
|
| + return (int)rdmult;
|
| }
|
|
|
| static int compute_rd_thresh_factor(int qindex, vpx_bit_depth_t bit_depth) {
|
| @@ -187,7 +199,7 @@
|
| #else
|
| (void) bit_depth;
|
| q = vp9_dc_quant(qindex, 0, VPX_BITS_8) / 4.0;
|
| -#endif
|
| +#endif // CONFIG_VP9_HIGHBITDEPTH
|
| // TODO(debargha): Adjust the function below.
|
| return MAX((int)(pow(q, RD_THRESH_POW) * 5.12), 8);
|
| }
|
| @@ -213,7 +225,7 @@
|
| #else
|
| cpi->mb.sadperbit16 = sad_per_bit16lut_8[qindex];
|
| cpi->mb.sadperbit4 = sad_per_bit4lut_8[qindex];
|
| -#endif
|
| +#endif // CONFIG_VP9_HIGHBITDEPTH
|
| }
|
|
|
| static void set_block_thresholds(const VP9_COMMON *cm, RD_OPT *rd) {
|
| @@ -598,3 +610,24 @@
|
| if (sf->disable_split_mask & (1 << i))
|
| rd->thresh_mult_sub8x8[i] = INT_MAX;
|
| }
|
| +
|
| +int vp9_get_intra_cost_penalty(int qindex, int qdelta,
|
| + vpx_bit_depth_t bit_depth) {
|
| + const int q = vp9_dc_quant(qindex, qdelta, bit_depth);
|
| +#if CONFIG_VP9_HIGHBITDEPTH
|
| + switch (bit_depth) {
|
| + case VPX_BITS_8:
|
| + return 20 * q;
|
| + case VPX_BITS_10:
|
| + return 5 * q;
|
| + case VPX_BITS_12:
|
| + return ROUND_POWER_OF_TWO(5 * q, 2);
|
| + default:
|
| + assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12");
|
| + return -1;
|
| + }
|
| +#else
|
| + return 20 * q;
|
| +#endif // CONFIG_VP9_HIGHBITDEPTH
|
| +}
|
| +
|
|
|