[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 551, Fri Sep 27 20:58:30 2002 UTC revision 552, Sat Sep 28 02:01:56 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;          int     frames = 0, credits_frames = 0, i_frames = 0, recminpsize = 0, recminisize = 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    
177                                    if (twopass->nns1.quant & NNSTATS_KEYFRAME)
178                                    {
179                                            if (!(twopass->nns1.kblk + twopass->nns1.mblk))
180                                                    recminisize = twopass->nns1.bytes;
181                                    }
182                                    else
183                                    {
184                                            if (!(twopass->nns1.kblk + twopass->nns1.mblk))
185                                                    recminpsize = twopass->nns1.bytes;
186                                    }
187    
188                                  ++frames;                                  ++frames;
189                          }                          }
190                          twopass->keyframe_locations[i_frames] = frames;                          twopass->keyframe_locations[i_frames] = frames;
# Line 257  Line 268 
268                                  {                                  {
269                                          twopass->minpsize = (twopass->nns1.kblk + 88) / 8;                                          twopass->minpsize = (twopass->nns1.kblk + 88) / 8;
270                                          twopass->minisize = ((twopass->nns1.kblk * 22) + 240) / 8;                                          twopass->minisize = ((twopass->nns1.kblk * 22) + 240) / 8;
271                                            if (recminpsize > twopass->minpsize)
272                                                    twopass->minpsize = recminpsize;
273                                            if (recminisize > twopass->minisize)
274                                                    twopass->minisize = recminisize;
275                                  }                                  }
276    
277                                  if (!codec_is_in_credits(&codec->config, frames) &&                                  if (!codec_is_in_credits(&codec->config, frames) &&
# Line 391  Line 406 
406    
407                                  total += twopass->nns1.bytes;                                  total += twopass->nns1.bytes;
408    
409                                    if (twopass->nns1.quant & NNSTATS_KEYFRAME)
410                                    {
411                                            if (!(twopass->nns1.kblk + twopass->nns1.mblk))
412                                                    recminisize = twopass->nns1.bytes;
413                                    }
414                                    else
415                                    {
416                                            if (!(twopass->nns1.kblk + twopass->nns1.mblk))
417                                                    recminpsize = twopass->nns1.bytes;
418                                    }
419    
420                                  ++frames;                                  ++frames;
421                          }                          }
422                          twopass->keyframe_locations[i_frames] = frames;                          twopass->keyframe_locations[i_frames] = frames;
# Line 527  Line 553 
553                                  {                                  {
554                                          twopass->minpsize = (twopass->nns1.kblk + 88) / 8;                                          twopass->minpsize = (twopass->nns1.kblk + 88) / 8;
555                                          twopass->minisize = ((twopass->nns1.kblk * 22) + 240) / 8;                                          twopass->minisize = ((twopass->nns1.kblk * 22) + 240) / 8;
556                                            if (recminpsize > twopass->minpsize)
557                                                    twopass->minpsize = recminpsize;
558                                            if (recminisize > twopass->minisize)
559                                                    twopass->minisize = recminisize;
560                                  }                                  }
561    
562                                  if (!codec_is_in_credits(&codec->config, frames) &&                                  if (!codec_is_in_credits(&codec->config, frames) &&
# Line 958  Line 988 
988                          bytes2 += ((int)dbytes);                          bytes2 += ((int)dbytes);
989                  }                  }
990    
991                    // cap bytes2 to first pass size, lowers number of quant=1 frames
992                    if (bytes2 > bytes1)
993                    {
994                            curve_comp_error += bytes2 - bytes1;
995                            bytes2 = bytes1;
996                    }
997                    else
998                    {
999                  if (frame->intra)                  if (frame->intra)
1000                  {                  {
1001                          if (bytes2 < twopass->minisize)                          if (bytes2 < twopass->minisize)
# Line 966  Line 1004 
1004                                  bytes2 = twopass->minisize;                                  bytes2 = twopass->minisize;
1005                          }                          }
1006                  }                  }
                 else  
                 {  
                         // cap bytes2 to first pass size, lowers number of quant=1 frames  
                         if (bytes2 > bytes1)  
                         {  
                                 curve_comp_error += bytes2 - bytes1;  
                                 bytes2 = bytes1;  
                         }  
1007                          else if (bytes2 < twopass->minpsize)                          else if (bytes2 < twopass->minpsize)
1008                                  bytes2 = twopass->minpsize;                                  bytes2 = twopass->minpsize;
1009                  }                  }
# Line 1009  Line 1039 
1039    
1040          // 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
1041          // too much/little bitrate          // too much/little bitrate
1042          overflow = (int)((double)overflow * bytes2 / twopass->average_frame *          overflow = (int)((double)overflow * bytes2 / twopass->average_frame);
                 (bytes1 - bytes2) / bytes1);  
1043    
1044          // Foxer: reign in overflow with huge frames          // Foxer: reign in overflow with huge frames
1045          if (labs(overflow) > labs(twopass->overflow))          if (labs(overflow) > labs(twopass->overflow))
# Line 1039  Line 1068 
1068                  bytes2 = twopass->max_framesize;                  bytes2 = twopass->max_framesize;
1069          }          }
1070    
1071          if (bytes2 < 1)          // make sure to not scale below the minimum framesize
1072            if (twopass->nns1.quant & NNSTATS_KEYFRAME)
1073          {          {
1074                  bytes2 = 1;                  if (bytes2 < twopass->minisize)
1075                            bytes2 = twopass->minisize;
1076          }          }
1077            else if (bytes2 < twopass->minpsize)
1078                    bytes2 = twopass->minpsize;
1079    
1080          twopass->bytes1 = bytes1;          twopass->bytes1 = bytes1;
1081          twopass->bytes2 = bytes2;          twopass->bytes2 = bytes2;
# Line 1262  Line 1295 
1295                  return;                  return;
1296          }          }
1297  }  }
1298    

Legend:
Removed from v.551  
changed lines
  Added in v.552

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