restored swscale and updated opengl fx spec

This commit is contained in:
itsmattkc
2018-08-20 12:36:53 +10:00
parent 951be4d223
commit b06ab214ea
26 changed files with 395 additions and 309 deletions
+5 -9
View File
@@ -8,7 +8,7 @@
#include <QXmlStreamWriter>
#include <QXmlStreamAttributes>
InvertEffect::InvertEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_INVERT_EFFECT), vert_shader(QOpenGLShader::Vertex), frag_shader(QOpenGLShader::Fragment) {
InvertEffect::InvertEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_INVERT_EFFECT) {
enable_opengl = true;
EffectRow* amount_row = add_row("Amount:");
@@ -22,12 +22,8 @@ InvertEffect::InvertEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_INVERT_
connect(amount_val, SIGNAL(changed()), this, SLOT(field_changed()));
}
void InvertEffect::process_gl(long p, QOpenGLShaderProgram& shader_prog, int* anchor_x, int* anchor_y) {
double value = amount_val->get_double_value(p)*0.01;
vert_shader.compileSourceCode("varying vec2 vTexCoord;\nvoid main() {\n\tvTexCoord = gl_MultiTexCoord0.xy;\n\tgl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n}");
frag_shader.compileSourceCode("uniform sampler2D myTexture;\nvarying vec2 vTexCoord;\nvoid main(void) {\n\tvec4 textureColor = texture2D(myTexture, vTexCoord);\n\tgl_FragColor = vec4(textureColor.r+((1.0-textureColor.r-textureColor.r)*" + QString::number(value, 'f', 2) + "), textureColor.g+((1.0-textureColor.g-textureColor.g)*" + QString::number(value, 'f', 2) + "), textureColor.b+((1.0-textureColor.b-textureColor.b)*" + QString::number(value, 'f', 2) + "), 1);\n}");
shader_prog.addShader(&vert_shader);
shader_prog.addShader(&frag_shader);
void InvertEffect::process_gl(long frame, QOpenGLShaderProgram& shaders, GLTextureCoords&) {
double value = amount_val->get_double_value(frame)*0.01;
shaders.addShaderFromSourceCode(QOpenGLShader::Vertex, "varying vec2 vTexCoord;\nvoid main() {\n\tvTexCoord = gl_MultiTexCoord0.xy;\n\tgl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n}");
shaders.addShaderFromSourceCode(QOpenGLShader::Fragment, "uniform sampler2D myTexture;\nvarying vec2 vTexCoord;\nvoid main(void) {\n\tvec4 textureColor = texture2D(myTexture, vTexCoord);\n\tgl_FragColor = vec4(textureColor.r+((1.0-textureColor.r-textureColor.r)*" + QString::number(value, 'f', 2) + "), textureColor.g+((1.0-textureColor.g-textureColor.g)*" + QString::number(value, 'f', 2) + "), textureColor.b+((1.0-textureColor.b-textureColor.b)*" + QString::number(value, 'f', 2) + "), 1);\n}");
}
+2 -5
View File
@@ -9,12 +9,9 @@ class InvertEffect : public Effect {
Q_OBJECT
public:
InvertEffect(Clip* c);
void process_gl(long p, QOpenGLShaderProgram& shader_prog, int *anchor_x, int *anchor_y);
EffectField* amount_val;
void process_gl(long frame, QOpenGLShaderProgram& shaders, GLTextureCoords& coords);
private:
QOpenGLShader vert_shader;
QOpenGLShader frag_shader;
EffectField* amount_val;
};
#endif // INVERTEFFECT_H
+3 -3
View File
@@ -49,9 +49,9 @@ void ShakeEffect::refresh() {
}
}
void ShakeEffect::process_gl(long p, QOpenGLShaderProgram&, int*, int*) {
void ShakeEffect::process_gl(long frame, QOpenGLShaderProgram& shaders, GLTextureCoords& coords) {
if (shake_progress > shake_limit) {
double ival = intensity_val->get_double_value(p);
double ival = intensity_val->get_double_value(frame);
if ((int)ival > 0) {
prev_x = next_x;
prev_y = next_y;
@@ -81,7 +81,7 @@ void ShakeEffect::process_gl(long p, QOpenGLShaderProgram&, int*, int*) {
offset_x = 0;
offset_y = 0;
}
double rot_val = rotation_val->get_double_value(p);
double rot_val = rotation_val->get_double_value(frame);
if ((int)rot_val > 0) {
prev_rot = next_rot;
next_rot = (qrand() % (int) (rot_val * 2)) - rot_val;
+1 -1
View File
@@ -7,7 +7,7 @@ class ShakeEffect : public Effect {
Q_OBJECT
public:
ShakeEffect(Clip* c);
void process_gl(long p, QOpenGLShaderProgram& shader_prog, int* anchor_x, int* anchor_y);
void process_gl(long frame, QOpenGLShaderProgram& shaders, GLTextureCoords& coords);
EffectField* intensity_val;
EffectField* rotation_val;
+7 -2
View File
@@ -16,7 +16,7 @@
#define SMPTE_LOWER_BARS 4
SolidEffect::SolidEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_SOLID_EFFECT) {
enable_image = true;
enable_opengl = true;
solid_type = add_row("Type:")->add_field(EFFECT_FIELD_COMBO);
solid_type->add_combo_item("Solid Color", SOLID_TYPE_COLOR);
@@ -40,7 +40,12 @@ void SolidEffect::enable_color() {
solid_color_field->set_enabled(solid_type->get_combo_data(-1) == SOLID_TYPE_COLOR);
}
void SolidEffect::process_image(long frame, QImage& img) {
void SolidEffect::process_gl(long frame, QOpenGLShaderProgram& shaders, GLTextureCoords& coords) {
}
void SolidEffect::process_image(long frame, uint8_t* data, int w, int h) {
QImage img(data, w, h, QImage::Format_RGBA8888); // create QImage wrapper
QPainter p(&img);
int width = img.width();
int height = img.height();
+2 -1
View File
@@ -10,7 +10,8 @@ public:
EffectField* solid_type;
EffectField* solid_color_field;
EffectField* opacity_field;
void process_image(long p, QImage &img);
void process_gl(long frame, QOpenGLShaderProgram& shaders, GLTextureCoords& coords);
void process_image(long p, uint8_t* data, int width, int height);
private slots:
void enable_color();
};
+2 -1
View File
@@ -242,7 +242,8 @@ void blurred2(QImage& result, const QRect& rect, int radius, bool alphaOnly = fa
}
}
void TextEffect::process_image(long frame, QImage& img) {
void TextEffect::process_image(long frame, uint8_t* data, int w, int h) {
QImage img(data, w, h, QImage::Format_RGBA8888);
QPainter p(&img);
p.setRenderHint(QPainter::Antialiasing);
int width = img.width();
+1 -1
View File
@@ -9,7 +9,7 @@ class TextEffect : public Effect {
Q_OBJECT
public:
TextEffect(Clip* c);
void process_image(long frame, QImage& img);
void process_image(long frame, uint8_t* data, int width, int height);
EffectField* text_val;
EffectField* size_val;
+11 -3
View File
@@ -121,13 +121,21 @@ void TransformEffect::toggle_uniform_scale(bool enabled) {
scale_y->set_enabled(!enabled);
}
void TransformEffect::process_gl(long frame, QOpenGLShaderProgram&, int* anchor_x, int* anchor_y) {
void TransformEffect::process_gl(long frame, QOpenGLShaderProgram&, GLTextureCoords& coords) {
// position
glTranslatef(position_x->get_double_value(frame)-(parent_clip->sequence->width/2), position_y->get_double_value(frame)-(parent_clip->sequence->height/2), 0);
// anchor point
*anchor_x += (anchor_x_box->get_double_value(frame)-default_anchor_x);
*anchor_y += (anchor_y_box->get_double_value(frame)-default_anchor_y);
int anchor_x_offset = (anchor_x_box->get_double_value(frame)-default_anchor_x);
int anchor_y_offset = (anchor_y_box->get_double_value(frame)-default_anchor_y);
coords.vertexTopLeftX += anchor_x_offset;
coords.vertexTopRightX += anchor_x_offset;
coords.vertexBottomLeftX += anchor_x_offset;
coords.vertexBottomRightX += anchor_x_offset;
coords.vertexTopLeftY += anchor_y_offset;
coords.vertexTopRightY += anchor_y_offset;
coords.vertexBottomLeftY += anchor_y_offset;
coords.vertexBottomRightY += anchor_y_offset;
// rotation
glRotatef(rotation->get_double_value(frame), 0, 0, 1);
+1 -1
View File
@@ -8,7 +8,7 @@ class TransformEffect : public Effect {
public:
TransformEffect(Clip* c);
void refresh();
void process_gl(long p, QOpenGLShaderProgram& shader_prog, int* anchor_x, int* anchor_y);
void process_gl(long frame, QOpenGLShaderProgram& shaders, GLTextureCoords& coords);
EffectField* position_x;
EffectField* position_y;