From 57fbf357f6a097630ebaebe14ac4c62e330be76a Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Tue, 24 Feb 2015 23:59:26 -0600 Subject: [PATCH] Increased debug output precision. Fixed rounding bug on timeline when finding a clips actual frame number. Fixed bug with a clips JSON properties output. --- include/ReaderBase.h | 12 ++++++------ include/WriterBase.h | 12 ++++++------ src/Clip.cpp | 4 ++-- src/ReaderBase.cpp | 13 +++++++------ src/Timeline.cpp | 11 +++++++---- src/WriterBase.cpp | 13 +++++++------ 6 files changed, 35 insertions(+), 30 deletions(-) diff --git a/include/ReaderBase.h b/include/ReaderBase.h index a20a3c3d..3555aa0f 100644 --- a/include/ReaderBase.h +++ b/include/ReaderBase.h @@ -101,12 +101,12 @@ namespace openshot void AppendDebugItem(Json::Value debug_item); /// Append debug information as JSON - void AppendDebugMethod(string method_name, string arg1_name, int arg1_value, - string arg2_name, int arg2_value, - string arg3_name, int arg3_value, - string arg4_name, int arg4_value, - string arg5_name, int arg5_value, - string arg6_name, int arg6_value); + void AppendDebugMethod(string method_name, string arg1_name, float arg1_value, + string arg2_name, float arg2_value, + string arg3_name, float arg3_value, + string arg4_name, float arg4_value, + string arg5_name, float arg5_value, + string arg6_name, float arg6_value); public: diff --git a/include/WriterBase.h b/include/WriterBase.h index 8701c67c..8b1e960a 100644 --- a/include/WriterBase.h +++ b/include/WriterBase.h @@ -91,12 +91,12 @@ namespace openshot void AppendDebugItem(Json::Value debug_item); /// Append debug information as JSON - void AppendDebugMethod(string method_name, string arg1_name, int arg1_value, - string arg2_name, int arg2_value, - string arg3_name, int arg3_value, - string arg4_name, int arg4_value, - string arg5_name, int arg5_value, - string arg6_name, int arg6_value); + void AppendDebugMethod(string method_name, string arg1_name, float arg1_value, + string arg2_name, float arg2_value, + string arg3_name, float arg3_value, + string arg4_name, float arg4_value, + string arg5_name, float arg5_value, + string arg6_name, float arg6_value); public: /// Constructor for WriterBase class, many things are initialized here diff --git a/src/Clip.cpp b/src/Clip.cpp index cff6ce7c..941bb282 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -533,7 +533,7 @@ string Clip::PropertiesJSON(int requested_frame) { // Generate JSON properties list Json::Value root; root["id"] = add_property_json("ID", 0.0, "string", Id(), false, 0, -1, -1, CONSTANT, -1, true); - root["position"] = add_property_json("Position", Position(), "int", "", false, 0, 0, 1000 * 60 * 30, CONSTANT, -1, false); + root["position"] = add_property_json("Position", Position(), "float", "", false, 0, 0, 1000 * 60 * 30, CONSTANT, -1, false); root["layer"] = add_property_json("Layer", Layer(), "int", "", false, 0, 0, 1000, CONSTANT, -1, false); root["start"] = add_property_json("Start", Start(), "float", "", false, 0, 0, 1000 * 60 * 30, CONSTANT, -1, false); root["end"] = add_property_json("End", End(), "float", "", false, 0, 0, 1000 * 60 * 30, CONSTANT, -1, false); @@ -583,7 +583,7 @@ Json::Value Clip::add_property_json(string name, float value, string type, strin prop["name"] = name; prop["value"] = value; prop["memo"] = memo; - prop["type"] = value; + prop["type"] = type; prop["min"] = min_value; prop["max"] = max_value; prop["keyframe"] = contains_point; diff --git a/src/ReaderBase.cpp b/src/ReaderBase.cpp index 8778aad3..3624c193 100644 --- a/src/ReaderBase.cpp +++ b/src/ReaderBase.cpp @@ -78,12 +78,12 @@ void ReaderBase::AppendDebugItem(Json::Value debug_item) } // Append debug information as JSON -void ReaderBase::AppendDebugMethod(string method_name, string arg1_name, int arg1_value, - string arg2_name, int arg2_value, - string arg3_name, int arg3_value, - string arg4_name, int arg4_value, - string arg5_name, int arg5_value, - string arg6_name, int arg6_value) +void ReaderBase::AppendDebugMethod(string method_name, string arg1_name, float arg1_value, + string arg2_name, float arg2_value, + string arg3_name, float arg3_value, + string arg4_name, float arg4_value, + string arg5_name, float arg5_value, + string arg6_name, float arg6_value) { if (!debug) // Don't do anything @@ -93,6 +93,7 @@ void ReaderBase::AppendDebugMethod(string method_name, string arg1_name, int arg debug_item["method"] = method_name; // Output to standard output + cout << fixed << setprecision(4); cout << "Debug: Method: " << method_name << " ("; // Add attributes to method JSON diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 5f460785..cf0d251e 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -574,19 +574,22 @@ tr1::shared_ptr Timeline::GetFrame(int requested_frame) throw(ReaderClose Clip *clip = (*clip_itr); // Does clip intersect the current requested time - float clip_duration = clip->End() - clip->Start(); - bool does_clip_intersect = (clip->Position() <= requested_time && clip->Position() + clip_duration >= requested_time); + bool does_clip_intersect = (clip->Position() <= requested_time && clip->Position() + clip->Duration() >= requested_time); // Debug output #pragma omp critical (debug_output) - AppendDebugMethod("Timeline::GetFrame (Does clip intersect)", "frame_number", frame_number, "requested_time", requested_time, "clip->Position()", clip->Position(), "clip_duration", clip_duration, "does_clip_intersect", does_clip_intersect, "", -1); + AppendDebugMethod("Timeline::GetFrame (Does clip intersect)", "frame_number", frame_number, "requested_time", requested_time, "clip->Position()", clip->Position(), "clip->Duration()", clip->Duration(), "does_clip_intersect", does_clip_intersect, "", -1); // Clip is visible if (does_clip_intersect) { // Determine the frame needed for this clip (based on the position on the timeline) float time_diff = (requested_time - clip->Position()) + clip->Start(); - int clip_frame_number = round(time_diff * info.fps.ToFloat()) + 1; + int clip_frame_number = (time_diff * info.fps.ToFloat()) + 1; + + // Debug output + #pragma omp critical (debug_output) + AppendDebugMethod("Timeline::GetFrame (Calculate clip's frame #)", "time_diff", time_diff, "requested_time", requested_time, "clip->Position()", clip->Position(), "clip->Start()", clip->Start(), "info.fps.ToFloat()", info.fps.ToFloat(), "clip_frame_number", clip_frame_number); // Add clip's frame as layer add_layer(new_frame, clip, clip_frame_number, frame_number); diff --git a/src/WriterBase.cpp b/src/WriterBase.cpp index 911e00fe..fb631a4d 100644 --- a/src/WriterBase.cpp +++ b/src/WriterBase.cpp @@ -77,12 +77,12 @@ void WriterBase::AppendDebugItem(Json::Value debug_item) } // Append debug information as JSON -void WriterBase::AppendDebugMethod(string method_name, string arg1_name, int arg1_value, - string arg2_name, int arg2_value, - string arg3_name, int arg3_value, - string arg4_name, int arg4_value, - string arg5_name, int arg5_value, - string arg6_name, int arg6_value) +void WriterBase::AppendDebugMethod(string method_name, string arg1_name, float arg1_value, + string arg2_name, float arg2_value, + string arg3_name, float arg3_value, + string arg4_name, float arg4_value, + string arg5_name, float arg5_value, + string arg6_name, float arg6_value) { if (!debug) // Don't do anything @@ -92,6 +92,7 @@ void WriterBase::AppendDebugMethod(string method_name, string arg1_name, int arg debug_item["method"] = method_name; // Output to standard output + cout << fixed << setprecision(4); cout << "Debug: Method: " << method_name << " ("; // Add attributes to method JSON