From 80a1fe8ca4731a30c681ecdf05879f34550dc759 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 12 Oct 2020 23:28:03 -0500 Subject: [PATCH] Initializing Clip info struct, and fixing clip cache settings --- include/Clip.h | 15 +++++++++------ src/Clip.cpp | 29 ++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/include/Clip.h b/include/Clip.h index fd28c162a..0bc99e849 100644 --- a/include/Clip.h +++ b/include/Clip.h @@ -98,6 +98,15 @@ namespace openshot { /// Section lock for multiple threads juce::CriticalSection getFrameCriticalSection; + /// Init default settings for a clip + void init_settings(); + + /// Init reader info details + void init_reader_settings(); + + /// Update default rotation from reader + void init_reader_rotation(); + private: bool waveform; ///< Should a waveform be used instead of the clip's image std::list effects; /// frame, int64_t frame_number); - /// Init default settings for a clip - void init_settings(); - - /// Update default rotation from reader - void init_reader_rotation(); - /// Compare 2 floating point numbers bool isEqual(double a, double b); diff --git a/src/Clip.cpp b/src/Clip.cpp index 1d2b392d8..d81b5c610 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -69,9 +69,6 @@ void Clip::init_settings() // Init alpha alpha = Keyframe(1.0); - // Init rotation - init_reader_rotation(); - // Init time & volume time = Keyframe(1.0); volume = Keyframe(1.0); @@ -101,8 +98,22 @@ void Clip::init_settings() has_audio = Keyframe(-1.0); has_video = Keyframe(-1.0); - // Initialize Clip cache - cache.SetMaxBytesFromInfo(OPEN_MP_NUM_PROCESSORS * 2, info.width, info.height, info.sample_rate, info.channels); + // Init reader info struct and cache size + init_reader_settings(); +} + +// Init reader info details +void Clip::init_reader_settings() { + if (reader) { + // Init rotation (if any) + init_reader_rotation(); + + // Initialize info struct + info = reader->info; + + // Initialize Clip cache + cache.SetMaxBytesFromInfo(OPEN_MP_NUM_PROCESSORS * 2, info.width, info.height, info.sample_rate, info.channels); + } } // Init reader's rotation (if any) @@ -208,8 +219,8 @@ Clip::Clip(std::string path) : resampler(NULL), reader(NULL), allocated_reader(N End(reader->info.duration); reader->ParentClip(this); allocated_reader = reader; - init_reader_rotation(); - } + // Init reader info struct and cache size + init_reader_settings(); } } // Destructor @@ -237,8 +248,8 @@ void Clip::Reader(ReaderBase* new_reader) // set parent reader->ParentClip(this); - // Init rotation (if any) - init_reader_rotation(); + // Init reader info struct and cache size + init_reader_settings(); } /// Get the current reader