diff options
Diffstat (limited to 'source/blender/sequencer/intern')
-rw-r--r-- | source/blender/sequencer/intern/animation.c | 2 | ||||
-rw-r--r-- | source/blender/sequencer/intern/disk_cache.c | 38 | ||||
-rw-r--r-- | source/blender/sequencer/intern/effects.c | 215 | ||||
-rw-r--r-- | source/blender/sequencer/intern/image_cache.c | 20 | ||||
-rw-r--r-- | source/blender/sequencer/intern/image_cache.h | 2 | ||||
-rw-r--r-- | source/blender/sequencer/intern/modifier.c | 92 | ||||
-rw-r--r-- | source/blender/sequencer/intern/proxy.c | 12 | ||||
-rw-r--r-- | source/blender/sequencer/intern/proxy_job.c | 4 | ||||
-rw-r--r-- | source/blender/sequencer/intern/render.c | 64 | ||||
-rw-r--r-- | source/blender/sequencer/intern/sequencer.c | 2 | ||||
-rw-r--r-- | source/blender/sequencer/intern/sound.c | 3 | ||||
-rw-r--r-- | source/blender/sequencer/intern/strip_add.c | 5 | ||||
-rw-r--r-- | source/blender/sequencer/intern/strip_edit.c | 59 | ||||
-rw-r--r-- | source/blender/sequencer/intern/strip_time.c | 71 | ||||
-rw-r--r-- | source/blender/sequencer/intern/strip_time.h | 1 | ||||
-rw-r--r-- | source/blender/sequencer/intern/strip_transform.c | 28 | ||||
-rw-r--r-- | source/blender/sequencer/intern/utils.c | 4 |
17 files changed, 310 insertions, 312 deletions
diff --git a/source/blender/sequencer/intern/animation.c b/source/blender/sequencer/intern/animation.c index b8b2dda4690..280d2177d89 100644 --- a/source/blender/sequencer/intern/animation.c +++ b/source/blender/sequencer/intern/animation.c @@ -75,7 +75,7 @@ void SEQ_offset_animdata(Scene *scene, Sequence *seq, int ofs) } GSET_FOREACH_BEGIN (FCurve *, fcu, fcurves) { - unsigned int i; + uint i; if (fcu->bezt) { for (i = 0; i < fcu->totvert; i++) { BezTriple *bezt = &fcu->bezt[i]; diff --git a/source/blender/sequencer/intern/disk_cache.c b/source/blender/sequencer/intern/disk_cache.c index 37830205588..beb2c77b003 100644 --- a/source/blender/sequencer/intern/disk_cache.c +++ b/source/blender/sequencer/intern/disk_cache.c @@ -69,7 +69,7 @@ #define COLORSPACE_NAME_MAX 64 /* XXX: defined in IMB intern. */ typedef struct DiskCacheHeaderEntry { - unsigned char encoding; + uchar encoding; uint64_t frameno; uint64_t size_compressed; uint64_t size_raw; @@ -182,7 +182,7 @@ static void seq_disk_cache_get_files(SeqDiskCache *disk_cache, char *path) if (is_dir && !FILENAME_IS_CURRPAR(file)) { char subpath[FILE_MAX]; BLI_strncpy(subpath, fl->path, sizeof(subpath)); - BLI_path_slash_ensure(subpath); + BLI_path_slash_ensure(subpath, sizeof(sizeof(subpath))); seq_disk_cache_get_files(disk_cache, subpath); } @@ -291,8 +291,8 @@ static void seq_disk_cache_get_project_dir(SeqDiskCache *disk_cache, char *path, /* Use suffix, so that the cache directory name does not conflict with the bmain's blend file. */ const char *suffix = "_seq_cache"; strncat(cache_dir, suffix, sizeof(cache_dir) - strlen(cache_dir) - 1); - BLI_strncpy(path, seq_disk_cache_base_dir(), path_len); - BLI_path_append(path, path_len, cache_dir); + + BLI_path_join(path, path_len, seq_disk_cache_base_dir(), cache_dir); } static void seq_disk_cache_get_dir( @@ -303,13 +303,13 @@ static void seq_disk_cache_get_dir( char project_dir[FILE_MAX]; seq_disk_cache_get_project_dir(disk_cache, project_dir, sizeof(project_dir)); - sprintf(scene_name, "%s-%" PRId64, scene->id.name, disk_cache->timestamp); + BLI_snprintf( + scene_name, sizeof(scene_name), "%s-%" PRId64, scene->id.name, disk_cache->timestamp); BLI_strncpy(seq_name, seq->name, sizeof(seq_name)); BLI_filename_make_safe(scene_name); BLI_filename_make_safe(seq_name); - BLI_strncpy(path, project_dir, path_len); - BLI_path_append(path, path_len, scene_name); - BLI_path_append(path, path_len, seq_name); + + BLI_path_join(path, path_len, project_dir, scene_name, seq_name); } static void seq_disk_cache_get_file_path(SeqDiskCache *disk_cache, @@ -320,14 +320,15 @@ static void seq_disk_cache_get_file_path(SeqDiskCache *disk_cache, seq_disk_cache_get_dir(disk_cache, key->context.scene, key->seq, path, path_len); int frameno = (int)key->frame_index / DCACHE_IMAGES_PER_FILE; char cache_filename[FILE_MAXFILE]; - sprintf(cache_filename, - DCACHE_FNAME_FORMAT, - key->type, - key->context.rectx, - key->context.recty, - key->context.preview_render_size, - key->context.view_id, - frameno); + BLI_snprintf(cache_filename, + sizeof(cache_filename), + DCACHE_FNAME_FORMAT, + key->type, + key->context.rectx, + key->context.recty, + key->context.preview_render_size, + key->context.view_id, + frameno); BLI_path_append(path, path_len, cache_filename); } @@ -350,8 +351,7 @@ static void seq_disk_cache_handle_versioning(SeqDiskCache *disk_cache) int version = 0; seq_disk_cache_get_project_dir(disk_cache, filepath, sizeof(filepath)); - BLI_strncpy(path_version_file, filepath, sizeof(path_version_file)); - BLI_path_append(path_version_file, sizeof(path_version_file), "cache_version"); + BLI_path_join(path_version_file, sizeof(path_version_file), filepath, "cache_version"); if (BLI_exists(filepath) && BLI_is_dir(filepath)) { FILE *file = BLI_fopen(path_version_file, "r"); @@ -384,7 +384,7 @@ static void seq_disk_cache_delete_invalid_files(SeqDiskCache *disk_cache, DiskCacheFile *next_file, *cache_file = disk_cache->files.first; char cache_dir[FILE_MAX]; seq_disk_cache_get_dir(disk_cache, scene, seq, cache_dir, sizeof(cache_dir)); - BLI_path_slash_ensure(cache_dir); + BLI_path_slash_ensure(cache_dir, sizeof(cache_dir)); while (cache_file) { next_file = cache_file->next; diff --git a/source/blender/sequencer/intern/effects.c b/source/blender/sequencer/intern/effects.c index 25a6acb8975..3e3fe85ed39 100644 --- a/source/blender/sequencer/intern/effects.c +++ b/source/blender/sequencer/intern/effects.c @@ -71,22 +71,22 @@ static void slice_get_byte_buffers(const SeqRenderData *context, const ImBuf *ibuf3, const ImBuf *out, int start_line, - unsigned char **rect1, - unsigned char **rect2, - unsigned char **rect3, - unsigned char **rect_out) + uchar **rect1, + uchar **rect2, + uchar **rect3, + uchar **rect_out) { int offset = 4 * start_line * context->rectx; - *rect1 = (unsigned char *)ibuf1->rect + offset; - *rect_out = (unsigned char *)out->rect + offset; + *rect1 = (uchar *)ibuf1->rect + offset; + *rect_out = (uchar *)out->rect + offset; if (ibuf2) { - *rect2 = (unsigned char *)ibuf2->rect + offset; + *rect2 = (uchar *)ibuf2->rect + offset; } if (ibuf3) { - *rect3 = (unsigned char *)ibuf3->rect + offset; + *rect3 = (uchar *)ibuf3->rect + offset; } } @@ -205,11 +205,11 @@ static void init_alpha_over_or_under(Sequence *seq) } static void do_alphaover_effect_byte( - float fac, int x, int y, unsigned char *rect1, unsigned char *rect2, unsigned char *out) + float fac, int x, int y, uchar *rect1, uchar *rect2, uchar *out) { - unsigned char *cp1 = rect1; - unsigned char *cp2 = rect2; - unsigned char *rt = out; + uchar *cp1 = rect1; + uchar *cp2 = rect2; + uchar *rt = out; for (int i = 0; i < y; i++) { for (int j = 0; j < x; j++) { @@ -222,10 +222,10 @@ static void do_alphaover_effect_byte( float mfac = 1.0f - fac * rt1[3]; if (fac <= 0.0f) { - *((unsigned int *)rt) = *((unsigned int *)cp2); + *((uint *)rt) = *((uint *)cp2); } else if (mfac <= 0.0f) { - *((unsigned int *)rt) = *((unsigned int *)cp1); + *((uint *)rt) = *((uint *)cp1); } else { tempc[0] = fac * rt1[0] + mfac * rt2[0]; @@ -294,7 +294,7 @@ static void do_alphaover_effect(const SeqRenderData *context, do_alphaover_effect_float(fac, context->rectx, total_lines, rect1, rect2, rect_out); } else { - unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; + uchar *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; slice_get_byte_buffers( context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); @@ -310,11 +310,11 @@ static void do_alphaover_effect(const SeqRenderData *context, * \{ */ static void do_alphaunder_effect_byte( - float fac, int x, int y, unsigned char *rect1, unsigned char *rect2, unsigned char *out) + float fac, int x, int y, uchar *rect1, uchar *rect2, uchar *out) { - unsigned char *cp1 = rect1; - unsigned char *cp2 = rect2; - unsigned char *rt = out; + uchar *cp1 = rect1; + uchar *cp2 = rect2; + uchar *rt = out; for (int i = 0; i < y; i++) { for (int j = 0; j < x; j++) { @@ -328,16 +328,16 @@ static void do_alphaunder_effect_byte( * 'skybuf' can be crossed in */ if (rt2[3] <= 0.0f && fac >= 1.0f) { - *((unsigned int *)rt) = *((unsigned int *)cp1); + *((uint *)rt) = *((uint *)cp1); } else if (rt2[3] >= 1.0f) { - *((unsigned int *)rt) = *((unsigned int *)cp2); + *((uint *)rt) = *((uint *)cp2); } else { float temp_fac = (fac * (1.0f - rt2[3])); if (fac <= 0) { - *((unsigned int *)rt) = *((unsigned int *)cp2); + *((uint *)rt) = *((uint *)cp2); } else { tempc[0] = (temp_fac * rt1[0] + rt2[0]); @@ -415,7 +415,7 @@ static void do_alphaunder_effect(const SeqRenderData *context, do_alphaunder_effect_float(fac, context->rectx, total_lines, rect1, rect2, rect_out); } else { - unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; + uchar *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; slice_get_byte_buffers( context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); @@ -430,12 +430,11 @@ static void do_alphaunder_effect(const SeqRenderData *context, /** \name Cross Effect * \{ */ -static void do_cross_effect_byte( - float fac, int x, int y, unsigned char *rect1, unsigned char *rect2, unsigned char *out) +static void do_cross_effect_byte(float fac, int x, int y, uchar *rect1, uchar *rect2, uchar *out) { - unsigned char *rt1 = rect1; - unsigned char *rt2 = rect2; - unsigned char *rt = out; + uchar *rt1 = rect1; + uchar *rt2 = rect2; + uchar *rt = out; int temp_fac = (int)(256.0f * fac); int temp_mfac = 256 - temp_fac; @@ -496,7 +495,7 @@ static void do_cross_effect(const SeqRenderData *context, do_cross_effect_float(fac, context->rectx, total_lines, rect1, rect2, rect_out); } else { - unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; + uchar *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; slice_get_byte_buffers( context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); @@ -512,8 +511,8 @@ static void do_cross_effect(const SeqRenderData *context, * \{ */ /* copied code from initrender.c */ -static unsigned short gamtab[65536]; -static unsigned short igamtab1[256]; +static ushort gamtab[65536]; +static ushort igamtab1[256]; static bool gamma_tabs_init = false; #define RE_GAMMA_TABLE_SIZE 400 @@ -666,11 +665,11 @@ static void free_gammacross(Sequence *UNUSED(seq), const bool UNUSED(do_id_user) } static void do_gammacross_effect_byte( - float fac, int x, int y, unsigned char *rect1, unsigned char *rect2, unsigned char *out) + float fac, int x, int y, uchar *rect1, uchar *rect2, uchar *out) { - unsigned char *cp1 = rect1; - unsigned char *cp2 = rect2; - unsigned char *rt = out; + uchar *cp1 = rect1; + uchar *cp2 = rect2; + uchar *rt = out; float mfac = 1.0f - fac; @@ -705,10 +704,13 @@ static void do_gammacross_effect_float( for (int i = 0; i < y; i++) { for (int j = 0; j < x; j++) { - *rt = gammaCorrect(mfac * invGammaCorrect(*rt1) + fac * invGammaCorrect(*rt2)); - rt1++; - rt2++; - rt++; + rt[0] = gammaCorrect(mfac * invGammaCorrect(rt1[0]) + fac * invGammaCorrect(rt2[0])); + rt[1] = gammaCorrect(mfac * invGammaCorrect(rt1[1]) + fac * invGammaCorrect(rt2[1])); + rt[2] = gammaCorrect(mfac * invGammaCorrect(rt1[2]) + fac * invGammaCorrect(rt2[2])); + rt[3] = gammaCorrect(mfac * invGammaCorrect(rt1[3]) + fac * invGammaCorrect(rt2[3])); + rt1 += 4; + rt2 += 4; + rt += 4; } } } @@ -744,7 +746,7 @@ static void do_gammacross_effect(const SeqRenderData *context, do_gammacross_effect_float(fac, context->rectx, total_lines, rect1, rect2, rect_out); } else { - unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; + uchar *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; slice_get_byte_buffers( context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); @@ -759,12 +761,11 @@ static void do_gammacross_effect(const SeqRenderData *context, /** \name Color Add Effect * \{ */ -static void do_add_effect_byte( - float fac, int x, int y, unsigned char *rect1, unsigned char *rect2, unsigned char *out) +static void do_add_effect_byte(float fac, int x, int y, uchar *rect1, uchar *rect2, uchar *out) { - unsigned char *cp1 = rect1; - unsigned char *cp2 = rect2; - unsigned char *rt = out; + uchar *cp1 = rect1; + uchar *cp2 = rect2; + uchar *rt = out; int temp_fac = (int)(256.0f * fac); @@ -824,7 +825,7 @@ static void do_add_effect(const SeqRenderData *context, do_add_effect_float(fac, context->rectx, total_lines, rect1, rect2, rect_out); } else { - unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; + uchar *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; slice_get_byte_buffers( context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); @@ -839,12 +840,11 @@ static void do_add_effect(const SeqRenderData *context, /** \name Color Subtract Effect * \{ */ -static void do_sub_effect_byte( - float fac, int x, int y, unsigned char *rect1, unsigned char *rect2, unsigned char *out) +static void do_sub_effect_byte(float fac, int x, int y, uchar *rect1, uchar *rect2, uchar *out) { - unsigned char *cp1 = rect1; - unsigned char *cp2 = rect2; - unsigned char *rt = out; + uchar *cp1 = rect1; + uchar *cp2 = rect2; + uchar *rt = out; int temp_fac = (int)(256.0f * fac); @@ -906,7 +906,7 @@ static void do_sub_effect(const SeqRenderData *context, do_sub_effect_float(fac, context->rectx, total_lines, rect1, rect2, rect_out); } else { - unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; + uchar *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; slice_get_byte_buffers( context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); @@ -925,17 +925,16 @@ static void do_sub_effect(const SeqRenderData *context, #define XOFF 8 #define YOFF 8 -static void do_drop_effect_byte( - float fac, int x, int y, unsigned char *rect2i, unsigned char *rect1i, unsigned char *outi) +static void do_drop_effect_byte(float fac, int x, int y, uchar *rect2i, uchar *rect1i, uchar *outi) { const int xoff = min_ii(XOFF, x); const int yoff = min_ii(YOFF, y); int temp_fac = (int)(70.0f * fac); - unsigned char *rt2 = rect2i + yoff * 4 * x; - unsigned char *rt1 = rect1i; - unsigned char *out = outi; + uchar *rt2 = rect2i + yoff * 4 * x; + uchar *rt1 = rect1i; + uchar *out = outi; for (int i = 0; i < y - yoff; i++) { memcpy(out, rt1, sizeof(*out) * xoff * 4); rt1 += xoff * 4; @@ -999,12 +998,11 @@ static void do_drop_effect_float( /** \name Multiply Effect * \{ */ -static void do_mul_effect_byte( - float fac, int x, int y, unsigned char *rect1, unsigned char *rect2, unsigned char *out) +static void do_mul_effect_byte(float fac, int x, int y, uchar *rect1, uchar *rect2, uchar *out) { - unsigned char *rt1 = rect1; - unsigned char *rt2 = rect2; - unsigned char *rt = out; + uchar *rt1 = rect1; + uchar *rt2 = rect2; + uchar *rt = out; int temp_fac = (int)(256.0f * fac); @@ -1069,7 +1067,7 @@ static void do_mul_effect(const SeqRenderData *context, do_mul_effect_float(fac, context->rectx, total_lines, rect1, rect2, rect_out); } else { - unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; + uchar *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; slice_get_byte_buffers( context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); @@ -1084,27 +1082,25 @@ static void do_mul_effect(const SeqRenderData *context, /** \name Blend Mode Effect * \{ */ -typedef void (*IMB_blend_func_byte)(unsigned char *dst, - const unsigned char *src1, - const unsigned char *src2); +typedef void (*IMB_blend_func_byte)(uchar *dst, const uchar *src1, const uchar *src2); typedef void (*IMB_blend_func_float)(float *dst, const float *src1, const float *src2); BLI_INLINE void apply_blend_function_byte(float fac, int x, int y, - unsigned char *rect1, - unsigned char *rect2, - unsigned char *out, + uchar *rect1, + uchar *rect2, + uchar *out, IMB_blend_func_byte blend_function) { - unsigned char *rt1 = rect1; - unsigned char *rt2 = rect2; - unsigned char *rt = out; + uchar *rt1 = rect1; + uchar *rt2 = rect2; + uchar *rt = out; for (int i = 0; i < y; i++) { for (int j = 0; j < x; j++) { - unsigned int achannel = rt2[3]; - rt2[3] = (unsigned int)achannel * fac; + uint achannel = rt2[3]; + rt2[3] = (uint)achannel * fac; blend_function(rt, rt1, rt2); rt2[3] = achannel; rt[3] = rt1[3]; @@ -1213,13 +1209,8 @@ static void do_blend_effect_float( } } -static void do_blend_effect_byte(float fac, - int x, - int y, - unsigned char *rect1, - unsigned char *rect2, - int btype, - unsigned char *out) +static void do_blend_effect_byte( + float fac, int x, int y, uchar *rect1, uchar *rect2, int btype, uchar *out) { switch (btype) { case SEQ_TYPE_ADD: @@ -1309,7 +1300,7 @@ static void do_blend_mode_effect(const SeqRenderData *context, fac, context->rectx, total_lines, rect1, rect2, seq->blend_mode, rect_out); } else { - unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; + uchar *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; slice_get_byte_buffers( context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); do_blend_effect_byte( @@ -1360,7 +1351,7 @@ static void do_colormix_effect(const SeqRenderData *context, fac, context->rectx, total_lines, rect1, rect2, data->blend_effect, rect_out); } else { - unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; + uchar *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; slice_get_byte_buffers( context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); do_blend_effect_byte( @@ -1665,21 +1656,16 @@ static void copy_wipe_effect(Sequence *dst, Sequence *src, const int UNUSED(flag dst->effectdata = MEM_dupallocN(src->effectdata); } -static void do_wipe_effect_byte(Sequence *seq, - float fac, - int x, - int y, - unsigned char *rect1, - unsigned char *rect2, - unsigned char *out) +static void do_wipe_effect_byte( + Sequence *seq, float fac, int x, int y, uchar *rect1, uchar *rect2, uchar *out) { WipeZone wipezone; WipeVars *wipe = (WipeVars *)seq->effectdata; precalc_wipe_zone(&wipezone, wipe, x, y); - unsigned char *cp1 = rect1; - unsigned char *cp2 = rect2; - unsigned char *rt = out; + uchar *cp1 = rect1; + uchar *cp2 = rect2; + uchar *rt = out; for (int i = 0; i < y; i++) { for (int j = 0; j < x; j++) { @@ -1809,9 +1795,9 @@ static ImBuf *do_wipe_effect(const SeqRenderData *context, fac, context->rectx, context->recty, - (unsigned char *)ibuf1->rect, - (unsigned char *)ibuf2->rect, - (unsigned char *)out->rect); + (uchar *)ibuf1->rect, + (uchar *)ibuf2->rect, + (uchar *)out->rect); } return out; @@ -2212,9 +2198,9 @@ static void do_glow_effect_byte(Sequence *seq, float fac, int x, int y, - unsigned char *rect1, - unsigned char *UNUSED(rect2), - unsigned char *out) + uchar *rect1, + uchar *UNUSED(rect2), + uchar *out) { float *outbuf, *inbuf; GlowVars *glow = (GlowVars *)seq->effectdata; @@ -2289,9 +2275,9 @@ static ImBuf *do_glow_effect(const SeqRenderData *context, fac, context->rectx, context->recty, - (unsigned char *)ibuf1->rect, + (uchar *)ibuf1->rect, NULL, - (unsigned char *)out->rect); + (uchar *)out->rect); } return out; @@ -2353,13 +2339,13 @@ static ImBuf *do_solid_color(const SeqRenderData *context, int y = out->y; if (out->rect) { - unsigned char color[4]; + uchar color[4]; color[0] = cv->col[0] * 255; color[1] = cv->col[1] * 255; color[2] = cv->col[2] * 255; color[3] = 255; - unsigned char *rect = (unsigned char *)out->rect; + uchar *rect = (uchar *)out->rect; for (int i = 0; i < y; i++) { for (int j = 0; j < x; j++) { @@ -2745,7 +2731,7 @@ static void do_overdrop_effect(const SeqRenderData *context, do_alphaover_effect_float(fac, x, y, rect1, rect2, rect_out); } else { - unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; + uchar *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; slice_get_byte_buffers( context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); @@ -2835,8 +2821,8 @@ static void do_gaussian_blur_effect_byte_x(Sequence *seq, int y, int frame_width, int UNUSED(frame_height), - const unsigned char *rect, - unsigned char *out) + const uchar *rect, + uchar *out) { #define INDEX(_x, _y) (((_y) * (x) + (_x)) * 4) GaussianBlurVars *data = seq->effectdata; @@ -2885,8 +2871,8 @@ static void do_gaussian_blur_effect_byte_y(Sequence *seq, int y, int UNUSED(frame_width), int frame_height, - const unsigned char *rect, - unsigned char *out) + const uchar *rect, + uchar *out) { #define INDEX(_x, _y) (((_y) * (x) + (_x)) * 4) GaussianBlurVars *data = seq->effectdata; @@ -3032,7 +3018,7 @@ static void do_gaussian_blur_effect_x_cb(const SeqRenderData *context, rect_out); } else { - unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; + uchar *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; slice_get_byte_buffers( context, ibuf, NULL, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); @@ -3043,7 +3029,7 @@ static void do_gaussian_blur_effect_x_cb(const SeqRenderData *context, total_lines, context->rectx, context->recty, - (unsigned char *)ibuf->rect, + (uchar *)ibuf->rect, rect_out); } } @@ -3071,7 +3057,7 @@ static void do_gaussian_blur_effect_y_cb(const SeqRenderData *context, rect_out); } else { - unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; + uchar *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; slice_get_byte_buffers( context, ibuf, NULL, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); @@ -3082,7 +3068,7 @@ static void do_gaussian_blur_effect_y_cb(const SeqRenderData *context, total_lines, context->rectx, context->recty, - (unsigned char *)ibuf->rect, + (uchar *)ibuf->rect, rect_out); } } @@ -3348,7 +3334,7 @@ static ImBuf *do_text_effect(const SeqRenderData *context, } /* set before return */ - BLF_size(font, proxy_size_comp * data->text_size, 72); + BLF_size(font, proxy_size_comp * data->text_size); const int font_flags = BLF_WORD_WRAP | /* Always allow wrapping. */ ((data->flag & SEQ_TEXT_BOLD) ? BLF_BOLD : 0) | @@ -3358,8 +3344,7 @@ static ImBuf *do_text_effect(const SeqRenderData *context, /* use max width to enable newlines only */ BLF_wordwrap(font, (data->wrap_width != 0.0f) ? data->wrap_width * width : -1); - BLF_buffer( - font, out->rect_float, (unsigned char *)out->rect, width, height, out->channels, display); + BLF_buffer(font, out->rect_float, (uchar *)out->rect, width, height, out->channels, display); line_height = BLF_height_max(font); diff --git a/source/blender/sequencer/intern/image_cache.c b/source/blender/sequencer/intern/image_cache.c index 53f076c9681..21ce2cbdf9a 100644 --- a/source/blender/sequencer/intern/image_cache.c +++ b/source/blender/sequencer/intern/image_cache.c @@ -98,9 +98,9 @@ static bool seq_cmp_render_data(const SeqRenderData *a, const SeqRenderData *b) (a->scene->r.views_format != b->scene->r.views_format) || (a->view_id != b->view_id)); } -static unsigned int seq_hash_render_data(const SeqRenderData *a) +static uint seq_hash_render_data(const SeqRenderData *a) { - unsigned int rval = a->rectx + a->recty; + uint rval = a->rectx + a->recty; rval ^= a->preview_render_size; rval ^= ((intptr_t)a->bmain) << 6; @@ -112,12 +112,12 @@ static unsigned int seq_hash_render_data(const SeqRenderData *a) return rval; } -static unsigned int seq_cache_hashhash(const void *key_) +static uint seq_cache_hashhash(const void *key_) { const SeqCacheKey *key = key_; - unsigned int rval = seq_hash_render_data(&key->context); + uint rval = seq_hash_render_data(&key->context); - rval ^= *(const unsigned int *)&key->frame_index; + rval ^= *(const uint *)&key->frame_index; rval += key->type; rval ^= ((intptr_t)key->seq) << 6; @@ -703,8 +703,7 @@ void seq_cache_thumbnail_cleanup(Scene *scene, rctf *view_area_safe) const int frame_index = key->timeline_frame - SEQ_time_left_handle_frame_get(scene, key->seq); const int frame_step = SEQ_render_thumbnails_guaranteed_set_frame_step_get(scene, key->seq); - const int relative_base_frame = round_fl_to_int((frame_index / (float)frame_step)) * - frame_step; + const int relative_base_frame = round_fl_to_int(frame_index / (float)frame_step) * frame_step; const int nearest_guaranted_absolute_frame = relative_base_frame + SEQ_time_left_handle_frame_get(scene, key->seq); @@ -812,8 +811,11 @@ bool seq_cache_put_if_possible( return false; } -void seq_cache_thumbnail_put( - const SeqRenderData *context, Sequence *seq, float timeline_frame, ImBuf *i, rctf *view_area) +void seq_cache_thumbnail_put(const SeqRenderData *context, + Sequence *seq, + float timeline_frame, + ImBuf *i, + const rctf *view_area) { Scene *scene = context->scene; diff --git a/source/blender/sequencer/intern/image_cache.h b/source/blender/sequencer/intern/image_cache.h index a7ae130dc41..7b7e020c926 100644 --- a/source/blender/sequencer/intern/image_cache.h +++ b/source/blender/sequencer/intern/image_cache.h @@ -48,7 +48,7 @@ void seq_cache_thumbnail_put(const struct SeqRenderData *context, struct Sequence *seq, float timeline_frame, struct ImBuf *i, - rctf *view_area); + const struct rctf *view_area); bool seq_cache_put_if_possible(const struct SeqRenderData *context, struct Sequence *seq, float timeline_frame, diff --git a/source/blender/sequencer/intern/modifier.c b/source/blender/sequencer/intern/modifier.c index b17db8f762e..a962bcdbd06 100644 --- a/source/blender/sequencer/intern/modifier.c +++ b/source/blender/sequencer/intern/modifier.c @@ -44,9 +44,9 @@ static bool modifierTypesInit = false; typedef void (*modifier_apply_threaded_cb)(int width, int height, - unsigned char *rect, + uchar *rect, float *rect_float, - unsigned char *mask_rect, + uchar *mask_rect, const float *mask_rect_float, void *data_v); @@ -61,7 +61,7 @@ typedef struct ModifierInitData { typedef struct ModifierThread { int width, height; - unsigned char *rect, *mask_rect; + uchar *rect, *mask_rect; float *rect_float, *mask_rect_float; void *user_data; @@ -140,7 +140,7 @@ static void modifier_init_handle(void *handle_v, int start_line, int tot_line, v handle->user_data = init_data->user_data; if (ibuf->rect) { - handle->rect = (unsigned char *)ibuf->rect + offset; + handle->rect = (uchar *)ibuf->rect + offset; } if (ibuf->rect_float) { @@ -149,7 +149,7 @@ static void modifier_init_handle(void *handle_v, int start_line, int tot_line, v if (mask) { if (mask->rect) { - handle->mask_rect = (unsigned char *)mask->rect + offset; + handle->mask_rect = (uchar *)mask->rect + offset; } if (mask->rect_float) { @@ -345,17 +345,13 @@ static void make_cb_table_float_sop( } } -static void color_balance_byte_byte(StripColorBalance *cb_, - unsigned char *rect, - unsigned char *mask_rect, - int width, - int height, - float mul) +static void color_balance_byte_byte( + StripColorBalance *cb_, uchar *rect, uchar *mask_rect, int width, int height, float mul) { - // unsigned char cb_tab[3][256]; - unsigned char *cp = rect; - unsigned char *e = cp + width * 4 * height; - unsigned char *m = mask_rect; + // uchar cb_tab[3][256]; + uchar *cp = rect; + uchar *e = cp + width * 4 * height; + uchar *m = mask_rect; StripColorBalance cb = calc_cb(cb_); @@ -394,18 +390,18 @@ static void color_balance_byte_byte(StripColorBalance *cb_, } static void color_balance_byte_float(StripColorBalance *cb_, - unsigned char *rect, + uchar *rect, float *rect_float, - unsigned char *mask_rect, + uchar *mask_rect, int width, int height, float mul) { float cb_tab[4][256]; int c, i; - unsigned char *p = rect; - unsigned char *e = p + width * 4 * height; - unsigned char *m = mask_rect; + uchar *p = rect; + uchar *e = p + width * 4 * height; + uchar *m = mask_rect; float *o; StripColorBalance cb; @@ -501,7 +497,7 @@ typedef struct ColorBalanceThread { int width, height; - unsigned char *rect, *mask_rect; + uchar *rect, *mask_rect; float *rect_float, *mask_rect_float; bool make_float; @@ -528,7 +524,7 @@ static void color_balance_init_handle(void *handle_v, handle->make_float = init_data->make_float; if (ibuf->rect) { - handle->rect = (unsigned char *)ibuf->rect + offset; + handle->rect = (uchar *)ibuf->rect + offset; } if (ibuf->rect_float) { @@ -537,7 +533,7 @@ static void color_balance_init_handle(void *handle_v, if (mask) { if (mask->rect) { - handle->mask_rect = (unsigned char *)mask->rect + offset; + handle->mask_rect = (uchar *)mask->rect + offset; } if (mask->rect_float) { @@ -555,8 +551,8 @@ static void *color_balance_do_thread(void *thread_data_v) ColorBalanceThread *thread_data = (ColorBalanceThread *)thread_data_v; StripColorBalance *cb = thread_data->cb; int width = thread_data->width, height = thread_data->height; - unsigned char *rect = thread_data->rect; - unsigned char *mask_rect = thread_data->mask_rect; + uchar *rect = thread_data->rect; + uchar *mask_rect = thread_data->mask_rect; float *rect_float = thread_data->rect_float; float *mask_rect_float = thread_data->mask_rect_float; float mul = thread_data->mul; @@ -657,9 +653,9 @@ typedef struct WhiteBalanceThreadData { static void whiteBalance_apply_threaded(int width, int height, - unsigned char *rect, + uchar *rect, float *rect_float, - unsigned char *mask_rect, + uchar *mask_rect, const float *mask_rect_float, void *data_v) { @@ -765,9 +761,9 @@ static void curves_copy_data(SequenceModifierData *target, SequenceModifierData static void curves_apply_threaded(int width, int height, - unsigned char *rect, + uchar *rect, float *rect_float, - unsigned char *mask_rect, + uchar *mask_rect, const float *mask_rect_float, void *data_v) { @@ -798,7 +794,7 @@ static void curves_apply_threaded(int width, } } if (rect) { - unsigned char *pixel = rect + pixel_index; + uchar *pixel = rect + pixel_index; float result[3], tempc[4]; straight_uchar_to_premul_float(tempc, pixel); @@ -895,9 +891,9 @@ static void hue_correct_copy_data(SequenceModifierData *target, SequenceModifier static void hue_correct_apply_threaded(int width, int height, - unsigned char *rect, + uchar *rect, float *rect_float, - unsigned char *mask_rect, + uchar *mask_rect, const float *mask_rect_float, void *data_v) { @@ -990,9 +986,9 @@ typedef struct BrightContrastThreadData { static void brightcontrast_apply_threaded(int width, int height, - unsigned char *rect, + uchar *rect, float *rect_float, - unsigned char *mask_rect, + uchar *mask_rect, const float *mask_rect_float, void *data_v) { @@ -1008,7 +1004,7 @@ static void brightcontrast_apply_threaded(int width, /* * The algorithm is by Werner D. Streidt * (http://visca.com/ffactory/archives/5-99/msg00021.html) - * Extracted of OpenCV demhist.c + * Extracted of OpenCV `demhist.c`. */ if (contrast > 0) { a = 1.0f - delta * 2.0f; @@ -1026,14 +1022,14 @@ static void brightcontrast_apply_threaded(int width, int pixel_index = (y * width + x) * 4; if (rect) { - unsigned char *pixel = rect + pixel_index; + uchar *pixel = rect + pixel_index; for (c = 0; c < 3; c++) { i = (float)pixel[c] / 255.0f; v = a * i + b; if (mask_rect) { - unsigned char *m = mask_rect + pixel_index; + uchar *m = mask_rect + pixel_index; float t = (float)m[c] / 255.0f; v = (float)pixel[c] / 255.0f * (1.0f - t) + v * t; @@ -1092,9 +1088,9 @@ static SequenceModifierTypeInfo seqModifier_BrightContrast = { static void maskmodifier_apply_threaded(int width, int height, - unsigned char *rect, + uchar *rect, float *rect_float, - unsigned char *mask_rect, + uchar *mask_rect, const float *mask_rect_float, void *UNUSED(data_v)) { @@ -1113,9 +1109,9 @@ static void maskmodifier_apply_threaded(int width, int pixel_index = (y * width + x) * 4; if (rect) { - unsigned char *pixel = rect + pixel_index; - unsigned char *mask_pixel = mask_rect + pixel_index; - unsigned char mask = min_iii(mask_pixel[0], mask_pixel[1], mask_pixel[2]); + uchar *pixel = rect + pixel_index; + uchar *mask_pixel = mask_rect + pixel_index; + uchar mask = min_iii(mask_pixel[0], mask_pixel[1], mask_pixel[2]); /* byte buffer is straight, so only affect on alpha itself, * this is the only way to alpha-over byte strip after @@ -1177,7 +1173,7 @@ typedef struct AvgLogLum { static void tonemapmodifier_init_data(SequenceModifierData *smd) { SequencerTonemapModifierData *tmmd = (SequencerTonemapModifierData *)smd; - /* Same as tonemap compositor node. */ + /* Same as tone-map compositor node. */ tmmd->type = SEQ_TONEMAP_RD_PHOTORECEPTOR; tmmd->key = 0.18f; tmmd->offset = 1.0f; @@ -1190,9 +1186,9 @@ static void tonemapmodifier_init_data(SequenceModifierData *smd) static void tonemapmodifier_apply_threaded_simple(int width, int height, - unsigned char *rect, + uchar *rect, float *rect_float, - unsigned char *mask_rect, + uchar *mask_rect, const float *mask_rect_float, void *data_v) { @@ -1249,9 +1245,9 @@ static void tonemapmodifier_apply_threaded_simple(int width, static void tonemapmodifier_apply_threaded_photoreceptor(int width, int height, - unsigned char *rect, + uchar *rect, float *rect_float, - unsigned char *mask_rect, + uchar *mask_rect, const float *mask_rect_float, void *data_v) { @@ -1319,7 +1315,7 @@ static void tonemapmodifier_apply(struct SequenceModifierData *smd, ImBuf *ibuf, float lsum = 0.0f; int p = ibuf->x * ibuf->y; float *fp = ibuf->rect_float; - unsigned char *cp = (unsigned char *)ibuf->rect; + uchar *cp = (uchar *)ibuf->rect; float avl, maxl = -FLT_MAX, minl = FLT_MAX; const float sc = 1.0f / p; float Lav = 0.0f; diff --git a/source/blender/sequencer/intern/proxy.c b/source/blender/sequencer/intern/proxy.c index 4220efab8bf..eaea310f423 100644 --- a/source/blender/sequencer/intern/proxy.c +++ b/source/blender/sequencer/intern/proxy.c @@ -106,7 +106,7 @@ bool seq_proxy_get_custom_file_fname(Sequence *seq, char *name, const int view_i return false; } - BLI_join_dirfile(fname, PROXY_MAXFILE, proxy->dir, proxy->file); + BLI_path_join(fname, PROXY_MAXFILE, proxy->dir, proxy->file); BLI_path_abs(fname, BKE_main_blendfile_path_from_global()); if (view_id > 0) { @@ -325,7 +325,7 @@ static bool seq_proxy_multiview_context_invalid(Sequence *seq, Scene *scene, con if (view_id == 0) { char path[FILE_MAX]; - BLI_join_dirfile(path, sizeof(path), seq->strip->dir, seq->strip->stripdata->name); + BLI_path_join(path, sizeof(path), seq->strip->dir, seq->strip->stripdata->name); BLI_path_abs(path, BKE_main_blendfile_path_from_global()); BKE_scene_multiview_view_prefix_get(scene, path, prefix, &ext); } @@ -479,10 +479,7 @@ bool SEQ_proxy_rebuild_context(Main *bmain, return true; } -void SEQ_proxy_rebuild(SeqIndexBuildContext *context, - short *stop, - short *do_update, - float *progress) +void SEQ_proxy_rebuild(SeqIndexBuildContext *context, bool *stop, bool *do_update, float *progress) { const bool overwrite = context->overwrite; SeqRenderData render_context; @@ -585,8 +582,7 @@ void seq_proxy_index_dir_set(struct anim *anim, const char *base_dir) char fname[FILE_MAXFILE]; IMB_anim_get_fname(anim, fname, FILE_MAXFILE); - BLI_strncpy(dir, base_dir, sizeof(dir)); - BLI_path_append(dir, sizeof(dir), fname); + BLI_path_join(dir, sizeof(dir), base_dir, fname); IMB_anim_set_index_dir(anim, dir); } diff --git a/source/blender/sequencer/intern/proxy_job.c b/source/blender/sequencer/intern/proxy_job.c index 8520c06f9a2..d7dfe0130d8 100644 --- a/source/blender/sequencer/intern/proxy_job.c +++ b/source/blender/sequencer/intern/proxy_job.c @@ -41,7 +41,7 @@ static void proxy_freejob(void *pjv) } /* Only this runs inside thread. */ -static void proxy_startjob(void *pjv, short *stop, short *do_update, float *progress) +static void proxy_startjob(void *pjv, bool *stop, bool *do_update, float *progress) { ProxyJob *pj = pjv; LinkData *link; @@ -52,7 +52,7 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog SEQ_proxy_rebuild(context, stop, do_update, progress); if (*stop) { - pj->stop = 1; + pj->stop = true; fprintf(stderr, "Canceling proxy rebuild on users request...\n"); break; } diff --git a/source/blender/sequencer/intern/render.c b/source/blender/sequencer/intern/render.c index fd3b6103b94..5c6a59a5943 100644 --- a/source/blender/sequencer/intern/render.c +++ b/source/blender/sequencer/intern/render.c @@ -123,12 +123,8 @@ void seq_imbuf_to_sequencer_space(Scene *scene, ImBuf *ibuf, bool make_float) * However, this might also have negative effect by adding weird * artifacts which will then not happen in final render. */ - IMB_colormanagement_transform_byte_threaded((unsigned char *)ibuf->rect, - ibuf->x, - ibuf->y, - ibuf->channels, - from_colorspace, - to_colorspace); + IMB_colormanagement_transform_byte_threaded( + (uchar *)ibuf->rect, ibuf->x, ibuf->y, ibuf->channels, from_colorspace, to_colorspace); } else { /* We perform conversion to a float buffer so we don't worry about @@ -136,7 +132,7 @@ void seq_imbuf_to_sequencer_space(Scene *scene, ImBuf *ibuf, bool make_float) */ imb_addrectfloatImBuf(ibuf, 4); IMB_colormanagement_transform_from_byte_threaded(ibuf->rect_float, - (unsigned char *)ibuf->rect, + (uchar *)ibuf->rect, ibuf->x, ibuf->y, ibuf->channels, @@ -942,7 +938,7 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context, return NULL; } - BLI_join_dirfile(name, sizeof(name), seq->strip->dir, s_elem->name); + BLI_path_join(name, sizeof(name), seq->strip->dir, s_elem->name); BLI_path_abs(name, BKE_main_blendfile_path_from_global()); /* Try to get a proxy image. */ @@ -1030,6 +1026,15 @@ static ImBuf *seq_render_movie_strip_custom_file_proxy(const SeqRenderData *cont return IMB_anim_absolute(proxy->anim, frameno, IMB_TC_NONE, IMB_PROXY_NONE); } +static IMB_Timecode_Type seq_render_movie_strip_timecode_get(Sequence *seq) +{ + bool use_timecodes = (seq->flag & SEQ_USE_PROXY) != 0; + if (!use_timecodes) { + return IMB_TC_NONE; + } + return seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_NONE; +} + /** * Render individual view for multi-view or single (default view) for mono-view. */ @@ -1053,7 +1058,7 @@ static ImBuf *seq_render_movie_strip_view(const SeqRenderData *context, else { ibuf = IMB_anim_absolute(sanim->anim, frame_index + seq->anim_startofs, - seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN, + seq_render_movie_strip_timecode_get(seq), psize); } @@ -1066,7 +1071,7 @@ static ImBuf *seq_render_movie_strip_view(const SeqRenderData *context, if (ibuf == NULL) { ibuf = IMB_anim_absolute(sanim->anim, frame_index + seq->anim_startofs, - seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN, + seq_render_movie_strip_timecode_get(seq), IMB_PROXY_NONE); } if (ibuf == NULL) { @@ -1298,15 +1303,15 @@ ImBuf *seq_render_mask(const SeqRenderData *context, else { /* pixels */ const float *fp_src; - unsigned char *ub_dst; + uchar *ub_dst; ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect); fp_src = maskbuf; - ub_dst = (unsigned char *)ibuf->rect; + ub_dst = (uchar *)ibuf->rect; i = context->rectx * context->recty; while (--i) { - ub_dst[0] = ub_dst[1] = ub_dst[2] = (unsigned char)(*fp_src * 255.0f); /* already clamped */ + ub_dst[0] = ub_dst[1] = ub_dst[2] = (uchar)(*fp_src * 255.0f); /* already clamped */ ub_dst[3] = 255; fp_src += 1; @@ -1352,7 +1357,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, * find render). * However, when called from within the UI (image preview in sequencer) * we do want to use scene Render, that way the render result is defined - * for display in render/imagewindow + * for display in render/image-window * * Hmm, don't see, why we can't do that all the time, * and since G.is_rendering is uhm, gone... (Peter) @@ -1451,7 +1456,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, BKE_render_resolution(&scene->r, false, &width, &height); const char *viewname = BKE_scene_multiview_render_view_name_get(&scene->r, context->view_id); - unsigned int draw_flags = V3D_OFSDRAW_NONE; + uint draw_flags = V3D_OFSDRAW_NONE; draw_flags |= (use_gpencil) ? V3D_OFSDRAW_SHOW_ANNOTATION : 0; draw_flags |= (context->scene->r.seq_flag & R_SEQ_OVERRIDE_SCENE_SETTINGS) ? V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS : @@ -1506,8 +1511,16 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, re = RE_NewSceneRender(scene); } - RE_RenderFrame( - re, context->bmain, scene, have_comp ? NULL : view_layer, camera, frame, 0.0f, false); + const float subframe = frame - floorf(frame); + + RE_RenderFrame(re, + context->bmain, + scene, + have_comp ? NULL : view_layer, + camera, + floorf(frame), + subframe, + false); /* restore previous state after it was toggled on & off by RE_RenderFrame */ G.is_rendering = is_rendering; @@ -1997,7 +2010,7 @@ ImBuf *SEQ_render_give_ibuf_direct(const SeqRenderData *context, float SEQ_render_thumbnail_first_frame_get(const Scene *scene, Sequence *seq, float frame_step, - rctf *view_area) + const rctf *view_area) { int first_drawable_frame = max_iii( SEQ_time_left_handle_frame_get(scene, seq), seq->start, view_area->xmin); @@ -2089,8 +2102,8 @@ void SEQ_render_thumbnails(const SeqRenderData *context, Sequence *seq, Sequence *seq_orig, float frame_step, - rctf *view_area, - const short *stop) + const rctf *view_area, + const bool *stop) { SeqRenderState state; seq_render_state_init(&state); @@ -2099,7 +2112,7 @@ void SEQ_render_thumbnails(const SeqRenderData *context, /* Adding the hold offset value (seq->anim_startofs) to the start frame. Position of image not * affected, but frame loaded affected. */ float upper_thumb_bound = SEQ_time_has_right_still_frames(scene, seq) ? - (seq->start + seq->len) : + SEQ_time_content_end_frame_get(scene, seq) : SEQ_time_right_handle_frame_get(scene, seq); upper_thumb_bound = (upper_thumb_bound > view_area->xmax) ? view_area->xmax + frame_step : upper_thumb_bound; @@ -2133,9 +2146,10 @@ void SEQ_render_thumbnails(const SeqRenderData *context, int SEQ_render_thumbnails_guaranteed_set_frame_step_get(const Scene *scene, const Sequence *seq) { - const int content_start = max_ii(SEQ_time_left_handle_frame_get(scene, seq), seq->start); + const int content_start = max_ii(SEQ_time_left_handle_frame_get(scene, seq), + SEQ_time_start_frame_get(seq)); const int content_end = min_ii(SEQ_time_right_handle_frame_get(scene, seq), - seq->start + seq->len); + SEQ_time_content_end_frame_get(scene, seq)); const int content_len = content_end - content_start; /* Arbitrary, but due to performance reasons should be as low as possible. */ @@ -2149,8 +2163,8 @@ int SEQ_render_thumbnails_guaranteed_set_frame_step_get(const Scene *scene, cons void SEQ_render_thumbnails_base_set(const SeqRenderData *context, Sequence *seq, Sequence *seq_orig, - rctf *view_area, - const short *stop) + const rctf *view_area, + const bool *stop) { SeqRenderState state; seq_render_state_init(&state); diff --git a/source/blender/sequencer/intern/sequencer.c b/source/blender/sequencer/intern/sequencer.c index 4548975574d..c6f4d47ac75 100644 --- a/source/blender/sequencer/intern/sequencer.c +++ b/source/blender/sequencer/intern/sequencer.c @@ -171,7 +171,7 @@ static void seq_sequence_free_ex(Scene *scene, } if (seq->sound && do_id_user) { - id_us_min(((ID *)seq->sound)); + id_us_min((ID *)seq->sound); } if (seq->stereo3d_format) { diff --git a/source/blender/sequencer/intern/sound.c b/source/blender/sequencer/intern/sound.c index c4992848cb5..69ccbdcb54e 100644 --- a/source/blender/sequencer/intern/sound.c +++ b/source/blender/sequencer/intern/sound.c @@ -26,7 +26,8 @@ #include "sequencer.h" #include "strip_time.h" -/* Unlike _update_sound_ funcs, these ones take info from audaspace to update sequence length! */ +/* Unlike _update_sound_ functions, + * these ones take info from audaspace to update sequence length! */ #ifdef WITH_AUDASPACE static bool sequencer_refresh_sound_length_recursive(Main *bmain, Scene *scene, ListBase *seqbase) { diff --git a/source/blender/sequencer/intern/strip_add.c b/source/blender/sequencer/intern/strip_add.c index 753a6ee39e0..d98a00aa9a5 100644 --- a/source/blender/sequencer/intern/strip_add.c +++ b/source/blender/sequencer/intern/strip_add.c @@ -204,7 +204,7 @@ void SEQ_add_image_init_alpha_mode(Sequence *seq) char name[FILE_MAX]; ImBuf *ibuf; - BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name); + BLI_path_join(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name); BLI_path_abs(name, BKE_main_blendfile_path_from_global()); /* Initialize input color space. */ @@ -545,7 +545,7 @@ void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const boo const bool is_multiview = (seq->flag & SEQ_USE_VIEWS) != 0 && (scene->r.scemode & R_MULTIVIEW) != 0; - BLI_join_dirfile(path, sizeof(path), seq->strip->dir, seq->strip->stripdata->name); + BLI_path_join(path, sizeof(path), seq->strip->dir, seq->strip->stripdata->name); BLI_path_abs(path, BKE_main_blendfile_path_from_global()); SEQ_relations_sequence_free_anim(seq); @@ -668,7 +668,6 @@ void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const boo if (lock_range) { SEQ_time_left_handle_frame_set(scene, seq, prev_startdisp); SEQ_time_right_handle_frame_set(scene, seq, prev_enddisp); - SEQ_transform_fix_single_image_seq_offsets(scene, seq); } SEQ_relations_invalidate_cache_raw(scene, seq); diff --git a/source/blender/sequencer/intern/strip_edit.c b/source/blender/sequencer/intern/strip_edit.c index c35138b280a..69e43f3679c 100644 --- a/source/blender/sequencer/intern/strip_edit.c +++ b/source/blender/sequencer/intern/strip_edit.c @@ -258,49 +258,50 @@ bool SEQ_edit_move_strip_to_meta(Scene *scene, return true; } -static void seq_split_set_left_hold_offset(Scene *scene, Sequence *seq, int timeline_frame) +static void seq_split_set_right_hold_offset(Scene *scene, Sequence *seq, int timeline_frame) { - /* Adjust within range of extended stillframes before strip. */ - if (timeline_frame < seq->start) { - seq->start = timeline_frame - 1; - seq->anim_endofs += SEQ_time_strip_length_get(scene, seq) - 1; - seq->startstill = timeline_frame - seq->startdisp - 1; - seq->endstill = 0; + const float content_start = SEQ_time_start_frame_get(seq); + const float content_end = SEQ_time_content_end_frame_get(scene, seq); + + /* Adjust within range of extended still-frames before strip. */ + if (timeline_frame < content_start) { + const float offset = content_start + 1 - timeline_frame; + seq->start -= offset; + seq->startofs += offset; + SEQ_time_right_handle_frame_set(scene, seq, timeline_frame); } /* Adjust within range of strip contents. */ - else if ((timeline_frame >= seq->start) && - (timeline_frame <= (seq->start + SEQ_time_strip_length_get(scene, seq)))) { + else if ((timeline_frame >= content_start) && (timeline_frame <= content_end)) { seq->endofs = 0; - seq->endstill = 0; - seq->anim_endofs += (seq->start + SEQ_time_strip_length_get(scene, seq)) - timeline_frame; + seq->anim_endofs += (content_end - timeline_frame) * seq->speed_factor; } - /* Adjust within range of extended stillframes after strip. */ - else if ((seq->start + SEQ_time_strip_length_get(scene, seq)) < timeline_frame) { - seq->endstill = timeline_frame - seq->start - SEQ_time_strip_length_get(scene, seq); + /* Adjust within range of extended still-frames after strip. */ + else if (timeline_frame > content_end) { + SEQ_time_right_handle_frame_set(scene, seq, timeline_frame); } } -static void seq_split_set_right_hold_offset(Scene *scene, Sequence *seq, int timeline_frame) +static void seq_split_set_left_hold_offset(Scene *scene, Sequence *seq, int timeline_frame) { - /* Adjust within range of extended stillframes before strip. */ - if (timeline_frame < seq->start) { - seq->startstill = seq->start - timeline_frame; + const float content_start = SEQ_time_start_frame_get(seq); + const float content_end = SEQ_time_content_end_frame_get(scene, seq); + + /* Adjust within range of extended still-frames before strip. */ + if (timeline_frame < content_start) { + SEQ_time_left_handle_frame_set(scene, seq, timeline_frame); } /* Adjust within range of strip contents. */ - else if ((timeline_frame >= seq->start) && - (timeline_frame <= (seq->start + SEQ_time_strip_length_get(scene, seq)))) { - seq->anim_startofs += timeline_frame - seq->start; + else if ((timeline_frame >= content_start) && (timeline_frame <= content_end)) { + seq->anim_startofs += (timeline_frame - content_start) * seq->speed_factor; seq->start = timeline_frame; - seq->startstill = 0; seq->startofs = 0; } - /* Adjust within range of extended stillframes after strip. */ - else if ((seq->start + SEQ_time_strip_length_get(scene, seq)) < timeline_frame) { - seq->start = timeline_frame; - seq->startofs = 0; - seq->anim_startofs += SEQ_time_strip_length_get(scene, seq) - 1; - seq->endstill = seq->enddisp - timeline_frame - 1; - seq->startstill = 0; + /* Adjust within range of extended still-frames after strip. */ + else if (timeline_frame > content_end) { + const float offset = timeline_frame - content_end + 1; + seq->start += offset; + seq->endofs += offset; + SEQ_time_left_handle_frame_set(scene, seq, timeline_frame); } } diff --git a/source/blender/sequencer/intern/strip_time.c b/source/blender/sequencer/intern/strip_time.c index 5d8266dbc6e..0b480b22e91 100644 --- a/source/blender/sequencer/intern/strip_time.c +++ b/source/blender/sequencer/intern/strip_time.c @@ -53,7 +53,7 @@ float seq_give_frame_index(const Scene *scene, Sequence *seq, float timeline_fra { float frame_index; float sta = SEQ_time_start_frame_get(seq); - float end = SEQ_time_start_frame_get(seq) + SEQ_time_strip_length_get(scene, seq) - 1; + float end = SEQ_time_content_end_frame_get(scene, seq) - 1; if (seq->type & SEQ_TYPE_EFFECT) { end = SEQ_time_right_handle_frame_get(scene, seq); @@ -169,11 +169,16 @@ void SEQ_time_update_meta_strip_range(const Scene *scene, Sequence *seq_meta) seq_meta->len -= seq_meta->anim_startofs; seq_meta->len -= seq_meta->anim_endofs; - seq_update_sound_bounds_recursive(scene, seq_meta); + /* Functions `SEQ_time_*_handle_frame_set()` can not be used here, because they are clamped, so + * change must be done at once. */ + seq_meta->startofs = strip_start - seq_meta->start; + seq_meta->startdisp = strip_start; /* Only to make files usable in older versions. */ + seq_meta->endofs = seq_meta->start + SEQ_time_strip_length_get(scene, seq_meta) - strip_end; + seq_meta->enddisp = strip_end; /* Only to make files usable in older versions. */ - /* Prevent meta-strip to move in timeline. */ - SEQ_time_left_handle_frame_set(scene, seq_meta, strip_start); - SEQ_time_right_handle_frame_set(scene, seq_meta, strip_end); + seq_update_sound_bounds_recursive(scene, seq_meta); + SEQ_time_update_meta_strip_range(scene, seq_sequence_lookup_meta_by_seq(scene, seq_meta)); + seq_time_update_effects_strip_range(scene, seq_sequence_lookup_effects_by_seq(scene, seq_meta)); } void seq_time_effect_range_set(const Scene *scene, Sequence *seq) @@ -465,8 +470,7 @@ bool SEQ_time_has_left_still_frames(const Scene *scene, const Sequence *seq) bool SEQ_time_has_right_still_frames(const Scene *scene, const Sequence *seq) { - return SEQ_time_right_handle_frame_get(scene, seq) > - SEQ_time_start_frame_get(seq) + SEQ_time_strip_length_get(scene, seq); + return SEQ_time_right_handle_frame_get(scene, seq) > SEQ_time_content_end_frame_get(scene, seq); } bool SEQ_time_has_still_frames(const Scene *scene, const Sequence *seq) @@ -474,8 +478,6 @@ bool SEQ_time_has_still_frames(const Scene *scene, const Sequence *seq) return SEQ_time_has_right_still_frames(scene, seq) || SEQ_time_has_left_still_frames(scene, seq); } -/* Length of strip content in frames. This is number of original frames adjusted by playback rate - * factor */ int SEQ_time_strip_length_get(const Scene *scene, const Sequence *seq) { if (seq->type == SEQ_TYPE_SOUND_RAM) { @@ -485,7 +487,6 @@ int SEQ_time_strip_length_get(const Scene *scene, const Sequence *seq) return seq->len / seq_time_playback_rate_factor_get(scene, seq); } -/* Return timeline frame, where strip content starts. */ float SEQ_time_start_frame_get(const Sequence *seq) { return seq->start; @@ -498,6 +499,11 @@ void SEQ_time_start_frame_set(const Scene *scene, Sequence *seq, int timeline_fr seq_time_update_effects_strip_range(scene, seq_sequence_lookup_effects_by_seq(scene, seq)); } +float SEQ_time_content_end_frame_get(const Scene *scene, const Sequence *seq) +{ + return SEQ_time_start_frame_get(seq) + SEQ_time_strip_length_get(scene, seq); +} + int SEQ_time_left_handle_frame_get(const Scene *UNUSED(scene), const Sequence *seq) { if (seq->seq1 || seq->seq2) { @@ -513,35 +519,56 @@ int SEQ_time_right_handle_frame_get(const Scene *scene, const Sequence *seq) return seq->enddisp; } - return seq->start + SEQ_time_strip_length_get(scene, seq) - seq->endofs; + return SEQ_time_content_end_frame_get(scene, seq) - seq->endofs; } -void SEQ_time_left_handle_frame_set(const Scene *scene, Sequence *seq, int val) +void SEQ_time_left_handle_frame_set(const Scene *scene, Sequence *seq, int timeline_frame) { const float right_handle_orig_frame = SEQ_time_right_handle_frame_get(scene, seq); - if (val >= right_handle_orig_frame) { - val = right_handle_orig_frame - 1; + if (timeline_frame >= right_handle_orig_frame) { + timeline_frame = right_handle_orig_frame - 1; + } + + float offset = timeline_frame - SEQ_time_start_frame_get(seq); + + if (SEQ_transform_single_image_check(seq)) { + /* This strip has only 1 frame of content, that is always stretched to whole strip length. + * Therefore, strip start should be moved instead of adjusting offset. */ + SEQ_time_start_frame_set(scene, seq, timeline_frame); + seq->endofs += offset; + } + else { + seq->startofs = offset; } - seq->startofs = val - seq->start; - seq->startdisp = val; /* Only to make files usable in older versions. */ + seq->startdisp = timeline_frame; /* Only to make files usable in older versions. */ SEQ_time_update_meta_strip_range(scene, seq_sequence_lookup_meta_by_seq(scene, seq)); seq_time_update_effects_strip_range(scene, seq_sequence_lookup_effects_by_seq(scene, seq)); } -void SEQ_time_right_handle_frame_set(const Scene *scene, Sequence *seq, int val) +void SEQ_time_right_handle_frame_set(const Scene *scene, Sequence *seq, int timeline_frame) { - const float strip_content_end_frame = seq->start + SEQ_time_strip_length_get(scene, seq); const float left_handle_orig_frame = SEQ_time_left_handle_frame_get(scene, seq); - if (val <= left_handle_orig_frame) { - val = left_handle_orig_frame + 1; + if (timeline_frame <= left_handle_orig_frame) { + timeline_frame = left_handle_orig_frame + 1; } - seq->endofs = strip_content_end_frame - val; - seq->enddisp = val; /* Only to make files usable in older versions. */ + seq->endofs = SEQ_time_content_end_frame_get(scene, seq) - timeline_frame; + seq->enddisp = timeline_frame; /* Only to make files usable in older versions. */ + + SEQ_time_update_meta_strip_range(scene, seq_sequence_lookup_meta_by_seq(scene, seq)); + seq_time_update_effects_strip_range(scene, seq_sequence_lookup_effects_by_seq(scene, seq)); +} + +void seq_time_translate_handles(const Scene *scene, Sequence *seq, const int offset) +{ + seq->startofs += offset; + seq->endofs -= offset; + seq->startdisp += offset; /* Only to make files usable in older versions. */ + seq->enddisp -= offset; /* Only to make files usable in older versions. */ SEQ_time_update_meta_strip_range(scene, seq_sequence_lookup_meta_by_seq(scene, seq)); seq_time_update_effects_strip_range(scene, seq_sequence_lookup_effects_by_seq(scene, seq)); diff --git a/source/blender/sequencer/intern/strip_time.h b/source/blender/sequencer/intern/strip_time.h index db581649f8a..19f549924df 100644 --- a/source/blender/sequencer/intern/strip_time.h +++ b/source/blender/sequencer/intern/strip_time.h @@ -40,6 +40,7 @@ void seq_time_gap_info_get(const struct Scene *scene, struct GapInfo *r_gap_info); void seq_time_effect_range_set(const struct Scene *scene, Sequence *seq); void seq_time_update_effects_strip_range(const struct Scene *scene, struct SeqCollection *effects); +void seq_time_translate_handles(const struct Scene *scene, struct Sequence *seq, const int offset); #ifdef __cplusplus } diff --git a/source/blender/sequencer/intern/strip_transform.c b/source/blender/sequencer/intern/strip_transform.c index a7361cbb1f9..14875df9445 100644 --- a/source/blender/sequencer/intern/strip_transform.c +++ b/source/blender/sequencer/intern/strip_transform.c @@ -82,27 +82,6 @@ bool SEQ_transform_seqbase_isolated_sel_check(ListBase *seqbase) return true; } -void SEQ_transform_fix_single_image_seq_offsets(const Scene *scene, Sequence *seq) -{ - int left, start; - if (!SEQ_transform_single_image_check(seq)) { - return; - } - - /* make sure the image is always at the start since there is only one, - * adjusting its start should be ok */ - left = SEQ_time_left_handle_frame_get(scene, seq); - start = seq->start; - if (start != left) { - const int offset = left - start; - SEQ_time_left_handle_frame_set( - scene, seq, SEQ_time_left_handle_frame_get(scene, seq) - offset); - SEQ_time_right_handle_frame_set( - scene, seq, SEQ_time_right_handle_frame_get(scene, seq) - offset); - seq->start += offset; - } -} - bool SEQ_transform_sequence_can_be_translated(Sequence *seq) { return !(seq->type & SEQ_TYPE_EFFECT) || (SEQ_effect_get_num_inputs(seq->type) == 0); @@ -146,12 +125,9 @@ void SEQ_transform_translate_sequence(Scene *evil_scene, Sequence *seq, int delt SEQ_transform_translate_sequence(evil_scene, seq_child, delta); } /* Move meta start/end points. */ - SEQ_time_left_handle_frame_set( - evil_scene, seq, SEQ_time_left_handle_frame_get(evil_scene, seq) + delta); - SEQ_time_right_handle_frame_set( - evil_scene, seq, SEQ_time_right_handle_frame_get(evil_scene, seq) + delta); + seq_time_translate_handles(evil_scene, seq, delta); } - else { /* All other strip types. */ + else if (seq->seq1 == NULL && seq->seq2 == NULL) { /* All other strip types. */ seq->start += delta; /* Only to make files usable in older versions. */ seq->startdisp = SEQ_time_left_handle_frame_get(evil_scene, seq); diff --git a/source/blender/sequencer/intern/utils.c b/source/blender/sequencer/intern/utils.c index e6c641a5532..5b70bc33e88 100644 --- a/source/blender/sequencer/intern/utils.c +++ b/source/blender/sequencer/intern/utils.c @@ -224,7 +224,7 @@ void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile) /* reset all the previously created anims */ SEQ_relations_sequence_free_anim(seq); - BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name); + BLI_path_join(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name); BLI_path_abs(name, BKE_main_blendfile_path_from_global()); proxy = seq->strip->proxy; @@ -407,7 +407,7 @@ Sequence *SEQ_sequence_from_strip_elem(ListBase *seqbase, StripElem *se) for (iseq = seqbase->first; iseq; iseq = iseq->next) { Sequence *seq_found; if ((iseq->strip && iseq->strip->stripdata) && - (ARRAY_HAS_ITEM(se, iseq->strip->stripdata, iseq->len))) { + ARRAY_HAS_ITEM(se, iseq->strip->stripdata, iseq->len)) { break; } if ((seq_found = SEQ_sequence_from_strip_elem(&iseq->seqbase, se))) { |