Skip to content

Commit a505f87

Browse files
committed
Refactoring timeline_frame_number out of apply_layer() and TimelineInfoStruct, we already have this data in scope (on the background frame instance)
1 parent 441cb18 commit a505f87

File tree

5 files changed

+12
-17
lines changed

5 files changed

+12
-17
lines changed

src/Clip.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,9 @@ std::shared_ptr<Frame> Clip::GetFrame(std::shared_ptr<openshot::Frame> backgroun
394394
// Apply global timeline effects (i.e. transitions & masks... if any)
395395
if (timeline != NULL && options != NULL) {
396396
if (options->is_top_clip) {
397-
// Apply global timeline effects (only to top clip... if overlapping)
397+
// Apply global timeline effects (only to top clip... if overlapping, pass in timeline frame number)
398398
Timeline* timeline_instance = (Timeline*) timeline;
399-
original_frame = timeline_instance->apply_effects(original_frame, options->timeline_frame_number, Layer());
399+
original_frame = timeline_instance->apply_effects(original_frame, background_frame->number, Layer());
400400
}
401401
}
402402

src/Clip.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ namespace openshot {
164164
void reverse_buffer(juce::AudioSampleBuffer* buffer);
165165

166166

167-
168167
public:
169168
openshot::GravityType gravity; ///< The gravity of a clip determines where it snaps to its parent
170169
openshot::ScaleType scale; ///< The scale determines how a clip should be resized to fit its parent
@@ -244,8 +243,7 @@ namespace openshot {
244243
/// @param frame_number The frame number (starting at 1) of the clip on the timeline. The image size and number
245244
/// of samples match the timeline.
246245
/// @param options The openshot::TimelineInfoStruct pointer, with more details about this specific timeline clip,
247-
/// such as, if it's a top clip, and what the absolute timeline frame number is. This info is used to apply global
248-
/// transitions and masks, if needed.
246+
/// such as, if it's a top clip. This info is used to apply global transitions and masks, if needed.
249247
std::shared_ptr<openshot::Frame> GetFrame(std::shared_ptr<openshot::Frame> background_frame, int64_t frame_number, openshot::TimelineInfoStruct* options);
250248

251249
/// Open the internal reader

src/Timeline.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,11 +475,10 @@ std::shared_ptr<Frame> Timeline::GetOrCreateFrame(std::shared_ptr<Frame> backgro
475475
}
476476

477477
// Process a new layer of video or audio
478-
void Timeline::add_layer(std::shared_ptr<Frame> new_frame, Clip* source_clip, int64_t clip_frame_number, int64_t timeline_frame_number, bool is_top_clip, float max_volume)
478+
void Timeline::add_layer(std::shared_ptr<Frame> new_frame, Clip* source_clip, int64_t clip_frame_number, bool is_top_clip, float max_volume)
479479
{
480480
// Create timeline options (with details about this current frame request)
481481
TimelineInfoStruct* options = new TimelineInfoStruct();
482-
options->timeline_frame_number = timeline_frame_number;
483482
options->is_top_clip = is_top_clip;
484483

485484
// Get the clip's frame, composited on top of the current timeline frame
@@ -492,12 +491,12 @@ void Timeline::add_layer(std::shared_ptr<Frame> new_frame, Clip* source_clip, in
492491
return;
493492

494493
// Debug output
495-
ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer", "new_frame->number", new_frame->number, "clip_frame_number", clip_frame_number, "timeline_frame_number", timeline_frame_number);
494+
ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer", "new_frame->number", new_frame->number, "clip_frame_number", clip_frame_number);
496495

497496
/* COPY AUDIO - with correct volume */
498497
if (source_clip->Reader()->info.has_audio) {
499498
// Debug output
500-
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);
499+
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);
501500

502501
if (source_frame->GetAudioChannelsCount() == info.channels && source_clip->has_audio.GetInt(clip_frame_number) != 0)
503502
for (int channel = 0; channel < source_frame->GetAudioChannelsCount(); channel++)
@@ -550,7 +549,7 @@ void Timeline::add_layer(std::shared_ptr<Frame> new_frame, Clip* source_clip, in
550549
}
551550
else
552551
// Debug output
553-
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);
552+
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);
554553
}
555554

556555
// Debug output
@@ -753,7 +752,7 @@ std::shared_ptr<Frame> Timeline::GetFrame(int64_t requested_frame)
753752
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);
754753

755754
// Add clip's frame as layer
756-
add_layer(new_frame, clip, clip_frame_number, requested_frame, is_top_clip, max_volume);
755+
add_layer(new_frame, clip, clip_frame_number, is_top_clip, max_volume);
757756

758757
} else {
759758
// Debug output

src/Timeline.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ namespace openshot {
175175
int max_concurrent_frames; ///< Max concurrent frames to process at one time
176176

177177
/// Process a new layer of video or audio
178-
void add_layer(std::shared_ptr<openshot::Frame> new_frame, openshot::Clip* source_clip, int64_t clip_frame_number, int64_t timeline_frame_number, bool is_top_clip, float max_volume);
178+
void add_layer(std::shared_ptr<openshot::Frame> new_frame, openshot::Clip* source_clip, int64_t clip_frame_number, bool is_top_clip, float max_volume);
179179

180180
/// Apply a FrameMapper to a clip which matches the settings of this timeline
181181
void apply_mapper_to_clip(openshot::Clip* clip);

src/TimelineBase.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,12 @@ namespace openshot {
3939
* @brief This struct contains info about the current Timeline clip instance
4040
*
4141
* When the Timeline requests an openshot::Frame instance from a Clip, it passes
42-
* this struct along, with some additional details from the Timeline, such as the absolute
43-
* timeline frame number requested, and if this clip is above or below overlapping clips, etc...
44-
* This info can help determine if a Clip should apply global effects from the Timeline, such
45-
* as a global Transition/Mask effect.
42+
* this struct along, with some additional details from the Timeline, such as if this clip is
43+
* above or below overlapping clips, etc... This info can help determine if a Clip should apply
44+
* global effects from the Timeline, such as a global Transition/Mask effect.
4645
*/
4746
struct TimelineInfoStruct
4847
{
49-
int64_t timeline_frame_number; ///< The absolute frame number from the timeline we are requesting
5048
bool is_top_clip; ///< Is clip on top (if overlapping another clip)
5149
};
5250

0 commit comments

Comments
 (0)