[svn] / trunk / vfw / src / 2pass.c Repository:
ViewVC logotype

Diff of /trunk/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 482, Thu Sep 12 21:18:49 2002 UTC
# Line 161  Line 161 
161                                  {                                  {
162                                          if (twopass->nns1.quant & NNSTATS_KEYFRAME)                                          if (twopass->nns1.quant & NNSTATS_KEYFRAME)
163                                          {                                          {
164                                                  i_boost_total = twopass->nns2.bytes * codec->config.keyframe_boost / 100;                                                  i_boost_total += twopass->nns2.bytes * codec->config.keyframe_boost / 100;
165                                                  i_total += twopass->nns2.bytes;                                                  i_total += twopass->nns2.bytes;
166                                                  twopass->keyframe_locations[i_frames] = frames;                                                  twopass->keyframe_locations[i_frames] = frames;
167                                                  ++i_frames;                                                  ++i_frames;
# 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 793  Line 794 
794                  }                  }
795                  else    // DLG_MODE_2PASS_2_EXT                  else    // DLG_MODE_2PASS_2_EXT
796                  {                  {
797                            if (codec->config.credits_mode == CREDITS_MODE_QUANT)
798                            {
799                                    if (codec->config.credits_quant_i != codec->config.credits_quant_p)
800                                    {
801                                            frame->quant = frame->intra ?
802                                                    codec->config.credits_quant_i :
803                                                    codec->config.credits_quant_p;
804                                    }
805                                    else
806                                    {
807                                            frame->quant = codec->config.credits_quant_p;
808                                            frame->intra = -1;
809                                    }
810    
811                                    twopass->bytes1 = bytes1;
812                                    twopass->bytes2 = bytes1;
813                                    twopass->desired_bytes2 = bytes1;
814                                    return ICERR_OK;
815                            }
816                            else
817                          bytes2 = twopass->nns2.bytes;                          bytes2 = twopass->nns2.bytes;
818                  }                  }
819          }          }
# Line 929  Line 950 
950    
951          twopass->desired_bytes2 = bytes2;          twopass->desired_bytes2 = bytes2;
952    
953            // if this keyframe is too close to the next,
954            // reduce it's byte allotment
955            if (frame->intra && !credits_pos)
956            {
957                    KFdistance = codec->twopass.keyframe_locations[codec->twopass.KF_idx] -
958                            codec->twopass.keyframe_locations[codec->twopass.KF_idx - 1];
959    
960                    if (KFdistance < codec->config.kftreshold)
961                    {
962                            KFdistance = KFdistance - codec->config.min_key_interval;
963    
964                            if (KFdistance >= 0)
965                            {
966                                    KF_min_size = bytes2 * (100 - codec->config.kfreduction) / 100;
967                                    if (KF_min_size < 1)
968                                            KF_min_size = 1;
969    
970                                    bytes2 = KF_min_size + (bytes2 - KF_min_size) * KFdistance /
971                                            (codec->config.kftreshold - codec->config.min_key_interval);
972    
973                                    if (bytes2 < 1)
974                                            bytes2 = 1;
975                            }
976                    }
977            }
978    
979          // 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
980          // too much/little bitrate          // too much/little bitrate
981          overflow = (int)((double)overflow * bytes2 / twopass->average_frame);          overflow = (int)((double)overflow * bytes2 / twopass->average_frame);
# Line 1110  Line 1157 
1157                          codec->twopass.quant_count[frame->quant]++;                          codec->twopass.quant_count[frame->quant]++;
1158                          if ((codec->twopass.nns1.quant & NNSTATS_KEYFRAME))                          if ((codec->twopass.nns1.quant & NNSTATS_KEYFRAME))
1159                          {                          {
1160                                    // calculate how much to distribute per frame in
1161                                    // order to make up for this keyframe's overflow
1162    
1163                                  codec->twopass.overflow += codec->twopass.KFoverflow;                                  codec->twopass.overflow += codec->twopass.KFoverflow;
1164                                  codec->twopass.KFoverflow = codec->twopass.desired_bytes2 - frame->length;                                  codec->twopass.KFoverflow = codec->twopass.desired_bytes2 - frame->length;
1165    
# Line 1132  Line 1182 
1182                          }                          }
1183                          else                          else
1184                          {                          {
1185                                    // distribute part of the keyframe overflow
1186    
1187                                  codec->twopass.overflow += codec->twopass.desired_bytes2 - frame->length +                                  codec->twopass.overflow += codec->twopass.desired_bytes2 - frame->length +
1188                                          codec->twopass.KFoverflow_partial;                                          codec->twopass.KFoverflow_partial;
1189                                  codec->twopass.KFoverflow -= codec->twopass.KFoverflow_partial;                                  codec->twopass.KFoverflow -= codec->twopass.KFoverflow_partial;

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

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