~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/src/editseq.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2007-05-17 11:47:59 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517114759-yp4ybrnhp2u7pk66
Tags: 2.44-1
* New upstream release.
* Drop debian/patches/01_64bits_stupidity, not needed anymore: as of this
  version blender is 64 bits safe again. Adjust README.Debian accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
 * $Id: editseq.c,v 1.53 2007/02/01 00:59:53 schlaile Exp $
 
2
 * $Id: editseq.c,v 1.55 2007/04/04 06:27:36 schlaile Exp $
3
3
 *
4
4
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5
5
 *
493
493
        std_rmouse_transform(transform_seq);
494
494
}
495
495
 
496
 
static Sequence *alloc_sequence(int cfra, int machine)
 
496
 
 
497
Sequence *alloc_sequence(ListBase *lb, int cfra, int machine)
497
498
{
498
 
        Editing *ed;
499
499
        Sequence *seq;
500
500
 
501
 
        ed= G.scene->ed;
 
501
        /*ed= G.scene->ed;*/
502
502
 
503
503
        seq= MEM_callocN( sizeof(Sequence), "addseq");
504
 
        BLI_addtail(ed->seqbasep, seq);
 
504
        BLI_addtail(lb, seq);
505
505
 
506
506
        set_last_seq(seq);
507
507
 
542
542
        if(totsel==0) return 0;
543
543
 
544
544
        /* make seq */
545
 
        seq= alloc_sequence(cfra, machine);
 
545
        seq= alloc_sequence(((Editing *)G.scene->ed)->seqbasep, cfra, machine);
546
546
        seq->len= totsel;
547
547
 
548
548
        if(totsel==1) {
588
588
        return seq;
589
589
}
590
590
 
591
 
static void sfile_to_mv_sequence(SpaceFile *sfile, int cfra, int machine)
 
591
 
 
592
static int sfile_to_mv_sequence_load(SpaceFile *sfile, int cfra, 
 
593
                                     int machine, int index )
592
594
{
593
595
        Sequence *seq;
594
596
        struct anim *anim;
601
603
        totframe= 0;
602
604
 
603
605
        strncpy(str, sfile->dir, FILE_MAXDIR-1);
604
 
        strncat(str, sfile->file, FILE_MAXDIR-1);
 
606
        if(index<0)
 
607
                strncat(str, sfile->file, FILE_MAXDIR-1);
 
608
        else
 
609
                strncat(str, sfile->filelist[index].relname, FILE_MAXDIR-1);
605
610
 
606
611
        /* is it a movie? */
607
612
        anim = openanim(str, IB_rect);
608
613
        if(anim==0) {
609
614
                error("The selected file is not a movie or "
610
615
                      "FFMPEG-support not compiled in!");
611
 
                return;
 
616
                return(cfra);
612
617
        }
613
 
 
 
618
        
614
619
        totframe= IMB_anim_get_duration(anim);
615
620
 
616
621
        /* make seq */
617
 
        seq= alloc_sequence(cfra, machine);
 
622
        seq= alloc_sequence(((Editing *)G.scene->ed)->seqbasep, cfra, machine);
618
623
        seq->len= totframe;
619
624
        seq->type= SEQ_MOVIE;
620
625
        seq->anim= anim;
638
643
        strip->stripdata= se= MEM_callocN(totframe*sizeof(StripElem), "stripelem");
639
644
 
640
645
        /* name movie in first strip */
641
 
        strncpy(se->name, sfile->file, FILE_MAXFILE-1);
 
646
        if(index<0)
 
647
                strncpy(se->name, sfile->file, FILE_MAXFILE-1);
 
648
        else
 
649
                strncpy(se->name, sfile->filelist[index].relname, FILE_MAXFILE-1);
642
650
 
643
651
        for(a=1; a<=totframe; a++, se++) {
644
652
                se->ok= 1;
647
655
 
648
656
        /* last active name */
649
657
        strncpy(last_imagename, seq->strip->dir, FILE_MAXDIR-1);
 
658
        return(cfra+totframe);
 
659
}
 
660
 
 
661
static void sfile_to_mv_sequence(SpaceFile *sfile, int cfra, int machine)
 
662
{
 
663
        int a, totsel;
 
664
 
 
665
        totsel= 0;
 
666
        for(a= 0; a<sfile->totfile; a++) {
 
667
                if(sfile->filelist[a].flags & ACTIVE) {
 
668
                        if ((sfile->filelist[a].type & S_IFDIR)==0) {
 
669
                                totsel++;
 
670
                        }
 
671
                }
 
672
        }
 
673
 
 
674
        if((totsel==0) && (sfile->file[0])) {
 
675
                cfra= sfile_to_mv_sequence_load(sfile, cfra, machine, -1);
 
676
                return;
 
677
        }
 
678
 
 
679
        if(totsel==0) return;
 
680
 
 
681
        /* ok. check all the select file, and load it. */
 
682
        for(a= 0; a<sfile->totfile; a++) {
 
683
                if(sfile->filelist[a].flags & ACTIVE) {
 
684
                        if ((sfile->filelist[a].type & S_IFDIR)==0) {
 
685
                                /* load and update current frame. */
 
686
                                cfra= sfile_to_mv_sequence_load(sfile, cfra, machine, a);
 
687
                        }
 
688
                }
 
689
        }
650
690
}
651
691
 
652
692
static Sequence *sfile_to_ramsnd_sequence(SpaceFile *sfile, 
682
722
        totframe= (int) ( ((float)(sound->streamlen-1)/( (float)G.scene->audio.mixrate*4.0 ))* (float)G.scene->r.frs_sec);
683
723
 
684
724
        /* make seq */
685
 
        seq= alloc_sequence(cfra, machine);
 
725
        seq= alloc_sequence(((Editing *)G.scene->ed)->seqbasep, cfra, machine);
686
726
        seq->len= totframe;
687
727
        seq->type= SEQ_RAM_SOUND;
688
728
        seq->sound = sound;
719
759
        return seq;
720
760
}
721
761
 
722
 
static void sfile_to_hdsnd_sequence(SpaceFile *sfile, int cfra, int machine)
 
762
static int sfile_to_hdsnd_sequence_load(SpaceFile *sfile, int cfra, 
 
763
                                        int machine, int index)
723
764
{
724
765
        Sequence *seq;
725
766
        struct hdaudio *hdaudio;
732
773
        totframe= 0;
733
774
 
734
775
        strncpy(str, sfile->dir, FILE_MAXDIR-1);
735
 
        strncat(str, sfile->file, FILE_MAXDIR-1);
 
776
        if(index<0)
 
777
                strncat(str, sfile->file, FILE_MAXDIR-1);
 
778
        else
 
779
                strncat(str, sfile->filelist[index].relname, FILE_MAXDIR-1);
736
780
 
737
781
        /* is it a sound file? */
738
782
        hdaudio = sound_open_hdaudio(str);
739
783
        if(hdaudio==0) {
740
784
                error("The selected file is not a sound file or "
741
785
                      "FFMPEG-support not compiled in!");
742
 
                return;
 
786
                return(cfra);
743
787
        }
744
788
 
745
789
        totframe= sound_hdaudio_get_duration(hdaudio, G.scene->r.frs_sec);
746
790
 
747
791
        /* make seq */
748
 
        seq= alloc_sequence(cfra, machine);
 
792
        seq= alloc_sequence(((Editing *)G.scene->ed)->seqbasep, cfra, machine);
749
793
        seq->len= totframe;
750
794
        seq->type= SEQ_HD_SOUND;
751
795
        seq->hdaudio= hdaudio;
768
812
        strip->stripdata= se= MEM_callocN(totframe*sizeof(StripElem), "stripelem");
769
813
 
770
814
        /* name movie in first strip */
771
 
        strncpy(se->name, sfile->file, FILE_MAXFILE-1);
 
815
        if(index<0)
 
816
                strncpy(se->name, sfile->file, FILE_MAXFILE-1);
 
817
        else
 
818
                strncpy(se->name, sfile->filelist[index].relname, FILE_MAXFILE-1);
772
819
 
773
820
        for(a=1; a<=totframe; a++, se++) {
774
821
                se->ok= 2;
778
825
 
779
826
        /* last active name */
780
827
        strncpy(last_sounddir, seq->strip->dir, FILE_MAXDIR-1);
 
828
        return(cfra+totframe);
 
829
}
 
830
 
 
831
static void sfile_to_hdsnd_sequence(SpaceFile *sfile, int cfra, int machine)
 
832
{
 
833
        int totsel, a;
 
834
 
 
835
        totsel= 0;
 
836
        for(a= 0; a<sfile->totfile; a++) {
 
837
                if(sfile->filelist[a].flags & ACTIVE) {
 
838
                        if((sfile->filelist[a].type & S_IFDIR)==0) {
 
839
                                totsel++;
 
840
                        }
 
841
                }
 
842
        }
 
843
 
 
844
        if((totsel==0) && (sfile->file[0])) {
 
845
                cfra= sfile_to_hdsnd_sequence_load(sfile, cfra, machine, -1);
 
846
                return;
 
847
        }
 
848
 
 
849
        if(totsel==0) return;
 
850
 
 
851
        /* ok, check all the select file, and load it. */
 
852
        for(a= 0; a<sfile->totfile; a++) {
 
853
                if(sfile->filelist[a].flags & ACTIVE) {
 
854
                        if((sfile->filelist[a].type & S_IFDIR)==0) {
 
855
                                /* load and update current frame. */
 
856
                                cfra= sfile_to_hdsnd_sequence_load(sfile, cfra, machine, a);
 
857
                        }
 
858
                }
 
859
        }
781
860
}
782
861
 
783
862
 
1158
1237
        machine= (int)(y+0.5);
1159
1238
 
1160
1239
        /* allocate and initialize */
1161
 
        newseq= alloc_sequence(cfra, machine);
 
1240
        newseq= alloc_sequence(((Editing *)G.scene->ed)->seqbasep, cfra, machine);
1162
1241
        newseq->type= event_to_efftype(type);
1163
1242
 
1164
1243
        sh = get_sequence_effect(newseq);
1373
1452
                                cfra= (int)(x+0.5);
1374
1453
                                machine= (int)(y+0.5);
1375
1454
 
1376
 
                                seq= alloc_sequence(cfra, machine);
 
1455
                                seq= alloc_sequence(((Editing *)G.scene->ed)->seqbasep, cfra, machine);
1377
1456
                                seq->type= SEQ_SCENE;
1378
1457
                                seq->scene= sce;
1379
1458
                                seq->sfra= sce->r.sfra;
1990
2069
 
1991
2070
        /* remove all selected from main list, and put in meta */
1992
2071
 
1993
 
        seqm= alloc_sequence(1, 1);
 
2072
        seqm= alloc_sequence(((Editing *)G.scene->ed)->seqbasep, 1, 1);
1994
2073
        seqm->type= SEQ_META;
1995
2074
        seqm->flag= SELECT;
1996
2075