From b0bae808b9dd090285f585282be7a5944d765104 Mon Sep 17 00:00:00 2001 From: Fredrik Mellbin Date: Sat, 25 May 2024 14:18:33 +0200 Subject: [PATCH] Undo assumption that CFR output is identical to VFR output at the same framerate --- src/avisynth/avssources.cpp | 17 ++++++----------- src/vapoursynth/vapoursource4.cpp | 17 ++++++----------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/avisynth/avssources.cpp b/src/avisynth/avssources.cpp index 63ef7de3d9..79646168f0 100644 --- a/src/avisynth/avssources.cpp +++ b/src/avisynth/avssources.cpp @@ -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((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((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; } } diff --git a/src/vapoursynth/vapoursource4.cpp b/src/vapoursynth/vapoursource4.cpp index 6460f0dfd1..be437fb60b 100644 --- a/src/vapoursynth/vapoursource4.cpp +++ b/src/vapoursynth/vapoursource4.cpp @@ -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((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((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; } }