committing before playback rewrite

This commit is contained in:
itsmattkc
2018-10-13 19:58:19 +11:00
parent a285f10e6a
commit 2be02c29a8
4 changed files with 145 additions and 141 deletions
+8 -2
View File
@@ -453,6 +453,11 @@ void reset_cache(Clip* c, long target_frame) {
qDebug() << "flushed?";
av_frame_unref(temp);
}*/
/*av_buffersrc_add_frame(c->buffersrc_ctx, NULL);
av_frame_unref(c->frame);
while (av_buffersink_get_frame(c->buffersink_ctx, c->frame) >= 0) {
av_frame_unref(c->frame);
}*/
double timebase = av_q2d(c->stream->time_base);
@@ -462,7 +467,8 @@ void reset_cache(Clip* c, long target_frame) {
// seeks to nearest keyframe (target_frame represents internal clip frame)
int64_t seek_ts = qRound(clip_frame_to_seconds(c, target_frame) / timebase);
av_seek_frame(c->formatCtx, ms->file_index, seek_ts/* - (av_q2d(av_inv_q(c->stream->time_base)))*/, AVSEEK_FLAG_BACKWARD);
qDebug() << "requesting: " << seek_ts;
av_seek_frame(c->formatCtx, ms->file_index, seek_ts, AVSEEK_FLAG_BACKWARD);
// play up to the frame we actually want
int ret;
@@ -476,7 +482,7 @@ void reset_cache(Clip* c, long target_frame) {
av_frame_unref(temp);
av_frame_free(&temp);
} else {
av_seek_frame(c->formatCtx, ms->file_index, c->stream->start_time, AVSEEK_FLAG_BACKWARD);
av_seek_frame(c->formatCtx, ms->file_index, 0, AVSEEK_FLAG_BACKWARD);
}
} else if (c->stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
// seek (target_frame represents timeline timecode in frames, not clip timecode)
+8 -14
View File
@@ -145,26 +145,20 @@ bool get_clip_frame(Clip* c, long playhead) {
// TODO just removed a bunch of mutexes - is this safe????
if (c->cache_A.written && clip_time >= c->cache_A.offset && clip_time < c->cache_A.offset + c->cache_size) {
if (clip_time < (c->cache_A.offset + c->cache_A.write_count)) {
// if (c->cache_A.mutex.tryLock()) { // lock in case cacher is still writing to it
using_cache_A = true;
c->cache_A.unread = false;
cache = c->cache_A.frames;
cache_offset = c->cache_A.offset;
// c->cache_A.mutex.unlock();
// }
using_cache_A = true;
c->cache_A.unread = false;
cache = c->cache_A.frames;
cache_offset = c->cache_A.offset;
} else {
// frame is coming but isn't here yet, no need to reset cache
no_frame = true;
}
} else if (c->cache_B.written && clip_time >= c->cache_B.offset && clip_time < c->cache_B.offset + c->cache_size) {
if (clip_time < (c->cache_B.offset + c->cache_B.write_count)) {
// if (c->cache_B.mutex.tryLock()) { // lock in case cacher is still writing to it
using_cache_B = true;
c->cache_B.unread = false;
cache = c->cache_B.frames;
cache_offset = c->cache_B.offset;
// c->cache_B.mutex.unlock();
// }
using_cache_B = true;
c->cache_B.unread = false;
cache = c->cache_B.frames;
cache_offset = c->cache_B.offset;
} else {
// frame is coming but isn't here yet, no need to reset cache
no_frame = true;