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
This commit is contained in:
Eitan 2021-03-20 00:08:32 +01:00 committed by Richard Antalik
parent bfad8deb0b
commit 7bf977e9f0
Notes: blender-bot 2023-02-14 06:05:27 +01:00
Referenced by issue #54395, VSE Edit Strip - Original Dimensions shows Proxy Dimensions
2 changed files with 19 additions and 6 deletions

View File

@ -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;
}

View File

@ -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);