diff options
-rw-r--r-- | intern/audaspace/AUD_C-API.h | 17 | ||||
-rw-r--r-- | intern/audaspace/OpenAL/AUD_OpenALDevice.cpp | 53 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_BufferReader.cpp | 2 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_C-API.cpp | 36 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_sequence.h | 42 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_sound.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sequence.c | 673 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sound.c | 48 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 20 | ||||
-rw-r--r-- | source/blender/editors/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_ops.c | 8 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 703 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/SConscript | 1 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_add.c | 211 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_draw.c | 5 |
15 files changed, 1088 insertions, 737 deletions
diff --git a/intern/audaspace/AUD_C-API.h b/intern/audaspace/AUD_C-API.h index d7cbe888910..a1418a989b1 100644 --- a/intern/audaspace/AUD_C-API.h +++ b/intern/audaspace/AUD_C-API.h @@ -39,6 +39,12 @@ typedef enum AUD_OPENAL_DEVICE } AUD_DeviceType; +typedef struct +{ + AUD_Specs specs; + float length; +} AUD_SoundInfo; + #ifndef AUD_CAPI_IMPLEMENTATION typedef void AUD_Sound; typedef void AUD_Handle; @@ -66,6 +72,13 @@ extern int* AUD_enumDevices(); extern void AUD_exit(); /** + * Returns information about a sound. + * \param sound The sound to get the info about. + * \return The AUD_SoundInfo structure with filled in data. + */ +extern AUD_SoundInfo AUD_getInfo(AUD_Sound* sound); + +/** * Loads a sound file. * \param filename The filename of the sound file. * \return A handle of the sound file. @@ -174,11 +187,9 @@ extern int AUD_setKeep(AUD_Handle* handle, int keep); * Seeks a playing or paused sound. * \param handle The handle to the sound. * \param seekTo From where the sound file should be played back in seconds. - * A negative value indicates the seconds that should be waited - * before playback starts. * \return Whether the handle has been valid or not. */ -extern int AUD_seek(AUD_Handle* handle, int seekTo); +extern int AUD_seek(AUD_Handle* handle, float seekTo); /** * Returns the status of a playing, paused or stopped sound. diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp index 6db35b7d578..8587dae027f 100644 --- a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp +++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp @@ -61,6 +61,9 @@ struct AUD_OpenALHandle : AUD_Handle /// The first buffer to be read next. int current; + + /// Whether the stream doesn't return any more data. + bool data_end; }; struct AUD_OpenALBufferedFactory @@ -145,7 +148,7 @@ void AUD_OpenALDevice::updateStreams() while(info--) { // if there's still data to play back - if(sound->current >= 0) + if(!sound->data_end) { // read data length = m_buffersize; @@ -154,7 +157,7 @@ void AUD_OpenALDevice::updateStreams() // read nothing? if(length == 0) { - sound->current = -1; + sound->data_end = true; break; } @@ -164,7 +167,7 @@ void AUD_OpenALDevice::updateStreams() ALenum err; if((err = alGetError()) != AL_NO_ERROR) { - sound->current = -1; + sound->data_end = true; break; } @@ -177,7 +180,7 @@ void AUD_OpenALDevice::updateStreams() if(alGetError() != AL_NO_ERROR) { - sound->current = -1; + sound->data_end = true; break; } @@ -186,7 +189,7 @@ void AUD_OpenALDevice::updateStreams() &sound->buffers[sound->current]); if(alGetError() != AL_NO_ERROR) { - sound->current = -1; + sound->data_end = true; break; } @@ -204,14 +207,11 @@ void AUD_OpenALDevice::updateStreams() if(info == AL_STOPPED) { // if it really stopped - if(sound->current < 0) + if(sound->data_end) { // pause or if(sound->keep) - { - alSourceRewind(sound->source); pause(sound); - } // stop else stop(sound); @@ -332,7 +332,6 @@ AUD_OpenALDevice::~AUD_OpenALDevice() delete sound; AUD_DELETE("handle") m_playingSounds->erase(m_playingSounds->begin()); } - delete m_playingSounds; AUD_DELETE("list") // delete all paused sounds while(!m_pausedSounds->empty()) @@ -347,7 +346,6 @@ AUD_OpenALDevice::~AUD_OpenALDevice() delete sound; AUD_DELETE("handle") m_pausedSounds->erase(m_pausedSounds->begin()); } - delete m_pausedSounds; AUD_DELETE("list") // delete all buffered factories while(!m_bufferedFactories->empty()) @@ -356,11 +354,14 @@ AUD_OpenALDevice::~AUD_OpenALDevice() delete *m_bufferedFactories->begin(); AUD_DELETE("bufferedfactory"); m_bufferedFactories->erase(m_bufferedFactories->begin()); } - delete m_bufferedFactories; AUD_DELETE("list") alcProcessContext(m_context); unlock(); + delete m_playingSounds; AUD_DELETE("list") + delete m_pausedSounds; AUD_DELETE("list") + delete m_bufferedFactories; AUD_DELETE("list") + // wait for the thread to stop if(m_thread != 0) pthread_join(m_thread, NULL); @@ -521,6 +522,7 @@ AUD_Handle* AUD_OpenALDevice::play(AUD_IFactory* factory, bool keep) sound->keep = keep; sound->current = -1; sound->isBuffered = true; + sound->data_end = true; alcSuspendContext(m_context); @@ -598,6 +600,7 @@ AUD_Handle* AUD_OpenALDevice::play(AUD_IFactory* factory, bool keep) sound->reader = reader; sound->current = 0; sound->isBuffered = false; + sound->data_end = false; valid &= getFormat(sound->format, specs); @@ -702,15 +705,30 @@ bool AUD_OpenALDevice::pause(AUD_Handle* handle) bool AUD_OpenALDevice::resume(AUD_Handle* handle) { - // only songs that are paused can be resumed + ALint info; lock(); + + // only songs that are paused can be resumed for(AUD_HandleIterator i = m_pausedSounds->begin(); i != m_pausedSounds->end(); i++) { if(*i == handle) { m_playingSounds->push_back(*i); - alSourcePlay((*i)->source); + + alGetSourcei((*i)->source, AL_SOURCE_STATE, &info); + + switch(info) + { + case AL_PLAYING: + break; + case AL_STOPPED: +// alSourceRewind((*i)->source); + default: +// alSourcePlay((*i)->source); + break; + } + start(); m_pausedSounds->erase(i); unlock(); @@ -813,8 +831,11 @@ bool AUD_OpenALDevice::seek(AUD_Handle* handle, float position) if(alhandle->isBuffered) alSourcef(alhandle->source, AL_SEC_OFFSET, position); else + { alhandle->reader->seek((int)(position * alhandle->reader->getSpecs().rate)); + alhandle->data_end = false; + } unlock(); return true; } @@ -1098,6 +1119,8 @@ bool AUD_OpenALDevice::updateListener(AUD_3DData &data) alListenerfv(AL_POSITION, (ALfloat*)data.position); alListenerfv(AL_VELOCITY, (ALfloat*)data.velocity); alListenerfv(AL_ORIENTATION, (ALfloat*)&(data.orientation[3])); + + return true; } bool AUD_OpenALDevice::setSetting(AUD_3DSetting setting, float value) @@ -1162,8 +1185,6 @@ float AUD_OpenALDevice::getSetting(AUD_3DSetting setting) return std::numeric_limits<float>::quiet_NaN(); } -#include <stdio.h> - bool AUD_OpenALDevice::updateSource(AUD_Handle* handle, AUD_3DData &data) { lock(); diff --git a/intern/audaspace/intern/AUD_BufferReader.cpp b/intern/audaspace/intern/AUD_BufferReader.cpp index 1e828cfb0f1..47bf5d3d171 100644 --- a/intern/audaspace/intern/AUD_BufferReader.cpp +++ b/intern/audaspace/intern/AUD_BufferReader.cpp @@ -45,7 +45,7 @@ void AUD_BufferReader::seek(int position) if(position < 0) m_position = 0; else if(position > m_buffer.get()->getSize() / AUD_SAMPLE_SIZE(m_specs)) - position = m_buffer.get()->getSize() / AUD_SAMPLE_SIZE(m_specs); + m_position = m_buffer.get()->getSize() / AUD_SAMPLE_SIZE(m_specs); else m_position = position; } diff --git a/intern/audaspace/intern/AUD_C-API.cpp b/intern/audaspace/intern/AUD_C-API.cpp index 4dc3c34e94c..ccf3ca3c6a1 100644 --- a/intern/audaspace/intern/AUD_C-API.cpp +++ b/intern/audaspace/intern/AUD_C-API.cpp @@ -36,12 +36,7 @@ #include "AUD_LoopFactory.h" #include "AUD_ReadDevice.h" #include "AUD_SourceCaps.h" - -/* -#define WITH_SDL -#define WITH_OPENAL -#define WITH_FFMPEG -//*/ +#include "AUD_IReader.h" #ifdef WITH_SDL #include "AUD_SDLDevice.h" @@ -138,6 +133,30 @@ void AUD_exit() AUD_3ddevice = NULL; } +AUD_SoundInfo AUD_getInfo(AUD_Sound* sound) +{ + assert(sound); + + AUD_IReader* reader = sound->createReader(); + + AUD_SoundInfo info; + + if(reader) + { + info.specs = reader->getSpecs(); + info.length = reader->getLength() / (float) info.specs.rate; + } + else + { + info.specs.channels = AUD_CHANNELS_INVALID; + info.specs.format = AUD_FORMAT_INVALID; + info.specs.rate = AUD_RATE_INVALID; + info.length = 0.0; + } + + return info; +} + AUD_Sound* AUD_load(const char* filename) { assert(filename); @@ -291,11 +310,10 @@ int AUD_setKeep(AUD_Handle* handle, int keep) return AUD_device->setKeep(handle, keep); } -int AUD_seek(AUD_Handle* handle, double seekTo) +int AUD_seek(AUD_Handle* handle, float seekTo) { assert(AUD_device); - int position = (int)(seekTo * AUD_device->getSpecs().rate); - return AUD_device->seek(handle, position); + return AUD_device->seek(handle, seekTo); } AUD_Status AUD_getStatus(AUD_Handle* handle) diff --git a/source/blender/blenkernel/BKE_sequence.h b/source/blender/blenkernel/BKE_sequence.h index 65a3b0216fe..4a1c9f4170b 100644 --- a/source/blender/blenkernel/BKE_sequence.h +++ b/source/blender/blenkernel/BKE_sequence.h @@ -9,7 +9,7 @@ * of the License, or (at your option) any later version. The Blender * Foundation also sells licenses for use in proprietary software under * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * about this. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -37,6 +37,7 @@ struct Strip; struct StripElem; struct ImBuf; struct Scene; +struct bContext; #define MAXSEQ 32 @@ -44,7 +45,6 @@ struct Scene; #define BUILD_SEQAR_COUNT_CURRENT 1 #define BUILD_SEQAR_COUNT_CHILDREN 2 - /* sequence iterator */ typedef struct SeqIterator { @@ -65,7 +65,7 @@ void seq_array(struct Editing *ed, struct Sequence ***seqarray, int *tot, int us SeqIterator iter;\ for(seq_begin(ed, &iter, 1); iter.valid; seq_next(&iter)) { \ seq= iter.seq; - + #define SEQ_BEGIN(ed, seq) \ { \ SeqIterator iter;\ @@ -90,41 +90,41 @@ struct SeqEffectHandle { /* init & init_plugin are _only_ called on first creation */ void (*init)(struct Sequence *seq); void (*init_plugin)(struct Sequence *seq, const char *fname); - - /* number of input strips needed + + /* number of input strips needed (called directly after construction) */ int (*num_inputs)(); - + /* load is called first time after readblenfile in get_sequence_effect automatically */ void (*load)(struct Sequence *seq); - + /* duplicate */ void (*copy)(struct Sequence *dst, struct Sequence *src); - + /* destruct */ void (*free)(struct Sequence *seq); - + /* returns: -1: no input needed, - 0: no early out, - 1: out = ibuf1, + 0: no early out, + 1: out = ibuf1, 2: out = ibuf2 */ int (*early_out)(struct Sequence *seq, - float facf0, float facf1); - + float facf0, float facf1); + /* stores the y-range of the effect IPO */ void (*store_icu_yrange)(struct Sequence * seq, short adrcode, float *ymin, float *ymax); - + /* stores the default facf0 and facf1 if no IPO is present */ void (*get_default_fac)(struct Sequence *seq, int cfra, float * facf0, float * facf1); - + /* execute the effect sequence effects are only required to either support - float-rects or byte-rects + float-rects or byte-rects (mixed cases are handled one layer up...) */ - + void (*execute)(struct Sequence *seq, int cfra, float facf0, float facf1, int x, int y, @@ -183,3 +183,11 @@ int seq_test_overlap(struct ListBase * seqbasep, struct Sequence *test); int shuffle_seq(struct ListBase * seqbasep, struct Sequence *test); void free_imbuf_seq(struct ListBase * seqbasep); +// AUD_XXX +void seq_play_seq(struct bContext *C, struct Sequence *seq, int start, int end, int keep); +void seq_stop_seq(struct bContext *C, struct Sequence *seq); +void seq_update_seq(struct bContext *C, struct Sequence *seq, int frame); +void seq_play_audio(struct bContext *C); +void seq_stop_audio(struct bContext *C); +void seq_update_audio(struct bContext *C, int frame); + diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index 61f16182c0e..a19ed760e19 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -34,6 +34,7 @@ struct PackedFile; struct bSound; // AUD_XXX struct bSample; +struct bContext; /* bad bad global... */ // AUD_XXX @@ -54,6 +55,10 @@ void sound_init(); void sound_exit(); +struct bSound* sound_new(struct bContext *C, char* filename); + +void sound_delete(struct bContext *C, struct bSound* sound); + void sound_load(struct bSound* sound); void sound_free(struct bSound* sound); diff --git a/source/blender/blenkernel/intern/sequence.c b/source/blender/blenkernel/intern/sequence.c index 3eeecd94a85..acf120d42f8 100644 --- a/source/blender/blenkernel/intern/sequence.c +++ b/source/blender/blenkernel/intern/sequence.c @@ -20,7 +20,7 @@ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. * - * Contributor(s): + * Contributor(s): * - Blender Foundation, 2003-2009 * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006 * @@ -51,6 +51,10 @@ #include "BLI_threads.h" #include <pthread.h> +// AUD_XXX +#include "BKE_context.h" +#include "AUD_C-API.h" + #ifdef WIN32 #define snprintf _snprintf #endif @@ -96,9 +100,9 @@ void new_tstripdata(Sequence *seq) { if(seq->strip) { free_tstripdata(seq->strip->len, seq->strip->tstripdata); - free_tstripdata(seq->strip->endstill, + free_tstripdata(seq->strip->endstill, seq->strip->tstripdata_endstill); - free_tstripdata(seq->strip->startstill, + free_tstripdata(seq->strip->startstill, seq->strip->tstripdata_startstill); seq->strip->tstripdata= 0; @@ -369,7 +373,7 @@ void build_seqar(ListBase *seqbase, Sequence ***seqar, int *totseq) } static void do_seq_count_cb(ListBase *seqbase, int *totseq, - int (*test_func)(Sequence * seq)) + int (*test_func)(Sequence * seq)) { Sequence *seq; @@ -387,7 +391,7 @@ static void do_seq_count_cb(ListBase *seqbase, int *totseq, } static void do_build_seqar_cb(ListBase *seqbase, Sequence ***seqar, int depth, - int (*test_func)(Sequence * seq)) + int (*test_func)(Sequence * seq)) { Sequence *seq; @@ -397,7 +401,7 @@ static void do_build_seqar_cb(ListBase *seqbase, Sequence ***seqar, int depth, seq->depth= depth; if(seq->seqbase.first && (test & BUILD_SEQAR_COUNT_CHILDREN)) { - do_build_seqar_cb(&seq->seqbase, seqar, depth+1, + do_build_seqar_cb(&seq->seqbase, seqar, depth+1, test_func); } if (test & BUILD_SEQAR_COUNT_CURRENT) { @@ -409,7 +413,7 @@ static void do_build_seqar_cb(ListBase *seqbase, Sequence ***seqar, int depth, } void build_seqar_cb(ListBase *seqbase, Sequence ***seqar, int *totseq, - int (*test_func)(Sequence * seq)) + int (*test_func)(Sequence * seq)) { Sequence **tseqar; @@ -432,10 +436,10 @@ void calc_sequence_disp(Sequence *seq) { if(seq->startofs && seq->startstill) seq->startstill= 0; if(seq->endofs && seq->endstill) seq->endstill= 0; - + seq->startdisp= seq->start + seq->startofs - seq->startstill; seq->enddisp= seq->start+seq->len - seq->endofs + seq->endstill; - + seq->handsize= 10.0; /* 10 frames */ if( seq->enddisp-seq->startdisp < 10 ) { seq->handsize= (float)(0.5*(seq->enddisp-seq->startdisp)); @@ -514,19 +518,19 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) char str[FILE_MAXDIR+FILE_MAXFILE]; if (!(seq->type == SEQ_MOVIE || seq->type == SEQ_IMAGE || - seq->type == SEQ_HD_SOUND || seq->type == SEQ_RAM_SOUND || - seq->type == SEQ_SCENE || seq->type == SEQ_META)) { + seq->type == SEQ_HD_SOUND || seq->type == SEQ_RAM_SOUND || + seq->type == SEQ_SCENE || seq->type == SEQ_META)) { return; } new_tstripdata(seq); if (seq->type != SEQ_SCENE && seq->type != SEQ_META && - seq->type != SEQ_IMAGE) { + seq->type != SEQ_IMAGE) { BLI_join_dirfile(str, seq->strip->dir, seq->strip->stripdata->name); BLI_convertstringcode(str, G.sce); BLI_convertstringframe(str, scene->r.cfra); - + } if (seq->type == SEQ_IMAGE) { @@ -546,9 +550,9 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) if (!seq->anim) { return; } - + seq->len = IMB_anim_get_duration(seq->anim); - + seq->anim_preseek = IMB_anim_get_preseek(seq->anim); seq->len -= seq->anim_startofs; @@ -561,19 +565,26 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) // XXX if(seq->hdaudio) sound_close_hdaudio(seq->hdaudio); // seq->hdaudio = sound_open_hdaudio(str); - if (!seq->hdaudio) { +// AUD_XXX +/* if (!seq->hdaudio) { return; - } + }*/ // XXX seq->len = sound_hdaudio_get_duration(seq->hdaudio, FPS) - seq->anim_startofs - seq->anim_endofs; +// AUD_XXX + if(seq->sound && seq->sound->stream) + seq->len = AUD_getInfo(seq->sound->stream).length * FPS - seq->anim_startofs - seq->anim_endofs; + if (seq->len < 0) { seq->len = 0; } seq->strip->len = seq->len; } else if (seq->type == SEQ_RAM_SOUND) { - seq->len = (int) ( ((float)(seq->sound->streamlen-1)/ - ((float)scene->audio.mixrate*4.0 )) - * FPS); +// AUD_XXX + seq->len = AUD_getInfo(seq->sound->stream).length * FPS; +/* seq->len = (int) ( ((float)(seq->sound->streamlen-1)/ + ((float)scene->audio.mixrate*4.0 )) + * FPS);*/ seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; if (seq->len < 0) { @@ -583,7 +594,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) } else if (seq->type == SEQ_SCENE) { Scene * sce = G.main->scene.first; int nr = 1; - + while(sce) { if(nr == seq->scenenr) { break; @@ -598,7 +609,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) sce = seq->scene; } - strncpy(seq->name + 2, sce->id.name + 2, + strncpy(seq->name + 2, sce->id.name + 2, sizeof(seq->name) - 2); seq->len= seq->scene->r.efra - seq->scene->r.sfra + 1; @@ -622,7 +633,7 @@ void sort_seq(Scene *scene) Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq, *seqt; - + if(ed==NULL) return; seqbase.first= seqbase.last= 0; @@ -780,7 +791,7 @@ static void multibuf(ImBuf *ibuf, float fmul) if(icol>254) rt[2]= 255; else rt[2]= icol; icol= (mul*rt[3])>>8; if(icol>254) rt[3]= 255; else rt[3]= icol; - + rt+= 4; } } @@ -791,7 +802,7 @@ static void multibuf(ImBuf *ibuf, float fmul) rt_float[1] *= fmul; rt_float[2] *= fmul; rt_float[3] *= fmul; - + rt_float += 4; } } @@ -816,7 +827,7 @@ static void do_effect(Scene *scene, int cfra, Sequence *seq, TStripElem * se) fac= seq->facf0; facf= seq->facf1; } else -#endif // XXX old animation system +#endif // XXX old animation system { sh.get_default_fac(seq, cfra, &fac, &facf); } @@ -826,8 +837,8 @@ static void do_effect(Scene *scene, int cfra, Sequence *seq, TStripElem * se) early_out = sh.early_out(seq, fac, facf); if (early_out == -1) { /* no input needed */ - sh.execute(seq, cfra, fac, facf, - se->ibuf->x, se->ibuf->y, + sh.execute(seq, cfra, fac, facf, + se->ibuf->x, se->ibuf->y, 0, 0, 0, se->ibuf); return; } @@ -844,7 +855,7 @@ static void do_effect(Scene *scene, int cfra, Sequence *seq, TStripElem * se) se3= se->se3; if ( (se1==0 || se2==0 || se3==0) - || (se1->ibuf==0 || se2->ibuf==0 || se3->ibuf==0)) { + || (se1->ibuf==0 || se2->ibuf==0 || se3->ibuf==0)) { make_black_ibuf(se->ibuf); return; } @@ -904,7 +915,7 @@ static void do_effect(Scene *scene, int cfra, Sequence *seq, TStripElem * se) if (!se3->ibuf->rect_float && se->ibuf->rect_float) { IMB_float_from_rect(se3->ibuf); } - + if (!se1->ibuf->rect && !se->ibuf->rect_float) { IMB_rect_from_float(se1->ibuf); } @@ -925,7 +936,7 @@ static int give_stripelem_index(Sequence *seq, int cfra) if(seq->startdisp >cfra || seq->enddisp <= cfra) return -1; if(seq->len == 0) return -1; - if(seq->flag&SEQ_REVERSE_FRAMES) { + if(seq->flag&SEQ_REVERSE_FRAMES) { /*reverse frame in this sequence */ if(cfra <= seq->start) nr= seq->len-1; else if(cfra >= seq->start+seq->len-1) nr= 0; @@ -961,31 +972,31 @@ TStripElem *give_tstripelem(Sequence *seq, int cfra) se = seq->strip->tstripdata; if (se == 0 && seq->len > 0) { se = seq->strip->tstripdata = alloc_tstripdata(seq->len, - "tstripelems"); + "tstripelems"); } nr = give_stripelem_index(seq, cfra); if (nr == -1) return 0; if (se == 0) return 0; - se += nr; + se += nr; /* if there are IPOs with blend modes active, one has to watch out for startstill + endstill area: we can't use the same tstripelem here for all ibufs, since then, blending with IPOs won't work! - + Rather common case, if you use a single image and try to fade it in and out... or want to use your strip as a watermark in alpha over mode... */ if (seq->blend_mode != SEQ_BLEND_REPLACE || - (/*seq->ipo && seq->ipo->curve.first &&*/ + (/*seq->ipo && seq->ipo->curve.first &&*/ (!(seq->type & SEQ_EFFECT) || !seq->seq1))) { Strip * s = seq->strip; if (cfra < seq->start) { se = s->tstripdata_startstill; if (seq->startstill > s->startstill) { - free_tstripdata(s->startstill, + free_tstripdata(s->startstill, s->tstripdata_startstill); se = 0; } @@ -1002,7 +1013,7 @@ TStripElem *give_tstripelem(Sequence *seq, int cfra) } else if (cfra > seq->start + seq->len-1) { se = s->tstripdata_endstill; if (seq->endstill > s->endstill) { - free_tstripdata(s->endstill, + free_tstripdata(s->endstill, s->tstripdata_endstill); se = 0; } @@ -1018,7 +1029,7 @@ TStripElem *give_tstripelem(Sequence *seq, int cfra) } } - + se->nr= nr; return se; @@ -1035,8 +1046,8 @@ StripElem *give_stripelem(Sequence *seq, int cfra) if (nr == -1) return 0; if (se == 0) return 0; - se += nr + seq->anim_startofs; - + se += nr + seq->anim_startofs; + return se; } @@ -1070,9 +1081,9 @@ int evaluate_seq_frame(Scene *scene, int cfra) static int video_seq_is_rendered(Sequence * seq) { - return (seq - && !(seq->flag & SEQ_MUTE) - && seq->type != SEQ_RAM_SOUND + return (seq + && !(seq->flag & SEQ_MUTE) + && seq->type != SEQ_RAM_SOUND && seq->type != SEQ_HD_SOUND); } @@ -1099,7 +1110,7 @@ static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Se } } } - + chanshown = b; for (;b > 0; b--) { @@ -1118,7 +1129,7 @@ static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Se return cnt; } - + /* ********************************************************************** proxy management @@ -1139,7 +1150,7 @@ static int seq_proxy_get_fname(Scene *scene, Sequence * seq, int cfra, char * na strcpy(dir, seq->strip->proxy->dir); } else { if (seq->type == SEQ_IMAGE || seq->type == SEQ_MOVIE) { - snprintf(dir, FILE_MAXDIR, "%s/BL_proxy", + snprintf(dir, FILE_MAXDIR, "%s/BL_proxy", seq->strip->dir); } else { return FALSE; @@ -1180,7 +1191,7 @@ static int seq_proxy_get_fname(Scene *scene, Sequence * seq, int cfra, char * na BLI_convertstringcode(name, G.sce); BLI_convertstringframe(name, frameno); - + strcat(name, ".jpg"); @@ -1207,16 +1218,16 @@ static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, in if (!seq_proxy_get_fname(scene, seq, cfra, name, render_size)) { return 0; } - + seq->strip->proxy->anim = openanim(name, IB_rect); } if (!seq->strip->proxy->anim) { return 0; } - + return IMB_anim_absolute(seq->strip->proxy->anim, frameno); } - + if (!seq_proxy_get_fname(scene, seq, cfra, name, render_size)) { return 0; } @@ -1229,7 +1240,7 @@ static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, in } static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int cfra, - int build_proxy_run, int render_size); + int build_proxy_run, int render_size); static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int render_size) { @@ -1252,7 +1263,7 @@ static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int re /* that's why it is called custom... */ if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) { return; - } + } if (!seq_proxy_get_fname(scene, seq, cfra, name, render_size)) { return; @@ -1267,7 +1278,7 @@ static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int re IMB_freeImBuf(se->ibuf); se->ibuf = 0; } - + do_build_seq_ibuf(scene, seq, se, cfra, TRUE, render_size); if (!se->ibuf) { @@ -1292,7 +1303,7 @@ static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int re ibuf->ftype= JPG | quality; BLI_make_existing_file(name); - + ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat); if (ok == 0) { perror(name); @@ -1311,7 +1322,7 @@ void seq_proxy_rebuild(Scene *scene, Sequence * seq) G.afbreek = 0; - /* flag management tries to account for strobe and + /* flag management tries to account for strobe and other "non-linearities", that might come in the future... better way would be to "touch" the files, so that _really_ no one is rebuild twice. @@ -1323,13 +1334,13 @@ void seq_proxy_rebuild(Scene *scene, Sequence * seq) tse->flag &= ~STRIPELEM_PREVIEW_DONE; } - + /* a _lot_ faster for movie files, if we read frames in sequential order */ if (seq->flag & SEQ_REVERSE_FRAMES) { - for (cfra = seq->enddisp-seq->endstill-1; - cfra >= seq->startdisp + seq->startstill; cfra--) { + for (cfra = seq->enddisp-seq->endstill-1; + cfra >= seq->startdisp + seq->startstill; cfra--) { TStripElem * tse = give_tstripelem(seq, cfra); if (!(tse->flag & STRIPELEM_PREVIEW_DONE)) { @@ -1342,8 +1353,8 @@ void seq_proxy_rebuild(Scene *scene, Sequence * seq) } } } else { - for (cfra = seq->startdisp + seq->startstill; - cfra < seq->enddisp - seq->endstill; cfra++) { + for (cfra = seq->startdisp + seq->startstill; + cfra < seq->enddisp - seq->endstill; cfra++) { TStripElem * tse = give_tstripelem(seq, cfra); if (!(tse->flag & STRIPELEM_PREVIEW_DONE)) { @@ -1361,7 +1372,7 @@ void seq_proxy_rebuild(Scene *scene, Sequence * seq) /* ********************************************************************** - color balance + color balance ********************************************************************** */ static StripColorBalance calc_cb(StripColorBalance * cb_) @@ -1402,14 +1413,14 @@ static StripColorBalance calc_cb(StripColorBalance * cb_) } static void make_cb_table_byte(float lift, float gain, float gamma, - unsigned char * table, float mul) + unsigned char * table, float mul) { int y; for (y = 0; y < 256; y++) { - float v = 1.0 * y / 255; + float v = 1.0 * y / 255; v *= gain; - v += lift; + v += lift; v = pow(v, gamma); v *= mul; if ( v > 1.0) { @@ -1428,7 +1439,7 @@ static void make_cb_table_float(float lift, float gain, float gamma, int y; for (y = 0; y < 256; y++) { - float v = (float) y * 1.0 / 255.0; + float v = (float) y * 1.0 / 255.0; v *= gain; v += lift; v = pow(v, gamma); @@ -1455,7 +1466,7 @@ static void color_balance_byte_byte(Sequence * seq, TStripElem* se, float mul) p[0] = cb_tab[0][p[0]]; p[1] = cb_tab[1][p[1]]; p[2] = cb_tab[2][p[2]]; - + p += 4; } } @@ -1477,7 +1488,7 @@ static void color_balance_byte_float(Sequence * seq, TStripElem* se, float mul) for (c = 0; c < 3; c++) { make_cb_table_float(cb.lift[c], cb.gain[c], cb.gamma[c], - cb_tab[c], mul); + cb_tab[c], mul); } for (i = 0; i < 256; i++) { @@ -1503,7 +1514,7 @@ static void color_balance_float_float(Sequence * seq, TStripElem* se, float mul) while (p < e) { int c; for (c = 0; c < 3; c++) { - p[c] = pow(p[c] * cb.gain[c] + cb.lift[c], + p[c] = pow(p[c] * cb.gain[c] + cb.lift[c], cb.gamma[c]) * mul; } p += 4; @@ -1533,9 +1544,9 @@ static void color_balance(Sequence * seq, TStripElem* se, float mul) - Crop and transform in image source coordinate space - Flip X + Flip Y (could be done afterwards, backward compatibility) - Promote image to float data (affects pipeline operations afterwards) - - Color balance (is most efficient in the byte -> float - (future: half -> float should also work fine!) - case, if done on load, since we can use lookup tables) + - Color balance (is most efficient in the byte -> float + (future: half -> float should also work fine!) + case, if done on load, since we can use lookup tables) - Premultiply */ @@ -1544,14 +1555,14 @@ static int input_have_to_preprocess(Scene *scene, Sequence * seq, TStripElem* se { float mul; - if ((seq->flag & SEQ_FILTERY) || - (seq->flag & SEQ_USE_CROP) || - (seq->flag & SEQ_USE_TRANSFORM) || - (seq->flag & SEQ_FLIPX) || - (seq->flag & SEQ_FLIPY) || - (seq->flag & SEQ_USE_COLOR_BALANCE) || - (seq->flag & SEQ_MAKE_PREMUL) || - (se->ibuf->x != seqrectx || se->ibuf->y != seqrecty)) { + if ((seq->flag & SEQ_FILTERY) || + (seq->flag & SEQ_USE_CROP) || + (seq->flag & SEQ_USE_TRANSFORM) || + (seq->flag & SEQ_FLIPX) || + (seq->flag & SEQ_FLIPY) || + (seq->flag & SEQ_USE_COLOR_BALANCE) || + (seq->flag & SEQ_MAKE_PREMUL) || + (se->ibuf->x != seqrectx || se->ibuf->y != seqrecty)) { return TRUE; } @@ -1571,7 +1582,7 @@ static int input_have_to_preprocess(Scene *scene, Sequence * seq, TStripElem* se if (mul != 1.0) { return TRUE; } - + return FALSE; } @@ -1612,8 +1623,8 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf } if (c.top + c.bottom >= se->ibuf->y || - c.left + c.right >= se->ibuf->x || - t.xofs >= dx || t.yofs >= dy) { + c.left + c.right >= se->ibuf->x || + t.xofs >= dx || t.yofs >= dy) { make_black_ibuf(se->ibuf); } else { ImBuf * i; @@ -1624,16 +1635,16 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf i = IMB_allocImBuf(dx, dy,32, IB_rect, 0); } - IMB_rectcpy(i, se->ibuf, - t.xofs, t.yofs, - c.left, c.bottom, - sx, sy); + IMB_rectcpy(i, se->ibuf, + t.xofs, t.yofs, + c.left, c.bottom, + sx, sy); IMB_freeImBuf(se->ibuf); se->ibuf = i; } - } + } if(seq->flag & SEQ_FLIPX) { IMB_flipx(se->ibuf); @@ -1685,10 +1696,10 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf if(se->ibuf->x != seqrectx || se->ibuf->y != seqrecty ) { if(scene->r.mode & R_OSA) { - IMB_scaleImBuf(se->ibuf, - (short)seqrectx, (short)seqrecty); + IMB_scaleImBuf(se->ibuf, + (short)seqrectx, (short)seqrecty); } else { - IMB_scalefastImBuf(se->ibuf, + IMB_scalefastImBuf(se->ibuf, (short)seqrectx, (short)seqrecty); } } @@ -1699,7 +1710,7 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf static void test_and_auto_discard_ibuf(TStripElem * se) { if (se->ibuf) { - if(se->ibuf->x != seqrectx || se->ibuf->y != seqrecty + if(se->ibuf->x != seqrectx || se->ibuf->y != seqrecty || !(se->ibuf->rect || se->ibuf->rect_float)) { IMB_freeImBuf(se->ibuf); @@ -1708,7 +1719,7 @@ static void test_and_auto_discard_ibuf(TStripElem * se) } } if (se->ibuf_comp) { - if(se->ibuf_comp->x != seqrectx || se->ibuf_comp->y != seqrecty + if(se->ibuf_comp->x != seqrectx || se->ibuf_comp->y != seqrecty || !(se->ibuf_comp->rect || se->ibuf_comp->rect_float)) { IMB_freeImBuf(se->ibuf_comp); @@ -1721,14 +1732,14 @@ static void test_and_auto_discard_ibuf_stills(Strip * strip) { if (strip->ibuf_startstill) { if (!strip->ibuf_startstill->rect && - !strip->ibuf_startstill->rect_float) { + !strip->ibuf_startstill->rect_float) { IMB_freeImBuf(strip->ibuf_startstill); strip->ibuf_startstill = 0; } } if (strip->ibuf_endstill) { if (!strip->ibuf_endstill->rect && - !strip->ibuf_endstill->rect_float) { + !strip->ibuf_endstill->rect_float) { IMB_freeImBuf(strip->ibuf_endstill); strip->ibuf_endstill = 0; } @@ -1743,9 +1754,9 @@ static void copy_from_ibuf_still(Sequence * seq, TStripElem * se) se->ibuf = IMB_dupImBuf(seq->strip->ibuf_startstill); } - if (se->nr == seq->len - 1 - && (seq->len != 1) - && seq->strip->ibuf_endstill) { + if (se->nr == seq->len - 1 + && (seq->len != 1) + && seq->strip->ibuf_endstill) { IMB_cache_limiter_touch(seq->strip->ibuf_endstill); se->ibuf = IMB_dupImBuf(seq->strip->ibuf_endstill); @@ -1799,7 +1810,7 @@ static void free_metastrip_imbufs(ListBase *seqbasep, int cfra, int chanshown) } } } - + } static void check_limiter_refcount(const char * func, TStripElem *se) @@ -1811,15 +1822,15 @@ static void check_limiter_refcount(const char * func, TStripElem *se) if (refcount > 1 && (G.f & G_DEBUG) == 0) { return; } - - fprintf(stderr, + + fprintf(stderr, "sequencer: (ibuf) %s: " "suspicious memcache " "limiter refcount: %d\n", func, refcount); } } } - + static void check_limiter_refcount_comp(const char * func, TStripElem *se) { if (se && se->ibuf_comp) { @@ -1829,7 +1840,7 @@ static void check_limiter_refcount_comp(const char * func, TStripElem *se) if (refcount > 1 && (G.f & G_DEBUG) == 0) { return; } - fprintf(stderr, + fprintf(stderr, "sequencer: (ibuf comp) %s: " "suspicious memcache " "limiter refcount: %d\n", func, refcount); @@ -1841,7 +1852,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, ListBase *seqbasep, int cfra, int chanshown, int render_size); static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int cfra, - int build_proxy_run, int render_size) + int build_proxy_run, int render_size) { char name[FILE_MAXDIR+FILE_MAXFILE]; int use_limiter = TRUE; @@ -1876,7 +1887,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int se->ibuf = meta_se->ibuf_comp; if(se->ibuf && (!input_have_to_preprocess(scene, seq, se, cfra) || - build_proxy_run)) { + build_proxy_run)) { IMB_refImBuf(se->ibuf); if (build_proxy_run) { IMB_cache_limiter_unref(se->ibuf); @@ -1905,7 +1916,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int } else if(seq->type & SEQ_EFFECT) { int use_preprocess = FALSE; /* should the effect be recalculated? */ - + if (!build_proxy_run && se->ibuf == 0) { se->ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); if (se->ibuf) { @@ -1921,12 +1932,12 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rectfloat, 0); else se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect, 0); - + do_effect(scene, cfra, seq, se); if (input_have_to_preprocess(scene, seq, se, cfra) && - !build_proxy_run) { + !build_proxy_run) { if ((se->se1 && (se->ibuf == se->se1->ibuf)) || - (se->se2 && (se->ibuf == se->se2->ibuf))) { + (se->se2 && (se->ibuf == se->se2->ibuf))) { struct ImBuf * i = IMB_dupImBuf(se->ibuf); @@ -1962,7 +1973,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int copy_to_ibuf_still(seq, se); } - + if(se->ibuf == 0) { se->ok = STRIPELEM_FAILED; } else if (!build_proxy_run) { @@ -1981,26 +1992,26 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int BLI_join_dirfile(name, seq->strip->dir, seq->strip->stripdata->name); BLI_convertstringcode(name, G.sce); BLI_convertstringframe(name, scene->r.cfra); - + seq->anim = openanim( - name, IB_rect | - ((seq->flag & SEQ_FILTERY) + name, IB_rect | + ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0)); } if(seq->anim) { IMB_anim_set_preseek(seq->anim, seq->anim_preseek); se->ibuf = IMB_anim_absolute(seq->anim, se->nr + seq->anim_startofs); /* we don't need both (speed reasons)! */ - if (se->ibuf - && se->ibuf->rect_float - && se->ibuf->rect) { + if (se->ibuf + && se->ibuf->rect_float + && se->ibuf->rect) { imb_freerectImBuf(se->ibuf); } } copy_to_ibuf_still(seq, se); } - + if(se->ibuf == 0) { se->ok = STRIPELEM_FAILED; } else if (!build_proxy_run) { @@ -2019,7 +2030,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int char scenename[64]; int have_seq= (sce->r.scemode & R_DOSEQ) && sce->ed && sce->ed->seqbase.first; int sce_valid =sce && (sce->camera || have_seq); - + if (se->ibuf == NULL && sce_valid && !build_proxy_run) { se->ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); if (se->ibuf) { @@ -2033,7 +2044,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int input_preprocess(scene, seq, se, cfra); } } - + if (!sce_valid) { se->ok = STRIPELEM_FAILED; } else if (se->ibuf==NULL && sce_valid) { @@ -2041,9 +2052,9 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int scene strips */ if (!have_seq) waitcursor(1); - + /* Hack! This function can be called from do_render_seq(), in that case - the seq->scene can already have a Render initialized with same name, + the seq->scene can already have a Render initialized with same name, so we have to use a default name. (compositor uses scene name to find render). However, when called from within the UI (image preview in sequencer) @@ -2054,26 +2065,26 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int strcpy(sce->id.name+2, " do_build_seq_ibuf"); } re= RE_NewRender(sce->id.name); - + /* prevent eternal loop */ doseq= scene->r.scemode & R_DOSEQ; scene->r.scemode &= ~R_DOSEQ; - + BIF_init_render_callbacks(re, 0); /* 0= no display callbacks */ - + /* XXX hrms, set_scene still needed? work on that... */ if(sce!=oldsce) set_scene_bg(sce); RE_BlenderFrame(re, sce, seq->sfra+se->nr+seq->anim_startofs); if(sce!=oldsce) set_scene_bg(oldsce); - + /* UGLY WARNING, it is set to zero in RE_BlenderFrame */ G.rendering= rendering; if(rendering) BLI_strncpy(sce->id.name+2, scenename, 64); - + RE_GetResultImage(re, &rres); - + if(rres.rectf) { se->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat, 0); memcpy(se->ibuf->rect_float, rres.rectf, 4*sizeof(float)*rres.rectx*rres.recty); @@ -2085,9 +2096,9 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int se->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect, 0); memcpy(se->ibuf->rect, rres.rect32, 4*rres.rectx*rres.recty); } - + BIF_end_render_callbacks(); - + /* restore */ scene->r.scemode |= doseq; @@ -2095,9 +2106,9 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int #if 0 if((G.f & G_PLAYANIM)==0 /* bad, is set on do_render_seq */ && !have_seq - && !build_proxy_run) + && !build_proxy_run) #endif - + CFRA = oldcfra; set_last_seq(oldseq); @@ -2140,14 +2151,14 @@ static void do_effect_seq_recursively(Scene *scene, Sequence *seq, TStripElem *s do_seq_ipo(scene, seq, cfra); fac= seq->facf0; facf= seq->facf1; - } else + } else #endif // XXX old animation system { sh.get_default_fac(seq, cfra, &fac, &facf); - } + } if( scene->r.mode & R_FIELDS ); else facf= fac; - + early_out = sh.early_out(seq, fac, facf); switch (early_out) { case -1: @@ -2202,7 +2213,7 @@ static TStripElem* do_build_seq_recursively_impl(Scene *scene, Sequence * seq, i } /* FIXME: - + If cfra was float throughout blender (especially in the render pipeline) one could even _render_ with subframe precision instead of faking using the blend code below... @@ -2219,11 +2230,11 @@ static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra TStripElem * se = 0; TStripElem * se1 = 0; TStripElem * se2 = 0; - + sequence_effect_speed_rebuild_map(seq, 0); - + f_cfra = seq->start + s->frameMap[nr]; - + cfra_left = (int) floor(f_cfra); cfra_right = (int) ceil(f_cfra); @@ -2233,8 +2244,8 @@ static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra return se; } - if (cfra_left == cfra_right || - (s->flags & SEQ_SPEED_BLEND) == 0) { + if (cfra_left == cfra_right || + (s->flags & SEQ_SPEED_BLEND) == 0) { test_and_auto_discard_ibuf(se); if (se->ibuf == NULL) { @@ -2262,7 +2273,7 @@ static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra struct SeqEffectHandle sh; if(se->ibuf) { - if(se->ibuf->x < seqrectx || se->ibuf->y < seqrecty + if(se->ibuf->x < seqrectx || se->ibuf->y < seqrecty || !(se->ibuf->rect || se->ibuf->rect_float)) { IMB_freeImBuf(se->ibuf); se->ibuf= 0; @@ -2277,16 +2288,16 @@ static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rectfloat, 0); else se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect, 0); - + if (!se1 || !se2) { make_black_ibuf(se->ibuf); } else { sh = get_sequence_effect(seq); - sh.execute(seq, cfra, - f_cfra - (float) cfra_left, - f_cfra - (float) cfra_left, - se->ibuf->x, se->ibuf->y, + sh.execute(seq, cfra, + f_cfra - (float) cfra_left, + f_cfra - (float) cfra_left, + se->ibuf->x, se->ibuf->y, se1->ibuf, se2->ibuf, 0, se->ibuf); } } @@ -2311,16 +2322,16 @@ static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra return se; } -/* +/* * build all ibufs recursively - * + * * if successfull, the returned TStripElem contains the (referenced!) imbuf - * that means: you _must_ call + * that means: you _must_ call * * IMB_cache_limiter_unref(rval); - * + * * if rval != 0 - * + * */ static TStripElem* do_build_seq_recursively(Scene *scene, Sequence * seq, int cfra, int render_size) @@ -2366,7 +2377,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, return se; } - + if(count == 1) { se = do_build_seq_recursively(scene, seq_arr[0], cfra, render_size); if (se->ibuf) { @@ -2396,7 +2407,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, IMB_refImBuf(se->ibuf); } else { se->ibuf_comp = IMB_allocImBuf( - (short)seqrectx, (short)seqrecty, + (short)seqrectx, (short)seqrecty, 32, IB_rect, 0); IMB_cache_limiter_insert(se->ibuf_comp); IMB_cache_limiter_ref(se->ibuf_comp); @@ -2412,7 +2423,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, #if 0 // XXX old animation system if(seq->ipo && seq->ipo->curve.first) { do_seq_ipo(scene, seq, cfra); - } + } #endif if( scene->r.mode & R_FIELDS ); else seq->facf0 = seq->facf1; @@ -2431,7 +2442,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, IMB_refImBuf(se->ibuf_comp); } else { se->ibuf_comp = IMB_allocImBuf( - (short)seqrectx, (short)seqrecty, + (short)seqrectx, (short)seqrecty, 32, IB_rect, 0); IMB_cache_limiter_insert(se->ibuf_comp); IMB_cache_limiter_ref(se->ibuf_comp); @@ -2441,7 +2452,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, case 1: if (i == 0) { se->ibuf_comp = IMB_allocImBuf( - (short)seqrectx, (short)seqrecty, + (short)seqrectx, (short)seqrecty, 32, IB_rect, 0); IMB_cache_limiter_insert(se->ibuf_comp); IMB_cache_limiter_ref(se->ibuf_comp); @@ -2452,7 +2463,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, do_build_seq_recursively(scene, seq, cfra, render_size); if (!se->ibuf) { se->ibuf = IMB_allocImBuf( - (short)seqrectx, (short)seqrecty, + (short)seqrectx, (short)seqrecty, 32, IB_rect, 0); IMB_cache_limiter_insert(se->ibuf); IMB_cache_limiter_ref(se->ibuf); @@ -2464,7 +2475,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, } break; } - + if (se->ibuf_comp) { break; } @@ -2477,7 +2488,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, struct SeqEffectHandle sh = get_sequence_blend(seq); TStripElem* se1 = give_tstripelem(seq_arr[i-1], cfra); TStripElem* se2 = give_tstripelem(seq_arr[i], cfra); - + int early_out = sh.early_out(seq, seq->facf0, seq->facf1); switch (early_out) { case 0: { @@ -2486,56 +2497,56 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, int swap_input = FALSE; if (se1->ibuf_comp->rect_float || - se2->ibuf->rect_float) { + se2->ibuf->rect_float) { se2->ibuf_comp = IMB_allocImBuf( - (short)seqrectx, (short)seqrecty, + (short)seqrectx, (short)seqrecty, 32, IB_rectfloat, 0); } else { se2->ibuf_comp = IMB_allocImBuf( - (short)seqrectx, (short)seqrecty, + (short)seqrectx, (short)seqrecty, 32, IB_rect, 0); } - if (!se1->ibuf_comp->rect_float && - se2->ibuf_comp->rect_float) { + if (!se1->ibuf_comp->rect_float && + se2->ibuf_comp->rect_float) { IMB_float_from_rect(se1->ibuf_comp); } - if (!se2->ibuf->rect_float && - se2->ibuf_comp->rect_float) { + if (!se2->ibuf->rect_float && + se2->ibuf_comp->rect_float) { IMB_float_from_rect(se2->ibuf); } - if (!se1->ibuf_comp->rect && - !se2->ibuf_comp->rect_float) { + if (!se1->ibuf_comp->rect && + !se2->ibuf_comp->rect_float) { IMB_rect_from_float(se1->ibuf_comp); } - if (!se2->ibuf->rect && - !se2->ibuf_comp->rect_float) { + if (!se2->ibuf->rect && + !se2->ibuf_comp->rect_float) { IMB_rect_from_float(se2->ibuf); } - - /* bad hack, to fix crazy input ordering of + + /* bad hack, to fix crazy input ordering of those two effects */ if (seq->blend_mode == SEQ_ALPHAOVER || - seq->blend_mode == SEQ_ALPHAUNDER || - seq->blend_mode == SEQ_OVERDROP) { + seq->blend_mode == SEQ_ALPHAUNDER || + seq->blend_mode == SEQ_OVERDROP) { swap_input = TRUE; } if (swap_input) { - sh.execute(seq, cfra, - seq->facf0, seq->facf1, x, y, + sh.execute(seq, cfra, + seq->facf0, seq->facf1, x, y, se2->ibuf, se1->ibuf_comp, 0, se2->ibuf_comp); } else { - sh.execute(seq, cfra, - seq->facf0, seq->facf1, x, y, + sh.execute(seq, cfra, + seq->facf0, seq->facf1, x, y, se1->ibuf_comp, se2->ibuf, 0, se2->ibuf_comp); } - + IMB_cache_limiter_insert(se2->ibuf_comp); IMB_cache_limiter_ref(se2->ibuf_comp); IMB_cache_limiter_touch(se2->ibuf_comp); @@ -2570,7 +2581,7 @@ static ImBuf *give_ibuf_seq_impl(Scene *scene, int rectx, int recty, int cfra, i ListBase *seqbasep; TStripElem *se; - + if(ed==NULL) return NULL; count = BLI_countlist(&ed->metastack); @@ -2586,7 +2597,7 @@ static ImBuf *give_ibuf_seq_impl(Scene *scene, int rectx, int recty, int cfra, i se = do_build_seq_array_recursively(scene, seqbasep, cfra, chanshown, render_size); - if(!se) { + if(!se) { return 0; } @@ -2604,7 +2615,7 @@ ImBuf *give_ibuf_seq_direct(Scene *scene, int rectx, int recty, int cfra, int re se = do_build_seq_recursively(scene, seq, cfra, render_size); - if(!se) { + if(!se) { return 0; } @@ -2659,17 +2670,17 @@ static int monoton_cfra = 0; typedef struct PrefetchThread { struct PrefetchThread *next, *prev; - + Scene *scene; struct PrefetchQueueElem *current; pthread_t pthread; int running; - + } PrefetchThread; typedef struct PrefetchQueueElem { struct PrefetchQueueElem *next, *prev; - + int rectx; int recty; int cfra; @@ -2717,9 +2728,9 @@ static void *seq_prefetch_thread(void * This_) } This->running = TRUE; - - if (e->cfra >= s_last) { - e->ibuf = give_ibuf_seq_impl(This->scene, + + if (e->cfra >= s_last) { + e->ibuf = give_ibuf_seq_impl(This->scene, e->rectx, e->recty, e->cfra, e->chanshown, e->render_size); } @@ -2766,7 +2777,7 @@ void seq_start_threads(Scene *scene) seq_last_given_monoton_cfra = monoton_cfra = 0; /* since global structures are modified during the processing - of one frame, only one render thread is currently possible... + of one frame, only one render thread is currently possible... (but we code, in the hope, that we can remove this restriction soon...) @@ -2798,13 +2809,13 @@ void seq_stop_threads() fprintf(stderr, "SEQ-THREAD: ... already stopped\n"); return; } - + pthread_mutex_lock(&wakeup_lock); seq_thread_shutdown = TRUE; - pthread_cond_broadcast(&wakeup_cond); - pthread_mutex_unlock(&wakeup_lock); + pthread_cond_broadcast(&wakeup_cond); + pthread_mutex_unlock(&wakeup_lock); for(tslot = running_threads.first; tslot; tslot= tslot->next) { pthread_join(tslot->pthread, NULL); @@ -2849,7 +2860,7 @@ void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown, pthread_mutex_lock(&queue_lock); BLI_addtail(&prefetch_wait, e); pthread_mutex_unlock(&queue_lock); - + pthread_mutex_lock(&wakeup_lock); pthread_cond_signal(&wakeup_cond); pthread_mutex_unlock(&wakeup_lock); @@ -2899,10 +2910,10 @@ ImBuf *give_ibuf_seq_threaded(Scene *scene, int rectx, int recty, int cfra, int for (e = prefetch_done.first; e; e = e->next) { if (cfra == e->cfra && - chanshown == e->chanshown && - rectx == e->rectx && - recty == e->recty && - render_size == e->render_size) { + chanshown == e->chanshown && + rectx == e->rectx && + recty == e->recty && + render_size == e->render_size) { success = TRUE; found_something = TRUE; break; @@ -2912,10 +2923,10 @@ ImBuf *give_ibuf_seq_threaded(Scene *scene, int rectx, int recty, int cfra, int if (!e) { for (e = prefetch_wait.first; e; e = e->next) { if (cfra == e->cfra && - chanshown == e->chanshown && - rectx == e->rectx && - recty == e->recty && - render_size == e->render_size) { + chanshown == e->chanshown && + rectx == e->rectx && + recty == e->recty && + render_size == e->render_size) { found_something = TRUE; break; } @@ -2925,14 +2936,14 @@ ImBuf *give_ibuf_seq_threaded(Scene *scene, int rectx, int recty, int cfra, int if (!e) { PrefetchThread *tslot; - for(tslot = running_threads.first; - tslot; tslot= tslot->next) { + for(tslot = running_threads.first; + tslot; tslot= tslot->next) { if (tslot->current && - cfra == tslot->current->cfra && - chanshown == tslot->current->chanshown && - rectx == tslot->current->rectx && - recty == tslot->current->recty && - render_size== tslot->current->render_size){ + cfra == tslot->current->cfra && + chanshown == tslot->current->chanshown && + rectx == tslot->current->rectx && + recty == tslot->current->recty && + render_size== tslot->current->render_size){ found_something = TRUE; break; } @@ -2951,7 +2962,7 @@ ImBuf *give_ibuf_seq_threaded(Scene *scene, int rectx, int recty, int cfra, int e = NULL; if (!found_something) { - fprintf(stderr, + fprintf(stderr, "SEQ-THREAD: Requested frame " "not in queue ???\n"); break; @@ -2961,7 +2972,7 @@ ImBuf *give_ibuf_seq_threaded(Scene *scene, int rectx, int recty, int cfra, int pthread_mutex_unlock(&frame_done_lock); } } - + return e ? e->ibuf : 0; } @@ -3002,20 +3013,20 @@ void free_imbuf_seq_except(Scene *scene, int cfra) if(seq->strip) { TStripElem * curelem = give_tstripelem(seq, cfra); - for(a = 0, se = seq->strip->tstripdata; - a < seq->strip->len && se; a++, se++) { + for(a = 0, se = seq->strip->tstripdata; + a < seq->strip->len && se; a++, se++) { if(se != curelem) { free_imbuf_strip_elem(se); } } for(a = 0, se = seq->strip->tstripdata_startstill; - a < seq->strip->startstill && se; a++, se++) { + a < seq->strip->startstill && se; a++, se++) { if(se != curelem) { free_imbuf_strip_elem(se); } } for(a = 0, se = seq->strip->tstripdata_endstill; - a < seq->strip->endstill && se; a++, se++) { + a < seq->strip->endstill && se; a++, se++) { if(se != curelem) { free_imbuf_strip_elem(se); } @@ -3044,19 +3055,19 @@ void free_imbuf_seq(ListBase * seqbase) Sequence *seq; TStripElem *se; int a; - + for(seq= seqbase->first; seq; seq= seq->next) { if(seq->strip) { - for(a = 0, se = seq->strip->tstripdata; - a < seq->strip->len && se; a++, se++) { + for(a = 0, se = seq->strip->tstripdata; + a < seq->strip->len && se; a++, se++) { free_imbuf_strip_elem(se); } - for(a = 0, se = seq->strip->tstripdata_startstill; - a < seq->strip->startstill && se; a++, se++) { + for(a = 0, se = seq->strip->tstripdata_startstill; + a < seq->strip->startstill && se; a++, se++) { free_imbuf_strip_elem(se); } - for(a = 0, se = seq->strip->tstripdata_endstill; - a < seq->strip->endstill && se; a++, se++) { + for(a = 0, se = seq->strip->tstripdata_endstill; + a < seq->strip->endstill && se; a++, se++) { free_imbuf_strip_elem(se); } if(seq->strip->ibuf_startstill) { @@ -3079,7 +3090,7 @@ void free_imbuf_seq(ListBase * seqbase) free_imbuf_seq(&seq->seqbase); } } - + } static int update_changed_seq_recurs(Scene *scene, Sequence *seq, Sequence *changed_seq, int len_change, int ibuf_change) @@ -3087,19 +3098,19 @@ static int update_changed_seq_recurs(Scene *scene, Sequence *seq, Sequence *chan Sequence *subseq; int a, free_imbuf = 0; TStripElem *se; - + /* recurs downwards to see if this seq depends on the changed seq */ - + if(seq == NULL) return 0; - + if(seq == changed_seq) free_imbuf = 1; - + for(subseq=seq->seqbase.first; subseq; subseq=subseq->next) if(update_changed_seq_recurs(scene, subseq, changed_seq, len_change, ibuf_change)) free_imbuf = TRUE; - + if(seq->seq1) if(update_changed_seq_recurs(scene, seq->seq1, changed_seq, len_change, ibuf_change)) free_imbuf = TRUE; @@ -3109,7 +3120,7 @@ static int update_changed_seq_recurs(Scene *scene, Sequence *seq, Sequence *chan if(seq->seq3 && (seq->seq3 != seq->seq1) && (seq->seq3 != seq->seq2)) if(update_changed_seq_recurs(scene, seq->seq3, changed_seq, len_change, ibuf_change)) free_imbuf = TRUE; - + if(free_imbuf) { if(ibuf_change) { se= seq->strip->tstripdata; @@ -3117,18 +3128,18 @@ static int update_changed_seq_recurs(Scene *scene, Sequence *seq, Sequence *chan for(a=0; a<seq->len; a++, se++) free_imbuf_strip_elem(se); } - + if(seq->type == SEQ_MOVIE) free_anim_seq(seq); if(seq->type == SEQ_SPEED) { sequence_effect_speed_rebuild_map(seq, 1); } } - + if(len_change) calc_sequence(seq); } - + return free_imbuf; } @@ -3136,9 +3147,9 @@ void update_changed_seq_and_deps(Scene *scene, Sequence *changed_seq, int len_ch { Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq; - + if (ed==NULL) return; - + for (seq=ed->seqbase.first; seq; seq=seq->next) update_changed_seq_recurs(scene, seq, changed_seq, len_change, ibuf_change); } @@ -3152,7 +3163,7 @@ void free_imbuf_seq() sce= sce->id.next; } } -#endif +#endif void free_imbuf_seq_with_ipo(Scene *scene, struct Ipo *ipo) { @@ -3186,14 +3197,14 @@ void do_render_seq(RenderResult *rr, int cfra) ibuf= give_ibuf_seq(rr->rectx, rr->recty, cfra, 0, 100.0); recurs_depth--; - + if(ibuf) { if(ibuf->rect_float) { if (!rr->rectf) rr->rectf= MEM_mallocN(4*sizeof(float)*rr->rectx*rr->recty, "render_seq rectf"); - + memcpy(rr->rectf, ibuf->rect_float, 4*sizeof(float)*rr->rectx*rr->recty); - + /* TSK! Since sequence render doesn't free the *rr render result, the old rect32 can hang around when sequence render has rendered a 32 bits one before */ if(rr->rect32) { @@ -3212,9 +3223,9 @@ void do_render_seq(RenderResult *rr, int cfra) /* R.rectz = BLI_dupallocN(ibuf->zbuf); */ /* } */ } - + /* Let the cache limitor take care of this (schlaile) */ - /* While render let's keep all memory available for render + /* While render let's keep all memory available for render (ton) At least if free memory is tight... This can make a big difference in encoding speed @@ -3435,7 +3446,7 @@ int shuffle_seq(ListBase * seqbasep, Sequence *test) calc_sequence(test); // XXX - I dont think this is needed since were only moving vertically, Campbell. } - + if(test->machine >= MAXSEQ) { /* Blender 2.4x would remove the strip. * nicer to move it to the end */ @@ -3458,3 +3469,187 @@ int shuffle_seq(ListBase * seqbasep, Sequence *test) return 1; } } + +// AUD_XXX +static int seq_audio_last_frame; +static int seq_audio_playing; + +void seq_play_seq(struct bContext *C, struct Sequence *seq, int start, int end, int keep) +{ + Scene* scene = CTX_data_scene(C); + + while(seq) + { + if(seq->type == SEQ_META) + seq_play_seq(C, seq->seqbase.first, start, end, keep); + + /* XXX don't play back scene sounds as the calculation is wrong for them + if (seq->type == SEQ_SCENE + && seq->scene + && (seq->scene->r.scemode & R_DOSEQ) + && !(seq->scene->r.scemode & R_RECURS_PROTECTION)) + { + Editing *ed; + + seq->scene->r.scemode |= R_RECURS_PROTECTION; + + ed = seq->scene->ed; + + if (ed) + { + // XXX Calculation?! + int sce_cfra = seq->sfra + seq->anim_startofs + + start - seq->startdisp; + int sce_efra = seq->anim_endofs + end - seq->enddisp; + + seq_play_seq(C, ed->seqbasep->first, sce_cfra, sce_efra, keep); + } + + seq->scene->r.scemode &= ~R_RECURS_PROTECTION; + }*/ + + if((seq->type == SEQ_RAM_SOUND || seq->type == SEQ_HD_SOUND) && + seq->sound && seq->sound->stream) + { + int e = seq->len - seq->endofs; + int delay = seq->start - SFRA; + + AUD_Sound *limiter, *delayer, *buffer; + + if(e + delay > end - SFRA) + e = end - SFRA - seq->start + seq->startofs; + + limiter = AUD_limitSound(seq->sound->stream, seq->startofs / FPS, (++e) / FPS); + delayer = AUD_delaySound(limiter, delay / FPS); + buffer = AUD_bufferSound(delayer); + + seq->effectdata = AUD_play(buffer, keep); + + if(start - SFRA > 0) + AUD_seek(seq->effectdata, (start - SFRA) / FPS); + + AUD_unload(buffer); + AUD_unload(delayer); + AUD_unload(limiter); + } + + seq = seq->next; + } +} + +void seq_stop_seq(struct bContext *C, struct Sequence *seq) +{ + while(seq) + { + if(seq->type == SEQ_META) + seq_stop_seq(C, seq->seqbase.first); + + /* XXX don't play back scene sounds as the calculation is wrong for them + if (seq->type == SEQ_SCENE + && seq->scene + && (seq->scene->r.scemode & R_DOSEQ) + && !(seq->scene->r.scemode & R_RECURS_PROTECTION)) + { + Editing *ed; + + seq->scene->r.scemode |= R_RECURS_PROTECTION; + + ed = seq->scene->ed; + + if (ed) + seq_stop_seq(C, ed->seqbasep->first); + + seq->scene->r.scemode &= ~R_RECURS_PROTECTION; + }*/ + + if((seq->type == SEQ_RAM_SOUND || seq->type == SEQ_HD_SOUND) && + seq->sound && seq->sound->stream) + AUD_stop(seq->effectdata); + + seq = seq->next; + } +} + +void seq_update_seq(struct bContext *C, struct Sequence *seq, int frame) +{ + Scene* scene = CTX_data_scene(C); + + while(seq) + { + if(seq->type == SEQ_META) + seq_update_seq(C, seq->seqbase.first, frame); + + /* XXX don't play back scene sounds as the calculation is wrong for them + if (seq->type == SEQ_SCENE + && seq->scene + && (seq->scene->r.scemode & R_DOSEQ) + && !(seq->scene->r.scemode & R_RECURS_PROTECTION)) + { + Editing *ed; + + seq->scene->r.scemode |= R_RECURS_PROTECTION; + + ed = seq->scene->ed; + + if (ed) + seq_update_seq(C, ed->seqbasep->first, frame); + + seq->scene->r.scemode &= ~R_RECURS_PROTECTION; + }*/ + + if((seq->type == SEQ_RAM_SOUND || seq->type == SEQ_HD_SOUND) && + seq->sound && seq->sound->stream) + { + AUD_seek(seq->effectdata, (frame-SFRA) / FPS); + if(AUD_getStatus(seq->effectdata) == AUD_STATUS_PAUSED) + { + AUD_resume(seq->effectdata); + } + } + + seq = seq->next; + } +} + +void seq_play_audio(struct bContext *C) +{ + Scene *scene = CTX_data_scene(C); + + if(scene->ed && scene->ed->seqbasep) + { + seq_play_seq(C, scene->ed->seqbasep->first, CFRA, EFRA, 1); + + seq_audio_last_frame = CFRA; + seq_audio_playing = 1; + } +} + +void seq_stop_audio(struct bContext *C) +{ + Scene *scene = CTX_data_scene(C); + if(seq_audio_playing) + { + seq_stop_seq(C, scene->ed->seqbasep->first); + seq_audio_playing = 0; + } +} + +void seq_update_audio(struct bContext *C, int frame) +{ + if(seq_audio_playing) + { + if(seq_audio_last_frame+1 != frame) + { + Scene *scene = CTX_data_scene(C); + + seq_update_seq(C, scene->ed->seqbasep->first, frame); + } + seq_audio_last_frame = frame; + } + else + { + Scene *scene = CTX_data_scene(C); + if(scene->ed && scene->ed->seqbasep) + seq_play_seq(C, scene->ed->seqbasep->first, CFRA, CFRA+1, 0); + } +} diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index c16b416ec42..ecf27c35ba4 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -19,6 +19,8 @@ #include "BKE_global.h" #include "BKE_main.h" #include "BKE_sound.h" +#include "BKE_context.h" +#include "BKE_library.h" #include "BKE_packedFile.h" #ifdef HAVE_CONFIG_H @@ -167,6 +169,52 @@ void sound_exit() AUD_exit(); } +struct bSound* sound_new(struct bContext *C, char* filename) +{ + bSound* sound = NULL; + + char str[FILE_MAX]; + int len; + + strcpy(str, filename); + BLI_convertstringcode(str, G.sce); + + len = strlen(filename); + while(len > 0 && filename[len-1] != '/' && filename[len-1] != '\\') + len--; + + sound = alloc_libblock(&CTX_data_main(C)->sound, ID_SO, filename+len); + strcpy(sound->name, filename); + + sound_load(sound); + + if(!sound->stream) + { + free_libblock(&CTX_data_main(C)->sound, sound); + sound = NULL; + } + else + { + sound->volume = 1.0; + sound->attenuation = 1.0; + sound->distance = 1.0; + sound->min_gain = 0.0; + sound->max_gain = 1.0; + } + + return sound; +} + +void sound_delete(struct bContext *C, struct bSound* sound) +{ + if(sound) + { + sound_free(sound); + + free_libblock(&CTX_data_main(C)->sound, sound); + } +} + void sound_load(struct bSound* sound) { if(sound) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 2c75c143bc3..21b3d26e68e 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -9130,6 +9130,18 @@ static void do_versions(FileData *fd, Library *lib, Main *main) PTCacheID *pid; ListBase pidlist; +// AUD_XXX + bSound *sound; + + for(sound = main->sound.first; sound; sound = sound->id.next) + { + if(sound->newpackedfile) + { + sound->packedfile = sound->newpackedfile; + sound->newpackedfile = NULL; + } + } + for(screen= main->screen.first; screen; screen= screen->id.next) { do_versions_windowmanager_2_50(screen); do_versions_gpencil_2_50(main, screen); @@ -9221,19 +9233,11 @@ static void do_versions(FileData *fd, Library *lib, Main *main) Scene *sce; ToolSettings *ts; int i; - // AUD_XXX bSound *sound; for(sound = main->sound.first; sound; sound = sound->id.next) - { - if(sound->newpackedfile) - { - sound->packedfile = sound->newpackedfile; - sound->newpackedfile = NULL; - } sound_load(sound); - } for(ob = main->object.first; ob; ob = ob->id.next) { diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt index b7a868ad537..20ef94a8a55 100644 --- a/source/blender/editors/CMakeLists.txt +++ b/source/blender/editors/CMakeLists.txt @@ -36,6 +36,7 @@ SET(INC ../windowmanager ../../kernel/gen_system ../../../intern/SoundSystem ../readstreamglue ../quicktime ../../../intern/elbeem/extern ../../../intern/ghost ../../../intern/opennl/extern ../../../extern/glew/include + ../../../intern/audaspace ../nodes ../gpu ../blenfont diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 73a1c934d97..45fe05dec4a 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -56,6 +56,9 @@ #include "ED_markers.h" #include "ED_screen.h" +// AUD_XXX +#include "BKE_sequence.h" + /* ********************** frame change operator ***************************/ /* Set any flags that are necessary to indicate modal time-changing operation */ @@ -91,6 +94,10 @@ static void change_frame_apply(bContext *C, wmOperator *op) if (cfra < MINAFRAME) cfra= MINAFRAME; CFRA= cfra; + // AUD XXX + if(scene->audio.flag & AUDIO_SCRUB) + seq_update_audio(C, CFRA); + WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); } @@ -121,6 +128,7 @@ static int change_frame_exec(bContext *C, wmOperator *op) change_frame_apply(C, op); change_frame_exit(C, op); + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 05f5d847159..40a234f25ed 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -6,7 +6,7 @@ * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -218,10 +218,10 @@ int ED_operator_posemode(bContext *C) { Object *obact= CTX_data_active_object(C); Object *obedit= CTX_data_edit_object(C); - + if ((obact != obedit) && (obact) && (obact->type==OB_ARMATURE)) return (obact->flag & OB_POSEMODE)!=0; - + return 0; } @@ -305,7 +305,7 @@ int ED_operator_editlattice(bContext *C) /* *************************** action zone operator ************************** */ -/* operator state vars used: +/* operator state vars used: none functions: @@ -313,12 +313,12 @@ functions: apply() set actionzone event exit() free customdata - + callbacks: exec() never used - invoke() check if in zone + invoke() check if in zone add customdata, put mouseco and area in it add modal handler @@ -343,7 +343,7 @@ static ScrArea *screen_areahascursor(bScreen *scr, int x, int y) if(BLI_in_rcti(&sa->totrct, x, y)) break; sa= sa->next; } - + return sa; } @@ -352,43 +352,43 @@ static int actionzone_area_poll(bContext *C) { wmWindow *win= CTX_wm_window(C); ScrArea *sa= CTX_wm_area(C); - + if(sa && win) { AZone *az; int x= win->eventstate->x; int y= win->eventstate->y; - + for(az= sa->actionzones.first; az; az= az->next) if(BLI_in_rcti(&az->rect, x, y)) return 1; - } + } return 0; } AZone *is_in_area_actionzone(ScrArea *sa, int x, int y) { AZone *az= NULL; - + for(az= sa->actionzones.first; az; az= az->next) { if(BLI_in_rcti(&az->rect, x, y)) { if(az->type == AZONE_AREA) { - if(IsPointInTri2DInts(az->x1, az->y1, az->x2, az->y2, x, y)) + if(IsPointInTri2DInts(az->x1, az->y1, az->x2, az->y2, x, y)) break; } else if(az->type == AZONE_REGION) { float v1[2], v2[2], v3[2], pt[2]; - + v1[0]= az->x1; v1[1]= az->y1; v2[0]= az->x2; v2[1]= az->y2; v3[0]= az->x3; v3[1]= az->y3; pt[0]= x; pt[1]=y; - if(IsPointInTri2D(v1, v2, v3, pt)) + if(IsPointInTri2D(v1, v2, v3, pt)) break; } } } - + return az; } @@ -406,9 +406,9 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type) wmEvent event; wmWindow *win= CTX_wm_window(C); sActionzoneData *sad= op->customdata; - + sad->modifier= RNA_int_get(op->ptr, "modifier"); - + event= *(win->eventstate); /* XXX huh huh? make api call */ if(type==AZONE_AREA) event.type= EVT_ACTIONZONE_AREA; @@ -417,7 +417,7 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type) event.customdata= op->customdata; event.customdatafree= TRUE; op->customdata= NULL; - + wm_event_add(win, &event); } @@ -425,17 +425,17 @@ static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event) { AZone *az= is_in_area_actionzone(CTX_wm_area(C), event->x, event->y); sActionzoneData *sad; - + /* quick escape */ if(az==NULL) return OPERATOR_PASS_THROUGH; - + /* ok we do the actionzone */ sad= op->customdata= MEM_callocN(sizeof(sActionzoneData), "sActionzoneData"); sad->sa1= CTX_wm_area(C); sad->az= az; sad->x= event->x; sad->y= event->y; - + /* region azone directly reacts on mouse clicks */ if(sad->az->type==AZONE_REGION) { actionzone_apply(C, op, AZONE_REGION); @@ -445,7 +445,7 @@ static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event) else { /* add modal handler */ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); - + return OPERATOR_RUNNING_MODAL; } } @@ -456,13 +456,13 @@ static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event) sActionzoneData *sad= op->customdata; int deltax, deltay; int mindelta= sad->az->type==AZONE_REGION?1:12; - + switch(event->type) { case MOUSEMOVE: /* calculate gesture direction */ deltax= (event->x - sad->x); deltay= (event->y - sad->y); - + if(deltay > ABS(deltax)) sad->gesture_dir= 'n'; else if(deltax > ABS(deltay)) @@ -471,28 +471,28 @@ static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event) sad->gesture_dir= 's'; else sad->gesture_dir= 'w'; - + /* gesture is large enough? */ if(ABS(deltax) > mindelta || ABS(deltay) > mindelta) { - + /* second area, for join */ sad->sa2= screen_areahascursor(CTX_wm_screen(C), event->x, event->y); /* apply sends event */ actionzone_apply(C, op, sad->az->type); actionzone_exit(C, op); - + return OPERATOR_FINISHED; } break; case ESCKEY: actionzone_exit(C, op); return OPERATOR_CANCELLED; - case LEFTMOUSE: + case LEFTMOUSE: actionzone_exit(C, op); return OPERATOR_CANCELLED; } - + return OPERATOR_RUNNING_MODAL; } @@ -501,20 +501,20 @@ void SCREEN_OT_actionzone(wmOperatorType *ot) /* identifiers */ ot->name= "Handle area action zones"; ot->idname= "SCREEN_OT_actionzone"; - + ot->invoke= actionzone_invoke; ot->modal= actionzone_modal; ot->poll= actionzone_area_poll; ot->flag= OPTYPE_BLOCKING; - + RNA_def_int(ot->srna, "modifier", 0, 0, 2, "modifier", "modifier state", 0, 2); } /* ************** swap area operator *********************************** */ -/* operator state vars used: - sa1 start area +/* operator state vars used: + sa1 start area sa2 area to swap with functions: @@ -528,7 +528,7 @@ void SCREEN_OT_actionzone(wmOperatorType *ot) callbacks: invoke() gets called on shift+lmb drag in actionzone - call init(), add handler + call init(), add handler modal() accept modal events while doing it @@ -545,7 +545,7 @@ static int area_swap_init(bContext *C, wmOperator *op, wmEvent *event) if(sad==NULL || sad->sa1==NULL) return 0; - + sd= MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData"); sd->sa1= sad->sa1; sd->sa2= sad->sa2; @@ -577,7 +577,7 @@ static int area_swap_invoke(bContext *C, wmOperator *op, wmEvent *event) /* add modal handler */ WM_cursor_modal(CTX_wm_window(C), BC_SWAPAREA_CURSOR); WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); - + return OPERATOR_RUNNING_MODAL; } @@ -634,46 +634,46 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event) bScreen *newsc, *sc; ScrArea *sa; rcti rect; - + win= CTX_wm_window(C); sc= CTX_wm_screen(C); sa= CTX_wm_area(C); - + /* XXX hrmf! */ if(event->type==EVT_ACTIONZONE_AREA) { sActionzoneData *sad= event->customdata; if(sad==NULL) return OPERATOR_PASS_THROUGH; - + sa= sad->sa1; } - + /* poll() checks area context, but we don't accept full-area windows */ if(sc->full != SCREENNORMAL) { if(event->type==EVT_ACTIONZONE_AREA) actionzone_exit(C, op); return OPERATOR_CANCELLED; } - + /* adds window to WM */ rect= sa->totrct; BLI_translate_rcti(&rect, win->posx, win->posy); newwin= WM_window_open(C, &rect); - + /* allocs new screen and adds to newly created window, using window size */ newsc= screen_add(newwin, CTX_data_scene(C), sc->id.name+2); newwin->screen= newsc; - + /* copy area to new screen */ area_copy_data((ScrArea *)newsc->areabase.first, sa, 0); - + /* screen, areas init */ WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); if(event->type==EVT_ACTIONZONE_AREA) actionzone_exit(C, op); - + return OPERATOR_FINISHED; } @@ -681,7 +681,7 @@ static void SCREEN_OT_area_dupli(wmOperatorType *ot) { ot->name= "Duplicate Area into New Window"; ot->idname= "SCREEN_OT_area_dupli"; - + ot->invoke= area_dupli_invoke; ot->poll= ED_operator_areaactive; } @@ -689,14 +689,14 @@ static void SCREEN_OT_area_dupli(wmOperatorType *ot) /* ************** move area edge operator *********************************** */ -/* operator state vars used: - x, y mouse coord near edge - delta movement of edge +/* operator state vars used: + x, y mouse coord near edge + delta movement of edge functions: init() set default property values, find edge based on mouse coords, test - if the edge can be moved, select edges, calculate min and max movement + if the edge can be moved, select edges, calculate min and max movement apply() apply delta on selection @@ -707,14 +707,14 @@ static void SCREEN_OT_area_dupli(wmOperatorType *ot) callbacks: exec() execute without any user interaction, based on properties - call init(), apply(), exit() + call init(), apply(), exit() invoke() gets called on mouse click near edge - call init(), add handler + call init(), add handler modal() accept modal events while doing it call apply() with delta motion - call exit() and remove handler + call exit() and remove handler */ @@ -727,14 +727,14 @@ typedef struct sAreaMoveData { static void area_move_set_limits(bScreen *sc, int dir, int *bigger, int *smaller) { ScrArea *sa; - + /* we check all areas and test for free space with MINSIZE */ *bigger= *smaller= 100000; - + for(sa= sc->areabase.first; sa; sa= sa->next) { if(dir=='h') { int y1= sa->v2->vec.y - sa->v1->vec.y-AREAMINY; - + /* if top or down edge selected, test height */ if(sa->v1->flag && sa->v4->flag) *bigger= MIN2(*bigger, y1); @@ -743,7 +743,7 @@ static void area_move_set_limits(bScreen *sc, int dir, int *bigger, int *smaller } else { int x1= sa->v4->vec.x - sa->v1->vec.x-AREAMINX; - + /* if left or right edge selected, test width */ if(sa->v1->flag && sa->v2->flag) *bigger= MIN2(*bigger, x1); @@ -776,12 +776,12 @@ static int area_move_init (bContext *C, wmOperator *op) md->dir= scredge_is_horizontal(actedge)?'h':'v'; if(md->dir=='h') md->origval= actedge->v1->vec.y; else md->origval= actedge->v1->vec.x; - + select_connected_scredge(sc, actedge); /* now all vertices with 'flag==1' are the ones that can be moved. */ area_move_set_limits(sc, md->dir, &md->bigger, &md->smaller); - + return 1; } @@ -791,9 +791,9 @@ static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int wmWindow *win= CTX_wm_window(C); bScreen *sc= CTX_wm_screen(C); ScrVert *v1; - + delta= CLAMPIS(delta, -smaller, bigger); - + for (v1= sc->vertbase.first; v1; v1= v1->next) { if (v1->flag) { /* that way a nice AREAGRID */ @@ -806,7 +806,7 @@ static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int v1->vec.y+= AREAGRID-1; v1->vec.y-= (v1->vec.y % AREAGRID); - + /* prevent too small top header */ if(v1->vec.y > win->sizey-AREAMINY) v1->vec.y= win->sizey-AREAMINY; @@ -821,7 +821,7 @@ static void area_move_apply(bContext *C, wmOperator *op) { sAreaMoveData *md= op->customdata; int delta; - + delta= RNA_int_get(op->ptr, "delta"); area_move_apply_do(C, md->origval, delta, md->dir, md->bigger, md->smaller); } @@ -831,7 +831,7 @@ static void area_move_exit(bContext *C, wmOperator *op) if(op->customdata) MEM_freeN(op->customdata); op->customdata= NULL; - + /* this makes sure aligned edges will result in aligned grabbing */ removedouble_scrverts(CTX_wm_screen(C)); removedouble_scredges(CTX_wm_screen(C)); @@ -841,10 +841,10 @@ static int area_move_exec(bContext *C, wmOperator *op) { if(!area_move_init(C, op)) return OPERATOR_CANCELLED; - + area_move_apply(C, op); area_move_exit(C, op); - + return OPERATOR_FINISHED; } @@ -854,12 +854,12 @@ static int area_move_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_int_set(op->ptr, "x", event->x); RNA_int_set(op->ptr, "y", event->y); - if(!area_move_init(C, op)) + if(!area_move_init(C, op)) return OPERATOR_PASS_THROUGH; - + /* add temp handler */ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); - + return OPERATOR_RUNNING_MODAL; } @@ -892,18 +892,18 @@ static int area_move_modal(bContext *C, wmOperator *op, wmEvent *event) area_move_apply(C, op); break; - + case LEFTMOUSE: if(event->val==0) { area_move_exit(C, op); return OPERATOR_FINISHED; } break; - + case ESCKEY: return area_move_cancel(C, op); } - + return OPERATOR_RUNNING_MODAL; } @@ -929,8 +929,8 @@ void SCREEN_OT_area_move(wmOperatorType *ot) /* ************** split area operator *********************************** */ -/* -operator state vars: +/* +operator state vars: fac spit point dir direction 'v' or 'h' @@ -952,15 +952,15 @@ functions: callbacks: exec() execute without any user interaction, based on state vars - call init(), apply(), exit() + call init(), apply(), exit() invoke() gets called on mouse click in action-widget - call init(), add modal handler + call init(), add modal handler call apply() with initial motion modal() accept modal events while doing it - call move-areas code with delta motion - call exit() or cancel() and remove handler + call move-areas code with delta motion + call exit() or cancel() and remove handler */ @@ -970,7 +970,7 @@ callbacks: typedef struct sAreaSplitData { int x, y; /* last used mouse position */ - + int origval; /* for move areas */ int bigger, smaller; /* constraints for moving new edge */ int delta; /* delta move edge */ @@ -987,25 +987,25 @@ static int area_split_init(bContext *C, wmOperator *op) ScrArea *sa= CTX_wm_area(C); sAreaSplitData *sd; int dir; - + /* required context */ if(sa==NULL) return 0; - + /* required properties */ dir= RNA_enum_get(op->ptr, "direction"); - + /* minimal size */ if(dir=='v' && sa->winx < 2*AREAMINX) return 0; if(dir=='h' && sa->winy < 2*AREAMINY) return 0; - + /* custom data */ sd= (sAreaSplitData*)MEM_callocN(sizeof (sAreaSplitData), "op_area_split"); op->customdata= sd; - + sd->sarea= sa; sd->origsize= dir=='v' ? sa->winx:sa->winy; sd->origmin = dir=='v' ? sa->totrct.xmin:sa->totrct.ymin; - + return 1; } @@ -1021,7 +1021,7 @@ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb) ScrVert *sbv2= sb->v2; ScrVert *sbv3= sb->v3; ScrVert *sbv4= sb->v4; - + if(sav1==sbv4 && sav2==sbv3) { /* sa to right of sb = W */ return screen_findedge(screen, sav1, sav2); } @@ -1046,21 +1046,21 @@ static int area_split_apply(bContext *C, wmOperator *op) sAreaSplitData *sd= (sAreaSplitData *)op->customdata; float fac; int dir; - + fac= RNA_float_get(op->ptr, "factor"); dir= RNA_enum_get(op->ptr, "direction"); sd->narea= area_split(CTX_wm_window(C), sc, sd->sarea, dir, fac); - + if(sd->narea) { ScrVert *sv; - + sd->nedge= area_findsharededge(sc, sd->sarea, sd->narea); - + /* select newly created edge, prepare for moving edge */ for(sv= sc->vertbase.first; sv; sv= sv->next) sv->flag = 0; - + sd->nedge->v1->flag= 1; sd->nedge->v2->flag= 1; @@ -1068,10 +1068,10 @@ static int area_split_apply(bContext *C, wmOperator *op) else sd->origval= sd->nedge->v1->vec.x; WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); - + return 1; - } - + } + return 0; } @@ -1081,7 +1081,7 @@ static void area_split_exit(bContext *C, wmOperator *op) MEM_freeN(op->customdata); op->customdata = NULL; } - + WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); /* this makes sure aligned edges will result in aligned grabbing */ @@ -1094,7 +1094,7 @@ static void area_split_exit(bContext *C, wmOperator *op) static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) { sAreaSplitData *sd; - + if(event->type==EVT_ACTIONZONE_AREA) { sActionzoneData *sad= event->customdata; int dir; @@ -1102,19 +1102,19 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) if(sad->modifier>0) { return OPERATOR_PASS_THROUGH; } - + /* no full window splitting allowed */ if(CTX_wm_area(C)->full) return OPERATOR_PASS_THROUGH; - + /* verify *sad itself */ if(sad==NULL || sad->sa1==NULL || sad->az==NULL) return OPERATOR_PASS_THROUGH; - + /* is this our *sad? if areas not equal it should be passed on */ if(CTX_wm_area(C)!=sad->sa1 || sad->sa1!=sad->sa2) return OPERATOR_PASS_THROUGH; - + /* prepare operator state vars */ if(sad->gesture_dir=='n' || sad->gesture_dir=='s') { dir= 'h'; @@ -1129,41 +1129,41 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) /* general init, also non-UI case, adds customdata, sets area and defaults */ if(!area_split_init(C, op)) return OPERATOR_PASS_THROUGH; - + sd= (sAreaSplitData *)op->customdata; - + sd->x= event->x; sd->y= event->y; - + /* do the split */ if(area_split_apply(C, op)) { area_move_set_limits(CTX_wm_screen(C), dir, &sd->bigger, &sd->smaller); - + /* add temp handler for edge move or cancel */ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); - + return OPERATOR_RUNNING_MODAL; } - + } else { /* nonmodal for now */ return op->type->exec(C, op); } - + return OPERATOR_PASS_THROUGH; } /* function to be called outside UI context, or for redo */ static int area_split_exec(bContext *C, wmOperator *op) { - + if(!area_split_init(C, op)) return OPERATOR_CANCELLED; - + area_split_apply(C, op); area_split_exit(C, op); - + return OPERATOR_FINISHED; } @@ -1194,16 +1194,16 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) switch(event->type) { case MOUSEMOVE: dir= RNA_enum_get(op->ptr, "direction"); - + sd->delta= (dir == 'v')? event->x - sd->origval: event->y - sd->origval; area_move_apply_do(C, sd->origval, sd->delta, dir, sd->bigger, sd->smaller); - + fac= (dir == 'v') ? event->x-sd->origmin : event->y-sd->origmin; RNA_float_set(op->ptr, "factor", fac / (float)sd->origsize); - + WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); break; - + case LEFTMOUSE: if(event->val==0) { /* mouse up */ area_split_exit(C, op); @@ -1214,7 +1214,7 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) case ESCKEY: return area_split_cancel(C, op); } - + return OPERATOR_RUNNING_MODAL; } @@ -1227,14 +1227,14 @@ void SCREEN_OT_area_split(wmOperatorType *ot) { ot->name = "Split area"; ot->idname = "SCREEN_OT_area_split"; - + ot->exec= area_split_exec; ot->invoke= area_split_invoke; ot->modal= area_split_modal; - + ot->poll= ED_operator_areaactive; ot->flag= OPTYPE_REGISTER|OPTYPE_BLOCKING; - + /* rna */ RNA_def_enum(ot->srna, "direction", prop_direction_items, 'h', "Direction", ""); RNA_def_float(ot->srna, "factor", 0.5f, 0.0, 1.0, "Factor", "", 0.0, 1.0); @@ -1249,34 +1249,34 @@ typedef struct RegionMoveData { int bigger, smaller, origval; int origx, origy; char edge; - + } RegionMoveData; static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event) { sActionzoneData *sad= event->customdata; AZone *az= sad->az; - + if(az->ar) { RegionMoveData *rmd= MEM_callocN(sizeof(RegionMoveData), "RegionMoveData"); - + op->customdata= rmd; - + rmd->ar= az->ar; rmd->edge= az->edge; rmd->origx= event->x; rmd->origy= event->y; - if(rmd->edge=='l' || rmd->edge=='r') + if(rmd->edge=='l' || rmd->edge=='r') rmd->origval= rmd->ar->type->minsizex; else rmd->origval= rmd->ar->type->minsizey; - + /* add temp handler */ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); - + return OPERATOR_RUNNING_MODAL; } - + return OPERATOR_FINISHED; } @@ -1284,11 +1284,11 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) { RegionMoveData *rmd= op->customdata; int delta; - + /* execute the events */ switch(event->type) { case MOUSEMOVE: - + if(rmd->edge=='l' || rmd->edge=='r') { delta= event->x - rmd->origx; if(rmd->edge=='l') delta= -delta; @@ -1313,29 +1313,29 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) else rmd->ar->flag &= ~RGN_FLAG_HIDDEN; } - + WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); - + break; - + case LEFTMOUSE: if(event->val==0) { - + if(ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) { rmd->ar->flag ^= RGN_FLAG_HIDDEN; WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); - } + } MEM_freeN(op->customdata); op->customdata = NULL; return OPERATOR_FINISHED; } break; - + case ESCKEY: ; } - + return OPERATOR_RUNNING_MODAL; } @@ -1345,12 +1345,12 @@ static void SCREEN_OT_region_scale(wmOperatorType *ot) /* identifiers */ ot->name= "Scale Region Size"; ot->idname= "SCREEN_OT_region_scale"; - + ot->invoke= region_scale_invoke; ot->modal= region_scale_modal; - + ot->poll= ED_operator_areaactive; - + ot->flag= OPTYPE_BLOCKING; } @@ -1396,11 +1396,11 @@ static int screen_set_exec(bContext *C, wmOperator *op) ScrArea *sa= CTX_wm_area(C); int tot= BLI_countlist(&CTX_data_main(C)->screen); int delta= RNA_int_get(op->ptr, "delta"); - + /* this screen is 'fake', solve later XXX */ if(sa && sa->full) return OPERATOR_CANCELLED; - + if(delta==1) { while(tot--) { screen= screen->id.next; @@ -1420,7 +1420,7 @@ static int screen_set_exec(bContext *C, wmOperator *op) else { screen= NULL; } - + if(screen) { ED_screen_set(C, screen); return OPERATOR_FINISHED; @@ -1432,10 +1432,10 @@ void SCREEN_OT_screen_set(wmOperatorType *ot) { ot->name = "Set Screen"; ot->idname = "SCREEN_OT_screen_set"; - + ot->exec= screen_set_exec; ot->poll= ED_operator_screenactive; - + /* rna */ RNA_def_pointer_runtime(ot->srna, "screen", &RNA_Screen, "Screen", ""); RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX); @@ -1455,7 +1455,7 @@ void SCREEN_OT_screen_full_area(wmOperatorType *ot) { ot->name = "Toggle Make Area Fullscreen"; ot->idname = "SCREEN_OT_screen_full_area"; - + ot->exec= screen_full_area_exec; ot->poll= ED_operator_areaactive; ot->flag= 0; @@ -1466,31 +1466,31 @@ void SCREEN_OT_screen_full_area(wmOperatorType *ot) /* ************** join area operator ********************************************** */ -/* operator state vars used: +/* operator state vars used: x1, y1 mouse coord in first area, which will disappear x2, y2 mouse coord in 2nd area, which will become joined functions: - init() find edge based on state vars - test if the edge divides two areas, + init() find edge based on state vars + test if the edge divides two areas, store active and nonactive area, - + apply() do the actual join exit() cleanup, send notifier callbacks: - exec() calls init, apply, exit - + exec() calls init, apply, exit + invoke() sets mouse coords in x,y - call init() - add modal handler + call init() + add modal handler modal() accept modal events while doing it call apply() with active window and nonactive window - call exit() and remove handler when LMB confirm + call exit() and remove handler when LMB confirm */ @@ -1518,21 +1518,21 @@ static int area_join_init(bContext *C, wmOperator *op) y1= RNA_int_get(op->ptr, "y1"); x2= RNA_int_get(op->ptr, "x2"); y2= RNA_int_get(op->ptr, "y2"); - + sa1 = screen_areahascursor(CTX_wm_screen(C), x1, y1); sa2 = screen_areahascursor(CTX_wm_screen(C), x2, y2); if(sa1==NULL || sa2==NULL || sa1==sa2) return 0; jd = (sAreaJoinData*)MEM_callocN(sizeof (sAreaJoinData), "op_area_join"); - + jd->sa1 = sa1; jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM; jd->sa2 = sa2; jd->sa2->flag |= AREA_FLAG_DRAWJOINTO; - + op->customdata= jd; - + return 1; } @@ -1569,9 +1569,9 @@ static void area_join_exit(bContext *C, wmOperator *op) static int area_join_exec(bContext *C, wmOperator *op) { - if(!area_join_init(C, op)) + if(!area_join_init(C, op)) return OPERATOR_CANCELLED; - + area_join_apply(C, op); area_join_exit(C, op); @@ -1588,30 +1588,30 @@ static int area_join_invoke(bContext *C, wmOperator *op, wmEvent *event) if(sad->modifier>0) { return OPERATOR_PASS_THROUGH; } - + /* verify *sad itself */ if(sad==NULL || sad->sa1==NULL || sad->sa2==NULL) return OPERATOR_PASS_THROUGH; - + /* is this our *sad? if areas equal it should be passed on */ if(sad->sa1==sad->sa2) return OPERATOR_PASS_THROUGH; - + /* prepare operator state vars */ RNA_int_set(op->ptr, "x1", sad->x); RNA_int_set(op->ptr, "y1", sad->y); RNA_int_set(op->ptr, "x2", event->x); RNA_int_set(op->ptr, "y2", event->y); - if(!area_join_init(C, op)) + if(!area_join_init(C, op)) return OPERATOR_PASS_THROUGH; - + /* add temp handler */ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); - + return OPERATOR_RUNNING_MODAL; } - + return OPERATOR_PASS_THROUGH; } @@ -1629,7 +1629,7 @@ static int area_join_cancel(bContext *C, wmOperator *op) } WM_event_add_notifier(C, NC_WINDOW, NULL); - + area_join_exit(C, op); return OPERATOR_CANCELLED; @@ -1640,25 +1640,25 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) { bScreen *sc= CTX_wm_screen(C); sAreaJoinData *jd = (sAreaJoinData *)op->customdata; - + /* execute the events */ switch(event->type) { - - case MOUSEMOVE: + + case MOUSEMOVE: { ScrArea *sa = screen_areahascursor(sc, event->x, event->y); int dir; - - if (sa) { + + if (sa) { if (jd->sa1 != sa) { dir = area_getorientation(sc, jd->sa1, sa); if (dir >= 0) { if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO; jd->sa2 = sa; jd->sa2->flag |= AREA_FLAG_DRAWJOINTO; - } + } else { - /* we are not bordering on the previously selected area + /* we are not bordering on the previously selected area we check if area has common border with the one marked for removal in this case we can swap areas. */ @@ -1670,16 +1670,16 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) jd->sa2 = sa; if (jd->sa1) jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM; if (jd->sa2) jd->sa2->flag |= AREA_FLAG_DRAWJOINTO; - } + } else { if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO; jd->sa2 = NULL; } } WM_event_add_notifier(C, NC_WINDOW, NULL); - } + } else { - /* we are back in the area previously selected for keeping + /* we are back in the area previously selected for keeping * we swap the areas if possible to allow user to choose */ if (jd->sa2 != NULL) { if (jd->sa1) jd->sa1->flag &= ~AREA_FLAG_DRAWJOINFROM; @@ -1692,7 +1692,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) if (dir < 0) { printf("oops, didn't expect that!\n"); } - } + } else { dir = area_getorientation(sc, jd->sa1, sa); if (dir >= 0) { @@ -1714,7 +1714,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_FINISHED; } break; - + case ESCKEY: return area_join_cancel(C, op); } @@ -1728,7 +1728,7 @@ void SCREEN_OT_area_join(wmOperatorType *ot) /* identifiers */ ot->name= "Join area"; ot->idname= "SCREEN_OT_area_join"; - + /* api callbacks */ ot->exec= area_join_exec; ot->invoke= area_join_invoke; @@ -1749,10 +1749,10 @@ void SCREEN_OT_area_join(wmOperatorType *ot) static int repeat_last_exec(bContext *C, wmOperator *op) { wmOperator *lastop= CTX_wm_manager(C)->operators.last; - + if(lastop) WM_operator_repeat(C, lastop); - + return OPERATOR_CANCELLED; } @@ -1761,12 +1761,12 @@ void SCREEN_OT_repeat_last(wmOperatorType *ot) /* identifiers */ ot->name= "Repeat Last"; ot->idname= "SCREEN_OT_repeat_last"; - + /* api callbacks */ ot->exec= repeat_last_exec; - + ot->poll= ED_operator_screenactive; - + } static int repeat_history_invoke(bContext *C, wmOperator *op, wmEvent *event) @@ -1776,11 +1776,11 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, wmEvent *event) uiPopupMenu *pup; uiLayout *layout; int items, i; - + items= BLI_countlist(&wm->operators); if(items==0) return OPERATOR_CANCELLED; - + pup= uiPupMenuBegin(C, op->type->name, 0); layout= uiPupMenuLayout(pup); @@ -1788,23 +1788,23 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, wmEvent *event) uiItemIntO(layout, lastop->type->name, 0, op->type->idname, "index", i); uiPupMenuEnd(C, pup); - + return OPERATOR_CANCELLED; } static int repeat_history_exec(bContext *C, wmOperator *op) { wmWindowManager *wm= CTX_wm_manager(C); - + op= BLI_findlink(&wm->operators, RNA_int_get(op->ptr, "index")); if(op) { /* let's put it as last operator in list */ BLI_remlink(&wm->operators, op); BLI_addtail(&wm->operators, op); - + WM_operator_repeat(C, op); } - + return OPERATOR_FINISHED; } @@ -1813,13 +1813,13 @@ void SCREEN_OT_repeat_history(wmOperatorType *ot) /* identifiers */ ot->name= "Repeat History"; ot->idname= "SCREEN_OT_repeat_history"; - + /* api callbacks */ ot->invoke= repeat_history_invoke; ot->exec= repeat_history_exec; - + ot->poll= ED_operator_screenactive; - + RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, 1000); } @@ -1834,7 +1834,7 @@ static int redo_last_invoke(bContext *C, wmOperator *op, wmEvent *event) for(lastop= wm->operators.last; lastop; lastop= lastop->prev) if((lastop->type->flag & OPTYPE_REGISTER) && (lastop->type->flag & OPTYPE_UNDO)) break; - + if(lastop) WM_operator_redo_popup(C, lastop); @@ -1846,10 +1846,10 @@ void SCREEN_OT_redo_last(wmOperatorType *ot) /* identifiers */ ot->name= "Redo Last"; ot->idname= "SCREEN_OT_redo_last"; - + /* api callbacks */ ot->invoke= redo_last_invoke; - + ot->poll= ED_operator_screenactive; } @@ -1859,7 +1859,7 @@ void SCREEN_OT_redo_last(wmOperatorType *ot) static int region_split_exec(bContext *C, wmOperator *op) { ARegion *ar= CTX_wm_region(C); - + if(ar->regiontype==RGN_TYPE_HEADER) BKE_report(op->reports, RPT_ERROR, "Cannot split header"); else if(ar->alignment==RGN_ALIGN_QSPLIT) @@ -1868,19 +1868,19 @@ static int region_split_exec(bContext *C, wmOperator *op) ScrArea *sa= CTX_wm_area(C); ARegion *newar= BKE_area_region_copy(sa->type, ar); int dir= RNA_enum_get(op->ptr, "type"); - + BLI_insertlinkafter(&sa->regionbase, ar, newar); - + newar->alignment= ar->alignment; - + if(dir=='h') ar->alignment= RGN_ALIGN_HSPLIT; else ar->alignment= RGN_ALIGN_VSPLIT; - + WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); } - + return OPERATOR_FINISHED; } @@ -1889,12 +1889,12 @@ void SCREEN_OT_region_split(wmOperatorType *ot) /* identifiers */ ot->name= "Split Region"; ot->idname= "SCREEN_OT_region_split"; - + /* api callbacks */ ot->invoke= WM_menu_invoke; ot->exec= region_split_exec; ot->poll= ED_operator_areaactive; - + RNA_def_enum(ot->srna, "type", prop_direction_items, 'h', "Direction", ""); } @@ -1904,23 +1904,23 @@ void SCREEN_OT_region_split(wmOperatorType *ot) static int region_foursplit_exec(bContext *C, wmOperator *op) { ARegion *ar= CTX_wm_region(C); - + /* some rules... */ if(ar->regiontype!=RGN_TYPE_WINDOW) BKE_report(op->reports, RPT_ERROR, "Only window region can be 4-splitted"); else if(ar->alignment==RGN_ALIGN_QSPLIT) { ScrArea *sa= CTX_wm_area(C); ARegion *arn; - + /* keep current region */ ar->alignment= 0; - + if(sa->spacetype==SPACE_VIEW3D) { RegionView3D *rv3d= ar->regiondata; rv3d->viewlock= 0; rv3d->rflag &= ~RV3D_CLIPPING; } - + for(ar= sa->regionbase.first; ar; ar= arn) { arn= ar->next; if(ar->alignment==RGN_ALIGN_QSPLIT) { @@ -1938,38 +1938,38 @@ static int region_foursplit_exec(bContext *C, wmOperator *op) ScrArea *sa= CTX_wm_area(C); ARegion *newar; int count; - + ar->alignment= RGN_ALIGN_QSPLIT; - + for(count=0; count<3; count++) { newar= BKE_area_region_copy(sa->type, ar); BLI_addtail(&sa->regionbase, newar); } - + /* lock views and set them */ if(sa->spacetype==SPACE_VIEW3D) { RegionView3D *rv3d; - + rv3d= ar->regiondata; rv3d->viewlock= RV3D_LOCKED; rv3d->view= V3D_VIEW_FRONT; rv3d->persp= V3D_ORTHO; - + ar= ar->next; rv3d= ar->regiondata; rv3d->viewlock= RV3D_LOCKED; rv3d->view= V3D_VIEW_TOP; rv3d->persp= V3D_ORTHO; - + ar= ar->next; rv3d= ar->regiondata; rv3d->viewlock= RV3D_LOCKED; rv3d->view= V3D_VIEW_RIGHT; rv3d->persp= V3D_ORTHO; - + ar= ar->next; rv3d= ar->regiondata; rv3d->view= V3D_VIEW_CAMERA; rv3d->persp= V3D_CAMOB; } - + WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); } - - + + return OPERATOR_FINISHED; } @@ -1978,7 +1978,7 @@ void SCREEN_OT_region_foursplit(wmOperatorType *ot) /* identifiers */ ot->name= "Split Region in 4 Parts"; ot->idname= "SCREEN_OT_region_foursplit"; - + /* api callbacks */ ot->invoke= WM_operator_confirm; ot->exec= region_foursplit_exec; @@ -2003,10 +2003,10 @@ static int region_flip_exec(bContext *C, wmOperator *op) ar->alignment= RGN_ALIGN_RIGHT; else if(ar->alignment==RGN_ALIGN_RIGHT) ar->alignment= RGN_ALIGN_LEFT; - + WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); printf("executed region flip\n"); - + return OPERATOR_FINISHED; } @@ -2016,10 +2016,10 @@ void SCREEN_OT_region_flip(wmOperatorType *ot) /* identifiers */ ot->name= "Flip Region"; ot->idname= "SCREEN_OT_region_flip"; - + /* api callbacks */ ot->exec= region_flip_exec; - + ot->poll= ED_operator_areaactive; ot->flag= OPTYPE_REGISTER; @@ -2059,7 +2059,7 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws) if(redraws & TIME_ALL_IMAGE_WIN) return 1; break; - + } } else if(regiontype==RGN_TYPE_UI) { @@ -2076,13 +2076,13 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws) static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) { bScreen *screen= CTX_wm_screen(C); - + if(screen->animtimer==event->customdata) { Scene *scene= CTX_data_scene(C); wmTimer *wt= screen->animtimer; ScreenAnimData *sad= wt->customdata; ScrArea *sa; - + if(scene->audio.flag & AUDIO_SYNC) { int step = floor(wt->duration * FPS); if (sad->reverse) // XXX does this option work with audio? @@ -2097,7 +2097,7 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) else scene->r.cfra++; } - + if (sad->reverse) { /* jump back to end */ if (scene->r.psfra) { @@ -2123,7 +2123,10 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) /* since we follow drawflags, we can't send notifier but tag regions ourselves */ ED_update_for_newframe(C, 1); - + + // AUD_XXX + seq_update_audio(C, CFRA); + for(sa= screen->areabase.first; sa; sa= sa->next) { ARegion *ar; for(ar= sa->regionbase.first; ar; ar= ar->next) { @@ -2134,9 +2137,9 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) ED_region_tag_redraw(ar); } } - + //WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); - + return OPERATOR_FINISHED; } return OPERATOR_PASS_THROUGH; @@ -2147,12 +2150,12 @@ static void SCREEN_OT_animation_step(wmOperatorType *ot) /* identifiers */ ot->name= "Animation Step"; ot->idname= "SCREEN_OT_animation_step"; - + /* api callbacks */ ot->invoke= screen_animation_step; - + ot->poll= ED_operator_screenactive; - + } /* ****************** anim player, starts or ends timer ***************** */ @@ -2161,23 +2164,29 @@ static void SCREEN_OT_animation_step(wmOperatorType *ot) static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event) { bScreen *screen= CTX_wm_screen(C); - + if(screen->animtimer) { ED_screen_animation_timer(C, 0, 0); + // AUD_XXX + seq_stop_audio(C); } else { int mode= (RNA_boolean_get(op->ptr, "reverse")) ? -1 : 1; - + ED_screen_animation_timer(C, TIME_REGION|TIME_ALL_3D_WIN, mode); - + if(screen->animtimer) { wmTimer *wt= screen->animtimer; ScreenAnimData *sad= wt->customdata; - + sad->ar= CTX_wm_region(C); + + // AUD_XXX + if(mode == 1) + seq_play_audio(C); } } - + return OPERATOR_FINISHED; } @@ -2186,20 +2195,20 @@ void SCREEN_OT_animation_play(wmOperatorType *ot) /* identifiers */ ot->name= "Animation player"; ot->idname= "SCREEN_OT_animation_play"; - + /* api callbacks */ ot->invoke= screen_animation_play; - + ot->poll= ED_operator_screenactive; - + RNA_def_boolean(ot->srna, "reverse", 0, "Play in Reverse", "Animation is played backwards"); } /* ************** border select operator (template) ***************************** */ -/* operator state vars used: (added by default WM callbacks) - xmin, ymin - xmax, ymax +/* operator state vars used: (added by default WM callbacks) + xmin, ymin + xmax, ymax customdata: the wmGesture pointer @@ -2210,23 +2219,23 @@ callbacks: invoke() default WM function adds modal handler - modal() default WM function + modal() default WM function accept modal events while doing it, calls exec(), handles ESC and border drawing - + poll() has to be filled in by user for context */ #if 0 static int border_select_do(bContext *C, wmOperator *op) { int event_type= RNA_int_get(op->ptr, "event_type"); - + if(event_type==LEFTMOUSE) printf("border select do select\n"); else if(event_type==RIGHTMOUSE) printf("border select deselect\n"); - else + else printf("border select do something\n"); - + return 1; } @@ -2235,14 +2244,14 @@ void SCREEN_OT_border_select(wmOperatorType *ot) /* identifiers */ ot->name= "Border select"; ot->idname= "SCREEN_OT_border_select"; - + /* api callbacks */ ot->exec= border_select_do; ot->invoke= WM_border_select_invoke; ot->modal= WM_border_select_modal; - + ot->poll= ED_operator_areaactive; - + /* rna */ RNA_def_int(ot->srna, "event_type", 0, INT_MIN, INT_MAX, "Event Type", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX); @@ -2255,7 +2264,7 @@ void SCREEN_OT_border_select(wmOperatorType *ot) /* ****************************** render invoking ***************** */ -/* set callbacks, exported to sequence render too. +/* set callbacks, exported to sequence render too. Only call in foreground (UI) renders. */ /* returns biggest area that is not uv/image editor. Note that it uses buttons */ @@ -2266,14 +2275,14 @@ static ScrArea *biggest_non_image_area(bContext *C) ScrArea *sa, *big= NULL; int size, maxsize= 0, bwmaxsize= 0; short foundwin= 0; - + for(sa= sc->areabase.first; sa; sa= sa->next) { if(sa->winx > 30 && sa->winy > 30) { size= sa->winx*sa->winy; if(sa->spacetype == SPACE_BUTS) { if(foundwin == 0 && size > bwmaxsize) { bwmaxsize= size; - big= sa; + big= sa; } } else if(sa->spacetype != SPACE_IMAGE && size > maxsize) { @@ -2283,7 +2292,7 @@ static ScrArea *biggest_non_image_area(bContext *C) } } } - + return big; } @@ -2292,7 +2301,7 @@ static ScrArea *biggest_area(bContext *C) bScreen *sc= CTX_wm_screen(C); ScrArea *sa, *big= NULL; int size, maxsize= 0; - + for(sa= sc->areabase.first; sa; sa= sa->next) { size= sa->winx*sa->winy; if(size > maxsize) { @@ -2309,7 +2318,7 @@ static ScrArea *find_area_showing_r_result(bContext *C) bScreen *sc= CTX_wm_screen(C); ScrArea *sa; SpaceImage *sima; - + /* find an imagewindow showing render result */ for(sa=sc->areabase.first; sa; sa= sa->next) { if(sa->spacetype==SPACE_IMAGE) { @@ -2326,7 +2335,7 @@ static ScrArea *find_area_image_empty(bContext *C) bScreen *sc= CTX_wm_screen(C); ScrArea *sa; SpaceImage *sima; - + /* find an imagewindow showing render result */ for(sa=sc->areabase.first; sa; sa= sa->next) { if(sa->spacetype==SPACE_IMAGE) { @@ -2344,7 +2353,7 @@ static ScrArea *find_empty_image_area(bContext *C) bScreen *sc= CTX_wm_screen(C); ScrArea *sa; SpaceImage *sima; - + /* find an imagewindow showing render result */ for(sa=sc->areabase.first; sa; sa= sa->next) { if(sa->spacetype==SPACE_IMAGE) { @@ -2362,25 +2371,25 @@ static void screen_set_image_output(bContext *C) Scene *scene= CTX_data_scene(C); ScrArea *sa; SpaceImage *sima; - + if(scene->r.displaymode==R_OUTPUT_SCREEN) { /* this function returns with changed context */ ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_IMAGE); sa= CTX_wm_area(C); } else { - + sa= find_area_showing_r_result(C); if(sa==NULL) sa= find_area_image_empty(C); - + if(sa==NULL) { /* find largest open non-image area */ sa= biggest_non_image_area(C); if(sa) { ED_area_newspace(C, sa, SPACE_IMAGE); sima= sa->spacedata.first; - + /* makes ESC go back to prev space */ sima->flag |= SI_PREVSPACE; } @@ -2390,26 +2399,26 @@ static void screen_set_image_output(bContext *C) if(sa->spacetype!=SPACE_IMAGE) { // XXX newspace(sa, SPACE_IMAGE); sima= sa->spacedata.first; - + /* makes ESC go back to prev space */ sima->flag |= SI_PREVSPACE; } } } - } + } sima= sa->spacedata.first; - + /* get the correct image, and scale it */ sima->image= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"); - + // if(G.displaymode==2) { // XXX if(sa->full) { sima->flag |= SI_FULLWINDOW|SI_PREVSPACE; - + // ed_screen_fullarea(C, sa); } // } - + } /* executes blocking render */ @@ -2417,20 +2426,20 @@ static int screen_render_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Render *re= RE_GetRender(scene->id.name); - + if(re==NULL) { re= RE_NewRender(scene->id.name); } RE_test_break_cb(re, NULL, (int (*)(void *)) blender_test_break); - + if(RNA_boolean_get(op->ptr, "anim")) RE_BlenderAnim(re, scene, scene->r.sfra, scene->r.efra, scene->frame_step); else RE_BlenderFrame(re, scene, scene->r.cfra); - + // no redraw needed, we leave state as we entered it ED_update_for_newframe(C, 1); - + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene); return OPERATOR_FINISHED; @@ -2450,7 +2459,7 @@ typedef struct RenderJob { static void render_freejob(void *rjv) { RenderJob *rj= rjv; - + MEM_freeN(rj); } @@ -2461,50 +2470,50 @@ static void make_renderinfo_string(RenderStats *rs, Scene *scene, char *str) uintptr_t mem_in_use, mmap_in_use; float megs_used_memory, mmap_used_memory; char *spos= str; - + mem_in_use= MEM_get_memory_in_use(); mmap_in_use= MEM_get_mapped_memory_in_use(); - + megs_used_memory= (mem_in_use-mmap_in_use)/(1024.0*1024.0); mmap_used_memory= (mmap_in_use)/(1024.0*1024.0); - + if(scene->lay & 0xFF000000) spos+= sprintf(spos, "Localview | "); else if(scene->r.scemode & R_SINGLE_LAYER) spos+= sprintf(spos, "Single Layer | "); - + spos+= sprintf(spos, "Fra:%d Ve:%d Fa:%d ", (scene->r.cfra), rs->totvert, rs->totface); if(rs->tothalo) spos+= sprintf(spos, "Ha:%d ", rs->tothalo); if(rs->totstrand) spos+= sprintf(spos, "St:%d ", rs->totstrand); spos+= sprintf(spos, "La:%d Mem:%.2fM (%.2fM) ", rs->totlamp, megs_used_memory, mmap_used_memory); - + if(rs->curfield) spos+= sprintf(spos, "Field %d ", rs->curfield); if(rs->curblur) spos+= sprintf(spos, "Blur %d ", rs->curblur); - + BLI_timestr(rs->lastframetime, info_time_str); spos+= sprintf(spos, "Time:%s ", info_time_str); - + if(rs->infostr) spos+= sprintf(spos, "| %s ", rs->infostr); - + /* very weak... but 512 characters is quite safe */ if(spos >= str+IMA_RW_MAXTEXT) printf("WARNING! renderwin text beyond limit \n"); - + } static void image_renderinfo_cb(void *rjv, RenderStats *rs) { RenderJob *rj= rjv; - + /* malloc OK here, stats_draw is not in tile threads */ if(rj->image->render_text==NULL) rj->image->render_text= MEM_callocN(IMA_RW_MAXTEXT, "rendertext"); - + make_renderinfo_string(rs, rj->scene, rj->image->render_text); - + /* make jobs timer to send notifier */ *(rj->do_update)= 1; @@ -2519,7 +2528,7 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec int ymin, ymax, xmin, xmax; int rymin, rxmin; char *rectc; - + ibuf= BKE_image_get_ibuf(rj->image, &rj->iuser); if(ibuf==NULL) return; @@ -2528,38 +2537,38 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec /* if ymax==recty, rendering of layer is ready, we should not draw, other things happen... */ if(rr->renlay==NULL || renrect->ymax>=rr->recty) return; - + /* xmin here is first subrect x coord, xmax defines subrect width */ xmin = renrect->xmin + rr->crop; xmax = renrect->xmax - xmin - rr->crop; if (xmax<2) return; - + ymin= renrect->ymin + rr->crop; ymax= renrect->ymax - ymin - rr->crop; if(ymax<2) return; renrect->ymin= renrect->ymax; - + } else { xmin = ymin = rr->crop; xmax = rr->rectx - 2*rr->crop; ymax = rr->recty - 2*rr->crop; } - + /* xmin ymin is in tile coords. transform to ibuf */ rxmin= rr->tilerect.xmin + xmin; if(rxmin >= ibuf->x) return; rymin= rr->tilerect.ymin + ymin; if(rymin >= ibuf->y) return; - + if(rxmin + xmax > ibuf->x) xmax= ibuf->x - rxmin; if(rymin + ymax > ibuf->y) ymax= ibuf->y - rymin; - + if(xmax < 1 || ymax < 1) return; - + /* find current float rect for display, first case is after composit... still weak */ if(rr->rectf) rectf= rr->rectf; @@ -2572,7 +2581,7 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec } } if(rectf==NULL) return; - + rectf+= 4*(rr->rectx*ymin + xmin); rectc= (char *)(ibuf->rect + ibuf->x*rymin + rxmin); @@ -2582,7 +2591,7 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec float *rf= rectf; float srgb[3]; char *rc= rectc; - + /* XXX temp. because crop offset */ if( rectc >= (char *)(ibuf->rect)) { for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) { @@ -2603,7 +2612,7 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec for(y1= 0; y1<ymax; y1++) { float *rf= rectf; char *rc= rectc; - + /* XXX temp. because crop offset */ if( rectc >= (char *)(ibuf->rect)) { for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) { @@ -2617,7 +2626,7 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec rectc += 4*ibuf->x; } } - + /* make jobs timer to send notifier */ *(rj->do_update)= 1; } @@ -2625,10 +2634,10 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec static void render_startjob(void *rjv, short *stop, short *do_update) { RenderJob *rj= rjv; - + rj->stop= stop; rj->do_update= do_update; - + if(rj->anim) RE_BlenderAnim(rj->re, rj->scene, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->frame_step); else @@ -2639,7 +2648,7 @@ static void render_startjob(void *rjv, short *stop, short *do_update) static int render_breakjob(void *rjv) { RenderJob *rj= rjv; - + if(G.afbreek) return 1; if(rj->stop && *(rj->stop)) @@ -2653,7 +2662,7 @@ static int screen_render_modal(bContext *C, wmOperator *op, wmEvent *event) /* no running blender, remove handler and pass through */ if(0==WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; - + /* running render */ switch (event->type) { case ESCKEY: @@ -2672,24 +2681,24 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) wmJob *steve; RenderJob *rj; Image *ima; - + /* only one job at a time */ if(WM_jobs_test(CTX_wm_manager(C), scene)) return OPERATOR_CANCELLED; - + /* handle UI stuff */ WM_cursor_wait(1); /* flush multires changes (for sculpt) */ multires_force_update(CTX_data_active_object(C)); - + /* get editmode results */ ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */ - + // store spare // get view3d layer, local layer, make this nice api call to render // store spare - + /* ensure at least 1 area shows result */ screen_set_image_output(C); @@ -2700,40 +2709,40 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) rj->anim= RNA_boolean_get(op->ptr, "anim"); rj->iuser.scene= scene; rj->iuser.ok= 1; - + /* setup job */ steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene); WM_jobs_customdata(steve, rj, render_freejob); WM_jobs_timer(steve, 0.2, NC_SCENE|ND_RENDER_RESULT, 0); WM_jobs_callbacks(steve, render_startjob, NULL, NULL); - + /* get a render result image, and make sure it is empty */ ima= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"); BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE); rj->image= ima; - + /* setup new render */ re= RE_NewRender(scene->id.name); RE_test_break_cb(re, rj, render_breakjob); RE_display_draw_cb(re, rj, image_rect_update); RE_stats_draw_cb(re, rj, image_renderinfo_cb); - + rj->re= re; G.afbreek= 0; - + // BKE_report in render! // RE_error_cb(re, error_cb); WM_jobs_start(CTX_wm_manager(C), steve); - + G.afbreek= 0; - + WM_cursor_wait(0); WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene); /* add modal handler for ESC */ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); - + return OPERATOR_RUNNING_MODAL; } @@ -2744,14 +2753,14 @@ void SCREEN_OT_render(wmOperatorType *ot) /* identifiers */ ot->name= "Render"; ot->idname= "SCREEN_OT_render"; - + /* api callbacks */ ot->invoke= screen_render_invoke; ot->modal= screen_render_modal; ot->exec= screen_render_exec; - + ot->poll= ED_operator_screenactive; - + RNA_def_int(ot->srna, "layers", 0, 0, INT_MAX, "Layers", "", 0, INT_MAX); RNA_def_boolean(ot->srna, "anim", 0, "Animation", ""); } @@ -2762,10 +2771,10 @@ static int render_view_cancel_exec(bContext *C, wmOperator *unused) { ScrArea *sa= CTX_wm_area(C); SpaceImage *sima= sa->spacedata.first; - + if(sima->flag & SI_PREVSPACE) { sima->flag &= ~SI_PREVSPACE; - + if(sima->flag & SI_FULLWINDOW) { sima->flag &= ~SI_FULLWINDOW; ED_screen_full_prevspace(C); @@ -2776,8 +2785,8 @@ static int render_view_cancel_exec(bContext *C, wmOperator *unused) else if(sima->flag & SI_FULLWINDOW) { sima->flag &= ~SI_FULLWINDOW; ed_screen_fullarea(C, sa); - } - + } + return OPERATOR_FINISHED; } @@ -2786,7 +2795,7 @@ void SCREEN_OT_render_view_cancel(struct wmOperatorType *ot) /* identifiers */ ot->name= "Cancel Render View"; ot->idname= "SCREEN_OT_render_view_cancel"; - + /* api callbacks */ ot->exec= render_view_cancel_exec; ot->poll= ED_operator_image_active; @@ -2797,14 +2806,14 @@ void SCREEN_OT_render_view_cancel(struct wmOperatorType *ot) static int render_view_show_exec(bContext *C, wmOperator *unused) { ScrArea *sa= find_area_showing_r_result(C); - + /* determine if render already shows */ if(sa) { SpaceImage *sima= sa->spacedata.first; - + if(sima->flag & SI_PREVSPACE) { sima->flag &= ~SI_PREVSPACE; - + if(sima->flag & SI_FULLWINDOW) { sima->flag &= ~SI_FULLWINDOW; ED_screen_full_prevspace(C); @@ -2818,7 +2827,7 @@ static int render_view_show_exec(bContext *C, wmOperator *unused) else { screen_set_image_output(C); } - + return OPERATOR_FINISHED; } @@ -2827,7 +2836,7 @@ void SCREEN_OT_render_view_show(struct wmOperatorType *ot) /* identifiers */ ot->name= "Show/Hide Render View"; ot->idname= "SCREEN_OT_render_view_show"; - + /* api callbacks */ ot->exec= render_view_show_exec; ot->poll= ED_operator_screenactive; @@ -2845,7 +2854,7 @@ void ED_operatortypes_screen(void) WM_operatortype_append(SCREEN_OT_repeat_last); WM_operatortype_append(SCREEN_OT_repeat_history); WM_operatortype_append(SCREEN_OT_redo_last); - + /* screen tools */ WM_operatortype_append(SCREEN_OT_area_move); WM_operatortype_append(SCREEN_OT_area_split); @@ -2860,12 +2869,12 @@ void ED_operatortypes_screen(void) WM_operatortype_append(SCREEN_OT_screen_full_area); WM_operatortype_append(SCREEN_OT_screenshot); WM_operatortype_append(SCREEN_OT_screencast); - + /*frame changes*/ WM_operatortype_append(SCREEN_OT_frame_offset); WM_operatortype_append(SCREEN_OT_animation_step); WM_operatortype_append(SCREEN_OT_animation_play); - + /* render */ WM_operatortype_append(SCREEN_OT_render); WM_operatortype_append(SCREEN_OT_render_view_cancel); @@ -2873,25 +2882,25 @@ void ED_operatortypes_screen(void) /* tools shared by more space types */ WM_operatortype_append(ED_OT_undo); - WM_operatortype_append(ED_OT_redo); - + WM_operatortype_append(ED_OT_redo); + } /* called in spacetypes.c */ void ED_keymap_screen(wmWindowManager *wm) { ListBase *keymap; - + /* Screen General ------------------------------------------------ */ keymap= WM_keymap_listbase(wm, "Screen", 0, 0); - + /* standard timers */ WM_keymap_add_item(keymap, "SCREEN_OT_animation_step", TIMER0, KM_ANY, KM_ANY, 0); - + RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "modifier", 0); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "modifier", 1); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "modifier", 2); - + /* screen tools */ WM_keymap_verify_item(keymap, "SCREEN_OT_area_split", EVT_ACTIONZONE_AREA, 0, 0, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_area_join", EVT_ACTIONZONE_AREA, 0, 0, 0); @@ -2900,7 +2909,7 @@ void ED_keymap_screen(wmWindowManager *wm) WM_keymap_verify_item(keymap, "SCREEN_OT_region_scale", EVT_ACTIONZONE_REGION, 0, 0, 0); /* area move after action zones */ WM_keymap_verify_item(keymap, "SCREEN_OT_area_move", LEFTMOUSE, KM_PRESS, 0, 0); - + RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1); WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", UPARROWKEY, KM_PRESS, KM_CTRL, 0); @@ -2912,39 +2921,39 @@ void ED_keymap_screen(wmWindowManager *wm) /* tests */ WM_keymap_add_item(keymap, "SCREEN_OT_region_split", SKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); WM_keymap_add_item(keymap, "SCREEN_OT_region_foursplit", SKEY, KM_PRESS, KM_CTRL|KM_ALT|KM_SHIFT, 0); - + WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_history", F3KEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_last", F4KEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_redo_last", F6KEY, KM_PRESS, 0, 0); - + RNA_string_set(WM_keymap_add_item(keymap, "SCRIPT_OT_python_file_run", F7KEY, KM_PRESS, 0, 0)->ptr, "filename", "test.py"); WM_keymap_verify_item(keymap, "SCRIPT_OT_python_run_ui_scripts", F8KEY, KM_PRESS, 0, 0); /* files */ WM_keymap_add_item(keymap, "FILE_OT_exec", RETKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_cancel", ESCKEY, KM_PRESS, 0, 0); - + /* undo */ WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0); - + /* render */ WM_keymap_add_item(keymap, "SCREEN_OT_render", F12KEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SCREEN_OT_render_view_cancel", ESCKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SCREEN_OT_render_view_show", F11KEY, KM_PRESS, 0, 0); - + /* Anim Playback ------------------------------------------------ */ keymap= WM_keymap_listbase(wm, "Frames", 0, 0); - + /* frame offsets */ RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", UPARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", 10); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", DOWNARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", -10); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", LEFTARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", -1); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", RIGHTARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", 1); - + /* play (forward and backwards) */ WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "reverse", 1); diff --git a/source/blender/editors/space_sequencer/SConscript b/source/blender/editors/space_sequencer/SConscript index ab51068a529..9e7ea185c25 100644 --- a/source/blender/editors/space_sequencer/SConscript +++ b/source/blender/editors/space_sequencer/SConscript @@ -6,5 +6,6 @@ sources = env.Glob('*.c') incs = '../include ../../blenlib ../../blenkernel ../../blenfont ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../makesrna' +incs += ' #/intern/audaspace' env.BlenderLib ( 'bf_editors_space_sequencer', sources, Split(incs), [], libtype=['core'], priority=[100] ) diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index f6cf6de4b00..cc9716f3001 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -89,6 +89,10 @@ #include "UI_resources.h" #include "UI_view2d.h" +// AUD_XXX +#include "BKE_sound.h" +#include "AUD_C-API.h" + /* own include */ #include "sequencer_intern.h" @@ -105,15 +109,15 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag) if(flag & SEQPROP_STARTFRAME) RNA_def_int(ot->srna, "start_frame", 0, INT_MIN, INT_MAX, "Start Frame", "Start frame of the sequence strip", INT_MIN, INT_MAX); - + if(flag & SEQPROP_ENDFRAME) RNA_def_int(ot->srna, "end_frame", 0, INT_MIN, INT_MAX, "End Frame", "End frame for the color strip", INT_MIN, INT_MAX); /* not useual since most strips have a fixed length */ - + RNA_def_int(ot->srna, "channel", 1, 1, MAXSEQ, "Channel", "Channel to place this strip into", 1, MAXSEQ); - + if(flag & SEQPROP_FILENAME) RNA_def_string(ot->srna, "filename", "", FILE_MAX, "Scene Name", "full path to load the strip data from"); - + RNA_def_boolean(ot->srna, "replace_sel", 1, "Replace Selection", "replace the current selection"); } @@ -121,22 +125,22 @@ static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, w { ARegion *ar= CTX_wm_region(C); View2D *v2d= UI_view2d_fromcontext(C); - - short mval[2]; + + short mval[2]; float mval_v2d[2]; - + mval[0]= event->x - ar->winrct.xmin; mval[1]= event->y - ar->winrct.ymin; - + UI_view2d_region_to_view(v2d, mval[0], mval[1], &mval_v2d[0], &mval_v2d[1]); - + RNA_int_set(op->ptr, "channel", (int)mval_v2d[1]+0.5f); RNA_int_set(op->ptr, "start_frame", (int)mval_v2d[0]); - + if ((flag & SEQPROP_ENDFRAME) && RNA_property_is_set(op->ptr, "end_frame")==0) RNA_int_set(op->ptr, "end_frame", (int)mval_v2d[0] + 25); // XXX arbitary but ok for now. - + } /* add scene operator */ @@ -144,54 +148,54 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, TRUE); - + Scene *sce_seq; char sce_name[MAX_ID_NAME-2]; - + Sequence *seq; /* generic strip vars */ Strip *strip; StripElem *se; - + int start_frame, channel; /* operator props */ - + start_frame= RNA_int_get(op->ptr, "start_frame"); channel= RNA_int_get(op->ptr, "channel"); - + RNA_string_get(op->ptr, "scene", sce_name); sce_seq= (Scene *)find_id("SC", sce_name); - + if (sce_seq==NULL) { BKE_reportf(op->reports, RPT_ERROR, "Scene \"%s\" not found", sce_name); return OPERATOR_CANCELLED; } - + seq = alloc_sequence(ed->seqbasep, start_frame, channel); - + seq->type= SEQ_SCENE; seq->scene= sce_seq; - + /* basic defaults */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); strip->len = seq->len = sce_seq->r.efra - sce_seq->r.sfra + 1; strip->us= 1; - + strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - - + + RNA_string_get(op->ptr, "name", seq->name); - + calc_sequence_disp(seq); sort_seq(scene); - + if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); set_last_seq(scene, seq); seq->flag |= SELECT; } - + ED_area_tag_redraw(CTX_wm_area(C)); - + return OPERATOR_FINISHED; } @@ -199,7 +203,7 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) static int sequencer_add_scene_strip_invoke(bContext *C, wmOperator *op, wmEvent *event) { sequencer_generic_invoke_xy__internal(C, op, event, 0); - + /* scene can be left default */ RNA_string_set(op->ptr, "scene", "Scene"); // XXX should popup a menu but ton says 2.5 will have some better feature for this @@ -209,7 +213,7 @@ static int sequencer_add_scene_strip_invoke(bContext *C, wmOperator *op, wmEvent void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot) { - + /* identifiers */ ot->name= "Add Scene Strip"; ot->idname= "SEQUENCER_OT_scene_strip_add"; @@ -220,10 +224,10 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot) ot->exec= sequencer_add_scene_strip_exec; ot->poll= ED_operator_sequencer_active; - + /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - + sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); RNA_def_string(ot->srna, "scene", "", MAX_ID_NAME-2, "Scene Name", "Scene name to add as a strip"); } @@ -233,45 +237,45 @@ static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, TRUE); - + struct anim *an; char filename[FILE_MAX]; Sequence *seq; /* generic strip vars */ Strip *strip; StripElem *se; - + int start_frame, channel; /* operator props */ - + start_frame= RNA_int_get(op->ptr, "start_frame"); channel= RNA_int_get(op->ptr, "channel"); - + RNA_string_get(op->ptr, "filename", filename); - + an = openanim(filename, IB_rect); if (an==NULL) { BKE_reportf(op->reports, RPT_ERROR, "Filename \"%s\" could not be loaded as a movie", filename); return OPERATOR_CANCELLED; } - + seq = alloc_sequence(ed->seqbasep, start_frame, channel); - + seq->type= SEQ_MOVIE; seq->anim= an; seq->anim_preseek = IMB_anim_get_preseek(an); - + /* basic defaults */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); - strip->len = seq->len = IMB_anim_get_duration( an ); + strip->len = seq->len = IMB_anim_get_duration( an ); strip->us= 1; - + strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - + BLI_split_dirfile_basic(filename, strip->dir, se->name); RNA_string_get(op->ptr, "name", seq->name); - + calc_sequence_disp(seq); sort_seq(scene); @@ -280,15 +284,15 @@ static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op) set_last_seq(scene, seq); seq->flag |= SELECT; } - + ED_area_tag_redraw(CTX_wm_area(C)); - + return OPERATOR_FINISHED; } static int sequencer_add_movie_strip_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ +{ sequencer_generic_invoke_xy__internal(C, op, event, 0); return WM_operator_filesel(C, op, event); //return sequencer_add_movie_strip_exec(C, op); @@ -297,7 +301,7 @@ static int sequencer_add_movie_strip_invoke(bContext *C, wmOperator *op, wmEvent void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) { - + /* identifiers */ ot->name= "Add Movie Strip"; ot->idname= "SEQUENCER_OT_movie_strip_add"; @@ -308,10 +312,10 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) ot->exec= sequencer_add_movie_strip_exec; ot->poll= ED_operator_sequencer_active; - + /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - + sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILENAME); RNA_def_boolean(ot->srna, "sound", FALSE, "Sound", "Load hd sound with the movie"); // XXX need to impliment this } @@ -322,7 +326,7 @@ static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, TRUE); - + bSound *sound; char filename[FILE_MAX]; @@ -330,12 +334,14 @@ static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op) Sequence *seq; /* generic strip vars */ Strip *strip; StripElem *se; - + + AUD_SoundInfo info; + int start_frame, channel; /* operator props */ - + start_frame= RNA_int_get(op->ptr, "start_frame"); channel= RNA_int_get(op->ptr, "channel"); - + RNA_string_get(op->ptr, "filename", filename); /* XXX if(sfile->flag & FILE_STRINGCODE) { @@ -343,40 +349,55 @@ static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op) }*/ // XXX sound= sound_new_sound(filename); - sound= NULL; - if (sound==NULL || sound->sample->type == SAMPLE_INVALID) { + // AUD_XXX + sound = sound_new(C, filename); + +// sound= NULL; + +// AUD_XXX if (sound==NULL || sound->sample->type == SAMPLE_INVALID) { + if (sound==NULL || sound->stream == NULL) { BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); return OPERATOR_CANCELLED; } - if (sound==NULL || sound->sample->bits != 16) { - BKE_report(op->reports, RPT_ERROR, "Only 16 bit audio is supported"); + // AUD_XXX + info = AUD_getInfo(sound->stream); + + if (info.specs.format == AUD_FORMAT_INVALID) { + sound_delete(C, sound); + BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); return OPERATOR_CANCELLED; } - + +/* if (sound==NULL || sound->sample->bits != 16) { + BKE_report(op->reports, RPT_ERROR, "Only 16 bit audio is supported"); + return OPERATOR_CANCELLED; + }*/ + sound->flags |= SOUND_FLAGS_SEQUENCE; // XXX audio_makestream(sound); - + seq = alloc_sequence(ed->seqbasep, start_frame, channel); - + seq->type= SEQ_RAM_SOUND; seq->sound= sound; - + /* basic defaults */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); - strip->len = seq->len = (int) ( ((float)(sound->streamlen-1) / ( (float)scene->r.audio.mixrate*4.0 ))* FPS); +// AUD_XXX strip->len = seq->len = (int) ( ((float)(sound->streamlen-1) / ( (float)scene->r.audio.mixrate*4.0 ))* FPS); + strip->len = seq->len = (int) (info.length * FPS); strip->us= 1; - + strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - + BLI_split_dirfile_basic(filename, strip->dir, se->name); RNA_string_get(op->ptr, "name", seq->name); - + calc_sequence_disp(seq); sort_seq(scene); - + /* last active name */ strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR-1); @@ -387,13 +408,13 @@ static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op) } ED_area_tag_redraw(CTX_wm_area(C)); - + return OPERATOR_FINISHED; } static int sequencer_add_sound_strip_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ +{ sequencer_generic_invoke_xy__internal(C, op, event, 0); return WM_operator_filesel(C, op, event); //return sequencer_add_sound_strip_exec(C, op); @@ -402,7 +423,7 @@ static int sequencer_add_sound_strip_invoke(bContext *C, wmOperator *op, wmEvent void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot) { - + /* identifiers */ ot->name= "Add Sound Strip"; ot->idname= "SEQUENCER_OT_sound_strip_add"; @@ -413,10 +434,10 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot) ot->exec= sequencer_add_sound_strip_exec; ot->poll= ED_operator_sequencer_active; - + /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - + sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILENAME); RNA_def_boolean(ot->srna, "hd", FALSE, "HD Sound", "Load the sound as streaming audio"); // XXX need to impliment this } @@ -434,28 +455,28 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) Sequence *seq; /* generic strip vars */ Strip *strip; StripElem *se; - + int start_frame, channel; /* operator props */ - + start_frame= RNA_int_get(op->ptr, "start_frame"); channel= RNA_int_get(op->ptr, "channel"); - + RNA_string_get(op->ptr, "filename", filename); - seq = alloc_sequence(ed->seqbasep, start_frame, channel); + seq = alloc_sequence(ed->seqbasep, start_frame, channel); seq->type= SEQ_IMAGE; - + /* basic defaults */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); BLI_split_dirfile_basic(filename, strip->dir, NULL); - + tot_images= RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); - + strip->len = seq->len = tot_images?tot_images:1; strip->us= 1; - + strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - + if(tot_images) { RNA_BEGIN(op->ptr, itemptr, "files") { RNA_string_get(&itemptr, "name", se->name); @@ -468,13 +489,13 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) } RNA_string_get(op->ptr, "name", seq->name); - + calc_sequence_disp(seq); sort_seq(scene); - + /* last active name */ strncpy(ed->act_imagedir, strip->dir, FILE_MAXDIR-1); - + if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); set_last_seq(scene, seq); @@ -482,7 +503,7 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) } ED_area_tag_redraw(CTX_wm_area(C)); - + return OPERATOR_FINISHED; } @@ -490,14 +511,14 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) static int sequencer_add_image_strip_invoke(bContext *C, wmOperator *op, wmEvent *event) { sequencer_generic_invoke_xy__internal(C, op, event, 0); - return WM_operator_filesel(C, op, event); + return WM_operator_filesel(C, op, event); //return sequencer_add_image_strip_exec(C, op); } void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) { - + /* identifiers */ ot->name= "Add Image Strip"; ot->idname= "SEQUENCER_OT_image_strip_add"; @@ -508,12 +529,12 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) ot->exec= sequencer_add_image_strip_exec; ot->poll= ED_operator_sequencer_active; - + /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - + sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILENAME); - + RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", ""); } @@ -530,7 +551,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) struct SeqEffectHandle sh; int start_frame, end_frame, channel, type; /* operator props */ - + Sequence *seq1, *seq2, *seq3; char *error_msg; @@ -539,7 +560,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) channel= RNA_int_get(op->ptr, "channel"); type= RNA_enum_get(op->ptr, "type"); - + // XXX We need unique names and move to invoke if(!seq_effect_find_selected(scene, NULL, type, &seq1, &seq2, &seq3, &error_msg)) { BKE_report(op->reports, RPT_ERROR, error_msg); @@ -570,7 +591,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) } calc_sequence(seq); - + /* basic defaults */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); strip->len = seq->len; @@ -603,7 +624,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) /* not sure if this is needed with update_changed_seq_and_deps. * it was NOT called in blender 2.4x, but wont hurt */ - sort_seq(scene); + sort_seq(scene); if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); @@ -642,10 +663,10 @@ void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot) ot->exec= sequencer_add_effect_strip_exec; ot->poll= ED_operator_sequencer_active; - + /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - + sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME|SEQPROP_FILENAME); RNA_def_enum(ot->srna, "type", sequencer_prop_effect_types, SEQ_CROSS, "Type", "Sequencer effect type"); RNA_def_float_vector(ot->srna, "color", 3, NULL, 0.0f, 1.0f, "Color", "Initialize the strip with this color (only used when type='COLOR')", 0.0f, 1.0f); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 3b90039335e..59d9575e005 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -664,8 +664,9 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, SpaceSeq *sseq, Sequence * draw_shadedstrip(seq, background_col, x1, y1, x2, y2); /* draw additional info and controls */ - if (seq->type == SEQ_RAM_SOUND) - drawseqwave(scene, v2d, seq, x1, y1, x2, y2, ar->winx); +// AUD_XXX +/* if (seq->type == SEQ_RAM_SOUND) + drawseqwave(scene, v2d, seq, x1, y1, x2, y2, ar->winx);*/ if (!is_single_image) draw_seq_extensions(scene, sseq, seq); |