From 43fd4fccb1135bc2482727c4f836dee83071ad0e Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Sat, 30 Jan 2016 02:10:40 -0600 Subject: [PATCH] Fixing an audio popping / video frame flashing issue with the Timeline calculating the incorrect frame from a Clip. Now the timeline correctly rounds the time diff, and determines the correct frame. --- src/FrameMapper.cpp | 2 -- src/QtPlayer.cpp | 2 +- src/Timeline.cpp | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/FrameMapper.cpp b/src/FrameMapper.cpp index 7e10229e..942f85e8 100644 --- a/src/FrameMapper.cpp +++ b/src/FrameMapper.cpp @@ -374,8 +374,6 @@ tr1::shared_ptr FrameMapper::GetFrame(long int requested_frame) throw(Rea if (final_frame) return final_frame; // Minimum number of frames to process (for performance reasons) - // TODO: Find a safe way to deal with Closing the reader while multi-processing is happening - // In the meantime, I'm leaving this at 1 int minimum_frames = OPEN_MP_NUM_PROCESSORS; // Set the number of threads in OpenMP diff --git a/src/QtPlayer.cpp b/src/QtPlayer.cpp index 2710b847..55f5623e 100644 --- a/src/QtPlayer.cpp +++ b/src/QtPlayer.cpp @@ -57,7 +57,7 @@ void QtPlayer::SetSource(const std::string &source) { FFmpegReader *ffreader = new FFmpegReader(source); ffreader->debug = false; - ffreader->Open(); + ffreader->DisplayInfo(); //reader = new FrameMapper(ffreader, ffreader->info.fps, PULLDOWN_NONE, ffreader->info.sample_rate, ffreader->info.channels, ffreader->info.channel_layout); reader = new Timeline(ffreader->info.width, ffreader->info.height, ffreader->info.fps, ffreader->info.sample_rate, ffreader->info.channels, ffreader->info.channel_layout); diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 54dc796d..092570e7 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -664,7 +664,7 @@ tr1::shared_ptr Timeline::GetFrame(long int requested_frame) throw(Reader // Determine the frame needed for this clip (based on the position on the timeline) float time_diff = (requested_time - clip->Position()) + clip->Start(); - int clip_frame_number = (time_diff * info.fps.ToFloat()) + 1; + int clip_frame_number = round(time_diff * info.fps.ToFloat()) + 1; // Debug output AppendDebugMethod("Timeline::GetFrame (Calculate clip's frame #)", "time_diff", time_diff, "requested_time", requested_time, "clip->Position()", clip->Position(), "clip->Start()", clip->Start(), "info.fps.ToFloat()", info.fps.ToFloat(), "clip_frame_number", clip_frame_number);