From a505f875d1763cd1ca358bdc2c33d4ff86bc29fc Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Thu, 20 May 2021 13:15:13 -0500 Subject: [PATCH] Refactoring timeline_frame_number out of apply_layer() and TimelineInfoStruct, we already have this data in scope (on the background frame instance) --- src/Clip.cpp | 4 ++-- src/Clip.h | 4 +--- src/Timeline.cpp | 11 +++++------ src/Timeline.h | 2 +- src/TimelineBase.h | 8 +++----- 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/Clip.cpp b/src/Clip.cpp index 794f8874..92fff2c3 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -394,9 +394,9 @@ std::shared_ptr Clip::GetFrame(std::shared_ptr backgroun // Apply global timeline effects (i.e. transitions & masks... if any) if (timeline != NULL && options != NULL) { if (options->is_top_clip) { - // Apply global timeline effects (only to top clip... if overlapping) + // Apply global timeline effects (only to top clip... if overlapping, pass in timeline frame number) Timeline* timeline_instance = (Timeline*) timeline; - original_frame = timeline_instance->apply_effects(original_frame, options->timeline_frame_number, Layer()); + original_frame = timeline_instance->apply_effects(original_frame, background_frame->number, Layer()); } } diff --git a/src/Clip.h b/src/Clip.h index adb168bd..5014bcc7 100644 --- a/src/Clip.h +++ b/src/Clip.h @@ -164,7 +164,6 @@ namespace openshot { void reverse_buffer(juce::AudioSampleBuffer* buffer); - public: openshot::GravityType gravity; ///< The gravity of a clip determines where it snaps to its parent openshot::ScaleType scale; ///< The scale determines how a clip should be resized to fit its parent @@ -244,8 +243,7 @@ namespace openshot { /// @param frame_number The frame number (starting at 1) of the clip on the timeline. The image size and number /// of samples match the timeline. /// @param options The openshot::TimelineInfoStruct pointer, with more details about this specific timeline clip, - /// such as, if it's a top clip, and what the absolute timeline frame number is. This info is used to apply global - /// transitions and masks, if needed. + /// such as, if it's a top clip. This info is used to apply global transitions and masks, if needed. std::shared_ptr GetFrame(std::shared_ptr background_frame, int64_t frame_number, openshot::TimelineInfoStruct* options); /// Open the internal reader diff --git a/src/Timeline.cpp b/src/Timeline.cpp index c038ee1d..f7e5f440 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -475,11 +475,10 @@ std::shared_ptr Timeline::GetOrCreateFrame(std::shared_ptr backgro } // Process a new layer of video or audio -void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, int64_t clip_frame_number, int64_t timeline_frame_number, bool is_top_clip, float max_volume) +void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, int64_t clip_frame_number, bool is_top_clip, float max_volume) { // Create timeline options (with details about this current frame request) TimelineInfoStruct* options = new TimelineInfoStruct(); - options->timeline_frame_number = timeline_frame_number; options->is_top_clip = is_top_clip; // Get the clip's frame, composited on top of the current timeline frame @@ -492,12 +491,12 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in return; // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer", "new_frame->number", new_frame->number, "clip_frame_number", clip_frame_number, "timeline_frame_number", timeline_frame_number); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer", "new_frame->number", new_frame->number, "clip_frame_number", clip_frame_number); /* COPY AUDIO - with correct volume */ if (source_clip->Reader()->info.has_audio) { // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Copy Audio)", "source_clip->Reader()->info.has_audio", source_clip->Reader()->info.has_audio, "source_frame->GetAudioChannelsCount()", source_frame->GetAudioChannelsCount(), "info.channels", info.channels, "clip_frame_number", clip_frame_number, "timeline_frame_number", timeline_frame_number); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Copy Audio)", "source_clip->Reader()->info.has_audio", source_clip->Reader()->info.has_audio, "source_frame->GetAudioChannelsCount()", source_frame->GetAudioChannelsCount(), "info.channels", info.channels, "clip_frame_number", clip_frame_number); if (source_frame->GetAudioChannelsCount() == info.channels && source_clip->has_audio.GetInt(clip_frame_number) != 0) for (int channel = 0; channel < source_frame->GetAudioChannelsCount(); channel++) @@ -550,7 +549,7 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in } else // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (No Audio Copied - Wrong # of Channels)", "source_clip->Reader()->info.has_audio", source_clip->Reader()->info.has_audio, "source_frame->GetAudioChannelsCount()", source_frame->GetAudioChannelsCount(), "info.channels", info.channels, "clip_frame_number", clip_frame_number, "timeline_frame_number", timeline_frame_number); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (No Audio Copied - Wrong # of Channels)", "source_clip->Reader()->info.has_audio", source_clip->Reader()->info.has_audio, "source_frame->GetAudioChannelsCount()", source_frame->GetAudioChannelsCount(), "info.channels", info.channels, "clip_frame_number", clip_frame_number); } // Debug output @@ -753,7 +752,7 @@ std::shared_ptr Timeline::GetFrame(int64_t requested_frame) ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (Calculate clip's frame #)", "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, requested_frame, is_top_clip, max_volume); + add_layer(new_frame, clip, clip_frame_number, is_top_clip, max_volume); } else { // Debug output diff --git a/src/Timeline.h b/src/Timeline.h index 6329eb12..3b3b49c3 100644 --- a/src/Timeline.h +++ b/src/Timeline.h @@ -175,7 +175,7 @@ namespace openshot { int max_concurrent_frames; ///< Max concurrent frames to process at one time /// Process a new layer of video or audio - void add_layer(std::shared_ptr new_frame, openshot::Clip* source_clip, int64_t clip_frame_number, int64_t timeline_frame_number, bool is_top_clip, float max_volume); + void add_layer(std::shared_ptr new_frame, openshot::Clip* source_clip, int64_t clip_frame_number, bool is_top_clip, float max_volume); /// Apply a FrameMapper to a clip which matches the settings of this timeline void apply_mapper_to_clip(openshot::Clip* clip); diff --git a/src/TimelineBase.h b/src/TimelineBase.h index 307c18c2..6a8d0762 100644 --- a/src/TimelineBase.h +++ b/src/TimelineBase.h @@ -39,14 +39,12 @@ namespace openshot { * @brief This struct contains info about the current Timeline clip instance * * When the Timeline requests an openshot::Frame instance from a Clip, it passes - * this struct along, with some additional details from the Timeline, such as the absolute - * timeline frame number requested, and if this clip is above or below overlapping clips, etc... - * This info can help determine if a Clip should apply global effects from the Timeline, such - * as a global Transition/Mask effect. + * this struct along, with some additional details from the Timeline, such as if this clip is + * above or below overlapping clips, etc... This info can help determine if a Clip should apply + * global effects from the Timeline, such as a global Transition/Mask effect. */ struct TimelineInfoStruct { - int64_t timeline_frame_number; ///< The absolute frame number from the timeline we are requesting bool is_top_clip; ///< Is clip on top (if overlapping another clip) };