From e0175ac494ac0d4565c75a0e2676ccf4831e69a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lo=C3=AFse=20Brosseau?= Date: Wed, 13 Nov 2024 14:40:34 -0500 Subject: [PATCH] Enable first frame to start at 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Éloïse Brosseau --- src/lib/image/MovieFFMpeg/MovieFFMpeg.cpp | 5 ++--- src/lib/ip/IPBaseNodes/StackIPNode.cpp | 2 +- src/lib/ip/IPCore/Session.cpp | 24 +++++++++++------------ 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/lib/image/MovieFFMpeg/MovieFFMpeg.cpp b/src/lib/image/MovieFFMpeg/MovieFFMpeg.cpp index 45267f488..4f4156fb2 100644 --- a/src/lib/image/MovieFFMpeg/MovieFFMpeg.cpp +++ b/src/lib/image/MovieFFMpeg/MovieFFMpeg.cpp @@ -1331,9 +1331,8 @@ MovieFFMpegReader::getFirstFrame(AVRational rate) // offset by the given positive value. // - m_formatStartFrame = max(int64_t(0), int64_t(0.49 + av_q2d(rate) * - double(m_avFormatContext->start_time) / double(AV_TIME_BASE))); - int64_t firstFrame = max(int64_t(m_formatStartFrame), int64_t(1)); + int64_t firstFrame = std::max(static_cast(0), static_cast(0.49 + av_q2d(rate) * + static_cast(m_avFormatContext->start_time) / static_cast(AV_TIME_BASE))); for (int i = 0; i < m_avFormatContext->nb_streams; i++) { diff --git a/src/lib/ip/IPBaseNodes/StackIPNode.cpp b/src/lib/ip/IPBaseNodes/StackIPNode.cpp index 293f813bb..965f37474 100644 --- a/src/lib/ip/IPBaseNodes/StackIPNode.cpp +++ b/src/lib/ip/IPBaseNodes/StackIPNode.cpp @@ -291,7 +291,7 @@ StackIPNode::computeRanges() m_info.cutIn = m_info.start; m_info.cutOut = m_info.end; - m_offset = m_info.start - 1; + m_offset = std::max(m_info.start - 1, 0); if (m_outputFPS->front() == 0.0 && !m_rangeInfos.empty() && ! m_rangeInfos[0].isUndiscovered) { diff --git a/src/lib/ip/IPCore/Session.cpp b/src/lib/ip/IPCore/Session.cpp index 71b455bb0..1508370fd 100644 --- a/src/lib/ip/IPCore/Session.cpp +++ b/src/lib/ip/IPCore/Session.cpp @@ -312,14 +312,14 @@ Session::Session(IPGraph* graph) m_waitForUploadThreadPrefetch(false), m_readingGTO(false), m_sessionType(SequenceSession), - m_rangeStart(1), - m_rangeEnd(2), + m_rangeStart(0), + m_rangeEnd(1), m_outputVideoDevice(0), m_controlVideoDevice(0), - m_narrowedRangeStart(1), - m_narrowedRangeEnd(2), - m_inPoint(1), - m_outPoint(2), + m_narrowedRangeStart(0), + m_narrowedRangeEnd(1), + m_inPoint(0), + m_outPoint(1), m_notPersistent(0), m_inc(1), //m_loadingError(false), @@ -336,7 +336,7 @@ Session::Session(IPGraph* graph) m_overhead(0), m_shift(0), m_skipped(0), - m_frame(1), + m_frame(0), m_fastStart(true), m_bufferWait(false), m_latencyWait(false), @@ -1706,11 +1706,11 @@ Session::clear() graph().flushAudioCache(); if (!m_beingDeleted) graph().reset(App()->videoModules()); setFileName("Untitled"); - setInPoint(1); - setOutPoint(2); - setRangeStart(1); - setRangeEnd(2); - setFrameInternal(1); + setInPoint(0); + setOutPoint(1); + setRangeStart(0); + setRangeEnd(1); + setFrameInternal(0); if (!m_beingDeleted) {