Merge commit 'f61272f0efd80da437570aad2c40e00f9d3f4fe6'
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 12 Jan 2013 12:32:13 +0000 (13:32 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 12 Jan 2013 12:32:13 +0000 (13:32 +0100)
* commit 'f61272f0efd80da437570aad2c40e00f9d3f4fe6':
  ratecontrol: K&R cosmetic formatting
  rtpdec: Remove a useless todo comment

Conflicts:
libavcodec/ratecontrol.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/ratecontrol.c
libavformat/rtpdec.c

  #endif
  
  static int init_pass2(MpegEncContext *s);
- static double get_qscale(MpegEncContext *s, RateControlEntry *rce, double rate_factor, int frame_num);
+ static double get_qscale(MpegEncContext *s, RateControlEntry *rce,
+                          double rate_factor, int frame_num);
  
- void ff_write_pass1_stats(MpegEncContext *s){
-     snprintf(s->avctx->stats_out, 256, "in:%d out:%d type:%d q:%d itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d skipcount:%d hbits:%d;\n",
-              s->current_picture_ptr->f.display_picture_number, s->current_picture_ptr->f.coded_picture_number, s->pict_type,
-              s->current_picture.f.quality, s->i_tex_bits, s->p_tex_bits, s->mv_bits, s->misc_bits,
-              s->f_code, s->b_code, s->current_picture.mc_mb_var_sum, s->current_picture.mb_var_sum, s->i_count, s->skip_count, s->header_bits);
+ void ff_write_pass1_stats(MpegEncContext *s)
+ {
+     snprintf(s->avctx->stats_out, 256,
+              "in:%d out:%d type:%d q:%d itex:%d ptex:%d mv:%d misc:%d "
+              "fcode:%d bcode:%d mc-var:%d var:%d icount:%d skipcount:%d hbits:%d;\n",
+              s->current_picture_ptr->f.display_picture_number,
+              s->current_picture_ptr->f.coded_picture_number,
+              s->pict_type,
+              s->current_picture.f.quality,
+              s->i_tex_bits,
+              s->p_tex_bits,
+              s->mv_bits,
+              s->misc_bits,
+              s->f_code,
+              s->b_code,
+              s->current_picture.mc_mb_var_sum,
+              s->current_picture.mb_var_sum,
+              s->i_count, s->skip_count,
+              s->header_bits);
  }
  
- static double get_fps(AVCodecContext *avctx){
++static double get_fps(AVCodecContext *avctx)
++{
 +    return 1.0 / av_q2d(avctx->time_base) / FFMAX(avctx->ticks_per_frame, 1);
 +}
 +
- static inline double qp2bits(RateControlEntry *rce, double qp){
-     if(qp<=0.0){
+ static inline double qp2bits(RateControlEntry *rce, double qp)
+ {
+     if (qp <= 0.0) {
          av_log(NULL, AV_LOG_ERROR, "qp<=0.0\n");
      }
-     return rce->qscale * (double)(rce->i_tex_bits + rce->p_tex_bits+1)/ qp;
+     return rce->qscale * (double)(rce->i_tex_bits + rce->p_tex_bits + 1) / qp;
  }
  
- static inline double bits2qp(RateControlEntry *rce, double bits){
-     if(bits<0.9){
+ static inline double bits2qp(RateControlEntry *rce, double bits)
+ {
+     if (bits < 0.9) {
          av_log(NULL, AV_LOG_ERROR, "bits<0.9\n");
      }
-     return rce->qscale * (double)(rce->i_tex_bits + rce->p_tex_bits+1)/ bits;
+     return rce->qscale * (double)(rce->i_tex_bits + rce->p_tex_bits + 1) / bits;
  }
  
  int ff_rate_control_init(MpegEncContext *s)
      };
      emms_c();
  
-     res = av_expr_parse(&rcc->rc_eq_eval, s->avctx->rc_eq ? s->avctx->rc_eq : "tex^qComp", const_names, func1_names, func1, NULL, NULL, 0, s->avctx);
 +    if (!s->avctx->rc_max_available_vbv_use && s->avctx->rc_buffer_size) {
 +        if (s->avctx->rc_max_rate) {
 +            s->avctx->rc_max_available_vbv_use = av_clipf(s->avctx->rc_max_rate/(s->avctx->rc_buffer_size*get_fps(s->avctx)), 1.0/3, 1.0);
 +        } else
 +            s->avctx->rc_max_available_vbv_use = 1.0;
 +    }
 +
+     res = av_expr_parse(&rcc->rc_eq_eval,
+                         s->avctx->rc_eq ? s->avctx->rc_eq : "tex^qComp",
+                         const_names, func1_names, func1,
+                         NULL, NULL, 0, s->avctx);
      if (res < 0) {
          av_log(s->avctx, AV_LOG_ERROR, "Error parsing rc_eq \"%s\"\n", s->avctx->rc_eq);
          return res;
      }
  
-     for(i=0; i<5; i++){
-         rcc->pred[i].coeff= FF_QP2LAMBDA * 7.0;
-         rcc->pred[i].count= 1.0;
-         rcc->pred[i].decay= 0.4;
-         rcc->i_cplx_sum [i]=
-         rcc->p_cplx_sum [i]=
-         rcc->mv_bits_sum[i]=
-         rcc->qscale_sum [i]=
-         rcc->frame_count[i]= 1; // 1 is better because of 1/0 and such
-         rcc->last_qscale_for[i]=FF_QP2LAMBDA * 5;
+     for (i = 0; i < 5; i++) {
+         rcc->pred[i].coeff = FF_QP2LAMBDA * 7.0;
+         rcc->pred[i].count = 1.0;
+         rcc->pred[i].decay = 0.4;
+         rcc->i_cplx_sum [i] =
+         rcc->p_cplx_sum [i] =
+         rcc->mv_bits_sum[i] =
+         rcc->qscale_sum [i] =
+         rcc->frame_count[i] = 1; // 1 is better because of 1/0 and such
+         rcc->last_qscale_for[i] = FF_QP2LAMBDA * 5;
      }
-     rcc->buffer_index= s->avctx->rc_initial_buffer_occupancy;
+     rcc->buffer_index = s->avctx->rc_initial_buffer_occupancy;
 +    if (!rcc->buffer_index)
 +        rcc->buffer_index = s->avctx->rc_buffer_size * 3 / 4;
  
-     if(s->flags&CODEC_FLAG_PASS2){
+     if (s->flags & CODEC_FLAG_PASS2) {
          int i;
          char *p;
  
              return -1;
          }
          /* init stuff with the user specified complexity */
-         if(s->avctx->rc_initial_cplx){
-             for(i=0; i<60*30; i++){
-                 double bits= s->avctx->rc_initial_cplx * (i/10000.0 + 1.0)*s->mb_num;
+         if (s->avctx->rc_initial_cplx) {
+             for (i = 0; i < 60 * 30; i++) {
+                 double bits = s->avctx->rc_initial_cplx * (i / 10000.0 + 1.0) * s->mb_num;
                  RateControlEntry rce;
  
-                 if     (i%((s->gop_size+3)/4)==0) rce.pict_type= AV_PICTURE_TYPE_I;
-                 else if(i%(s->max_b_frames+1))    rce.pict_type= AV_PICTURE_TYPE_B;
-                 else                              rce.pict_type= AV_PICTURE_TYPE_P;
-                 rce.new_pict_type= rce.pict_type;
-                 rce.mc_mb_var_sum= bits*s->mb_num/100000;
-                 rce.mb_var_sum   = s->mb_num;
-                 rce.qscale   = FF_QP2LAMBDA * 2;
-                 rce.f_code   = 2;
-                 rce.b_code   = 1;
-                 rce.misc_bits= 1;
-                 if(s->pict_type== AV_PICTURE_TYPE_I){
-                     rce.i_count   = s->mb_num;
-                     rce.i_tex_bits= bits;
-                     rce.p_tex_bits= 0;
-                     rce.mv_bits= 0;
-                 }else{
-                     rce.i_count   = 0; //FIXME we do know this approx
-                     rce.i_tex_bits= 0;
-                     rce.p_tex_bits= bits*0.9;
-                     rce.mv_bits= bits*0.1;
+                 if (i % ((s->gop_size + 3) / 4) == 0)
+                     rce.pict_type = AV_PICTURE_TYPE_I;
+                 else if (i % (s->max_b_frames + 1))
+                     rce.pict_type = AV_PICTURE_TYPE_B;
+                 else
+                     rce.pict_type = AV_PICTURE_TYPE_P;
+                 rce.new_pict_type = rce.pict_type;
+                 rce.mc_mb_var_sum = bits * s->mb_num / 100000;
+                 rce.mb_var_sum    = s->mb_num;
+                 rce.qscale    = FF_QP2LAMBDA * 2;
+                 rce.f_code    = 2;
+                 rce.b_code    = 1;
+                 rce.misc_bits = 1;
+                 if (s->pict_type == AV_PICTURE_TYPE_I) {
+                     rce.i_count    = s->mb_num;
+                     rce.i_tex_bits = bits;
+                     rce.p_tex_bits = 0;
+                     rce.mv_bits    = 0;
+                 } else {
+                     rce.i_count    = 0; // FIXME we do know this approx
+                     rce.i_tex_bits = 0;
+                     rce.p_tex_bits = bits * 0.9;
+                     rce.mv_bits    = bits * 0.1;
                  }
-                 rcc->i_cplx_sum [rce.pict_type] += rce.i_tex_bits*rce.qscale;
-                 rcc->p_cplx_sum [rce.pict_type] += rce.p_tex_bits*rce.qscale;
+                 rcc->i_cplx_sum[rce.pict_type]  += rce.i_tex_bits * rce.qscale;
+                 rcc->p_cplx_sum[rce.pict_type]  += rce.p_tex_bits * rce.qscale;
                  rcc->mv_bits_sum[rce.pict_type] += rce.mv_bits;
-                 rcc->frame_count[rce.pict_type] ++;
+                 rcc->frame_count[rce.pict_type]++;
+                 get_qscale(s, &rce, rcc->pass1_wanted_bits / rcc->pass1_rc_eq_output_sum, i);
  
-                 get_qscale(s, &rce, rcc->pass1_wanted_bits/rcc->pass1_rc_eq_output_sum, i);
-                 rcc->pass1_wanted_bits+= s->bit_rate/get_fps(s->avctx); //FIXME misbehaves a little for variable fps
+                 // FIXME misbehaves a little for variable fps
 -                rcc->pass1_wanted_bits += s->bit_rate / (1 / av_q2d(s->avctx->time_base));
++                rcc->pass1_wanted_bits += s->bit_rate / get_fps(s->avctx);
              }
          }
      }
  
      return 0;
@@@ -276,12 -298,13 +312,13 @@@ void ff_rate_control_uninit(MpegEncCont
  #endif
  }
  
- int ff_vbv_update(MpegEncContext *s, int frame_size){
-     RateControlContext *rcc= &s->rc_context;
-     const double fps= get_fps(s->avctx);
-     const int buffer_size= s->avctx->rc_buffer_size;
-     const double min_rate= s->avctx->rc_min_rate/fps;
-     const double max_rate= s->avctx->rc_max_rate/fps;
+ int ff_vbv_update(MpegEncContext *s, int frame_size)
+ {
+     RateControlContext *rcc = &s->rc_context;
 -    const double fps        = 1 / av_q2d(s->avctx->time_base);
++    const double fps        = get_fps(s->avctx);
+     const int buffer_size   = s->avctx->rc_buffer_size;
+     const double min_rate   = s->avctx->rc_min_rate / fps;
+     const double max_rate   = s->avctx->rc_max_rate / fps;
  
      av_dlog(s, "%d %f %d %f %f\n",
              buffer_size, rcc->buffer_index, frame_size, min_rate, max_rate);
@@@ -426,31 -465,37 +479,37 @@@ static void get_qminmax(int *qmin_ret, 
  
      assert(qmin <= qmax);
  
-     if(pict_type==AV_PICTURE_TYPE_B){
-         qmin= (int)(qmin*FFABS(s->avctx->b_quant_factor)+s->avctx->b_quant_offset + 0.5);
-         qmax= (int)(qmax*FFABS(s->avctx->b_quant_factor)+s->avctx->b_quant_offset + 0.5);
-     }else if(pict_type==AV_PICTURE_TYPE_I){
-         qmin= (int)(qmin*FFABS(s->avctx->i_quant_factor)+s->avctx->i_quant_offset + 0.5);
-         qmax= (int)(qmax*FFABS(s->avctx->i_quant_factor)+s->avctx->i_quant_offset + 0.5);
+     switch (pict_type) {
+     case AV_PICTURE_TYPE_B:
+         qmin = (int)(qmin * FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset + 0.5);
+         qmax = (int)(qmax * FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset + 0.5);
+         break;
+     case AV_PICTURE_TYPE_I:
+         qmin = (int)(qmin * FFABS(s->avctx->i_quant_factor) + s->avctx->i_quant_offset + 0.5);
+         qmax = (int)(qmax * FFABS(s->avctx->i_quant_factor) + s->avctx->i_quant_offset + 0.5);
+         break;
      }
  
-     qmin= av_clip(qmin, 1, FF_LAMBDA_MAX);
-     qmax= av_clip(qmax, 1, FF_LAMBDA_MAX);
+     qmin = av_clip(qmin, 1, FF_LAMBDA_MAX);
+     qmax = av_clip(qmax, 1, FF_LAMBDA_MAX);
  
-     if(qmax<qmin) qmax= qmin;
+     if (qmax < qmin)
+         qmax = qmin;
  
-     *qmin_ret= qmin;
-     *qmax_ret= qmax;
+     *qmin_ret = qmin;
+     *qmax_ret = qmax;
  }
  
- static double modify_qscale(MpegEncContext *s, RateControlEntry *rce, double q, int frame_num){
-     RateControlContext *rcc= &s->rc_context;
+ static double modify_qscale(MpegEncContext *s, RateControlEntry *rce,
+                             double q, int frame_num)
+ {
+     RateControlContext *rcc  = &s->rc_context;
+     const double buffer_size = s->avctx->rc_buffer_size;
 -    const double fps         = 1 / av_q2d(s->avctx->time_base);
++    const double fps         = get_fps(s->avctx);
+     const double min_rate    = s->avctx->rc_min_rate / fps;
+     const double max_rate    = s->avctx->rc_max_rate / fps;
+     const int pict_type      = rce->new_pict_type;
      int qmin, qmax;
-     const int pict_type= rce->new_pict_type;
-     const double buffer_size= s->avctx->rc_buffer_size;
-     const double fps= get_fps(s->avctx);
-     const double min_rate= s->avctx->rc_min_rate / fps;
-     const double max_rate= s->avctx->rc_max_rate / fps;
  
      get_qminmax(&qmin, &qmax, s, pict_type);
  
@@@ -681,85 -750,86 +764,91 @@@ float ff_rate_estimate_qscale(MpegEncCo
  
      get_qminmax(&qmin, &qmax, s, pict_type);
  
-     fps= get_fps(s->avctx);
-         /* update predictors */
-     if(picture_number>2 && !dry_run){
-         const int last_var= s->last_pict_type == AV_PICTURE_TYPE_I ? rcc->last_mb_var_sum : rcc->last_mc_mb_var_sum;
 -    fps = 1 / av_q2d(s->avctx->time_base);
++    fps = get_fps(s->avctx);
+     /* update predictors */
+     if (picture_number > 2 && !dry_run) {
+         const int last_var = s->last_pict_type == AV_PICTURE_TYPE_I ? rcc->last_mb_var_sum
+                                                                     : rcc->last_mc_mb_var_sum;
 +        av_assert1(s->frame_bits >= s->stuffing_bits);
-         update_predictor(&rcc->pred[s->last_pict_type], rcc->last_qscale, sqrt(last_var), s->frame_bits - s->stuffing_bits);
+         update_predictor(&rcc->pred[s->last_pict_type],
+                          rcc->last_qscale,
 -                         sqrt(last_var), s->frame_bits);
++                         sqrt(last_var),
++                         s->frame_bits - s->stuffing_bits);
      }
  
-     if(s->flags&CODEC_FLAG_PASS2){
-         assert(picture_number>=0);
-         if(picture_number >= rcc->num_entries) {
+     if (s->flags & CODEC_FLAG_PASS2) {
+         assert(picture_number >= 0);
 -        assert(picture_number < rcc->num_entries);
++        if (picture_number >= rcc->num_entries) {
 +            av_log(s, AV_LOG_ERROR, "Input is longer than 2-pass log file\n");
 +            return -1;
 +        }
-         rce= &rcc->entry[picture_number];
-         wanted_bits= rce->expected_bits;
-     }else{
+         rce         = &rcc->entry[picture_number];
+         wanted_bits = rce->expected_bits;
+     } else {
          Picture *dts_pic;
-         rce= &local_rce;
+         rce = &local_rce;
  
-         //FIXME add a dts field to AVFrame and ensure its set and use it here instead of reordering
-         //but the reordering is simpler for now until h.264 b pyramid must be handeld
-         if(s->pict_type == AV_PICTURE_TYPE_B || s->low_delay)
-             dts_pic= s->current_picture_ptr;
+         /* FIXME add a dts field to AVFrame and ensure it is set and use it
+          * here instead of reordering but the reordering is simpler for now
+          * until H.264 B-pyramid must be handled. */
+         if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay)
+             dts_pic = s->current_picture_ptr;
          else
-             dts_pic= s->last_picture_ptr;
+             dts_pic = s->last_picture_ptr;
  
          if (!dts_pic || dts_pic->f.pts == AV_NOPTS_VALUE)
-             wanted_bits= (uint64_t)(s->bit_rate*(double)picture_number/fps);
+             wanted_bits = (uint64_t)(s->bit_rate * (double)picture_number / fps);
          else
-             wanted_bits = (uint64_t)(s->bit_rate*(double)dts_pic->f.pts / fps);
+             wanted_bits = (uint64_t)(s->bit_rate * (double)dts_pic->f.pts / fps);
      }
  
-     diff= s->total_bits - wanted_bits;
-     br_compensation= (a->bit_rate_tolerance - diff)/a->bit_rate_tolerance;
-     if(br_compensation<=0.0) br_compensation=0.001;
+     diff = s->total_bits - wanted_bits;
+     br_compensation = (a->bit_rate_tolerance - diff) / a->bit_rate_tolerance;
+     if (br_compensation <= 0.0)
+         br_compensation = 0.001;
  
-     var= pict_type == AV_PICTURE_TYPE_I ? pic->mb_var_sum : pic->mc_mb_var_sum;
+     var = pict_type == AV_PICTURE_TYPE_I ? pic->mb_var_sum : pic->mc_mb_var_sum;
  
      short_term_q = 0; /* avoid warning */
-     if(s->flags&CODEC_FLAG_PASS2){
-         if(pict_type!=AV_PICTURE_TYPE_I)
+     if (s->flags & CODEC_FLAG_PASS2) {
+         if (pict_type != AV_PICTURE_TYPE_I)
              assert(pict_type == rce->new_pict_type);
  
-         q= rce->new_qscale / br_compensation;
+         q = rce->new_qscale / br_compensation;
          av_dlog(s, "%f %f %f last:%d var:%d type:%d//\n", q, rce->new_qscale,
                  br_compensation, s->frame_bits, var, pict_type);
-     }else{
-         rce->pict_type=
-         rce->new_pict_type= pict_type;
-         rce->mc_mb_var_sum= pic->mc_mb_var_sum;
-         rce->mb_var_sum   = pic->   mb_var_sum;
-         rce->qscale   = FF_QP2LAMBDA * 2;
-         rce->f_code   = s->f_code;
-         rce->b_code   = s->b_code;
-         rce->misc_bits= 1;
-         bits= predict_size(&rcc->pred[pict_type], rce->qscale, sqrt(var));
-         if(pict_type== AV_PICTURE_TYPE_I){
-             rce->i_count   = s->mb_num;
-             rce->i_tex_bits= bits;
-             rce->p_tex_bits= 0;
-             rce->mv_bits= 0;
-         }else{
-             rce->i_count   = 0; //FIXME we do know this approx
-             rce->i_tex_bits= 0;
-             rce->p_tex_bits= bits*0.9;
-             rce->mv_bits= bits*0.1;
+     } else {
+         rce->pict_type     =
+         rce->new_pict_type = pict_type;
+         rce->mc_mb_var_sum = pic->mc_mb_var_sum;
+         rce->mb_var_sum    = pic->mb_var_sum;
+         rce->qscale        = FF_QP2LAMBDA * 2;
+         rce->f_code        = s->f_code;
+         rce->b_code        = s->b_code;
+         rce->misc_bits     = 1;
+         bits = predict_size(&rcc->pred[pict_type], rce->qscale, sqrt(var));
+         if (pict_type == AV_PICTURE_TYPE_I) {
+             rce->i_count    = s->mb_num;
+             rce->i_tex_bits = bits;
+             rce->p_tex_bits = 0;
+             rce->mv_bits    = 0;
+         } else {
+             rce->i_count    = 0;    // FIXME we do know this approx
+             rce->i_tex_bits = 0;
+             rce->p_tex_bits = bits * 0.9;
+             rce->mv_bits    = bits * 0.1;
          }
-         rcc->i_cplx_sum [pict_type] += rce->i_tex_bits*rce->qscale;
-         rcc->p_cplx_sum [pict_type] += rce->p_tex_bits*rce->qscale;
+         rcc->i_cplx_sum[pict_type]  += rce->i_tex_bits * rce->qscale;
+         rcc->p_cplx_sum[pict_type]  += rce->p_tex_bits * rce->qscale;
          rcc->mv_bits_sum[pict_type] += rce->mv_bits;
-         rcc->frame_count[pict_type] ++;
+         rcc->frame_count[pict_type]++;
  
-         bits= rce->i_tex_bits + rce->p_tex_bits;
-         rate_factor= rcc->pass1_wanted_bits/rcc->pass1_rc_eq_output_sum * br_compensation;
+         bits        = rce->i_tex_bits + rce->p_tex_bits;
+         rate_factor = rcc->pass1_wanted_bits /
+                       rcc->pass1_rc_eq_output_sum * br_compensation;
  
-         q= get_qscale(s, rce, rate_factor, picture_number);
+         q = get_qscale(s, rce, rate_factor, picture_number);
          if (q < 0)
              return -1;
  
  
  static int init_pass2(MpegEncContext *s)
  {
-     RateControlContext *rcc= &s->rc_context;
-     AVCodecContext *a= s->avctx;
+     RateControlContext *rcc = &s->rc_context;
+     AVCodecContext *a       = s->avctx;
      int i, toobig;
-     double fps= get_fps(s->avctx);
-     double complexity[5]={0,0,0,0,0};   // approximate bits at quant=1
-     uint64_t const_bits[5]={0,0,0,0,0}; // quantizer independent bits
 -    double fps             = 1 / av_q2d(s->avctx->time_base);
++    double fps             = get_fps(s->avctx);
+     double complexity[5]   = { 0 }; // approximate bits at quant=1
+     uint64_t const_bits[5] = { 0 }; // quantizer independent bits
      uint64_t all_const_bits;
-     uint64_t all_available_bits= (uint64_t)(s->bit_rate*(double)rcc->num_entries/fps);
-     double rate_factor=0;
+     uint64_t all_available_bits = (uint64_t)(s->bit_rate *
+                                              (double)rcc->num_entries / fps);
+     double rate_factor          = 0;
      double step;
-     //int last_i_frame=-10000000;
-     const int filter_size= (int)(a->qblur*4) | 1;
+     const int filter_size = (int)(a->qblur * 4) | 1;
      double expected_bits;
      double *qscale, *blurred_qscale, qscale_sum;
  
          return -1;
      }
  
-     qscale= av_malloc(sizeof(double)*rcc->num_entries);
-     blurred_qscale= av_malloc(sizeof(double)*rcc->num_entries);
+     qscale         = av_malloc(sizeof(double) * rcc->num_entries);
+     blurred_qscale = av_malloc(sizeof(double) * rcc->num_entries);
      toobig = 0;
  
-     for(step=256*256; step>0.0000001; step*=0.5){
-         expected_bits=0;
-         rate_factor+= step;
+     for (step = 256 * 256; step > 0.0000001; step *= 0.5) {
+         expected_bits = 0;
+         rate_factor  += step;
  
-         rcc->buffer_index= s->avctx->rc_buffer_size/2;
+         rcc->buffer_index = s->avctx->rc_buffer_size / 2;
  
          /* find qscale */
-         for(i=0; i<rcc->num_entries; i++){
-             RateControlEntry *rce= &rcc->entry[i];
-             qscale[i]= get_qscale(s, &rcc->entry[i], rate_factor, i);
+         for (i = 0; i < rcc->num_entries; i++) {
+             RateControlEntry *rce = &rcc->entry[i];
+             qscale[i] = get_qscale(s, &rcc->entry[i], rate_factor, i);
              rcc->last_qscale_for[rce->pict_type] = qscale[i];
          }
-         assert(filter_size%2==1);
+         assert(filter_size % 2 == 1);
  
          /* fixed I/B QP relative to P mode */
-         for(i=FFMAX(0, rcc->num_entries-300); i<rcc->num_entries; i++){
-             RateControlEntry *rce= &rcc->entry[i];
++        for (i = FFMAX(0, rcc->num_entries - 300); i < rcc->num_entries; i++) {
++            RateControlEntry *rce = &rcc->entry[i];
 +
-             qscale[i]= get_diff_limited_q(s, rce, qscale[i]);
++            qscale[i] = get_diff_limited_q(s, rce, qscale[i]);
 +        }
 +
-         for(i=rcc->num_entries-1; i>=0; i--){
-             RateControlEntry *rce= &rcc->entry[i];
+         for (i = rcc->num_entries - 1; i >= 0; i--) {
+             RateControlEntry *rce = &rcc->entry[i];
  
-             qscale[i]= get_diff_limited_q(s, rce, qscale[i]);
+             qscale[i] = get_diff_limited_q(s, rce, qscale[i]);
          }
  
          /* smooth curve */
Simple merge