From 51545f57530b15b2b8901f9786293475590c80ad Mon Sep 17 00:00:00 2001 From: Dmitry Kovalev Date: Thu, 15 May 2014 12:01:34 -0700 Subject: [PATCH] Moving PC_TREE from MACROBLOCK to VP9_COMP. Because PC_TREE is encoder-level data, not MACROBLOCK-level data. Change-Id: I4f620c0781acd3a2744860610117e74948e0b2b5 --- vp9/encoder/vp9_block.h | 55 ------------------------------- vp9/encoder/vp9_context_tree.c | 42 ++++++++++++------------ vp9/encoder/vp9_context_tree.h | 58 ++++++++++++++++++++++++++++++-- vp9/encoder/vp9_encodeframe.c | 60 +++++++++++++++++----------------- vp9/encoder/vp9_encoder.c | 4 +-- vp9/encoder/vp9_encoder.h | 6 ++++ vp9/encoder/vp9_firstpass.c | 2 +- vp9/encoder/vp9_rdopt.c | 2 +- 8 files changed, 117 insertions(+), 112 deletions(-) diff --git a/vp9/encoder/vp9_block.h b/vp9/encoder/vp9_block.h index 2ccf4f80e..0504a4985 100644 --- a/vp9/encoder/vp9_block.h +++ b/vp9/encoder/vp9_block.h @@ -20,43 +20,6 @@ extern "C" { #endif -// Structure to hold snapshot of coding context during the mode picking process -typedef struct { - MODE_INFO mic; - uint8_t *zcoeff_blk; - int16_t *coeff[MAX_MB_PLANE][3]; - int16_t *qcoeff[MAX_MB_PLANE][3]; - int16_t *dqcoeff[MAX_MB_PLANE][3]; - uint16_t *eobs[MAX_MB_PLANE][3]; - - // dual buffer pointers, 0: in use, 1: best in store - int16_t *coeff_pbuf[MAX_MB_PLANE][3]; - int16_t *qcoeff_pbuf[MAX_MB_PLANE][3]; - int16_t *dqcoeff_pbuf[MAX_MB_PLANE][3]; - uint16_t *eobs_pbuf[MAX_MB_PLANE][3]; - - int is_coded; - int num_4x4_blk; - int skip; - int_mv best_ref_mv[2]; - int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES]; - int rate; - int distortion; - int best_mode_index; - int rddiv; - int rdmult; - int hybrid_pred_diff; - int comp_pred_diff; - int single_pred_diff; - int64_t tx_rd_diff[TX_MODES]; - int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS]; - - // motion vector cache for adaptive motion search control in partition - // search loop - int_mv pred_mv[MAX_REF_FRAMES]; - INTERP_FILTER pred_interp_filter; -} PICK_MODE_CONTEXT; - struct macroblock_plane { DECLARE_ALIGNED(16, int16_t, src_diff[64 * 64]); int16_t *qcoeff; @@ -73,18 +36,6 @@ struct macroblock_plane { // Zbin Over Quant value int16_t zbin_extra; }; -typedef struct PC_TREE { - int index; - PARTITION_TYPE partitioning; - BLOCK_SIZE block_size; - PICK_MODE_CONTEXT none; - PICK_MODE_CONTEXT horizontal[2]; - PICK_MODE_CONTEXT vertical[2]; - union { - struct PC_TREE *split[4]; - PICK_MODE_CONTEXT *leaf_split[4]; - }; -} PC_TREE; /* The [2] dimension is for whether we skip the EOB node (i.e. if previous * coefficient in this block was zero) or not. */ @@ -157,15 +108,9 @@ struct macroblock { // Used to store sub partition's choices. int_mv pred_mv[MAX_REF_FRAMES]; - PICK_MODE_CONTEXT *leaf_tree; - PC_TREE *pc_tree; - PC_TREE *pc_root; - int partition_cost[PARTITION_CONTEXTS][PARTITION_TYPES]; - void (*fwd_txm4x4)(const int16_t *input, int16_t *output, int stride); }; - #ifdef __cplusplus } // extern "C" #endif diff --git a/vp9/encoder/vp9_context_tree.c b/vp9/encoder/vp9_context_tree.c index ac9b56224..9b7a93267 100644 --- a/vp9/encoder/vp9_context_tree.c +++ b/vp9/encoder/vp9_context_tree.c @@ -9,6 +9,7 @@ */ #include "vp9/encoder/vp9_context_tree.h" +#include "vp9/encoder/vp9_encoder.h" static const BLOCK_SIZE square[] = { BLOCK_8X8, @@ -86,7 +87,7 @@ static void free_tree_contexts(PC_TREE *tree) { // partition level. There are contexts for none, horizontal, vertical, and // split. Along with a block_size value and a selected block_size which // represents the state of our search. -void vp9_setup_pc_tree(VP9_COMMON *cm, MACROBLOCK *x) { +void vp9_setup_pc_tree(VP9_COMMON *cm, VP9_COMP *cpi) { int i, j; const int leaf_nodes = 64; const int tree_nodes = 64 + 16 + 4 + 1; @@ -96,23 +97,24 @@ void vp9_setup_pc_tree(VP9_COMMON *cm, MACROBLOCK *x) { int square_index = 1; int nodes; - vpx_free(x->leaf_tree); - CHECK_MEM_ERROR(cm, x->leaf_tree, vpx_calloc(leaf_nodes, - sizeof(*x->leaf_tree))); - vpx_free(x->pc_tree); - CHECK_MEM_ERROR(cm, x->pc_tree, vpx_calloc(tree_nodes, sizeof(*x->pc_tree))); + vpx_free(cpi->leaf_tree); + CHECK_MEM_ERROR(cm, cpi->leaf_tree, vpx_calloc(leaf_nodes, + sizeof(*cpi->leaf_tree))); + vpx_free(cpi->pc_tree); + CHECK_MEM_ERROR(cm, cpi->pc_tree, vpx_calloc(tree_nodes, + sizeof(*cpi->pc_tree))); - this_pc = &x->pc_tree[0]; - this_leaf = &x->leaf_tree[0]; + this_pc = &cpi->pc_tree[0]; + this_leaf = &cpi->leaf_tree[0]; // 4x4 blocks smaller than 8x8 but in the same 8x8 block share the same // context so we only need to allocate 1 for each 8x8 block. for (i = 0; i < leaf_nodes; ++i) - alloc_mode_context(cm, 1, &x->leaf_tree[i]); + alloc_mode_context(cm, 1, &cpi->leaf_tree[i]); // Sets up all the leaf nodes in the tree. for (pc_tree_index = 0; pc_tree_index < leaf_nodes; ++pc_tree_index) { - PC_TREE *const tree = &x->pc_tree[pc_tree_index]; + PC_TREE *const tree = &cpi->pc_tree[pc_tree_index]; tree->block_size = square[0]; alloc_tree_contexts(cm, tree, 4); tree->leaf_split[0] = this_leaf++; @@ -124,7 +126,7 @@ void vp9_setup_pc_tree(VP9_COMMON *cm, MACROBLOCK *x) { // from leafs to the root. for (nodes = 16; nodes > 0; nodes >>= 2) { for (i = 0; i < nodes; ++i) { - PC_TREE *const tree = &x->pc_tree[pc_tree_index]; + PC_TREE *const tree = &cpi->pc_tree[pc_tree_index]; alloc_tree_contexts(cm, tree, 4 << (2 * square_index)); tree->block_size = square[square_index]; for (j = 0; j < 4; j++) @@ -133,24 +135,24 @@ void vp9_setup_pc_tree(VP9_COMMON *cm, MACROBLOCK *x) { } ++square_index; } - x->pc_root = &x->pc_tree[tree_nodes - 1]; - x->pc_root[0].none.best_mode_index = 2; + cpi->pc_root = &cpi->pc_tree[tree_nodes - 1]; + cpi->pc_root[0].none.best_mode_index = 2; } -void vp9_free_pc_tree(MACROBLOCK *x) { +void vp9_free_pc_tree(VP9_COMP *cpi) { const int tree_nodes = 64 + 16 + 4 + 1; int i; // Set up all 4x4 mode contexts for (i = 0; i < 64; ++i) - free_mode_context(&x->leaf_tree[i]); + free_mode_context(&cpi->leaf_tree[i]); // Sets up all the leaf nodes in the tree. for (i = 0; i < tree_nodes; ++i) - free_tree_contexts(&x->pc_tree[i]); + free_tree_contexts(&cpi->pc_tree[i]); - vpx_free(x->pc_tree); - x->pc_tree = NULL; - vpx_free(x->leaf_tree); - x->leaf_tree = NULL; + vpx_free(cpi->pc_tree); + cpi->pc_tree = NULL; + vpx_free(cpi->leaf_tree); + cpi->leaf_tree = NULL; } diff --git a/vp9/encoder/vp9_context_tree.h b/vp9/encoder/vp9_context_tree.h index 66a6f00e3..e12aac246 100644 --- a/vp9/encoder/vp9_context_tree.h +++ b/vp9/encoder/vp9_context_tree.h @@ -11,9 +11,61 @@ #ifndef VP9_ENCODER_VP9_CONTEXT_TREE_H_ #define VP9_ENCODER_VP9_CONTEXT_TREE_H_ -#include "vp9/encoder/vp9_encoder.h" +#include "vp9/common/vp9_onyxc_int.h" -void vp9_setup_pc_tree(VP9_COMMON *cm, MACROBLOCK *x); -void vp9_free_pc_tree(MACROBLOCK *x); +struct VP9_COMP; + +// Structure to hold snapshot of coding context during the mode picking process +typedef struct { + MODE_INFO mic; + uint8_t *zcoeff_blk; + int16_t *coeff[MAX_MB_PLANE][3]; + int16_t *qcoeff[MAX_MB_PLANE][3]; + int16_t *dqcoeff[MAX_MB_PLANE][3]; + uint16_t *eobs[MAX_MB_PLANE][3]; + + // dual buffer pointers, 0: in use, 1: best in store + int16_t *coeff_pbuf[MAX_MB_PLANE][3]; + int16_t *qcoeff_pbuf[MAX_MB_PLANE][3]; + int16_t *dqcoeff_pbuf[MAX_MB_PLANE][3]; + uint16_t *eobs_pbuf[MAX_MB_PLANE][3]; + + int is_coded; + int num_4x4_blk; + int skip; + int_mv best_ref_mv[2]; + int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES]; + int rate; + int distortion; + int best_mode_index; + int rddiv; + int rdmult; + int hybrid_pred_diff; + int comp_pred_diff; + int single_pred_diff; + int64_t tx_rd_diff[TX_MODES]; + int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS]; + + // motion vector cache for adaptive motion search control in partition + // search loop + int_mv pred_mv[MAX_REF_FRAMES]; + INTERP_FILTER pred_interp_filter; +} PICK_MODE_CONTEXT; + +typedef struct PC_TREE { + int index; + PARTITION_TYPE partitioning; + BLOCK_SIZE block_size; + PICK_MODE_CONTEXT none; + PICK_MODE_CONTEXT horizontal[2]; + PICK_MODE_CONTEXT vertical[2]; + union { + struct PC_TREE *split[4]; + PICK_MODE_CONTEXT *leaf_split[4]; + }; +} PC_TREE; + +void vp9_setup_pc_tree(struct VP9Common *cm, struct VP9_COMP *cpi); +void vp9_free_pc_tree(struct VP9_COMP *cpi); #endif /* VP9_ENCODER_VP9_CONTEXT_TREE_H_ */ diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index e33261a54..7b7450504 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -1538,7 +1538,7 @@ static void rd_use_partition(VP9_COMP *cpi, pl = partition_plane_context(xd, mi_row, mi_col, bsize); if (none_rate < INT_MAX) { - none_rate += x->partition_cost[pl][PARTITION_NONE]; + none_rate += cpi->partition_cost[pl][PARTITION_NONE]; none_rd = RDCOST(x->rdmult, x->rddiv, none_rate, none_dist); } @@ -1636,7 +1636,7 @@ static void rd_use_partition(VP9_COMP *cpi, pl = partition_plane_context(xd, mi_row, mi_col, bsize); if (last_part_rate < INT_MAX) { - last_part_rate += x->partition_cost[pl][partition]; + last_part_rate += cpi->partition_cost[pl][partition]; last_part_rd = RDCOST(x->rdmult, x->rddiv, last_part_rate, last_part_dist); } @@ -1689,11 +1689,11 @@ static void rd_use_partition(VP9_COMP *cpi, pl = partition_plane_context(xd, mi_row + y_idx, mi_col + x_idx, split_subsize); - chosen_rate += x->partition_cost[pl][PARTITION_NONE]; + chosen_rate += cpi->partition_cost[pl][PARTITION_NONE]; } pl = partition_plane_context(xd, mi_row, mi_col, bsize); if (chosen_rate < INT_MAX) { - chosen_rate += x->partition_cost[pl][PARTITION_SPLIT]; + chosen_rate += cpi->partition_cost[pl][PARTITION_SPLIT]; chosen_rd = RDCOST(x->rdmult, x->rddiv, chosen_rate, chosen_dist); } } @@ -2015,7 +2015,7 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, if (this_rate != INT_MAX) { if (bsize >= BLOCK_8X8) { pl = partition_plane_context(xd, mi_row, mi_col, bsize); - this_rate += x->partition_cost[pl][PARTITION_NONE]; + this_rate += cpi->partition_cost[pl][PARTITION_NONE]; } sum_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_dist); if (sum_rd < best_rd) { @@ -2103,7 +2103,7 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, if (sum_rd < best_rd && i == 4) { pl = partition_plane_context(xd, mi_row, mi_col, bsize); - sum_rate += x->partition_cost[pl][PARTITION_SPLIT]; + sum_rate += cpi->partition_cost[pl][PARTITION_SPLIT]; sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); if (sum_rd < best_rd) { best_rate = sum_rate; @@ -2157,7 +2157,7 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, } if (sum_rd < best_rd) { pl = partition_plane_context(xd, mi_row, mi_col, bsize); - sum_rate += x->partition_cost[pl][PARTITION_HORZ]; + sum_rate += cpi->partition_cost[pl][PARTITION_HORZ]; sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); if (sum_rd < best_rd) { best_rd = sum_rd; @@ -2206,7 +2206,7 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, } if (sum_rd < best_rd) { pl = partition_plane_context(xd, mi_row, mi_col, bsize); - sum_rate += x->partition_cost[pl][PARTITION_VERT]; + sum_rate += cpi->partition_cost[pl][PARTITION_VERT]; sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); if (sum_rd < best_rd) { best_rate = sum_rate; @@ -2268,17 +2268,16 @@ static void encode_rd_sb_row(VP9_COMP *cpi, const TileInfo *const tile, int64_t dummy_dist; int i; - MACROBLOCK *x = &cpi->mb; if (sf->adaptive_pred_interp_filter) { for (i = 0; i < 64; ++i) - x->leaf_tree[i].pred_interp_filter = SWITCHABLE; + cpi->leaf_tree[i].pred_interp_filter = SWITCHABLE; for (i = 0; i < 64; ++i) { - x->pc_tree[i].vertical[0].pred_interp_filter = SWITCHABLE; - x->pc_tree[i].vertical[1].pred_interp_filter = SWITCHABLE; - x->pc_tree[i].horizontal[0].pred_interp_filter = SWITCHABLE; - x->pc_tree[i].horizontal[1].pred_interp_filter = SWITCHABLE; + cpi->pc_tree[i].vertical[0].pred_interp_filter = SWITCHABLE; + cpi->pc_tree[i].vertical[1].pred_interp_filter = SWITCHABLE; + cpi->pc_tree[i].horizontal[0].pred_interp_filter = SWITCHABLE; + cpi->pc_tree[i].horizontal[1].pred_interp_filter = SWITCHABLE; } } @@ -2298,18 +2297,18 @@ static void encode_rd_sb_row(VP9_COMP *cpi, const TileInfo *const tile, set_fixed_partitioning(cpi, tile, mi, mi_row, mi_col, sf->always_this_block_size); rd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, - &dummy_rate, &dummy_dist, 1, x->pc_root); + &dummy_rate, &dummy_dist, 1, cpi->pc_root); } else if (sf->partition_search_type == VAR_BASED_FIXED_PARTITION) { BLOCK_SIZE bsize; set_offsets(cpi, tile, mi_row, mi_col, BLOCK_64X64); bsize = get_rd_var_based_fixed_partition(cpi, mi_row, mi_col); set_fixed_partitioning(cpi, tile, mi, mi_row, mi_col, bsize); rd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, - &dummy_rate, &dummy_dist, 1, x->pc_root); + &dummy_rate, &dummy_dist, 1, cpi->pc_root); } else if (sf->partition_search_type == VAR_BASED_PARTITION) { choose_partitioning(cpi, tile, mi_row, mi_col); rd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, - &dummy_rate, &dummy_dist, 1, x->pc_root); + &dummy_rate, &dummy_dist, 1, cpi->pc_root); } else { if ((cm->current_video_frame % sf->last_partitioning_redo_frequency) == 0 @@ -2328,7 +2327,8 @@ static void encode_rd_sb_row(VP9_COMP *cpi, const TileInfo *const tile, &sf->max_partition_size); } rd_pick_partition(cpi, tile, tp, mi_row, mi_col, BLOCK_64X64, - &dummy_rate, &dummy_dist, 1, INT64_MAX, x->pc_root); + &dummy_rate, &dummy_dist, 1, INT64_MAX, + cpi->pc_root); } else { if (sf->constrain_copy_partition && sb_has_motion(cm, prev_mi)) @@ -2337,7 +2337,7 @@ static void encode_rd_sb_row(VP9_COMP *cpi, const TileInfo *const tile, else copy_partitioning(cm, mi, prev_mi); rd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, - &dummy_rate, &dummy_dist, 1, x->pc_root); + &dummy_rate, &dummy_dist, 1, cpi->pc_root); } } } else { @@ -2349,7 +2349,7 @@ static void encode_rd_sb_row(VP9_COMP *cpi, const TileInfo *const tile, &sf->max_partition_size); } rd_pick_partition(cpi, tile, tp, mi_row, mi_col, BLOCK_64X64, - &dummy_rate, &dummy_dist, 1, INT64_MAX, x->pc_root); + &dummy_rate, &dummy_dist, 1, INT64_MAX, cpi->pc_root); } } } @@ -2627,7 +2627,7 @@ static void nonrd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, if (this_rate != INT_MAX) { int pl = partition_plane_context(xd, mi_row, mi_col, bsize); - this_rate += x->partition_cost[pl][PARTITION_NONE]; + this_rate += cpi->partition_cost[pl][PARTITION_NONE]; sum_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_dist); if (sum_rd < best_rd) { int64_t stop_thresh = 4096; @@ -2665,7 +2665,7 @@ static void nonrd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, sum_rd = 0; if (do_split) { int pl = partition_plane_context(xd, mi_row, mi_col, bsize); - sum_rate += x->partition_cost[pl][PARTITION_SPLIT]; + sum_rate += cpi->partition_cost[pl][PARTITION_SPLIT]; subsize = get_subsize(bsize, PARTITION_SPLIT); for (i = 0; i < 4 && sum_rd < best_rd; ++i) { const int x_idx = (i & 1) * ms; @@ -2724,7 +2724,7 @@ static void nonrd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, sum_rd = INT64_MAX; } else { int pl = partition_plane_context(xd, mi_row, mi_col, bsize); - this_rate += x->partition_cost[pl][PARTITION_HORZ]; + this_rate += cpi->partition_cost[pl][PARTITION_HORZ]; sum_rate += this_rate; sum_dist += this_dist; sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); @@ -2758,7 +2758,7 @@ static void nonrd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, sum_rd = INT64_MAX; } else { int pl = partition_plane_context(xd, mi_row, mi_col, bsize); - this_rate += x->partition_cost[pl][PARTITION_VERT]; + this_rate += cpi->partition_cost[pl][PARTITION_VERT]; sum_rate += this_rate; sum_dist += this_dist; sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); @@ -2944,12 +2944,12 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, const TileInfo *const tile, case VAR_BASED_PARTITION: choose_partitioning(cpi, tile, mi_row, mi_col); nonrd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, - 1, &dummy_rate, &dummy_dist, x->pc_root); + 1, &dummy_rate, &dummy_dist, cpi->pc_root); break; case SOURCE_VAR_BASED_PARTITION: set_source_var_based_partition(cpi, tile, mi, mi_row, mi_col); nonrd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, - 1, &dummy_rate, &dummy_dist, x->pc_root); + 1, &dummy_rate, &dummy_dist, cpi->pc_root); break; case VAR_BASED_FIXED_PARTITION: case FIXED_PARTITION: @@ -2958,7 +2958,7 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, const TileInfo *const tile, get_nonrd_var_based_fixed_partition(cpi, mi_row, mi_col); set_fixed_partitioning(cpi, tile, mi, mi_row, mi_col, bsize); nonrd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, - 1, &dummy_rate, &dummy_dist, x->pc_root); + 1, &dummy_rate, &dummy_dist, cpi->pc_root); break; case REFERENCE_PARTITION: if (cpi->sf.partition_check || @@ -2969,12 +2969,12 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, const TileInfo *const tile, &cpi->sf.max_partition_size); nonrd_pick_partition(cpi, tile, tp, mi_row, mi_col, BLOCK_64X64, &dummy_rate, &dummy_dist, 1, INT64_MAX, - x->pc_root); + cpi->pc_root); } else { copy_partitioning(cm, mi, prev_mi); nonrd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, 1, &dummy_rate, &dummy_dist, - x->pc_root); + cpi->pc_root); } break; default: @@ -3037,7 +3037,7 @@ static void encode_frame_internal(VP9_COMP *cpi) { int i; struct macroblock_plane *const p = x->plane; struct macroblockd_plane *const pd = xd->plane; - PICK_MODE_CONTEXT *ctx = &x->pc_root->none; + PICK_MODE_CONTEXT *ctx = &cpi->pc_root->none; for (i = 0; i < MAX_MB_PLANE; ++i) { p[i].coeff = ctx->coeff_pbuf[i][0]; diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 911ce7c61..02536e34f 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -187,7 +187,7 @@ static void dealloc_compressor_data(VP9_COMP *cpi) { vpx_free(cpi->tok); cpi->tok = 0; - vp9_free_pc_tree(&cpi->mb); + vp9_free_pc_tree(cpi); for (i = 0; i < cpi->svc.number_spatial_layers; ++i) { LAYER_CONTEXT *const lc = &cpi->svc.layer_context[i]; @@ -455,7 +455,7 @@ void vp9_alloc_compressor_data(VP9_COMP *cpi) { CHECK_MEM_ERROR(cm, cpi->tok, vpx_calloc(tokens, sizeof(*cpi->tok))); } - vp9_setup_pc_tree(&cpi->common, &cpi->mb); + vp9_setup_pc_tree(&cpi->common, cpi); } static void update_frame_size(VP9_COMP *cpi) { diff --git a/vp9/encoder/vp9_encoder.h b/vp9/encoder/vp9_encoder.h index 17c826f8c..6ffbd3f19 100644 --- a/vp9/encoder/vp9_encoder.h +++ b/vp9/encoder/vp9_encoder.h @@ -24,6 +24,7 @@ #include "vp9/common/vp9_onyxc_int.h" #include "vp9/encoder/vp9_aq_cyclicrefresh.h" +#include "vp9/encoder/vp9_context_tree.h" #include "vp9/encoder/vp9_encodemb.h" #include "vp9/encoder/vp9_firstpass.h" #include "vp9/encoder/vp9_lookahead.h" @@ -502,6 +503,11 @@ typedef struct VP9_COMP { int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES]; int switchable_interp_costs[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS]; + PICK_MODE_CONTEXT *leaf_tree; + PC_TREE *pc_tree; + PC_TREE *pc_root; + int partition_cost[PARTITION_CONTEXTS][PARTITION_TYPES]; + #if CONFIG_MULTIPLE_ARF // ARF tracking variables. int multi_arf_enabled; diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index d2cc3c54d..56413afac 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -476,7 +476,7 @@ void vp9_first_pass(VP9_COMP *cpi) { TileInfo tile; struct macroblock_plane *const p = x->plane; struct macroblockd_plane *const pd = xd->plane; - const PICK_MODE_CONTEXT *ctx = &x->pc_root->none; + const PICK_MODE_CONTEXT *ctx = &cpi->pc_root->none; int i; int recon_yoffset, recon_uvoffset; diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index 64f3e5a74..6b7b5d56a 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -297,7 +297,7 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi) { fill_token_costs(x->token_costs, cm->fc.coef_probs); for (i = 0; i < PARTITION_CONTEXTS; i++) - vp9_cost_tokens(x->partition_cost[i], get_partition_probs(cm, i), + vp9_cost_tokens(cpi->partition_cost[i], get_partition_probs(cm, i), vp9_partition_tree); } -- 2.40.0