Experimental: adding debug logging to Frame destructor and QImage cleanup. Also, preventing processing of empty samples

This commit is contained in:
Jonathan Thomas
2022-07-26 15:09:57 -05:00
parent 285059baad
commit 89321d3bae
3 changed files with 12 additions and 0 deletions

View File

@@ -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;

View File

@@ -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();

View File

@@ -11,6 +11,7 @@
#ifndef OPENSHOT_QT_UTILITIES_H
#define OPENSHOT_QT_UTILITIES_H
#include <iostream>
#include <Qt>
#include <QTextStream>
@@ -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<unsigned char*>(info);
std::cout << "--> delete pointer, info: " << info << std::endl;
delete[] qbuffer;
}
} // namespace