nicer effects panel, improved split selection
This commit is contained in:
@@ -10,23 +10,6 @@ void CrossDissolveTransition::process_transition(double progress) {
|
||||
glColor4f(1.0, 1.0, 1.0, color[3]*progress);
|
||||
}
|
||||
|
||||
void CrossDissolveTransition::process_audio(double range_start, double range_end, quint8* samples, int nb_samples, bool reverse) {
|
||||
double interval = (range_end - range_start) / nb_samples;
|
||||
|
||||
for (int i=0;i<nb_samples;i+=2) {
|
||||
qint16 samp = (qint16) (((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF));
|
||||
|
||||
if (reverse) {
|
||||
samp *= 1 - (range_start + (interval * i));
|
||||
} else {
|
||||
samp *= range_start + (interval * i);
|
||||
}
|
||||
|
||||
samples[i+1] = (quint8) (samp >> 8);
|
||||
samples[i] = (quint8) samp;
|
||||
}
|
||||
}
|
||||
|
||||
Transition* CrossDissolveTransition::copy() {
|
||||
Transition* t = new CrossDissolveTransition();
|
||||
t->length = length;
|
||||
|
||||
@@ -16,6 +16,7 @@ void init_effects() {
|
||||
video_effect_names[VIDEO_SHAKE_EFFECT] = "Shake";
|
||||
video_effect_names[VIDEO_TEXT_EFFECT] = "Text";
|
||||
video_effect_names[VIDEO_SOLID_EFFECT] = "Solid";
|
||||
video_effect_names[VIDEO_INVERT_EFFECT] = "Invert";
|
||||
|
||||
audio_effect_names[AUDIO_VOLUME_EFFECT] = "Volume";
|
||||
audio_effect_names[AUDIO_PAN_EFFECT] = "Pan";
|
||||
@@ -28,6 +29,7 @@ Effect* create_effect(int effect_id, Clip* c) {
|
||||
case VIDEO_SHAKE_EFFECT: return new ShakeEffect(c); break;
|
||||
case VIDEO_TEXT_EFFECT: return new TextEffect(c); break;
|
||||
case VIDEO_SOLID_EFFECT: return new SolidEffect(c); break;
|
||||
case VIDEO_INVERT_EFFECT: return new InvertEffect(c); break;
|
||||
}
|
||||
} else {
|
||||
switch (effect_id) {
|
||||
|
||||
@@ -21,6 +21,7 @@ enum VideoEffects {
|
||||
VIDEO_SHAKE_EFFECT,
|
||||
VIDEO_TEXT_EFFECT,
|
||||
VIDEO_SOLID_EFFECT,
|
||||
VIDEO_INVERT_EFFECT,
|
||||
VIDEO_EFFECT_COUNT
|
||||
};
|
||||
|
||||
@@ -130,6 +131,19 @@ private:
|
||||
QOpenGLTexture* texture;
|
||||
};
|
||||
|
||||
class InvertEffect : public Effect {
|
||||
Q_OBJECT
|
||||
public:
|
||||
InvertEffect(Clip* c);
|
||||
void init();
|
||||
void process_gl(int *anchor_x, int *anchor_y);
|
||||
Effect* copy(Clip *c);
|
||||
void load(QXmlStreamReader* stream);
|
||||
void save(QXmlStreamWriter* stream);
|
||||
|
||||
LabelSlider* amount_val;
|
||||
};
|
||||
|
||||
// audio effects
|
||||
class VolumeEffect : public Effect {
|
||||
public:
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#include "effects/effects.h"
|
||||
|
||||
#include "ui/labelslider.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QGridLayout>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QXmlStreamAttributes>
|
||||
|
||||
InvertEffect::InvertEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_INVERT_EFFECT) {
|
||||
ui_layout->addWidget(new QLabel("Amount:"), 0, 0);
|
||||
amount_val = new LabelSlider();
|
||||
ui_layout->addWidget(amount_val, 0, 1);
|
||||
|
||||
// set defaults
|
||||
amount_val->set_minimum_value(0);
|
||||
amount_val->set_maximum_value(100);
|
||||
init();
|
||||
|
||||
connect(amount_val, SIGNAL(valueChanged()), this, SLOT(field_changed()));
|
||||
}
|
||||
|
||||
void InvertEffect::init() {
|
||||
amount_val->set_default_value(100);
|
||||
}
|
||||
|
||||
Effect* InvertEffect::copy(Clip* c) {
|
||||
InvertEffect* i = new InvertEffect(c);
|
||||
i->amount_val->set_value(amount_val->value());
|
||||
return i;
|
||||
}
|
||||
|
||||
void InvertEffect::load(QXmlStreamReader *stream) {
|
||||
const QXmlStreamAttributes& attr = stream->attributes();
|
||||
for (int i=0;i<attr.size();i++) {
|
||||
const QXmlStreamAttribute& a = attr.at(i);
|
||||
if (a.name() == "amount") {
|
||||
amount_val->set_value(a.value().toDouble());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InvertEffect::save(QXmlStreamWriter *stream) {
|
||||
stream->writeAttribute("amount", QString::number(amount_val->value()));
|
||||
}
|
||||
|
||||
void InvertEffect::process_gl(int* anchor_x, int* anchor_y) {
|
||||
|
||||
// gl_FragColor = vec4(1.0 - textureColor.r, 1.0 -textureColor.g, 1.0 -textureColor.b, 1);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "transition.h"
|
||||
|
||||
LinearFadeTransition::LinearFadeTransition() : Transition(AUDIO_LINEAR_FADE_TRANSITION) {}
|
||||
|
||||
void LinearFadeTransition::process_audio(double range_start, double range_end, quint8* samples, int nb_samples, bool reverse) {
|
||||
double interval = (range_end - range_start) / nb_samples;
|
||||
|
||||
for (int i=0;i<nb_samples;i+=2) {
|
||||
qint16 samp = (qint16) (((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF));
|
||||
|
||||
if (reverse) {
|
||||
samp *= 1 - (range_start + (interval * i));
|
||||
} else {
|
||||
samp *= range_start + (interval * i);
|
||||
}
|
||||
|
||||
samples[i+1] = (quint8) (samp >> 8);
|
||||
samples[i] = (quint8) samp;
|
||||
}
|
||||
}
|
||||
|
||||
Transition* LinearFadeTransition::copy() {
|
||||
Transition* t = new LinearFadeTransition();
|
||||
t->length = length;
|
||||
return t;
|
||||
}
|
||||
+15
-9
@@ -15,11 +15,6 @@ enum AudioTransitions {
|
||||
AUDIO_TRANSITION_COUNT
|
||||
};
|
||||
|
||||
void init_transitions();
|
||||
|
||||
extern QVector<QString> video_transition_names;
|
||||
extern QVector<QString> audio_transition_names;
|
||||
|
||||
class Transition
|
||||
{
|
||||
public:
|
||||
@@ -28,20 +23,31 @@ public:
|
||||
int id;
|
||||
QString name;
|
||||
int length;
|
||||
Transition* link;
|
||||
Transition* link;
|
||||
virtual void process_transition(double);
|
||||
virtual void process_audio(double, double, quint8*, int, bool);
|
||||
virtual Transition* copy();
|
||||
virtual Transition* copy();
|
||||
};
|
||||
|
||||
void init_transitions();
|
||||
Transition* create_transition(int transition_id, Clip* c);
|
||||
extern QVector<QString> video_transition_names;
|
||||
extern QVector<QString> audio_transition_names;
|
||||
|
||||
// Video Transitions
|
||||
class CrossDissolveTransition : public Transition {
|
||||
public:
|
||||
CrossDissolveTransition();
|
||||
void process_transition(double);
|
||||
void process_audio(double, double, quint8*, int, bool);
|
||||
Transition* copy();
|
||||
};
|
||||
|
||||
Transition* create_transition(int transition_id, Clip* c);
|
||||
// Audio Transitions
|
||||
class LinearFadeTransition : public Transition {
|
||||
public:
|
||||
LinearFadeTransition();
|
||||
void process_audio(double, double, quint8*, int, bool);
|
||||
Transition* copy();
|
||||
};
|
||||
|
||||
#endif // TRANSITION_H
|
||||
|
||||
Reference in New Issue
Block a user