merged with master

This commit is contained in:
itsmattkc
2019-01-09 10:39:23 +11:00
18 changed files with 210 additions and 127 deletions
+24
View File
@@ -0,0 +1,24 @@
#include "fillleftrighteffect.h"
#define FILL_TYPE_LEFT 0
#define FILL_TYPE_RIGHT 1
FillLeftRightEffect::FillLeftRightEffect(Clip* c, const EffectMeta *em) : Effect(c, em) {
EffectRow* type_row = add_row("Type");
fill_type = type_row->add_field(EFFECT_FIELD_COMBO, "type");
fill_type->add_combo_item("Fill Left with Right", FILL_TYPE_LEFT);
fill_type->add_combo_item("Fill Right with Left", FILL_TYPE_RIGHT);
}
void FillLeftRightEffect::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int) {
double interval = (timecode_end-timecode_start)/nb_bytes;
for (int i=0;i<nb_bytes;i+=4) {
if (fill_type->get_combo_data(timecode_start+(interval*i)) == FILL_TYPE_LEFT) {
samples[i+1] = samples[i+3];
samples[i] = samples[i+2];
} else {
samples[i+3] = samples[i+1];
samples[i+2] = samples[i];
}
}
}
+14
View File
@@ -0,0 +1,14 @@
#ifndef FILLLEFTRIGHTEFFECT_H
#define FILLLEFTRIGHTEFFECT_H
#include "project/effect.h"
class FillLeftRightEffect : public Effect {
public:
FillLeftRightEffect(Clip* c, const EffectMeta* em);
void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count);
private:
EffectField* fill_type;
};
#endif // FILLLEFTRIGHTEFFECT_H
+22 -9
View File
@@ -19,17 +19,30 @@ VolumeEffect::VolumeEffect(Clip* c, const EffectMeta *em) : Effect(c, em) {
void VolumeEffect::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int) {
double interval = (timecode_end-timecode_start)/nb_bytes;
for (int i=0;i<nb_bytes;i+=2) {
for (int i=0;i<nb_bytes;i+=4) {
double vol_val = log_volume(volume_val->get_double_value(timecode_start+(interval*i), true)*0.01);
qint32 samp = (qint16) (((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF));
samp *= vol_val;
if (samp > INT16_MAX) {
samp = INT16_MAX;
} else if (samp < INT16_MIN) {
samp = INT16_MIN;
qint32 right_samp = (qint16) (((samples[i+3] & 0xFF) << 8) | (samples[i+2] & 0xFF));
qint32 left_samp = (qint16) (((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF));
left_samp *= vol_val;
right_samp *= vol_val;
if (left_samp > INT16_MAX) {
left_samp = INT16_MAX;
} else if (left_samp < INT16_MIN) {
left_samp = INT16_MIN;
}
samples[i+1] = (quint8) (samp >> 8);
samples[i] = (quint8) samp;
if (right_samp > INT16_MAX) {
right_samp = INT16_MAX;
} else if (right_samp < INT16_MIN) {
right_samp = INT16_MIN;
}
samples[i+3] = (quint8) (right_samp >> 8);
samples[i+2] = (quint8) right_samp;
samples[i+1] = (quint8) (left_samp >> 8);
samples[i] = (quint8) left_samp;
}
}
+13 -5
View File
@@ -74,6 +74,14 @@ void VSTHostWin::loadPlugin() {
plugin = mainEntryPoint(hostCallback);
}
void VSTHostWin::freePlugin() {
if (plugin != NULL) {
stopPlugin();
FreeLibrary(modulePtr);
plugin = NULL;
}
}
bool VSTHostWin::configurePluginCallbacks() {
// Check plugin's magic number
// If incorrect, then the file either was not loaded properly, is not a
@@ -166,6 +174,10 @@ VSTHostWin::VSTHostWin(Clip* c, const EffectMeta *em) : Effect(c, em) {
connect(dialog, SIGNAL(finished(int)), this, SLOT(uncheck_show_button()));
}
VSTHostWin::~VSTHostWin() {
freePlugin();
}
void VSTHostWin::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int) {
if (plugin != NULL) {
int interval = BLOCK_SIZE*4;
@@ -220,11 +232,7 @@ void VSTHostWin::uncheck_show_button() {
}
void VSTHostWin::change_plugin() {
if (plugin != NULL) {
stopPlugin();
FreeLibrary(modulePtr);
plugin = NULL;
}
freePlugin();
loadPlugin();
if (plugin != NULL) {
if (configurePluginCallbacks()) {
+2
View File
@@ -15,6 +15,7 @@ class VSTHostWin : public Effect {
Q_OBJECT
public:
VSTHostWin(Clip* c, const EffectMeta* em);
~VSTHostWin();
void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count);
private slots:
void show_interface(bool show);
@@ -24,6 +25,7 @@ private:
EffectField* file_field;
void loadPlugin();
void freePlugin();
dispatcherFuncPtr dispatcher;
AEffect* plugin;
bool configurePluginCallbacks();
+4 -2
View File
@@ -119,7 +119,8 @@ SOURCES += \
ui/rectangleselect.cpp \
dialogs/actionsearch.cpp \
effects/internal/vsthostwin.cpp \
ui/embeddedfilechooser.cpp
ui/embeddedfilechooser.cpp \
effects/internal/fillleftrighteffect.cpp
HEADERS += \
mainwindow.h \
@@ -208,7 +209,8 @@ HEADERS += \
ui/rectangleselect.h \
dialogs/actionsearch.h \
effects/internal/vsthostwin.h \
ui/embeddedfilechooser.h
ui/embeddedfilechooser.h \
effects/internal/fillleftrighteffect.h
FORMS +=
@@ -17,7 +17,7 @@
<url type="donation">https://www.patreon.com/olivevideoeditor</url>
<url type="bugtracker">https://github.com/olive-editor/olive/issues</url>
<screenshots>
<screenshot type="default"><image>https://olivevideoeditor.org/img/screenshot.jpg</image></screenshot>
<screenshot type="default"><image>https://olivevideoeditor.org/img/screenshot.1600.jpg</image></screenshot>
</screenshots>
<content_rating type="oars-1.1" />
<releases>
+4
View File
@@ -145,6 +145,10 @@ void EffectControls::copy(bool del) {
}
}
void EffectControls::scroll_to_frame(long frame) {
scroll_to_frame_internal(horizontalScrollBar, frame, zoom, keyframeView->width());
}
void EffectControls::show_effect_menu(int type, int subtype) {
effect_menu_type = type;
effect_menu_subtype = subtype;
+1
View File
@@ -42,6 +42,7 @@ public:
void delete_selected_keyframes();
void copy(bool del);
bool multiple;
void scroll_to_frame(long frame);
QVector<int> selected_clips;
+94 -81
View File
@@ -11,6 +11,8 @@
#include "grapheditor.h"
#include "debug.h"
#include <QScrollBar>
Project* panel_project = 0;
EffectControls* panel_effect_controls = 0;
Viewer* panel_sequence_viewer = 0;
@@ -27,43 +29,43 @@ void update_effect_controls() {
int vclip = -1;
int aclip = -1;
QVector<int> selected_clips;
int mode = TA_NO_TRANSITION;
int mode = TA_NO_TRANSITION;
if (sequence != NULL) {
for (int i=0;i<sequence->clips.size();i++) {
Clip* clip = sequence->clips.at(i);
if (clip != NULL) {
for (int j=0;j<sequence->selections.size();j++) {
const Selection& s = sequence->selections.at(j);
bool add = true;
if (clip->timeline_in >= s.in && clip->timeline_out <= s.out && clip->track == s.track) {
mode = TA_NO_TRANSITION;
} else if (selection_contains_transition(s, clip, TA_OPENING_TRANSITION)) {
mode = TA_OPENING_TRANSITION;
} else if (selection_contains_transition(s, clip, TA_CLOSING_TRANSITION)) {
mode = TA_CLOSING_TRANSITION;
} else {
add = false;
}
if (clip != NULL) {
for (int j=0;j<sequence->selections.size();j++) {
const Selection& s = sequence->selections.at(j);
bool add = true;
if (clip->timeline_in >= s.in && clip->timeline_out <= s.out && clip->track == s.track) {
mode = TA_NO_TRANSITION;
} else if (selection_contains_transition(s, clip, TA_OPENING_TRANSITION)) {
mode = TA_OPENING_TRANSITION;
} else if (selection_contains_transition(s, clip, TA_CLOSING_TRANSITION)) {
mode = TA_CLOSING_TRANSITION;
} else {
add = false;
}
if (add) {
if (clip->track < 0 && vclip == -1) {
vclip = i;
} else if (clip->track >= 0 && aclip == -1) {
aclip = i;
} else {
vclip = -2;
aclip = -2;
if (add) {
if (clip->track < 0 && vclip == -1) {
vclip = i;
} else if (clip->track >= 0 && aclip == -1) {
aclip = i;
} else {
vclip = -2;
aclip = -2;
multiple = true;
multiple = true;
break;
}
}
}
break;
}
}
}
}
}
if (!multiple) {
// check if aclip is linked to vclip
// check if aclip is linked to vclip
if (vclip >= 0) selected_clips.append(vclip);
if (aclip >= 0) selected_clips.append(aclip);
if (vclip >= 0 && aclip >= 0) {
@@ -84,7 +86,7 @@ void update_effect_controls() {
}
}
bool same = (selected_clips.size() == panel_effect_controls->selected_clips.size());
bool same = (selected_clips.size() == panel_effect_controls->selected_clips.size());
if (same) {
for (int i=0;i<selected_clips.size();i++) {
if (selected_clips.at(i) != panel_effect_controls->selected_clips.at(i)) {
@@ -101,9 +103,9 @@ void update_effect_controls() {
}
void update_ui(bool modified) {
if (modified) {
update_effect_controls();
}
if (modified) {
update_effect_controls();
}
panel_effect_controls->update_keyframes();
panel_timeline->repaint_timeline();
panel_sequence_viewer->update_viewer();
@@ -111,61 +113,72 @@ void update_ui(bool modified) {
}
QDockWidget *get_focused_panel() {
QDockWidget* w = NULL;
if (config.hover_focus) {
if (panel_project->underMouse()) {
w = panel_project;
} else if (panel_effect_controls->underMouse()) {
w = panel_effect_controls;
} else if (panel_sequence_viewer->underMouse()) {
w = panel_sequence_viewer;
} else if (panel_footage_viewer->underMouse()) {
w = panel_footage_viewer;
} else if (panel_timeline->underMouse()) {
w = panel_timeline;
}
}
if (w == NULL) {
if (panel_project->is_focused()) {
w = panel_project;
QDockWidget* w = NULL;
if (config.hover_focus) {
if (panel_project->underMouse()) {
w = panel_project;
} else if (panel_effect_controls->underMouse()) {
w = panel_effect_controls;
} else if (panel_sequence_viewer->underMouse()) {
w = panel_sequence_viewer;
} else if (panel_footage_viewer->underMouse()) {
w = panel_footage_viewer;
} else if (panel_timeline->underMouse()) {
w = panel_timeline;
}
}
if (w == NULL) {
if (panel_project->is_focused()) {
w = panel_project;
} else if (panel_effect_controls->keyframe_focus() || panel_effect_controls->is_focused()) {
w = panel_effect_controls;
} else if (panel_sequence_viewer->is_focused()) {
w = panel_sequence_viewer;
} else if (panel_footage_viewer->is_focused()) {
w = panel_footage_viewer;
} else if (panel_timeline->focused()) {
w = panel_timeline;
}
}
return w;
w = panel_effect_controls;
} else if (panel_sequence_viewer->is_focused()) {
w = panel_sequence_viewer;
} else if (panel_footage_viewer->is_focused()) {
w = panel_footage_viewer;
} else if (panel_timeline->focused()) {
w = panel_timeline;
}
}
return w;
}
void alloc_panels(QWidget* parent) {
// TODO maybe replace these with non-pointers later on?
panel_sequence_viewer = new Viewer(parent);
panel_sequence_viewer->setObjectName("seq_viewer");
panel_footage_viewer = new Viewer(parent);
panel_footage_viewer->setObjectName("footage_viewer");
panel_project = new Project(parent);
panel_project->setObjectName("proj_root");
panel_effect_controls = new EffectControls(parent);
panel_effect_controls->setObjectName("fx_controls");
panel_timeline = new Timeline(parent);
panel_timeline->setObjectName("timeline");
panel_graph_editor = new GraphEditor(parent);
panel_graph_editor->setObjectName("graph_editor");
// TODO maybe replace these with non-pointers later on?
panel_sequence_viewer = new Viewer(parent);
panel_sequence_viewer->setObjectName("seq_viewer");
panel_footage_viewer = new Viewer(parent);
panel_footage_viewer->setObjectName("footage_viewer");
panel_project = new Project(parent);
panel_project->setObjectName("proj_root");
panel_effect_controls = new EffectControls(parent);
panel_effect_controls->setObjectName("fx_controls");
panel_timeline = new Timeline(parent);
panel_timeline->setObjectName("timeline");
panel_graph_editor = new GraphEditor(parent);
panel_graph_editor->setObjectName("graph_editor");
}
void free_panels() {
delete panel_sequence_viewer;
panel_sequence_viewer = NULL;
delete panel_footage_viewer;
panel_footage_viewer = NULL;
delete panel_project;
panel_project = NULL;
delete panel_effect_controls;
panel_effect_controls = NULL;
delete panel_timeline;
panel_timeline = NULL;
delete panel_sequence_viewer;
panel_sequence_viewer = NULL;
delete panel_footage_viewer;
panel_footage_viewer = NULL;
delete panel_project;
panel_project = NULL;
delete panel_effect_controls;
panel_effect_controls = NULL;
delete panel_timeline;
panel_timeline = NULL;
}
void scroll_to_frame_internal(QScrollBar* bar, long frame, double zoom, int area_width) {
int screen_point = getScreenPointFromFrame(zoom, frame) - bar->value();
int min_x = area_width*0.1;
int max_x = area_width-min_x;
if (screen_point < min_x) {
bar->setValue(getScreenPointFromFrame(zoom, frame) - min_x);
} else if (screen_point > max_x) {
bar->setValue(getScreenPointFromFrame(zoom, frame) - max_x);
}
}
+2
View File
@@ -9,6 +9,7 @@ class GraphEditor;
class QWidget;
class QDockWidget;
class QScrollBar;
extern Project* panel_project;
extern EffectControls* panel_effect_controls;
@@ -21,5 +22,6 @@ void update_ui(bool modified);
QDockWidget* get_focused_panel();
void alloc_panels(QWidget *parent);
void free_panels();
void scroll_to_frame_internal(QScrollBar* bar, long frame, double zoom, int area_width);
#endif // PANELS_H
+7 -4
View File
@@ -475,6 +475,10 @@ void Timeline::select_all() {
}
}
void Timeline::scroll_to_frame(long frame) {
scroll_to_frame_internal(horizontalScrollBar, frame, zoom, timeline_area->width());
}
void Timeline::resizeEvent(QResizeEvent *event) {
if (sequence != NULL) set_sb_max();
}
@@ -1391,14 +1395,13 @@ void Timeline::toggle_links() {
for (int i=0;i<sequence->clips.size();i++) {
Clip* c = sequence->clips.at(i);
if (c != NULL && is_clip_selected(c, true)) {
command->clips.append(i);
if (!command->clips.contains(i)) command->clips.append(i);
if (c->linked.size() > 0) {
command->link = false; // prioritize unlinking
for (int j=0;j<c->linked.size();j++) { // add links to the command
if (!command->clips.contains(c->linked.at(j))) {
command->clips.append(c->linked.at(j));
}
if (!command->clips.contains(c->linked.at(j))) command->clips.append(c->linked.at(j));
}
}
}
+2
View File
@@ -203,6 +203,8 @@ public:
QPushButton* toolTransitionButton;
QPushButton* snappingButton;
void scroll_to_frame(long frame);
void resizeEvent(QResizeEvent *event);
public slots:
void repaint_timeline();
+5
View File
@@ -3,6 +3,7 @@
#include "playback/audio.h"
#include "timeline.h"
#include "panels/project.h"
#include "panels/effectcontrols.h"
#include "project/sequence.h"
#include "project/clip.h"
#include "panels/panels.h"
@@ -237,6 +238,10 @@ bool frame_rate_is_droppable(float rate) {
void Viewer::seek(long p) {
pause();
seq->playhead = p;
if (main_sequence) {
panel_timeline->scroll_to_frame(p);
panel_effect_controls->scroll_to_frame(p);
}
update_parents();
reset_all_audio();
audio_scrub = true;
+8 -22
View File
@@ -29,6 +29,7 @@
#include "effects/internal/shakeeffect.h"
#include "effects/internal/cornerpineffect.h"
#include "effects/internal/vsthostwin.h"
#include "effects/internal/fillleftrighteffect.h"
#include <QCheckBox>
#include <QGridLayout>
@@ -61,6 +62,7 @@ Effect* create_effect(Clip* c, const EffectMeta* em) {
case EFFECT_INTERNAL_TONE: return new ToneEffect(c, em);
case EFFECT_INTERNAL_SHAKE: return new ShakeEffect(c, em);
case EFFECT_INTERNAL_CORNERPIN: return new CornerPinEffect(c, em);
case EFFECT_INTERNAL_FILLLEFTRIGHT: return new FillLeftRightEffect(c, em);
case EFFECT_INTERNAL_VST: return new VSTHostWin(c, em);
}
} else {
@@ -106,6 +108,10 @@ void load_internal_effects() {
em.internal = EFFECT_INTERNAL_NOISE;
effects.append(em);
em.name = "Fill Left/Right";
em.internal = EFFECT_INTERNAL_FILLLEFTRIGHT;
effects.append(em);
em.subtype = EFFECT_TYPE_VIDEO;
em.name = "Transform";
@@ -463,7 +469,7 @@ Effect::~Effect() {
close();
}
delete container;
//delete container;
for (int i=0;i<rows.size();i++) {
delete rows.at(i);
@@ -922,27 +928,7 @@ GLuint Effect::process_superimpose(double timecode) {
return 0;
}
//void Effect::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count) {
void Effect::process_audio(double, double, quint8*, int, int) {
// only volume/pan, hand off to AU and VST for all other cases
/*double interval = (timecode_end-timecode_start)/nb_bytes;
for (int i=0;i<nb_bytes;i+=2) {
qint32 samp = (qint16) (((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF));
jsEngine.globalObject().setProperty("sample", samp);
jsEngine.globalObject().setProperty("volume", row(0)->field(0)->get_double_value(timecode_start+(interval*i), true));
QJSValue result = eval.call();
samp = result.toInt();
QJSValueList args;
args << samples << nb_bytes;
samples[i+1] = (quint8) (samp >> 8);
samples[i] = (quint8) samp;
}*/
}
void Effect::process_audio(double, double, quint8*, int, int) {}
void Effect::gizmo_draw(double, GLTextureCoords &) {}
+2 -2
View File
@@ -63,8 +63,8 @@ extern QMutex effects_loaded;
#define EFFECT_INTERNAL_SHAKE 7
#define EFFECT_INTERNAL_TIMECODE 8
#define EFFECT_INTERNAL_MASK 9
#define EFFECT_INTERNAL_VST 10
#define EFFECT_INTERNAL_FILLLEFTRIGHT 10
#define EFFECT_INTERNAL_VST 11
#define EFFECT_INTERNAL_CORNERPIN 12
#define EFFECT_INTERNAL_COUNT 13
+2
View File
@@ -489,6 +489,7 @@ AddClipCommand::~AddClipCommand() {
}
void AddClipCommand::undo() {
panel_effect_controls->clear_effects(true);
for (int i=0;i<clips.size();i++) {
Clip* c = seq->clips.last();
panel_timeline->deselect_area(c->timeline_in, c->timeline_out, c->track);
@@ -539,6 +540,7 @@ void LinkCommand::undo() {
void LinkCommand::redo() {
old_links.clear();
for (int i=0;i<clips.size();i++) {
dout << clips.at(i);
Clip* c = s->clips.at(clips.at(i));
if (link) {
for (int j=0;j<clips.size();j++) {
+3 -1
View File
@@ -199,7 +199,9 @@ void KeyframeView::set_y_scroll(int s) {
}
void KeyframeView::resize_move(double d) {
header->update_zoom(header->get_zoom()*d);
panel_effect_controls->zoom *= d;
header->update_zoom(panel_effect_controls->zoom);
update();
}
void KeyframeView::mousePressEvent(QMouseEvent *event) {