Guest User

Untitled

a guest
Aug 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.42 KB | None | 0 0
  1. // start times of each frame, in ms
  2. double *framestart;
  3.  
  4. // end times of each frame, in ms
  5. // these are equal to the start time of the next frame, except the last frame, which we BS
  6. double *frameend;
  7.  
  8. // length of one CFR frame, in ms
  9. double cfrlength;
  10.  
  11. // number of frames total
  12. int nframes;
  13.  
  14. // for each output frame, what input frame it corresponds to
  15. int *remaps;
  16.  
  17. // this is strictly concept code
  18. ...
  19.  
  20. for (int i = 0, int outpos = 0; i < nframes; i++)
  21. {
  22.   // start of the space we have to insert frame into
  23.   double cfrstart = cfrlength * outpos;
  24.   // total length of the window we have to insert a frame into (can be negative, this is ok)
  25.   double diff = frameend[i] - cfrstart;
  26.  
  27.   // try to insert one copy of frame at low threshold (so likely to succeed)
  28.   if (diff >= th1)
  29.   {
  30.     diff -= cfrlength; // consumed an entire frame's worth of space
  31.     remaps[outpos] = i; // show this frame
  32.     outpos++;
  33.   }
  34.   else
  35.   { // record that we dropped a frame
  36.     ndrop++;
  37.   }
  38.  
  39.   // try to insert as many as needed copies of this frame at high threshold (so less likely to succeed)
  40.   while (diff >= th2)
  41.   {
  42.     diff -= cfrlength;
  43.     remaps[outpos] = i;
  44.     outpos++;
  45.     // record that we duped a frame
  46.     ndup++;
  47.   }
  48. }
  49. // the most important significant thing that is missing is a special case for frames before frame 0 of the vfr stream,
  50. // which can be filled with blank if there's enough space
Add Comment
Please, Sign In to add comment