fixed playback/export flickering and hanging

This commit is contained in:
itsmattkc
2018-10-29 17:01:52 +11:00
parent 2e2846597e
commit a54fee767d
32 changed files with 216 additions and 163 deletions
+32
View File
@@ -0,0 +1,32 @@
#include "debug.h"
#include <QFile>
#include <QDateTime>
#include <QStandardPaths>
#ifndef QT_DEBUG
QFile debug_file;
QDebug debug_out(&debug_file);
#endif
void setup_debug() {
#ifndef QT_DEBUG
debug_file.setFileName(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/debug_log");
if (debug_file.open(QFile::WriteOnly)) {
QString debug_intro = "Olive Session " + QString::number(QDateTime::currentMSecsSinceEpoch());
debug_file.write(debug_intro.toLatin1());
} else {
debug_out = QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC).debug();
}
#endif
}
void close_debug() {
#ifndef QT_DEBUG
if (debug_file.isOpen()) {
debug_file.putChar(10);
debug_file.putChar(10);
debug_file.close();
}
#endif
}
+16
View File
@@ -0,0 +1,16 @@
#ifndef DEBUG_H
#define DEBUG_H
#include <QDebug>
#ifndef QT_DEBUG
#define dout debug_out << "\n"
extern QDebug debug_out;
#else
#define dout qDebug()
#endif
void setup_debug();
void close_debug();
#endif // DEBUG_H
+4 -4
View File
@@ -4,10 +4,10 @@
#include <QOpenGLWidget>
#include <QFileDialog>
#include <QThread>
#include <QDebug>
#include <QMessageBox>
#include <QOpenGLContext>
#include "debug.h"
#include "panels/panels.h"
#include "panels/viewer.h"
#include "panels/timeline.h"
@@ -279,7 +279,7 @@ void ExportDialog::on_formatCombobox_currentIndexChanged(int index)
default_acodec = 1;
break;
default:
qDebug() << "[ERROR] Invalid format selection - this is a bug, please inform the developers";
dout << "[ERROR] Invalid format selection - this is a bug, please inform the developers";
}
AVCodec* codec_info;
@@ -384,7 +384,7 @@ void ExportDialog::on_pushButton_clicked() {
ext = "tif";
break;
default:
qDebug() << "[ERROR] Invalid codec selection for an image sequence";
dout << "[ERROR] Invalid codec selection for an image sequence";
QMessageBox::critical(this, "Invalid codec", "Couldn't determine output parameters for the selected codec. This is a bug, please contact the developers.", QMessageBox::Ok);
return;
}
@@ -446,7 +446,7 @@ void ExportDialog::on_pushButton_clicked() {
}
break;
default:
qDebug() << "[ERROR] Invalid format - this is a bug, please inform the developers";
dout << "[ERROR] Invalid format - this is a bug, please inform the developers";
QMessageBox::critical(this, "Invalid format", "Couldn't determine output format. This is a bug, please contact the developers.", QMessageBox::Ok);
return;
}
-1
View File
@@ -9,7 +9,6 @@
#include "playback/playback.h"
#include <QVariant>
#include <QDebug>
extern "C" {
#include <libavcodec/avcodec.h>
-1
View File
@@ -5,7 +5,6 @@
#include <QMenuBar>
#include <QAction>
#include <QDebug>
KeySequenceEditor::KeySequenceEditor(QAction* a)
: QKeySequenceEdit(0), action(a) {
-1
View File
@@ -16,7 +16,6 @@
#include <QPushButton>
#include <QMessageBox>
#include <QCheckBox>
#include <QDebug>
ReplaceClipMediaDialog::ReplaceClipMediaDialog(QWidget *parent, SourceTable *table, QTreeWidgetItem *old_media) :
QDialog(parent),
-1
View File
@@ -6,7 +6,6 @@
#include <QCheckBox>
#include <QPushButton>
#include <QDialogButtonBox>
#include <QDebug>
#include "ui/labelslider.h"
#include "project/clip.h"
+2 -1
View File
@@ -6,6 +6,7 @@
#include "project/clip.h"
#include "project/sequence.h"
#include "debug.h"
ToneEffect::ToneEffect(Clip* c) : Effect(c, EFFECT_TYPE_AUDIO, AUDIO_TONE_EFFECT), sinX(INT_MIN) {
type_val = add_row("Type:")->add_field(EFFECT_FIELD_COMBO);
@@ -54,7 +55,7 @@ void ToneEffect::process_audio(double timecode_start, double timecode_end, quint
int presin = sinX;
sinX++;
if (sinX < presin) {
qDebug() << "[WARNING] Tone effect overflowed";
dout << "[WARNING] Tone effect overflowed";
}
}
}
-2
View File
@@ -3,7 +3,6 @@
#include <QGridLayout>
#include <QLabel>
#include <QtMath>
#include <QDebug>
#include <stdint.h>
#include "ui/labelslider.h"
@@ -22,7 +21,6 @@ VolumeEffect::VolumeEffect(Clip* c) : Effect(c, EFFECT_TYPE_AUDIO, AUDIO_VOLUME_
}
void VolumeEffect::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int) {
// qDebug() << timecode_start << timecode_end;
double interval = (timecode_end-timecode_start)/nb_bytes;
for (int i=0;i<nb_bytes;i+=2) {
double vol_val = qSqrt(volume_val->get_double_value(timecode_start+(interval*i), true)*0.01);
+8 -7
View File
@@ -16,6 +16,7 @@
#include "project/clip.h"
#include "panels/timeline.h"
#include "panels/effectcontrols.h"
#include "debug.h"
#include "effects/video/transformeffect.h"
#include "effects/video/inverteffect.h"
@@ -92,7 +93,7 @@ Effect* create_effect(int effect_id, Clip* c) {
case AUDIO_TONE_EFFECT: return new ToneEffect(c); break;
}
}
qDebug() << "[ERROR] Invalid effect ID";
dout << "[ERROR] Invalid effect ID";
return NULL;
}
@@ -271,14 +272,14 @@ void Effect::load(QXmlStreamReader& stream) {
}
}
} else {
qDebug() << "[ERROR] Too many fields for effect" << id << "row" << row_count << ". Project might be corrupt. (Got" << field_count << ", expected <" << row->fieldCount()-1 << ")";
dout << "[ERROR] Too many fields for effect" << id << "row" << row_count << ". Project might be corrupt. (Got" << field_count << ", expected <" << row->fieldCount()-1 << ")";
}
field_count++;
}
}
} else {
qDebug() << "[ERROR] Too many rows for effect" << id << ". Project might be corrupt. (Got" << row_count << ", expected <" << rows.size()-1 << ")";
dout << "[ERROR] Too many rows for effect" << id << ". Project might be corrupt. (Got" << row_count << ", expected <" << rows.size()-1 << ")";
}
row_count++;
}
@@ -313,11 +314,11 @@ void Effect::save(QXmlStreamWriter& stream) {
void Effect::open() {
if (isOpen) {
qDebug() << "[WARNING] Tried to open an effect that was already open";
dout << "[WARNING] Tried to open an effect that was already open";
close();
}
if (QOpenGLContext::currentContext() == NULL) {
qDebug() << "[WARNING] No current context to create a shader program for - will retry next repaint";
dout << "[WARNING] No current context to create a shader program for - will retry next repaint";
} else {
glslProgram = new QOpenGLShaderProgram();
if (!vertPath.isEmpty()) glslProgram->addShaderFromSourceFile(QOpenGLShader::Vertex, vertPath);
@@ -329,7 +330,7 @@ void Effect::open() {
void Effect::close() {
if (!isOpen) {
qDebug() << "[WARNING] Tried to close an effect that was already closed";
dout << "[WARNING] Tried to close an effect that was already closed";
} else {
delete glslProgram;
}
@@ -340,7 +341,7 @@ void Effect::close() {
void Effect::startEffect() {
if (!isOpen) {
open();
qDebug() << "[WARNING] Tried to start a closed effect - opening";
dout << "[WARNING] Tried to start a closed effect - opening";
}
bound = glslProgram->bind();
}
+2 -3
View File
@@ -2,8 +2,7 @@
#include "project/clip.h"
#include "io/config.h"
#include <QDebug>
#include "debug.h"
QVector<QString> video_transition_names;
QVector<QString> audio_transition_names;
@@ -38,6 +37,6 @@ Transition* create_transition(int transition_id, Clip* c) {
case AUDIO_LINEAR_FADE_TRANSITION: return new LinearFadeTransition();
}
}
qDebug() << "[ERROR] Invalid transition ID";
dout << "[ERROR] Invalid transition ID";
return NULL;
}
-1
View File
@@ -4,7 +4,6 @@
#include <QLabel>
#include <QtMath>
#include <QOpenGLFunctions>
#include <QDebug>
#include "ui/labelslider.h"
#include "ui/collapsiblewidget.h"
-1
View File
@@ -9,7 +9,6 @@
#include <QColorDialog>
#include <QFontDatabase>
#include <QComboBox>
#include <QDebug>
#include <QWidget>
#include "ui/labelslider.h"
+2 -2
View File
@@ -1,6 +1,5 @@
#include "transformeffect.h"
#include <QDebug>
#include <QWidget>
#include <QLabel>
#include <QGridLayout>
@@ -16,6 +15,7 @@
#include "ui/labelslider.h"
#include "ui/comboboxex.h"
#include "panels/project.h"
#include "debug.h"
#define BLEND_MODE_NORMAL 0
#define BLEND_MODE_SCREEN 1
@@ -143,7 +143,7 @@ void TransformEffect::process_coords(double timecode, GLTextureCoords& coords) {
glBlendFunc(GL_DST_COLOR, GL_ZERO);
break;
default:
qDebug() << "[ERROR] Invalid blend mode. This is a bug - please contact developers";
dout << "[ERROR] Invalid blend mode. This is a bug - please contact developers";
}
// opacity
+4 -3
View File
@@ -3,7 +3,8 @@
#include <QFile>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include <QDebug>
#include "debug.h"
Config config;
@@ -90,7 +91,7 @@ void Config::load(QString path) {
}
}
if (stream.hasError()) {
qDebug() << "[ERROR] Error parsing config XML." << stream.errorString();
dout << "[ERROR] Error parsing config XML." << stream.errorString();
}
f.close();
@@ -100,7 +101,7 @@ void Config::load(QString path) {
void Config::save(QString path) {
QFile f(path);
if (!f.open(QIODevice::WriteOnly)) {
qDebug() << "[ERROR] Could not save configuration";
dout << "[ERROR] Could not save configuration";
return;
}
+19 -19
View File
@@ -9,6 +9,7 @@
#include "playback/playback.h"
#include "playback/audio.h"
#include "dialogs/exportdialog.h"
#include "debug.h"
extern "C" {
#include <libavcodec/avcodec.h>
@@ -18,7 +19,6 @@ extern "C" {
#include <libswscale/swscale.h>
}
#include <QDebug>
#include <QApplication>
#include <QOffscreenSurface>
#include <QOpenGLFramebufferObject>
@@ -51,7 +51,7 @@ ExportThread::ExportThread() : continueEncode(true) {
bool ExportThread::encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx, AVFrame* frame, AVPacket* packet, AVStream* stream) {
ret = avcodec_send_frame(codec_ctx, frame);
if (ret < 0) {
qDebug() << "[ERROR] Failed to send frame to encoder." << ret;
dout << "[ERROR] Failed to send frame to encoder." << ret;
ed->export_error = "failed to send frame to encoder (" + QString::number(ret) + ")";
return false;
}
@@ -62,7 +62,7 @@ bool ExportThread::encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx,
return true;
} else if (ret < 0) {
if (ret != AVERROR_EOF) {
qDebug() << "[ERROR] Failed to receive packet from encoder." << ret;
dout << "[ERROR] Failed to receive packet from encoder." << ret;
ed->export_error = "failed to receive packet from encoder (" + QString::number(ret) + ")";
}
return false;
@@ -82,7 +82,7 @@ bool ExportThread::setupVideo() {
// find video encoder
vcodec = avcodec_find_encoder((enum AVCodecID) video_codec);
if (!vcodec) {
qDebug() << "[ERROR] Could not find video encoder";
dout << "[ERROR] Could not find video encoder";
ed->export_error = "could not video encoder for " + QString::number(video_codec);
return false;
}
@@ -91,7 +91,7 @@ bool ExportThread::setupVideo() {
video_stream = avformat_new_stream(fmt_ctx, vcodec);
video_stream->id = 0;
if (!video_stream) {
qDebug() << "[ERROR] Could not allocate video stream";
dout << "[ERROR] Could not allocate video stream";
ed->export_error = "could not allocate video stream";
return false;
}
@@ -100,7 +100,7 @@ bool ExportThread::setupVideo() {
vcodec_ctx = video_stream->codec;
// vcodec_ctx = avcodec_alloc_context3(vcodec);
if (!vcodec_ctx) {
qDebug() << "[ERROR] Could not allocate video encoding context";
dout << "[ERROR] Could not allocate video encoding context";
ed->export_error = "could not allocate video encoding context";
return false;
}
@@ -135,7 +135,7 @@ bool ExportThread::setupVideo() {
ret = avcodec_open2(vcodec_ctx, vcodec, NULL);
if (ret < 0) {
qDebug() << "[ERROR] Could not open output video encoder." << ret;
dout << "[ERROR] Could not open output video encoder." << ret;
ed->export_error = "could not open output video encoder (" + QString::number(ret) + ")";
return false;
}
@@ -143,7 +143,7 @@ bool ExportThread::setupVideo() {
// copy video encoder parameters to output stream
ret = avcodec_parameters_from_context(video_stream->codecpar, vcodec_ctx);
if (ret < 0) {
qDebug() << "[ERROR] Could not copy video encoder parameters to output stream." << ret;
dout << "[ERROR] Could not copy video encoder parameters to output stream." << ret;
ed->export_error = "could not copy video encoder parameters to output stream (" + QString::number(ret) + ")";
return false;
}
@@ -187,7 +187,7 @@ bool ExportThread::setupAudio() {
// find encoder
acodec = avcodec_find_encoder(static_cast<AVCodecID>(audio_codec));
if (!acodec) {
qDebug() << "[ERROR] Could not find audio encoder";
dout << "[ERROR] Could not find audio encoder";
ed->export_error = "could not audio encoder for " + QString::number(audio_codec);
return false;
}
@@ -196,7 +196,7 @@ bool ExportThread::setupAudio() {
audio_stream = avformat_new_stream(fmt_ctx, acodec);
audio_stream->id = 1;
if (!audio_stream) {
qDebug() << "[ERROR] Could not allocate audio stream";
dout << "[ERROR] Could not allocate audio stream";
ed->export_error = "could not allocate audio stream";
return false;
}
@@ -205,7 +205,7 @@ bool ExportThread::setupAudio() {
acodec_ctx = audio_stream->codec;
// acodec_ctx = avcodec_alloc_context3(acodec);
if (!acodec_ctx) {
qDebug() << "[ERROR] Could not find allocate audio encoding context";
dout << "[ERROR] Could not find allocate audio encoding context";
ed->export_error = "could not allocate audio encoding context";
return false;
}
@@ -229,7 +229,7 @@ bool ExportThread::setupAudio() {
// open encoder
ret = avcodec_open2(acodec_ctx, acodec, NULL);
if (ret < 0) {
qDebug() << "[ERROR] Could not open output audio encoder." << ret;
dout << "[ERROR] Could not open output audio encoder." << ret;
ed->export_error = "could not open output audio encoder (" + QString::number(ret) + ")";
return false;
}
@@ -237,7 +237,7 @@ bool ExportThread::setupAudio() {
// copy params to output stream
ret = avcodec_parameters_from_context(audio_stream->codecpar, acodec_ctx);
if (ret < 0) {
qDebug() << "[ERROR] Could not copy audio encoder parameters to output stream." << ret;
dout << "[ERROR] Could not copy audio encoder parameters to output stream." << ret;
ed->export_error = "could not copy audio encoder parameters to output stream (" + QString::number(ret) + ")";
return false;
}
@@ -267,7 +267,7 @@ bool ExportThread::setupAudio() {
av_frame_make_writable(audio_frame);
ret = av_frame_get_buffer(audio_frame, 0);
if (ret < 0) {
qDebug() << "[ERROR] Could not allocate audio buffer." << ret;
dout << "[ERROR] Could not allocate audio buffer." << ret;
ed->export_error = "could not allocate audio buffer (" + QString::number(ret) + ")";
return false;
}
@@ -289,7 +289,7 @@ bool ExportThread::setupAudio() {
bool ExportThread::setupContainer() {
avformat_alloc_output_context2(&fmt_ctx, NULL, NULL, c_filename);
if (!fmt_ctx) {
qDebug() << "[ERROR] Could not create output context";
dout << "[ERROR] Could not create output context";
ed->export_error = "could not create output format context";
return false;
}
@@ -298,7 +298,7 @@ bool ExportThread::setupContainer() {
ret = avio_open(&fmt_ctx->pb, c_filename, AVIO_FLAG_WRITE);
if (ret < 0) {
qDebug() << "[ERROR] Could not open output file." << ret;
dout << "[ERROR] Could not open output file." << ret;
ed->export_error = "could not open output file (" + QString::number(ret) + ")";
return false;
}
@@ -310,7 +310,7 @@ void ExportThread::run() {
panel_sequence_viewer->pause();
if (!panel_sequence_viewer->viewer_widget->context()->makeCurrent(&surface)) {
qDebug() << "[ERROR] Make current failed";
dout << "[ERROR] Make current failed";
ed->export_error = "could not make OpenGL context current";
return;
}
@@ -329,7 +329,7 @@ void ExportThread::run() {
if (continueEncode) {
ret = avformat_write_header(fmt_ctx, NULL);
if (ret < 0) {
qDebug() << "[ERROR] Could not write output file header." << ret;
dout << "[ERROR] Could not write output file header." << ret;
ed->export_error = "could not write output file header (" + QString::number(ret) + ")";
continueEncode = false;
}
@@ -418,7 +418,7 @@ void ExportThread::run() {
ret = av_write_trailer(fmt_ctx);
if (ret < 0) {
qDebug() << "[ERROR] Could not write output file trailer." << ret;
dout << "[ERROR] Could not write output file trailer." << ret;
ed->export_error = "could not write output file trailer (" + QString::number(ret) + ")";
continueEncode = false;
}
+17 -14
View File
@@ -5,10 +5,10 @@
#include "panels/project.h"
#include "io/config.h"
#include "io/crc32.h"
#include "debug.h"
#include <QPainter>
#include <QPixmap>
#include <QDebug>
#include <QtMath>
#include <QTreeWidgetItem>
#include <QSemaphore>
@@ -52,7 +52,7 @@ void PreviewGenerator::parse_media() {
for (int i=0;i<(int)fmt_ctx->nb_streams;i++) {
// Find the decoder for the video stream
if (avcodec_find_decoder(fmt_ctx->streams[i]->codecpar->codec_id) == NULL) {
qDebug() << "[ERROR] Unsupported codec in stream" << i << "of file" << media->name;
dout << "[ERROR] Unsupported codec in stream" << i << "of file" << media->name;
} else {
MediaStream* ms = media->get_stream_from_file_index(fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO, i);
bool append = false;
@@ -66,11 +66,11 @@ void PreviewGenerator::parse_media() {
&& fmt_ctx->streams[i]->codecpar->width > 0
&& fmt_ctx->streams[i]->codecpar->height > 0) {
/*qDebug() << "avg_frame_rate was:" << fmt_ctx->streams[i]->avg_frame_rate.num << "/" << fmt_ctx->streams[i]->avg_frame_rate.den;
qDebug() << "r_frame_rate was:" << fmt_ctx->streams[i]->r_frame_rate.num << "/" << fmt_ctx->streams[i]->r_frame_rate.den;
qDebug() << "codec_frame_rate was:" << fmt_ctx->streams[i]->codec->framerate.num << "/" << fmt_ctx->streams[i]->codec->framerate.den;
qDebug() << "nb_frames was:" << fmt_ctx->streams[i]->nb_frames;
qDebug() << "duration was:" << fmt_ctx->streams[i]->duration << "OR fmt_ctx's duration is:" << fmt_ctx->duration;*/
/*dout << "avg_frame_rate was:" << fmt_ctx->streams[i]->avg_frame_rate.num << "/" << fmt_ctx->streams[i]->avg_frame_rate.den;
dout << "r_frame_rate was:" << fmt_ctx->streams[i]->r_frame_rate.num << "/" << fmt_ctx->streams[i]->r_frame_rate.den;
dout << "codec_frame_rate was:" << fmt_ctx->streams[i]->codec->framerate.num << "/" << fmt_ctx->streams[i]->codec->framerate.den;
dout << "nb_frames was:" << fmt_ctx->streams[i]->nb_frames;
dout << "duration was:" << fmt_ctx->streams[i]->duration << "OR fmt_ctx's duration is:" << fmt_ctx->duration;*/
if (fmt_ctx->streams[i]->avg_frame_rate.den == 0
&& fmt_ctx->streams[i]->duration == AV_NOPTS_VALUE) { // source is LIKELY a still image
@@ -87,8 +87,11 @@ void PreviewGenerator::parse_media() {
}
ms->video_width = fmt_ctx->streams[i]->codecpar->width;
ms->video_height = fmt_ctx->streams[i]->codecpar->height;
// default value, we get the true value later in generate_waveform()
ms->video_auto_interlacing = VIDEO_PROGRESSIVE;
ms->video_interlacing = VIDEO_PROGRESSIVE; // default value, we get the true value later in generate_waveform()
ms->video_interlacing = VIDEO_PROGRESSIVE;
if (append) media->video_tracks.append(ms);
} else if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
ms->audio_channels = fmt_ctx->streams[i]->codecpar->channels;
@@ -122,7 +125,7 @@ bool PreviewGenerator::retrieve_preview(const QString& hash) {
QString thumb_path = get_thumbnail_path(hash, ms);
QFile f(thumb_path);
if (f.exists()) {
qDebug() << "loaded thumb" << ms->file_index << "from" << thumb_path;
dout << "loaded thumb" << ms->file_index << "from" << thumb_path;
ms->video_preview.load(thumb_path);
ms->preview_done = true;
} else {
@@ -135,7 +138,7 @@ bool PreviewGenerator::retrieve_preview(const QString& hash) {
QString waveform_path = get_waveform_path(hash, ms);
QFile f(waveform_path);
if (f.exists()) {
qDebug() << "loaded wave" << ms->file_index << "from" << waveform_path;
dout << "loaded wave" << ms->file_index << "from" << waveform_path;
f.open(QFile::ReadOnly);
QByteArray data = f.readAll();
ms->audio_preview.resize(data.size());
@@ -213,13 +216,13 @@ void PreviewGenerator::generate_waveform() {
int read_ret = av_read_frame(fmt_ctx, &packet);
if (read_ret < 0) {
end_of_file = true;
if (read_ret != AVERROR_EOF) qDebug() << "[ERROR] Failed to read packet for preview generation" << read_ret;
if (read_ret != AVERROR_EOF) dout << "[ERROR] Failed to read packet for preview generation" << read_ret;
break;
}
if (codec_ctx[packet.stream_index] != NULL) {
int send_ret = avcodec_send_packet(codec_ctx[packet.stream_index], &packet);
if (send_ret < 0 && send_ret != AVERROR(EAGAIN)) {
qDebug() << "[ERROR] Failed to send packet for preview generation - aborting" << send_ret;
dout << "[ERROR] Failed to send packet for preview generation - aborting" << send_ret;
end_of_file = true;
break;
}
@@ -419,7 +422,7 @@ void PreviewGenerator::run() {
for (int i=0;i<media->video_tracks.size();i++) {
MediaStream* ms = media->video_tracks.at(i);
if (ms->video_preview.save(get_thumbnail_path(hash, ms), "PNG")) {
qDebug() << "saved" << ms->file_index << "thumb to" << get_thumbnail_path(hash, ms);
dout << "saved" << ms->file_index << "thumb to" << get_thumbnail_path(hash, ms);
}
}
for (int i=0;i<media->audio_tracks.size();i++) {
@@ -428,7 +431,7 @@ void PreviewGenerator::run() {
f.open(QFile::WriteOnly);
f.write(ms->audio_preview.constData(), ms->audio_preview.size());
f.close();
qDebug() << "saved" << ms->file_index << "waveform to" << get_waveform_path(hash, ms);
dout << "saved" << ms->file_index << "waveform to" << get_waveform_path(hash, ms);
}
}
+1 -1
View File
@@ -9,7 +9,7 @@ extern "C" {
int main(int argc, char *argv[]) {
// init ffmpeg subsystem
av_register_all();
avfilter_register_all();
avfilter_register_all();
QApplication a(argc, argv);
MainWindow w;
+9 -4
View File
@@ -28,7 +28,8 @@
#include "ui_timeline.h"
#include <QDebug>
#include "debug.h"
#include <QStyleFactory>
#include <QMessageBox>
#include <QFileDialog>
@@ -69,6 +70,8 @@ MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
setup_debug();
mainWindow = this;
// set up style?
@@ -135,7 +138,7 @@ MainWindow::MainWindow(QWidget *parent) :
if (QFile(file_name).remove()) deleted_ars++;
}
}
if (deleted_ars > 0) qDebug() << "[INFO] Deleted" << deleted_ars << "autorecovery" << ((deleted_ars == 1) ? "file that was" : "files that were") << "older than 7 days";
if (deleted_ars > 0) dout << "[INFO] Deleted" << deleted_ars << "autorecovery" << ((deleted_ars == 1) ? "file that was" : "files that were") << "older than 7 days";
// delete previews older than 30 days
QDir preview_dir = QDir(data_dir + "/previews");
@@ -149,7 +152,7 @@ MainWindow::MainWindow(QWidget *parent) :
if (QFile(file_name).remove()) deleted_ars++;
}
}
if (deleted_ars > 0) qDebug() << "[INFO] Deleted" << deleted_ars << "preview" << ((deleted_ars == 1) ? "file that was" : "files that were") << "last read over 30 days ago";
if (deleted_ars > 0) dout << "[INFO] Deleted" << deleted_ars << "preview" << ((deleted_ars == 1) ? "file that was" : "files that were") << "last read over 30 days ago";
}
// detect auto-recovery file
@@ -214,6 +217,8 @@ MainWindow::~MainWindow() {
delete panel_timeline;
delete panel_sequence_viewer;
delete panel_footage_viewer;
close_debug();
}
void MainWindow::on_action_Import_triggered()
@@ -370,7 +375,7 @@ void MainWindow::on_actionSplit_at_Playhead_triggered()
void MainWindow::autorecover_interval() {
if (isWindowModified()) {
panel_project->save_project(true);
qDebug() << "[INFO] Auto-recovery project saved";
dout << "[INFO] Auto-recovery project saved";
}
}
+4 -2
View File
@@ -86,7 +86,8 @@ SOURCES += \
effects/video/waveeffect.cpp \
effects/video/temperatureeffect.cpp \
io/crc32.cpp \
dialogs/loaddialog.cpp
dialogs/loaddialog.cpp \
debug.cpp
HEADERS += \
mainwindow.h \
@@ -151,7 +152,8 @@ HEADERS += \
effects/video/waveeffect.h \
effects/video/temperatureeffect.h \
io/crc32.h \
dialogs/loaddialog.h
dialogs/loaddialog.h \
debug.h
FORMS += \
mainwindow.ui \
+2 -2
View File
@@ -2,7 +2,6 @@
#include "ui_effectcontrols.h"
#include <QMenu>
#include <QDebug>
#include <QVBoxLayout>
#include <QResizeEvent>
#include <QScrollBar>
@@ -19,6 +18,7 @@
#include "panels/timeline.h"
#include "panels/viewer.h"
#include "ui/viewerwidget.h"
#include "debug.h"
EffectControls::EffectControls(QWidget *parent) :
QDockWidget(parent),
@@ -278,7 +278,7 @@ bool EffectControls::is_focused() {
}
}
} else {
qDebug() << "[WARNING] Tried to check focus of a NULL clip";
dout << "[WARNING] Tried to check focus of a NULL clip";
}
}
return false;
+6 -6
View File
@@ -21,11 +21,11 @@
#include "dialogs/newsequencedialog.h"
#include "dialogs/mediapropertiesdialog.h"
#include "dialogs/loaddialog.h"
#include "debug.h"
#include <QFileDialog>
#include <QString>
#include <QVariant>
#include <QDebug>
#include <QCharRef>
#include <QMessageBox>
#include <QDropEvent>
@@ -573,7 +573,7 @@ void* get_media_from_tree(QTreeWidgetItem* item) {
switch (type) {
case MEDIA_TYPE_FOOTAGE: return get_footage_from_tree(item);
case MEDIA_TYPE_SEQUENCE: return get_sequence_from_tree(item);
default: qDebug() << "[ERROR] Invalid media type when retrieving media";
default: dout << "[ERROR] Invalid media type when retrieving media";
}
return NULL;*/
}
@@ -1011,7 +1011,7 @@ void Project::load_project() {
QFile file(project_url);
if (!file.open(QIODevice::ReadOnly)) {
qDebug() << "[ERROR] Could not open file";
dout << "[ERROR] Could not open file";
return;
}
@@ -1071,7 +1071,7 @@ void Project::load_project() {
if (!cont) {
if (show_err) QMessageBox::critical(this, "Project Load Error", "Error loading project: " + error_str, QMessageBox::Ok);
} else if (stream.hasError()) {
qDebug() << "[ERROR] Error parsing XML." << stream.errorString();
dout << "[ERROR] Error parsing XML." << stream.errorString();
QMessageBox::critical(this, "XML Parsing Error", "Couldn't load '" + project_url + "'. " + stream.errorString(), QMessageBox::Ok);
cont = false;
}
@@ -1251,7 +1251,7 @@ void Project::save_project(bool autorecovery) {
QFile file(autorecovery ? autorecovery_filename : project_url);
if (!file.open(QIODevice::WriteOnly/* | QIODevice::Text*/)) {
qDebug() << "[ERROR] Could not open file";
dout << "[ERROR] Could not open file";
return;
}
@@ -1304,7 +1304,7 @@ void Project::save_recent_projects() {
}
f.close();
} else {
qDebug() << "[WARNING] Could not save recent projects";
dout << "[WARNING] Could not save recent projects";
}
}
+3 -2
View File
@@ -11,6 +11,7 @@
#include "project/undo.h"
#include "ui/audiomonitor.h"
#include "ui_timeline.h"
#include "debug.h"
#define FRAMES_IN_ONE_MINUTE 1798 // 1800 - 2
#define FRAMES_IN_TEN_MINUTES 17978 // (FRAMES_IN_ONE_MINUTE * 10) - 2
@@ -98,7 +99,7 @@ long timecode_to_frame(const QString& s, int view, double frame_rate) {
QList<QString> list = s.split(QRegExp("[:;]"));
for (int i=0;i<list.size();i++) {
qDebug() << "list" << i << list.at(i);
dout << "list" << i << list.at(i);
}
if (view == TIMECODE_FRAMES || list.size() == 1) {
@@ -275,7 +276,7 @@ void Viewer::play() {
init_audio(seq);
}
if (is_recording_cued() && !start_recording()) {
qDebug() << "[ERROR] Failed to record audio";
dout << "[ERROR] Failed to record audio";
return;
}
playhead_start = seq->playhead;
+6 -6
View File
@@ -8,13 +8,13 @@
#include "panels/timeline.h"
#include "panels/viewer.h"
#include "ui_timeline.h"
#include "debug.h"
#include <QAudioOutput>
#include <QAudioInput>
#include <QtMath>
#include <QFile>
#include <QDir>
#include <QDebug>
extern "C" {
#include <libavcodec/avcodec.h>
@@ -92,7 +92,7 @@ int get_buffer_offset_from_frame(Sequence* s, long frame) {
if (frame >= audio_ibuffer_frame) {
return qFloor(av_samples_get_buffer_size(NULL, av_get_channel_layout_nb_channels(s->audio_layout), qRound(((frame-audio_ibuffer_frame)/s->frame_rate)*s->audio_frequency), AV_SAMPLE_FMT_S16, 1)/4)*4;
} else {
qDebug() << "[WARNING] Invalid values passed to get_buffer_offset_from_frame";
dout << "[WARNING] Invalid values passed to get_buffer_offset_from_frame";
return 0;
}
#endif
@@ -264,14 +264,14 @@ void write_wave_trailer(QFile& f) {
bool start_recording() {
if (sequence == NULL) {
qDebug() << "[ERROR] No active sequence to record into";
dout << "[ERROR] No active sequence to record into";
return false;
}
QString audio_path = project_url + " Audio";
QDir audio_dir(audio_path);
if (!audio_dir.exists() && !audio_dir.mkpath(".")) {
qDebug() << "[ERROR] Failed to create audio directory";
dout << "[ERROR] Failed to create audio directory";
return false;
}
@@ -284,7 +284,7 @@ bool start_recording() {
output_recording.setFileName(audio_filename);
if (!output_recording.open(QFile::WriteOnly)) {
qDebug() << "[ERROR] Failed to open output file. Does Olive have permission to write to this directory?";
dout << "[ERROR] Failed to open output file. Does Olive have permission to write to this directory?";
return false;
}
@@ -294,7 +294,7 @@ bool start_recording() {
}
QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice();
if (!info.isFormatSupported(audio_format)) {
qDebug() << "[WARNING] Default format not supported, using nearest";
dout << "[WARNING] Default format not supported, using nearest";
audio_format = info.nearestFormat(audio_format);
}
write_wave_header(output_recording, audio_format);
+42 -42
View File
@@ -9,6 +9,7 @@
#include "panels/timeline.h"
#include "panels/project.h"
#include "effects/transition.h"
#include "debug.h"
extern "C" {
#include <libavformat/avformat.h>
@@ -21,7 +22,6 @@ extern "C" {
#include <libavutil/opt.h>
}
#include <QDebug>
#include <QOpenGLFramebufferObject>
#include <QtMath>
#include <math.h>
@@ -103,7 +103,7 @@ void cache_audio_worker(Clip* c, Clip* nest) {
av_seek_frame(c->formatCtx, c->stream->index, backtrack_seek, AVSEEK_FLAG_BACKWARD);
#ifdef AUDIOWARNINGS
if (backtrack_seek == 0) {
qDebug() << "backtracked to 0";
dout << "backtracked to 0";
}
#endif
}
@@ -117,13 +117,13 @@ void cache_audio_worker(Clip* c, Clip* nest) {
ret = retrieve_next_frame(c, c->frame);
if (ret >= 0) {
if ((ret = av_buffersrc_add_frame_flags(c->buffersrc_ctx, c->frame, AV_BUFFERSRC_FLAG_KEEP_REF)) < 0) {
qDebug() << "[ERROR] Could not feed filtergraph -" << ret;
dout << "[ERROR] Could not feed filtergraph -" << ret;
break;
}
} else {
if (ret == AVERROR_EOF) {
#ifdef AUDIOWARNINGS
qDebug() << "reached EOF while reading";
dout << "reached EOF while reading";
#endif
// TODO revise usage of reached_end in audio
if (!c->reverse) {
@@ -131,7 +131,7 @@ void cache_audio_worker(Clip* c, Clip* nest) {
} else {
}
} else {
qDebug() << "[WARNING] Raw audio frame data could not be retrieved." << ret;
dout << "[WARNING] Raw audio frame data could not be retrieved." << ret;
c->reached_end = true;
}
break;
@@ -140,12 +140,12 @@ void cache_audio_worker(Clip* c, Clip* nest) {
if (ret < 0) {
if (ret != AVERROR_EOF) {
qDebug() << "[ERROR] Could not pull from filtergraph";
dout << "[ERROR] Could not pull from filtergraph";
c->reached_end = true;
break;
} else {
#ifdef AUDIOWARNINGS
qDebug() << "reached EOF while pulling from filtergraph";
dout << "reached EOF while pulling from filtergraph";
#endif
if (!c->reverse) break;
}
@@ -157,15 +157,15 @@ void cache_audio_worker(Clip* c, Clip* nest) {
if (ret != AVERROR_EOF) {
if (loop == 2) {
#ifdef AUDIOWARNINGS
qDebug() << "starting rev_frame";
dout << "starting rev_frame";
#endif
rev_frame->nb_samples = 0;
rev_frame->pts = c->frame->pkt_pts;
}
int offset = rev_frame->nb_samples * av_get_bytes_per_sample(static_cast<AVSampleFormat>(rev_frame->format)) * rev_frame->channels;
#ifdef AUDIOWARNINGS
qDebug() << "offset 1:" << offset;
qDebug() << "retrieved samples:" << frame->nb_samples << "size:" << (frame->nb_samples * av_get_bytes_per_sample(static_cast<AVSampleFormat>(frame->format)) * frame->channels);
dout << "offset 1:" << offset;
dout << "retrieved samples:" << frame->nb_samples << "size:" << (frame->nb_samples * av_get_bytes_per_sample(static_cast<AVSampleFormat>(frame->format)) * frame->channels);
#endif
memcpy(
rev_frame->data[0]+offset,
@@ -173,7 +173,7 @@ void cache_audio_worker(Clip* c, Clip* nest) {
(frame->nb_samples * av_get_bytes_per_sample(static_cast<AVSampleFormat>(frame->format)) * frame->channels)
);
#ifdef AUDIOWARNINGS
qDebug() << "pts:" << c->frame->pts << "dur:" << c->frame->pkt_duration << "rev_target:" << c->reverse_target << "offset:" << offset << "limit:" << rev_frame->linesize[0];
dout << "pts:" << c->frame->pts << "dur:" << c->frame->pkt_duration << "rev_target:" << c->reverse_target << "offset:" << offset << "limit:" << rev_frame->linesize[0];
#endif
}
@@ -181,20 +181,20 @@ void cache_audio_worker(Clip* c, Clip* nest) {
// if (c->frame->pts == c->rev_target) {
if ((c->frame->pts >= c->reverse_target) || (ret == AVERROR_EOF)) {
/*qDebug() << "time for the end of rev cache" << rev_frame->nb_samples << c->rev_target << c->frame->pts << c->frame->pkt_duration << c->frame->nb_samples;
qDebug() << "diff:" << (c->frame->pkt_pts + c->frame->pkt_duration) - c->rev_target;
/*dout << "time for the end of rev cache" << rev_frame->nb_samples << c->rev_target << c->frame->pts << c->frame->pkt_duration << c->frame->nb_samples;
dout << "diff:" << (c->frame->pkt_pts + c->frame->pkt_duration) - c->rev_target;
int cutoff = qRound64 ((((c->frame->pkt_pts + c->frame->pkt_duration) - c->rev_target) * timebase) * c->sequence->audio_frequency);
if (cutoff > 0) {
qDebug() << "cut off" << cutoff << "samples (rate:" << c->sequence->audio_frequency << ")";
dout << "cut off" << cutoff << "samples (rate:" << c->sequence->audio_frequency << ")";
rev_frame->nb_samples -= cutoff;
}*/
#ifdef AUDIOWARNINGS
qDebug() << "pre cutoff deets::: rev_frame.pts:" << rev_frame->pts << "rev_frame.nb_samples" << rev_frame->nb_samples << "rev_target:" << c->reverse_target;
dout << "pre cutoff deets::: rev_frame.pts:" << rev_frame->pts << "rev_frame.nb_samples" << rev_frame->nb_samples << "rev_target:" << c->reverse_target;
#endif
rev_frame->nb_samples = qRound64(static_cast<double>(c->reverse_target - rev_frame->pts) / c->stream->codecpar->sample_rate * c->sequence->audio_frequency);
#ifdef AUDIOWARNINGS
qDebug() << "post cutoff deets::" << rev_frame->nb_samples;
dout << "post cutoff deets::" << rev_frame->nb_samples;
#endif
int frame_size = rev_frame->nb_samples * rev_frame->channels * av_get_bytes_per_sample(static_cast<AVSampleFormat>(rev_frame->format));
@@ -224,7 +224,7 @@ void cache_audio_worker(Clip* c, Clip* nest) {
loop++;
#ifdef AUDIOWARNINGS
qDebug() << "loop" << loop;
dout << "loop" << loop;
#endif
} else {
frame->pts = c->frame->pts;
@@ -253,15 +253,15 @@ void cache_audio_worker(Clip* c, Clip* nest) {
int nb_samples = qRound64((target_sts - frame_sts)*c->sequence->audio_frequency);
c->frame_sample_index = nb_samples * 4;
#ifdef AUDIOWARNINGS
qDebug() << "fsts:" << frame_sts << "tsts:" << target_sts << "nbs:" << nb_samples << "nbb:" << nb_bytes << "rev_targetToSec:" << (c->reverse_target * timebase);
qDebug() << "fsi-calc:" << c->frame_sample_index;
dout << "fsts:" << frame_sts << "tsts:" << target_sts << "nbs:" << nb_samples << "nbb:" << nb_bytes << "rev_targetToSec:" << (c->reverse_target * timebase);
dout << "fsi-calc:" << c->frame_sample_index;
#endif
if (c->reverse) c->frame_sample_index = nb_bytes - c->frame_sample_index;
c->audio_just_reset = false;
}
#ifdef AUDIOWARNINGS
qDebug() << "fsi-post-post:" << c->frame_sample_index;
dout << "fsi-post-post:" << c->frame_sample_index;
#endif
if (c->audio_buffer_write == 0) c->audio_buffer_write = get_buffer_offset_from_frame(c->sequence, qMax(timeline_in, c->audio_target_frame));
@@ -281,7 +281,7 @@ void cache_audio_worker(Clip* c, Clip* nest) {
if (c->reverse) frame = c->queue.at(1);
#ifdef AUDIOWARNINGS
qDebug() << "j" << c->frame_sample_index << nb_bytes;
dout << "j" << c->frame_sample_index << nb_bytes;
#endif
// apply any audio effects to the data
@@ -309,7 +309,7 @@ void cache_audio_worker(Clip* c, Clip* nest) {
}
break;
default: // shouldn't ever get here
qDebug() << "[ERROR] Tried to cache a non-footage/tone clip";
dout << "[ERROR] Tried to cache a non-footage/tone clip";
return;
}
@@ -335,7 +335,7 @@ void cache_audio_worker(Clip* c, Clip* nest) {
c->frame_sample_index+=2;
}
#ifdef AUDIOWARNINGS
if (c->audio_buffer_write >= buffer_timeline_out) qDebug() << "timeline out at fsi" << c->frame_sample_index << "of frame ts" << c->frame->pts;
if (c->audio_buffer_write >= buffer_timeline_out) dout << "timeline out at fsi" << c->frame_sample_index << "of frame ts" << c->frame->pts;
#endif
audio_write_lock.unlock();
@@ -346,7 +346,7 @@ void cache_audio_worker(Clip* c, Clip* nest) {
break;
}
// qDebug() << "ended" << c->frame_sample_index << nb_bytes;
// dout << "ended" << c->frame_sample_index << nb_bytes;
}
if (c->reached_end) {
frame->nb_samples = 0;
@@ -408,12 +408,12 @@ void cache_video_worker(Clip* c, long playhead) {
} else if (static_cast<Media*>(c->media)->get_stream_from_file_index(true, c->media_stream)->infinite_length) {
send_it = true;
} else {
qDebug() << "skipped adding a frame to the queue - fpts:" << send_frame->pts << "target:" << target_pts;
dout << "skipped adding a frame to the queue - fpts:" << send_frame->pts << "target:" << target_pts;
}
if (send_it) {
if ((send_ret = av_buffersrc_add_frame_flags(c->buffersrc_ctx, send_frame, AV_BUFFERSRC_FLAG_KEEP_REF)) < 0) {
qDebug() << "[ERROR] Failed to add frame to buffer source." << send_ret;
dout << "[ERROR] Failed to add frame to buffer source." << send_ret;
break;
}
}
@@ -423,7 +423,7 @@ void cache_video_worker(Clip* c, long playhead) {
if (read_ret == AVERROR_EOF) {
c->reached_end = true;
} else {
qDebug() << "[ERROR] Failed to read frame." << read_ret;
dout << "[ERROR] Failed to read frame." << read_ret;
}
break;
}
@@ -433,7 +433,7 @@ void cache_video_worker(Clip* c, long playhead) {
if (retr_ret == AVERROR_EOF) {
c->reached_end = true;
} else {
qDebug() << "[ERROR] Failed to retrieve frame from buffersink." << retr_ret;
dout << "[ERROR] Failed to retrieve frame from buffersink." << retr_ret;
}
av_frame_free(&frame);
break;
@@ -503,7 +503,7 @@ void reset_cache(Clip* c, long target_frame) {
av_frame_unref(c->frame);
int ret = retrieve_next_frame(c, c->frame);
if (ret < 0) {
qDebug() << "[WARNING] Seeking terminated prematurely";
dout << "[WARNING] Seeking terminated prematurely";
break;
}
if (c->frame->pts <= target_ts) {
@@ -532,9 +532,9 @@ void reset_cache(Clip* c, long target_frame) {
c->reverse_target = timestamp;
timestamp -= av_q2d(av_inv_q(c->stream->time_base));
#ifdef AUDIOWARNINGS
qDebug() << "seeking to" << timestamp << "(originally" << c->reverse_target << ")";
dout << "seeking to" << timestamp << "(originally" << c->reverse_target << ")";
} else {
qDebug() << "reset called; seeking to" << timestamp;
dout << "reset called; seeking to" << timestamp;
#endif
}
av_seek_frame(c->formatCtx, ms->file_index, timestamp, AVSEEK_FLAG_BACKWARD);
@@ -577,14 +577,14 @@ void open_clip_worker(Clip* clip) {
if (errCode != 0) {
char err[1024];
av_strerror(errCode, err, 1024);
qDebug() << "[ERROR] Could not open" << filename << "-" << err;
dout << "[ERROR] Could not open" << filename << "-" << err;
}
errCode = avformat_find_stream_info(clip->formatCtx, NULL);
if (errCode < 0) {
char err[1024];
av_strerror(errCode, err, 1024);
qDebug() << "[ERROR] Could not open" << filename << "-" << err;
dout << "[ERROR] Could not open" << filename << "-" << err;
}
av_dump_format(clip->formatCtx, 0, filename, 0);
@@ -613,13 +613,13 @@ void open_clip_worker(Clip* clip) {
// Open codec
if (avcodec_open2(clip->codecCtx, clip->codec, &opts) < 0) {
qDebug() << "[ERROR] Could not open codec";
dout << "[ERROR] Could not open codec";
}
// allocate filtergraph
clip->filter_graph = avfilter_graph_alloc();
if (clip->filter_graph == NULL) {
qDebug() << "[ERROR] Could not create filtergraph";
dout << "[ERROR] Could not create filtergraph";
}
char filter_args[512];
@@ -659,7 +659,7 @@ void open_clip_worker(Clip* clip) {
enum AVPixelFormat pix_fmts[] = { static_cast<AVPixelFormat>(dest_format), AV_PIX_FMT_NONE };
if (av_opt_set_int_list(clip->buffersink_ctx, "pix_fmts", pix_fmts, AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN) < 0) {
qDebug() << "[ERROR] Could not set output pixel format";
dout << "[ERROR] Could not set output pixel format";
}
if (ms->video_interlacing == VIDEO_PROGRESSIVE) {
@@ -705,12 +705,12 @@ void open_clip_worker(Clip* clip) {
enum AVSampleFormat sample_fmts[] = { sample_format, static_cast<AVSampleFormat>(-1) };
if (av_opt_set_int_list(clip->buffersink_ctx, "sample_fmts", sample_fmts, -1, AV_OPT_SEARCH_CHILDREN) < 0) {
qDebug() << "[ERROR] Could not set output sample format";
dout << "[ERROR] Could not set output sample format";
}
int64_t channel_layouts[] = { AV_CH_LAYOUT_STEREO, static_cast<AVSampleFormat>(-1) };
if (av_opt_set_int_list(clip->buffersink_ctx, "channel_layouts", channel_layouts, -1, AV_OPT_SEARCH_CHILDREN) < 0) {
qDebug() << "[ERROR] Could not set output sample format";
dout << "[ERROR] Could not set output sample format";
}
int target_sample_rate = clip->sequence->audio_frequency;
@@ -732,7 +732,7 @@ void open_clip_worker(Clip* clip) {
int sample_rates[] = { target_sample_rate, 0 };
if (av_opt_set_int_list(clip->buffersink_ctx, "sample_rates", sample_rates, 0, AV_OPT_SEARCH_CHILDREN) < 0) {
qDebug() << "[ERROR] Could not set output sample rates";
dout << "[ERROR] Could not set output sample rates";
}
avfilter_graph_config(clip->filter_graph, NULL);
@@ -752,7 +752,7 @@ void open_clip_worker(Clip* clip) {
clip->frame->nb_samples = 2048;
av_frame_make_writable(clip->frame);
if (av_frame_get_buffer(clip->frame, 0)) {
qDebug() << "[ERROR] Could not allocate buffer for tone clip";
dout << "[ERROR] Could not allocate buffer for tone clip";
}
clip->audio_reset = true;
break;
@@ -764,7 +764,7 @@ void open_clip_worker(Clip* clip) {
clip->finished_opening = true;
qDebug() << "[INFO] Clip opened on track" << clip->track;
dout << "[INFO] Clip opened on track" << clip->track;
}
void cache_clip_worker(Clip* clip, long playhead, bool reset, Clip* nest) {
@@ -805,7 +805,7 @@ void close_clip_worker(Clip* clip) {
clip->reset();
qDebug() << "[INFO] Clip closed on track" << clip->track;
dout << "[INFO] Clip closed on track" << clip->track;
}
void Cacher::run() {
+27 -18
View File
@@ -10,6 +10,7 @@
#include "panels/viewer.h"
#include "effects/effect.h"
#include "panels/effectcontrols.h"
#include "debug.h"
extern "C" {
#include <libavformat/avformat.h>
@@ -21,7 +22,6 @@ extern "C" {
#include <QtMath>
#include <QObject>
#include <QOpenGLTexture>
#include <QDebug>
#include <QOpenGLPixelTransferOptions>
#include <QOpenGLFramebufferObject>
@@ -130,18 +130,18 @@ void get_clip_frame(Clip* c, long playhead) {
if (ms->infinite_length) {
target_frame = c->queue.at(0);
#ifdef GCF_DEBUG
qDebug() << "GCF ==> USE PRECISE (INFINITE)";
dout << "GCF ==> USE PRECISE (INFINITE)";
#endif
} else {
// correct frame may be somewhere else in the queue
int closest_frame = 0;
for (int i=1;i<c->queue.size();i++) {
//qDebug() << "results for" << i << qAbs(c->queue.at(i)->pts - target_pts) << qAbs(c->queue.at(closest_frame)->pts - target_pts) << c->queue.at(i)->pts << target_pts;
//dout << "results for" << i << qAbs(c->queue.at(i)->pts - target_pts) << qAbs(c->queue.at(closest_frame)->pts - target_pts) << c->queue.at(i)->pts << target_pts;
if (c->queue.at(i)->pts == target_pts) {
#ifdef GCF_DEBUG
qDebug() << "GCF ==> USE PRECISE";
dout << "GCF ==> USE PRECISE";
#endif
closest_frame = i;
break;
@@ -152,42 +152,51 @@ void get_clip_frame(Clip* c, long playhead) {
// remove all frames earlier than this one from the queue
target_frame = c->queue.at(closest_frame);
int64_t next_pts = INT64_MAX;
int64_t minimum_ts = target_frame->pts;
if (c->reverse) minimum_ts += quarter_pts; else minimum_ts -= quarter_pts;
//qDebug() << "closest frame was" << closest_frame << "with" << target_frame->pts << "/" << target_pts;
/*if (c->reverse) {
minimum_ts += quarter_pts;
} else {
minimum_ts -= quarter_pts;
}*/
//dout << "closest frame was" << closest_frame << "with" << target_frame->pts << "/" << target_pts;
for (int i=0;i<c->queue.size();i++) {
if (c->queue.at(i)->pts > target_frame->pts && c->queue.at(i)->pts < next_pts) {
next_pts = c->queue.at(i)->pts;
}
if (c->queue.at(i) != target_frame && ((c->queue.at(i)->pts > minimum_ts) == c->reverse)) {
//qDebug() << "removed frame at" << i << "because its pts was" << c->queue.at(i)->pts << "compared to" << target_frame->pts;
//dout << "removed frame at" << i << "because its pts was" << c->queue.at(i)->pts << "compared to" << target_frame->pts;
av_frame_free(&c->queue[i]); // may be a little heavy for the UI thread?
c->queue.removeAt(i);
i--;
}
}
if (next_pts == INT64_MAX) next_pts = target_frame->pts + target_frame->pkt_duration;
// we didn't get the exact frame
// we didn't get the exact timestamp
if (target_frame->pts != target_pts) {
if (target_pts > target_frame->pts && target_pts <= target_frame->pts + target_frame->pkt_duration) {
if (target_pts > target_frame->pts && target_pts <= next_pts) {
#ifdef GCF_DEBUG
qDebug() << "GCF ==> USE IMPRECISE";
dout << "GCF ==> USE IMPRECISE";
#endif
} else {
int64_t pts_diff = qAbs(target_pts - target_frame->pts);
if (c->reached_end && target_pts > target_frame->pts) {
#ifdef GCF_DEBUG
qDebug() << "GCF ==> EOF TOLERANT";
dout << "GCF ==> EOF TOLERANT";
#endif
c->reached_end = false;
cache = false;
} else if (target_pts < target_frame->pts || pts_diff > second_pts) {
#ifdef GCF_DEBUG
qDebug() << "GCF ==> RESET" << target_pts << "(" << target_frame->pts << "-" << target_frame->pts+target_frame->pkt_duration << ")";
dout << "GCF ==> RESET" << target_pts << "(" << target_frame->pts << "-" << target_frame->pts+target_frame->pkt_duration << ")";
#endif
target_frame = NULL;
reset = true;
} else {
#ifdef GCF_DEBUG
qDebug() << "GCF ==> WAIT - target:" << target_pts << "closest frame:" << target_frame->pts;
dout << "GCF ==> WAIT - target pts:" << target_pts << "closest frame:" << target_frame->pts;
#endif
//if (c->queue.size() >= c->max_queue_size) c->queue_remove_earliest();
target_frame = NULL;
@@ -202,7 +211,7 @@ void get_clip_frame(Clip* c, long playhead) {
if (target_frame == NULL || reset) {
// reset cache
texture_failed = true;
qDebug() << "[INFO] Frame queue couldn't keep up - either the user seeked or the system is overloaded (queue size:" << c->queue.size() << ")";
dout << "[INFO] Frame queue couldn't keep up - either the user seeked or the system is overloaded (queue size:" << c->queue.size() << ")";
}
if (target_frame != NULL) {
@@ -260,24 +269,24 @@ int retrieve_next_frame(Clip* c, AVFrame* f) {
if (read_ret >= 0) {
int send_ret = avcodec_send_packet(c->codecCtx, c->pkt);
if (send_ret < 0) {
qDebug() << "[ERROR] Failed to send packet to decoder." << send_ret;
dout << "[ERROR] Failed to send packet to decoder." << send_ret;
return send_ret;
}
} else {
if (read_ret == AVERROR_EOF) {
int send_ret = avcodec_send_packet(c->codecCtx, NULL);
if (send_ret < 0) {
qDebug() << "[ERROR] Failed to send packet to decoder." << send_ret;
dout << "[ERROR] Failed to send packet to decoder." << send_ret;
return send_ret;
}
} else {
qDebug() << "[ERROR] Could not read frame." << read_ret;
dout << "[ERROR] Could not read frame." << read_ret;
return read_ret; // skips trying to find a frame at all
}
}
}
if (receive_ret < 0) {
if (receive_ret != AVERROR_EOF) qDebug() << "[ERROR] Failed to receive packet from decoder." << receive_ret;
if (receive_ret != AVERROR_EOF) dout << "[ERROR] Failed to receive packet from decoder." << receive_ret;
result = receive_ret;
}
-2
View File
@@ -11,8 +11,6 @@
#include "panels/timeline.h"
#include "undo.h"
#include <QDebug>
extern "C" {
#include <libavformat/avformat.h>
}
-2
View File
@@ -3,8 +3,6 @@
#include "project/clip.h"
#include "effects/transition.h"
#include <QDebug>
Sequence::Sequence() :
playhead(0),
using_workarea(false),
-1
View File
@@ -1,6 +1,5 @@
#include "undo.h"
#include <QDebug>
#include <QTreeWidgetItem>
#include <QMessageBox>
#include <QCheckBox>
-1
View File
@@ -8,7 +8,6 @@
#include <QPainter>
#include <QLinearGradient>
#include <QtMath>
#include <QDebug>
#define AUDIO_MONITOR_PEAK_HEIGHT 15
#define AUDIO_MONITOR_GAP 3
+6 -9
View File
@@ -15,6 +15,7 @@
#include "ui_timeline.h"
#include "mainwindow.h"
#include "ui/viewerwidget.h"
#include "debug.h"
#include "effects/effect.h"
#include "effects/transition.h"
@@ -22,7 +23,6 @@
#include <QPainter>
#include <QColor>
#include <QDebug>
#include <QMouseEvent>
#include <QObject>
#include <QVariant>
@@ -231,20 +231,17 @@ void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) {
}
}
/*if (config.enable_drag_files_to_timeline && event->mimeData()->hasUrls()) {
// TODO for this to work, we need a way to abort PreviewGenerator
qDebug() << "TODO get data for:";
if (config.enable_drag_files_to_timeline && event->mimeData()->hasUrls()) {
dout << "TODO get data for:";
QList<QUrl> urls = event->mimeData()->urls();
if (!urls.isEmpty()) {
for (int i=0;i<urls.size();i++) {
qDebug() << (urls.at(i).toLocalFile());
dout << (urls.at(i).toLocalFile());
}
}
import_init = true;
}*/
}
if (import_init) {
event->accept();
@@ -1965,7 +1962,7 @@ void draw_waveform(Clip* clip, MediaStream* ms, long media_length, QPainter *p,
p->drawLine(clip_rect.left()+i, mid+min, clip_rect.left()+i, mid+max);
}
}/* else {
qDebug() << "[WARNING] Tried to reach" << offset + 1 << ", limit:" << ms->audio_preview.size();
dout << "[WARNING] Tried to reach" << offset + 1 << ", limit:" << ms->audio_preview.size();
}*/
}
}
+4 -4
View File
@@ -13,8 +13,8 @@
#include "ui_timeline.h"
#include "playback/cacher.h"
#include "io/config.h"
#include "debug.h"
#include <QDebug>
#include <QPainter>
#include <QAudioOutput>
#include <QOpenGLShaderProgram>
@@ -279,7 +279,7 @@ GLuint ViewerWidget::compose_sequence(Clip* nest, bool render_audio) {
Clip* c = current_clips.at(i);
if (c->media_type == MEDIA_TYPE_FOOTAGE && !c->finished_opening) {
qDebug() << "[WARNING] Tried to display clip" << i << "but it's closed";
dout << "[WARNING] Tried to display clip" << i << "but it's closed";
texture_failed = true;
} else {
if (c->track < 0) {
@@ -306,7 +306,7 @@ GLuint ViewerWidget::compose_sequence(Clip* nest, bool render_audio) {
if (!texture_failed) {
if (textureID == 0 && c->media_type != MEDIA_TYPE_SOLID) {
qDebug() << "[WARNING] Texture hasn't been created yet";
dout << "[WARNING] Texture hasn't been created yet";
texture_failed = true;
} else if (playhead >= c->timeline_in) {
glPushMatrix();
@@ -514,7 +514,7 @@ void ViewerWidget::paintGL() {
if (texture_failed) {
if (rendering) {
qDebug() << "[INFO] Texture failed - looping";
dout << "[INFO] Texture failed - looping";
loop = true;
} else {
retry_timer.start();