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:
Родитель
dea6f5217e
Коммит
269428e35c
|
@ -19,6 +19,9 @@ extern "C" {
|
||||||
|
|
||||||
extern const unsigned int vp9_prob_cost[256];
|
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_zero(prob) (vp9_prob_cost[prob])
|
||||||
|
|
||||||
#define vp9_cost_one(prob) vp9_cost_zero(vpx_complement(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);
|
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 {
|
typedef struct vp9_token_state {
|
||||||
int rate;
|
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) {
|
vpx_prob upd_p) {
|
||||||
const vpx_prob new_p = get_binary_prob(ct[0], ct[1]) | 1;
|
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) >
|
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);
|
vpx_write(w, update, upd_p);
|
||||||
if (update) {
|
if (update) {
|
||||||
*cur_p = new_p;
|
*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) {
|
if (*skippable == 0) {
|
||||||
*rate <<= 10;
|
*rate <<= (2 + VP9_PROB_COST_SHIFT);
|
||||||
*rate += (eob_cost << 8);
|
*rate += (eob_cost << VP9_PROB_COST_SHIFT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#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;
|
(((uint64_t)qstep * qstep << (n_log2 + 10)) + (var >> 1)) / var;
|
||||||
const int xsq_q10 = (int)VPXMIN(xsq_q10_64, MAX_XSQ_Q10);
|
const int xsq_q10 = (int)VPXMIN(xsq_q10_64, MAX_XSQ_Q10);
|
||||||
model_rd_norm(xsq_q10, &r_q10, &d_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;
|
*dist = (var * (int64_t)d_q10 + 512) >> 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include "vp9/encoder/vp9_block.h"
|
#include "vp9/encoder/vp9_block.h"
|
||||||
#include "vp9/encoder/vp9_context_tree.h"
|
#include "vp9/encoder/vp9_context_tree.h"
|
||||||
|
#include "vp9/encoder/vp9_cost.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -25,7 +26,7 @@ extern "C" {
|
||||||
#define RDDIV_BITS 7
|
#define RDDIV_BITS 7
|
||||||
|
|
||||||
#define RDCOST(RM, DM, R, D) \
|
#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 QIDX_SKIP_THRESH 115
|
||||||
|
|
||||||
#define MV_COST_WEIGHT 108
|
#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);
|
int quantizer = (pd->dequant[1] >> dequant_shift);
|
||||||
|
|
||||||
if (quantizer < 120)
|
if (quantizer < 120)
|
||||||
rate = (square_error * (280 - quantizer)) >> 8;
|
rate = (square_error * (280 - quantizer)) >> (16 - VP9_PROB_COST_SHIFT);
|
||||||
else
|
else
|
||||||
rate = 0;
|
rate = 0;
|
||||||
dist = (square_error * quantizer) >> 8;
|
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) {
|
static int prob_diff_update_cost(vpx_prob newp, vpx_prob oldp) {
|
||||||
int delp = remap_prob(newp, 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) {
|
static void encode_uniform(vpx_writer *w, int v) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче