From 7bf977e9f0cf57add1543f83d357a19f0848b2b5 Mon Sep 17 00:00:00 2001 From: Eitan Date: Sat, 20 Mar 2021 00:08:32 +0100 Subject: Fix T54395: Original image size set incorrectly `SequenceElement` type `orig_height` and `orig_width` members were set to incorrect size when using proxies and not set when strip was added which caused value to be unset. Since now image dimensions must be read when strip is created, these members can be initialized. When proxies are used, do not set original size since it is not guaranteed, that proxies are exact size. These values are not guaranteed to be up to date or exact. They should be used for strictly informative purposes. Reviewed By: ISS Differential Revision: https://developer.blender.org/D6506 --- source/blender/sequencer/intern/render.c | 8 ++++---- source/blender/sequencer/intern/strip_add.c | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 6 deletions(-) (limited to 'source/blender/sequencer') diff --git a/source/blender/sequencer/intern/render.c b/source/blender/sequencer/intern/render.c index 73d12bfd6b6..572fff0ad38 100644 --- a/source/blender/sequencer/intern/render.c +++ b/source/blender/sequencer/intern/render.c @@ -1023,8 +1023,6 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context, /* Try to get a proxy image. */ ibuf = seq_proxy_fetch(context, seq, timeline_frame); if (ibuf != NULL) { - s_elem->orig_width = ibuf->x; - s_elem->orig_height = ibuf->y; *r_is_proxy_image = true; return ibuf; } @@ -1231,8 +1229,10 @@ static ImBuf *seq_render_movie_strip(const SeqRenderData *context, return NULL; } - seq->strip->stripdata->orig_width = ibuf->x; - seq->strip->stripdata->orig_height = ibuf->y; + if (*r_is_proxy_image == false) { + seq->strip->stripdata->orig_width = ibuf->x; + seq->strip->stripdata->orig_height = ibuf->y; + } return ibuf; } diff --git a/source/blender/sequencer/intern/strip_add.c b/source/blender/sequencer/intern/strip_add.c index aab522da659..99a01dbe791 100644 --- a/source/blender/sequencer/intern/strip_add.c +++ b/source/blender/sequencer/intern/strip_add.c @@ -327,6 +327,15 @@ Sequence *SEQ_add_image_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL BLI_path_abs(file_path, BKE_main_blendfile_path(bmain)); ImBuf *ibuf = IMB_loadiffname(file_path, IB_rect, seq->strip->colorspace_settings.name); if (ibuf != NULL) { + /* Set image resolution. Assume that all images in sequence are same size. This fields are only + * informative. */ + StripElem *strip_elem = strip->stripdata; + for (int i = 0; i < load_data->image.len; i++) { + strip_elem->orig_width = ibuf->x; + strip_elem->orig_height = ibuf->y; + strip_elem++; + } + SEQ_set_scale_to_fit( seq, ibuf->x, ibuf->y, scene->r.xsch, scene->r.ysch, load_data->fit_method); IMB_freeImBuf(ibuf); @@ -458,6 +467,8 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL const int totfiles = seq_num_files(scene, load_data->views_format, load_data->use_multiview); struct anim **anim_arr = MEM_callocN(sizeof(struct anim *) * totfiles, "Video files"); int i; + float width; + float height; if (load_data->use_multiview && (load_data->views_format == R_IMF_VIEWS_INDIVIDUAL)) { char prefix[FILE_MAX]; @@ -528,8 +539,8 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL } /* Set initial scale based on load_data->fit_method. */ - const float width = IMB_anim_get_image_width(anim_arr[0]); - const float height = IMB_anim_get_image_height(anim_arr[0]); + width = IMB_anim_get_image_width(anim_arr[0]); + height = IMB_anim_get_image_height(anim_arr[0]); SEQ_set_scale_to_fit(seq, width, height, scene->r.xsch, scene->r.ysch, load_data->fit_method); } @@ -542,6 +553,8 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL /* We only need 1 element for MOVIE strips. */ StripElem *se; strip->stripdata = se = MEM_callocN(sizeof(StripElem), "stripelem"); + strip->stripdata->orig_width = width; + strip->stripdata->orig_height = height; BLI_split_dirfile(load_data->path, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name)); seq_add_set_name(seq, load_data); -- cgit v1.2.3