Large refactor of Timeline, TimelineBase, ClipBase, and Clip, to allow a Clip access to the parent timeline instance (if available), and thus, certain properties (preview size, timeline FPS, etc...). This allows for a simpler rendering of Clip keyframes (during the Clip::GetFrame method), and a simpler Timeline class, that can change the preview window size dynamically and no longer requires a Singleton Settings class.

- Also removed "crop" from Clip class, as it was never implmeneted correctly, and we have a fully functional "crop" effect when needed
 - Added caching to Clip class, to optimize previewing of cached frames (much faster than previous)
This commit is contained in:
Jonathan Thomas
2020-10-04 16:59:21 -05:00
parent 453d55f41a
commit f9a717ef4b
35 changed files with 517 additions and 345 deletions

View File

@@ -1286,15 +1286,16 @@ void FFmpegReader::ProcessVideoPacket(int64_t requested_frame) {
// without losing quality. NOTE: We cannot go smaller than the timeline itself, or the add_layer timeline
// method will scale it back to timeline size before scaling it smaller again. This needs to be fixed in
// the future.
int max_width = openshot::Settings::Instance()->MAX_WIDTH;
if (max_width <= 0)
max_width = info.width;
int max_height = openshot::Settings::Instance()->MAX_HEIGHT;
if (max_height <= 0)
max_height = info.height;
int max_width = info.width;
int max_height = info.height;
Clip *parent = (Clip *) GetClip();
Clip *parent = (Clip *) ParentClip();
if (parent) {
if (parent->ParentTimeline()) {
// Set max width/height based on parent clip's timeline (if attached to a timeline)
max_width = parent->ParentTimeline()->preview_width;
max_height = parent->ParentTimeline()->preview_height;
}
if (parent->scale == SCALE_FIT || parent->scale == SCALE_STRETCH) {
// Best fit or Stretch scaling (based on max timeline size * scaling keyframes)
float max_scale_x = parent->scale_x.GetMaxPoint().co.Y;