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

Diff of /vfw/src/2pass.c

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

revision 1.7.2.2, Sat Sep 28 02:01:47 2002 UTC revision 1.9, Mon Sep 23 06:05:55 2002 UTC
# Line 41  Line 41 
41          DWORD version = -20;          DWORD version = -20;
42          DWORD read, wrote;          DWORD read, wrote;
43    
44          int     frames = 0, credits_frames = 0, i_frames = 0, recminpsize = 0, recminisize = 0;          int     frames = 0, credits_frames = 0, i_frames = 0;
45          __int64 total_ext = 0, total = 0, i_total = 0, i_boost_total = 0, start = 0, end = 0, start_curved = 0, end_curved = 0;          __int64 total_ext = 0, total = 0, i_total = 0, i_boost_total = 0, start = 0, end = 0, start_curved = 0, end_curved = 0;
46          __int64 desired = (__int64)codec->config.desired_size * 1024;          __int64 desired = (__int64)codec->config.desired_size * 1024;
47    
# Line 174  Line 174 
174                                  else                                  else
175                                          ++credits_frames;                                          ++credits_frames;
176    
                                 if (twopass->nns1.quant & NNSTATS_KEYFRAME)  
                                 {  
                                         if (!(twopass->nns1.kblk + twopass->nns1.mblk))  
                                                 recminisize = twopass->nns1.bytes;  
                                 }  
                                 else  
                                 {  
                                         if (!(twopass->nns1.kblk + twopass->nns1.mblk))  
                                                 recminpsize = twopass->nns1.bytes;  
                                 }  
   
177                                  ++frames;                                  ++frames;
178                          }                          }
179                          twopass->keyframe_locations[i_frames] = frames;                          twopass->keyframe_locations[i_frames] = frames;
# Line 268  Line 257 
257                                  {                                  {
258                                          twopass->minpsize = (twopass->nns1.kblk + 88) / 8;                                          twopass->minpsize = (twopass->nns1.kblk + 88) / 8;
259                                          twopass->minisize = ((twopass->nns1.kblk * 22) + 240) / 8;                                          twopass->minisize = ((twopass->nns1.kblk * 22) + 240) / 8;
                                         if (recminpsize > twopass->minpsize)  
                                                 twopass->minpsize = recminpsize;  
                                         if (recminisize > twopass->minisize)  
                                                 twopass->minisize = recminisize;  
260                                  }                                  }
261    
262                                  if (!codec_is_in_credits(&codec->config, frames) &&                                  if (!codec_is_in_credits(&codec->config, frames) &&
# Line 406  Line 391 
391    
392                                  total += twopass->nns1.bytes;                                  total += twopass->nns1.bytes;
393    
                                 if (twopass->nns1.quant & NNSTATS_KEYFRAME)  
                                 {  
                                         if (!(twopass->nns1.kblk + twopass->nns1.mblk))  
                                                 recminisize = twopass->nns1.bytes;  
                                 }  
                                 else  
                                 {  
                                         if (!(twopass->nns1.kblk + twopass->nns1.mblk))  
                                                 recminpsize = twopass->nns1.bytes;  
                                 }  
   
394                                  ++frames;                                  ++frames;
395                          }                          }
396                          twopass->keyframe_locations[i_frames] = frames;                          twopass->keyframe_locations[i_frames] = frames;
# Line 553  Line 527 
527                                  {                                  {
528                                          twopass->minpsize = (twopass->nns1.kblk + 88) / 8;                                          twopass->minpsize = (twopass->nns1.kblk + 88) / 8;
529                                          twopass->minisize = ((twopass->nns1.kblk * 22) + 240) / 8;                                          twopass->minisize = ((twopass->nns1.kblk * 22) + 240) / 8;
                                         if (recminpsize > twopass->minpsize)  
                                                 twopass->minpsize = recminpsize;  
                                         if (recminisize > twopass->minisize)  
                                                 twopass->minisize = recminisize;  
530                                  }                                  }
531    
532                                  if (!codec_is_in_credits(&codec->config, frames) &&                                  if (!codec_is_in_credits(&codec->config, frames) &&
# Line 988  Line 958 
958                          bytes2 += ((int)dbytes);                          bytes2 += ((int)dbytes);
959                  }                  }
960    
                 // cap bytes2 to first pass size, lowers number of quant=1 frames  
                 if (bytes2 > bytes1)  
                 {  
                         curve_comp_error += bytes2 - bytes1;  
                         bytes2 = bytes1;  
                 }  
                 else  
                 {  
961                          if (frame->intra)                          if (frame->intra)
962                          {                          {
963                                  if (bytes2 < twopass->minisize)                                  if (bytes2 < twopass->minisize)
# Line 1004  Line 966 
966                                          bytes2 = twopass->minisize;                                          bytes2 = twopass->minisize;
967                                  }                                  }
968                          }                          }
969                    else
970                    {
971                            // cap bytes2 to first pass size, lowers number of quant=1 frames
972                            if (bytes2 > bytes1)
973                            {
974                                    curve_comp_error += bytes2 - bytes1;
975                                    bytes2 = bytes1;
976                            }
977                          else if (bytes2 < twopass->minpsize)                          else if (bytes2 < twopass->minpsize)
978                                  bytes2 = twopass->minpsize;                                  bytes2 = twopass->minpsize;
979                  }                  }
# Line 1039  Line 1009 
1009    
1010          // 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
1011          // too much/little bitrate          // too much/little bitrate
1012          overflow = (int)((double)overflow * bytes2 / twopass->average_frame);          overflow = (int)((double)overflow * bytes2 / twopass->average_frame *
1013                    (bytes1 - bytes2) / bytes1);
1014    
1015          // Foxer: reign in overflow with huge frames          // Foxer: reign in overflow with huge frames
1016          if (labs(overflow) > labs(twopass->overflow))          if (labs(overflow) > labs(twopass->overflow))
# Line 1068  Line 1039 
1039                  bytes2 = twopass->max_framesize;                  bytes2 = twopass->max_framesize;
1040          }          }
1041    
1042          // make sure to not scale below the minimum framesize          if (bytes2 < 1)
         if (twopass->nns1.quant & NNSTATS_KEYFRAME)  
1043          {          {
1044                  if (bytes2 < twopass->minisize)                  bytes2 = 1;
                         bytes2 = twopass->minisize;  
1045          }          }
         else if (bytes2 < twopass->minpsize)  
                 bytes2 = twopass->minpsize;  
1046    
1047          twopass->bytes1 = bytes1;          twopass->bytes1 = bytes1;
1048          twopass->bytes2 = bytes2;          twopass->bytes2 = bytes2;
# Line 1295  Line 1262 
1262                  return;                  return;
1263          }          }
1264  }  }
   

Legend:
Removed from v.1.7.2.2  
changed lines
  Added in v.1.9

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