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:
Diffstat (limited to 'source/blender/blenkernel/intern/movieclip.c')
-rw-r--r--source/blender/blenkernel/intern/movieclip.c159
1 files changed, 106 insertions, 53 deletions
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 51f7fd2208c..1a61fa2c537 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -84,8 +84,9 @@ static int sequence_guess_offset(const char *full_name, int head_len, unsigned s
static int rendersize_to_proxy(const MovieClipUser *user, int flag)
{
- if ((flag & MCLIP_USE_PROXY) == 0)
+ if ((flag & MCLIP_USE_PROXY) == 0) {
return IMB_PROXY_NONE;
+ }
switch (user->render_size) {
case MCLIP_PROXY_RENDER_SIZE_25:
@@ -131,8 +132,9 @@ static int rendersize_to_number(int render_size)
static int get_timecode(MovieClip *clip, int flag)
{
- if ((flag & MCLIP_USE_PROXY) == 0)
+ if ((flag & MCLIP_USE_PROXY) == 0) {
return IMB_TC_NONE;
+ }
return clip->proxy.tc;
}
@@ -179,10 +181,12 @@ static void get_proxy_fname(
BLI_snprintf(dir, FILE_MAX, "%s/BL_proxy", clipdir);
}
- if (undistorted)
+ if (undistorted) {
BLI_snprintf(name, FILE_MAX, "%s/%s/proxy_%d_undistorted/%08d", dir, clipfile, size, proxynr);
- else
+ }
+ else {
BLI_snprintf(name, FILE_MAX, "%s/%s/proxy_%d/%08d", dir, clipfile, size, proxynr);
+ }
BLI_path_abs(name, BKE_main_blendfile_path_from_global());
BLI_path_frame(name, 1, 0);
@@ -378,10 +382,12 @@ static void movieclip_calc_length(MovieClip *clip)
for (;;) {
get_sequence_fname(clip, clip->len + clip->start_frame, name);
- if (BLI_exists(name))
+ if (BLI_exists(name)) {
clip->len++;
- else
+ }
+ else {
break;
+ }
}
}
}
@@ -458,8 +464,9 @@ static int user_frame_to_cache_frame(MovieClip *clip, int framenr)
index += clip->cache->sequence_offset;
}
- if (index < 0)
+ if (index < 0) {
return framenr - index;
+ }
return framenr;
}
@@ -703,8 +710,9 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *name)
/* exists? */
file = BLI_open(str, O_BINARY | O_RDONLY, 0);
- if (file == -1)
+ if (file == -1) {
return NULL;
+ }
close(file);
/* ** add new movieclip ** */
@@ -742,14 +750,16 @@ MovieClip *BKE_movieclip_file_add_exists_ex(Main *bmain, const char *filepath, b
if (BLI_path_cmp(strtest, str) == 0) {
id_us_plus(&clip->id); /* officially should not, it doesn't link here! */
- if (r_exists)
+ if (r_exists) {
*r_exists = true;
+ }
return clip;
}
}
- if (r_exists)
+ if (r_exists) {
*r_exists = false;
+ }
return BKE_movieclip_file_add(bmain, filepath);
}
@@ -790,11 +800,13 @@ static ImBuf *get_undistorted_ibuf(MovieClip *clip,
{
ImBuf *undistibuf;
- if (distortion)
+ if (distortion) {
undistibuf = BKE_tracking_distortion_exec(
distortion, &clip->tracking, ibuf, ibuf->x, ibuf->y, 0.0f, 1);
- else
+ }
+ else {
undistibuf = BKE_tracking_undistort_frame(&clip->tracking, ibuf, ibuf->x, ibuf->y, 0.0f);
+ }
IMB_scaleImBuf(undistibuf, ibuf->x, ibuf->y);
@@ -861,26 +873,32 @@ static ImBuf *get_postprocessed_cached_frame(const MovieClip *clip,
}
/* no cache or no cached postprocessed image */
- if (!clip->cache || !clip->cache->postprocessed.ibuf)
+ if (!clip->cache || !clip->cache->postprocessed.ibuf) {
return NULL;
+ }
/* postprocessing happened for other frame */
- if (cache->postprocessed.framenr != framenr)
+ if (cache->postprocessed.framenr != framenr) {
return NULL;
+ }
/* cached ibuf used different proxy settings */
- if (cache->postprocessed.render_flag != render_flag || cache->postprocessed.proxy != proxy)
+ if (cache->postprocessed.render_flag != render_flag || cache->postprocessed.proxy != proxy) {
return NULL;
+ }
- if (cache->postprocessed.flag != postprocess_flag)
+ if (cache->postprocessed.flag != postprocess_flag) {
return NULL;
+ }
if (need_undistortion_postprocess(user, flag)) {
- if (!check_undistortion_cache_flags(clip))
+ if (!check_undistortion_cache_flags(clip)) {
return NULL;
+ }
}
- else if (cache->postprocessed.undistortion_used)
+ else if (cache->postprocessed.undistortion_used) {
return NULL;
+ }
IMB_refImBuf(cache->postprocessed.ibuf);
@@ -905,8 +923,9 @@ static ImBuf *postprocess_frame(
bool disable_blue = (postprocess_flag & MOVIECLIP_DISABLE_BLUE) != 0;
bool grayscale = (postprocess_flag & MOVIECLIP_PREVIEW_GRAYSCALE) != 0;
- if (disable_red || disable_green || disable_blue || grayscale)
+ if (disable_red || disable_green || disable_blue || grayscale) {
BKE_tracking_disable_channels(postproc_ibuf, disable_red, disable_green, disable_blue, 1);
+ }
}
return postproc_ibuf;
@@ -943,8 +962,9 @@ static void put_postprocessed_frame_to_cache(
IMB_refImBuf(ibuf);
- if (cache->postprocessed.ibuf)
+ if (cache->postprocessed.ibuf) {
IMB_freeImBuf(cache->postprocessed.ibuf);
+ }
cache->postprocessed.ibuf = ibuf;
}
@@ -964,12 +984,14 @@ static ImBuf *movieclip_get_postprocessed_ibuf(
if (need_postprocessed_frame(user, flag, postprocess_flag)) {
ibuf = get_postprocessed_cached_frame(clip, user, flag, postprocess_flag);
- if (!ibuf)
+ if (!ibuf) {
need_postprocess = true;
+ }
}
- if (!ibuf)
+ if (!ibuf) {
ibuf = get_imbuf_cache(clip, user, flag);
+ }
if (!ibuf) {
bool use_sequence = false;
@@ -1054,25 +1076,31 @@ static ImBuf *get_stable_cached_frame(
}
/* there's no cached frame or it was calculated for another frame */
- if (!cache->stabilized.ibuf || cache->stabilized.framenr != framenr)
+ if (!cache->stabilized.ibuf || cache->stabilized.framenr != framenr) {
return NULL;
+ }
- if (cache->stabilized.reference_ibuf != reference_ibuf)
+ if (cache->stabilized.reference_ibuf != reference_ibuf) {
return NULL;
+ }
/* cached ibuf used different proxy settings */
- if (cache->stabilized.render_flag != render_flag || cache->stabilized.proxy != proxy)
+ if (cache->stabilized.render_flag != render_flag || cache->stabilized.proxy != proxy) {
return NULL;
+ }
- if (cache->stabilized.postprocess_flag != postprocess_flag)
+ if (cache->stabilized.postprocess_flag != postprocess_flag) {
return NULL;
+ }
/* stabilization also depends on pixel aspect ratio */
- if (cache->stabilized.aspect != tracking->camera.pixel_aspect)
+ if (cache->stabilized.aspect != tracking->camera.pixel_aspect) {
return NULL;
+ }
- if (cache->stabilized.filter != tracking->stabilization.filter)
+ if (cache->stabilized.filter != tracking->stabilization.filter) {
return NULL;
+ }
stableibuf = cache->stabilized.ibuf;
@@ -1121,8 +1149,9 @@ static ImBuf *put_stabilized_frame_to_cache(
cache->stabilized.postprocess_flag = postprocess_flag;
- if (cache->stabilized.ibuf)
+ if (cache->stabilized.ibuf) {
IMB_freeImBuf(cache->stabilized.ibuf);
+ }
cache->stabilized.ibuf = stableibuf;
@@ -1143,35 +1172,43 @@ ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip,
ibuf = BKE_movieclip_get_postprocessed_ibuf(clip, user, postprocess_flag);
- if (!ibuf)
+ if (!ibuf) {
return NULL;
+ }
if (clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) {
MovieClipCache *cache = clip->cache;
stableibuf = get_stable_cached_frame(clip, user, ibuf, framenr, postprocess_flag);
- if (!stableibuf)
+ if (!stableibuf) {
stableibuf = put_stabilized_frame_to_cache(clip, user, ibuf, framenr, postprocess_flag);
+ }
- if (loc)
+ if (loc) {
copy_v2_v2(loc, cache->stabilized.loc);
+ }
- if (scale)
+ if (scale) {
*scale = cache->stabilized.scale;
+ }
- if (angle)
+ if (angle) {
*angle = cache->stabilized.angle;
+ }
}
else {
- if (loc)
+ if (loc) {
zero_v2(loc);
+ }
- if (scale)
+ if (scale) {
*scale = 1.0f;
+ }
- if (angle)
+ if (angle) {
*angle = 0.0f;
+ }
stableibuf = ibuf;
}
@@ -1224,8 +1261,9 @@ void BKE_movieclip_get_size(MovieClip *clip, MovieClipUser *user, int *width, in
*height = clip->lastsize[1];
}
- if (ibuf)
+ if (ibuf) {
IMB_freeImBuf(ibuf);
+ }
}
}
void BKE_movieclip_get_size_fl(MovieClip *clip, MovieClipUser *user, float size[2])
@@ -1300,11 +1338,13 @@ static void free_buffers(MovieClip *clip)
if (clip->cache) {
IMB_moviecache_free(clip->cache->moviecache);
- if (clip->cache->postprocessed.ibuf)
+ if (clip->cache->postprocessed.ibuf) {
IMB_freeImBuf(clip->cache->postprocessed.ibuf);
+ }
- if (clip->cache->stabilized.ibuf)
+ if (clip->cache->stabilized.ibuf) {
IMB_freeImBuf(clip->cache->stabilized.ibuf);
+ }
MEM_freeN(clip->cache);
clip->cache = NULL;
@@ -1356,8 +1396,9 @@ void BKE_movieclip_reload(Main *bmain, MovieClip *clip)
void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClipScopes *scopes)
{
- if (scopes->ok)
+ if (scopes->ok) {
return;
+ }
if (scopes->track_preview) {
IMB_freeImBuf(scopes->track_preview);
@@ -1459,17 +1500,20 @@ static void movieclip_build_proxy_ibuf(
scaleibuf = IMB_dupImBuf(ibuf);
- if (threaded)
+ if (threaded) {
IMB_scaleImBuf_threaded(scaleibuf, (short)rectx, (short)recty);
- else
+ }
+ else {
IMB_scaleImBuf(scaleibuf, (short)rectx, (short)recty);
+ }
quality = clip->proxy.quality;
scaleibuf->ftype = IMB_FTYPE_JPG;
scaleibuf->foptions.quality = quality;
/* unsupported feature only confuses other s/w */
- if (scaleibuf->planes == 32)
+ if (scaleibuf->planes == 32) {
scaleibuf->planes = 24;
+ }
/* TODO: currently the most weak part of multithreaded proxies,
* could be solved in a way that thread only prepares memory
@@ -1478,8 +1522,9 @@ static void movieclip_build_proxy_ibuf(
BLI_thread_lock(LOCK_MOVIECLIP);
BLI_make_existing_file(name);
- if (IMB_saveiff(scaleibuf, name, IB_rect) == 0)
+ if (IMB_saveiff(scaleibuf, name, IB_rect) == 0) {
perror(name);
+ }
BLI_thread_unlock(LOCK_MOVIECLIP);
@@ -1500,8 +1545,9 @@ void BKE_movieclip_build_proxy_frame(MovieClip *clip,
ImBuf *ibuf;
MovieClipUser user;
- if (!build_count)
+ if (!build_count) {
return;
+ }
user.framenr = cfra;
user.render_flag = 0;
@@ -1513,16 +1559,19 @@ void BKE_movieclip_build_proxy_frame(MovieClip *clip,
ImBuf *tmpibuf = ibuf;
int i;
- if (undistorted)
+ if (undistorted) {
tmpibuf = get_undistorted_ibuf(clip, distortion, ibuf);
+ }
- for (i = 0; i < build_count; i++)
+ for (i = 0; i < build_count; i++) {
movieclip_build_proxy_ibuf(clip, tmpibuf, cfra, build_sizes[i], undistorted, true);
+ }
IMB_freeImBuf(ibuf);
- if (tmpibuf != ibuf)
+ if (tmpibuf != ibuf) {
IMB_freeImBuf(tmpibuf);
+ }
}
}
@@ -1537,21 +1586,25 @@ void BKE_movieclip_build_proxy_frame_for_ibuf(MovieClip *clip,
int build_count,
bool undistorted)
{
- if (!build_count)
+ if (!build_count) {
return;
+ }
if (ibuf) {
ImBuf *tmpibuf = ibuf;
int i;
- if (undistorted)
+ if (undistorted) {
tmpibuf = get_undistorted_ibuf(clip, distortion, ibuf);
+ }
- for (i = 0; i < build_count; i++)
+ for (i = 0; i < build_count; i++) {
movieclip_build_proxy_ibuf(clip, tmpibuf, cfra, build_sizes[i], undistorted, false);
+ }
- if (tmpibuf != ibuf)
+ if (tmpibuf != ibuf) {
IMB_freeImBuf(tmpibuf);
+ }
}
}