Added wave_color to Clip's JSON properties. Also fixed a bug with adding effects from a JSON diff. Made the background color of a wave visualization transparent, and made the wave graphic come before the effects are processed, which allows the wave to be faded, animated, etc...

This commit is contained in:
Jonathan Thomas
2015-11-25 23:54:10 -06:00
parent 35a476816b
commit 55684663da
3 changed files with 38 additions and 26 deletions
+6
View File
@@ -588,6 +588,12 @@ string Clip::PropertiesJSON(long int requested_frame) {
root["volume"] = add_property_json("Volume", volume.GetValue(requested_frame), "float", "", volume.Contains(requested_point), volume.GetCount(), 0.0, 1.0, volume.GetClosestPoint(requested_point).interpolation, volume.GetClosestPoint(requested_point).co.X, false);
root["time"] = add_property_json("Time", time.GetValue(requested_frame), "float", "", time.Contains(requested_point), time.GetCount(), 0.0, 1000 * 60 * 30, time.GetClosestPoint(requested_point).interpolation, time.GetClosestPoint(requested_point).co.X, false);
root["wave_color"] = add_property_json("Wave Color", 0.0, "color", "", wave_color.red.Contains(requested_point), wave_color.red.GetCount(), -10000, 10000, wave_color.red.GetClosestPoint(requested_point).interpolation, wave_color.red.GetClosestPoint(requested_point).co.X, false);
root["wave_color"]["red"] = add_property_json("Red", wave_color.red.GetValue(requested_frame), "float", "", wave_color.red.Contains(requested_point), wave_color.red.GetCount(), -10000, 10000, wave_color.red.GetClosestPoint(requested_point).interpolation, wave_color.red.GetClosestPoint(requested_point).co.X, false);
root["wave_color"]["blue"] = add_property_json("Blue", wave_color.blue.GetValue(requested_frame), "float", "", wave_color.blue.Contains(requested_point), wave_color.blue.GetCount(), -10000, 10000, wave_color.blue.GetClosestPoint(requested_point).interpolation, wave_color.blue.GetClosestPoint(requested_point).co.X, false);
root["wave_color"]["green"] = add_property_json("Green", wave_color.green.GetValue(requested_frame), "float", "", wave_color.green.Contains(requested_point), wave_color.green.GetCount(), -10000, 10000, wave_color.green.GetClosestPoint(requested_point).interpolation, wave_color.green.GetClosestPoint(requested_point).co.X, false);
// Return formatted string
return root.toStyledString();
}
+1 -1
View File
@@ -185,7 +185,7 @@ tr1::shared_ptr<QImage> Frame::GetWaveform(int width, int height, int Red, int G
// Create blank image
wave_image = tr1::shared_ptr<QImage>(new QImage(total_width, total_height, QImage::Format_RGBA8888));
wave_image->fill(QColor(QString::fromStdString("#000000")));
wave_image->fill(QColor(0,0,0,0));
// Load QPainter with wave_image device
QPainter painter(wave_image.get());
+31 -25
View File
@@ -198,8 +198,6 @@ void Timeline::add_layer(tr1::shared_ptr<Frame> new_frame, Clip* source_clip, lo
// Get the clip's frame & image
tr1::shared_ptr<Frame> source_frame;
#pragma omp ordered
source_frame = tr1::shared_ptr<Frame>(source_clip->GetFrame(clip_frame_number));
@@ -210,6 +208,23 @@ void Timeline::add_layer(tr1::shared_ptr<Frame> new_frame, Clip* source_clip, lo
// Debug output
AppendDebugMethod("Timeline::add_layer", "new_frame->number", new_frame->number, "clip_frame_number", clip_frame_number, "timeline_frame_number", timeline_frame_number, "", -1, "", -1, "", -1);
/* REPLACE IMAGE WITH WAVEFORM IMAGE (IF NEEDED) */
if (source_clip->Waveform())
{
// Debug output
AppendDebugMethod("Timeline::add_layer (Generate Waveform Image)", "source_frame->number", source_frame->number, "source_clip->Waveform()", source_clip->Waveform(), "clip_frame_number", clip_frame_number, "", -1, "", -1, "", -1);
// Get the color of the waveform
int red = source_clip->wave_color.red.GetInt(clip_frame_number);
int green = source_clip->wave_color.green.GetInt(clip_frame_number);
int blue = source_clip->wave_color.blue.GetInt(clip_frame_number);
int alpha = source_clip->wave_color.alpha.GetInt(clip_frame_number);
// Generate Waveform Dynamically (the size of the timeline)
tr1::shared_ptr<QImage> source_image = source_frame->GetWaveform(info.width, info.height, red, green, blue, alpha);
source_frame->AddImage(tr1::shared_ptr<QImage>(source_image));
}
/* Apply effects to the source frame (if any). If multiple clips are overlapping, only process the
* effects on the top clip. */
if (is_top_clip)
@@ -259,29 +274,11 @@ void Timeline::add_layer(tr1::shared_ptr<Frame> new_frame, Clip* source_clip, lo
}
/* GET IMAGE DATA - OR GENERATE IT */
if (!source_clip->Waveform())
{
// Debug output
AppendDebugMethod("Timeline::add_layer (Get Source Image)", "source_frame->number", source_frame->number, "source_clip->Waveform()", source_clip->Waveform(), "clip_frame_number", clip_frame_number, "", -1, "", -1, "", -1);
// Debug output
AppendDebugMethod("Timeline::add_layer (Get Source Image)", "source_frame->number", source_frame->number, "source_clip->Waveform()", source_clip->Waveform(), "clip_frame_number", clip_frame_number, "", -1, "", -1, "", -1);
// Get actual frame image data
source_image = source_frame->GetImage();
}
else
{
// Debug output
AppendDebugMethod("Timeline::add_layer (Generate Waveform Image)", "source_frame->number", source_frame->number, "source_clip->Waveform()", source_clip->Waveform(), "clip_frame_number", clip_frame_number, "", -1, "", -1, "", -1);
// Get the color of the waveform
int red = source_clip->wave_color.red.GetInt(clip_frame_number);
int green = source_clip->wave_color.green.GetInt(clip_frame_number);
int blue = source_clip->wave_color.blue.GetInt(clip_frame_number);
int alpha = source_clip->wave_color.alpha.GetInt(clip_frame_number);
// Generate Waveform Dynamically (the size of the timeline)
source_image = source_frame->GetWaveform(info.width, info.height, red, green, blue, alpha);
}
// Get actual frame image data
source_image = source_frame->GetImage();
// Get some basic image properties
int source_width = source_image->width();
@@ -1076,7 +1073,13 @@ void Timeline::apply_json_to_effects(Json::Value change, EffectBase* existing_ef
EffectBase *e = NULL;
// Init the matching effect object
if (effect_type == "ChromaKey")
if (effect_type == "Blur")
e = new Blur();
else if (effect_type == "Brightness")
e = new Brightness();
else if (effect_type == "ChromaKey")
e = new ChromaKey();
else if (effect_type == "Deinterlace")
@@ -1088,6 +1091,9 @@ void Timeline::apply_json_to_effects(Json::Value change, EffectBase* existing_ef
else if (effect_type == "Negate")
e = new Negate();
else if (effect_type == "Saturation")
e = new Saturation();
// Load Json into Effect
e->SetJsonValue(change["value"]);