Skip to content

Commit f12bf06

Browse files
kcatmadame-rachelle
authored andcommitted
Allow larger denominators for IVF movies
1 parent 6f7eede commit f12bf06

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/common/cutscenes/movieplayer.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,7 @@ class VpxPlayer : public MoviePlayer
325325
vpx_codec_ctx_t codec{};
326326
vpx_codec_iter_t iter = nullptr;
327327

328-
uint32_t convnumer;
329-
uint32_t convdenom;
328+
double convrate;
330329

331330
uint64_t nsecsperframe;
332331
uint64_t nextframetime;
@@ -398,15 +397,20 @@ class VpxPlayer : public MoviePlayer
398397
if (numframes == 0) return false;
399398
fr.Seek(4, FileReader::SeekCur);
400399

401-
if (fpsdenominator > 1000 || fpsnumerator == 0 || fpsdenominator == 0)
400+
if (fpsnumerator == 0 || fpsdenominator == 0)
402401
{
403402
// default to 30 fps if the header does not provide useful info.
404403
fpsdenominator = 30;
405404
fpsnumerator = 1;
406405
}
407406

408-
convnumer = 120 * fpsnumerator;
409-
convdenom = fpsdenominator * origframedelay;
407+
if (origframedelay < 1)
408+
convrate = 0.0;
409+
else
410+
{
411+
convrate = 120.0 * double(fpsnumerator);
412+
convrate /= double(fpsdenominator) * double(origframedelay);
413+
}
410414

411415
nsecsperframe = int64_t(fpsnumerator) * 1'000'000'000 / fpsdenominator;
412416
nextframetime = 0;
@@ -577,7 +581,7 @@ class VpxPlayer : public MoviePlayer
577581
if (framenum >= numframes) stop = true;
578582

579583
bool nostopsound = (flags & NOSOUNDCUTOFF);
580-
int soundframe = convdenom ? Scale(framenum, convnumer, convdenom) : framenum;
584+
int soundframe = (convrate > 0.0) ? int(convrate * framenum) : framenum;
581585
if (soundframe > lastsoundframe)
582586
{
583587
if (soundtrack == -1)

0 commit comments

Comments
 (0)