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/sequencer.c')
-rw-r--r--source/blender/blenkernel/intern/sequencer.c116
1 files changed, 74 insertions, 42 deletions
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 90c3347a1df..a947a48938e 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -53,6 +53,8 @@
#include "BLI_threads.h"
#include "BLI_utildefines.h"
+#include "BLF_translation.h"
+
#include "BKE_animsys.h"
#include "BKE_global.h"
#include "BKE_image.h"
@@ -507,8 +509,8 @@ static void seq_update_sound_bounds_recursive_rec(Scene *scene, Sequence *metase
* since sound is played outside of evaluating the imbufs, */
for (seq = metaseq->seqbase.first; seq; seq = seq->next) {
if (seq->type == SEQ_TYPE_META) {
- seq_update_sound_bounds_recursive_rec(scene, seq, maxi(start, metaseq_start(seq)),
- mini(end, metaseq_end(seq)));
+ seq_update_sound_bounds_recursive_rec(scene, seq, max_ii(start, metaseq_start(seq)),
+ min_ii(end, metaseq_end(seq)));
}
else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SCENE)) {
if (seq->scene_sound) {
@@ -674,8 +676,8 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, int lock_range)
if (seq->anim) IMB_free_anim(seq->anim);
- /* OCIO_TODO: support configurable input space for strips */
- seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, NULL);
+ seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
+ seq->streamindex, seq->strip->colorspace_settings.name);
if (!seq->anim) {
return;
@@ -717,7 +719,7 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, int lock_range)
#ifdef WITH_AUDASPACE
if (!seq->sound)
return;
- seq->len = ceil(AUD_getInfo(seq->sound->playback_handle).length * FPS);
+ seq->len = ceil((double)AUD_getInfo(seq->sound->playback_handle).length * FPS);
seq->len -= seq->anim_startofs;
seq->len -= seq->anim_endofs;
if (seq->len < 0) {
@@ -991,7 +993,7 @@ static float give_stripelem_index(Sequence *seq, float cfra)
if (seq->type & SEQ_TYPE_EFFECT) {
end = seq->enddisp;
- }
+ }
if (end < sta) {
return -1;
@@ -1172,8 +1174,8 @@ static void seq_open_anim_file(Sequence *seq)
seq->strip->dir, seq->strip->stripdata->name);
BLI_path_abs(name, G.main->name);
- /* OCIO_TODO: support configurable input space for strips */
- seq->anim = openanim(name, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, NULL);
+ seq->anim = openanim(name, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
+ seq->streamindex, seq->strip->colorspace_settings.name);
if (seq->anim == NULL) {
return;
@@ -1299,7 +1301,6 @@ static ImBuf *seq_proxy_fetch(SeqRenderData context, Sequence *seq, int cfra)
}
if (BLI_exists(name)) {
- /* OCIO_TODO: support configurable spaces for strips */
ImBuf *ibuf = IMB_loadiffname(name, IB_rect, NULL);
if (ibuf)
@@ -1344,7 +1345,6 @@ static void seq_proxy_build_frame(SeqRenderData context, Sequence *seq, int cfra
BLI_make_existing_file(name);
- /* OCIO_TODO: support per-strip color space settings */
ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat);
if (ok == 0) {
perror(name);
@@ -1882,7 +1882,7 @@ static ImBuf *input_preprocess(SeqRenderData context, Sequence *seq, float cfra,
ibuf = i;
}
- }
+ }
if (seq->flag & SEQ_FLIPX) {
IMB_flipx(ibuf);
@@ -1965,17 +1965,20 @@ static ImBuf *copy_from_ibuf_still(SeqRenderData context, Sequence *seq, float n
static void copy_to_ibuf_still(SeqRenderData context, Sequence *seq, float nr, ImBuf *ibuf)
{
+ /* warning: ibuf may be NULL if the video fails to load */
if (nr == 0 || nr == seq->len - 1) {
/* we have to store a copy, since the passed ibuf
* could be preprocessed afterwards (thereby silently
* changing the cached image... */
ibuf = IMB_dupImBuf(ibuf);
- sequencer_imbuf_assign_spaces(context.scene, ibuf);
+ if (ibuf) {
+ sequencer_imbuf_assign_spaces(context.scene, ibuf);
+ }
if (nr == 0) {
BKE_sequencer_cache_put(context, seq, seq->start, SEQ_STRIPELEM_IBUF_STARTSTILL, ibuf);
- }
+ }
if (nr == seq->len - 1) {
BKE_sequencer_cache_put(context, seq, seq->start, SEQ_STRIPELEM_IBUF_ENDSTILL, ibuf);
@@ -2334,11 +2337,14 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float
* -jahka
*/
- int rendering = G.is_rendering;
- int doseq;
- int doseq_gl = G.is_rendering ? /*(scene->r.seq_flag & R_SEQ_GL_REND)*/ 0 : /*(scene->r.seq_flag & R_SEQ_GL_PREV)*/ 1;
+ const short is_rendering = G.is_rendering;
+ const int do_seq_gl = G.is_rendering ?
+ 0 /* (context.scene->r.seq_flag & R_SEQ_GL_REND) */ :
+ (context.scene->r.seq_flag & R_SEQ_GL_PREV);
+ int do_seq;
int have_seq = FALSE;
Scene *scene;
+ int is_thread_main = BLI_thread_is_main();
/* don't refer to seq->scene above this point!, it can be NULL */
if (seq->scene == NULL) {
@@ -2353,9 +2359,10 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float
oldcfra = scene->r.cfra;
scene->r.cfra = frame;
- if (seq->scene_camera)
+ if (seq->scene_camera) {
camera = seq->scene_camera;
- else {
+ }
+ else {
BKE_scene_camera_switch_update(scene);
camera = scene->camera;
}
@@ -2366,8 +2373,8 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float
}
/* prevent eternal loop */
- doseq = context.scene->r.scemode & R_DOSEQ;
- context.scene->r.scemode &= ~R_DOSEQ;
+ do_seq = context.scene->r.scemode & R_DOSEQ;
+ scene->r.scemode &= ~R_DOSEQ;
#ifdef DURIAN_CAMERA_SWITCH
/* stooping to new low's in hackyness :( */
@@ -2376,8 +2383,9 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float
#else
(void)oldmarkers;
#endif
-
- if (sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (scene == context.scene || have_seq == 0) && camera) {
+
+ if ((sequencer_view3d_cb && do_seq_gl && camera) && is_thread_main)
+ {
char err_out[256] = "unknown";
/* for old scened this can be uninitialized,
* should probably be added to do_versions at some point if the functionality stays */
@@ -2396,15 +2404,19 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float
Render *re = RE_GetRender(scene->id.name);
RenderResult rres;
- /* XXX: this if can be removed when sequence preview rendering uses the job system */
- if (rendering || context.scene != scene) {
+ /* XXX: this if can be removed when sequence preview rendering uses the job system
+ *
+ * disable rendered preview for sequencer while rendering -- it's very much possible
+ * that preview render will went into conflict with final render
+ */
+ if (!is_thread_main || is_rendering == FALSE) {
if (re == NULL)
re = RE_NewRender(scene->id.name);
RE_BlenderFrame(re, context.bmain, scene, NULL, camera, scene->lay, frame, FALSE);
/* restore previous state after it was toggled on & off by RE_BlenderFrame */
- G.is_rendering = rendering;
+ G.is_rendering = is_rendering;
}
RE_AcquireResultImage(re, &rres);
@@ -2431,7 +2443,7 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float
}
/* restore */
- context.scene->r.scemode |= doseq;
+ scene->r.scemode |= do_seq;
scene->r.cfra = oldcfra;
@@ -2518,8 +2530,7 @@ static ImBuf *do_render_strip_uncached(SeqRenderData context, Sequence *seq, flo
BLI_path_abs(name, G.main->name);
}
- /* OCIO_TODO: support configurable space for image strips */
- if (s_elem && (ibuf = IMB_loadiffname(name, IB_rect, NULL))) {
+ if (s_elem && (ibuf = IMB_loadiffname(name, IB_rect, seq->strip->colorspace_settings.name))) {
/* we don't need both (speed reasons)! */
if (ibuf->rect_float && ibuf->rect)
imb_freerectImBuf(ibuf);
@@ -2822,7 +2833,7 @@ ImBuf *BKE_sequencer_give_ibuf(SeqRenderData context, float cfra, int chanshown)
count = BLI_countlist(&ed->metastack);
if ((chanshown < 0) && (count > 0)) {
- count = MAX2(count + chanshown, 0);
+ count = max_ii(count + chanshown, 0);
seqbasep = ((MetaStack *)BLI_findlink(&ed->metastack, count))->oldbasep;
}
else {
@@ -3191,7 +3202,7 @@ int BKE_sequence_tx_get_final_left(Sequence *seq, int metaclip)
{
if (metaclip && seq->tmp) {
/* return the range clipped by the parents range */
- return maxi(BKE_sequence_tx_get_final_left(seq, 0), BKE_sequence_tx_get_final_left((Sequence *)seq->tmp, TRUE));
+ return max_ii(BKE_sequence_tx_get_final_left(seq, 0), BKE_sequence_tx_get_final_left((Sequence *)seq->tmp, TRUE));
}
else {
return (seq->start - seq->startstill) + seq->startofs;
@@ -3202,7 +3213,7 @@ int BKE_sequence_tx_get_final_right(Sequence *seq, int metaclip)
{
if (metaclip && seq->tmp) {
/* return the range clipped by the parents range */
- return mini(BKE_sequence_tx_get_final_right(seq, 0), BKE_sequence_tx_get_final_right((Sequence *)seq->tmp, TRUE));
+ return min_ii(BKE_sequence_tx_get_final_right(seq, 0), BKE_sequence_tx_get_final_right((Sequence *)seq->tmp, TRUE));
}
else {
return ((seq->start + seq->len) + seq->endstill) - seq->endofs;
@@ -3454,7 +3465,7 @@ int BKE_sequence_base_shuffle(ListBase *seqbasep, Sequence *test, Scene *evil_sc
for (seq = seqbasep->first; seq; seq = seq->next) {
if (seq->machine == orig_machine)
- new_frame = MAX2(new_frame, seq->enddisp);
+ new_frame = max_ii(new_frame, seq->enddisp);
}
test->machine = orig_machine;
@@ -3479,10 +3490,10 @@ static int shuffle_seq_time_offset_test(ListBase *seqbasep, char dir)
for (seq_other = seqbasep->first; seq_other; seq_other = seq_other->next) {
if (!seq_other->tmp && seq_overlap(seq, seq_other)) {
if (dir == 'L') {
- offset = MIN2(offset, seq_other->startdisp - seq->enddisp);
+ offset = min_ii(offset, seq_other->startdisp - seq->enddisp);
}
else {
- offset = MAX2(offset, seq_other->enddisp - seq->startdisp);
+ offset = max_ii(offset, seq_other->enddisp - seq->startdisp);
}
}
}
@@ -3667,26 +3678,26 @@ int BKE_sequence_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str)
char name[sizeof(seq_a->name)];
if (seq_a->len != seq_b->len) {
- *error_str = "Strips must be the same length";
+ *error_str = N_("Strips must be the same length");
return 0;
}
- /* type checking, could be more advanced but disalow sound vs non-sound copy */
+ /* type checking, could be more advanced but disallow sound vs non-sound copy */
if (seq_a->type != seq_b->type) {
if (seq_a->type == SEQ_TYPE_SOUND_RAM || seq_b->type == SEQ_TYPE_SOUND_RAM) {
- *error_str = "Strips were not compatible";
+ *error_str = N_("Strips were not compatible");
return 0;
}
/* disallow effects to swap with non-effects strips */
if ((seq_a->type & SEQ_TYPE_EFFECT) != (seq_b->type & SEQ_TYPE_EFFECT)) {
- *error_str = "Strips were not compatible";
+ *error_str = N_("Strips were not compatible");
return 0;
}
if ((seq_a->type & SEQ_TYPE_EFFECT) && (seq_b->type & SEQ_TYPE_EFFECT)) {
if (BKE_sequence_effect_get_num_inputs(seq_a->type) != BKE_sequence_effect_get_num_inputs(seq_b->type)) {
- *error_str = "Strips must have the same number of inputs";
+ *error_str = N_("Strips must have the same number of inputs");
return 0;
}
}
@@ -3929,6 +3940,25 @@ Sequence *BKE_sequence_alloc(ListBase *lb, int cfra, int machine)
return seq;
}
+void BKE_sequence_init_colorspace(Sequence *seq)
+{
+ if (seq->strip && seq->strip->stripdata) {
+ char name[FILE_MAX];
+ ImBuf *ibuf;
+
+ BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name);
+ BLI_path_abs(name, G.main->name);
+
+ /* initialize input color space */
+ if (seq->type == SEQ_TYPE_IMAGE) {
+ ibuf = IMB_loadiffname(name, IB_rect, seq->strip->colorspace_settings.name);
+
+ if (ibuf)
+ IMB_freeImBuf(ibuf);
+ }
+ }
+}
+
/* NOTE: this function doesn't fill in image names */
Sequence *BKE_sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
{
@@ -3998,7 +4028,7 @@ Sequence *BKE_sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoad
/* basic defaults */
seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
- seq->len = ceil(info.length * FPS);
+ seq->len = (int)ceil((double)info.length * FPS);
strip->us = 1;
/* we only need 1 element to store the filename */
@@ -4035,14 +4065,14 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
Sequence *seq; /* generic strip vars */
Strip *strip;
StripElem *se;
+ char colorspace[64] = "\0"; /* MAX_COLORSPACE_NAME */
struct anim *an;
BLI_strncpy(path, seq_load->path, sizeof(path));
BLI_path_abs(path, G.main->name);
- /* OCIO_TODO: support configurable input space for strips */
- an = openanim(path, IB_rect, 0, NULL);
+ an = openanim(path, IB_rect, 0, colorspace);
if (an == NULL)
return NULL;
@@ -4061,6 +4091,8 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
seq->len = IMB_anim_get_duration(an, IMB_TC_RECORD_RUN);
strip->us = 1;
+ BLI_strncpy(seq->strip->colorspace_settings.name, colorspace, sizeof(seq->strip->colorspace_settings.name));
+
/* we only need 1 element for MOVIE strips */
strip->stripdata = se = MEM_callocN(sizeof(StripElem), "stripelem");