#include "solideffect.h" #include #include #include #include #include "project/clip.h" #include "project/sequence.h" #define SOLID_TYPE_COLOR 0 #define SOLID_TYPE_BARS 1 #define SMPTE_BARS 7 #define SMPTE_STRIP_COUNT 3 #define SMPTE_LOWER_BARS 4 SolidEffect::SolidEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_SOLID_EFFECT), vert(QOpenGLShader::Vertex), frag(QOpenGLShader::Fragment) { enable_opengl = true; solid_type = add_row("Type:")->add_field(EFFECT_FIELD_COMBO); solid_type->add_combo_item("Solid Color", SOLID_TYPE_COLOR); solid_type->add_combo_item("SMPTE Bars", SOLID_TYPE_BARS); solid_color_field = add_row("Color:")->add_field(EFFECT_FIELD_COLOR); solid_color_field->set_color_value(Qt::red); opacity_field = add_row("Opacity:")->add_field(EFFECT_FIELD_DOUBLE); opacity_field->set_double_minimum_value(0); opacity_field->set_double_maximum_value(100); opacity_field->set_double_default_value(100); connect(solid_type, SIGNAL(changed()), this, SLOT(field_changed())); connect(solid_color_field, SIGNAL(changed()), this, SLOT(field_changed())); connect(opacity_field, SIGNAL(changed()), this, SLOT(field_changed())); vert.compileSourceFile(":/shaders/common.vert"); frag.compileSourceFile(":/shaders/solideffect.frag"); program.addShader(&vert); program.addShader(&frag); } void SolidEffect::process_gl(double timecode, GLTextureCoords&) { solid_color_field->set_enabled(solid_type->get_combo_data(timecode) == SOLID_TYPE_COLOR); program.bind(); program.setUniformValue("solidColor", solid_color_field->get_color_value(timecode)); program.setUniformValue("amount_val", (GLfloat) (opacity_field->get_double_value(timecode)*0.01)); } void SolidEffect::clean_gl() { program.release(); } 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(); switch (solid_type->get_combo_data(frame).toInt()) { case SOLID_TYPE_COLOR: { QColor brush = solid_color_field->get_color_value(frame); p.fillRect(0, 0, width, height, QColor(brush.red(), brush.green(), brush.blue(), opacity_field->get_double_value(frame)*2.55)); } break; case SOLID_TYPE_BARS: // draw smpte bars int bar_width = qCeil((double) parent_clip->sequence->width / 7.0); int first_bar_height = qCeil((double) parent_clip->sequence->height / 3.0 * 2.0); int second_bar_height = qCeil((double) parent_clip->sequence->height / 12.5); int third_bar_y = first_bar_height + second_bar_height; int third_bar_height = parent_clip->sequence->height - third_bar_y; int third_bar_width = 0; int bar_x, strip_width; QColor first_color, second_color, third_color; for (int i=0;i