From 89321d3baeba8fed952ca9ce4038aeab074d8c9d Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Tue, 26 Jul 2022 15:09:57 -0500 Subject: [PATCH] Experimental: adding debug logging to Frame destructor and QImage cleanup. Also, preventing processing of empty samples --- src/FFmpegReader.cpp | 6 ++++++ src/Frame.cpp | 2 ++ src/QtUtilities.h | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index 9064be37..cc156f88 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -1465,6 +1465,12 @@ void FFmpegReader::ProcessAudioPacket(int64_t requested_frame) { // Estimate the # of samples and the end of this packet's location (to prevent GAPS for the next timestamp) int pts_remaining_samples = packet_samples / info.channels; // Adjust for zero based array + // Bail if no samples found + if (pts_remaining_samples == 0) { + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessAudioPacket (No samples, bailing)", "packet_samples", packet_samples, "info.channels", info.channels, "pts_remaining_samples", pts_remaining_samples); + return; + } + // DEBUG (FOR AUDIO ISSUES) - Get the audio packet start time (in seconds) int64_t adjusted_pts = audio_pts; double audio_seconds = (double(adjusted_pts) * info.audio_timebase.ToDouble()) + pts_offset_seconds; diff --git a/src/Frame.cpp b/src/Frame.cpp index 0cec0193..273983ad 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -108,6 +108,8 @@ void Frame::DeepCopy(const Frame& other) // Destructor Frame::~Frame() { + std::cout << "Frame::~Frame, number: " << number << ", has_image_data: " << has_image_data << std::endl; + // Clear all pointers image.reset(); audio.reset(); diff --git a/src/QtUtilities.h b/src/QtUtilities.h index a827bc37..b5c4ac04 100644 --- a/src/QtUtilities.h +++ b/src/QtUtilities.h @@ -11,6 +11,7 @@ #ifndef OPENSHOT_QT_UTILITIES_H #define OPENSHOT_QT_UTILITIES_H +#include #include #include @@ -28,10 +29,13 @@ namespace openshot { // Clean up buffer after QImage is deleted static inline void cleanUpBuffer(void *info) { + std::cout << "--> cleanUpBuffer, info: " << info << std::endl; if (!info) return; // Remove buffer since QImage tells us to + std::cout << "--> reinterpret cast, info: " << info << std::endl; auto* qbuffer = reinterpret_cast(info); + std::cout << "--> delete pointer, info: " << info << std::endl; delete[] qbuffer; } } // namespace