Commit c2883676 authored by Dmitry Kovalev's avatar Dmitry Kovalev
Browse files

Adding consts and cleaning up vp9_rdopt.

Change-Id: I9423b543e1be414e5c9e10480b813f06e6b88f8a
parent 6440e295
...@@ -270,7 +270,8 @@ static INLINE int mi_cols_aligned_to_sb(int n_mis) { ...@@ -270,7 +270,8 @@ static INLINE int mi_cols_aligned_to_sb(int n_mis) {
return ALIGN_POWER_OF_TWO(n_mis, MI_BLOCK_SIZE_LOG2); return ALIGN_POWER_OF_TWO(n_mis, MI_BLOCK_SIZE_LOG2);
} }
static INLINE const vp9_prob* get_partition_probs(VP9_COMMON *cm, int ctx) { static INLINE const vp9_prob* get_partition_probs(const VP9_COMMON *cm,
int ctx) {
return cm->frame_type == KEY_FRAME ? vp9_kf_partition_probs[ctx] return cm->frame_type == KEY_FRAME ? vp9_kf_partition_probs[ctx]
: cm->fc.partition_prob[ctx]; : cm->fc.partition_prob[ctx];
} }
......
...@@ -145,9 +145,8 @@ static int16_t* raster_block_offset_int16(BLOCK_SIZE plane_bsize, ...@@ -145,9 +145,8 @@ static int16_t* raster_block_offset_int16(BLOCK_SIZE plane_bsize,
} }
static void fill_mode_costs(VP9_COMP *cpi) { static void fill_mode_costs(VP9_COMP *cpi) {
VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb; MACROBLOCK *const x = &cpi->mb;
FRAME_CONTEXT *const fc = &cm->fc; const FRAME_CONTEXT *const fc = &cpi->common.fc;
int i, j; int i, j;
for (i = 0; i < INTRA_MODES; i++) for (i = 0; i < INTRA_MODES; i++)
...@@ -164,8 +163,7 @@ static void fill_mode_costs(VP9_COMP *cpi) { ...@@ -164,8 +163,7 @@ static void fill_mode_costs(VP9_COMP *cpi) {
for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i) for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i)
vp9_cost_tokens((int *)x->switchable_interp_costs[i], vp9_cost_tokens((int *)x->switchable_interp_costs[i],
fc->switchable_interp_prob[i], fc->switchable_interp_prob[i], vp9_switchable_interp_tree);
vp9_switchable_interp_tree);
} }
static void fill_token_costs(vp9_coeff_cost *c, static void fill_token_costs(vp9_coeff_cost *c,
...@@ -214,7 +212,7 @@ void vp9_init_me_luts() { ...@@ -214,7 +212,7 @@ void vp9_init_me_luts() {
} }
} }
int vp9_compute_rd_mult(VP9_COMP *cpi, int qindex) { int vp9_compute_rd_mult(const VP9_COMP *cpi, int qindex) {
const int q = vp9_dc_quant(qindex, 0); const int q = vp9_dc_quant(qindex, 0);
// TODO(debargha): Adjust the function below // TODO(debargha): Adjust the function below
int rdmult = 88 * q * q / 25; int rdmult = 88 * q * q / 25;
...@@ -228,12 +226,9 @@ int vp9_compute_rd_mult(VP9_COMP *cpi, int qindex) { ...@@ -228,12 +226,9 @@ int vp9_compute_rd_mult(VP9_COMP *cpi, int qindex) {
} }
static int compute_rd_thresh_factor(int qindex) { static int compute_rd_thresh_factor(int qindex) {
int q;
// TODO(debargha): Adjust the function below // TODO(debargha): Adjust the function below
q = (int)(pow(vp9_dc_quant(qindex, 0) / 4.0, RD_THRESH_POW) * 5.12); const int q = (int)(pow(vp9_dc_quant(qindex, 0) / 4.0, RD_THRESH_POW) * 5.12);
if (q < 8) return MAX(q, 8);
q = 8;
return q;
} }
void vp9_initialize_me_consts(VP9_COMP *cpi, int qindex) { void vp9_initialize_me_consts(VP9_COMP *cpi, int qindex) {
...@@ -242,9 +237,9 @@ void vp9_initialize_me_consts(VP9_COMP *cpi, int qindex) { ...@@ -242,9 +237,9 @@ void vp9_initialize_me_consts(VP9_COMP *cpi, int qindex) {
} }
static void set_block_thresholds(VP9_COMP *cpi) { static void set_block_thresholds(VP9_COMP *cpi) {
const VP9_COMMON *const cm = &cpi->common;
const SPEED_FEATURES *const sf = &cpi->sf;
int i, bsize, segment_id; int i, bsize, segment_id;
VP9_COMMON *cm = &cpi->common;
SPEED_FEATURES *sf = &cpi->sf;
for (segment_id = 0; segment_id < MAX_SEGMENTS; ++segment_id) { for (segment_id = 0; segment_id < MAX_SEGMENTS; ++segment_id) {
const int qindex = clamp(vp9_get_qindex(&cm->seg, segment_id, const int qindex = clamp(vp9_get_qindex(&cm->seg, segment_id,
...@@ -274,8 +269,8 @@ static void set_block_thresholds(VP9_COMP *cpi) { ...@@ -274,8 +269,8 @@ static void set_block_thresholds(VP9_COMP *cpi) {
} }
void vp9_initialize_rd_consts(VP9_COMP *cpi) { void vp9_initialize_rd_consts(VP9_COMP *cpi) {
VP9_COMMON *cm = &cpi->common; VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *x = &cpi->mb; MACROBLOCK *const x = &cpi->mb;
int i; int i;
vp9_clear_system_state(); vp9_clear_system_state();
...@@ -433,7 +428,7 @@ static void model_rd_for_sb(VP9_COMP *cpi, BLOCK_SIZE bsize, ...@@ -433,7 +428,7 @@ static void model_rd_for_sb(VP9_COMP *cpi, BLOCK_SIZE bsize,
int i; int i;
int64_t rate_sum = 0; int64_t rate_sum = 0;
int64_t dist_sum = 0; int64_t dist_sum = 0;
int ref = xd->mi_8x8[0]->mbmi.ref_frame[0]; const int ref = xd->mi_8x8[0]->mbmi.ref_frame[0];
unsigned int sse; unsigned int sse;
for (i = 0; i < MAX_MB_PLANE; ++i) { for (i = 0; i < MAX_MB_PLANE; ++i) {
...@@ -482,8 +477,8 @@ static void model_rd_for_sb_y_tx(VP9_COMP *cpi, BLOCK_SIZE bsize, ...@@ -482,8 +477,8 @@ static void model_rd_for_sb_y_tx(VP9_COMP *cpi, BLOCK_SIZE bsize,
int *out_skip) { int *out_skip) {
int j, k; int j, k;
BLOCK_SIZE bs; BLOCK_SIZE bs;
struct macroblock_plane *const p = &x->plane[0]; const struct macroblock_plane *const p = &x->plane[0];
struct macroblockd_plane *const pd = &xd->plane[0]; const struct macroblockd_plane *const pd = &xd->plane[0];
const int width = 4 * num_4x4_blocks_wide_lookup[bsize]; const int width = 4 * num_4x4_blocks_wide_lookup[bsize];
const int height = 4 * num_4x4_blocks_high_lookup[bsize]; const int height = 4 * num_4x4_blocks_high_lookup[bsize];
int rate_sum = 0; int rate_sum = 0;
...@@ -557,8 +552,8 @@ static INLINE int cost_coeffs(MACROBLOCK *x, ...@@ -557,8 +552,8 @@ static INLINE int cost_coeffs(MACROBLOCK *x,
const int16_t *scan, const int16_t *nb) { const int16_t *scan, const int16_t *nb) {
MACROBLOCKD *const xd = &x->e_mbd; MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *mbmi = &xd->mi_8x8[0]->mbmi; MB_MODE_INFO *mbmi = &xd->mi_8x8[0]->mbmi;
struct macroblock_plane *p = &x->plane[plane]; const struct macroblock_plane *p = &x->plane[plane];
struct macroblockd_plane *pd = &xd->plane[plane]; const struct macroblockd_plane *pd = &xd->plane[plane];
const PLANE_TYPE type = pd->plane_type; const PLANE_TYPE type = pd->plane_type;
const int16_t *band_count = &band_counts[tx_size][1]; const int16_t *band_count = &band_counts[tx_size][1];
const int eob = p->eobs[block]; const int eob = p->eobs[block];
...@@ -622,8 +617,8 @@ static void dist_block(int plane, int block, TX_SIZE tx_size, ...@@ -622,8 +617,8 @@ static void dist_block(int plane, int block, TX_SIZE tx_size,
const int ss_txfrm_size = tx_size << 1; const int ss_txfrm_size = tx_size << 1;
MACROBLOCK* const x = args->x; MACROBLOCK* const x = args->x;
MACROBLOCKD* const xd = &x->e_mbd; MACROBLOCKD* const xd = &x->e_mbd;
struct macroblock_plane *const p = &x->plane[plane]; const struct macroblock_plane *const p = &x->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane]; const struct macroblockd_plane *const pd = &xd->plane[plane];
int64_t this_sse; int64_t this_sse;
int shift = tx_size == TX_32X32 ? 0 : 2; int shift = tx_size == TX_32X32 ? 0 : 2;
int16_t *const coeff = BLOCK_OFFSET(p->coeff, block); int16_t *const coeff = BLOCK_OFFSET(p->coeff, block);
...@@ -656,7 +651,7 @@ static void block_rd_txfm(int plane, int block, BLOCK_SIZE plane_bsize, ...@@ -656,7 +651,7 @@ static void block_rd_txfm(int plane, int block, BLOCK_SIZE plane_bsize,
struct rdcost_block_args *args = arg; struct rdcost_block_args *args = arg;
MACROBLOCK *const x = args->x; MACROBLOCK *const x = args->x;
MACROBLOCKD *const xd = &x->e_mbd; MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *mbmi = &xd->mi_8x8[0]->mbmi; MB_MODE_INFO *const mbmi = &xd->mi_8x8[0]->mbmi;
int64_t rd1, rd2, rd; int64_t rd1, rd2, rd;
if (args->skip) if (args->skip)
...@@ -734,7 +729,7 @@ static void txfm_rd_in_plane(MACROBLOCK *x, ...@@ -734,7 +729,7 @@ static void txfm_rd_in_plane(MACROBLOCK *x,
int64_t ref_best_rd, int plane, int64_t ref_best_rd, int plane,
BLOCK_SIZE bsize, TX_SIZE tx_size) { BLOCK_SIZE bsize, TX_SIZE tx_size) {
MACROBLOCKD *const xd = &x->e_mbd; MACROBLOCKD *const xd = &x->e_mbd;
struct macroblockd_plane *const pd = &xd->plane[plane]; const struct macroblockd_plane *const pd = &xd->plane[plane];
struct rdcost_block_args args = { 0 }; struct rdcost_block_args args = { 0 };
args.x = x; args.x = x;
args.best_rd = ref_best_rd; args.best_rd = ref_best_rd;
......
...@@ -35,7 +35,7 @@ extern "C" { ...@@ -35,7 +35,7 @@ extern "C" {
struct TileInfo; struct TileInfo;
int vp9_compute_rd_mult(VP9_COMP *cpi, int qindex); int vp9_compute_rd_mult(const VP9_COMP *cpi, int qindex);
void vp9_initialize_rd_consts(VP9_COMP *cpi); void vp9_initialize_rd_consts(VP9_COMP *cpi);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment