Fixing whitespace

This commit is contained in:
Jonathan Thomas
2022-10-28 19:01:27 -05:00
parent 1547fb1d52
commit 9f3fa0af52
2 changed files with 64 additions and 64 deletions

View File

@@ -343,9 +343,9 @@ void Timeline::AddClip(Clip* clip)
// All clips should be converted to the frame rate of this timeline
if (auto_map_clips) {
// Apply framemapper (or update existing framemapper)
apply_mapper_to_clip(clip);
}
// Apply framemapper (or update existing framemapper)
apply_mapper_to_clip(clip);
}
// Add clip to list
clips.push_back(clip);
@@ -856,8 +856,8 @@ void Timeline::Close()
{
ZmqLogger::Instance()->AppendDebugMethod("Timeline::Close");
// Get lock (prevent getting frames while this happens)
const std::lock_guard<std::recursive_mutex> guard(getFrameMutex);
// Get lock (prevent getting frames while this happens)
const std::lock_guard<std::recursive_mutex> guard(getFrameMutex);
// Close all open clips
for (auto clip : clips)
@@ -1151,8 +1151,8 @@ Json::Value Timeline::JsonValue() const {
// Load JSON string into this object
void Timeline::SetJson(const std::string value) {
// Get lock (prevent getting frames while this happens)
const std::lock_guard<std::recursive_mutex> lock(getFrameMutex);
// Get lock (prevent getting frames while this happens)
const std::lock_guard<std::recursive_mutex> lock(getFrameMutex);
// Parse JSON string into JSON objects
try
@@ -1394,8 +1394,8 @@ void Timeline::apply_json_to_clips(Json::Value change) {
// Apply framemapper (or update existing framemapper)
if (auto_map_clips) {
apply_mapper_to_clip(existing_clip);
}
apply_mapper_to_clip(existing_clip);
}
}
} else if (change_type == "delete") {
@@ -1526,7 +1526,7 @@ void Timeline::apply_json_to_effects(Json::Value change, EffectBase* existing_ef
// Apply JSON diff to timeline properties
void Timeline::apply_json_to_timeline(Json::Value change) {
bool cache_dirty = true;
bool cache_dirty = true;
// Get key and type of change
std::string change_type = change["type"].asString();
@@ -1558,7 +1558,7 @@ void Timeline::apply_json_to_timeline(Json::Value change) {
info.video_length = info.fps.ToFloat() * info.duration;
// We don't want to clear cache for duration adjustments
cache_dirty = false;
cache_dirty = false;
}
else if (root_key == "width") {
// Set width
@@ -1647,8 +1647,8 @@ void Timeline::apply_json_to_timeline(Json::Value change) {
}
if (cache_dirty) {
// Clear entire cache
ClearAllCache();
// Clear entire cache
ClearAllCache();
}
}

View File

@@ -607,7 +607,7 @@ TEST_CASE( "GetMaxFrame and GetMaxTime", "[libopenshot][timeline]" )
std::stringstream path1;
path1 << TEST_MEDIA_PATH << "interlaced.png";
Clip clip1(path1.str());
clip1.Id("C1");
clip1.Id("C1");
clip1.Layer(1);
clip1.Position(50);
clip1.End(45);
@@ -643,21 +643,21 @@ TEST_CASE( "GetMaxFrame and GetMaxTime", "[libopenshot][timeline]" )
CHECK(t.GetMaxFrame() == 115 * 30 + 1);
CHECK(t.GetMaxTime() == Approx(115.0).margin(0.001));
// Update Clip's basic properties with JSON Diff
std::stringstream json_change1;
json_change1 << "[{\"type\":\"update\",\"key\":[\"clips\",{\"id\":\"C2\"}],\"value\":{\"id\":\"C2\",\"layer\":4000000,\"position\":0.0,\"start\":0,\"end\":10},\"partial\":false}]";
t.ApplyJsonDiff(json_change1.str());
// Update Clip's basic properties with JSON Diff
std::stringstream json_change1;
json_change1 << "[{\"type\":\"update\",\"key\":[\"clips\",{\"id\":\"C2\"}],\"value\":{\"id\":\"C2\",\"layer\":4000000,\"position\":0.0,\"start\":0,\"end\":10},\"partial\":false}]";
t.ApplyJsonDiff(json_change1.str());
CHECK(t.GetMaxFrame() == 10 * 30 + 1);
CHECK(t.GetMaxTime() == Approx(10.0).margin(0.001));
CHECK(t.GetMaxFrame() == 10 * 30 + 1);
CHECK(t.GetMaxTime() == Approx(10.0).margin(0.001));
// Insert NEW Clip with JSON Diff
std::stringstream json_change2;
json_change2 << "[{\"type\":\"insert\",\"key\":[\"clips\"],\"value\":{\"id\":\"C3\",\"layer\":4000000,\"position\":10.0,\"start\":0,\"end\":10,\"reader\":{\"acodec\":\"\",\"audio_bit_rate\":0,\"audio_stream_index\":-1,\"audio_timebase\":{\"den\":1,\"num\":1},\"channel_layout\":4,\"channels\":0,\"display_ratio\":{\"den\":1,\"num\":1},\"duration\":3600.0,\"file_size\":\"160000\",\"fps\":{\"den\":1,\"num\":30},\"has_audio\":false,\"has_single_image\":true,\"has_video\":true,\"height\":200,\"interlaced_frame\":false,\"metadata\":{},\"path\":\"" << path1.str() << "\",\"pixel_format\":-1,\"pixel_ratio\":{\"den\":1,\"num\":1},\"sample_rate\":0,\"top_field_first\":true,\"type\":\"QtImageReader\",\"vcodec\":\"\",\"video_bit_rate\":0,\"video_length\":\"108000\",\"video_stream_index\":-1,\"video_timebase\":{\"den\":30,\"num\":1},\"width\":200}},\"partial\":false}]";
t.ApplyJsonDiff(json_change2.str());
// Insert NEW Clip with JSON Diff
std::stringstream json_change2;
json_change2 << "[{\"type\":\"insert\",\"key\":[\"clips\"],\"value\":{\"id\":\"C3\",\"layer\":4000000,\"position\":10.0,\"start\":0,\"end\":10,\"reader\":{\"acodec\":\"\",\"audio_bit_rate\":0,\"audio_stream_index\":-1,\"audio_timebase\":{\"den\":1,\"num\":1},\"channel_layout\":4,\"channels\":0,\"display_ratio\":{\"den\":1,\"num\":1},\"duration\":3600.0,\"file_size\":\"160000\",\"fps\":{\"den\":1,\"num\":30},\"has_audio\":false,\"has_single_image\":true,\"has_video\":true,\"height\":200,\"interlaced_frame\":false,\"metadata\":{},\"path\":\"" << path1.str() << "\",\"pixel_format\":-1,\"pixel_ratio\":{\"den\":1,\"num\":1},\"sample_rate\":0,\"top_field_first\":true,\"type\":\"QtImageReader\",\"vcodec\":\"\",\"video_bit_rate\":0,\"video_length\":\"108000\",\"video_stream_index\":-1,\"video_timebase\":{\"den\":30,\"num\":1},\"width\":200}},\"partial\":false}]";
t.ApplyJsonDiff(json_change2.str());
CHECK(t.GetMaxFrame() == 20 * 30 + 1);
CHECK(t.GetMaxTime() == Approx(20.0).margin(0.001));
CHECK(t.GetMaxFrame() == 20 * 30 + 1);
CHECK(t.GetMaxTime() == Approx(20.0).margin(0.001));
}
TEST_CASE( "Multi-threaded Timeline GetFrame", "[libopenshot][timeline]" )
@@ -745,55 +745,55 @@ TEST_CASE( "Multi-threaded Timeline Add/Remove Clip", "[libopenshot][timeline]"
TEST_CASE( "ApplyJSONDiff and FrameMappers", "[libopenshot][timeline]" )
{
// Create a timeline
Timeline t(640, 480, Fraction(60, 1), 44100, 2, LAYOUT_STEREO);
t.Open();
// Create a timeline
Timeline t(640, 480, Fraction(60, 1), 44100, 2, LAYOUT_STEREO);
t.Open();
// Auto create FrameMappers for each clip
t.AutoMapClips(true);
// Auto create FrameMappers for each clip
t.AutoMapClips(true);
// Add clip
std::stringstream path1;
path1 << TEST_MEDIA_PATH << "interlaced.png";
Clip clip1(path1.str());
clip1.Id("ABC");
clip1.Layer(1);
clip1.Position(0);
clip1.End(10);
// Add clip
std::stringstream path1;
path1 << TEST_MEDIA_PATH << "interlaced.png";
Clip clip1(path1.str());
clip1.Id("ABC");
clip1.Layer(1);
clip1.Position(0);
clip1.End(10);
// Verify clip reader type (not wrapped yet, because we have not added clip to timeline)
CHECK(clip1.Reader()->Name() == "QtImageReader");
// Verify clip reader type (not wrapped yet, because we have not added clip to timeline)
CHECK(clip1.Reader()->Name() == "QtImageReader");
t.AddClip(&clip1);
t.AddClip(&clip1);
// Verify clip was wrapped in FrameMapper
CHECK(clip1.Reader()->Name() == "FrameMapper");
// Verify clip was wrapped in FrameMapper
CHECK(clip1.Reader()->Name() == "FrameMapper");
// Update Clip's basic properties with JSON Diff (i.e. no reader JSON)
std::stringstream json_change1;
json_change1 << "[{\"type\":\"update\",\"key\":[\"clips\",{\"id\":\"" << clip1.Id() << "\"}],\"value\":{\"id\":\"" << clip1.Id() << "\",\"layer\":4000000,\"position\":14.7,\"start\":0,\"end\":10},\"partial\":false}]";
t.ApplyJsonDiff(json_change1.str());
// Update Clip's basic properties with JSON Diff (i.e. no reader JSON)
std::stringstream json_change1;
json_change1 << "[{\"type\":\"update\",\"key\":[\"clips\",{\"id\":\"" << clip1.Id() << "\"}],\"value\":{\"id\":\"" << clip1.Id() << "\",\"layer\":4000000,\"position\":14.7,\"start\":0,\"end\":10},\"partial\":false}]";
t.ApplyJsonDiff(json_change1.str());
// Verify clip is still wrapped in FrameMapper
CHECK(clip1.Reader()->Name() == "FrameMapper");
// Verify clip is still wrapped in FrameMapper
CHECK(clip1.Reader()->Name() == "FrameMapper");
// Update clip's reader back to a QtImageReader
std::stringstream json_change2;
json_change2 << "[{\"type\":\"update\",\"key\":[\"clips\",{\"id\":\"" << clip1.Id() << "\"}],\"value\":{\"id\":\"" << clip1.Id() << "\",\"reader\":{\"acodec\":\"\",\"audio_bit_rate\":0,\"audio_stream_index\":-1,\"audio_timebase\":{\"den\":1,\"num\":1},\"channel_layout\":4,\"channels\":0,\"display_ratio\":{\"den\":1,\"num\":1},\"duration\":3600.0,\"file_size\":\"160000\",\"fps\":{\"den\":1,\"num\":30},\"has_audio\":false,\"has_single_image\":true,\"has_video\":true,\"height\":200,\"interlaced_frame\":false,\"metadata\":{},\"path\":\"" << path1.str() << "\",\"pixel_format\":-1,\"pixel_ratio\":{\"den\":1,\"num\":1},\"sample_rate\":0,\"top_field_first\":true,\"type\":\"QtImageReader\",\"vcodec\":\"\",\"video_bit_rate\":0,\"video_length\":\"108000\",\"video_stream_index\":-1,\"video_timebase\":{\"den\":30,\"num\":1},\"width\":200},\"position\":14.7,\"start\":0,\"end\":10},\"partial\":false}]";
t.ApplyJsonDiff(json_change2.str());
// Update clip's reader back to a QtImageReader
std::stringstream json_change2;
json_change2 << "[{\"type\":\"update\",\"key\":[\"clips\",{\"id\":\"" << clip1.Id() << "\"}],\"value\":{\"id\":\"" << clip1.Id() << "\",\"reader\":{\"acodec\":\"\",\"audio_bit_rate\":0,\"audio_stream_index\":-1,\"audio_timebase\":{\"den\":1,\"num\":1},\"channel_layout\":4,\"channels\":0,\"display_ratio\":{\"den\":1,\"num\":1},\"duration\":3600.0,\"file_size\":\"160000\",\"fps\":{\"den\":1,\"num\":30},\"has_audio\":false,\"has_single_image\":true,\"has_video\":true,\"height\":200,\"interlaced_frame\":false,\"metadata\":{},\"path\":\"" << path1.str() << "\",\"pixel_format\":-1,\"pixel_ratio\":{\"den\":1,\"num\":1},\"sample_rate\":0,\"top_field_first\":true,\"type\":\"QtImageReader\",\"vcodec\":\"\",\"video_bit_rate\":0,\"video_length\":\"108000\",\"video_stream_index\":-1,\"video_timebase\":{\"den\":30,\"num\":1},\"width\":200},\"position\":14.7,\"start\":0,\"end\":10},\"partial\":false}]";
t.ApplyJsonDiff(json_change2.str());
// Verify clip reader type
CHECK(clip1.Reader()->Name() == "FrameMapper");
// Verify clip reader type
CHECK(clip1.Reader()->Name() == "FrameMapper");
// Disable Auto FrameMappers for each clip
t.AutoMapClips(false);
// Disable Auto FrameMappers for each clip
t.AutoMapClips(false);
// Update clip's reader back to a QtImageReader
std::stringstream json_change3;
json_change3 << "[{\"type\":\"update\",\"key\":[\"clips\",{\"id\":\"" << clip1.Id() << "\"}],\"value\":{\"id\":\"" << clip1.Id() << "\",\"reader\":{\"acodec\":\"\",\"audio_bit_rate\":0,\"audio_stream_index\":-1,\"audio_timebase\":{\"den\":1,\"num\":1},\"channel_layout\":4,\"channels\":0,\"display_ratio\":{\"den\":1,\"num\":1},\"duration\":3600.0,\"file_size\":\"160000\",\"fps\":{\"den\":1,\"num\":30},\"has_audio\":false,\"has_single_image\":true,\"has_video\":true,\"height\":200,\"interlaced_frame\":false,\"metadata\":{},\"path\":\"" << path1.str() << "\",\"pixel_format\":-1,\"pixel_ratio\":{\"den\":1,\"num\":1},\"sample_rate\":0,\"top_field_first\":true,\"type\":\"QtImageReader\",\"vcodec\":\"\",\"video_bit_rate\":0,\"video_length\":\"108000\",\"video_stream_index\":-1,\"video_timebase\":{\"den\":30,\"num\":1},\"width\":200},\"position\":14.7,\"start\":0,\"end\":10},\"partial\":false}]";
t.ApplyJsonDiff(json_change3.str());
// Update clip's reader back to a QtImageReader
std::stringstream json_change3;
json_change3 << "[{\"type\":\"update\",\"key\":[\"clips\",{\"id\":\"" << clip1.Id() << "\"}],\"value\":{\"id\":\"" << clip1.Id() << "\",\"reader\":{\"acodec\":\"\",\"audio_bit_rate\":0,\"audio_stream_index\":-1,\"audio_timebase\":{\"den\":1,\"num\":1},\"channel_layout\":4,\"channels\":0,\"display_ratio\":{\"den\":1,\"num\":1},\"duration\":3600.0,\"file_size\":\"160000\",\"fps\":{\"den\":1,\"num\":30},\"has_audio\":false,\"has_single_image\":true,\"has_video\":true,\"height\":200,\"interlaced_frame\":false,\"metadata\":{},\"path\":\"" << path1.str() << "\",\"pixel_format\":-1,\"pixel_ratio\":{\"den\":1,\"num\":1},\"sample_rate\":0,\"top_field_first\":true,\"type\":\"QtImageReader\",\"vcodec\":\"\",\"video_bit_rate\":0,\"video_length\":\"108000\",\"video_stream_index\":-1,\"video_timebase\":{\"den\":30,\"num\":1},\"width\":200},\"position\":14.7,\"start\":0,\"end\":10},\"partial\":false}]";
t.ApplyJsonDiff(json_change3.str());
// Verify clip reader type
CHECK(clip1.Reader()->Name() == "QtImageReader");
// Verify clip reader type
CHECK(clip1.Reader()->Name() == "QtImageReader");
}