Skip to content

Commit

Permalink
Initializing Clip info struct, and fixing clip cache settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jonoomph authored and ferdnyc committed Oct 19, 2020
1 parent 8d36b12 commit b936ea8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
15 changes: 9 additions & 6 deletions include/Clip.h
Expand Up @@ -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<openshot::EffectBase*> effects; ///<List of clips on this timeline
Expand Down Expand Up @@ -131,12 +140,6 @@ namespace openshot {
/// Adjust the audio and image of a time mapped frame
void get_time_mapped_frame(std::shared_ptr<openshot::Frame> 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);

Expand Down
29 changes: 20 additions & 9 deletions src/Clip.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -208,8 +219,8 @@ Clip::Clip(std::string path) : resampler(NULL), reader(NULL), allocated_reader(N
End(reader->info.duration);
reader->SetParentClip(this);
allocated_reader = reader;
init_reader_rotation();
}
// Init reader info struct and cache size
init_reader_settings(); }
}

// Destructor
Expand Down Expand Up @@ -237,8 +248,8 @@ void Clip::Reader(ReaderBase* new_reader)
// set parent
reader->SetParentClip(this);

// Init rotation (if any)
init_reader_rotation();
// Init reader info struct and cache size
init_reader_settings();
}

/// Get the current reader
Expand Down

0 comments on commit b936ea8

Please sign in to comment.