[Bf-blender-cvs] [f7f3b2d3182] master: Cleanup: Remove goto statements from strip rendering functions
Richard Antalik
noreply at git.blender.org
Thu Jun 18 05:54:01 CEST 2020
Commit: f7f3b2d31823ac3f45b04d97cbed209eafbba15d
Author: Richard Antalik
Date: Thu Jun 18 05:35:46 2020 +0200
Branches: master
https://developer.blender.org/rBf7f3b2d31823ac3f45b04d97cbed209eafbba15d
Cleanup: Remove goto statements from strip rendering functions
Remove goto statement from `seq_render_image_strip()` and `seq_render_movie_strip()`.
`seq_render_image_strip_view()` and `seq_render_movie_strip_view()` is used to render individual views in both monoview and multiview branch.
I have included `seq_can_use_proxy()` for convinience
Reviewed By: sybren
Differential Revision: https://developer.blender.org/D7870
===================================================================
M source/blender/blenkernel/intern/sequencer.c
===================================================================
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 7ec4797a998..d2f31241f01 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -1180,7 +1180,7 @@ static void seqbase_unique_name(ListBase *seqbasep, SeqUniqueInfo *sui)
Sequence *seq;
for (seq = seqbasep->first; seq; seq = seq->next) {
if ((sui->seq != seq) && STREQ(sui->name_dest, seq->name + 2)) {
- /* SEQ_NAME_MAXSTR -4 for the number, -1 for \0, - 2 for prefix */
+ /* SEQ_NAME_MAXSTR -4 for the number, -1 for \0, - 2 for r_prefix */
BLI_snprintf(sui->name_dest,
sizeof(sui->name_dest),
"%.*s.%03d",
@@ -2247,6 +2247,15 @@ void BKE_sequencer_proxy_set(struct Sequence *seq, bool value)
}
}
+static bool seq_can_use_proxy(Sequence *seq, IMB_Proxy_Size psize)
+{
+ if (seq->strip->proxy == NULL) {
+ return false;
+ }
+ short size_flags = seq->strip->proxy->build_size_flags;
+ return (seq->flag & SEQ_USE_PROXY) != 0 && psize != IMB_PROXY_NONE && (size_flags & psize) != 0;
+}
+
/*********************** color balance *************************/
static StripColorBalance calc_cb(StripColorBalance *cb_)
@@ -2985,97 +2994,116 @@ static ImBuf *seq_render_effect_strip_impl(const SeqRenderData *context,
return out;
}
-static ImBuf *seq_render_image_strip(const SeqRenderData *context,
- Sequence *seq,
- float UNUSED(nr),
- float cfra)
+/* Render individual view for multiview or single (default view) for monoview. */
+static ImBuf *seq_render_image_strip_view(const SeqRenderData *context,
+ Sequence *seq,
+ float cfra,
+ char *name,
+ char *prefix,
+ const char *ext,
+ int view_id)
{
- ImBuf *ibuf = NULL;
- char name[FILE_MAX];
- bool is_multiview = (seq->flag & SEQ_USE_VIEWS) != 0 &&
- (context->scene->r.scemode & R_MULTIVIEW) != 0;
- StripElem *s_elem = BKE_sequencer_give_stripelem(seq, cfra);
- int flag;
- if (s_elem) {
- BLI_join_dirfile(name, sizeof(name), seq->strip->dir, s_elem->name);
- BLI_path_abs(name, BKE_main_blendfile_path_from_global());
- }
+ ImBuf *ibuf = NULL;
- flag = IB_rect | IB_metadata;
+ int flag = IB_rect | IB_metadata;
if (seq->alpha_mode == SEQ_ALPHA_PREMUL) {
flag |= IB_alphamode_premul;
}
- if (!s_elem) {
- /* don't do anything */
+ if (prefix[0] == '\0') {
+ ibuf = IMB_loadiffname(name, flag, seq->strip->colorspace_settings.name);
+ }
+ else {
+ char str[FILE_MAX];
+ seq_multiview_name(context->scene, view_id, prefix, ext, str, FILE_MAX);
+ ibuf = IMB_loadiffname(str, flag, seq->strip->colorspace_settings.name);
}
- else if (is_multiview) {
- const int totfiles = seq_num_files(context->scene, seq->views_format, true);
- int totviews;
- struct ImBuf **ibufs_arr;
- char prefix[FILE_MAX];
- const char *ext = NULL;
- if (totfiles > 1) {
- BKE_scene_multiview_view_prefix_get(context->scene, name, prefix, &ext);
- if (prefix[0] == '\0') {
- goto monoview_image;
- }
- }
- else {
- prefix[0] = '\0';
+ if (ibuf == NULL) {
+ return NULL;
+ }
+
+ /* We don't need both (speed reasons)! */
+ if (ibuf->rect_float != NULL && ibuf->rect != NULL) {
+ imb_freerectImBuf(ibuf);
+ }
+
+ /* All sequencer color is done in SRGB space, linear gives odd crossfades. */
+ BKE_sequencer_imbuf_to_sequencer_space(context->scene, ibuf, false);
+
+ return ibuf;
+}
+
+static bool seq_image_strip_is_multiview_render(
+ Scene *scene, Sequence *seq, int totfiles, char *name, char *r_prefix, const char *r_ext)
+{
+ if (totfiles > 1) {
+ BKE_scene_multiview_view_prefix_get(scene, name, r_prefix, &r_ext);
+ if (r_prefix[0] == '\0') {
+ return false;
}
+ }
+ else {
+ r_prefix[0] = '\0';
+ }
- totviews = BKE_scene_multiview_num_views_get(&context->scene->r);
- ibufs_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Sequence Image Views Imbufs");
+ return (seq->flag & SEQ_USE_VIEWS) != 0 && (scene->r.scemode & R_MULTIVIEW) != 0;
+}
- for (int view_id = 0; view_id < totfiles; view_id++) {
+static ImBuf *seq_render_image_strip(const SeqRenderData *context,
+ Sequence *seq,
+ float UNUSED(nr),
+ float cfra)
+{
+ char name[FILE_MAX];
+ const char *ext = NULL;
+ char prefix[FILE_MAX];
+ ImBuf *ibuf = NULL;
- if (prefix[0] == '\0') {
- ibufs_arr[view_id] = IMB_loadiffname(name, flag, seq->strip->colorspace_settings.name);
- }
- else {
- char str[FILE_MAX];
- seq_multiview_name(context->scene, view_id, prefix, ext, str, FILE_MAX);
- ibufs_arr[view_id] = IMB_loadiffname(str, flag, seq->strip->colorspace_settings.name);
- }
+ StripElem *s_elem = BKE_sequencer_give_stripelem(seq, cfra);
+ if (s_elem == NULL) {
+ return NULL;
+ }
- if (ibufs_arr[view_id]) {
- /* we don't need both (speed reasons)! */
- if (ibufs_arr[view_id]->rect_float && ibufs_arr[view_id]->rect) {
- imb_freerectImBuf(ibufs_arr[view_id]);
- }
- }
+ BLI_join_dirfile(name, sizeof(name), seq->strip->dir, s_elem->name);
+ BLI_path_abs(name, BKE_main_blendfile_path_from_global());
+
+ const int totfiles = seq_num_files(context->scene, seq->views_format, true);
+ bool is_multiview_render = seq_image_strip_is_multiview_render(
+ context->scene, seq, totfiles, name, prefix, ext);
+
+ if (is_multiview_render) {
+ int totviews = BKE_scene_multiview_num_views_get(&context->scene->r);
+ ImBuf **ibufs_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Sequence Image Views Imbufs");
+
+ for (int view_id = 0; view_id < totfiles; view_id++) {
+ ibufs_arr[view_id] = seq_render_image_strip_view(
+ context, seq, cfra, name, prefix, ext, view_id);
+ }
+
+ if (ibufs_arr[0] == NULL) {
+ return NULL;
}
- if (seq->views_format == R_IMF_VIEWS_STEREO_3D && ibufs_arr[0]) {
+ if (seq->views_format == R_IMF_VIEWS_STEREO_3D) {
IMB_ImBufFromStereo3d(seq->stereo3d_format, ibufs_arr[0], &ibufs_arr[0], &ibufs_arr[1]);
}
for (int view_id = 0; view_id < totviews; view_id++) {
- if (ibufs_arr[view_id]) {
- SeqRenderData localcontext = *context;
- localcontext.view_id = view_id;
-
- /* all sequencer color is done in SRGB space, linear gives odd crossfades */
- BKE_sequencer_imbuf_to_sequencer_space(context->scene, ibufs_arr[view_id], false);
+ SeqRenderData localcontext = *context;
+ localcontext.view_id = view_id;
- if (view_id != context->view_id) {
- ibufs_arr[view_id] = seq_render_preprocess_ibuf(
- &localcontext, seq, ibufs_arr[view_id], cfra, clock(), true, false, false);
- }
+ if (view_id != context->view_id) {
+ ibufs_arr[view_id] = seq_render_preprocess_ibuf(
+ &localcontext, seq, ibufs_arr[view_id], cfra, clock(), true, false, false);
}
}
- /* return the original requested ImBuf */
+ /* Return the original requested ImBuf. */
ibuf = ibufs_arr[context->view_id];
- if (ibuf) {
- s_elem->orig_width = ibufs_arr[0]->x;
- s_elem->orig_height = ibufs_arr[0]->y;
- }
- /* "remove" the others (decrease their refcount) */
+ /* Remove the others (decrease their refcount). */
for (int view_id = 0; view_id < totviews; view_id++) {
if (ibufs_arr[view_id] != ibuf) {
IMB_freeImBuf(ibufs_arr[view_id]);
@@ -3085,116 +3113,107 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context,
MEM_freeN(ibufs_arr);
}
else {
- monoview_image:
- if ((ibuf = IMB_loadiffname(name, flag, seq->strip->colorspace_settings.name))) {
- /* we don't need both (speed reasons)! */
- if (ibuf->rect_float && ibuf->rect) {
- imb_freerectImBuf(ibuf);
- }
-
- /* all sequencer color is done in SRGB space, linear gives odd crossfades */
- BKE_sequencer_imbuf_to_sequencer_space(context->scene, ibuf, false);
+ ibuf = seq_render_image_strip_view(context, seq, cfra, name, prefix, ext, context->view_id);
+ }
- s_elem->orig_width = ibuf->x;
- s_elem->orig_height = ibuf->y;
- }
+ if (ibuf == NULL) {
+ return NULL;
}
+ s_elem->orig_width = ibuf->x;
+ s_elem->orig_height = ibuf->y;
+
return ibuf;
}
-static ImBuf *seq_render_movie_strip(const SeqRenderData *context,
- Sequence *seq,
- float nr,
- float cfra)
+/* Render individual view for multiview or single (default view) for monoview. */
+static ImBuf *seq_render_movie_strip_view(
+ const SeqRenderData *context, Sequence *seq, float nr, float cfra, StripAnim *sanim)
{
ImBuf *ibuf = NULL;
- StripAnim *sanim;
+ IMB_Proxy_Size psize = seq_rendersize_to_proxysize(context->preview_render_size);
- bool is_multiview = (seq->flag & SEQ_USE_VIEWS) != 0 &&
- (context->scene->r.scemode & R_MULTIVIEW) != 0;
+ IMB_anim_set_preseek(sanim->anim, seq->anim_preseek);
- IMB_Proxy_Size psize = seq_rendersize_to_proxysize(context->preview_render_size);
+ if (seq_can_use_proxy(seq, psize)) {
+ ibuf = IMB_anim_absolute(sanim->anim,
+ nr + seq->anim_startofs,
+ seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN,
+ psize);
+ }
- if ((seq->flag & SEQ_USE_PROXY) == 0) {
- psize = IMB_PROXY_NONE;
+ /* Fetching for requested proxy size failed, try fetching the original instead. */
+ if (ibuf == NULL) {
+ ibuf = IMB_anim_absolute(sanim->anim,
+ nr + seq->anim_startofs,
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list