Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Parborg <darkdefende@gmail.com>2021-10-05 19:45:47 +0300
committerSebastian Parborg <darkdefende@gmail.com>2021-10-05 19:53:58 +0300
commit0a1a173e57d0f9e797dbb4972adda2993fccd6d7 (patch)
tree5a9ac0346fd1dcf618834d21e19e24b1209ad567 /source/blender/imbuf/intern
parent6eefcd7d78389fbcb92f6d482024224ceea5d1fa (diff)
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.
Diffstat (limited to 'source/blender/imbuf/intern')
-rw-r--r--source/blender/imbuf/intern/anim_movie.c44
1 files changed, 19 insertions, 25 deletions
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index 13f9356751e..4eb078113dd 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -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) {