[Bf-blender-cvs] [df171bf8bc1] soc-2021-vse-strip-thumbnails: Thumbnail Caching
Aditya Y Jeppu
noreply at git.blender.org
Sat Jun 19 19:23:40 CEST 2021
Commit: df171bf8bc13ea8c3c1d59451d5cd9516fa349fb
Author: Aditya Y Jeppu
Date: Sat Jun 19 22:47:00 2021 +0530
Branches: soc-2021-vse-strip-thumbnails
https://developer.blender.org/rBdf171bf8bc13ea8c3c1d59451d5cd9516fa349fb
Thumbnail Caching
The caching code is updated to allow for separate thumbnail storage. The size
is taken as 0.25*render size as of now. flag set up to control when to store
thumbs. Image scaling done in preprocess stage using already present code for
crop and transform.
===================================================================
M source/blender/editors/space_sequencer/sequencer_draw.c
M source/blender/makesdna/DNA_sequence_types.h
M source/blender/sequencer/SEQ_render.h
M source/blender/sequencer/intern/image_cache.c
M source/blender/sequencer/intern/render.c
===================================================================
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index b64e739c289..61c42e228d1 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -1115,8 +1115,8 @@ static void draw_seq_strip_thumbnail(View2D *v2d,
render_size = SEQ_rendersize_to_scale_factor(sseq->render_size);
}
- rectx = roundf(render_size * scene->r.xsch);
- recty = roundf(render_size * scene->r.ysch);
+ rectx = roundf(render_size * 0.25 * scene->r.xsch);
+ recty = roundf(render_size * 0.25 * scene->r.ysch);
/* if thumbs too small ignore */
min_size = ((y2 - y1) / pixely) > 40 * U.dpi_fac;
@@ -1130,20 +1130,19 @@ static void draw_seq_strip_thumbnail(View2D *v2d,
context.use_proxies = false;
context.is_prefetch_render = false;
context.is_proxy_render = false;
+ context.is_thumb = true;
/*Calculate thumb dimensions */
float thumb_h = (SEQ_STRIP_OFSTOP - SEQ_STRIP_OFSBOTTOM) - (20 * U.dpi_fac * pixely);
- float aspect_ratio = ((float)scene->r.xsch) / scene->r.ysch;
+ float aspect_ratio = ((float)rectx) / recty;
float thumb_h_px = thumb_h / pixely;
float thumb_w = aspect_ratio * thumb_h_px * pixelx;
- float zoom_x = thumb_w / scene->r.xsch;
- float zoom_y = thumb_h / scene->r.ysch;
+ float zoom_x = thumb_w / rectx;
+ float zoom_y = thumb_h / recty;
y2 = y1 + thumb_h - pixely;
x1 = seq->start;
- // TODO(AYJ) : add x1 = x1 + handsize_clamped
-
int frame_factor = 0;
float cut_off = 0;
float upper_thumb_bound = strip_x2 - handsize_clamped;
@@ -1175,7 +1174,7 @@ static void draw_seq_strip_thumbnail(View2D *v2d,
/* clip if full thumbnail cannot be displayed */
if (x2 >= (upper_thumb_bound - 1)) {
x2 = (upper_thumb_bound - 1);
- if (x2 - x1 < 4)
+ if (x2 - x1 < 1)
break;
}
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index 59b153397c1..008c9b2f249 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -691,22 +691,22 @@ enum {
SEQ_CACHE_STORE_PREPROCESSED = (1 << 1),
SEQ_CACHE_STORE_COMPOSITE = (1 << 2),
SEQ_CACHE_STORE_FINAL_OUT = (1 << 3),
+ SEQ_CACHE_STORE_THUMBNAIL = (1 << 4),
/* For lookup purposes */
- SEQ_CACHE_ALL_TYPES = SEQ_CACHE_STORE_RAW | SEQ_CACHE_STORE_PREPROCESSED |
- SEQ_CACHE_STORE_COMPOSITE | SEQ_CACHE_STORE_FINAL_OUT,
+ SEQ_CACHE_ALL_TYPES = SEQ_CACHE_STORE_RAW | SEQ_CACHE_STORE_PREPROCESSED | SEQ_CACHE_STORE_COMPOSITE | SEQ_CACHE_STORE_FINAL_OUT,
- SEQ_CACHE_OVERRIDE = (1 << 4),
+ SEQ_CACHE_OVERRIDE = (1 << 5),
/* enable cache visualization overlay in timeline UI */
- SEQ_CACHE_VIEW_ENABLE = (1 << 5),
- SEQ_CACHE_VIEW_RAW = (1 << 6),
- SEQ_CACHE_VIEW_PREPROCESSED = (1 << 7),
- SEQ_CACHE_VIEW_COMPOSITE = (1 << 8),
- SEQ_CACHE_VIEW_FINAL_OUT = (1 << 9),
-
- SEQ_CACHE_PREFETCH_ENABLE = (1 << 10),
- SEQ_CACHE_DISK_CACHE_ENABLE = (1 << 11),
+ SEQ_CACHE_VIEW_ENABLE = (1 << 6),
+ SEQ_CACHE_VIEW_RAW = (1 << 7),
+ SEQ_CACHE_VIEW_PREPROCESSED = (1 << 8),
+ SEQ_CACHE_VIEW_COMPOSITE = (1 << 9),
+ SEQ_CACHE_VIEW_FINAL_OUT = (1 << 10),
+
+ SEQ_CACHE_PREFETCH_ENABLE = (1 << 11),
+ SEQ_CACHE_DISK_CACHE_ENABLE = (1 << 12),
};
#ifdef __cplusplus
diff --git a/source/blender/sequencer/SEQ_render.h b/source/blender/sequencer/SEQ_render.h
index c138daf1318..d8789eb21d0 100644
--- a/source/blender/sequencer/SEQ_render.h
+++ b/source/blender/sequencer/SEQ_render.h
@@ -51,6 +51,7 @@ typedef struct SeqRenderData {
bool skip_cache;
bool is_proxy_render;
bool is_prefetch_render;
+ bool is_thumb;
int view_id;
/* ID of task for assigning temp cache entries to particular task(thread, etc.) */
eSeqTaskId task_id;
diff --git a/source/blender/sequencer/intern/image_cache.c b/source/blender/sequencer/intern/image_cache.c
index a6e4b6ea7ed..ef6bec474e7 100644
--- a/source/blender/sequencer/intern/image_cache.c
+++ b/source/blender/sequencer/intern/image_cache.c
@@ -1302,8 +1302,9 @@ void seq_cache_cleanup_sequence(Scene *scene,
}
int invalidate_composite = invalidate_types & SEQ_CACHE_STORE_FINAL_OUT;
- int invalidate_source = invalidate_types & (SEQ_CACHE_STORE_RAW | SEQ_CACHE_STORE_PREPROCESSED |
- SEQ_CACHE_STORE_COMPOSITE);
+ int invalidate_source = invalidate_types &
+ (SEQ_CACHE_STORE_RAW | SEQ_CACHE_STORE_PREPROCESSED |
+ SEQ_CACHE_STORE_COMPOSITE); // TODO(AYJ) : add thumbnail
GHashIterator gh_iter;
BLI_ghashIterator_init(&gh_iter, cache->hash);
diff --git a/source/blender/sequencer/intern/render.c b/source/blender/sequencer/intern/render.c
index 76623599864..4d4fcc8677e 100644
--- a/source/blender/sequencer/intern/render.c
+++ b/source/blender/sequencer/intern/render.c
@@ -235,6 +235,7 @@ void SEQ_render_new_render_data(Main *bmain,
r_context->gpu_offscreen = NULL;
r_context->task_id = SEQ_TASK_MAIN_RENDER;
r_context->is_prefetch_render = false;
+ r_context->is_thumb = false;
}
void seq_render_state_init(SeqRenderState *state)
@@ -468,6 +469,9 @@ static bool seq_input_have_to_preprocess(const SeqRenderData *context,
return true;
}
+ if (context->is_thumb)
+ return true;
+
return false;
}
@@ -536,7 +540,10 @@ static void sequencer_preprocess_transform_crop(
SEQ_rendersize_to_scale_factor(
context->preview_render_size);
const bool do_scale_to_render_size = seq_need_scale_to_render_size(seq, is_proxy_image);
- const float image_scale_factor = do_scale_to_render_size ? 1.0f : preview_scale_factor;
+ float image_scale_factor = do_scale_to_render_size ? 1.0f : preview_scale_factor;
+ // TODO(AYJ) : check is setting image_scale_factor as const is imp
+ if (context->is_thumb)
+ image_scale_factor = 0.25f;
float transform_matrix[3][3];
sequencer_image_crop_transform_matrix(
@@ -545,7 +552,7 @@ static void sequencer_preprocess_transform_crop(
/* Proxy image is smaller, so crop values must be corrected by proxy scale factor.
* Proxy scale factor always matches preview_scale_factor. */
rctf source_crop;
- const float crop_scale_factor = do_scale_to_render_size ? preview_scale_factor : 1.0f;
+ float crop_scale_factor = do_scale_to_render_size ? preview_scale_factor : 1.0f;
sequencer_image_crop_init(seq, in, crop_scale_factor, &source_crop);
const eIMBInterpolationFilterMode filter = context->for_render ? IMB_FILTER_BILINEAR :
@@ -607,7 +614,7 @@ static ImBuf *input_preprocess(const SeqRenderData *context,
}
if (sequencer_use_crop(seq) || sequencer_use_transform(seq) || context->rectx != ibuf->x ||
- context->recty != ibuf->y) {
+ context->recty != ibuf->y || context->is_thumb) {
const int x = context->rectx;
const int y = context->recty;
preprocessed_ibuf = IMB_allocImBuf(x, y, 32, ibuf->rect_float ? IB_rectfloat : IB_rect);
@@ -681,7 +688,7 @@ static ImBuf *seq_render_preprocess_ibuf(const SeqRenderData *context,
}
/* Proxies and effect strips are not stored in cache. */
- if (!is_proxy_image && (seq->type & SEQ_TYPE_EFFECT) == 0) {
+ if (!is_proxy_image && (seq->type & SEQ_TYPE_EFFECT) == 0 && !context->is_thumb) {
seq_cache_put(context, seq, timeline_frame, SEQ_CACHE_STORE_RAW, ibuf);
}
@@ -689,6 +696,11 @@ static ImBuf *seq_render_preprocess_ibuf(const SeqRenderData *context,
ibuf = input_preprocess(context, seq, timeline_frame, ibuf, is_proxy_image);
}
+ if (context->is_thumb) {
+ seq_cache_put(context, seq, timeline_frame, SEQ_CACHE_STORE_THUMBNAIL, ibuf);
+ return ibuf;
+ }
+
seq_cache_put(context, seq, timeline_frame, SEQ_CACHE_STORE_PREPROCESSED, ibuf);
return ibuf;
}
@@ -1737,14 +1749,22 @@ ImBuf *seq_render_strip(const SeqRenderData *context,
bool use_preprocess = false;
bool is_proxy_image = false;
- ibuf = seq_cache_get(context, seq, timeline_frame, SEQ_CACHE_STORE_PREPROCESSED);
- if (ibuf != NULL) {
- return ibuf;
+ if (context->is_thumb) {
+ ibuf = seq_cache_get(context, seq, timeline_frame, SEQ_CACHE_STORE_THUMBNAIL);
+ if (ibuf != NULL)
+ return ibuf;
+ }
+ else {
+ ibuf = seq_cache_get(context, seq, timeline_frame, SEQ_CACHE_STORE_PREPROCESSED);
+ if (ibuf != NULL) {
+ return ibuf;
+ }
}
/* Proxies are not stored in cache. */
if (!SEQ_can_use_proxy(
- context, seq, SEQ_rendersize_to_proxysize(context->preview_render_size))) {
+ context, seq, SEQ_rendersize_to_proxysize(context->preview_render_size)) &&
+ !context->is_thumb) {
ibuf = seq_cache_get(context, seq, timeline_frame, SEQ_CACHE_STORE_RAW);
}
More information about the Bf-blender-cvs
mailing list