Merge "Moving frame_coef_probs from VP9_COMP to local scope."
authorDmitry Kovalev <dkovalev@google.com>
Wed, 14 May 2014 19:38:19 +0000 (12:38 -0700)
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>
Wed, 14 May 2014 19:38:19 +0000 (12:38 -0700)
1  2 
vp9/encoder/vp9_bitstream.c
vp9/encoder/vp9_encoder.h

@@@ -485,8 -485,8 +485,8 @@@ static void write_modes(VP9_COMP *cpi
  }
  
  static void build_tree_distribution(VP9_COMP *cpi, TX_SIZE tx_size,
-                                     vp9_coeff_stats *coef_branch_ct) {
-   vp9_coeff_probs_model *coef_probs = cpi->frame_coef_probs[tx_size];
+                                     vp9_coeff_stats *coef_branch_ct,
+                                     vp9_coeff_probs_model *coef_probs) {
    vp9_coeff_count *coef_counts = cpi->coef_counts[tx_size];
    unsigned int (*eob_branch_ct)[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS] =
        cpi->common.counts.eob_branch[tx_size];
  
  static void update_coef_probs_common(vp9_writer* const bc, VP9_COMP *cpi,
                                       TX_SIZE tx_size,
-                                      vp9_coeff_stats *frame_branch_ct) {
-   vp9_coeff_probs_model *new_frame_coef_probs = cpi->frame_coef_probs[tx_size];
-   vp9_coeff_probs_model *old_frame_coef_probs =
-       cpi->common.fc.coef_probs[tx_size];
+                                      vp9_coeff_stats *frame_branch_ct,
+                                      vp9_coeff_probs_model *new_coef_probs) {
+   vp9_coeff_probs_model *old_coef_probs = cpi->common.fc.coef_probs[tx_size];
    const vp9_prob upd = DIFF_UPDATE_PROB;
    const int entropy_nodes_update = UNCONSTRAINED_NODES;
    int i, j, k, l, t;
            for (k = 0; k < COEF_BANDS; ++k) {
              for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) {
                for (t = 0; t < entropy_nodes_update; ++t) {
-                 vp9_prob newp = new_frame_coef_probs[i][j][k][l][t];
-                 const vp9_prob oldp = old_frame_coef_probs[i][j][k][l][t];
+                 vp9_prob newp = new_coef_probs[i][j][k][l][t];
+                 const vp9_prob oldp = old_coef_probs[i][j][k][l][t];
                  int s;
                  int u = 0;
                  if (t == PIVOT_NODE)
                    s = vp9_prob_diff_update_savings_search_model(
                        frame_branch_ct[i][j][k][l][0],
-                       old_frame_coef_probs[i][j][k][l], &newp, upd);
+                       old_coef_probs[i][j][k][l], &newp, upd);
                  else
                    s = vp9_prob_diff_update_savings_search(
                        frame_branch_ct[i][j][k][l][t], oldp, &newp, upd);
              for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) {
                // calc probs and branch cts for this frame only
                for (t = 0; t < entropy_nodes_update; ++t) {
-                 vp9_prob newp = new_frame_coef_probs[i][j][k][l][t];
-                 vp9_prob *oldp = old_frame_coef_probs[i][j][k][l] + t;
+                 vp9_prob newp = new_coef_probs[i][j][k][l][t];
+                 vp9_prob *oldp = old_coef_probs[i][j][k][l] + t;
                  const vp9_prob upd = DIFF_UPDATE_PROB;
                  int s;
                  int u = 0;
                  if (t == PIVOT_NODE)
                    s = vp9_prob_diff_update_savings_search_model(
                        frame_branch_ct[i][j][k][l][0],
-                       old_frame_coef_probs[i][j][k][l], &newp, upd);
+                       old_coef_probs[i][j][k][l], &newp, upd);
                  else
                    s = vp9_prob_diff_update_savings_search(
                        frame_branch_ct[i][j][k][l][t],
              for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) {
                // calc probs and branch cts for this frame only
                for (t = 0; t < entropy_nodes_update; ++t) {
-                 vp9_prob newp = new_frame_coef_probs[i][j][k][l][t];
-                 vp9_prob *oldp = old_frame_coef_probs[i][j][k][l] + t;
+                 vp9_prob newp = new_coef_probs[i][j][k][l][t];
+                 vp9_prob *oldp = old_coef_probs[i][j][k][l] + t;
                  int s;
                  int u = 0;
                  if (l >= prev_coef_contexts_to_update ||
                    if (t == PIVOT_NODE)
                      s = vp9_prob_diff_update_savings_search_model(
                          frame_branch_ct[i][j][k][l][0],
-                         old_frame_coef_probs[i][j][k][l], &newp, upd);
+                         old_coef_probs[i][j][k][l], &newp, upd);
                    else
                      s = vp9_prob_diff_update_savings_search(
                          frame_branch_ct[i][j][k][l][t],
@@@ -670,14 -669,17 +669,17 @@@ static void update_coef_probs(VP9_COMP 
    const TX_SIZE max_tx_size = tx_mode_to_biggest_tx_size[tx_mode];
    TX_SIZE tx_size;
    vp9_coeff_stats frame_branch_ct[TX_SIZES][PLANE_TYPES];
+   vp9_coeff_probs_model frame_coef_probs[TX_SIZES][PLANE_TYPES];
  
    vp9_clear_system_state();
  
    for (tx_size = TX_4X4; tx_size <= TX_32X32; ++tx_size)
-     build_tree_distribution(cpi, tx_size, frame_branch_ct[tx_size]);
+     build_tree_distribution(cpi, tx_size, frame_branch_ct[tx_size],
+                             frame_coef_probs[tx_size]);
  
    for (tx_size = TX_4X4; tx_size <= max_tx_size; ++tx_size)
-     update_coef_probs_common(w, cpi, tx_size, frame_branch_ct[tx_size]);
+     update_coef_probs_common(w, cpi, tx_size, frame_branch_ct[tx_size],
+                              frame_coef_probs[tx_size]);
  }
  
  static void encode_loopfilter(struct loopfilter *lf,
@@@ -1006,10 -1008,9 +1008,10 @@@ static void write_frame_size_with_refs(
      found = cm->width == cfg->y_crop_width &&
              cm->height == cfg->y_crop_height;
  
 -    // TODO(ivan): This prevents a bug while more than 3 buffers are used. Do it
 -    // in a better way.
 -    if (cpi->use_svc) {
 +    // Set "found" to 0 for temporal svc and for spatial svc key frame
 +    if (cpi->use_svc &&
 +        (cpi->svc.number_spatial_layers == 1 ||
 +         cpi->svc.layer_context[cpi->svc.spatial_layer_id].is_key_frame)) {
        found = 0;
      }
      vp9_wb_write_bit(wb, found);
@@@ -40,6 -40,8 +40,6 @@@
  extern "C" {
  #endif
  
 -// #define MODE_TEST_HIT_STATS
 -
  #define DEFAULT_GF_INTERVAL         10
  
  #define MAX_MODES 30
@@@ -274,7 -276,6 +274,7 @@@ typedef struct VP9EncoderConfig 
  
    int arnr_max_frames;
    int arnr_strength;
 +  int arnr_type;
  
    int tile_columns;
    int tile_rows;
@@@ -391,7 -392,6 +391,6 @@@ typedef struct VP9_COMP 
    RATE_CONTROL rc;
  
    vp9_coeff_count coef_counts[TX_SIZES][PLANE_TYPES];
-   vp9_coeff_probs_model frame_coef_probs[TX_SIZES][PLANE_TYPES];
  
    struct vpx_codec_pkt_list  *output_pkt_list;
  
  
    YV12_BUFFER_CONFIG alt_ref_buffer;
    YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS];
 -  int fixed_divide[512];
  
  #if CONFIG_INTERNAL_STATS
    unsigned int mode_chosen_counts[MAX_MODES];
  
    search_site_config ss_cfg;
  
 +  int mbmode_cost[INTRA_MODES];
 +  unsigned inter_mode_cost[INTER_MODE_CONTEXTS][INTER_MODES];
 +  int intra_uv_mode_cost[FRAME_TYPES][INTRA_MODES];
 +  int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES];
 +  int switchable_interp_costs[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS];
 +
  #if CONFIG_MULTIPLE_ARF
    // ARF tracking variables.
    int multi_arf_enabled;
    int this_frame_weight;
    int max_arf_level;
  #endif
 -
 -#ifdef MODE_TEST_HIT_STATS
 -  // Debug / test stats
 -  int64_t mode_test_hits[BLOCK_SIZES];
 -#endif
  } VP9_COMP;
  
  void vp9_initialize_enc();
@@@ -552,7 -552,14 +551,7 @@@ int vp9_set_reference_enc(VP9_COMP *cpi
  
  int vp9_update_entropy(VP9_COMP *cpi, int update);
  
 -int vp9_set_roimap(VP9_COMP *cpi, unsigned char *map,
 -                   unsigned int rows, unsigned int cols,
 -                   int delta_q[MAX_SEGMENTS],
 -                   int delta_lf[MAX_SEGMENTS],
 -                   unsigned int threshold[MAX_SEGMENTS]);
 -
 -int vp9_set_active_map(VP9_COMP *cpi, unsigned char *map,
 -                       unsigned int rows, unsigned int cols);
 +int vp9_set_active_map(VP9_COMP *cpi, unsigned char *map, int rows, int cols);
  
  int vp9_set_internal_size(VP9_COMP *cpi,
                            VPX_SCALING horiz_mode, VPX_SCALING vert_mode);
@@@ -586,8 -593,7 +585,8 @@@ static INLINE YV12_BUFFER_CONFIG *get_r
  // alt ref frames tend to be coded at a higher than ambient quality
  static INLINE int frame_is_boosted(const VP9_COMP *cpi) {
    return frame_is_intra_only(&cpi->common) || cpi->refresh_alt_ref_frame ||
 -         (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref);
 +         (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref) ||
 +         vp9_is_upper_layer_key_frame(cpi);
  }
  
  static INLINE int get_token_alloc(int mb_rows, int mb_cols) {