diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-03-26 17:30:53 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-03-26 17:30:53 +0400 |
commit | dbfe971c06e4e029b679b4a178258974e9845ad1 (patch) | |
tree | 369980964610df98d53ca3c24c8834bdfa4b6c51 /source | |
parent | 53dab9ec69d8a583f458a47d3cdfdae06486ca17 (diff) |
Fix for crash when adding image sequence movie clip into a sequencer
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/movieclip.c | 38 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_movieclip_types.h | 4 |
2 files changed, 37 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 1a7c45cea0d..585c1a7dc14 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -256,6 +256,28 @@ static ImBuf *movieclip_load_movie_file(MovieClip *clip, MovieClipUser *user, in return ibuf; } +static void movieclip_calc_length(MovieClip *clip) +{ + if (clip->anim) { + clip->len = IMB_anim_get_duration(clip->anim, clip->proxy.tc); + } + else if (clip->source == MCLIP_SRC_SEQUENCE) { + int framenr = 1; + char name[FILE_MAX]; + + for (;;) { + get_sequence_fname(clip, framenr, name); + + if (!BLI_exists(name)) { + clip->len = framenr + 1; + break; + } + + framenr++; + } + } +} + /*********************** image buffer cache *************************/ typedef struct MovieClipCache { @@ -452,9 +474,9 @@ MovieClip *BKE_add_movieclip_file(const char *name) BLI_strncpy(clip->name, name, sizeof(clip->name)); if (BLI_testextensie_array(name, imb_ext_movie)) - clip->source= MCLIP_SRC_MOVIE; + clip->source = MCLIP_SRC_MOVIE; else - clip->source= MCLIP_SRC_SEQUENCE; + clip->source = MCLIP_SRC_SEQUENCE; user.framenr = 1; BKE_movieclip_get_size(clip, &user, &width, &height); @@ -465,6 +487,8 @@ MovieClip *BKE_add_movieclip_file(const char *name) clip->tracking.camera.focal = 24.0f * width / clip->tracking.camera.sensor_width; } + movieclip_calc_length(clip); + return clip; } @@ -891,9 +915,13 @@ void BKE_movieclip_get_size(MovieClip *clip, MovieClipUser *user, int *width, in } } -int BKE_movieclip_get_duration(struct MovieClip *clip) +int BKE_movieclip_get_duration(MovieClip *clip) { - return IMB_anim_get_duration(clip->anim, clip->proxy.tc); + if (!clip->len && clip->anim) { + return IMB_anim_get_duration(clip->anim, clip->proxy.tc); + } + + return clip->len; } void BKE_movieclip_aspect(MovieClip *clip, float *aspx, float *aspy) @@ -959,6 +987,8 @@ void BKE_movieclip_reload(MovieClip *clip) clip->source = MCLIP_SRC_MOVIE; else clip->source = MCLIP_SRC_SEQUENCE; + + movieclip_calc_length(clip); } void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClipScopes *scopes) diff --git a/source/blender/makesdna/DNA_movieclip_types.h b/source/blender/makesdna/DNA_movieclip_types.h index b4e6c07cec3..ed7310ff883 100644 --- a/source/blender/makesdna/DNA_movieclip_types.h +++ b/source/blender/makesdna/DNA_movieclip_types.h @@ -82,7 +82,9 @@ typedef struct MovieClip { * in SpaceClip clip user */ struct MovieClipProxy proxy; /* proxy to clip data */ - int flag, pad; + int flag; + + int len; /* lenght of movie */ } MovieClip; typedef struct MovieClipScopes { |