From 9503483a5d51230c757f3bdf406538ac1cdecb3b Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 11 Apr 2016 17:43:56 -0500 Subject: [PATCH] Added a lock around adding missing frame images (in FFmpegReader), which might be causing crashes, and fixed a log issue inside the FrameMapper, which also might be affecting performance and/or causing crashes. --- src/FFmpegReader.cpp | 8 +++----- src/FrameMapper.cpp | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index 91aba7a4..9a3dcf75 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -1561,13 +1561,11 @@ bool FFmpegReader::CheckMissingFrame(long int requested_frame) // Create missing frame (and copy image from previous frame) tr1::shared_ptr missing_frame = CreateFrame(itr->second); if (last_video_frame != NULL && missing_frame != NULL) { - missing_frame->AddImage(tr1::shared_ptr(new QImage(*last_video_frame->GetImage())), true); // Add this frame to the processed map (since it's already done) - { - const GenericScopedLock lock(processingCriticalSection); - processed_video_frames[itr->second] = itr->second; - } + const GenericScopedLock lock(processingCriticalSection); + missing_frame->AddImage(tr1::shared_ptr(new QImage(*last_video_frame->GetImage())), true); + processed_video_frames[itr->second] = itr->second; // Remove missing frame from map missing_video_frames.erase(itr); diff --git a/src/FrameMapper.cpp b/src/FrameMapper.cpp index 5b1ac2ac..04062860 100644 --- a/src/FrameMapper.cpp +++ b/src/FrameMapper.cpp @@ -381,11 +381,11 @@ tr1::shared_ptr FrameMapper::GetFrame(long int requested_frame) throw(Rea // Allow nested OpenMP sections omp_set_nested(true); + // Debug output + AppendDebugMethod("FrameMapper::GetFrame (Loop through frames)", "requested_frame", requested_frame, "minimum_frames", minimum_frames, "", -1, "", -1, "", -1, "", -1); + #pragma omp parallel { - // Debug output - AppendDebugMethod("FrameMapper::GetFrame (Loop through frames)", "requested_frame", requested_frame, "minimum_frames", minimum_frames, "", -1, "", -1, "", -1, "", -1); - // Loop through all requested frames, each frame gets it's own thread #pragma omp for ordered for (long int frame_number = requested_frame; frame_number < requested_frame + minimum_frames; frame_number++)