/WX enabled for MSVC in CMake too.
[blender.git] / source / blender / blenkernel / intern / sequencer.c
index 866f907..5950a46 100644 (file)
@@ -62,8 +62,6 @@
 #include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
 
-
-
 #include "BKE_context.h"
 #include "BKE_sound.h"
 #include "AUD_C-API.h"
@@ -579,7 +577,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range)
        if (seq->type != SEQ_SCENE && seq->type != SEQ_META &&
                seq->type != SEQ_IMAGE) {
                BLI_join_dirfile(str, seq->strip->dir, seq->strip->stripdata->name);
-               BLI_path_abs(str, G.sce);
+               BLI_path_abs(str, G.main->name);
        }
 
        if (seq->type == SEQ_IMAGE) {
@@ -710,12 +708,12 @@ static int clear_scene_in_allseqs_cb(Sequence *seq, void *arg_pt)
        return 1;
 }
 
-void clear_scene_in_allseqs(Scene *scene)
+void clear_scene_in_allseqs(Main *bmain, Scene *scene)
 {
        Scene *scene_iter;
 
        /* when a scene is deleted: test all seqs */
-       for(scene_iter= G.main->scene.first; scene_iter; scene_iter= scene_iter->id.next) {
+       for(scene_iter= bmain->scene.first; scene_iter; scene_iter= scene_iter->id.next) {
                if(scene_iter != scene && scene_iter->ed) {
                        seqbase_recursive_apply(&scene_iter->ed->seqbase, clear_scene_in_allseqs_cb, scene);
                }
@@ -1005,7 +1003,7 @@ static int get_shown_sequences(   ListBase * seqbasep, int cfra, int chanshown, Se
                }
        }
 
-       for (;b <= chanshown; b++) {
+       for (;b <= chanshown && b >= 0; b++) {
                if (video_seq_is_rendered(seq_arr[b])) {
                        seq_arr_out[cnt++] = seq_arr[b];
                }
@@ -1021,7 +1019,7 @@ static int get_shown_sequences(   ListBase * seqbasep, int cfra, int chanshown, Se
 
 #define PROXY_MAXFILE (2*FILE_MAXDIR+FILE_MAXFILE)
 
-static int seq_proxy_get_fname(Scene *scene, Sequence * seq, int cfra, char * name, int render_size)
+static int seq_proxy_get_fname(Scene *UNUSED(scene), Sequence * seq, int cfra, char * name, int render_size)
 {
        int frameno;
        char dir[FILE_MAXDIR];
@@ -1044,7 +1042,7 @@ static int seq_proxy_get_fname(Scene *scene, Sequence * seq, int cfra, char * na
 
        if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) {
                BLI_join_dirfile(name, dir, seq->strip->proxy->file);
-               BLI_path_abs(name, G.sce);
+               BLI_path_abs(name, G.main->name);
 
                return TRUE;
        }
@@ -1071,7 +1069,7 @@ static int seq_proxy_get_fname(Scene *scene, Sequence * seq, int cfra, char * na
                         render_size);
        }
 
-       BLI_path_abs(name, G.sce);
+       BLI_path_abs(name, G.main->name);
        BLI_path_frame(name, frameno, 0);
 
 
@@ -1444,7 +1442,7 @@ static void color_balance(Sequence * seq, ImBuf* ibuf, float mul)
 */
 
 int input_have_to_preprocess(
-       Scene *scene, Sequence * seq, float cfra, int seqrectx, int seqrecty)
+       Scene *UNUSED(scene), Sequence * seq, float UNUSED(cfra), int UNUSED(seqrectx), int UNUSED(seqrecty))
 {
        float mul;
 
@@ -1476,7 +1474,7 @@ int input_have_to_preprocess(
 }
 
 static ImBuf * input_preprocess(
-       Scene *scene, Sequence *seq, float cfra, int seqrectx, int seqrecty,
+       Scene *scene, Sequence *seq, float UNUSED(cfra), int seqrectx, int seqrecty,
        ImBuf * ibuf)
 {
        float mul;
@@ -1521,9 +1519,9 @@ static ImBuf * input_preprocess(
                        ImBuf * i;
 
                        if (ibuf->rect_float) {
-                               i = IMB_allocImBuf(dx, dy,32, IB_rectfloat, 0);
+                               i = IMB_allocImBuf(dx, dy,32, IB_rectfloat);
                        } else {
-                               i = IMB_allocImBuf(dx, dy,32, IB_rect, 0);
+                               i = IMB_allocImBuf(dx, dy,32, IB_rect);
                        }
 
                        IMB_rectcpy(i, ibuf, 
@@ -1659,17 +1657,17 @@ static void copy_to_ibuf_still(Sequence * seq, float nr,
    ********************************************************************** */
 
 static ImBuf* seq_render_strip_stack(
-       Scene *scene,
+       Main *bmain, Scene *scene,
        ListBase *seqbasep, float cfra, int chanshown, int render_size,
        int seqrectx, int seqrecty);
 
-static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra,
+static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float cfra,
                                int render_size, 
                                int seqrectx, int seqrecty);
 
 
 static ImBuf* seq_render_effect_strip_impl(
-       Scene *scene, float cfra, Sequence *seq, int render_size,
+       Main *bmain, Scene *scene, float cfra, Sequence *seq, int render_size,
        int seqrectx, int seqrecty)
 {
        float fac, facf;
@@ -1707,7 +1705,7 @@ static ImBuf* seq_render_effect_strip_impl(
        early_out = sh.early_out(seq, fac, facf);
 
        if (early_out == -1) { /* no input needed */
-               out = sh.execute(scene, seq, cfra, fac, facf, 
+               out = sh.execute(bmain, scene, seq, cfra, fac, facf, 
                                 seqrectx, seqrecty, render_size,
                                 0, 0, 0);
                goto finish;
@@ -1722,7 +1720,7 @@ static ImBuf* seq_render_effect_strip_impl(
                break;
        case 1:
                if (seq->seq1) {
-                       ibuf[0] = seq_render_strip(scene, seq->seq1, cfra,
+                       ibuf[0] = seq_render_strip(bmain, scene, seq->seq1, cfra,
                                                   render_size, 
                                                   seqrectx, seqrecty);
                }
@@ -1737,7 +1735,7 @@ static ImBuf* seq_render_effect_strip_impl(
                goto finish;
        case 2:
                if (seq->seq2) {
-                       ibuf[1] = seq_render_strip(scene, seq->seq2, cfra,
+                       ibuf[1] = seq_render_strip(bmain, scene, seq->seq2, cfra,
                                                   render_size, 
                                                   seqrectx, seqrecty);
                }
@@ -1755,19 +1753,19 @@ static ImBuf* seq_render_effect_strip_impl(
        }
 
        if (seq->seq1) {
-               ibuf[0] = seq_render_strip(scene, seq->seq1, cfra,
+               ibuf[0] = seq_render_strip(bmain, scene, seq->seq1, cfra,
                                           render_size, 
                                           seqrectx, seqrecty);
        } 
 
        if (seq->seq2) {
-               ibuf[1] = seq_render_strip(scene, seq->seq2, cfra,
+               ibuf[1] = seq_render_strip(bmain, scene, seq->seq2, cfra,
                                           render_size, 
                                           seqrectx, seqrecty);
        }
 
        if (seq->seq3) {
-               ibuf[2] = seq_render_strip(scene, seq->seq3, cfra,
+               ibuf[2] = seq_render_strip(bmain, scene, seq->seq3, cfra,
                                           render_size, 
                                           seqrectx, seqrecty);
        }
@@ -1776,7 +1774,7 @@ static ImBuf* seq_render_effect_strip_impl(
                goto finish;
        }
 
-       out = sh.execute(scene, seq, cfra, fac, facf, seqrectx, seqrecty, 
+       out = sh.execute(bmain, scene, seq, cfra, fac, facf, seqrectx, seqrecty, 
                         render_size,
                         ibuf[0], ibuf[1], ibuf[2]);
 
@@ -1787,7 +1785,7 @@ finish:
 
        if (!out) {
                out = IMB_allocImBuf(
-                       (short)seqrectx, (short)seqrecty, 32, IB_rect, 0);
+                       (short)seqrectx, (short)seqrecty, 32, IB_rect);
        }
 
        return out;
@@ -1795,7 +1793,7 @@ finish:
 
 
 static ImBuf * seq_render_scene_strip_impl(
-       Scene * scene, Sequence * seq, float nr, int seqrectx, int seqrecty)
+       Main *bmain, Scene * scene, Sequence * seq, float nr, int seqrectx, int seqrecty)
 {
        ImBuf * ibuf = 0;
        float frame= seq->sfra + nr + seq->anim_startofs;
@@ -1851,8 +1849,8 @@ static ImBuf * seq_render_scene_strip_impl(
        
        if(sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (seq->scene == scene || have_seq==0) && seq->scene->camera) {
                /* opengl offscreen render */
-               scene_update_for_newframe(G.main, seq->scene, seq->scene->lay);
-               ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty, 
+               scene_update_for_newframe(bmain, seq->scene, seq->scene->lay);
+               ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty, IB_rect,
                                          scene->r.seq_prev_type);
        }
        else {
@@ -1861,15 +1859,24 @@ static ImBuf * seq_render_scene_strip_impl(
                
                if(rendering)
                        re= RE_NewRender(" do_build_seq_ibuf");
+               /* If the top level scene that does the sequencer rendering is included 
+                * as a strip the default render name for the strip will conflict with
+                * the original render, so override the name in this case.
+                * See bugs #22236 and #24160 for examples.
+                * XXX: Somebody with deeper insight to the rendering pipeline should
+                *      probably check if this is the best way to handle this. -jahka
+                */
+               else if(seq->scene == scene)
+                       re= RE_NewRender("scene_conflict_render");
                else
                        re= RE_NewRender(sce->id.name);
                
-               RE_BlenderFrame(re, G.main, sce, NULL, sce->lay, frame);
+               RE_BlenderFrame(re, bmain, sce, NULL, sce->lay, frame);
                
                RE_AcquireResultImage(re, &rres);
                
                if(rres.rectf) {
-                       ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat, 0);
+                       ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat);
                        memcpy(ibuf->rect_float, rres.rectf, 4*sizeof(float)*rres.rectx*rres.recty);
                        if(rres.rectz) {
                                addzbuffloatImBuf(ibuf);
@@ -1881,7 +1888,7 @@ static ImBuf * seq_render_scene_strip_impl(
                        IMB_convert_profile(ibuf, IB_PROFILE_SRGB);                     
                }
                else if (rres.rect32) {
-                       ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect, 0);
+                       ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect);
                        memcpy(ibuf->rect, rres.rect32, 4*rres.rectx*rres.recty);
                }
                
@@ -1904,7 +1911,7 @@ static ImBuf * seq_render_scene_strip_impl(
        return ibuf;
 }
 
-static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra,
+static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float cfra,
                                int render_size, 
                                int seqrectx, int seqrecty)
 {
@@ -1929,7 +1936,7 @@ static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra,
 
                if(!ibuf && seq->seqbase.first) {
                        meta_ibuf = seq_render_strip_stack(
-                               scene,
+                               bmain, scene,
                                &seq->seqbase, seq->start + nr, 0,
                                render_size, seqrectx, seqrecty);
                }
@@ -1961,7 +1968,7 @@ static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra,
                        /* weeek! */
                        f_cfra = seq->start + s->frameMap[(int) nr];
 
-                       child_ibuf = seq_render_strip(scene, seq->seq1, f_cfra,
+                       child_ibuf = seq_render_strip(bmain, scene, seq->seq1, f_cfra,
                                                      render_size, 
                                                      seqrectx, seqrecty);
                }
@@ -1985,7 +1992,7 @@ static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra,
 
                if(ibuf == 0) {         
                        ibuf = seq_render_effect_strip_impl(
-                               scene, cfra, seq, render_size, 
+                               bmain, scene, cfra, seq, render_size, 
                                seqrectx, seqrecty);
                }
        } else if(seq->type == SEQ_IMAGE) {
@@ -1993,7 +2000,7 @@ static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra,
 
                if(ibuf == 0 && s_elem) {
                        BLI_join_dirfile(name, seq->strip->dir, s_elem->name);
-                       BLI_path_abs(name, G.sce);
+                       BLI_path_abs(name, G.main->name);
 
                        ibuf = seq_proxy_fetch(scene, seq, cfra, render_size);
                }
@@ -2029,7 +2036,7 @@ static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra,
                                BLI_join_dirfile(name, 
                                                 seq->strip->dir, 
                                                 seq->strip->stripdata->name);
-                               BLI_path_abs(name, G.sce);
+                               BLI_path_abs(name, G.main->name);
                                        
                                seq->anim = openanim(
                                        name, IB_rect | 
@@ -2061,7 +2068,7 @@ static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra,
                }
                
                if (ibuf == 0) {
-                       ibuf = seq_render_scene_strip_impl(scene, seq, nr,
+                       ibuf = seq_render_scene_strip_impl(bmain, scene, seq, nr,
                                                           seqrectx, seqrecty);
 
                        copy_to_ibuf_still(seq, nr, ibuf);
@@ -2070,7 +2077,7 @@ static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra,
 
        if (!ibuf) {
                ibuf = IMB_allocImBuf(
-                       (short)seqrectx, (short)seqrecty, 32, IB_rect, 0);
+                       (short)seqrectx, (short)seqrecty, 32, IB_rect);
        }
 
        if (ibuf->x != seqrectx || ibuf->y != seqrecty) {
@@ -2129,7 +2136,7 @@ static int seq_get_early_out_for_blend_mode(Sequence * seq)
 }
 
 static ImBuf* seq_render_strip_stack(
-       Scene *scene, ListBase *seqbasep, float cfra, int chanshown, 
+       Main *bmain, Scene *scene, ListBase *seqbasep, float cfra, int chanshown, 
        int render_size, int seqrectx, int seqrecty)
 {
        Sequence* seq_arr[MAXSEQ+1];
@@ -2161,7 +2168,7 @@ static ImBuf* seq_render_strip_stack(
        }
        
        if(count == 1) {
-               out = seq_render_strip(scene, seq_arr[0],
+               out = seq_render_strip(bmain, scene, seq_arr[0],
                                        cfra, render_size,
                                        seqrectx, seqrecty);
                seq_stripelem_cache_put(
@@ -2185,7 +2192,7 @@ static ImBuf* seq_render_strip_stack(
                        break;
                }
                if (seq->blend_mode == SEQ_BLEND_REPLACE) {
-                       out = seq_render_strip(scene, seq, cfra,
+                       out = seq_render_strip(bmain, scene, seq, cfra,
                                               render_size,
                                               seqrectx, seqrecty);
                        break;
@@ -2196,7 +2203,7 @@ static ImBuf* seq_render_strip_stack(
                switch (early_out) {
                case -1:
                case 2:
-                       out = seq_render_strip(scene, seq, cfra,
+                       out = seq_render_strip(bmain, scene, seq, cfra,
                                               render_size,
                                               seqrectx, seqrecty);
                        break;
@@ -2204,12 +2211,12 @@ static ImBuf* seq_render_strip_stack(
                        if (i == 0) {
                                out = IMB_allocImBuf(
                                        (short)seqrectx, (short)seqrecty, 
-                                       32, IB_rect, 0);
+                                       32, IB_rect);
                        }
                        break;
                case 0:
                        if (i == 0) {
-                               out = seq_render_strip(scene, seq, cfra,
+                               out = seq_render_strip(bmain, scene, seq, cfra,
                                                       render_size,
                                                       seqrectx, seqrecty);
                        }
@@ -2234,7 +2241,7 @@ static ImBuf* seq_render_strip_stack(
                if (seq_get_early_out_for_blend_mode(seq) == 0) {
                        struct SeqEffectHandle sh = get_sequence_blend(seq);
                        ImBuf * ibuf1 = out;
-                       ImBuf * ibuf2 = seq_render_strip(scene, seq, cfra,
+                       ImBuf * ibuf2 = seq_render_strip(bmain, scene, seq, cfra,
                                                         render_size,
                                                         seqrectx, seqrecty);
 
@@ -2246,11 +2253,11 @@ static ImBuf* seq_render_strip_stack(
                        int y= seqrecty;
 
                        if (swap_input) {
-                               out = sh.execute(scene, seq, cfra, 
+                               out = sh.execute(bmain, scene, seq, cfra, 
                                                 facf, facf, x, y, render_size,
                                                 ibuf2, ibuf1, 0);
                        } else {
-                               out = sh.execute(scene, seq, cfra, 
+                               out = sh.execute(bmain, scene, seq, cfra, 
                                                 facf, facf, x, y, render_size,
                                                 ibuf1, ibuf2, 0);
                        }
@@ -2272,7 +2279,7 @@ static ImBuf* seq_render_strip_stack(
  * you have to free after usage!
  */
 
-ImBuf *give_ibuf_seq(Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size)
+ImBuf *give_ibuf_seq(Main *bmain, Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size)
 {
        Editing *ed= seq_give_editing(scene, FALSE);
        int count;
@@ -2289,18 +2296,18 @@ ImBuf *give_ibuf_seq(Scene *scene, int rectx, int recty, int cfra, int chanshown
        }
 
        return seq_render_strip_stack(
-               scene, seqbasep, cfra, chanshown, render_size, rectx, recty);
+               bmain, scene, seqbasep, cfra, chanshown, render_size, rectx, recty);
 }
 
-ImBuf *give_ibuf_seqbase(struct Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size, ListBase *seqbasep)
+ImBuf *give_ibuf_seqbase(Main *bmain, Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size, ListBase *seqbasep)
 {
-       return seq_render_strip_stack(scene, seqbasep, cfra, chanshown, render_size, rectx, recty);
+       return seq_render_strip_stack(bmain, scene, seqbasep, cfra, chanshown, render_size, rectx, recty);
 }
 
 
-ImBuf *give_ibuf_seq_direct(Scene *scene, int rectx, int recty, int cfra, int render_size, Sequence *seq)
+ImBuf *give_ibuf_seq_direct(Main *bmain, Scene *scene, int rectx, int recty, int cfra, int render_size, Sequence *seq)
 {
-       return seq_render_strip(scene, seq, cfra, render_size, rectx, recty);
+       return seq_render_strip(bmain, scene, seq, cfra, render_size, rectx, recty);
 }
 
 #if 0
@@ -2566,13 +2573,13 @@ static void seq_wait_for_prefetch_ready()
 }
 #endif
 
-ImBuf *give_ibuf_seq_threaded(Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size)
+ImBuf *give_ibuf_seq_threaded(Main *bmain, Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size)
 {
        PrefetchQueueElem *e = NULL;
        int found_something = FALSE;
 
        if (seq_thread_shutdown) {
-               return give_ibuf_seq(scene, rectx, recty, cfra, chanshown, render_size);
+               return give_ibuf_seq(bmain, scene, rectx, recty, cfra, chanshown, render_size);
        }
 
        while (!e) {
@@ -3210,7 +3217,7 @@ void seq_offset_animdata(Scene *scene, Sequence *seq, int ofs)
 
        for (fcu= scene->adt->action->curves.first; fcu; fcu= fcu->next) {
                if(strstr(fcu->rna_path, "sequence_editor.sequences_all[") && strstr(fcu->rna_path, str)) {
-                       int i;
+                       unsigned int i;
                        for (i = 0; i < fcu->totvert; i++) {
                                BezTriple *bezt= &fcu->bezt[i];
                                bezt->vec[0][0] += ofs;
@@ -3483,7 +3490,7 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
        struct anim *an;
 
        BLI_strncpy(path, seq_load->path, sizeof(path));
-       BLI_path_abs(path, G.sce);
+       BLI_path_abs(path, G.main->name);
 
        an = openanim(path, IB_rect);
 
@@ -3531,8 +3538,9 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
 }
 
 
-static Sequence *seq_dupli(struct Scene *scene, Sequence *seq, int dupe_flag)
+static Sequence *seq_dupli(struct Scene *scene, struct Scene *scene_to, Sequence *seq, int dupe_flag)
 {
+       Scene *sce_audio= scene_to ? scene_to : scene;
        Sequence *seqn = MEM_dupallocN(seq);
 
        seq->tmp = seqn;
@@ -3566,7 +3574,7 @@ static Sequence *seq_dupli(struct Scene *scene, Sequence *seq, int dupe_flag)
        } else if(seq->type == SEQ_SCENE) {
                seqn->strip->stripdata = 0;
                if(seq->scene_sound)
-                       seqn->scene_sound = sound_scene_add_scene_sound(scene, seqn, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs);
+                       seqn->scene_sound = sound_scene_add_scene_sound(sce_audio, seqn, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs);
        } else if(seq->type == SEQ_MOVIE) {
                seqn->strip->stripdata =
                                MEM_dupallocN(seq->strip->stripdata);
@@ -3575,7 +3583,7 @@ static Sequence *seq_dupli(struct Scene *scene, Sequence *seq, int dupe_flag)
                seqn->strip->stripdata =
                                MEM_dupallocN(seq->strip->stripdata);
                if(seq->scene_sound)
-                       seqn->scene_sound = sound_add_scene_sound(scene, seqn, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs);
+                       seqn->scene_sound = sound_add_scene_sound(sce_audio, seqn, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs);
 
                seqn->sound->id.us++;
        } else if(seq->type == SEQ_IMAGE) {
@@ -3610,13 +3618,13 @@ static Sequence *seq_dupli(struct Scene *scene, Sequence *seq, int dupe_flag)
        return seqn;
 }
 
-Sequence * seq_dupli_recursive(struct Scene *scene, Sequence * seq, int dupe_flag)
+Sequence * seq_dupli_recursive(struct Scene *scene, struct Scene *scene_to, Sequence * seq, int dupe_flag)
 {
-       Sequence * seqn = seq_dupli(scene, seq, dupe_flag);
+       Sequence * seqn = seq_dupli(scene, scene_to, seq, dupe_flag);
        if (seq->type == SEQ_META) {
                Sequence *s;
                for(s= seq->seqbase.first; s; s = s->next) {
-                       Sequence *n = seq_dupli_recursive(scene, s, dupe_flag);
+                       Sequence *n = seq_dupli_recursive(scene, scene_to, s, dupe_flag);
                        if (n) {
                                BLI_addtail(&seqn->seqbase, n);
                        }
@@ -3625,7 +3633,7 @@ Sequence * seq_dupli_recursive(struct Scene *scene, Sequence * seq, int dupe_fla
        return seqn;
 }
 
-void seqbase_dupli_recursive(Scene *scene, ListBase *nseqbase, ListBase *seqbase, int dupe_flag)
+void seqbase_dupli_recursive(Scene *scene, Scene *scene_to, ListBase *nseqbase, ListBase *seqbase, int dupe_flag)
 {
        Sequence *seq;
        Sequence *seqn = 0;
@@ -3634,7 +3642,7 @@ void seqbase_dupli_recursive(Scene *scene, ListBase *nseqbase, ListBase *seqbase
        for(seq= seqbase->first; seq; seq= seq->next) {
                seq->tmp= NULL;
                if((seq->flag & SELECT) || (dupe_flag & SEQ_DUPE_ALL)) {
-                       seqn = seq_dupli(scene, seq, dupe_flag);
+                       seqn = seq_dupli(scene, scene_to, seq, dupe_flag);
                        if (seqn) { /*should never fail */
                                if(dupe_flag & SEQ_DUPE_CONTEXT) {
                                        seq->flag &= ~SEQ_ALLSEL;
@@ -3643,7 +3651,7 @@ void seqbase_dupli_recursive(Scene *scene, ListBase *nseqbase, ListBase *seqbase
 
                                BLI_addtail(nseqbase, seqn);
                                if(seq->type==SEQ_META)
-                                       seqbase_dupli_recursive(scene, &seqn->seqbase, &seq->seqbase, dupe_flag);
+                                       seqbase_dupli_recursive(scene, scene_to, &seqn->seqbase, &seq->seqbase, dupe_flag);
 
                                if(dupe_flag & SEQ_DUPE_CONTEXT) {
                                        if (seq == last_seq) {