[svn] / branches / dev-api-3 / vfw / src / 2pass.c Repository:
ViewVC logotype

Diff of /branches/dev-api-3/vfw/src/2pass.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 342, Fri Jul 26 19:58:22 2002 UTC revision 365, Wed Aug 7 06:13:18 2002 UTC
# Line 710  Line 710 
710          int overflow;          int overflow;
711          int credits_pos;          int credits_pos;
712          int capped_to_max_framesize = 0;          int capped_to_max_framesize = 0;
713            int KFdistance, KF_min_size;
714    
715          if (codec->framenum == 0)          if (codec->framenum == 0)
716          {          {
# Line 929  Line 930 
930    
931          twopass->desired_bytes2 = bytes2;          twopass->desired_bytes2 = bytes2;
932    
933            // if this keyframe is too close to the next,
934            // reduce it's byte allotment
935            if (frame->intra && !credits_pos)
936            {
937                    KFdistance = codec->twopass.keyframe_locations[codec->twopass.KF_idx] -
938                            codec->twopass.keyframe_locations[codec->twopass.KF_idx - 1];
939    
940                    if (KFdistance < codec->config.kftreshold)
941                    {
942                            KFdistance = KFdistance - codec->config.min_key_interval;
943    
944                            if (KFdistance >= 0)
945                            {
946                                    KF_min_size = bytes2 * (100 - codec->config.kfreduction) / 100;
947                                    if (KF_min_size < 1)
948                                            KF_min_size = 1;
949    
950                                    bytes2 = KF_min_size + (bytes2 - KF_min_size) * KFdistance /
951                                            (codec->config.kftreshold - codec->config.min_key_interval);
952    
953                                    if (bytes2 < 1)
954                                            bytes2 = 1;
955                            }
956                    }
957            }
958    
959          // Foxer: scale overflow in relation to average size, so smaller frames don't get          // Foxer: scale overflow in relation to average size, so smaller frames don't get
960          // too much/little bitrate          // too much/little bitrate
961          overflow = (int)((double)overflow * bytes2 / twopass->average_frame);          overflow = (int)((double)overflow * bytes2 / twopass->average_frame);
# Line 1110  Line 1137 
1137                          codec->twopass.quant_count[frame->quant]++;                          codec->twopass.quant_count[frame->quant]++;
1138                          if ((codec->twopass.nns1.quant & NNSTATS_KEYFRAME))                          if ((codec->twopass.nns1.quant & NNSTATS_KEYFRAME))
1139                          {                          {
1140                                    // calculate how much to distribute per frame in
1141                                    // order to make up for this keyframe's overflow
1142    
1143                                  codec->twopass.overflow += codec->twopass.KFoverflow;                                  codec->twopass.overflow += codec->twopass.KFoverflow;
1144                                  codec->twopass.KFoverflow = codec->twopass.desired_bytes2 - frame->length;                                  codec->twopass.KFoverflow = codec->twopass.desired_bytes2 - frame->length;
1145    
# Line 1132  Line 1162 
1162                          }                          }
1163                          else                          else
1164                          {                          {
1165                                    // distribute part of the keyframe overflow
1166    
1167                                  codec->twopass.overflow += codec->twopass.desired_bytes2 - frame->length +                                  codec->twopass.overflow += codec->twopass.desired_bytes2 - frame->length +
1168                                          codec->twopass.KFoverflow_partial;                                          codec->twopass.KFoverflow_partial;
1169                                  codec->twopass.KFoverflow -= codec->twopass.KFoverflow_partial;                                  codec->twopass.KFoverflow -= codec->twopass.KFoverflow_partial;

Legend:
Removed from v.342  
changed lines
  Added in v.365

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4