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 &&
|
||||
|
||||
Reference in New Issue
Block a user