diff --git a/dialogs/mediapropertiesdialog.cpp b/dialogs/mediapropertiesdialog.cpp index 6f4fae51e..a94215f0f 100644 --- a/dialogs/mediapropertiesdialog.cpp +++ b/dialogs/mediapropertiesdialog.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include #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;ivideo_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;iaudio_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;icount();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;jvideo_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;jaudio_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); diff --git a/dialogs/mediapropertiesdialog.h b/dialogs/mediapropertiesdialog.h index 13f96c3d1..db173408d 100644 --- a/dialogs/mediapropertiesdialog.h +++ b/dialogs/mediapropertiesdialog.h @@ -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(); }; diff --git a/io/previewgenerator.cpp b/io/previewgenerator.cpp index bb24f3cbd..afb753ef4 100644 --- a/io/previewgenerator.cpp +++ b/io/previewgenerator.cpp @@ -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& stream_list = (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) ? footage->audio_tracks : footage->video_tracks; + for (int j=0;jlength = fmt_ctx->duration; @@ -123,32 +132,32 @@ bool PreviewGenerator::retrieve_preview(const QString& hash) { bool found = true; for (int i=0;ivideo_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;iaudio_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;jaudio_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;ivideo_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;iaudio_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;ivideo_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;iaudio_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;ivideo_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;iaudio_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); } diff --git a/io/previewgenerator.h b/io/previewgenerator.h index 2f1f86c7d..3065bb072 100644 --- a/io/previewgenerator.h +++ b/io/previewgenerator.h @@ -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 diff --git a/panels/project.cpp b/panels/project.cpp index 96640180b..4b31f4676 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -181,13 +181,13 @@ Sequence* create_sequence_from_media(QVector& media_list) { if (m->ready) { if (!got_video_values) { for (int j=0;jvideo_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_list) { } if (!got_audio_values) { for (int j=0;jaudio_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;jvideo_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;jaudio_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(); diff --git a/panels/timeline.cpp b/panels/timeline.cpp index 432fb6996..2f450ae56 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -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;jaudio_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;jvideo_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: diff --git a/panels/viewer.cpp b/panels/viewer.cpp index 01e488079..5563a5943 100644 --- a/panels/viewer.cpp +++ b/panels/viewer.cpp @@ -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 { diff --git a/playback/cacher.cpp b/playback/cacher.cpp index d9a7056ce..ef6687c9e 100644 --- a/playback/cacher.cpp +++ b/playback/cacher.cpp @@ -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, diff --git a/playback/playback.cpp b/playback/playback.cpp index 1448e312a..9dd4a399d 100644 --- a/playback/playback.cpp +++ b/playback/playback.cpp @@ -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(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)"; diff --git a/project/clip.cpp b/project/clip.cpp index 213a53858..a2f4eafb6 100644 --- a/project/clip.cpp +++ b/project/clip.cpp @@ -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; } diff --git a/project/footage.cpp b/project/footage.cpp index b54f5a4a3..ec3a8baa1 100644 --- a/project/footage.cpp +++ b/project/footage.cpp @@ -24,12 +24,6 @@ void Footage::reset() { preview_gen->cancel(); preview_gen->wait(); } - for (int i=0;ifile_index == index) { - return video_tracks.at(i); + if (video_tracks.at(i).file_index == index) { + return &video_tracks[i]; } } } else { for (int i=0;ifile_index == index) { - return audio_tracks.at(i); + if (audio_tracks.at(i).file_index == index) { + return &audio_tracks[i]; } } } diff --git a/project/footage.h b/project/footage.h index 015253173..effbced64 100644 --- a/project/footage.h +++ b/project/footage.h @@ -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 video_tracks; - QVector audio_tracks; + QVector video_tracks; + QVector 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(); }; diff --git a/project/media.cpp b/project/media.cpp index cec9c7f8f..bf72646cb 100644 --- a/project/media.cpp +++ b/project/media.cpp @@ -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;ivideo_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); diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index da2d3b738..2e11b423e 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -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; diff --git a/ui/timelinewidget.h b/ui/timelinewidget.h index bf03b1595..b8339a1b6 100644 --- a/ui/timelinewidget.h +++ b/ui/timelinewidget.h @@ -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 diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index a501fbfec..9a1681dc7 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -485,7 +485,7 @@ GLuint ViewerWidget::compose_sequence(QVector& 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 diff --git a/ui/viewerwidget.h b/ui/viewerwidget.h index fa51aa383..0450efd52 100644 --- a/ui/viewerwidget.h +++ b/ui/viewerwidget.h @@ -34,7 +34,7 @@ public: bool waveform; Clip* waveform_clip; - FootageStream* waveform_ms; + const FootageStream* waveform_ms; double waveform_zoom; int waveform_scroll;