diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-04-04 13:50:38 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-04-04 13:50:38 +0400 |
commit | 845aea6864cf4b3aa34d7676f725ab268465e34f (patch) | |
tree | c8c9c04cc8b4d5053e41ce438ae4cf9723a153b0 /source/blender/editors/space_clip/clip_editor.c | |
parent | ef1af9f9c41a9cb33550bcaf396023ff840a3dab (diff) |
Clip editor prefetch changes
Made it an operator instead of automatic prefetching.
Filling the whole memory with frames is not always
desired behavior.
Now prefetching is available via P-key, or from Clip
panel in toolbox or from Clip menu.
Also enabled prefetching for non-proxied movies.
Diffstat (limited to 'source/blender/editors/space_clip/clip_editor.c')
-rw-r--r-- | source/blender/editors/space_clip/clip_editor.c | 61 |
1 files changed, 7 insertions, 54 deletions
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index d297d0485e3..b3b6251645c 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -605,26 +605,9 @@ typedef struct PrefetchThread { } PrefetchThread; /* check whether pre-fetching is allowed */ -static bool check_prefetch_allowed(void) +static bool check_prefetch_break(void) { - wmWindowManager *wm; - - /* if there's any job started, better to leave all CPU and - * HDD bandwidth to it - * - * also, display transform could be needed during playback, - * so better to avoid prefetching in this case and reserve - * all the power for display transform - */ - for (wm = G.main->wm.first; wm; wm = wm->id.next) { - if (WM_jobs_has_running_except(wm, WM_JOB_TYPE_CLIP_PREFETCH)) - return false; - - if (ED_screen_animation_playing(wm)) - return false; - } - - return true; + return G.is_break; } /* read file for specified frame number to the memory */ @@ -706,7 +689,7 @@ static unsigned char *prefetch_thread_next_frame(PrefetchQueue *queue, MovieClip unsigned char *mem = NULL; BLI_spin_lock(&queue->spin); - if (!*queue->stop && check_prefetch_allowed() && + if (!*queue->stop && !check_prefetch_break() && IN_RANGE_INCL(queue->current_frame, queue->start_frame, queue->end_frame)) { int current_frame; @@ -848,7 +831,7 @@ static bool prefetch_movie_frame(MovieClip *clip, int frame, short render_size, MovieClipUser user = {0}; ImBuf *ibuf; - if (!check_prefetch_allowed() || *stop) + if (check_prefetch_break() || *stop) return false; user.framenr = frame; @@ -968,26 +951,6 @@ static bool prefetch_check_early_out(const bContext *C) int first_uncached_frame, end_frame; int clip_len; - if (clip->prefetch_ok) - return true; - - if (clip->source == MCLIP_SRC_MOVIE) { - /* for movies we only prefetch undistorted proxy, - * in other cases prefetching could lead to issues - * due to timecodes issues. - */ - - if (clip->flag & MCLIP_USE_PROXY) { - MovieClipUser *user = &sc->user; - - if ((user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT) == 0) - return true; - } - else { - return true; - } - } - clip_len = BKE_movieclip_get_duration(clip); /* check whether all the frames from prefetch range are cached */ @@ -1016,7 +979,6 @@ void clip_start_prefetch_job(const bContext *C) wmJob *wm_job; PrefetchJob *pj; SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip_get_clip(sc); if (prefetch_check_early_out(C)) return; @@ -1024,17 +986,6 @@ void clip_start_prefetch_job(const bContext *C) wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), CTX_wm_area(C), "Prefetching", WM_JOB_PROGRESS, WM_JOB_TYPE_CLIP_PREFETCH); - if (WM_jobs_is_running(wm_job)) { - /* if job is already running, it'll call clip editor redraw when - * it's finished, so cache line is nicely updated - * this will also trigger call of this function, which will ensure - * all needed frames are prefetched - */ - return; - } - - clip->prefetch_ok = true; - /* create new job */ pj = MEM_callocN(sizeof(PrefetchJob), "prefetch job"); pj->clip = ED_space_clip_get_clip(sc); @@ -1045,9 +996,11 @@ void clip_start_prefetch_job(const bContext *C) pj->render_flag = sc->user.render_flag; WM_jobs_customdata_set(wm_job, pj, prefetch_freejob); - WM_jobs_timer(wm_job, 0.2, NC_MOVIECLIP, 0); + WM_jobs_timer(wm_job, 0.2, NC_MOVIECLIP | ND_DISPLAY, 0); WM_jobs_callbacks(wm_job, prefetch_startjob, NULL, NULL, NULL); + G.is_break = FALSE; + /* and finally start the job */ WM_jobs_start(CTX_wm_manager(C), wm_job); } |