various improvements
This commit is contained in:
+12
-7
@@ -206,7 +206,7 @@ void cache_video_worker(Clip* c, long playhead, ClipCache* cache) {
|
||||
|
||||
int i = 0;
|
||||
|
||||
double fr_ratio = qRound((c->sequence->frame_rate / c->frame_rate)*100)*0.01;
|
||||
// double fr_ratio = c->sequence->frame_rate / c->frame_rate;
|
||||
|
||||
/* old swscale solution
|
||||
if (!c->reached_end) {
|
||||
@@ -231,17 +231,20 @@ void cache_video_worker(Clip* c, long playhead, ClipCache* cache) {
|
||||
|
||||
if (ret >= 0) {
|
||||
// optimization: mathematically determine based on the sequence and clips' frame rates whether this frame will actually be shown
|
||||
double timeline_frame = (i+cache->offset) * fr_ratio;
|
||||
// note: is not actually much faster and currently leads to crashes, may remove in the future
|
||||
// int proposed_frame = qFloor((i+cache->offset) * fr_ratio);
|
||||
|
||||
if (qFloor(timeline_frame) == timeline_frame) {
|
||||
// if (proposed_frame != c->last_cached_frame) {
|
||||
if ((ret = av_buffersrc_add_frame_flags(c->buffersrc_ctx, c->frame, AV_BUFFERSRC_FLAG_KEEP_REF)) < 0) {
|
||||
qDebug() << "[ERROR] Could not feed filtergraph -" << ret;
|
||||
error = true;
|
||||
break;
|
||||
// } else {
|
||||
// c->last_cached_frame = proposed_frame;
|
||||
}
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
// } else {
|
||||
// i++;
|
||||
// }
|
||||
} else {
|
||||
if (ret == AVERROR_EOF) {
|
||||
c->reached_end = true;
|
||||
@@ -306,6 +309,8 @@ void reset_cache(Clip* c, long target_frame) {
|
||||
} while (retrieved_frame < target_frame);
|
||||
|
||||
av_frame_free(&temp);
|
||||
|
||||
c->last_cached_frame = -1;
|
||||
} else if (c->stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||
// seek (target_frame represents timeline timecode in frames, not clip timecode)
|
||||
swr_drop_output(c->swr_ctx, swr_get_out_samples(c->swr_ctx, 0));
|
||||
@@ -367,7 +372,7 @@ void open_clip_worker(Clip* clip) {
|
||||
|
||||
AVDictionary* opts = NULL;
|
||||
|
||||
// decoding optimization configuration
|
||||
// optimized decoding settings
|
||||
if (clip->stream->codecpar->codec_id != AV_CODEC_ID_PNG &&
|
||||
clip->stream->codecpar->codec_id != AV_CODEC_ID_APNG &&
|
||||
clip->stream->codecpar->codec_id != AV_CODEC_ID_TIFF &&
|
||||
|
||||
+6
-13
@@ -36,12 +36,7 @@ void open_clip(Clip* clip, bool multithreaded) {
|
||||
// maybe keep cacher instance in memory while clip exists for performance?
|
||||
clip->cacher = new Cacher(clip);
|
||||
QObject::connect(clip->cacher, SIGNAL(finished()), clip->cacher, SLOT(deleteLater()));
|
||||
|
||||
if (clip->track < 0) {
|
||||
clip->cacher->start(QThread::LowPriority);
|
||||
} else {
|
||||
clip->cacher->start(QThread::TimeCriticalPriority);
|
||||
}
|
||||
clip->cacher->start((clip->track < 0) ? QThread::LowPriority : QThread::TimeCriticalPriority);
|
||||
}
|
||||
} else {
|
||||
clip->finished_opening = false;
|
||||
@@ -114,11 +109,6 @@ bool get_clip_frame(Clip* c, long playhead) {
|
||||
// do we need to update the texture?
|
||||
MediaStream* ms = static_cast<Media*>(c->media)->get_stream_from_file_index(c->track < 0, c->media_stream);
|
||||
|
||||
// backwards compatibilty code
|
||||
if (c->frame_rate == 0) {
|
||||
c->frame_rate = ms->video_frame_rate;
|
||||
}
|
||||
|
||||
long sequence_clip_time = playhead - c->timeline_in + c->clip_in;
|
||||
long clip_time = refactor_frame_number(sequence_clip_time, c->sequence->frame_rate, c->frame_rate);
|
||||
|
||||
@@ -286,7 +276,10 @@ void retrieve_next_frame_raw_data(Clip* c, AVFrame* output) {
|
||||
// output->pts = c->frame->best_effort_timestamp;
|
||||
} else if (c->stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||
output->pts = c->frame->pts;
|
||||
ret = swr_convert_frame(c->swr_ctx, output, c->frame);
|
||||
ret = swr_convert_frame(c->swr_ctx, output, c->frame);
|
||||
|
||||
|
||||
|
||||
if (ret < 0) {
|
||||
qDebug() << "[ERROR] Failed to resample audio." << ret;
|
||||
}
|
||||
@@ -303,7 +296,7 @@ bool is_clip_active(Clip* c, long playhead) {
|
||||
return c->enabled
|
||||
&& c->timeline_in < playhead + ceil(c->sequence->frame_rate)
|
||||
&& c->timeline_out > playhead
|
||||
&& playhead - c->timeline_in + c->clip_in < c->getMediaLength(c->sequence->frame_rate);
|
||||
&& playhead - c->timeline_in + c->clip_in < c->getMaximumLength();
|
||||
}
|
||||
|
||||
void set_sequence(Sequence* s) {
|
||||
|
||||
Reference in New Issue
Block a user