Tie the bit cost scale to a define.

This is a pure-refactor in preparation to potentially raise the bit-cost
resolution.

Verified at good speed 0 and rt speed -6.

Change-Id: I5347e6e8c28a9ad9dd0aae1d76a3d0f3c2335bb9
This commit is contained in:
Alex Converse 2016-01-15 14:32:52 -08:00
Родитель dea6f5217e
Коммит 269428e35c
8 изменённых файлов: 15 добавлений и 8 удалений

Просмотреть файл

@ -19,6 +19,9 @@ extern "C" {
extern const unsigned int vp9_prob_cost[256];
// The factor to scale from cost in bits to cost in vp9_prob_cost units.
#define VP9_PROB_COST_SHIFT 8
#define vp9_cost_zero(prob) (vp9_prob_cost[prob])
#define vp9_cost_one(prob) vp9_cost_zero(vpx_complement(prob))

Просмотреть файл

@ -50,7 +50,9 @@ void vp9_subtract_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) {
pd->dst.buf, pd->dst.stride);
}
#define RDTRUNC(RM, DM, R, D) ((128 + (R) * (RM)) & 0xFF)
#define RDTRUNC(RM, DM, R, D) \
(((1 << (VP9_PROB_COST_SHIFT - 1)) + (R) * (RM)) & \
((1 << VP9_PROB_COST_SHIFT) - 1))
typedef struct vp9_token_state {
int rate;

Просмотреть файл

@ -138,7 +138,8 @@ static int update_mv(vpx_writer *w, const unsigned int ct[2], vpx_prob *cur_p,
vpx_prob upd_p) {
const vpx_prob new_p = get_binary_prob(ct[0], ct[1]) | 1;
const int update = cost_branch256(ct, *cur_p) + vp9_cost_zero(upd_p) >
cost_branch256(ct, new_p) + vp9_cost_one(upd_p) + 7 * 256;
cost_branch256(ct, new_p) + vp9_cost_one(upd_p) +
(7 << VP9_PROB_COST_SHIFT);
vpx_write(w, update, upd_p);
if (update) {
*cur_p = new_p;

Просмотреть файл

@ -682,8 +682,8 @@ static void block_yrd(VP9_COMP *cpi, MACROBLOCK *x, int *rate, int64_t *dist,
}
if (*skippable == 0) {
*rate <<= 10;
*rate += (eob_cost << 8);
*rate <<= (2 + VP9_PROB_COST_SHIFT);
*rate += (eob_cost << VP9_PROB_COST_SHIFT);
}
}
#endif

Просмотреть файл

@ -409,7 +409,7 @@ void vp9_model_rd_from_var_lapndz(unsigned int var, unsigned int n_log2,
(((uint64_t)qstep * qstep << (n_log2 + 10)) + (var >> 1)) / var;
const int xsq_q10 = (int)VPXMIN(xsq_q10_64, MAX_XSQ_Q10);
model_rd_norm(xsq_q10, &r_q10, &d_q10);
*rate = ((r_q10 << n_log2) + 2) >> 2;
*rate = ROUND_POWER_OF_TWO(r_q10 << n_log2, 10 - VP9_PROB_COST_SHIFT);
*dist = (var * (int64_t)d_q10 + 512) >> 10;
}
}

Просмотреть файл

@ -17,6 +17,7 @@
#include "vp9/encoder/vp9_block.h"
#include "vp9/encoder/vp9_context_tree.h"
#include "vp9/encoder/vp9_cost.h"
#ifdef __cplusplus
extern "C" {
@ -25,7 +26,7 @@ extern "C" {
#define RDDIV_BITS 7
#define RDCOST(RM, DM, R, D) \
(((128 + ((int64_t)R) * (RM)) >> 8) + (D << DM))
(ROUND_POWER_OF_TWO(((int64_t)R) * (RM), VP9_PROB_COST_SHIFT) + (D << DM))
#define QIDX_SKIP_THRESH 115
#define MV_COST_WEIGHT 108

Просмотреть файл

@ -248,7 +248,7 @@ static void model_rd_for_sb(VP9_COMP *cpi, BLOCK_SIZE bsize,
int quantizer = (pd->dequant[1] >> dequant_shift);
if (quantizer < 120)
rate = (square_error * (280 - quantizer)) >> 8;
rate = (square_error * (280 - quantizer)) >> (16 - VP9_PROB_COST_SHIFT);
else
rate = 0;
dist = (square_error * quantizer) >> 8;

Просмотреть файл

@ -80,7 +80,7 @@ static int remap_prob(int v, int m) {
static int prob_diff_update_cost(vpx_prob newp, vpx_prob oldp) {
int delp = remap_prob(newp, oldp);
return update_bits[delp] * 256;
return update_bits[delp] << VP9_PROB_COST_SHIFT;
}
static void encode_uniform(vpx_writer *w, int v) {