sequence encapsulation
This commit is contained in:
+16
-16
@@ -69,8 +69,8 @@ void apply_audio_effects(Clip* clip, double timecode_start, AVFrame* frame, int
|
||||
}
|
||||
if (clip->opening_transition != nullptr) {
|
||||
if (clip->media() != nullptr && clip->media()->get_type() == MEDIA_TYPE_FOOTAGE) {
|
||||
double transition_start = (clip->clip_in(true) / clip->track()->sequence()->frame_rate);
|
||||
double transition_end = (clip->clip_in(true) + clip->opening_transition->get_length()) / clip->track()->sequence()->frame_rate;
|
||||
double transition_start = (clip->clip_in(true) / clip->track()->sequence()->frame_rate());
|
||||
double transition_end = (clip->clip_in(true) + clip->opening_transition->get_length()) / clip->track()->sequence()->frame_rate();
|
||||
if (timecode_end < transition_end) {
|
||||
double adjustment = transition_end - transition_start;
|
||||
double adjusted_range_start = (timecode_start - transition_start) / adjustment;
|
||||
@@ -82,8 +82,8 @@ void apply_audio_effects(Clip* clip, double timecode_start, AVFrame* frame, int
|
||||
if (clip->closing_transition != nullptr) {
|
||||
if (clip->media() != nullptr && clip->media()->get_type() == MEDIA_TYPE_FOOTAGE) {
|
||||
long length_with_transitions = clip->timeline_out(true) - clip->timeline_in(true);
|
||||
double transition_start = (clip->clip_in(true) + length_with_transitions - clip->closing_transition->get_length()) / clip->track()->sequence()->frame_rate;
|
||||
double transition_end = (clip->clip_in(true) + length_with_transitions) / clip->track()->sequence()->frame_rate;
|
||||
double transition_start = (clip->clip_in(true) + length_with_transitions - clip->closing_transition->get_length()) / clip->track()->sequence()->frame_rate();
|
||||
double transition_end = (clip->clip_in(true) + length_with_transitions) / clip->track()->sequence()->frame_rate();
|
||||
if (timecode_start > transition_start) {
|
||||
double adjustment = transition_end - transition_start;
|
||||
double adjusted_range_start = (timecode_start - transition_start) / adjustment;
|
||||
@@ -97,7 +97,7 @@ void apply_audio_effects(Clip* clip, double timecode_start, AVFrame* frame, int
|
||||
Clip* next_nest = nests.last();
|
||||
nests.removeLast();
|
||||
apply_audio_effects(next_nest,
|
||||
timecode_start + (double(clip->timeline_in(true)-clip->clip_in(true))/clip->track()->sequence()->frame_rate),
|
||||
timecode_start + (double(clip->timeline_in(true)-clip->clip_in(true))/clip->track()->sequence()->frame_rate()),
|
||||
frame,
|
||||
nb_samples,
|
||||
nb_channels,
|
||||
@@ -127,16 +127,16 @@ void Cacher::CacheAudioWorker() {
|
||||
bool reverse_audio = IsReversed();
|
||||
|
||||
long frame_skip = 0;
|
||||
double last_fr = clip->track()->sequence()->frame_rate;
|
||||
double last_fr = clip->track()->sequence()->frame_rate();
|
||||
if (!nests_.isEmpty()) {
|
||||
for (int i=nests_.size()-1;i>=0;i--) {
|
||||
timeline_in = rescale_frame_number(timeline_in, last_fr, nests_.at(i)->track()->sequence()->frame_rate) + nests_.at(i)->timeline_in(true) - nests_.at(i)->clip_in(true);
|
||||
timeline_out = rescale_frame_number(timeline_out, last_fr, nests_.at(i)->track()->sequence()->frame_rate) + nests_.at(i)->timeline_in(true) - nests_.at(i)->clip_in(true);
|
||||
target_frame = rescale_frame_number(target_frame, last_fr, nests_.at(i)->track()->sequence()->frame_rate) + nests_.at(i)->timeline_in(true) - nests_.at(i)->clip_in(true);
|
||||
timeline_in = rescale_frame_number(timeline_in, last_fr, nests_.at(i)->track()->sequence()->frame_rate()) + nests_.at(i)->timeline_in(true) - nests_.at(i)->clip_in(true);
|
||||
timeline_out = rescale_frame_number(timeline_out, last_fr, nests_.at(i)->track()->sequence()->frame_rate()) + nests_.at(i)->timeline_in(true) - nests_.at(i)->clip_in(true);
|
||||
target_frame = rescale_frame_number(target_frame, last_fr, nests_.at(i)->track()->sequence()->frame_rate()) + nests_.at(i)->timeline_in(true) - nests_.at(i)->clip_in(true);
|
||||
|
||||
timeline_out = qMin(timeline_out, nests_.at(i)->timeline_out(true));
|
||||
|
||||
frame_skip = rescale_frame_number(frame_skip, last_fr, nests_.at(i)->track()->sequence()->frame_rate);
|
||||
frame_skip = rescale_frame_number(frame_skip, last_fr, nests_.at(i)->track()->sequence()->frame_rate());
|
||||
|
||||
long validator = nests_.at(i)->timeline_in(true) - timeline_in;
|
||||
if (validator > 0) {
|
||||
@@ -144,7 +144,7 @@ void Cacher::CacheAudioWorker() {
|
||||
//timeline_in = nests_.at(i)->timeline_in(true);
|
||||
}
|
||||
|
||||
last_fr = nests_.at(i)->track()->sequence()->frame_rate;
|
||||
last_fr = nests_.at(i)->track()->sequence()->frame_rate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,7 +405,7 @@ void Cacher::CacheAudioWorker() {
|
||||
apply_audio_effects(clip,
|
||||
samples_to_seconds(audio_buffer_write, 2, current_audio_freq())
|
||||
+ audio_ibuffer_timecode
|
||||
+ (double(clip->clip_in(true))/clip->track()->sequence()->frame_rate)
|
||||
+ (double(clip->clip_in(true))/clip->track()->sequence()->frame_rate())
|
||||
- (double(timeline_in)/last_fr),
|
||||
frame,
|
||||
nb_samples,
|
||||
@@ -418,7 +418,7 @@ void Cacher::CacheAudioWorker() {
|
||||
if (frame->nb_samples == 0) {
|
||||
break;
|
||||
} else {
|
||||
qint64 buffer_timeline_out = get_buffer_offset_from_frame(clip->track()->sequence()->frame_rate, timeline_out);
|
||||
qint64 buffer_timeline_out = get_buffer_offset_from_frame(clip->track()->sequence()->frame_rate(), timeline_out);
|
||||
|
||||
audio_write_lock.lock();
|
||||
|
||||
@@ -882,7 +882,7 @@ void Cacher::OpenWorker() {
|
||||
if (clip->type() == olive::kTypeAudio) {
|
||||
frame_ = av_frame_alloc();
|
||||
frame_->format = kDestSampleFmt;
|
||||
frame_->channel_layout = clip->track()->sequence()->audio_layout;
|
||||
frame_->channel_layout = clip->track()->sequence()->audio_layout();
|
||||
frame_->channels = av_get_channel_layout_nb_channels(frame_->channel_layout);
|
||||
frame_->sample_rate = current_audio_freq();
|
||||
frame_->nb_samples = 2048;
|
||||
@@ -1040,8 +1040,8 @@ void Cacher::OpenWorker() {
|
||||
|
||||
reverse_frame->format = kDestSampleFmt;
|
||||
reverse_frame->nb_samples = current_audio_freq()*10;
|
||||
reverse_frame->channel_layout = clip->track()->sequence()->audio_layout;
|
||||
reverse_frame->channels = av_get_channel_layout_nb_channels(clip->track()->sequence()->audio_layout);
|
||||
reverse_frame->channel_layout = clip->track()->sequence()->audio_layout();
|
||||
reverse_frame->channels = av_get_channel_layout_nb_channels(clip->track()->sequence()->audio_layout());
|
||||
av_frame_get_buffer(reverse_frame, 0);
|
||||
|
||||
queue_.append(reverse_frame);
|
||||
|
||||
@@ -192,16 +192,16 @@ bool ExportThread::SetupVideo() {
|
||||
video_frame = av_frame_alloc();
|
||||
av_frame_make_writable(video_frame);
|
||||
video_frame->format = AV_PIX_FMT_RGBA;
|
||||
video_frame->width = params_.sequence->width;
|
||||
video_frame->height = params_.sequence->height;
|
||||
video_frame->width = params_.sequence->width();
|
||||
video_frame->height = params_.sequence->height();
|
||||
av_frame_get_buffer(video_frame, 0);
|
||||
|
||||
av_init_packet(&video_pkt);
|
||||
|
||||
// Set up conversion context
|
||||
sws_ctx = sws_getContext(
|
||||
params_.sequence->width,
|
||||
params_.sequence->height,
|
||||
params_.sequence->width(),
|
||||
params_.sequence->height(),
|
||||
AV_PIX_FMT_RGBA,
|
||||
params_.video_width,
|
||||
params_.video_height,
|
||||
@@ -288,7 +288,7 @@ bool ExportThread::SetupAudio() {
|
||||
acodec_ctx->channel_layout,
|
||||
acodec_ctx->sample_fmt,
|
||||
acodec_ctx->sample_rate,
|
||||
params_.sequence->audio_layout,
|
||||
params_.sequence->audio_layout(),
|
||||
AV_SAMPLE_FMT_S16,
|
||||
acodec_ctx->sample_rate,
|
||||
0,
|
||||
@@ -449,7 +449,7 @@ void ExportThread::Export()
|
||||
}
|
||||
|
||||
// Get the current sequence playhead in seconds (used for timestamp calculations later on)
|
||||
double timecode_secs = double(params_.sequence->playhead - params_.start_frame) / params_.sequence->frame_rate;
|
||||
double timecode_secs = double(params_.sequence->playhead - params_.start_frame) / params_.sequence->frame_rate();
|
||||
|
||||
// If we're exporting video, construct an AVFrame in the destination codec's pixel format to convert the raw RGBA
|
||||
// OpenGL buffer to
|
||||
|
||||
@@ -236,7 +236,7 @@ GLuint olive::rendering::compose_sequence(ComposeSequenceParams ¶ms) {
|
||||
for (int i=0;i<params.nests.size();i++) {
|
||||
s = params.nests.at(i)->media()->to_sequence().get();
|
||||
playhead += params.nests.at(i)->clip_in(true) - params.nests.at(i)->timeline_in(true);
|
||||
playhead = rescale_frame_number(playhead, params.nests.at(i)->track()->sequence()->frame_rate, s->frame_rate);
|
||||
playhead = rescale_frame_number(playhead, params.nests.at(i)->track()->sequence()->frame_rate(), s->frame_rate());
|
||||
}
|
||||
|
||||
if (params.type == olive::kTypeVideo && !params.nests.last()->fbo.isEmpty()) {
|
||||
@@ -348,8 +348,8 @@ GLuint olive::rendering::compose_sequence(ComposeSequenceParams ¶ms) {
|
||||
|
||||
params.ctx->functions()->glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
int half_width = s->width/2;
|
||||
int half_height = s->height/2;
|
||||
int half_width = s->width()/2;
|
||||
int half_height = s->height()/2;
|
||||
|
||||
projection.ortho(-half_width, half_width, -half_height, half_height, -1, 1);
|
||||
}
|
||||
@@ -540,10 +540,10 @@ GLuint olive::rendering::compose_sequence(ComposeSequenceParams ¶ms) {
|
||||
|
||||
// Check whether the parent clip is auto-scaled
|
||||
if (c->autoscaled()
|
||||
&& (video_width != s->width
|
||||
&& video_height != s->height)) {
|
||||
float width_multiplier = float(s->width) / float(video_width);
|
||||
float height_multiplier = float(s->height) / float(video_height);
|
||||
&& (video_width != s->width()
|
||||
&& video_height != s->height())) {
|
||||
float width_multiplier = float(s->width()) / float(video_width);
|
||||
float height_multiplier = float(s->height()) / float(video_height);
|
||||
float scale_multiplier = qMin(width_multiplier, height_multiplier);
|
||||
|
||||
coords.matrix.scale(scale_multiplier, scale_multiplier);
|
||||
@@ -563,7 +563,7 @@ GLuint olive::rendering::compose_sequence(ComposeSequenceParams ¶ms) {
|
||||
if (textureID > 0) {
|
||||
|
||||
// set viewport to sequence size
|
||||
params.ctx->functions()->glViewport(0, 0, s->width, s->height);
|
||||
params.ctx->functions()->glViewport(0, 0, s->width(), s->height());
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -76,29 +76,29 @@ void RenderThread::run() {
|
||||
ctx->makeCurrent(&surface);
|
||||
|
||||
// if the sequence size has changed, we'll need to reinitialize the textures
|
||||
if (seq->width != tex_width || seq->height != tex_height) {
|
||||
if (seq->width() != tex_width || seq->height() != tex_height) {
|
||||
delete_buffers();
|
||||
|
||||
// cache sequence values for future checks
|
||||
tex_width = seq->width;
|
||||
tex_height = seq->height;
|
||||
tex_width = seq->width();
|
||||
tex_height = seq->height();
|
||||
}
|
||||
|
||||
// create any buffers that don't yet exist
|
||||
if (!composite_buffer.IsCreated()) {
|
||||
composite_buffer.Create(ctx, seq->width, seq->height);
|
||||
composite_buffer.Create(ctx, seq->width(), seq->height());
|
||||
}
|
||||
if (!front_buffer_1.IsCreated()) {
|
||||
front_buffer_1.Create(ctx, seq->width, seq->height);
|
||||
front_buffer_1.Create(ctx, seq->width(), seq->height());
|
||||
}
|
||||
if (!front_buffer_2.IsCreated()) {
|
||||
front_buffer_2.Create(ctx, seq->width, seq->height);
|
||||
front_buffer_2.Create(ctx, seq->width(), seq->height());
|
||||
}
|
||||
if (!back_buffer_1.IsCreated()) {
|
||||
back_buffer_1.Create(ctx, seq->width, seq->height);
|
||||
back_buffer_1.Create(ctx, seq->width(), seq->height());
|
||||
}
|
||||
if (!back_buffer_2.IsCreated()) {
|
||||
back_buffer_2.Create(ctx, seq->width, seq->height);
|
||||
back_buffer_2.Create(ctx, seq->width(), seq->height());
|
||||
}
|
||||
|
||||
// If there's no pipeline shader, create it now
|
||||
|
||||
Reference in New Issue
Block a user