added fill left/right effect

This commit is contained in:
itsmattkc
2019-01-09 10:05:43 +11:00
parent 607d36115a
commit 6b1bb620c1
6 changed files with 72 additions and 13 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;
}
}
+4 -2
View File
@@ -117,7 +117,8 @@ SOURCES += \
ui/clickablelabel.cpp \
project/keyframe.cpp \
ui/rectangleselect.cpp \
dialogs/actionsearch.cpp
dialogs/actionsearch.cpp \
effects/internal/fillleftrighteffect.cpp
HEADERS += \
mainwindow.h \
@@ -204,7 +205,8 @@ HEADERS += \
ui/clickablelabel.h \
project/keyframe.h \
ui/rectangleselect.h \
dialogs/actionsearch.h
dialogs/actionsearch.h \
effects/internal/fillleftrighteffect.h
FORMS +=
+7 -1
View File
@@ -28,6 +28,7 @@
#include "effects/internal/paneffect.h"
#include "effects/internal/shakeeffect.h"
#include "effects/internal/cornerpineffect.h"
#include "effects/internal/fillleftrighteffect.h"
#include <QCheckBox>
#include <QGridLayout>
@@ -60,6 +61,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);
}
} else {
dout << "[ERROR] Invalid effect data";
@@ -100,6 +102,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";
@@ -447,7 +453,7 @@ Effect::~Effect() {
close();
}
delete container;
//delete container;
for (int i=0;i<rows.size();i++) {
delete rows.at(i);
+1 -1
View File
@@ -63,7 +63,7 @@ extern QMutex effects_loaded;
#define EFFECT_INTERNAL_SHAKE 7
#define EFFECT_INTERNAL_TIMECODE 8
#define EFFECT_INTERNAL_MASK 9
#define EFFECT_INTERNAL_FILLLEFTRIGHT 10
#define EFFECT_INTERNAL_CORNERPIN 12
#define EFFECT_INTERNAL_COUNT 13