diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-03-20 21:03:20 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-03-20 21:03:20 +0400 |
commit | 808ac6debf45952974c5723bf93a83b1107d6e61 (patch) | |
tree | 36cac1c201f137f373f03b8c626e8263bf26e507 /source/blender/editors/space_clip/space_clip.c | |
parent | 09a604561d39db04330da1c1833be3b6fa1329b6 (diff) |
Prefetching for movie clips
This commit basically implements frames prefetching for
movie clip datablock.
Number of frames to be prefetched is controlled in User
Preferences, System tab, Prefetch Frames option.
Currently prefetching is destructive-less for movie cache,
meaning mo frames will be removed from the cache when while
prefetching. This is because it's half of simplier to
implement, but it also makes sense from tracking point of
view -- we could want to playback in both directions and
removing frames from behind time cursor is not always a
good idea.
Anyway, smarter prefetching strategy could be developed
later.
Some implementation notes:
- Added MEM_CacheLimiter_get_memory_in_use function to get
memory usage of specified memory limiter.
- Fixed prototype of MEM_CacheLimiter_get_maximum which
was simply wrong (used wrong data type for output).
- Added some utility functions to movie clip and movie
cache for direct cache interaction and obtaining cache
statistics.
- Prefetching is implemented using general jobs system.
which is invoking from clip draw function.
- Prefetcing will stop as soon other job or playback starts.
This is done from performance point of view. Jobs will
likely require lots of CPU power and better to provide
whole CPU to it.
Playback is a bit more complicated case. For jpeg sequence
playback prefetching while paying back is nice. But trying
to prefetch heavy exr images and doing color space
conversion slows down both playback and prefetching.
TODO:
- Think of better policy of dealing with already cached frames
(like when cached frames from other clips prevents frames
from current clip to be prefetched)
- Currently a bit funky redraw notification happens from
prefetch job. Perhaps own ND_ is better to have here.
- Hiding clip while prefetch is active in theory shall stop
prefetching job.
- Having multiple clips opened on file load will prefetch
frames for only one of them.
Diffstat (limited to 'source/blender/editors/space_clip/space_clip.c')
-rw-r--r-- | source/blender/editors/space_clip/space_clip.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 4f9757a6640..ced19020034 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -236,6 +236,16 @@ static void clip_stabilization_tag_refresh(ScrArea *sa) } } +static void clip_prefetch_tag_refresh(ScrArea *sa) +{ + SpaceClip *sc = (SpaceClip *) sa->spacedata.first; + MovieClip *clip = ED_space_clip_get_clip(sc); + + if (clip) { + clip->prefetch_ok = FALSE; + } +} + /* ******************** default callbacks for clip space ***************** */ static SpaceLink *clip_new(const bContext *C) @@ -351,6 +361,7 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) switch (wmn->data) { case ND_FRAME: clip_scopes_tag_refresh(sa); + clip_prefetch_tag_refresh(sa); /* no break! */ case ND_FRAME_RANGE: @@ -359,11 +370,19 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_MOVIECLIP: + if (wmn->data == 0 && wmn->action == 0) { + /* a nit funky, happens from prefetch job to update + * cache line and job progress + */ + ED_area_tag_redraw(sa); + } + switch (wmn->data) { case ND_DISPLAY: case ND_SELECT: clip_scopes_tag_refresh(sa); ED_area_tag_redraw(sa); + clip_prefetch_tag_refresh(sa); break; } switch (wmn->action) { @@ -407,6 +426,7 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) case NC_SCREEN: switch (wmn->data) { case ND_ANIMPLAY: + clip_prefetch_tag_refresh(sa); ED_area_tag_redraw(sa); break; } @@ -415,6 +435,7 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) if (wmn->data == ND_SPACE_CLIP) { clip_scopes_tag_refresh(sa); clip_stabilization_tag_refresh(sa); + clip_prefetch_tag_refresh(sa); ED_area_tag_redraw(sa); } break; @@ -424,6 +445,10 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_redraw(sa); } break; + case NC_WM: + if (wmn->data == ND_FILEREAD) + clip_prefetch_tag_refresh(sa); + break; } } |