]> granicus.if.org Git - libvpx/commitdiff
Merge "Adding get_pass() function."
authorDmitry Kovalev <dkovalev@google.com>
Fri, 18 Apr 2014 17:38:20 +0000 (10:38 -0700)
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>
Fri, 18 Apr 2014 17:38:20 +0000 (10:38 -0700)
1  2 
vp9/encoder/vp9_onyx_if.c

index 42ed11d0a115f35f4b84290338bf7c27a68dcd81,1e0c11f43aa414b6ed65011875d34fef7f9c7232..78372b803879827ad58ede3ac0a94d689b2947fc
@@@ -372,6 -372,9 +372,6 @@@ static void update_reference_segmentati
      cache_ptr += cm->mi_cols;
    }
  }
 -static int is_slowest_mode(int mode) {
 -  return (mode == TWO_PASS_SECOND_BEST || mode == ONE_PASS_BEST);
 -}
  
  static void set_rd_speed_thresholds(VP9_COMP *cpi) {
    int i;
  
    // Set baseline threshold values
    for (i = 0; i < MAX_MODES; ++i)
 -    rd->thresh_mult[i] = is_slowest_mode(cpi->oxcf.mode) ? -500 : 0;
 +    rd->thresh_mult[i] = is_best_mode(cpi->oxcf.mode) ? -500 : 0;
  
    rd->thresh_mult[THR_NEARESTMV] = 0;
    rd->thresh_mult[THR_NEARESTG] = 0;
@@@ -461,7 -464,7 +461,7 @@@ static void set_rd_speed_thresholds_sub
    int i;
  
    for (i = 0; i < MAX_REFS; ++i)
 -    rd->thresh_mult_sub8x8[i] = is_slowest_mode(cpi->oxcf.mode)  ? -500 : 0;
 +    rd->thresh_mult_sub8x8[i] = is_best_mode(cpi->oxcf.mode)  ? -500 : 0;
  
    rd->thresh_mult_sub8x8[THR_LAST] += 2500;
    rd->thresh_mult_sub8x8[THR_GOLD] += 2500;
@@@ -676,6 -679,23 +676,23 @@@ static void init_config(struct VP9_COM
      cpi->fixed_divide[i] = 0x80000 / i;
  }
  
+ static int get_pass(MODE mode) {
+   switch (mode) {
+     case REALTIME:
+     case ONE_PASS_GOOD:
+     case ONE_PASS_BEST:
+       return 0;
+     case TWO_PASS_FIRST:
+       return 1;
+     case TWO_PASS_SECOND_GOOD:
+     case TWO_PASS_SECOND_BEST:
+       return 2;
+   }
+   return -1;
+ }
  void vp9_change_config(struct VP9_COMP *cpi, const VP9_CONFIG *oxcf) {
    VP9_COMMON *const cm = &cpi->common;
    RATE_CONTROL *const rc = &cpi->rc;
      assert(cm->bit_depth > BITS_8);
  
    cpi->oxcf = *oxcf;
-   switch (cpi->oxcf.mode) {
-       // Real time and one pass deprecated in test code base
-     case ONE_PASS_GOOD:
-       cpi->pass = 0;
-       break;
-     case ONE_PASS_BEST:
-       cpi->pass = 0;
-       break;
-     case TWO_PASS_FIRST:
-       cpi->pass = 1;
-       break;
-     case TWO_PASS_SECOND_GOOD:
-       cpi->pass = 2;
-       break;
-     case TWO_PASS_SECOND_BEST:
-       cpi->pass = 2;
-       break;
-     case REALTIME:
-       cpi->pass = 0;
-       cpi->oxcf.play_alternate = 0;
-       break;
-   }
+   cpi->pass = get_pass(cpi->oxcf.mode);
+   if (cpi->oxcf.mode == REALTIME)
+     cpi->oxcf.play_alternate = 0;
  
    cpi->oxcf.lossless = oxcf->lossless;
    if (cpi->oxcf.lossless) {
    rc->worst_quality = cpi->oxcf.worst_allowed_q;
    rc->best_quality = cpi->oxcf.best_allowed_q;
  
 -  // active values should only be modified if out of new range
 -
 -  cpi->cq_target_quality = cpi->oxcf.cq_level;
 -
    cm->interp_filter = DEFAULT_INTERP_FILTER;
  
    cm->display_width = cpi->oxcf.width;
@@@ -1691,7 -1690,6 +1683,7 @@@ static int recode_loop_test(const VP9_C
                              int q, int maxq, int minq) {
    const VP9_COMMON *const cm = &cpi->common;
    const RATE_CONTROL *const rc = &cpi->rc;
 +  const VP9_CONFIG *const oxcf = &cpi->oxcf;
    int force_recode = 0;
  
    // Special case trap if maximum allowed frame size exceeded.
      if ((rc->projected_frame_size > high_limit && q < maxq) ||
          (rc->projected_frame_size < low_limit && q > minq)) {
        force_recode = 1;
 -    } else if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) {
 +    } else if (oxcf->end_usage == USAGE_CONSTRAINED_QUALITY) {
        // Deal with frame undershoot and whether or not we are
        // below the automatically set cq level.
 -      if (q > cpi->cq_target_quality &&
 +      if (q > oxcf->cq_level &&
            rc->projected_frame_size < ((rc->this_frame_target * 7) >> 3)) {
          force_recode = 1;
        }
@@@ -1887,7 -1885,7 +1879,7 @@@ static void output_frame_level_debug_st
          (double)vp9_dc_quant(cm->base_qindex, 0) / 4.0,
          cpi->rc.avg_q,
          vp9_convert_qindex_to_q(cpi->rc.ni_av_qi),
 -        vp9_convert_qindex_to_q(cpi->cq_target_quality),
 +        vp9_convert_qindex_to_q(cpi->oxcf.cq_level),
          cpi->refresh_last_frame, cpi->refresh_golden_frame,
          cpi->refresh_alt_ref_frame, cm->frame_type, cpi->rc.gfu_boost,
          cpi->twopass.bits_left,