fixed an import crash and updated multiple clip code

This commit is contained in:
itsmattkc
2018-09-10 10:51:45 +10:00
parent 96802e971a
commit 5c7d08f162
6 changed files with 87 additions and 70 deletions
+15 -13
View File
@@ -45,26 +45,28 @@ void PreviewGenerator::parse_media() {
ms->file_index = i;
append = true;
}
if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
if (fmt_ctx->streams[i]->avg_frame_rate.den == 0) { // source is LIKELY a still image
ms->infinite_length = true;
contains_still_image = true;
ms->video_frame_rate = 0;
} else {
ms->infinite_length = false;
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) {
if (fmt_ctx->streams[i]->avg_frame_rate.den == 0) { // source is LIKELY a still image
ms->infinite_length = true;
contains_still_image = true;
ms->video_frame_rate = 0;
} else {
ms->infinite_length = false;
ms->video_frame_rate = av_q2d(fmt_ctx->streams[i]->avg_frame_rate);
}
ms->video_width = fmt_ctx->streams[i]->codecpar->width;
ms->video_height = fmt_ctx->streams[i]->codecpar->height;
if (append) media->video_tracks.append(ms);
ms->video_width = fmt_ctx->streams[i]->codecpar->width;
ms->video_height = fmt_ctx->streams[i]->codecpar->height;
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;
ms->audio_layout = fmt_ctx->streams[i]->codecpar->channel_layout;
ms->audio_frequency = fmt_ctx->streams[i]->codecpar->sample_rate;
if (append) media->audio_tracks.append(ms);
} else {
delete ms;
}
} else if (append) {
delete ms;
}
}
}
media->length = fmt_ctx->duration;
+28 -21
View File
@@ -22,6 +22,7 @@
EffectControls::EffectControls(QWidget *parent) :
QDockWidget(parent),
multiple(false),
zoom(1),
ui(new Ui::EffectControls)
{
@@ -37,6 +38,8 @@ EffectControls::EffectControls(QWidget *parent) :
ui->keyframeView->header = ui->headers;
ui->label_2->setVisible(false);
connect(ui->keyframeScroller->verticalScrollBar(), SIGNAL(valueChanged(int)), ui->scrollArea->verticalScrollBar(), SLOT(setValue(int)));
connect(ui->keyframeScroller->horizontalScrollBar(), SIGNAL(valueChanged(int)), ui->keyframeHeaderScroller->horizontalScrollBar(), SLOT(setValue(int)));
}
@@ -174,29 +177,33 @@ void EffectControls::deselect_all_effects(QWidget* sender) {
}
void EffectControls::load_effects() {
// load in new clips
for (int i=0;i<selected_clips.size();i++) {
Clip* c = sequence->get_clip(selected_clips.at(i));
QVBoxLayout* layout;
if (c->track < 0) {
ui->vcontainer->setVisible(true);
layout = static_cast<QVBoxLayout*>(ui->video_effect_area->layout());
} else {
ui->acontainer->setVisible(true);
layout = static_cast<QVBoxLayout*>(ui->audio_effect_area->layout());
ui->label_2->setVisible(multiple);
if (!multiple) {
// load in new clips
for (int i=0;i<selected_clips.size();i++) {
Clip* c = sequence->get_clip(selected_clips.at(i));
QVBoxLayout* layout;
if (c->track < 0) {
ui->vcontainer->setVisible(true);
layout = static_cast<QVBoxLayout*>(ui->video_effect_area->layout());
} else {
ui->acontainer->setVisible(true);
layout = static_cast<QVBoxLayout*>(ui->audio_effect_area->layout());
}
for (int j=0;j<c->effects.size();j++) {
Effect* e = c->effects.at(j);
CollapsibleWidget* container = e->container;
layout->addWidget(container);
connect(container, SIGNAL(deselect_others(QWidget*)), this, SLOT(deselect_all_effects(QWidget*)));
}
}
for (int j=0;j<c->effects.size();j++) {
Effect* e = c->effects.at(j);
CollapsibleWidget* container = e->container;
layout->addWidget(container);
connect(container, SIGNAL(deselect_others(QWidget*)), this, SLOT(deselect_all_effects(QWidget*)));
if (selected_clips.size() > 0) {
ui->keyframeView->setMinimumHeight(ui->effects_area->height());
ui->keyframeView->setEnabled(true);
ui->headers->setVisible(true);
ui->keyframeView->update();
}
}
if (selected_clips.size() > 0) {
ui->keyframeView->setMinimumHeight(ui->effects_area->height());
ui->keyframeView->setEnabled(true);
ui->headers->setVisible(true);
ui->keyframeView->update();
}
}
+1
View File
@@ -39,6 +39,7 @@ public:
void set_zoom(bool in);
bool keyframe_focus();
void delete_selected_keyframes();
bool multiple;
QVector<int> selected_clips;
+10
View File
@@ -399,6 +399,16 @@
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>(Multiple clips selected)</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
+31 -34
View File
@@ -810,48 +810,45 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
// find out how many clips are selected
// limits to one video clip and one audio clip and only if they're linked
// one of these days it might be nice to have multiple clips in the effects panel
bool got_vclip = false;
bool got_aclip = false;
panel_effect_controls->multiple = false;
int vclip = -1;
int aclip = -1;
for (int i=0;i<sequence->clip_count();i++) {
Clip* clip = sequence->get_clip(i);
if (clip != NULL && panel_timeline->is_clip_selected(clip, true)) {
if (clip->track < 0) {
if (got_vclip) {
vclip = -1;
} else {
vclip = i;
got_vclip = true;
}
} else {
if (got_aclip) {
aclip = -1;
} else {
aclip = i;
got_aclip = true;
}
}
if (clip != NULL && panel_timeline->is_clip_selected(clip, true)) {
if (clip->track < 0 && vclip == -1) {
vclip = i;
} else if (clip->track >= 0 && aclip == -1) {
aclip = i;
} else {
vclip = -2;
aclip = -2;
panel_effect_controls->multiple = true;
break;
}
}
}
// check if aclip is linked to vclip
QVector<int> selected_clips;
if (vclip != -1) selected_clips.append(vclip);
if (aclip != -1) selected_clips.append(aclip);
if (vclip != -1 && aclip != -1) {
bool found = false;
Clip* vclip_ref = sequence->get_clip(vclip);
for (int i=0;i<vclip_ref->linked.size();i++) {
if (vclip_ref->linked.at(i) == aclip) {
found = true;
break;
}
}
if (!found) {
// only display multiple clips if they're linked
selected_clips.clear();
}
}
if (!panel_effect_controls->multiple) {
if (vclip >= 0) selected_clips.append(vclip);
if (aclip >= 0) selected_clips.append(aclip);
if (vclip >= 0 && aclip >= 0) {
bool found = false;
Clip* vclip_ref = sequence->get_clip(vclip);
for (int i=0;i<vclip_ref->linked.size();i++) {
if (vclip_ref->linked.at(i) == aclip) {
found = true;
break;
}
}
if (!found) {
// only display multiple clips if they're linked
selected_clips.clear();
panel_effect_controls->multiple = true;
}
}
}
panel_effect_controls->set_clips(selected_clips);
}
}
+2 -2
View File
@@ -34,8 +34,8 @@ ViewerWidget::ViewerWidget(QWidget *parent) :
format.setDepthBufferSize(24);
setFormat(format);
// error handler - retries after 250ms if we couldn't get the entire image
retry_timer.setInterval(250);
// error handler - retries after 500ms if we couldn't get the entire image
retry_timer.setInterval(500);
connect(&retry_timer, SIGNAL(timeout()), this, SLOT(retry()));
}