Skip to content

Commit

Permalink
Undo assumption that CFR output is identical to VFR output at the sam…
Browse files Browse the repository at this point in the history
…e framerate
  • Loading branch information
myrsloik committed May 25, 2024
1 parent a3c6e25 commit b0bae80
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
17 changes: 6 additions & 11 deletions src/avisynth/avssources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,14 @@ AvisynthVideoSource::AvisynthVideoSource(const char *SourceFile, int Track, FFMS
VI.num_frames = VP->NumFrames;
if (FPSNum > 0 && FPSDen > 0) {
vsh::reduceRational(&FPSNum, &FPSDen);
if (VI.fps_denominator != FPSDen || VI.fps_numerator != FPSNum) {
VI.fps_denominator = FPSDen;
VI.fps_numerator = FPSNum;
if (VP->NumFrames > 1) {
VI.num_frames = static_cast<int>((VP->LastTime - VP->FirstTime) * (1 + 1. / (VP->NumFrames - 1)) * FPSNum / FPSDen + 0.5);
if (VI.num_frames < 1)
VI.num_frames = 1;
} else {
VI.fps_denominator = FPSDen;
VI.fps_numerator = FPSNum;
if (VP->NumFrames > 1) {
VI.num_frames = static_cast<int>((VP->LastTime - VP->FirstTime) * (1 + 1. / (VP->NumFrames - 1)) * FPSNum / FPSDen + 0.5);
if (VI.num_frames < 1)
VI.num_frames = 1;
}
} else {
FPSNum = 0;
FPSDen = 0;
VI.num_frames = 1;
}
}

Expand Down
17 changes: 6 additions & 11 deletions src/vapoursynth/vapoursource4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,14 @@ VSVideoSource4::VSVideoSource4(const char *SourceFile, int Track, FFMS_Index *In

if (FPSNum > 0 && FPSDen > 0) {
vsh::reduceRational(&FPSNum, &FPSDen);
if (VI[0].fpsDen != FPSDen || VI[0].fpsNum != FPSNum) {
VI[0].fpsDen = FPSDen;
VI[0].fpsNum = FPSNum;
if (VP->NumFrames > 1) {
VI[0].numFrames = static_cast<int>((VP->LastTime - VP->FirstTime) * (1 + 1. / (VP->NumFrames - 1)) * FPSNum / FPSDen + 0.5);
if (VI[0].numFrames < 1)
VI[0].numFrames = 1;
} else {
VI[0].fpsDen = FPSDen;
VI[0].fpsNum = FPSNum;
if (VP->NumFrames > 1) {
VI[0].numFrames = static_cast<int>((VP->LastTime - VP->FirstTime) * (1 + 1. / (VP->NumFrames - 1)) * FPSNum / FPSDen + 0.5);
if (VI[0].numFrames < 1)
VI[0].numFrames = 1;
}
} else {
FPSNum = 0;
FPSDen = 0;
VI[0].numFrames = 1;
}
}

Expand Down

0 comments on commit b0bae80

Please sign in to comment.