Cleanup: Make anim_getnew in the VSE less confusing

It was using dummy image buffers to indicate if an animation container
could be initialized or not.

Use booleans instead.
This commit is contained in:
Sebastian Parborg 2021-10-05 18:45:47 +02:00
parent 6eefcd7d78
commit 0a1a173e57
1 changed files with 19 additions and 25 deletions

View File

@ -1496,16 +1496,15 @@ static void free_anim_ffmpeg(struct anim *anim)
#endif
/* Try next picture to read */
/* No picture, try to open next animation */
/* Succeed, remove first image from animation */
/* Try to init the anim struct.
* Returns true on success.*/
static ImBuf *anim_getnew(struct anim *anim)
static bool anim_getnew(struct anim *anim)
{
struct ImBuf *ibuf = NULL;
BLI_assert(anim->curtype == ANIM_NONE);
if (anim == NULL) {
return NULL;
/* Nothing to init. */
return false;
}
free_anim_movie(anim);
@ -1518,44 +1517,43 @@ static ImBuf *anim_getnew(struct anim *anim)
free_anim_ffmpeg(anim);
#endif
if (anim->curtype != 0) {
return NULL;
}
anim->curtype = imb_get_anim_type(anim->name);
switch (anim->curtype) {
case ANIM_SEQUENCE:
ibuf = IMB_loadiffname(anim->name, anim->ib_flags, anim->colorspace);
case ANIM_SEQUENCE: {
ImBuf *ibuf = IMB_loadiffname(anim->name, anim->ib_flags, anim->colorspace);
if (ibuf) {
BLI_strncpy(anim->first, anim->name, sizeof(anim->first));
anim->duration_in_frames = 1;
IMB_freeImBuf(ibuf);
}
else {
return false;
}
break;
}
case ANIM_MOVIE:
if (startmovie(anim)) {
return NULL;
return false;
}
ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0); /* fake */
break;
#ifdef WITH_AVI
case ANIM_AVI:
if (startavi(anim)) {
printf("couldn't start avi\n");
return NULL;
return false;
}
ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0);
break;
#endif
#ifdef WITH_FFMPEG
case ANIM_FFMPEG:
if (startffmpeg(anim)) {
return 0;
return false;
}
ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0);
break;
#endif
}
return ibuf;
return true;
}
struct ImBuf *IMB_anim_previewframe(struct anim *anim)
@ -1589,14 +1587,10 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim,
filter_y = (anim->ib_flags & IB_animdeinterlace);
if (preview_size == IMB_PROXY_NONE) {
if (anim->curtype == 0) {
ibuf = anim_getnew(anim);
if (ibuf == NULL) {
if (anim->curtype == ANIM_NONE) {
if (!anim_getnew(anim)) {
return NULL;
}
IMB_freeImBuf(ibuf); /* ???? */
ibuf = NULL;
}
if (position < 0) {