switched to global audio rate, support for QT_SCALE_FACTOR
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
#include "stabilizerdialog.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
StabilizerDialog::StabilizerDialog(QWidget *parent) : QDialog(parent) {
|
||||
layout = new QVBoxLayout(this);
|
||||
setLayout(layout);
|
||||
|
||||
enable_stab = new QCheckBox(this);
|
||||
enable_stab->setText("Enable Stabilizer");
|
||||
layout->addWidget(enable_stab);
|
||||
|
||||
buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
|
||||
layout->addWidget(buttons);
|
||||
|
||||
connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef STABILIZERDIALOG_H
|
||||
#define STABILIZERDIALOG_H
|
||||
|
||||
class QVBoxLayout;
|
||||
class QCheckBox;
|
||||
class QDialogButtonBox;
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class StabilizerDialog : public QDialog
|
||||
{
|
||||
public:
|
||||
StabilizerDialog(QWidget* parent = 0);
|
||||
private:
|
||||
QVBoxLayout* layout;
|
||||
QCheckBox* enable_stab;
|
||||
QDialogButtonBox* buttons;
|
||||
};
|
||||
|
||||
#endif // STABILIZERDIALOG_H
|
||||
+6
-1
@@ -29,7 +29,8 @@ Config::Config()
|
||||
enable_seek_to_import(false),
|
||||
enable_audio_scrubbing(true),
|
||||
drop_on_media_to_replace(true),
|
||||
autoscroll(AUTOSCROLL_PAGE_SCROLL)
|
||||
autoscroll(AUTOSCROLL_PAGE_SCROLL),
|
||||
audio_rate(48000)
|
||||
{}
|
||||
|
||||
void Config::load(QString path) {
|
||||
@@ -103,6 +104,9 @@ void Config::load(QString path) {
|
||||
} else if (stream.name() == "Autoscroll") {
|
||||
stream.readNext();
|
||||
autoscroll = stream.text().toInt();
|
||||
} else if (stream.name() == "AudioRate") {
|
||||
stream.readNext();
|
||||
audio_rate = stream.text().toInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -148,6 +152,7 @@ void Config::save(QString path) {
|
||||
stream.writeTextElement("AudioScrubbing", QString::number(enable_audio_scrubbing));
|
||||
stream.writeTextElement("DropFileOnMediaToReplace", QString::number(drop_on_media_to_replace));
|
||||
stream.writeTextElement("Autoscroll", QString::number(autoscroll));
|
||||
stream.writeTextElement("AudioRate", QString::number(audio_rate));
|
||||
|
||||
stream.writeEndElement(); // configuration
|
||||
stream.writeEndDocument(); // doc
|
||||
|
||||
@@ -41,6 +41,7 @@ struct Config {
|
||||
bool enable_audio_scrubbing;
|
||||
bool drop_on_media_to_replace;
|
||||
int autoscroll;
|
||||
int audio_rate;
|
||||
|
||||
void load(QString path);
|
||||
void save(QString path);
|
||||
|
||||
+3
-1
@@ -213,7 +213,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
config_dir = data_dir + "/config.xml";
|
||||
config.load(config_dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init_audio();
|
||||
|
||||
connect(ui->action_Undo, SIGNAL(triggered(bool)), this, SLOT(undo()));
|
||||
connect(ui->action_Redo, SIGNAL(triggered(bool)), this, SLOT(redo()));
|
||||
|
||||
@@ -94,7 +94,8 @@ SOURCES += \
|
||||
project/effectfield.cpp \
|
||||
effects/internal/cubetransition.cpp \
|
||||
project/effectgizmo.cpp \
|
||||
io/clipboard.cpp
|
||||
io/clipboard.cpp \
|
||||
dialogs/stabilizerdialog.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
@@ -168,7 +169,8 @@ HEADERS += \
|
||||
project/effectfield.h \
|
||||
effects/internal/cubetransition.h \
|
||||
project/effectgizmo.h \
|
||||
io/clipboard.h
|
||||
io/clipboard.h \
|
||||
dialogs/stabilizerdialog.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui \
|
||||
|
||||
@@ -102,15 +102,6 @@ void Viewer::reset_all_audio() {
|
||||
clear_audio_ibuffer();
|
||||
}
|
||||
|
||||
void Viewer::assert_audio_device() {
|
||||
if (is_audio_device_set() &&
|
||||
(audio_output->format().sampleRate() != seq->audio_frequency
|
||||
|| audio_output->format().channelCount() != av_get_channel_layout_nb_channels(seq->audio_layout))) {
|
||||
closeActiveClips(seq, true);
|
||||
init_audio(seq);
|
||||
}
|
||||
}
|
||||
|
||||
long timecode_to_frame(const QString& s, int view, double frame_rate) {
|
||||
QList<QString> list = s.split(QRegExp("[:;]"));
|
||||
|
||||
@@ -242,7 +233,6 @@ void Viewer::seek(long p) {
|
||||
seq->playhead = p;
|
||||
update_parents();
|
||||
reset_all_audio();
|
||||
assert_audio_device();
|
||||
audio_scrub = true;
|
||||
}
|
||||
|
||||
@@ -307,7 +297,6 @@ void Viewer::play() {
|
||||
|
||||
if (seq != NULL) {
|
||||
reset_all_audio();
|
||||
assert_audio_device();
|
||||
if (is_recording_cued() && !start_recording()) {
|
||||
dout << "[ERROR] Failed to record audio";
|
||||
return;
|
||||
@@ -590,8 +579,6 @@ void Viewer::set_sequence(bool main, Sequence *s) {
|
||||
|
||||
bool null_sequence = (seq == NULL);
|
||||
|
||||
init_audio(seq);
|
||||
|
||||
ui->headers->setEnabled(!null_sequence);
|
||||
ui->currentTimecode->setEnabled(!null_sequence);
|
||||
ui->openGLWidget->setEnabled(!null_sequence);
|
||||
|
||||
+1
-2
@@ -61,8 +61,7 @@ public:
|
||||
long recording_end;
|
||||
int recording_track;
|
||||
|
||||
void reset_all_audio();
|
||||
void assert_audio_device();
|
||||
void reset_all_audio();
|
||||
void update_parents();
|
||||
|
||||
ViewerWidget* viewer_widget;
|
||||
|
||||
+37
-38
@@ -40,52 +40,51 @@ bool is_audio_device_set() {
|
||||
return audio_device_set;
|
||||
}
|
||||
|
||||
void init_audio(Sequence* s) {
|
||||
void init_audio() {
|
||||
stop_audio();
|
||||
|
||||
if (s != NULL) {
|
||||
QAudioFormat audio_format;
|
||||
audio_format.setSampleRate(s->audio_frequency);
|
||||
audio_format.setChannelCount(av_get_channel_layout_nb_channels(s->audio_layout));
|
||||
audio_format.setSampleSize(16);
|
||||
audio_format.setCodec("audio/pcm");
|
||||
audio_format.setByteOrder(QAudioFormat::LittleEndian);
|
||||
audio_format.setSampleType(QAudioFormat::SignedInt);
|
||||
QAudioFormat audio_format;
|
||||
audio_format.setSampleRate(config.audio_rate);
|
||||
audio_format.setChannelCount(2);
|
||||
audio_format.setSampleSize(16);
|
||||
audio_format.setCodec("audio/pcm");
|
||||
audio_format.setByteOrder(QAudioFormat::LittleEndian);
|
||||
audio_format.setSampleType(QAudioFormat::SignedInt);
|
||||
|
||||
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
|
||||
QList<QAudioDeviceInfo> devs = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
||||
dout << "[INFO] Found the following audio devices:";
|
||||
for (int i=0;i<devs.size();i++) {
|
||||
dout << " " << devs.at(i).deviceName();
|
||||
}
|
||||
if (info.isNull() && devs.size() > 0) {
|
||||
dout << "[WARNING] Default audio returned NULL, attempting to use first device found...";
|
||||
info = devs.at(0);
|
||||
}
|
||||
dout << "[INFO] Using audio device" << info.deviceName();
|
||||
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
|
||||
QList<QAudioDeviceInfo> devs = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
||||
dout << "[INFO] Found the following audio devices:";
|
||||
for (int i=0;i<devs.size();i++) {
|
||||
dout << " " << devs.at(i).deviceName();
|
||||
}
|
||||
if (info.isNull() && devs.size() > 0) {
|
||||
dout << "[WARNING] Default audio returned NULL, attempting to use first device found...";
|
||||
info = devs.at(0);
|
||||
}
|
||||
dout << "[INFO] Using audio device" << info.deviceName();
|
||||
|
||||
if (!info.isFormatSupported(audio_format)) {
|
||||
qWarning() << "[WARNING] Audio format is not supported by backend, using nearest";
|
||||
audio_format = info.nearestFormat(audio_format);
|
||||
}
|
||||
if (!info.isFormatSupported(audio_format)) {
|
||||
qWarning() << "[WARNING] Audio format is not supported by backend, using nearest";
|
||||
audio_format = info.nearestFormat(audio_format);
|
||||
}
|
||||
|
||||
audio_output = new QAudioOutput(info, audio_format);
|
||||
audio_output->setNotifyInterval(5);
|
||||
audio_output = new QAudioOutput(info, audio_format);
|
||||
audio_output->moveToThread(QApplication::instance()->thread());
|
||||
audio_output->setNotifyInterval(5);
|
||||
|
||||
// connect
|
||||
audio_io_device = audio_output->start();
|
||||
if (audio_io_device == NULL) {
|
||||
dout << "[WARNING] Received NULL audio device. No compatible audio output was found.";
|
||||
} else {
|
||||
audio_device_set = true;
|
||||
// connect
|
||||
audio_io_device = audio_output->start();
|
||||
if (audio_io_device == NULL) {
|
||||
dout << "[WARNING] Received NULL audio device. No compatible audio output was found.";
|
||||
} else {
|
||||
audio_device_set = true;
|
||||
|
||||
// start sender thread
|
||||
audio_thread = new AudioSenderThread();
|
||||
QObject::connect(audio_output, SIGNAL(notify()), audio_thread, SLOT(notifyReceiver()));
|
||||
audio_thread->start(QThread::TimeCriticalPriority);
|
||||
// start sender thread
|
||||
audio_thread = new AudioSenderThread();
|
||||
QObject::connect(audio_output, SIGNAL(notify()), audio_thread, SLOT(notifyReceiver()));
|
||||
audio_thread->start(QThread::TimeCriticalPriority);
|
||||
|
||||
clear_audio_ibuffer();
|
||||
}
|
||||
clear_audio_ibuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ void clear_audio_ibuffer();
|
||||
|
||||
bool is_audio_device_set();
|
||||
|
||||
void init_audio(Sequence *s);
|
||||
void init_audio();
|
||||
void stop_audio();
|
||||
int get_buffer_offset_from_frame(double framerate, long frame);
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ void get_clip_frame(Clip* c, long playhead) {
|
||||
#ifdef GCF_DEBUG
|
||||
dout << "GCF ==> RESET" << target_pts << "(" << target_frame->pts << "-" << target_frame->pts+target_frame->pkt_duration << ")";
|
||||
#endif
|
||||
// target_frame = NULL;
|
||||
target_frame = NULL;
|
||||
reset = true;
|
||||
c->last_invalid_ts = target_pts;
|
||||
} else {
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#define MEDIA_TYPE_FOOTAGE 0
|
||||
#define MEDIA_TYPE_SEQUENCE 1
|
||||
#define MEDIA_TYPE_FOLDER 2
|
||||
#define MEDIA_TYPE_SOLID 3
|
||||
#define MEDIA_TYPE_TONE 4
|
||||
|
||||
class Footage;
|
||||
class MediaThrobber;
|
||||
|
||||
+12
-1
@@ -16,6 +16,7 @@
|
||||
#include "ui_timeline.h"
|
||||
#include "mainwindow.h"
|
||||
#include "ui/viewerwidget.h"
|
||||
#include "dialogs/stabilizerdialog.h"
|
||||
#include "project/media.h"
|
||||
#include "debug.h"
|
||||
|
||||
@@ -150,6 +151,11 @@ void TimelineWidget::show_context_menu(const QPoint& pos) {
|
||||
QAction* nestAction = menu.addAction("&Nest");
|
||||
connect(nestAction, SIGNAL(triggered(bool)), mainWindow, SLOT(on_actionNest_triggered()));
|
||||
|
||||
if (selected_clips.size() == 1 && selected_clips.at(0)->media != NULL && selected_clips.at(0)->media->get_type() == MEDIA_TYPE_FOOTAGE) {
|
||||
QAction* stabilizerAction = menu.addAction("S&tabilizer");
|
||||
connect(stabilizerAction, SIGNAL(triggered(bool)), this, SLOT(show_stabilizer_diag()));
|
||||
}
|
||||
|
||||
// set autoscale arbitrarily to the first selected clip
|
||||
autoscaleAction->setChecked(selected_clips.at(0)->autoscale);
|
||||
|
||||
@@ -229,7 +235,12 @@ void TimelineWidget::rename_clip() {
|
||||
undo_stack.push(rcc);
|
||||
update_ui(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineWidget::show_stabilizer_diag() {
|
||||
StabilizerDialog sd;
|
||||
sd.exec();
|
||||
}
|
||||
|
||||
bool same_sign(int a, int b) {
|
||||
|
||||
@@ -85,6 +85,7 @@ private slots:
|
||||
void toggle_autoscale();
|
||||
void tooltip_timer_timeout();
|
||||
void rename_clip();
|
||||
void show_stabilizer_diag();
|
||||
};
|
||||
|
||||
#endif // TIMELINEWIDGET_H
|
||||
|
||||
+12
-1
@@ -32,6 +32,7 @@
|
||||
#include <QOffscreenSurface>
|
||||
#include <QFileDialog>
|
||||
#include <QPolygon>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
extern "C" {
|
||||
#include <libavformat/avformat.h>
|
||||
@@ -618,7 +619,17 @@ GLuint ViewerWidget::compose_sequence(QVector<Clip*>& nests, bool render_audio)
|
||||
} else if (rendering) {
|
||||
glViewport(0, 0, s->width, s->height);
|
||||
} else {
|
||||
glViewport(0, 0, width(), height());
|
||||
int widget_width = width();
|
||||
int widget_height = height();
|
||||
|
||||
QString qt_scale_factor = QString(qgetenv("QT_SCALE_FACTOR"));
|
||||
if (!qt_scale_factor.isEmpty()) {
|
||||
double scale = qt_scale_factor.toDouble();
|
||||
widget_width *= scale;
|
||||
widget_height *= scale;
|
||||
}
|
||||
|
||||
glViewport(0, 0, widget_width, widget_height);
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, composite_texture);
|
||||
|
||||
Reference in New Issue
Block a user