diff --git a/effects/internal/fillleftrighteffect.cpp b/effects/internal/fillleftrighteffect.cpp new file mode 100644 index 000000000..d21765e60 --- /dev/null +++ b/effects/internal/fillleftrighteffect.cpp @@ -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;iget_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]; + } + } +} diff --git a/effects/internal/fillleftrighteffect.h b/effects/internal/fillleftrighteffect.h new file mode 100644 index 000000000..3b3390d2e --- /dev/null +++ b/effects/internal/fillleftrighteffect.h @@ -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 diff --git a/effects/internal/volumeeffect.cpp b/effects/internal/volumeeffect.cpp index b7b18017b..48a329c16 100644 --- a/effects/internal/volumeeffect.cpp +++ b/effects/internal/volumeeffect.cpp @@ -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;iget_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; } } diff --git a/olive.pro b/olive.pro index 28e268fbe..40185c471 100644 --- a/olive.pro +++ b/olive.pro @@ -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 += diff --git a/project/effect.cpp b/project/effect.cpp index 74f901388..6315ade00 100644 --- a/project/effect.cpp +++ b/project/effect.cpp @@ -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 #include @@ -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