completed deinterlacing

This commit is contained in:
itsmattkc
2018-10-14 09:10:59 +11:00
parent fc28900c9c
commit 21165b6e8e
7 changed files with 199 additions and 78 deletions
+21 -11
View File
@@ -23,10 +23,12 @@ MediaPropertiesDialog::MediaPropertiesDialog(QWidget *parent, QTreeWidgetItem *i
if (m->video_tracks.size() > 0) {
interlacing_box = new QComboBox();
interlacing_box->addItem("Auto (" + get_interlacing_name(media->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(media->video_tracks.at(0)->video_interlacing);
interlacing_box->setCurrentIndex((media->video_tracks.at(0)->video_auto_interlacing == media->video_tracks.at(0)->video_interlacing) ? 0 : media->video_tracks.at(0)->video_interlacing + 1);
grid->addWidget(new QLabel("Interlacing:"), 0, 0);
grid->addWidget(interlacing_box, 0, 1);
@@ -45,19 +47,27 @@ MediaPropertiesDialog::MediaPropertiesDialog(QWidget *parent, QTreeWidgetItem *i
}
void MediaPropertiesDialog::accept() {
ComboAction* ca = new ComboAction();
ca->append(new SetInt(&media->video_tracks.at(0)->video_interlacing, interlacing_box->currentIndex()));
ca->append(new SetString(&media->name, name_box->text()));
ComboAction* ca = new ComboAction();
item->setText(0, name_box->text());
//set interlacing
if (interlacing_box->currentIndex() > 0) {
ca->append(new SetInt(&media->video_tracks.at(0)->video_interlacing, interlacing_box->currentIndex() - 1));
} else {
ca->append(new SetInt(&media->video_tracks.at(0)->video_interlacing, media->video_tracks.at(0)->video_auto_interlacing));
}
MediaRename* mr = new MediaRename();
mr->from = media->name;
mr->item = item;
mr->to = name_box->text();
ca->append(mr);
//set name
MediaRename* mr = new MediaRename();
mr->from = media->name;
mr->item = item;
mr->to = name_box->text();
item->setText(0, name_box->text());
undo_stack.push(ca);
ca->append(mr);
ca->appendPost(new CloseAllClipsCommand());
ca->appendPost(new UpdateFootageTooltip(item, media));
undo_stack.push(ca);
QDialog::accept();
}
+1
View File
@@ -29,6 +29,7 @@ struct MediaStream {
bool infinite_length;
double video_frame_rate;
int video_interlacing;
int video_auto_interlacing;
int audio_channels;
int audio_layout;
int audio_frequency;
+9 -59
View File
@@ -61,6 +61,7 @@ void PreviewGenerator::parse_media() {
}
ms->video_width = fmt_ctx->streams[i]->codecpar->width;
ms->video_height = fmt_ctx->streams[i]->codecpar->height;
ms->video_auto_interlacing = VIDEO_PROGRESSIVE;
ms->video_interlacing = VIDEO_PROGRESSIVE; // default value, we get the true value later in generate_waveform()
if (append) media->video_tracks.append(ms);
} else if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
@@ -173,7 +174,8 @@ void PreviewGenerator::generate_waveform() {
s->video_preview = QImage(data, dstW, dstH, linesize[0], QImage::Format_RGB888);
// is video interlaced?
s->video_interlacing = (temp_frame->interlaced_frame) ? ((temp_frame->top_field_first) ? VIDEO_TOP_FIELD_FIRST : VIDEO_BOTTOM_FIELD_FIRST) : VIDEO_PROGRESSIVE;
s->video_auto_interlacing = (temp_frame->interlaced_frame) ? ((temp_frame->top_field_first) ? VIDEO_TOP_FIELD_FIRST : VIDEO_BOTTOM_FIELD_FIRST) : VIDEO_PROGRESSIVE;
s->video_interlacing = s->video_auto_interlacing;
s->preview_done = true;
@@ -319,66 +321,14 @@ void PreviewGenerator::run() {
}
avformat_close_input(&fmt_ctx);
}
QString tooltip = "Name: " + media->name + "\nFilename: " + media->url + "\n";
if (error) {
tooltip += errorStr;
if (error) {
update_footage_tooltip(item, media, errorStr);
emit set_icon(ICON_TYPE_ERROR, replace);
} else {
// tooltip += "Video Tracks: " + QString::number(media->video_tracks.size()) + "\nAudio Tracks: " + QString::number(media->audio_tracks.size()) + "\n";
if (media->video_tracks.size() > 0) {
tooltip += "Video Dimensions: ";
for (int i=0;i<media->video_tracks.size();i++) {
if (i > 0) {
tooltip += ", ";
}
tooltip += QString::number(media->video_tracks.at(i)->video_width) + "x" + QString::number(media->video_tracks.at(i)->video_height);
}
tooltip += "\n";
tooltip += "Frame Rate: ";
for (int i=0;i<media->video_tracks.size();i++) {
if (i > 0) {
tooltip += ", ";
}
tooltip += QString::number(media->video_tracks.at(i)->video_frame_rate);
if (media->video_tracks.at(i)->video_interlacing != VIDEO_PROGRESSIVE) {
tooltip += " fields (" + QString::number(media->video_tracks.at(i)->video_frame_rate*0.5) + " frames)";
}
}
tooltip += "\n";
tooltip += "Interlacing: ";
for (int i=0;i<media->video_tracks.size();i++) {
if (i > 0) {
tooltip += ", ";
}
tooltip += get_interlacing_name(media->video_tracks.at(i)->video_interlacing);
}
tooltip += "\n";
}
if (media->audio_tracks.size() > 0) {
tooltip += "Audio Frequency: ";
for (int i=0;i<media->audio_tracks.size();i++) {
if (i > 0) {
tooltip += ", ";
}
tooltip += QString::number(media->audio_tracks.at(i)->audio_frequency);
}
tooltip += "\n";
tooltip += "Audio Channels: ";
for (int i=0;i<media->audio_tracks.size();i++) {
if (i > 0) {
tooltip += ", ";
}
tooltip += get_channel_layout_name(media->audio_tracks.at(i)->audio_channels, media->audio_tracks.at(i)->audio_layout);
}
// tooltip += "\n";
}
} else {
update_footage_tooltip(item, media);
}
item->setToolTip(0, tooltip);
delete [] filename;
media->preview_gen = NULL;
}
+62
View File
@@ -1361,3 +1361,65 @@ QString get_interlacing_name(int interlacing) {
default: return "Invalid";
}
}
void update_footage_tooltip(QTreeWidgetItem *item, Media *media, QString error) {
QString tooltip = "Name: " + media->name + "\nFilename: " + media->url + "\n";
if (error.isEmpty()) {
if (media->video_tracks.size() > 0) {
tooltip += "Video Dimensions: ";
for (int i=0;i<media->video_tracks.size();i++) {
if (i > 0) {
tooltip += ", ";
}
tooltip += QString::number(media->video_tracks.at(i)->video_width) + "x" + QString::number(media->video_tracks.at(i)->video_height);
}
tooltip += "\n";
tooltip += "Frame Rate: ";
for (int i=0;i<media->video_tracks.size();i++) {
if (i > 0) {
tooltip += ", ";
}
tooltip += QString::number(media->video_tracks.at(i)->video_frame_rate);
if (media->video_tracks.at(i)->video_interlacing != VIDEO_PROGRESSIVE) {
tooltip += " fields (" + QString::number(media->video_tracks.at(i)->video_frame_rate*0.5) + " frames)";
}
}
tooltip += "\n";
tooltip += "Interlacing: ";
for (int i=0;i<media->video_tracks.size();i++) {
if (i > 0) {
tooltip += ", ";
}
tooltip += get_interlacing_name(media->video_tracks.at(i)->video_interlacing);
}
tooltip += "\n";
}
if (media->audio_tracks.size() > 0) {
tooltip += "Audio Frequency: ";
for (int i=0;i<media->audio_tracks.size();i++) {
if (i > 0) {
tooltip += ", ";
}
tooltip += QString::number(media->audio_tracks.at(i)->audio_frequency);
}
tooltip += "\n";
tooltip += "Audio Channels: ";
for (int i=0;i<media->audio_tracks.size();i++) {
if (i > 0) {
tooltip += ", ";
}
tooltip += get_channel_layout_name(media->audio_tracks.at(i)->audio_channels, media->audio_tracks.at(i)->audio_layout);
}
// tooltip += "\n";
}
} else {
}
item->setToolTip(0, tooltip);
}
+1
View File
@@ -35,6 +35,7 @@ void set_footage_of_tree(QTreeWidgetItem* item, Media* media);
Sequence* get_sequence_from_tree(QTreeWidgetItem* item);
void set_sequence_of_tree(QTreeWidgetItem* item, Sequence* sequence);
void set_item_to_folder(QTreeWidgetItem* item);
void update_footage_tooltip(QTreeWidgetItem* item, Media* media, QString error = 0);
QString get_channel_layout_name(int channels, int layout);
QString get_interlacing_name(int interlacing);
+76 -8
View File
@@ -37,18 +37,28 @@ void ComboAction::undo() {
for (int i=commands.size()-1;i>=0;i--) {
commands.at(i)->undo();
}
for (int i=0;i<post_commands.size();i++) {
post_commands.at(i)->undo();
}
}
void ComboAction::redo() {
for (int i=0;i<commands.size();i++) {
commands.at(i)->redo();
}
for (int i=0;i<post_commands.size();i++) {
post_commands.at(i)->redo();
}
}
void ComboAction::append(QUndoCommand* u) {
commands.append(u);
}
void ComboAction::appendPost(QUndoCommand* u) {
post_commands.append(u);
}
MoveClipAction::MoveClipAction(Clip *c, long iin, long iout, long iclip_in, int itrack) :
clip(c),
old_in(c->timeline_in),
@@ -1366,7 +1376,11 @@ void KeyframeSet::redo() {
done = true;
}
EffectFieldUndo::EffectFieldUndo(EffectField* f) : field(f), done(true) {
EffectFieldUndo::EffectFieldUndo(EffectField* f) :
field(f),
done(true),
old_project_changed(mainWindow->isWindowModified())
{
old_val = field->get_previous_data();
new_val = field->get_current_data();
}
@@ -1374,19 +1388,26 @@ EffectFieldUndo::EffectFieldUndo(EffectField* f) : field(f), done(true) {
void EffectFieldUndo::undo() {
field->set_current_data(old_val);
done = false;
mainWindow->setWindowModified(old_project_changed);
}
void EffectFieldUndo::redo() {
if (!done) {
field->set_current_data(new_val);
}
mainWindow->setWindowModified(true);
}
SetAutoscaleAction::SetAutoscaleAction() :
old_project_changed(mainWindow->isWindowModified())
{}
void SetAutoscaleAction::undo() {
for (int i=0;i<clips.size();i++) {
clips.at(i)->autoscale = !clips.at(i)->autoscale;
}
panel_sequence_viewer->viewer_widget->update();
mainWindow->setWindowModified(old_project_changed);
}
void SetAutoscaleAction::redo() {
@@ -1394,6 +1415,7 @@ void SetAutoscaleAction::redo() {
clips.at(i)->autoscale = !clips.at(i)->autoscale;
}
panel_sequence_viewer->viewer_widget->update();
mainWindow->setWindowModified(true);
}
AddMarkerAction::AddMarkerAction(Sequence* s, long t, QString n) :
@@ -1437,26 +1459,31 @@ void AddMarkerAction::redo() {
MoveMarkerAction::MoveMarkerAction(Marker* m, long o, long n) :
marker(m),
old_time(o),
new_time(n)
new_time(n),
old_project_changed(mainWindow->isWindowModified())
{}
void MoveMarkerAction::undo() {
marker->frame = old_time;
mainWindow->setWindowModified(old_project_changed);
}
void MoveMarkerAction::redo() {
marker->frame = new_time;
mainWindow->setWindowModified(true);
}
DeleteMarkerAction::DeleteMarkerAction(Sequence* s) :
seq(s),
sorted(false)
sorted(false),
old_project_changed(mainWindow->isWindowModified())
{}
void DeleteMarkerAction::undo() {
for (int i=markers.size()-1;i>=0;i--) {
seq->markers.insert(markers.at(i), copies.at(i));
}
mainWindow->setWindowModified(old_project_changed);
}
void DeleteMarkerAction::redo() {
@@ -1473,46 +1500,55 @@ void DeleteMarkerAction::redo() {
seq->markers.removeAt(markers.at(i));
}
sorted = true;
mainWindow->setWindowModified(true);
}
SetSpeedAction::SetSpeedAction(Clip* c, double speed) :
clip(c),
old_speed(c->speed),
new_speed(speed)
new_speed(speed),
old_project_changed(mainWindow->isWindowModified())
{}
void SetSpeedAction::undo() {
clip->speed = old_speed;
clip->recalculateMaxLength();
mainWindow->setWindowModified(old_project_changed);
}
void SetSpeedAction::redo() {
clip->speed = new_speed;
clip->recalculateMaxLength();
mainWindow->setWindowModified(true);
}
SetBool::SetBool(bool* b, bool setting) :
boolean(b),
old_setting(*b),
new_setting(setting)
new_setting(setting),
old_project_changed(mainWindow->isWindowModified())
{}
void SetBool::undo() {
*boolean = old_setting;
mainWindow->setWindowModified(old_project_changed);
}
void SetBool::redo() {
*boolean = new_setting;
mainWindow->setWindowModified(true);
}
SetSelectionsCommand::SetSelectionsCommand(Sequence* s) :
seq(s),
done(true)
done(true),
old_project_changed(mainWindow->isWindowModified())
{}
void SetSelectionsCommand::undo() {
sequence->selections = old_data;
done = false;
mainWindow->setWindowModified(old_project_changed);
}
void SetSelectionsCommand::redo() {
@@ -1520,6 +1556,7 @@ void SetSelectionsCommand::redo() {
sequence->selections = new_data;
done = true;
}
mainWindow->setWindowModified(true);
}
SetEnableCommand::SetEnableCommand(Clip* c, bool enable) :
@@ -1559,6 +1596,8 @@ void EditSequenceCommand::undo() {
seq->audio_frequency = old_audio_frequency;
seq->audio_layout = old_audio_layout;
update();
mainWindow->setWindowModified(old_project_changed);
}
void EditSequenceCommand::redo() {
@@ -1569,6 +1608,8 @@ void EditSequenceCommand::redo() {
seq->audio_frequency = audio_frequency;
seq->audio_layout = audio_layout;
update();
mainWindow->setWindowModified(true);
}
void EditSequenceCommand::update() {
@@ -1595,27 +1636,54 @@ void EditSequenceCommand::update() {
SetInt::SetInt(int* pointer, int new_value) :
p(pointer),
oldval(*pointer),
newval(new_value)
newval(new_value),
old_project_changed(mainWindow->isWindowModified())
{}
void SetInt::undo() {
*p = oldval;
mainWindow->setWindowModified(old_project_changed);
}
void SetInt::redo() {
*p = newval;
mainWindow->setWindowModified(true);
}
SetString::SetString(QString* pointer, QString new_value) :
p(pointer),
oldval(*pointer),
newval(new_value)
newval(new_value),
old_project_changed(mainWindow->isWindowModified())
{}
void SetString::undo() {
*p = oldval;
mainWindow->setWindowModified(old_project_changed);
}
void SetString::redo() {
*p = newval;
mainWindow->setWindowModified(true);
}
void CloseAllClipsCommand::undo() {
redo();
}
void CloseAllClipsCommand::redo() {
closeActiveClips(sequence, true);
}
UpdateFootageTooltip::UpdateFootageTooltip(QTreeWidgetItem *i, Media *m) :
item(i),
media(m)
{}
void UpdateFootageTooltip::undo() {
redo();
}
void UpdateFootageTooltip::redo() {
update_footage_tooltip(item, media);
}
+29
View File
@@ -34,8 +34,10 @@ public:
void undo();
void redo();
void append(QUndoCommand* u);
void appendPost(QUndoCommand* u);
private:
QVector<QUndoCommand*> commands;
QVector<QUndoCommand*> post_commands;
};
class MoveClipAction : public QUndoCommand {
@@ -375,13 +377,17 @@ private:
QVariant old_val;
QVariant new_val;
bool done;
bool old_project_changed;
};
class SetAutoscaleAction : public QUndoCommand {
public:
SetAutoscaleAction();
void undo();
void redo();
QVector<Clip*> clips;
private:
bool old_project_changed;
};
class AddMarkerAction : public QUndoCommand {
@@ -407,6 +413,7 @@ private:
Marker* marker;
long old_time;
long new_time;
bool old_project_changed;
};
class DeleteMarkerAction : public QUndoCommand {
@@ -419,6 +426,7 @@ private:
Sequence* seq;
QVector<Marker> copies;
bool sorted;
bool old_project_changed;
};
class SetSpeedAction : public QUndoCommand {
@@ -430,6 +438,7 @@ private:
Clip* clip;
double old_speed;
double new_speed;
bool old_project_changed;
};
class SetBool : public QUndoCommand {
@@ -441,6 +450,7 @@ private:
bool* boolean;
bool old_setting;
bool new_setting;
bool old_project_changed;
};
class SetSelectionsCommand : public QUndoCommand {
@@ -453,6 +463,7 @@ public:
private:
Sequence* seq;
bool done;
bool old_project_changed;
};
class SetEnableCommand : public QUndoCommand {
@@ -502,6 +513,7 @@ private:
int* p;
int oldval;
int newval;
bool old_project_changed;
};
class SetString : public QUndoCommand {
@@ -513,6 +525,23 @@ private:
QString* p;
QString oldval;
QString newval;
bool old_project_changed;
};
class CloseAllClipsCommand : public QUndoCommand {
public:
void undo();
void redo();
};
class UpdateFootageTooltip : public QUndoCommand {
public:
UpdateFootageTooltip(QTreeWidgetItem* i, Media* m);
void undo();
void redo();
private:
QTreeWidgetItem* item;
Media* media;
};
#endif // UNDO_H