diff --git a/lib/javascript/config.mk b/lib/javascript/config.mk index f622d30a..161bd75f 100644 --- a/lib/javascript/config.mk +++ b/lib/javascript/config.mk @@ -166,11 +166,12 @@ endif endif # Name of the binary code directories -ifdef BUILD_IDG -OBJDIR = $(OS_CONFIG)$(OBJDIR_TAG).OBJD -else -OBJDIR = $(OS_CONFIG)$(OBJDIR_TAG).OBJ -endif +# ifdef BUILD_IDG +# OBJDIR = $(OS_CONFIG)$(OBJDIR_TAG).OBJD +# else +# OBJDIR = $(OS_CONFIG)$(OBJDIR_TAG).OBJ +# endif +OBJDIR = obj VPATH = $(OBJDIR) # Automatic make dependencies file diff --git a/lib/javascript/jsautocfg.h b/lib/javascript/jsautocfg.h deleted file mode 120000 index 95e5fd2d..00000000 --- a/lib/javascript/jsautocfg.h +++ /dev/null @@ -1 +0,0 @@ -Linux_All_DBG.OBJ/jsautocfg.h \ No newline at end of file diff --git a/scripts/audio_test.js b/scripts/audio_test.js index 40f006e0..d2ecca45 100644 --- a/scripts/audio_test.js +++ b/scripts/audio_test.js @@ -3,7 +3,7 @@ // also check the values (samplesize and samplerate) to match your conf // -jrml -H=800; +H=600; M=H/128; W=H/(H/80); //W=600 @@ -13,12 +13,12 @@ set_resolution(W,H); -audio = new AudioJack("alsa_pcm:capture_1", 2048, 44100); +audio = new AudioJack("alsaplayer", 2048, 44100); -encoder = new VideoEncoder(10, 64000, 5, 24000); -encoder.add_audio(audio); -register_encoder(encoder); -encoder.start_filesave("prova.ogg"); +// encoder = new VideoEncoder(10, 64000, 5, 24000); +// encoder.add_audio(audio); +// register_encoder(encoder); +// encoder.start_filesave("prova.ogg"); geo = new GeometryLayer(); geo.activate(true); diff --git a/scripts/pan_joy.js b/scripts/pan_joy.js index 9d808236..0e08231a 100644 --- a/scripts/pan_joy.js +++ b/scripts/pan_joy.js @@ -43,11 +43,13 @@ function init() { try { i = new ImageLayer(tile_x,tile_y); i.open(images[curr_img]); + i.set_fps(); + i.start(); add_layer(i); i.set_position(tile_x*m, tile_y*n); i.activate(); imgs[m][n] = i; - echo ("size " + i.get_width() + "x" + i.get_height() ); + // echo ("size " + i.get_width() + "x" + i.get_height() ); } catch (e) { echo("Failed to open " + e); //echo("Failed to open " + images[curr_img] + ": " + e); @@ -84,7 +86,7 @@ try { } } catch (e) { echo("mh, no joystick?! " + e); - quit(); + // quit(); } last_js = new Array(); @@ -120,11 +122,11 @@ function max_speed () { if (sy < -max_s) sy=-max_s; } -kbd = new KeyboardController(); -register_controller(kbd); -kbd.released_q = function() { quit(); } -kbd.released_a = next_img; -kbd.released_z = prev_img; +// kbd = new KeyboardController(); +// register_controller(kbd); +// kbd.released_q = function() { quit(); } +// kbd.released_a = next_img; +// kbd.released_z = prev_img; function next_img() { //curr_img++; diff --git a/scripts/star.js b/scripts/star.js index ec8e7bcf..3a0bbff7 100644 --- a/scripts/star.js +++ b/scripts/star.js @@ -44,32 +44,33 @@ kbd = new KeyboardController(); kbd.pressed_esc = function() { running = false; } register_controller( kbd ); -geo = new GeometryLayer(); -geo.color(255,255,255,255); -geo.set_blit("alpha"); -geo.set_blit_value(0.1); -geo.start(); -geo.activate(true); -add_layer(geo); +star = new GeometryLayer(); +star.color(255,255,255,255); +star.set_blit("alpha"); +//star.set_name("star.js"); +star.set_blit_value(0.1); +//star.start(); +star.activate(true); +add_layer(star); -drawStar(geo,30,1); +drawStar(star,30,1); srand(); cc = 1; -while(running) { +bang = new TriggerController(); +register_controller(bang); +bang.frame = function() { + cc += 0.05; - geo.color(rand()%255, rand()%255, rand()%255, 0xff); - drawStar(geo, 30, Math.sin(cc)); + star.color(rand()%255, rand()%255, rand()%255, 0xff); + drawStar(star, 30, Math.sin(cc)); if(cc>4.0) { cc = 1; srand(); } - - run(0.01); } -quit(); diff --git a/scripts/text_scroller.js b/scripts/text_scroller.js index e8ef2532..77328f37 100644 --- a/scripts/text_scroller.js +++ b/scripts/text_scroller.js @@ -8,6 +8,9 @@ W = 640; H = 480; +set_resolution(W, H); +set_fps(25); + wordspacing = 5; // setup the keyboard quit @@ -17,7 +20,7 @@ kbd.released_esc = function() { running = false; } register_controller( kbd ); // read a text file into an array -words = file_to_strings("../README"); +words = file_to_strings("test.txt"); // debug echo ( words.length + " words read" ); @@ -62,14 +65,21 @@ function render_word(wrd) { lay = new TextLayer(); lay.size( 50 ); // set the size - - add_layer( lay ); // add it to the screen lay.print( wrd ); // print the string in the layer - lay.set_position( W, 200 ); // start from the right of the screen - lay.slide_position( 0 - lay.w() , 200, 2); // slide to the right + lay.set_fps(25); + + lay.start(); + + + add_layer( lay ); // add it to the screen + + lay.set_position( W, 400 ); // start from the right of the scree + + + // lay.slide_position( 0 - lay.w() , 200, 2); // slide to the right return lay; } @@ -85,13 +95,23 @@ scroll.push( txt ); // advance the index of words idx++; -while(running) { +trigger = new TriggerController(); +register_controller( trigger ); +trigger.frame = function() { - left_x = scroll[0].x(); - right_x = scroll[ scroll.length -1 ].x(); + // slide all to the left + for(i=0; i words.length) idx = 0; - - if(!running) break; + // if the words are finished: stop + if(idx >= words.length) + this.frame = function() { }; } -quit(); diff --git a/src/context.cpp b/src/context.cpp index 74a84012..28b69753 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -19,6 +19,7 @@ * */ +#include #include #include #include @@ -44,12 +45,8 @@ #include #include -#include -#ifdef WITH_OPENGL -#include -#include -#endif +#include void fsigpipe (int Sig); int got_sigpipe; @@ -280,13 +277,14 @@ void Context::cafudda(double secs) { while (lay) { if (!pause) +#ifdef WITH_OPENGL if(screen->opengl) { lay->offset = lay->buffer; ((GlScreen*)screen)->glblit(lay); } else - +#endif lay->cafudda (); lay = (Layer *)lay->prev; diff --git a/src/context_js.cpp b/src/context_js.cpp index e8c2bb7f..03f266ea 100644 --- a/src/context_js.cpp +++ b/src/context_js.cpp @@ -250,8 +250,10 @@ JS(fullscreen) { JS(set_fps) { func("%u:%s:%s",__LINE__,__FILE__,__FUNCTION__); - int fps = JSVAL_TO_INT(argv[0]); - env->set_fps(fps); + + JS_ARG_NUMBER(fps, 0); + + env->set_fps((int)fps); return JS_TRUE; } diff --git a/src/controller.cpp b/src/controller.cpp index dfa97e82..2898b333 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -33,9 +33,9 @@ Controller::Controller() { Controller::~Controller() { func("%s this=%p",__PRETTY_FUNCTION__, this); rem(); - if (jsobj) - JS_SetPrivate(jsenv, jsobj, NULL); - jsobj = NULL; + // if (jsobj) + // JS_SetPrivate(jsenv, jsobj, NULL); + // jsobj = NULL; } char *Controller::get_name() { diff --git a/src/filter.cpp b/src/filter.cpp index c0fbc6d8..dfe0a8a3 100644 --- a/src/filter.cpp +++ b/src/filter.cpp @@ -194,6 +194,11 @@ Filter::Filter(int type, void *filt) active = false; inuse = false; + freior = NULL; + freeframe = NULL; + + bytesize = 0; + // critical errors: if(!filt) error("Filter constructor received a NULL object"); // if(!filt->opened) error("Filter constructor received a Freior object that is not open"); @@ -228,51 +233,68 @@ Filter::Filter(int type, void *filt) case FREEFRAME: freeframe = (Freeframe*)filt; + set_name((char*)freeframe->info->pluginName); + // init freeframe filter - freeframe->main(FF_INITIALISE, NULL, 0); + if(freeframe->main(FF_INITIALISE, NULL, 0).ivalue == FF_FAIL) + error("cannot initialise freeframe plugin %s",name); // TODO freeframe parameters - - if(get_debug()>2) - freeframe->print_info(); - set_name((char*)freeframe->info->pluginName); - - if(get_debug()>2) - freeframe->print_info(); - set_name((char*)freeframe->info->pluginName); + + // if(get_debug()>2) + freeframe->print_info(); + + break; default: error("filter type %u not supported",type); return; } - + backend = type; } Filter::~Filter() { - delete freior; + if(freior) delete freior; + if(freeframe) delete freeframe; } FilterInstance *Filter::apply(Layer *lay) { FilterInstance *instance; instance = new FilterInstance(this); - instance->core = (void*)(*freior->f0r_construct)(lay->geo.w, lay->geo.h); - if(!instance->core) { - error("freior constructor returned NULL applying filter %s",name); - delete instance; - return NULL; + if(freior) { + instance->core = (void*)(*freior->f0r_construct)(lay->geo.w, lay->geo.h); } + + if(freeframe) { + VideoInfoStruct vidinfo; + vidinfo.frameWidth = lay->geo.w; + vidinfo.frameHeight = lay->geo.h; + vidinfo.orientation = 1; + vidinfo.bitDepth = FF_CAP_32BITVIDEO; + instance->intcore = freeframe->main(FF_INSTANTIATE, &vidinfo, 0).ivalue; + if(instance->intcore == FF_FAIL) { + error("Filter %s cannot be instantiated", name); + delete instance; + return NULL; + } + } + + errno=0; instance->outframe = (uint32_t*) calloc(lay->geo.size, 1); if(errno != 0) { error("calloc outframe failed (%i) applying filter %s",errno, name); + error("Filter %s cannot be instantiated", name); delete instance; return NULL; } + bytesize = lay->geo.size; + lay->filters.append(instance); act("initialized filter %s on layer %s", name, lay->name); @@ -288,7 +310,8 @@ char *Filter::description() { if(backend==FREIOR) { ret = (char*)freior->info.explanation; } else if(backend==FREEFRAME) { - // TODO freeframe + // TODO freeframe has no extentedinfostruct returned!? + ret = "freeframe VFX"; } return ret; @@ -316,21 +339,34 @@ char *Filter::get_parameter_description(int i) { } void Filter::destruct(FilterInstance *inst) { - if(inst->core) - if(backend==FREIOR) { + + if(backend==FREIOR) { + + if(inst->core) { (*freior->f0r_destruct)((f0r_instance_t*)inst->core); inst->core = NULL; - } else if(backend==FREEFRAME) { - // TODO freeframe filter desctruct } + + } else if(backend==FREEFRAME) { + + freeframe->main(FF_DEINSTANTIATE, NULL, inst->intcore); + + } } void Filter::update(FilterInstance *inst, double time, uint32_t *inframe, uint32_t *outframe) { - if(backend==FREIOR) { - (*freior->f0r_update)((f0r_instance_t*)inst->core, time, inframe, outframe); - } else if(backend==FREEFRAME) { - // TODO freeframe - } + + if(backend==FREIOR) { + + (*freior->f0r_update)((f0r_instance_t*)inst->core, time, inframe, outframe); + + } else if(backend==FREEFRAME) { + + jmemcpy(outframe,inframe,bytesize); + + freeframe->main(FF_PROCESSFRAME, (void*)outframe, inst->intcore); + + } } @@ -340,8 +376,9 @@ FilterInstance::FilterInstance(Filter *fr) func("creating instance for filter %s",fr->name); proto = fr; - + core = NULL; + intcore = 0; outframe = NULL; active = true; @@ -351,10 +388,12 @@ FilterInstance::FilterInstance(Filter *fr) FilterInstance::~FilterInstance() { func("~FilterInstance"); + if(proto) proto->destruct(this); + if(outframe) free(outframe); - outframe=NULL; + } uint32_t *FilterInstance::process(float fps, uint32_t *inframe) { @@ -362,6 +401,7 @@ uint32_t *FilterInstance::process(float fps, uint32_t *inframe) { error("void filter instance was called for process: %p", this); return inframe; } + proto->update(this, fps, inframe, outframe); return outframe; } diff --git a/src/freeframe.cpp b/src/freeframe.cpp index ea1ba6af..d0e53500 100644 --- a/src/freeframe.cpp +++ b/src/freeframe.cpp @@ -89,7 +89,7 @@ int Freeframe::open(char *file) { // ... and here will segfault if ((plugmain(FF_GETPLUGINCAPS, (LPVOID) FF_CAP_32BITVIDEO, 0)).ivalue != FF_TRUE) { - error("plugin %s: no 24 bit support", file); + func("plugin %s: no 32 bit support", file); dlclose(handle); handle = NULL; return 0; @@ -101,13 +101,9 @@ int Freeframe::open(char *file) { handle = NULL; return 0; } + // init is called by Filter class -// if ((plugmain(FF_INITIALISE, NULL, 0)).ivalue == FF_FAIL) { -// error("plugin %s: init failed", file); -// dlclose(handle); -// handle = NULL; -// return 0; -// } + // (plugmain(FF_INITIALISE, NULL, 0)).ivalue { main = plugmain; info = pis; diff --git a/src/include/filter.h b/src/include/filter.h index 0aaf9b1f..1e28fe3e 100644 --- a/src/include/filter.h +++ b/src/include/filter.h @@ -94,6 +94,7 @@ class Filter : public Entry { protected: void destruct(FilterInstance *inst); void update(FilterInstance *inst, double time, uint32_t *inframe, uint32_t *outframe); + int bytesize; }; @@ -116,6 +117,7 @@ class FilterInstance : public Entry { bool active; bool inuse; + unsigned intcore; void *core; }; diff --git a/src/include/freeframe_freej.h b/src/include/freeframe_freej.h index 96c1bfd7..3d741b79 100644 --- a/src/include/freeframe_freej.h +++ b/src/include/freeframe_freej.h @@ -49,10 +49,6 @@ class Freeframe: public Entry { PlugInfoStruct *info; VideoInfoStruct vidinfo; - /* vidinfo.frameWidth = width; - vidinfo.frameHeight = height; - vidinfo.orientation = 1; - vidinfo.bitDepth = FF_CAP_V_BITS_VIDEO; */ bool opened; diff --git a/src/layer.cpp b/src/layer.cpp index 9cbc6be6..a0fed932 100644 --- a/src/layer.cpp +++ b/src/layer.cpp @@ -217,7 +217,7 @@ void Layer::set_position(int x, int y) { lock(); slide_x = geo.x = x; slide_y = geo.y = y; - //blitter.crop( screen ); + blitter.crop( screen ); unlock(); } diff --git a/src/layer_js.cpp b/src/layer_js.cpp index 37e0f71c..30eeb9df 100644 --- a/src/layer_js.cpp +++ b/src/layer_js.cpp @@ -420,10 +420,10 @@ JS(layer_set_position) { GET_LAYER(Layer); - int new_x_position, new_y_position; - js_ValueToInt32(cx, argv[0], &new_x_position); - js_ValueToInt32(cx, argv[1], &new_y_position); - lay->set_position(new_x_position,new_y_position); + JS_ARG_NUMBER(x,0); + JS_ARG_NUMBER(y,1); + + lay->set_position((int)x, (int)y); return JS_TRUE; } @@ -455,14 +455,15 @@ JS(layer_get_x_position) { GET_LAYER(Layer); - return JS_NewNumberValue(cx, lay->geo.x, rval); + return JS_NewNumberValue(cx, (double)lay->geo.x, rval); + } JS(layer_get_y_position) { func("%u:%s:%s",__LINE__,__FILE__,__FUNCTION__); GET_LAYER(Layer); - return JS_NewNumberValue(cx, lay->geo.y, rval); + return JS_NewNumberValue(cx, (double)lay->geo.y, rval); } JS(layer_get_width) { func("%u:%s:%s",__LINE__,__FILE__,__FUNCTION__); @@ -648,13 +649,14 @@ void js_layer_gc (JSContext *cx, JSObject *obj) { if (l) { func("JSvalcmp(%s): %p / %p Layer: %p", jc->name, OBJECT_TO_JSVAL(obj), l->data, l); if(l->list) { - notice("JSgc: Layer %s/%s is still on stage", jc->name, l->name); - l->data = NULL; + func("JSgc: Layer %s/%s is still on stage", jc->name, l->name); + //l->data = NULL; + // delete l; } else { - notice("JSgc: Layer %s/%s is useless, deleting", jc->name, l->name); - l->data = NULL; // Entry~ calls free(data) - l->stop(); - delete l; + func("JSgc: Layer %s/%s is useless, deleting", jc->name, l->name); + l->data = NULL; // Entry~ calls free(data) + l->stop(); + delete l; } } else { func("Mh, object(%s) has no private data", jc->name);