This commit is contained in:
itsmattkc
2019-01-03 00:09:39 +11:00
parent f4715fdf99
commit 2b7103e286
17 changed files with 221 additions and 150 deletions
+75 -15
View File
@@ -6,6 +6,8 @@
#include <QLineEdit>
#include <QDialogButtonBox>
#include <QTreeWidgetItem>
#include <QGroupBox>
#include <QListWidget>
#include "project/footage.h"
#include "project/media.h"
@@ -16,49 +18,107 @@ MediaPropertiesDialog::MediaPropertiesDialog(QWidget *parent, Media *i) :
QDialog(parent),
item(i)
{
setWindowTitle("\"" + i->data(0, Qt::DisplayRole).toString() + "\" Properties");
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QGridLayout* grid = new QGridLayout();
setLayout(grid);
int row = 0;
Footage* f = item->to_footage();
grid->addWidget(new QLabel("Tracks:"), row, 0, 1, 2);
row++;
track_list = new QListWidget();
for (int i=0;i<f->video_tracks.size();i++) {
const FootageStream& fs = f->video_tracks.at(i);
QListWidgetItem* item = new QListWidgetItem("Video " + QString::number(fs.file_index) + ": " + QString::number(fs.video_width) + "x" + QString::number(fs.video_height) + " " + QString::number(fs.video_frame_rate) + "FPS");
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(fs.enabled ? Qt::Checked : Qt::Unchecked);
item->setData(Qt::UserRole+1, fs.file_index);
track_list->addItem(item);
}
for (int i=0;i<f->audio_tracks.size();i++) {
const FootageStream& fs = f->audio_tracks.at(i);
QListWidgetItem* item = new QListWidgetItem("Audio " + QString::number(fs.file_index) + ": " + QString::number(fs.audio_frequency) + "Hz " + QString::number(fs.audio_channels) + " channels");
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(fs.enabled ? Qt::Checked : Qt::Unchecked);
item->setData(Qt::UserRole+1, fs.file_index);
track_list->addItem(item);
}
grid->addWidget(track_list, row, 0, 1, 2);
row++;
if (f->video_tracks.size() > 0) {
interlacing_box = new QComboBox();
interlacing_box->addItem("Auto (" + get_interlacing_name(f->video_tracks.at(0)->video_auto_interlacing) + ")");
interlacing_box->addItem("Auto (" + get_interlacing_name(f->video_tracks.at(0).video_auto_interlacing) + ")");
interlacing_box->addItem(get_interlacing_name(VIDEO_PROGRESSIVE));
interlacing_box->addItem(get_interlacing_name(VIDEO_TOP_FIELD_FIRST));
interlacing_box->addItem(get_interlacing_name(VIDEO_BOTTOM_FIELD_FIRST));
interlacing_box->setCurrentIndex((f->video_tracks.at(0)->video_auto_interlacing == f->video_tracks.at(0)->video_interlacing) ? 0 : f->video_tracks.at(0)->video_interlacing + 1);
interlacing_box->setCurrentIndex((f->video_tracks.at(0).video_auto_interlacing == f->video_tracks.at(0).video_interlacing) ? 0 : f->video_tracks.at(0).video_interlacing + 1);
grid->addWidget(new QLabel("Interlacing:"), 0, 0);
grid->addWidget(interlacing_box, 0, 1);
grid->addWidget(new QLabel("Interlacing:"), row, 0);
grid->addWidget(interlacing_box, row, 1);
row++;
}
name_box = new QLineEdit(item->get_name());
grid->addWidget(new QLabel("Name:"), 1, 0);
grid->addWidget(name_box, 1, 1);
grid->addWidget(new QLabel("Name:"), row, 0);
grid->addWidget(name_box, row, 1);
row++;
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
buttons->setCenterButtons(true);
grid->addWidget(buttons, 2, 0, 1, 2);
grid->addWidget(buttons, row, 0, 1, 2);
connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
}
void MediaPropertiesDialog::accept() {
Footage* f = item->to_footage();
ComboAction* ca = new ComboAction();
//set interlacing
Footage* f = item->to_footage();
if (interlacing_box->currentIndex() > 0) {
ca->append(new SetInt(&f->video_tracks.at(0)->video_interlacing, interlacing_box->currentIndex() - 1));
} else {
ca->append(new SetInt(&f->video_tracks.at(0)->video_interlacing, f->video_tracks.at(0)->video_auto_interlacing));
}
// set track enable
for (int i=0;i<track_list->count();i++) {
QListWidgetItem* item = track_list->item(i);
const QVariant& data = item->data(Qt::UserRole+1);
if (!data.isNull()) {
int index = data.toInt();
bool found = false;
for (int j=0;j<f->video_tracks.size();j++) {
if (f->video_tracks.at(j).file_index == index) {
f->video_tracks[j].enabled = (item->checkState() == Qt::Checked);
found = true;
break;
}
}
if (!found) {
for (int j=0;j<f->audio_tracks.size();j++) {
if (f->audio_tracks.at(j).file_index == index) {
f->audio_tracks[j].enabled = (item->checkState() == Qt::Checked);
break;
}
}
}
}
}
//set name
// set interlacing
if (f->video_tracks.size() > 0) {
if (interlacing_box->currentIndex() > 0) {
ca->append(new SetInt(&f->video_tracks[0].video_interlacing, interlacing_box->currentIndex() - 1));
} else {
ca->append(new SetInt(&f->video_tracks[0].video_interlacing, f->video_tracks.at(0).video_auto_interlacing));
}
}
// set name
MediaRename* mr = new MediaRename(item, name_box->text());
ca->append(mr);
+2
View File
@@ -7,6 +7,7 @@ struct Footage;
class QComboBox;
class QLineEdit;
class Media;
class QListWidget;
class MediaPropertiesDialog : public QDialog {
Q_OBJECT
@@ -16,6 +17,7 @@ private:
QComboBox* interlacing_box;
QLineEdit* name_box;
Media* item;
QListWidget* track_list;
private slots:
void accept();
};
+57 -48
View File
@@ -55,14 +55,13 @@ void PreviewGenerator::parse_media() {
if (avcodec_find_decoder(fmt_ctx->streams[i]->codecpar->codec_id) == NULL) {
dout << "[ERROR] Unsupported codec in stream" << i << "of file" << footage->name;
} else {
FootageStream* ms = footage->get_stream_from_file_index(fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO, i);
FootageStream ms;
ms.preview_done = false;
ms.file_index = i;
ms.enabled = true;
bool append = false;
if (ms == NULL) {
ms = new FootageStream();
ms->preview_done = false;
ms->file_index = i;
append = true;
}
if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO
&& fmt_ctx->streams[i]->codecpar->width > 0
&& fmt_ctx->streams[i]->codecpar->height > 0) {
@@ -76,33 +75,43 @@ void PreviewGenerator::parse_media() {
// heuristic to determine if video is a still image
if (fmt_ctx->streams[i]->avg_frame_rate.den == 0
&& fmt_ctx->streams[i]->codecpar->codec_id != AV_CODEC_ID_DNXHD) { // silly hack but this is the only scenario i've seen this
ms->infinite_length = true;
ms.infinite_length = true;
contains_still_image = true;
ms->video_frame_rate = 0;
ms.video_frame_rate = 0;
} else {
ms->infinite_length = false;
ms.infinite_length = false;
if (fmt_ctx->streams[i]->r_frame_rate.den == 0) {
ms->video_frame_rate = av_q2d(fmt_ctx->streams[i]->avg_frame_rate);
ms.video_frame_rate = av_q2d(fmt_ctx->streams[i]->avg_frame_rate);
} else {
ms->video_frame_rate = av_q2d(fmt_ctx->streams[i]->r_frame_rate);
ms.video_frame_rate = av_q2d(fmt_ctx->streams[i]->r_frame_rate);
}
}
ms->video_width = fmt_ctx->streams[i]->codecpar->width;
ms->video_height = fmt_ctx->streams[i]->codecpar->height;
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;
ms.video_auto_interlacing = VIDEO_PROGRESSIVE;
ms.video_interlacing = VIDEO_PROGRESSIVE;
if (append) footage->video_tracks.append(ms);
append = true;
} else if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
ms->audio_channels = fmt_ctx->streams[i]->codecpar->channels;
ms->audio_layout = fmt_ctx->streams[i]->codecpar->channel_layout;
ms->audio_frequency = fmt_ctx->streams[i]->codecpar->sample_rate;
if (append) footage->audio_tracks.append(ms);
} else if (append) {
delete ms;
}
ms.audio_channels = fmt_ctx->streams[i]->codecpar->channels;
ms.audio_layout = fmt_ctx->streams[i]->codecpar->channel_layout;
ms.audio_frequency = fmt_ctx->streams[i]->codecpar->sample_rate;
append = true;
}
if (append) {
QVector<FootageStream>& stream_list = (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) ? footage->audio_tracks : footage->video_tracks;
for (int j=0;j<stream_list.size();j++) {
if (stream_list.at(j).file_index == i) {
stream_list[j] = ms;
append = false;
}
}
if (append) stream_list.append(ms);
}
}
}
footage->length = fmt_ctx->duration;
@@ -123,32 +132,32 @@ bool PreviewGenerator::retrieve_preview(const QString& hash) {
bool found = true;
for (int i=0;i<footage->video_tracks.size();i++) {
FootageStream* ms = footage->video_tracks.at(i);
FootageStream& ms = footage->video_tracks[i];
QString thumb_path = get_thumbnail_path(hash, ms);
QFile f(thumb_path);
if (f.exists() && ms->video_preview.load(thumb_path)) {
if (f.exists() && ms.video_preview.load(thumb_path)) {
//dout << "loaded thumb" << ms->file_index << "from" << thumb_path;
ms->make_square_thumb();
ms->preview_done = true;
ms.make_square_thumb();
ms.preview_done = true;
} else {
found = false;
break;
}
}
for (int i=0;i<footage->audio_tracks.size();i++) {
FootageStream* ms = footage->audio_tracks.at(i);
FootageStream& ms = footage->audio_tracks[i];
QString waveform_path = get_waveform_path(hash, ms);
QFile f(waveform_path);
if (f.exists()) {
//dout << "loaded wave" << ms->file_index << "from" << waveform_path;
f.open(QFile::ReadOnly);
QByteArray data = f.readAll();
ms->audio_preview.resize(data.size());
ms.audio_preview.resize(data.size());
for (int j=0;j<data.size();j++) {
// faster way?
ms->audio_preview[j] = data.at(j);
ms.audio_preview[j] = data.at(j);
}
ms->preview_done = true;
ms.preview_done = true;
f.close();
} else {
found = false;
@@ -157,13 +166,13 @@ bool PreviewGenerator::retrieve_preview(const QString& hash) {
}
if (!found) {
for (int i=0;i<footage->video_tracks.size();i++) {
FootageStream* ms = footage->video_tracks.at(i);
ms->preview_done = false;
FootageStream& ms = footage->video_tracks[i];
ms.preview_done = false;
}
for (int i=0;i<footage->audio_tracks.size();i++) {
FootageStream* ms = footage->audio_tracks.at(i);
ms->audio_preview.clear();
ms->preview_done = false;
FootageStream& ms = footage->audio_tracks[i];
ms.audio_preview.clear();
ms.preview_done = false;
}
}
return !found;
@@ -336,7 +345,7 @@ void PreviewGenerator::generate_waveform() {
break;
}
}
s->audio_preview.append(min >> 8);
s->audio_preview.append(min >> 8);
s->audio_preview.append(max >> 8);
if (cancelled) break;
}
@@ -359,7 +368,7 @@ void PreviewGenerator::generate_waveform() {
} else if (footage->audio_tracks.size() == 0) {
done = true;
for (int i=0;i<footage->video_tracks.size();i++) {
if (!footage->video_tracks.at(i)->preview_done) {
if (!footage->video_tracks.at(i).preview_done) {
done = false;
break;
}
@@ -373,7 +382,7 @@ void PreviewGenerator::generate_waveform() {
}
}
for (int i=0;i<footage->audio_tracks.size();i++) {
footage->audio_tracks.at(i)->preview_done = true;
footage->audio_tracks[i].preview_done = true;
}
av_frame_free(&temp_frame);
av_packet_free(&packet);
@@ -397,12 +406,12 @@ void PreviewGenerator::generate_waveform() {
delete [] codec_ctx;
}
QString PreviewGenerator::get_thumbnail_path(const QString& hash, FootageStream* ms) {
return data_path + "/" + hash + "t" + QString::number(ms->file_index);
QString PreviewGenerator::get_thumbnail_path(const QString& hash, const FootageStream& ms) {
return data_path + "/" + hash + "t" + QString::number(ms.file_index);
}
QString PreviewGenerator::get_waveform_path(const QString& hash, FootageStream* ms) {
return data_path + "/" + hash + "w" + QString::number(ms->file_index);
QString PreviewGenerator::get_waveform_path(const QString& hash, const FootageStream& ms) {
return data_path + "/" + hash + "w" + QString::number(ms.file_index);
}
void PreviewGenerator::run() {
@@ -445,15 +454,15 @@ void PreviewGenerator::run() {
// save preview to file
for (int i=0;i<footage->video_tracks.size();i++) {
FootageStream* ms = footage->video_tracks.at(i);
ms->video_preview.save(get_thumbnail_path(hash, ms), "PNG");
FootageStream& ms = footage->video_tracks[i];
ms.video_preview.save(get_thumbnail_path(hash, ms), "PNG");
//dout << "saved" << ms->file_index << "thumbnail to" << get_thumbnail_path(hash, ms);
}
for (int i=0;i<footage->audio_tracks.size();i++) {
FootageStream* ms = footage->audio_tracks.at(i);
FootageStream& ms = footage->audio_tracks[i];
QFile f(get_waveform_path(hash, ms));
f.open(QFile::WriteOnly);
f.write(ms->audio_preview.constData(), ms->audio_preview.size());
f.write(ms.audio_preview.constData(), ms.audio_preview.size());
f.close();
//dout << "saved" << ms->file_index << "waveform to" << get_waveform_path(hash, ms);
}
+2 -2
View File
@@ -36,8 +36,8 @@ private:
bool replace;
bool cancelled;
QString data_path;
QString get_thumbnail_path(const QString &hash, FootageStream* ms);
QString get_waveform_path(const QString& hash, FootageStream* ms);
QString get_thumbnail_path(const QString &hash, const FootageStream &ms);
QString get_waveform_path(const QString& hash, const FootageStream &ms);
};
#endif // PREVIEWGENERATOR_H
+19 -19
View File
@@ -181,13 +181,13 @@ Sequence* create_sequence_from_media(QVector<Media*>& media_list) {
if (m->ready) {
if (!got_video_values) {
for (int j=0;j<m->video_tracks.size();j++) {
FootageStream* ms = m->video_tracks.at(j);
s->width = ms->video_width;
s->height = ms->video_height;
if (ms->video_frame_rate != 0) {
s->frame_rate = ms->video_frame_rate;
const FootageStream& ms = m->video_tracks.at(j);
s->width = ms.video_width;
s->height = ms.video_height;
if (ms.video_frame_rate != 0) {
s->frame_rate = ms.video_frame_rate;
if (ms->video_interlacing != VIDEO_PROGRESSIVE) s->frame_rate *= 2;
if (ms.video_interlacing != VIDEO_PROGRESSIVE) s->frame_rate *= 2;
// only break with a decent frame rate, otherwise there may be a better candidate
got_video_values = true;
@@ -197,8 +197,8 @@ Sequence* create_sequence_from_media(QVector<Media*>& media_list) {
}
if (!got_audio_values) {
for (int j=0;j<m->audio_tracks.size();j++) {
FootageStream* ms = m->audio_tracks.at(j);
s->audio_frequency = ms->audio_frequency;
const FootageStream& ms = m->audio_tracks.at(j);
s->audio_frequency = ms.audio_frequency;
got_audio_values = true;
break;
}
@@ -851,22 +851,22 @@ void Project::save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only,
stream.writeAttribute("in", QString::number(f->in));
stream.writeAttribute("out", QString::number(f->out));
for (int j=0;j<f->video_tracks.size();j++) {
FootageStream* ms = f->video_tracks.at(j);
const FootageStream& ms = f->video_tracks.at(j);
stream.writeStartElement("video");
stream.writeAttribute("id", QString::number(ms->file_index));
stream.writeAttribute("width", QString::number(ms->video_width));
stream.writeAttribute("height", QString::number(ms->video_height));
stream.writeAttribute("framerate", QString::number(ms->video_frame_rate, 'f', 10));
stream.writeAttribute("infinite", QString::number(ms->infinite_length));
stream.writeAttribute("id", QString::number(ms.file_index));
stream.writeAttribute("width", QString::number(ms.video_width));
stream.writeAttribute("height", QString::number(ms.video_height));
stream.writeAttribute("framerate", QString::number(ms.video_frame_rate, 'f', 10));
stream.writeAttribute("infinite", QString::number(ms.infinite_length));
stream.writeEndElement();
}
for (int j=0;j<f->audio_tracks.size();j++) {
FootageStream* ms = f->audio_tracks.at(j);
const FootageStream& ms = f->audio_tracks.at(j);
stream.writeStartElement("audio");
stream.writeAttribute("id", QString::number(ms->file_index));
stream.writeAttribute("channels", QString::number(ms->audio_channels));
stream.writeAttribute("layout", QString::number(ms->audio_layout));
stream.writeAttribute("frequency", QString::number(ms->audio_frequency));
stream.writeAttribute("id", QString::number(ms.file_index));
stream.writeAttribute("channels", QString::number(ms.audio_channels));
stream.writeAttribute("layout", QString::number(ms.audio_layout));
stream.writeAttribute("frequency", QString::number(ms.audio_frequency));
stream.writeEndElement();
}
stream.writeEndElement();
+14 -10
View File
@@ -182,7 +182,7 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector
can_import = m->ready;
if (m->using_inout) {
double source_fr = 30;
if (m->video_tracks.size() > 0 && !qIsNull(m->video_tracks.at(0)->video_frame_rate)) source_fr = m->video_tracks.at(0)->video_frame_rate;
if (m->video_tracks.size() > 0 && !qIsNull(m->video_tracks.at(0).video_frame_rate)) source_fr = m->video_tracks.at(0).video_frame_rate;
default_clip_in = refactor_frame_number(m->in, source_fr, seq->frame_rate);
default_clip_out = refactor_frame_number(m->out, source_fr, seq->frame_rate);
}
@@ -214,7 +214,7 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector
switch (medium->get_type()) {
case MEDIA_TYPE_FOOTAGE:
// is video source a still image?
if (m->video_tracks.size() > 0 && m->video_tracks[0]->infinite_length && m->audio_tracks.size() == 0) {
if (m->video_tracks.size() > 0 && m->video_tracks.at(0).infinite_length && m->audio_tracks.size() == 0) {
g.out = g.in + 100;
} else {
long length = m->get_length_in_frames(seq->frame_rate);
@@ -225,16 +225,20 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector
}
for (int j=0;j<m->audio_tracks.size();j++) {
g.track = j;
g.media_stream = m->audio_tracks.at(j)->file_index;
ghosts.append(g);
audio_ghosts = true;
if (m->audio_tracks.at(j).enabled) {
g.track = j;
g.media_stream = m->audio_tracks.at(j).file_index;
ghosts.append(g);
audio_ghosts = true;
}
}
for (int j=0;j<m->video_tracks.size();j++) {
g.track = -1-j;
g.media_stream = m->video_tracks.at(j)->file_index;
ghosts.append(g);
video_ghosts = true;
if (m->video_tracks.at(j).enabled) {
g.track = -1-j;
g.media_stream = m->video_tracks.at(j).file_index;
ghosts.append(g);
video_ghosts = true;
}
}
break;
case MEDIA_TYPE_SEQUENCE:
+9 -9
View File
@@ -573,14 +573,14 @@ void Viewer::set_media(Media* m) {
seq->frame_rate = 30;
if (footage->video_tracks.size() > 0) {
FootageStream* video_stream = footage->video_tracks.at(0);
seq->width = video_stream->video_width;
seq->height = video_stream->video_height;
if (video_stream->video_frame_rate > 0 && !video_stream->infinite_length) seq->frame_rate = video_stream->video_frame_rate;
const FootageStream& video_stream = footage->video_tracks.at(0);
seq->width = video_stream.video_width;
seq->height = video_stream.video_height;
if (video_stream.video_frame_rate > 0 && !video_stream.infinite_length) seq->frame_rate = video_stream.video_frame_rate;
Clip* c = new Clip(seq);
c->media = media;
c->media_stream = video_stream->file_index;
c->media_stream = video_stream.file_index;
c->timeline_in = 0;
c->timeline_out = footage->get_length_in_frames(seq->frame_rate);
if (c->timeline_out <= 0) c->timeline_out = 150;
@@ -594,12 +594,12 @@ void Viewer::set_media(Media* m) {
}
if (footage->audio_tracks.size() > 0) {
FootageStream* audio_stream = footage->audio_tracks.at(0);
seq->audio_frequency = audio_stream->audio_frequency;
const FootageStream& audio_stream = footage->audio_tracks.at(0);
seq->audio_frequency = audio_stream.audio_frequency;
Clip* c = new Clip(seq);
c->media = media;
c->media_stream = audio_stream->file_index;
c->media_stream = audio_stream.file_index;
c->timeline_in = 0;
c->timeline_out = footage->get_length_in_frames(seq->frame_rate);
c->track = 0;
@@ -610,7 +610,7 @@ void Viewer::set_media(Media* m) {
if (footage->video_tracks.size() == 0) {
viewer_widget->waveform = true;
viewer_widget->waveform_clip = c;
viewer_widget->waveform_ms = audio_stream;
viewer_widget->waveform_ms = &audio_stream;
viewer_widget->update();
}
} else {
+3 -3
View File
@@ -451,7 +451,7 @@ void cache_video_worker(Clip* c, long playhead) {
AVFrame* frame = av_frame_alloc();
Footage* media = c->media->to_footage();
FootageStream* ms = media->get_stream_from_file_index(true, c->media_stream);
const FootageStream* ms = media->get_stream_from_file_index(true, c->media_stream);
while ((retr_ret = av_buffersink_get_frame(c->buffersink_ctx, frame)) == AVERROR(EAGAIN)) {
if (c->multithreaded && c->cacher->interrupt) return; // abort
@@ -546,7 +546,7 @@ void reset_cache(Clip* c, long target_frame) {
c->frame->pts = 0;
}
} else {
FootageStream* ms = c->media->to_footage()->get_stream_from_file_index(c->track < 0, c->media_stream);
const FootageStream* ms = c->media->to_footage()->get_stream_from_file_index(c->track < 0, c->media_stream);
if (ms->infinite_length) {
/*avcodec_flush_buffers(c->codecCtx);
av_seek_frame(c->formatCtx, ms->file_index, 0, AVSEEK_FLAG_BACKWARD);*/
@@ -640,7 +640,7 @@ void open_clip_worker(Clip* clip) {
Footage* m = clip->media->to_footage();
QByteArray ba = m->url.toUtf8();
const char* filename = ba.constData();
FootageStream* ms = m->get_stream_from_file_index(clip->track < 0, clip->media_stream);
const FootageStream* ms = m->get_stream_from_file_index(clip->track < 0, clip->media_stream);
int errCode = avformat_open_input(
&clip->formatCtx,
+3 -3
View File
@@ -116,11 +116,11 @@ double get_timecode(Clip* c, long playhead) {
void get_clip_frame(Clip* c, long playhead) {
if (c->finished_opening) {
FootageStream* ms = c->media->to_footage()->get_stream_from_file_index(c->track < 0, c->media_stream);
const FootageStream* ms = c->media->to_footage()->get_stream_from_file_index(c->track < 0, c->media_stream);
int64_t target_pts = qMax(static_cast<int64_t>(0), playhead_to_timestamp(c, playhead));
int64_t second_pts = qRound64(av_q2d(av_inv_q(c->stream->time_base)));
if (ms->video_interlacing != VIDEO_PROGRESSIVE) {
if (ms->video_interlacing != VIDEO_PROGRESSIVE) {
target_pts *= 2;
second_pts *= 2;
}
@@ -132,7 +132,7 @@ void get_clip_frame(Clip* c, long playhead) {
c->queue_lock.lock();
if (c->queue.size() > 0) {
if (ms->infinite_length) {
if (ms->infinite_length) {
target_frame = c->queue.at(0);
#ifdef GCF_DEBUG
dout << "GCF ==> USE PRECISE (INFINITE)";
+6 -6
View File
@@ -113,9 +113,9 @@ void Clip::refresh() {
Footage* m = media->to_footage();
if (track < 0 && m->video_tracks.size() > 0) {
media_stream = m->video_tracks.at(0)->file_index;
media_stream = m->video_tracks.at(0).file_index;
} else if (track >= 0 && m->audio_tracks.size() > 0) {
media_stream = m->audio_tracks.at(0)->file_index;
media_stream = m->audio_tracks.at(0).file_index;
}
}
replaced = false;
@@ -241,8 +241,8 @@ void Clip::recalculateMaxLength() {
case MEDIA_TYPE_FOOTAGE:
{
Footage* m = media->to_footage();
FootageStream* ms = m->get_stream_from_file_index(track < 0, media_stream);
if (ms != NULL && ms->infinite_length) {
const FootageStream* ms = m->get_stream_from_file_index(track < 0, media_stream);
if (ms != NULL && ms->infinite_length) {
calculated_length = LONG_MAX;
} else {
calculated_length = m->get_length_in_frames(fr);
@@ -269,7 +269,7 @@ int Clip::getWidth() {
switch (media->get_type()) {
case MEDIA_TYPE_FOOTAGE:
{
FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream);
const FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream);
if (ms != NULL) return ms->video_width;
if (sequence != NULL) return sequence->width;
}
@@ -287,7 +287,7 @@ int Clip::getHeight() {
switch (media->get_type()) {
case MEDIA_TYPE_FOOTAGE:
{
FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream);
const FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream);
if (ms != NULL) return ms->video_height;
if (sequence != NULL) return sequence->height;
}
+4 -10
View File
@@ -24,12 +24,6 @@ void Footage::reset() {
preview_gen->cancel();
preview_gen->wait();
}
for (int i=0;i<video_tracks.size();i++) {
delete video_tracks.at(i);
}
for (int i=0;i<audio_tracks.size();i++) {
delete audio_tracks.at(i);
}
video_tracks.clear();
audio_tracks.clear();
ready = false;
@@ -43,14 +37,14 @@ long Footage::get_length_in_frames(double frame_rate) {
FootageStream* Footage::get_stream_from_file_index(bool video, int index) {
if (video) {
for (int i=0;i<video_tracks.size();i++) {
if (video_tracks.at(i)->file_index == index) {
return video_tracks.at(i);
if (video_tracks.at(i).file_index == index) {
return &video_tracks[i];
}
}
} else {
for (int i=0;i<audio_tracks.size();i++) {
if (audio_tracks.at(i)->file_index == index) {
return audio_tracks.at(i);
if (audio_tracks.at(i).file_index == index) {
return &audio_tracks[i];
}
}
}
+4 -3
View File
@@ -29,6 +29,7 @@ struct FootageStream {
int audio_channels;
int audio_layout;
int audio_frequency;
bool enabled;
// preview thumbnail/waveform
bool preview_done;
@@ -45,8 +46,8 @@ struct Footage {
QString url;
QString name;
int64_t length;
QVector<FootageStream*> video_tracks;
QVector<FootageStream*> audio_tracks;
QVector<FootageStream> video_tracks;
QVector<FootageStream> audio_tracks;
int save_id;
bool ready;
bool invalid;
@@ -59,7 +60,7 @@ struct Footage {
long out;
long get_length_in_frames(double frame_rate);
FootageStream* get_stream_from_file_index(bool video, int index);
FootageStream *get_stream_from_file_index(bool video, int index);
void reset();
};
+17 -16
View File
@@ -104,21 +104,21 @@ void Media::update_tooltip(const QString& error) {
if (i > 0) {
tooltip += ", ";
}
tooltip += QString::number(f->video_tracks.at(i)->video_width) + "x" + QString::number(f->video_tracks.at(i)->video_height);
tooltip += QString::number(f->video_tracks.at(i).video_width) + "x" + QString::number(f->video_tracks.at(i).video_height);
}
tooltip += "\n";
if (!f->video_tracks.at(0)->infinite_length) {
if (!f->video_tracks.at(0).infinite_length) {
tooltip += "Frame Rate: ";
for (int i=0;i<f->video_tracks.size();i++) {
if (i > 0) {
tooltip += ", ";
}
if (f->video_tracks.at(i)->video_interlacing == VIDEO_PROGRESSIVE) {
tooltip += QString::number(f->video_tracks.at(i)->video_frame_rate);
if (f->video_tracks.at(i).video_interlacing == VIDEO_PROGRESSIVE) {
tooltip += QString::number(f->video_tracks.at(i).video_frame_rate);
} else {
tooltip += QString::number(f->video_tracks.at(i)->video_frame_rate * 2);
tooltip += " fields (" + QString::number(f->video_tracks.at(i)->video_frame_rate) + " frames)";
tooltip += QString::number(f->video_tracks.at(i).video_frame_rate * 2);
tooltip += " fields (" + QString::number(f->video_tracks.at(i).video_frame_rate) + " frames)";
}
}
tooltip += "\n";
@@ -129,7 +129,7 @@ void Media::update_tooltip(const QString& error) {
if (i > 0) {
tooltip += ", ";
}
tooltip += get_interlacing_name(f->video_tracks.at(i)->video_interlacing);
tooltip += get_interlacing_name(f->video_tracks.at(i).video_interlacing);
}
}
@@ -141,7 +141,7 @@ void Media::update_tooltip(const QString& error) {
if (i > 0) {
tooltip += ", ";
}
tooltip += QString::number(f->audio_tracks.at(i)->audio_frequency);
tooltip += QString::number(f->audio_tracks.at(i).audio_frequency);
}
tooltip += "\n";
@@ -150,7 +150,7 @@ void Media::update_tooltip(const QString& error) {
if (i > 0) {
tooltip += ", ";
}
tooltip += get_channel_layout_name(f->audio_tracks.at(i)->audio_channels, f->audio_tracks.at(i)->audio_layout);
tooltip += get_channel_layout_name(f->audio_tracks.at(i).audio_channels, f->audio_tracks.at(i).audio_layout);
}
// tooltip += "\n";
}
@@ -202,8 +202,8 @@ double Media::get_frame_rate(int stream) {
case MEDIA_TYPE_FOOTAGE:
{
Footage* f = to_footage();
if (stream < 0) return f->video_tracks.at(0)->video_frame_rate;
return f->get_stream_from_file_index(true, stream)->video_frame_rate;
if (stream < 0) return f->video_tracks.at(0).video_frame_rate;
return f->get_stream_from_file_index(true, stream)->video_frame_rate;
}
case MEDIA_TYPE_SEQUENCE: return to_sequence()->frame_rate;
}
@@ -215,8 +215,8 @@ int Media::get_sampling_rate(int stream) {
case MEDIA_TYPE_FOOTAGE:
{
Footage* f = to_footage();
if (stream < 0) return f->audio_tracks.at(0)->audio_frequency;
return to_footage()->get_stream_from_file_index(false, stream)->audio_frequency;
if (stream < 0) return f->audio_tracks.at(0).audio_frequency;
return to_footage()->get_stream_from_file_index(false, stream)->audio_frequency;
}
case MEDIA_TYPE_SEQUENCE: return to_sequence()->audio_frequency;
}
@@ -258,8 +258,8 @@ QVariant Media::data(int column, int role) {
if (get_type() == MEDIA_TYPE_FOOTAGE) {
Footage* f = to_footage();
if (f->video_tracks.size() > 0
&& f->video_tracks.at(0)->preview_done) {
return f->video_tracks.at(0)->video_preview_square;
&& f->video_tracks.at(0).preview_done) {
return f->video_tracks.at(0).video_preview_square;
}
}
@@ -279,7 +279,8 @@ QVariant Media::data(int column, int role) {
Footage* f = to_footage();
double r = 30;
if (f->video_tracks.size() > 0 && !qIsNull(f->video_tracks.at(0)->video_frame_rate)) r = f->video_tracks.at(0)->video_frame_rate;
if (f->video_tracks.size() > 0 && !qIsNull(f->video_tracks.at(0).video_frame_rate))
r = f->video_tracks.at(0).video_frame_rate;
long len = f->get_length_in_frames(r);
if (len > 0) return frame_to_timecode(len, config.timecode_view, r);
+3 -3
View File
@@ -1272,9 +1272,9 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) {
Clip* c = NULL;
if (g.clip != -1) c = sequence->clips.at(g.clip);
FootageStream* ms = NULL;
const FootageStream* ms = NULL;
if (g.clip != -1 && c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) {
ms = c->media->to_footage()->get_stream_from_file_index(c->track < 0, c->media_stream);
ms = c->media->to_footage()->get_stream_from_file_index(c->track < 0, c->media_stream);
}
// validate ghosts for trimming
@@ -2145,7 +2145,7 @@ int color_brightness(int r, int g, int b) {
return (0.2126*r + 0.7152*g + 0.0722*b);
}
void draw_waveform(Clip* clip, FootageStream* ms, long media_length, QPainter *p, const QRect& clip_rect, int waveform_start, int waveform_limit, double zoom) {
void draw_waveform(Clip* clip, const FootageStream* ms, long media_length, QPainter *p, const QRect& clip_rect, int waveform_start, int waveform_limit, double zoom) {
int divider = ms->audio_channels*2;
int channel_height = clip_rect.height()/ms->audio_channels;
+1 -1
View File
@@ -22,7 +22,7 @@ class QPainter;
class Media;
bool same_sign(int a, int b);
void draw_waveform(Clip* clip, FootageStream* ms, long media_length, QPainter* p, const QRect& clip_rect, int waveform_start, int waveform_limit, double zoom);
void draw_waveform(Clip* clip, const FootageStream *ms, long media_length, QPainter* p, const QRect& clip_rect, int waveform_start, int waveform_limit, double zoom);
class TimelineWidget : public QWidget {
Q_OBJECT
+1 -1
View File
@@ -485,7 +485,7 @@ GLuint ViewerWidget::compose_sequence(QVector<Clip*>& nests, bool render_audio)
Footage* m = c->media->to_footage();
if (!m->invalid && !(c->track >= 0 && !is_audio_device_set())) {
if (m->ready) {
FootageStream* ms = m->get_stream_from_file_index(c->track < 0, c->media_stream);
const FootageStream* ms = m->get_stream_from_file_index(c->track < 0, c->media_stream);
if (ms != NULL && is_clip_active(c, playhead)) {
// if thread is already working, we don't want to touch this,
// but we also don't want to hang the UI thread
+1 -1
View File
@@ -34,7 +34,7 @@ public:
bool waveform;
Clip* waveform_clip;
FootageStream* waveform_ms;
const FootageStream* waveform_ms;
double waveform_zoom;
int waveform_scroll;