From a010d97204558e795e323a014fccca1f5a7c59c7 Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Fri, 7 Feb 2020 23:49:37 +0100 Subject: Cleanup: remove old VSE prefetching code. Reviewed By: brecht Differential Revision: https://developer.blender.org/D6774 --- source/blender/blenkernel/intern/sequencer.c | 140 --------------------------- 1 file changed, 140 deletions(-) (limited to 'source/blender/blenkernel/intern/sequencer.c') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 747ce18cada..4dc2177ec75 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -4147,146 +4147,6 @@ ImBuf *BKE_sequencer_give_ibuf_direct(const SeqRenderData *context, float cfra, return ibuf; } -/* *********************** threading api ******************* */ - -static ListBase running_threads; -static ListBase prefetch_wait; -static ListBase prefetch_done; - -static pthread_mutex_t queue_lock = PTHREAD_MUTEX_INITIALIZER; -static pthread_mutex_t wakeup_lock = PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t wakeup_cond = PTHREAD_COND_INITIALIZER; - -// static pthread_mutex_t prefetch_ready_lock = PTHREAD_MUTEX_INITIALIZER; -// static pthread_cond_t prefetch_ready_cond = PTHREAD_COND_INITIALIZER; - -static pthread_mutex_t frame_done_lock = PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t frame_done_cond = PTHREAD_COND_INITIALIZER; - -static volatile bool seq_thread_shutdown = true; -static volatile int seq_last_given_monoton_cfra = 0; -static int monoton_cfra = 0; - -typedef struct PrefetchThread { - struct PrefetchThread *next, *prev; - - Scene *scene; - struct PrefetchQueueElem *current; - pthread_t pthread; - int running; - -} PrefetchThread; - -typedef struct PrefetchQueueElem { - struct PrefetchQueueElem *next, *prev; - - int rectx; - int recty; - float cfra; - int chanshown; - int preview_render_size; - - int monoton_cfra; - - ImBuf *ibuf; -} PrefetchQueueElem; - -void BKE_sequencer_give_ibuf_prefetch_request(const SeqRenderData *context, - float cfra, - int chanshown) -{ - PrefetchQueueElem *e; - if (seq_thread_shutdown) { - return; - } - - e = MEM_callocN(sizeof(PrefetchQueueElem), "prefetch_queue_elem"); - e->rectx = context->rectx; - e->recty = context->recty; - e->cfra = cfra; - e->chanshown = chanshown; - e->preview_render_size = context->preview_render_size; - e->monoton_cfra = monoton_cfra++; - - pthread_mutex_lock(&queue_lock); - BLI_addtail(&prefetch_wait, e); - pthread_mutex_unlock(&queue_lock); - - pthread_mutex_lock(&wakeup_lock); - pthread_cond_signal(&wakeup_cond); - pthread_mutex_unlock(&wakeup_lock); -} - -ImBuf *BKE_sequencer_give_ibuf_threaded(const SeqRenderData *context, float cfra, int chanshown) -{ - PrefetchQueueElem *e = NULL; - bool found_something = false; - - if (seq_thread_shutdown) { - return BKE_sequencer_give_ibuf(context, cfra, chanshown); - } - - while (!e) { - bool success = false; - pthread_mutex_lock(&queue_lock); - - for (e = prefetch_done.first; e; e = e->next) { - if (cfra == e->cfra && chanshown == e->chanshown && context->rectx == e->rectx && - context->recty == e->recty && context->preview_render_size == e->preview_render_size) { - success = true; - found_something = true; - break; - } - } - - if (!e) { - for (e = prefetch_wait.first; e; e = e->next) { - if (cfra == e->cfra && chanshown == e->chanshown && context->rectx == e->rectx && - context->recty == e->recty && context->preview_render_size == e->preview_render_size) { - found_something = true; - break; - } - } - } - - if (!e) { - PrefetchThread *tslot; - - for (tslot = running_threads.first; tslot; tslot = tslot->next) { - if (tslot->current && cfra == tslot->current->cfra && - chanshown == tslot->current->chanshown && context->rectx == tslot->current->rectx && - context->recty == tslot->current->recty && - context->preview_render_size == tslot->current->preview_render_size) { - found_something = true; - break; - } - } - } - - /* e->ibuf is unrefed by render thread on next round. */ - - if (e) { - seq_last_given_monoton_cfra = e->monoton_cfra; - } - - pthread_mutex_unlock(&queue_lock); - - if (!success) { - e = NULL; - - if (!found_something) { - fprintf(stderr, "SEQ-THREAD: Requested frame not in queue ???\n"); - break; - } - pthread_mutex_lock(&frame_done_lock); - pthread_cond_wait(&frame_done_cond, &frame_done_lock); - pthread_mutex_unlock(&frame_done_lock); - } - } - - return e ? e->ibuf : NULL; -} - /* check whether sequence cur depends on seq */ bool BKE_sequence_check_depend(Sequence *seq, Sequence *cur) { -- cgit v1.2.3