diff options
51 files changed, 576 insertions, 42 deletions
diff --git a/Makefile.in b/Makefile.in index 022f970..370cfb2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -41,6 +41,7 @@ clean: install: cp fonts/* /usr/X11R6/lib/X11/fonts/TTF + cp -f --remove-destination doc/* $(PD_DIR)/doc/5.reference distro: clean all rm */*.o diff --git a/modules/Makefile b/modules/Makefile index 996f668..842c154 100644 --- a/modules/Makefile +++ b/modules/Makefile @@ -13,6 +13,6 @@ OBJECTS = pdp_intrusion.o pdp_yqt.o pdp_simura.o pdp_underwatch.o \ pdp_compose.o pdp_cmap.o pdp_aa.o pdp_ascii.o \ pdp_ffmpeg~.o pdp_live~.o pdp_segsnd~.o pdp_noquark.o \ pdp_juxta.o pdp_capture.o pdp_smuck.o pdp_lumafilt.o \ - pdp_transition.o pdp_imgloader.o pdp_imgsaver.o + pdp_transition.o pdp_imgloader.o pdp_imgsaver.o pdp_cache.o all_modules: $(OBJECTS) diff --git a/modules/Makefile.in b/modules/Makefile.in index 996f668..842c154 100644 --- a/modules/Makefile.in +++ b/modules/Makefile.in @@ -13,6 +13,6 @@ OBJECTS = pdp_intrusion.o pdp_yqt.o pdp_simura.o pdp_underwatch.o \ pdp_compose.o pdp_cmap.o pdp_aa.o pdp_ascii.o \ pdp_ffmpeg~.o pdp_live~.o pdp_segsnd~.o pdp_noquark.o \ pdp_juxta.o pdp_capture.o pdp_smuck.o pdp_lumafilt.o \ - pdp_transition.o pdp_imgloader.o pdp_imgsaver.o + pdp_transition.o pdp_imgloader.o pdp_imgsaver.o pdp_cache.o all_modules: $(OBJECTS) diff --git a/modules/pdp_aa.c b/modules/pdp_aa.c index ee159f9..6f59c39 100644 --- a/modules/pdp_aa.c +++ b/modules/pdp_aa.c @@ -309,13 +309,14 @@ extern "C" void pdp_aa_setup(void) { - post( pdp_aa_version ); + // post( pdp_aa_version ); pdp_aa_class = class_new(gensym("pdp_aa"), (t_newmethod)pdp_aa_new, (t_method)pdp_aa_free, sizeof(t_pdp_aa), 0, A_NULL); class_addmethod(pdp_aa_class, (t_method)pdp_aa_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_aa_class, (t_method)pdp_aa_driver, gensym("driver"), A_SYMBOL, A_NULL); class_addmethod(pdp_aa_class, (t_method)pdp_aa_render, gensym("render"), A_FLOAT, A_NULL); + class_sethelpsymbol( pdp_aa_class, gensym("pdp_aa.pd") ); } diff --git a/modules/pdp_aging.c b/modules/pdp_aging.c index f2317b2..0a47ff1 100644 --- a/modules/pdp_aging.c +++ b/modules/pdp_aging.c @@ -372,6 +372,7 @@ void pdp_aging_setup(void) class_addmethod(pdp_aging_class, (t_method)pdp_aging_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_aging_class, (t_method)pdp_aging_area_scale, gensym("area_scale"), A_FLOAT, A_NULL); class_addmethod(pdp_aging_class, (t_method)pdp_aging_scratches, gensym("scratches"), A_FLOAT, A_NULL); + class_sethelpsymbol( pdp_aging_class, gensym("pdp_aging.pd") ); } diff --git a/modules/pdp_ascii.c b/modules/pdp_ascii.c index 5d2dc50..cf7f77a 100644 --- a/modules/pdp_ascii.c +++ b/modules/pdp_ascii.c @@ -242,7 +242,7 @@ extern "C" void pdp_ascii_setup(void) { - post( pdp_ascii_version ); + // post( pdp_ascii_version ); pdp_ascii_class = class_new(gensym("pdp_ascii"), (t_newmethod)pdp_ascii_new, (t_method)pdp_ascii_free, sizeof(t_pdp_ascii), 0, A_NULL); @@ -250,6 +250,7 @@ void pdp_ascii_setup(void) class_addmethod(pdp_ascii_class, (t_method)pdp_ascii_color, gensym("color"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_ascii_class, (t_method)pdp_ascii_brightness, gensym("brightness"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_ascii_class, (t_method)pdp_ascii_ratio, gensym("ratio"), A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_ascii_class, gensym("pdp_ascii.pd") ); } diff --git a/modules/pdp_baltan.c b/modules/pdp_baltan.c index b75c074..e919ee2 100644 --- a/modules/pdp_baltan.c +++ b/modules/pdp_baltan.c @@ -223,6 +223,7 @@ void pdp_baltan_setup(void) class_addmethod(pdp_baltan_class, (t_method)pdp_baltan_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_baltan_class, (t_method)pdp_baltan_dfts, gensym("dfts"), A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_baltan_class, gensym("pdp_baltan.pd") ); } diff --git a/modules/pdp_capture.c b/modules/pdp_capture.c index f7e9292..3231f4d 100644 --- a/modules/pdp_capture.c +++ b/modules/pdp_capture.c @@ -919,7 +919,7 @@ extern "C" void pdp_capture_setup(void) { - post( pdp_capture_version ); + // post( pdp_capture_version ); pdp_capture_class = class_new(gensym("pdp_capture"), (t_newmethod)pdp_capture_new, (t_method)pdp_capture_free, sizeof(t_pdp_capture), 0, A_NULL); @@ -930,6 +930,7 @@ void pdp_capture_setup(void) class_addmethod(pdp_capture_class, (t_method)pdp_capture_y, gensym("y"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_capture_class, (t_method)pdp_capture_width, gensym("width"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_capture_class, (t_method)pdp_capture_height, gensym("height"), A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_capture_class, gensym("pdp_capture.pd") ); } diff --git a/modules/pdp_cmap.c b/modules/pdp_cmap.c index 3d8524f..ae2f516 100644 --- a/modules/pdp_cmap.c +++ b/modules/pdp_cmap.c @@ -513,7 +513,7 @@ extern "C" void pdp_cmap_setup(void) { - post( pdp_cmap_version ); + // post( pdp_cmap_version ); pdp_cmap_class = class_new(gensym("pdp_cmap"), (t_newmethod)pdp_cmap_new, (t_method)pdp_cmap_free, sizeof(t_pdp_cmap), 0, A_NULL); @@ -532,6 +532,7 @@ void pdp_cmap_setup(void) class_addmethod(pdp_cmap_class, (t_method)pdp_cmap_delete, gensym("delete"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_cmap_class, (t_method)pdp_cmap_resize, gensym("resize"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_cmap_class, (t_method)pdp_cmap_setcur, gensym("setcur"), A_DEFFLOAT, A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_cmap_class, gensym("pdp_cmap.pd") ); } #ifdef __cplusplus diff --git a/modules/pdp_compose.c b/modules/pdp_compose.c index ed2a5b3..e3fda24 100644 --- a/modules/pdp_compose.c +++ b/modules/pdp_compose.c @@ -436,7 +436,7 @@ extern "C" void pdp_compose_setup(void) { - post( pdp_compose_version ); + // post( pdp_compose_version ); pdp_compose_class = class_new(gensym("pdp_compose"), (t_newmethod)pdp_compose_new, (t_method)pdp_compose_free, sizeof(t_pdp_compose), 0, A_NULL); @@ -452,6 +452,7 @@ void pdp_compose_setup(void) class_addmethod(pdp_compose_class, (t_method)pdp_compose_tolerance, gensym("tolerance"), A_FLOAT, A_NULL); class_addmethod(pdp_compose_class, (t_method)pdp_compose_luminosity, gensym("luminosity"), A_FLOAT, A_NULL); class_addmethod(pdp_compose_class, (t_method)pdp_compose_setcur, gensym("setcur"), A_FLOAT, A_FLOAT, A_NULL); + class_sethelpsymbol( pdp_compose_class, gensym("pdp_compose.pd") ); } #ifdef __cplusplus diff --git a/modules/pdp_ctrack.c b/modules/pdp_ctrack.c index 45e1ccb..e9e631b 100644 --- a/modules/pdp_ctrack.c +++ b/modules/pdp_ctrack.c @@ -652,7 +652,7 @@ extern "C" void pdp_ctrack_setup(void) { - post( pdp_ctrack_version ); + // post( pdp_ctrack_version ); pdp_ctrack_class = class_new(gensym("pdp_ctrack"), (t_newmethod)pdp_ctrack_new, (t_method)pdp_ctrack_free, sizeof(t_pdp_ctrack), 0, A_NULL); @@ -669,6 +669,7 @@ void pdp_ctrack_setup(void) class_addmethod(pdp_ctrack_class, (t_method)pdp_ctrack_cursor, gensym("cursor"), A_FLOAT, A_NULL); class_addmethod(pdp_ctrack_class, (t_method)pdp_ctrack_frame, gensym("frame"), A_FLOAT, A_NULL); class_addmethod(pdp_ctrack_class, (t_method)pdp_ctrack_setcur, gensym("setcur"), A_DEFFLOAT, A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_ctrack_class, gensym("pdp_ctrack.pd") ); } #ifdef __cplusplus diff --git a/modules/pdp_cycle.c b/modules/pdp_cycle.c index f2d0085..5f4b44c 100644 --- a/modules/pdp_cycle.c +++ b/modules/pdp_cycle.c @@ -238,6 +238,7 @@ void pdp_cycle_setup(void) class_addmethod(pdp_cycle_class, (t_method)pdp_cycle_cycley, gensym("cycley"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_cycle_class, (t_method)pdp_cycle_cycleu, gensym("cycleu"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_cycle_class, (t_method)pdp_cycle_cyclev, gensym("cyclev"), A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_cycle_class, gensym("pdp_cycle.pd") ); } diff --git a/modules/pdp_dice.c b/modules/pdp_dice.c index ddb6007..f8addbb 100644 --- a/modules/pdp_dice.c +++ b/modules/pdp_dice.c @@ -337,6 +337,7 @@ void pdp_dice_setup(void) class_addmethod(pdp_dice_class, (t_method)pdp_dice_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_dice_class, (t_method)pdp_dice_cubebits, gensym("cubebits"), A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_dice_class, gensym("pdp_dice.pd") ); } diff --git a/modules/pdp_edge.c b/modules/pdp_edge.c index 89e3cd8..51396ea 100644 --- a/modules/pdp_edge.c +++ b/modules/pdp_edge.c @@ -292,6 +292,7 @@ void pdp_edge_setup(void) (t_method)pdp_edge_free, sizeof(t_pdp_edge), 0, A_NULL); class_addmethod(pdp_edge_class, (t_method)pdp_edge_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_edge_class, gensym("pdp_edge.pd") ); } diff --git a/modules/pdp_ffmpeg~.c b/modules/pdp_ffmpeg~.c index 30e321f..ef215ad 100644 --- a/modules/pdp_ffmpeg~.c +++ b/modules/pdp_ffmpeg~.c @@ -723,7 +723,7 @@ extern "C" void pdp_ffmpeg_tilde_setup(void) { - post( pdp_ffmpeg_version ); + // post( pdp_ffmpeg_version ); pdp_ffmpeg_class = class_new(gensym("pdp_ffmpeg~"), (t_newmethod)pdp_ffmpeg_new, (t_method)pdp_ffmpeg_free, sizeof(t_pdp_ffmpeg), 0, A_NULL); @@ -732,6 +732,7 @@ void pdp_ffmpeg_tilde_setup(void) class_addmethod(pdp_ffmpeg_class, (t_method)pdp_ffmpeg_dsp, gensym("dsp"), 0); class_addmethod(pdp_ffmpeg_class, (t_method)pdp_ffmpeg_feed, gensym("feed"), A_SYMBOL, A_NULL); class_addmethod(pdp_ffmpeg_class, (t_method)pdp_ffmpeg_starve, gensym("starve"), A_NULL); + class_sethelpsymbol( pdp_ffmpeg_class, gensym("pdp_ffmpeg~.pd") ); } diff --git a/modules/pdp_form.c b/modules/pdp_form.c index 5b92fe8..ccbd510 100644 --- a/modules/pdp_form.c +++ b/modules/pdp_form.c @@ -372,7 +372,7 @@ static void pdp_form_allocate(t_pdp_form *x) static void pdp_form_free_ressources(t_pdp_form *x) { - if ( x->x_image != NULL ) imlib_free_image(); + // if ( x->x_image != NULL ) imlib_free_image(); } static void pdp_form_process_yv12(t_pdp_form *x) @@ -405,6 +405,7 @@ static void pdp_form_process_yv12(t_pdp_form *x) memcpy( newdata, data, (x->x_vsize+(x->x_vsize>>1))<<1 ); // draw all texts + if ( x->x_image != NULL ) imlib_context_set_image(x->x_image); imlib_image_clear(); imlib_context_set_direction(IMLIB_TEXT_TO_ANGLE); imdata = imlib_image_get_data(); @@ -580,7 +581,7 @@ extern "C" void pdp_form_setup(void) { - post( pdp_form_version ); + // post( pdp_form_version ); pdp_form_class = class_new(gensym("pdp_form"), (t_newmethod)pdp_form_new, (t_method)pdp_form_free, sizeof(t_pdp_form), 0, A_NULL); @@ -600,6 +601,7 @@ void pdp_form_setup(void) class_addmethod(pdp_form_class, (t_method)pdp_form_clear, gensym("clear"), A_NULL); class_addmethod(pdp_form_class, (t_method)pdp_form_delete, gensym("delete"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_form_class, (t_method)pdp_form_resize, gensym("resize"), A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_form_class, gensym("pdp_form.pd") ); } diff --git a/modules/pdp_i.c b/modules/pdp_i.c index 4ea749c..d7d4b2f 100644 --- a/modules/pdp_i.c +++ b/modules/pdp_i.c @@ -446,9 +446,10 @@ static void *pdp_i_new(t_floatarg fportno) void pdp_i_setup(void) { - post( pdp_i_version ); + // post( pdp_i_version ); pdp_i_class = class_new(gensym("pdp_i"), (t_newmethod) pdp_i_new, (t_method) pdp_i_free, sizeof(t_pdp_i), CLASS_NOINLET, A_DEFFLOAT, A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_i_class, gensym("pdp_i.pd") ); } diff --git a/modules/pdp_imgloader.c b/modules/pdp_imgloader.c index 13cae1e..fbc0714 100644 --- a/modules/pdp_imgloader.c +++ b/modules/pdp_imgloader.c @@ -28,8 +28,21 @@ #include <ctype.h> #include <Imlib2.h> // imlib2 is required +#define MAX_ZONES 20 + static char *pdp_imgloader_version = "pdp_imgloader: version 0.1 : image loading object written by ydegoyon@free.fr "; +typedef struct _triangle +{ + t_int used; + t_int x1, y1; + t_int x2, y2; + t_int x3, y3; + t_float a1, b1; + t_float a2, b2; + t_float a3, b3; +} t_triangle; + typedef struct pdp_imgloader_struct { t_object x_obj; @@ -56,6 +69,9 @@ typedef struct pdp_imgloader_struct t_float x_blend; + t_triangle x_hiddenzones[ MAX_ZONES ]; // hide these parts of the image + unsigned char *x_mask; + } t_pdp_imgloader; /* load an image */ @@ -67,6 +83,7 @@ static void pdp_imgloader_load(t_pdp_imgloader *x, t_symbol *filename, t_floatar if ( x->x_image != NULL ) { + imlib_context_set_image(x->x_image); imlib_free_image(); } x->x_image = imlib_load_image_with_error_return( filename->s_name, &imliberr ); @@ -103,15 +120,378 @@ static void pdp_imgloader_blend(t_pdp_imgloader *x, t_floatarg fblend ) } } -static void pdp_imgloader_clear(t_pdp_imgloader *x ) +static t_int pdp_imgloader_isinzone(t_pdp_imgloader *x, t_int px, t_int py, t_int index) { - if ( x->x_image != NULL ) + t_int c1=0, c2=0, c3=0; + + if ( !x->x_hiddenzones[index].used ) { - imlib_free_image(); + return 0; + } + if ( px < x->x_hiddenzones[index].x1 ) + { + return 0; + } + if ( px > x->x_hiddenzones[index].x3 ) + { + return 0; } + if ( py < x->x_hiddenzones[index].y1 && + py < x->x_hiddenzones[index].y2 && + py < x->x_hiddenzones[index].y3 ) + { + return 0; + } + if ( py > x->x_hiddenzones[index].y1 && + py > x->x_hiddenzones[index].y2 && + py > x->x_hiddenzones[index].y3 ) + { + return 0; + } + if ( ( ( x->x_hiddenzones[index].x2 - x->x_hiddenzones[index].x1 ) == 0 ) && + ( px >= x->x_hiddenzones[index].x1 ) ) + { + c1 = 1; + } + else + { + if ( x->x_hiddenzones[index].a1 == 0 ) + { + if ( ( x->x_hiddenzones[index].y3 >= x->x_hiddenzones[index].y1 ) && + ( py >= x->x_hiddenzones[index].y1 )) + { + c1 = 1; + } + if ( ( x->x_hiddenzones[index].y3 <= x->x_hiddenzones[index].y1 ) && + ( py <= x->x_hiddenzones[index].y1 )) + { + c1 = 1; + } + } + else + { + if ( ( ( (float) py ) - ( x->x_hiddenzones[index].a1*((float)px)+ x->x_hiddenzones[index].b1 ) )* + ( ( (float) x->x_hiddenzones[index].y3 ) - + ( x->x_hiddenzones[index].a1*((float)x->x_hiddenzones[index].x3)+ + x->x_hiddenzones[index].b1 ) ) >= 0.0 ) + { + c1 = 1; + } + } + } + if ( ( ( x->x_hiddenzones[index].x3 - x->x_hiddenzones[index].x2 ) == 0 ) && + ( px <= x->x_hiddenzones[index].x2 ) ) + { + c2 = 1; + } + else + { + if ( x->x_hiddenzones[index].a2 == 0 ) + { + if ( ( x->x_hiddenzones[index].y1 >= x->x_hiddenzones[index].y2 ) && + ( py >= x->x_hiddenzones[index].y2 )) + { + c2 = 1; + } + if ( ( x->x_hiddenzones[index].y1 <= x->x_hiddenzones[index].y2 ) && + ( py <= x->x_hiddenzones[index].y2 )) + { + c2 = 1; + } + } + else + { + if ( ( ( (float) py ) - ( x->x_hiddenzones[index].a2*((float)px)+ x->x_hiddenzones[index].b2 ) )* + ( ( (float) x->x_hiddenzones[index].y1 ) - + ( x->x_hiddenzones[index].a2*((float)x->x_hiddenzones[index].x1)+ + x->x_hiddenzones[index].b2 ) ) >= 0.0 ) + { + c2 = 1; + } + } + } + if ( ( ( x->x_hiddenzones[index].x3 - x->x_hiddenzones[index].x1 ) == 0 ) && + ( px >= x->x_hiddenzones[index].x1 ) ) + { + c3 = 1; + } + else + { + if ( x->x_hiddenzones[index].a3 == 0 ) + { + if ( ( x->x_hiddenzones[index].y2 >= x->x_hiddenzones[index].y1 ) && + ( py >= x->x_hiddenzones[index].y1 )) + { + c3 = 1; + } + if ( ( x->x_hiddenzones[index].y2 <= x->x_hiddenzones[index].y1 ) && + ( py <= x->x_hiddenzones[index].y1 )) + { + c3 = 1; + } + } + else + { + if ( ( ( (float) py ) - ( x->x_hiddenzones[index].a3*((float)px)+ x->x_hiddenzones[index].b3 ) )* + ( ( (float) x->x_hiddenzones[index].y2 ) - + ( x->x_hiddenzones[index].a3*((float)x->x_hiddenzones[index].x2)+ + x->x_hiddenzones[index].b3 ) ) >= 0.0 ) + { + c3 = 1; + } + } + } + + return c1 && c2 && c3; +} + +static t_int pdp_imgloader_ishidden(t_pdp_imgloader *x, t_int px, t_int py) +{ + t_int ti; + + for ( ti=0; ti<MAX_ZONES; ti++ ) + { + if ( x->x_hiddenzones[ti].used ) + { + if ( pdp_imgloader_isinzone( x, px, py, ti ) ) + { + return 1; + } + } + } + return 0; +} + +static void pdp_imgloader_update_mask(t_pdp_imgloader *x ) +{ + t_int px, py; + + for ( py=0; py<x->x_vheight; py++ ) + { + for ( px=0; px<x->x_vwidth; px++ ) + { + *(x->x_mask+py*x->x_vwidth+px) = (unsigned char) pdp_imgloader_ishidden( x, px, py ); + } + } +} + +static void pdp_imgloader_hide(t_pdp_imgloader *x, t_symbol *s, int argc, t_atom *argv) +{ + t_int ti; + t_float fx1, fy1, fx2, fy2, fx3, fy3; + + if ( argc != 6 ) + { + post( "pdp_imgloader : hide : wrong number of arguments : %d", argc ); + return; + } + if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT || argv[2].a_type != A_FLOAT || + argv[3].a_type != A_FLOAT || argv[4].a_type != A_FLOAT || argv[5].a_type != A_FLOAT ) { + post( "pdp_imgloader : hide : wrong arguments" ); + return; + } + + fx1 = argv[0].a_w.w_float; + fy1 = argv[1].a_w.w_float; + fx2 = argv[2].a_w.w_float; + fy2 = argv[3].a_w.w_float; + fx3 = argv[4].a_w.w_float; + fy3 = argv[5].a_w.w_float; + + if ( ( (int)fx1 >= 0 ) && ( (int)fx1 < x->x_vwidth ) && + ( (int)fx2 >= 0 ) && ( (int)fx2 < x->x_vwidth ) && + ( (int)fx3 >= 0 ) && ( (int)fx3 < x->x_vwidth ) && + ( (int)fy1 >= 0 ) && ( (int)fy1 < x->x_vheight ) && + ( (int)fy2 >= 0 ) && ( (int)fy2 < x->x_vheight ) && + ( (int)fy3 >= 0 ) && ( (int)fy3 < x->x_vheight ) ) + { + post( "pdp_imgloader : hide : coordinates : %d %d %d %d %d %d", + (int)fx1, (int)fy1, (int)fx2, (int)fy2, (int)fx3, (int)fy3 ); + for ( ti=0; ti<MAX_ZONES; ti++ ) + { + if ( !x->x_hiddenzones[ti].used ) + { + x->x_hiddenzones[ti].used = 1; + if ( (int) fx1 < (int) fx2 ) + { + if ( (int) fx2 < (int) fx3 ) + { + x->x_hiddenzones[ti].x1 = (int) fx1; + x->x_hiddenzones[ti].y1 = (int) fy1; + x->x_hiddenzones[ti].x2 = (int) fx2; + x->x_hiddenzones[ti].y2 = (int) fy2; + x->x_hiddenzones[ti].x3 = (int) fx3; + x->x_hiddenzones[ti].y3 = (int) fy3; + } + else + { + if ( (int) fx3 < (int) fx1 ) + { + x->x_hiddenzones[ti].x1 = (int) fx3; + x->x_hiddenzones[ti].y1 = (int) fy3; + x->x_hiddenzones[ti].x2 = (int) fx1; + x->x_hiddenzones[ti].y2 = (int) fy1; + x->x_hiddenzones[ti].x3 = (int) fx2; + x->x_hiddenzones[ti].y3 = (int) fy2; + } + else + { + x->x_hiddenzones[ti].x1 = (int) fx1; + x->x_hiddenzones[ti].y1 = (int) fy1; + x->x_hiddenzones[ti].x2 = (int) fx3; + x->x_hiddenzones[ti].y2 = (int) fy3; + x->x_hiddenzones[ti].x3 = (int) fx2; + x->x_hiddenzones[ti].y3 = (int) fy2; + } + } + } + else + { + if ( (int) fx2 < (int) fx3 ) + { + if ( (int) fx3 < (int) fx1 ) + { + x->x_hiddenzones[ti].x1 = (int) fx2; + x->x_hiddenzones[ti].y1 = (int) fy2; + x->x_hiddenzones[ti].x2 = (int) fx3; + x->x_hiddenzones[ti].y2 = (int) fy3; + x->x_hiddenzones[ti].x3 = (int) fx1; + x->x_hiddenzones[ti].y3 = (int) fy1; + } + else + { + x->x_hiddenzones[ti].x1 = (int) fx2; + x->x_hiddenzones[ti].y1 = (int) fy2; + x->x_hiddenzones[ti].x2 = (int) fx1; + x->x_hiddenzones[ti].y2 = (int) fy1; + x->x_hiddenzones[ti].x3 = (int) fx3; + x->x_hiddenzones[ti].y3 = (int) fy3; + } + } + else + { + x->x_hiddenzones[ti].x1 = (int) fx3; + x->x_hiddenzones[ti].y1 = (int) fy3; + x->x_hiddenzones[ti].x2 = (int) fx2; + x->x_hiddenzones[ti].y2 = (int) fy2; + x->x_hiddenzones[ti].x3 = (int) fx1; + x->x_hiddenzones[ti].y3 = (int) fy1; + } + } + post( "pdp_imgloader : hiding : [%d,%d]/[%d,%d]/[%d,%d], ", + x->x_hiddenzones[ti].x1, x->x_hiddenzones[ti].y1, + x->x_hiddenzones[ti].x2, x->x_hiddenzones[ti].y2, + x->x_hiddenzones[ti].x3, x->x_hiddenzones[ti].y3 ); + if ( (x->x_hiddenzones[ti].x2-x->x_hiddenzones[ti].x1) != 0 ) + { + x->x_hiddenzones[ti].a1 = + ( ( (float) x->x_hiddenzones[ti].y2 ) - ( (float) x->x_hiddenzones[ti].y1 ) ) / + ( ( (float) x->x_hiddenzones[ti].x2 ) - ( (float) x->x_hiddenzones[ti].x1 ) ); + x->x_hiddenzones[ti].b1 = + ( ( (float) x->x_hiddenzones[ti].y1 )*( (float) x->x_hiddenzones[ti].x2 ) - + ( (float) x->x_hiddenzones[ti].y2 )*( (float) x->x_hiddenzones[ti].x1 ) ) / + ( ( (float) x->x_hiddenzones[ti].x2 ) - ( (float) x->x_hiddenzones[ti].x1 ) ); + } + if ( (x->x_hiddenzones[ti].x2-x->x_hiddenzones[ti].x3) != 0 ) + { + x->x_hiddenzones[ti].a2 = + ( ( (float) x->x_hiddenzones[ti].y3 ) - ( (float) x->x_hiddenzones[ti].y2 ) ) / + ( ( (float) x->x_hiddenzones[ti].x3 ) - ( (float) x->x_hiddenzones[ti].x2 ) ); + x->x_hiddenzones[ti].b2 = + ( ( (float) x->x_hiddenzones[ti].y3 )*( (float) x->x_hiddenzones[ti].x2 ) - + ( (float) x->x_hiddenzones[ti].y2 )*( (float) x->x_hiddenzones[ti].x3 ) ) / + ( ( (float) x->x_hiddenzones[ti].x2 ) - ( (float) x->x_hiddenzones[ti].x3 ) ); + } + if ( (x->x_hiddenzones[ti].x3-x->x_hiddenzones[ti].x1) != 0 ) + { + x->x_hiddenzones[ti].a3 = + ( ( (float) x->x_hiddenzones[ti].y3 ) - ( (float) x->x_hiddenzones[ti].y1 ) ) / + ( ( (float) x->x_hiddenzones[ti].x3 ) - ( (float) x->x_hiddenzones[ti].x1 ) ); + x->x_hiddenzones[ti].b3 = + ( ( (float) x->x_hiddenzones[ti].y1 )*( (float) x->x_hiddenzones[ti].x3 ) - + ( (float) x->x_hiddenzones[ti].y3 )*( (float) x->x_hiddenzones[ti].x1 ) ) / + ( ( (float) x->x_hiddenzones[ti].x3 ) - ( (float) x->x_hiddenzones[ti].x1 ) ); + } + post( "pdp_imgloader : hiding : a1=%f b1=%f", + x->x_hiddenzones[ti].a1, x->x_hiddenzones[ti].b1 ); + post( "pdp_imgloader : hiding : a2=%f b2=%f", + x->x_hiddenzones[ti].a2, x->x_hiddenzones[ti].b2 ); + post( "pdp_imgloader : hiding : a3=%f b3=%f", + x->x_hiddenzones[ti].a3, x->x_hiddenzones[ti].b3 ); + pdp_imgloader_update_mask( x ); + return; + } + if ( x->x_hiddenzones[ti].used && ( ti == MAX_ZONES-1 ) ) + { + post( "pdp_imgloader : hidden zones table is full" ); + return; + } + } + } + else + { + post( "pdp_imgloader : hide : wrong coordinates : %d %d %d %d %d %d (width=%d) (height=%d)", + (int)fx1, (int)fy1, (int)fx2, (int)fy2, (int)fx3, (int)fy3, x->x_vwidth, x->x_vheight ); + return; + } +} + +static void pdp_imgloader_rawhide(t_pdp_imgloader *x, t_symbol *s, int argc, t_atom *argv) +{ + if ( (x->x_vwidth == 0) || ( x->x_vheight == 0 ) ) + { + post( "pdp_imgloader : rawhide : no video loaded" ); + return; + } + + argv[0].a_w.w_float *= x->x_vwidth; + argv[1].a_w.w_float *= x->x_vheight; + argv[2].a_w.w_float *= x->x_vwidth; + argv[3].a_w.w_float *= x->x_vheight; + argv[4].a_w.w_float *= x->x_vwidth; + argv[5].a_w.w_float *= x->x_vheight; + + post( "pdp_imgloader : rawhide : coordinates : %f %f %f %f %f %f (width=%d) (height=%d)", + argv[0].a_w.w_float, argv[1].a_w.w_float, argv[2].a_w.w_float, + argv[3].a_w.w_float, argv[4].a_w.w_float, argv[5].a_w.w_float, + x->x_vwidth, x->x_vheight ); + + pdp_imgloader_hide( x, s, argc, argv ); +} + +static void pdp_imgloader_unhide(t_pdp_imgloader *x, t_floatarg findex ) +{ + if ( ( (int) findex < 0 ) || ( (int) findex >= MAX_ZONES ) ) + { + post( "pdp_imgloader : unhide : wrong index" ); + return; + } + x->x_hiddenzones[(int)findex].used = 0; + pdp_imgloader_update_mask( x ); +} + +static void pdp_imgloader_clear(t_pdp_imgloader *x ) +{ + //if ( x->x_image != NULL ) + //{ + // imlib_free_image(); + //} x->x_image = NULL; } +static void pdp_imgloader_free_ressources(t_pdp_imgloader *x ) +{ + if ( x->x_mask != NULL ) + { + freebytes( x->x_mask, x->x_vsize ); + } +} + +static void pdp_imgloader_allocate(t_pdp_imgloader *x ) +{ + x->x_mask = (unsigned char*)getbytes( x->x_vsize ); +} + static void pdp_imgloader_process_yv12(t_pdp_imgloader *x) { t_pdp *header = pdp_packet_header(x->x_packet0); @@ -126,9 +506,11 @@ static void pdp_imgloader_process_yv12(t_pdp_imgloader *x) if ( ( (int)(header->info.image.width) != x->x_vwidth ) || ( (int)(header->info.image.height) != x->x_vheight ) ) { + pdp_imgloader_free_ressources( x ); x->x_vwidth = header->info.image.width; x->x_vheight = header->info.image.height; x->x_vsize = x->x_vwidth*x->x_vheight; + pdp_imgloader_allocate( x ); } newheader->info.image.encoding = header->info.image.encoding; @@ -137,6 +519,7 @@ static void pdp_imgloader_process_yv12(t_pdp_imgloader *x) memcpy( newdata, data, (x->x_vsize+(x->x_vsize>>1))<<1 ); + if ( x->x_image != NULL ) imlib_context_set_image(x->x_image); pY = newdata; pV = newdata+x->x_vsize; pU = newdata+x->x_vsize+(x->x_vsize>>2); @@ -147,6 +530,7 @@ static void pdp_imgloader_process_yv12(t_pdp_imgloader *x) if ( ( x->x_image != NULL ) && (px >= x->x_xoffset) && ( px < x->x_xoffset + x->x_iwidth ) && (py >= x->x_yoffset) && ( py < x->x_yoffset + x->x_iheight ) + && ( !(*(x->x_mask+py*x->x_vwidth+px)) ) ) { y = yuv_RGBtoY(x->x_imdata[(py-x->x_yoffset)*x->x_iwidth+(px-x->x_xoffset)]); @@ -171,6 +555,17 @@ static void pdp_imgloader_process_yv12(t_pdp_imgloader *x) *(pU) = (int)((1-factor)*(*(pU)) + factor*((u-128)<<8)); } } + // paint it white ( for debugging ) + /* + if ( ( abs( py - x->x_hiddenzones[0].a1*px - x->x_hiddenzones[0].b1 ) < 0.1 ) || + ( abs( py - x->x_hiddenzones[0].a2*px - x->x_hiddenzones[0].b2 ) < 0.1 ) || + ( abs( py - x->x_hiddenzones[0].a3*px - x->x_hiddenzones[0].b3 ) < 0.1 ) ) + { + *(pY) = (0xff<<7); + *(pU) = (0xff<<8); + *(pV) = (0xff<<8); + } + */ pY++; if ( (px%2==0) && (py%2==0) ) { @@ -245,6 +640,7 @@ static void pdp_imgloader_free(t_pdp_imgloader *x) { int i; + pdp_imgloader_free_ressources(x); pdp_queue_finish(x->x_queue_id); pdp_packet_mark_unused(x->x_packet0); } @@ -253,7 +649,7 @@ t_class *pdp_imgloader_class; void *pdp_imgloader_new(void) { - int i; + int ti; t_pdp_imgloader *x = (t_pdp_imgloader *)pd_new(pdp_imgloader_class); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("xoffset")); @@ -267,6 +663,12 @@ void *pdp_imgloader_new(void) x->x_image = NULL; x->x_blend = 1; + x->x_mask = NULL; + + for ( ti=0; ti<MAX_ZONES; ti++ ) + { + x->x_hiddenzones[ti].used = 0; + } return (void *)x; } @@ -281,7 +683,7 @@ extern "C" void pdp_imgloader_setup(void) { - post( pdp_imgloader_version ); + // post( pdp_imgloader_version ); pdp_imgloader_class = class_new(gensym("pdp_imgloader"), (t_newmethod)pdp_imgloader_new, (t_method)pdp_imgloader_free, sizeof(t_pdp_imgloader), 0, A_NULL); @@ -292,6 +694,10 @@ void pdp_imgloader_setup(void) class_addmethod(pdp_imgloader_class, (t_method)pdp_imgloader_xoffset, gensym("xoffset"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_imgloader_class, (t_method)pdp_imgloader_yoffset, gensym("yoffset"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_imgloader_class, (t_method)pdp_imgloader_blend, gensym("blend"), A_DEFFLOAT, A_NULL); + class_addmethod(pdp_imgloader_class, (t_method)pdp_imgloader_hide, gensym("hide"), A_GIMME, A_NULL); + class_addmethod(pdp_imgloader_class, (t_method)pdp_imgloader_rawhide, gensym("rawhide"), A_GIMME, A_NULL); + class_addmethod(pdp_imgloader_class, (t_method)pdp_imgloader_unhide, gensym("unhide"), A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_imgloader_class, gensym("pdp_imgloader.pd") ); } diff --git a/modules/pdp_imgsaver.c b/modules/pdp_imgsaver.c index 5f11098..6e261a0 100644 --- a/modules/pdp_imgsaver.c +++ b/modules/pdp_imgsaver.c @@ -122,11 +122,11 @@ static void *pdp_imgsaver_do_save(void *tdata) post( "pdp_imgsaver : saved to : %s", x->x_filename->s_name ); } - if ( x->x_image != NULL ) - { - imlib_free_image(); - x->x_image = NULL; - } + //if ( x->x_image != NULL ) + //{ + // imlib_free_image(); + //} + x->x_image = NULL; x->x_save_pending = 0; x->x_filename = NULL; @@ -150,11 +150,11 @@ static void pdp_imgsaver_save(t_pdp_imgsaver *x, t_symbol *filename) } x->x_save_pending = 1; x->x_filename = filename; - if ( x->x_image != NULL ) - { - imlib_free_image(); - x->x_image = NULL; - } + //if ( x->x_image != NULL ) + //{ + // imlib_free_image(); + //} + x->x_image = NULL; // launch saving thread if ( pthread_attr_init( &save_child_attr ) < 0 ) @@ -325,13 +325,14 @@ extern "C" void pdp_imgsaver_setup(void) { - post( pdp_imgsaver_version ); + // post( pdp_imgsaver_version ); pdp_imgsaver_class = class_new(gensym("pdp_imgsaver"), (t_newmethod)pdp_imgsaver_new, (t_method)pdp_imgsaver_free, sizeof(t_pdp_imgsaver), 0, A_NULL); class_addmethod(pdp_imgsaver_class, (t_method)pdp_imgsaver_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_imgsaver_class, (t_method)pdp_imgsaver_save, gensym("save"), A_SYMBOL, A_NULL); + class_sethelpsymbol( pdp_imgsaver_class, gensym("pdp_imgsaver.pd") ); } diff --git a/modules/pdp_intrusion.c b/modules/pdp_intrusion.c index 26c9ead..763f41f 100644 --- a/modules/pdp_intrusion.c +++ b/modules/pdp_intrusion.c @@ -420,6 +420,7 @@ void pdp_intrusion_setup(void) class_addmethod(pdp_intrusion_class, (t_method)pdp_intrusion_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_intrusion_class, (t_method)pdp_intrusion_background, gensym("background"), A_NULL); class_addmethod(pdp_intrusion_class, (t_method)pdp_intrusion_threshold, gensym("threshold"), A_FLOAT, A_NULL); + class_sethelpsymbol( pdp_intrusion_class, gensym("pdp_intrusion.pd") ); } diff --git a/modules/pdp_juxta.c b/modules/pdp_juxta.c index e0b107a..5f04902 100644 --- a/modules/pdp_juxta.c +++ b/modules/pdp_juxta.c @@ -305,12 +305,13 @@ extern "C" void pdp_juxta_setup(void) { - post( pdp_juxta_version ); + // post( pdp_juxta_version ); pdp_juxta_class = class_new(gensym("pdp_juxta"), (t_newmethod)pdp_juxta_new, (t_method)pdp_juxta_free, sizeof(t_pdp_juxta), CLASS_NOINLET, A_NULL); class_addmethod(pdp_juxta_class, (t_method)pdp_juxta_input_0, gensym("pdp1"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_juxta_class, (t_method)pdp_juxta_input_1, gensym("pdp2"), A_SYMBOL, A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_juxta_class, gensym("pdp_juxta.pd") ); } diff --git a/modules/pdp_lens.c b/modules/pdp_lens.c index a46312a..072d8d0 100644 --- a/modules/pdp_lens.c +++ b/modules/pdp_lens.c @@ -331,6 +331,7 @@ void pdp_lens_setup(void) class_addmethod(pdp_lens_class, (t_method)pdp_lens_csize, gensym("csize"), A_FLOAT, A_NULL); class_addmethod(pdp_lens_class, (t_method)pdp_lens_zoom, gensym("zoom"), A_FLOAT, A_NULL); class_addmethod(pdp_lens_class, (t_method)pdp_lens_mode, gensym("mode"), A_FLOAT, A_NULL); + class_sethelpsymbol( pdp_lens_class, gensym("pdp_lens.pd") ); } diff --git a/modules/pdp_live~.c b/modules/pdp_live~.c index aa8398d..6b8823f 100644 --- a/modules/pdp_live~.c +++ b/modules/pdp_live~.c @@ -772,7 +772,7 @@ extern "C" void pdp_live_tilde_setup(void) { - post( pdp_live_version ); + // post( pdp_live_version ); pdp_live_class = class_new(gensym("pdp_live~"), (t_newmethod)pdp_live_new, (t_method)pdp_live_free, sizeof(t_pdp_live), 0, A_NULL); @@ -781,6 +781,7 @@ void pdp_live_tilde_setup(void) class_addmethod(pdp_live_class, (t_method)pdp_live_disconnect, gensym("disconnect"), A_NULL); class_addmethod(pdp_live_class, (t_method)pdp_live_priority, gensym("priority"), A_FLOAT, A_NULL); class_addmethod(pdp_live_class, (t_method)pdp_live_audio, gensym("audio"), A_FLOAT, A_NULL); + class_sethelpsymbol( pdp_live_class, gensym("pdp_live~.pd") ); } diff --git a/modules/pdp_lumafilt.c b/modules/pdp_lumafilt.c index 62f1a87..0de1676 100644 --- a/modules/pdp_lumafilt.c +++ b/modules/pdp_lumafilt.c @@ -123,7 +123,7 @@ static void pdp_lumafilt_process_yv12(t_pdp_lumafilt *x) for (py = 0; py < x->x_vheight; py++) { for (px = 0; px < x->x_vwidth; px++) { luma = (*(pnY)>>7); - if ( ( luma >0 ) && ( luma < MAX_LUMA ) ) // paranoid + if ( ( luma >=0 ) && ( luma < MAX_LUMA ) ) // paranoid { if ( x->x_filter[luma] ) { @@ -247,6 +247,7 @@ void pdp_lumafilt_setup(void) class_addmethod(pdp_lumafilt_class, (t_method)pdp_lumafilt_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_lumafilt_class, (t_method)pdp_lumafilt_filter, gensym("filter"), A_DEFFLOAT, A_DEFFLOAT, A_NULL); class_addmethod(pdp_lumafilt_class, (t_method)pdp_lumafilt_mfilter, gensym("mfilter"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_lumafilt_class, gensym("pdp_lumafilt.pd") ); } diff --git a/modules/pdp_mgrid.c b/modules/pdp_mgrid.c index 3f3939c..77e8ad9 100644 --- a/modules/pdp_mgrid.c +++ b/modules/pdp_mgrid.c @@ -318,7 +318,7 @@ extern "C" void pdp_mgrid_setup(void) { - post( pdp_mgrid_version ); + // post( pdp_mgrid_version ); pdp_mgrid_class = class_new(gensym("pdp_mgrid"), (t_newmethod)pdp_mgrid_new, (t_method)pdp_mgrid_free, sizeof(t_pdp_mgrid), 0, A_NULL); @@ -327,6 +327,7 @@ void pdp_mgrid_setup(void) class_addmethod(pdp_mgrid_class, (t_method)pdp_mgrid_x_dim, gensym("dimx"), A_FLOAT, A_NULL); class_addmethod(pdp_mgrid_class, (t_method)pdp_mgrid_y_dim, gensym("dimy"), A_FLOAT, A_NULL); class_addmethod(pdp_mgrid_class, (t_method)pdp_mgrid_color, gensym("color"), A_FLOAT, A_NULL); + class_sethelpsymbol( pdp_mgrid_class, gensym("pdp_mgrid.pd") ); } diff --git a/modules/pdp_mosaic.c b/modules/pdp_mosaic.c index 1fb3487..9bcca86 100644 --- a/modules/pdp_mosaic.c +++ b/modules/pdp_mosaic.c @@ -304,6 +304,7 @@ void pdp_mosaic_setup(void) class_addmethod(pdp_mosaic_class, (t_method)pdp_mosaic_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_mosaic_class, (t_method)pdp_mosaic_background, gensym("background"), A_NULL); class_addmethod(pdp_mosaic_class, (t_method)pdp_mosaic_level, gensym("level"), A_FLOAT, A_NULL); + class_sethelpsymbol( pdp_mosaic_class, gensym("pdp_mosaic.pd") ); } diff --git a/modules/pdp_nervous.c b/modules/pdp_nervous.c index df76821..aeb3553 100644 --- a/modules/pdp_nervous.c +++ b/modules/pdp_nervous.c @@ -275,6 +275,7 @@ void pdp_nervous_setup(void) class_addmethod(pdp_nervous_class, (t_method)pdp_nervous_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_nervous_class, (t_method)pdp_nervous_mode, gensym("mode"), A_FLOAT, A_NULL); class_addmethod(pdp_nervous_class, (t_method)pdp_nervous_planes, gensym("planes"), A_FLOAT, A_NULL); + class_sethelpsymbol( pdp_nervous_class, gensym("pdp_nervous.pd") ); } diff --git a/modules/pdp_noquark.c b/modules/pdp_noquark.c index 399b11f..0ba61d9 100644 --- a/modules/pdp_noquark.c +++ b/modules/pdp_noquark.c @@ -271,6 +271,7 @@ void pdp_noquark_setup(void) class_addmethod(pdp_noquark_class, (t_method)pdp_noquark_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_noquark_class, (t_method)pdp_noquark_planes, gensym("planes"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_noquark_class, (t_method)pdp_noquark_tolerance, gensym("tolerance"), A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_noquark_class, gensym("pdp_noquark.pd") ); } diff --git a/modules/pdp_o.c b/modules/pdp_o.c index 34b2b18..ee5e084 100644 --- a/modules/pdp_o.c +++ b/modules/pdp_o.c @@ -569,7 +569,7 @@ extern "C" void pdp_o_setup(void) { - post( pdp_o_version ); + // post( pdp_o_version ); pdp_o_class = class_new(gensym("pdp_o"), (t_newmethod)pdp_o_new, (t_method)pdp_o_free, sizeof(t_pdp_o), 0, A_NULL); @@ -581,6 +581,7 @@ void pdp_o_setup(void) class_addmethod(pdp_o_class, (t_method)pdp_o_refresh, gensym("refresh"), A_NULL); class_addmethod(pdp_o_class, (t_method)pdp_o_framerate, gensym("framerate"), A_FLOAT, A_NULL); class_addmethod(pdp_o_class, (t_method)pdp_o_smoothing, gensym("smoothing"), A_FLOAT, A_NULL); + class_sethelpsymbol( pdp_o_class, gensym("pdp_o.pd") ); } diff --git a/modules/pdp_puzzle.c b/modules/pdp_puzzle.c index 0c0520f..f9fad2d 100644 --- a/modules/pdp_puzzle.c +++ b/modules/pdp_puzzle.c @@ -413,6 +413,7 @@ void pdp_puzzle_setup(void) class_addmethod(pdp_puzzle_class, (t_method)pdp_puzzle_left, gensym("left"), A_NULL); class_addmethod(pdp_puzzle_class, (t_method)pdp_puzzle_right, gensym("right"), A_NULL); class_addmethod(pdp_puzzle_class, (t_method)pdp_puzzle_nbblocks, gensym("nbblocks"), A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_puzzle_class, gensym("pdp_puzzle.pd") ); } diff --git a/modules/pdp_quark.c b/modules/pdp_quark.c index 4942ce4..8a59e9e 100644 --- a/modules/pdp_quark.c +++ b/modules/pdp_quark.c @@ -260,6 +260,7 @@ void pdp_quark_setup(void) class_addmethod(pdp_quark_class, (t_method)pdp_quark_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_quark_class, (t_method)pdp_quark_planes, gensym("planes"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_quark_class, (t_method)pdp_quark_tolerance, gensym("tolerance"), A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_quark_class, gensym("pdp_quark.pd") ); } diff --git a/modules/pdp_radioactiv.c b/modules/pdp_radioactiv.c index c39dd4b..cab733a 100644 --- a/modules/pdp_radioactiv.c +++ b/modules/pdp_radioactiv.c @@ -508,6 +508,7 @@ void pdp_radioactiv_setup(void) class_addmethod(pdp_radioactiv_class, (t_method)pdp_radioactiv_mode, gensym("mode"), A_FLOAT, A_NULL); class_addmethod(pdp_radioactiv_class, (t_method)pdp_radioactiv_snap_time, gensym("snaptime"), A_FLOAT, A_NULL); class_addmethod(pdp_radioactiv_class, (t_method)pdp_radioactiv_snap_interval, gensym("snapinterval"), A_FLOAT, A_NULL); + class_sethelpsymbol( pdp_radioactiv_class, gensym("pdp_radioactiv.pd") ); } diff --git a/modules/pdp_rec~.c b/modules/pdp_rec~.c index 7f879d0..2a0d68e 100644 --- a/modules/pdp_rec~.c +++ b/modules/pdp_rec~.c @@ -682,7 +682,7 @@ extern "C" void pdp_rec_tilde_setup(void) { - post( pdp_rec_version ); + // post( pdp_rec_version ); pdp_rec_class = class_new(gensym("pdp_rec~"), (t_newmethod)pdp_rec_new, (t_method)pdp_rec_free, sizeof(t_pdp_rec), 0, A_NULL); @@ -697,6 +697,7 @@ void pdp_rec_tilde_setup(void) class_addmethod(pdp_rec_class, (t_method)pdp_rec_jpeg, gensym("jpeg"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_rec_class, (t_method)pdp_rec_start, gensym("start"), A_NULL); class_addmethod(pdp_rec_class, (t_method)pdp_rec_stop, gensym("stop"), A_NULL); + class_sethelpsymbol( pdp_rec_class, gensym("pdp_rec~.pd") ); } diff --git a/modules/pdp_rev.c b/modules/pdp_rev.c index 58f5753..1834447 100644 --- a/modules/pdp_rev.c +++ b/modules/pdp_rev.c @@ -253,6 +253,7 @@ void pdp_rev_setup(void) class_addmethod(pdp_rev_class, (t_method)pdp_rev_linespace, gensym("linespace"), A_FLOAT, A_NULL); class_addmethod(pdp_rev_class, (t_method)pdp_rev_vscale, gensym("vscale"), A_FLOAT, A_NULL); class_addmethod(pdp_rev_class, (t_method)pdp_rev_color, gensym("color"), A_FLOAT, A_NULL); + class_sethelpsymbol( pdp_rev_class, gensym("pdp_rev.pd") ); } diff --git a/modules/pdp_ripple.c b/modules/pdp_ripple.c index 4f54b30..ab7209b 100644 --- a/modules/pdp_ripple.c +++ b/modules/pdp_ripple.c @@ -559,6 +559,7 @@ void pdp_ripple_setup(void) class_addmethod(pdp_ripple_class, (t_method)pdp_ripple_background, gensym("background"), A_NULL); class_addmethod(pdp_ripple_class, (t_method)pdp_ripple_threshold, gensym("threshold"), A_FLOAT, A_NULL); class_addmethod(pdp_ripple_class, (t_method)pdp_ripple_increment, gensym("increment"), A_FLOAT, A_NULL); + class_sethelpsymbol( pdp_ripple_class, gensym("pdp_ripple.pd") ); } diff --git a/modules/pdp_segsnd~.c b/modules/pdp_segsnd~.c index f593af7..4e997f8 100644 --- a/modules/pdp_segsnd~.c +++ b/modules/pdp_segsnd~.c @@ -115,7 +115,7 @@ static void pdp_segsnd_allocate(t_pdp_segsnd *x) static void pdp_segsnd_free_ressources(t_pdp_segsnd *x) { - if ( x->x_image != NULL ) imlib_free_image(); + // if ( x->x_image != NULL ) imlib_free_image(); x->x_image = NULL; if ( x->x_data ) freebytes( x->x_data, (( x->x_vsize + (x->x_vsize>>1))<<1)); x->x_data = NULL; @@ -151,6 +151,7 @@ static void pdp_segsnd_process_yv12(t_pdp_segsnd *x) memcpy( newdata, data, (x->x_vsize+(x->x_vsize>>1))<<1 ); memcpy( x->x_data, data, ((x->x_vsize+(x->x_vsize>>1))<<1)); + if ( x->x_image != NULL ) imlib_context_set_image(x->x_image); imlib_image_clear(); imlib_context_set_direction(IMLIB_TEXT_TO_ANGLE); imdata = imlib_image_get_data(); @@ -392,7 +393,7 @@ extern "C" void pdp_segsnd_tilde_setup(void) { - post( pdp_segsnd_version ); + // post( pdp_segsnd_version ); pdp_segsnd_class = class_new(gensym("pdp_segsnd~"), (t_newmethod)pdp_segsnd_new, (t_method)pdp_segsnd_free, sizeof(t_pdp_segsnd), 0, A_NULL); @@ -404,6 +405,7 @@ void pdp_segsnd_tilde_setup(void) class_addmethod(pdp_segsnd_class, (t_method)pdp_segsnd_x2, gensym("x2"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_segsnd_class, (t_method)pdp_segsnd_y2, gensym("y2"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_segsnd_class, (t_method)pdp_segsnd_random, gensym("random"), A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_segsnd_class, gensym("pdp_segsnd~.pd") ); } diff --git a/modules/pdp_shagadelic.c b/modules/pdp_shagadelic.c index dd24e03..a40bf62 100644 --- a/modules/pdp_shagadelic.c +++ b/modules/pdp_shagadelic.c @@ -299,6 +299,7 @@ void pdp_shagadelic_setup(void) class_addmethod(pdp_shagadelic_class, (t_method)pdp_shagadelic_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_shagadelic_class, (t_method)pdp_shagadelic_mask, gensym("mask"), A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_shagadelic_class, gensym("pdp_shagadelic.pd") ); } diff --git a/modules/pdp_simura.c b/modules/pdp_simura.c index 04fd74b..87a471c 100644 --- a/modules/pdp_simura.c +++ b/modules/pdp_simura.c @@ -435,6 +435,7 @@ void pdp_simura_setup(void) class_addmethod(pdp_simura_class, (t_method)pdp_simura_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_simura_class, (t_method)pdp_simura_color, gensym("color"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_simura_class, (t_method)pdp_simura_mode, gensym("mode"), A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_simura_class, gensym("pdp_simura.pd") ); } diff --git a/modules/pdp_smuck.c b/modules/pdp_smuck.c index 968bea4..4737c9f 100644 --- a/modules/pdp_smuck.c +++ b/modules/pdp_smuck.c @@ -220,6 +220,7 @@ void pdp_smuck_setup(void) class_addmethod(pdp_smuck_class, (t_method)pdp_smuck_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_smuck_class, (t_method)pdp_smuck_n, gensym("n"), A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_smuck_class, gensym("pdp_smuck.pd") ); } diff --git a/modules/pdp_spigot.c b/modules/pdp_spigot.c index 3b79bb1..c25859c 100644 --- a/modules/pdp_spigot.c +++ b/modules/pdp_spigot.c @@ -160,6 +160,7 @@ void pdp_spigot_setup(void) class_addmethod(pdp_spigot_class, (t_method)pdp_spigot_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_spigot_class, (t_method)pdp_spigot_toggle, gensym("toggle"), A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_spigot_class, gensym("pdp_spigot.pd") ); } diff --git a/modules/pdp_spiral.c b/modules/pdp_spiral.c index a97442b..a2430b9 100644 --- a/modules/pdp_spiral.c +++ b/modules/pdp_spiral.c @@ -511,6 +511,7 @@ void pdp_spiral_setup(void) class_addmethod(pdp_spiral_class, (t_method)pdp_spiral_depth_shift, gensym("focus_increment"), A_FLOAT, A_NULL); class_addmethod(pdp_spiral_class, (t_method)pdp_spiral_depth_shift, gensym("toggle_xor"), A_FLOAT, A_NULL); class_addmethod(pdp_spiral_class, (t_method)pdp_spiral_depth_shift, gensym("animate_focus"), A_FLOAT, A_NULL); + class_sethelpsymbol( pdp_spiral_class, gensym("pdp_spiral.pd") ); } diff --git a/modules/pdp_text.c b/modules/pdp_text.c index 81bd83f..41ddf6c 100644 --- a/modules/pdp_text.c +++ b/modules/pdp_text.c @@ -387,7 +387,7 @@ static void pdp_text_allocate(t_pdp_text *x) static void pdp_text_free_ressources(t_pdp_text *x) { - if ( x->x_image != NULL ) imlib_free_image(); + // if ( x->x_image != NULL ) imlib_free_image(); } static void pdp_text_process_yv12(t_pdp_text *x) @@ -421,6 +421,7 @@ static void pdp_text_process_yv12(t_pdp_text *x) memcpy( newdata, data, (x->x_vsize+(x->x_vsize>>1))<<1 ); // draw all texts + if ( x->x_image != NULL ) imlib_context_set_image(x->x_image); imlib_image_clear(); imlib_context_set_direction(IMLIB_TEXT_TO_ANGLE); imdata = imlib_image_get_data(); @@ -593,7 +594,7 @@ void pdp_text_setup(void) { Imlib_Font font; - post( pdp_text_version ); + // post( pdp_text_version ); pdp_text_class = class_new(gensym("pdp_text"), (t_newmethod)pdp_text_new, (t_method)pdp_text_free, sizeof(t_pdp_text), 0, A_NULL); @@ -615,6 +616,7 @@ void pdp_text_setup(void) class_addmethod(pdp_text_class, (t_method)pdp_text_dither, gensym("dither"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_text_class, (t_method)pdp_text_blend, gensym("blend"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_text_class, (t_method)pdp_text_antialias, gensym("antialias"), A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_text_class, gensym("pdp_text.pd") ); imlib_add_path_to_font_path("/usr/X11R6/lib/X11/fonts/TTF"); font = imlib_load_font(DEFAULT_FONT); diff --git a/modules/pdp_transform.c b/modules/pdp_transform.c index b69f778..ccde3a4 100644 --- a/modules/pdp_transform.c +++ b/modules/pdp_transform.c @@ -349,6 +349,7 @@ void pdp_transform_setup(void) class_addmethod(pdp_transform_class, (t_method)pdp_transform_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_transform_class, (t_method)pdp_transform_table, gensym("table"), A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_transform_class, gensym("pdp_transform.pd") ); } diff --git a/modules/pdp_transition.c b/modules/pdp_transition.c index d186aa0..4894c6a 100644 --- a/modules/pdp_transition.c +++ b/modules/pdp_transition.c @@ -19,7 +19,7 @@ */ /* This object is an object allowing transitions between two video sources - * "circle", "wipe", "random", "melt" and "blend" + * "circle", "wipe", "random", "melt", "page" and "blend" * Written by Yves Degoyon */ @@ -27,6 +27,7 @@ #include <math.h> #define BLEND_MAX 200 +#define PAGE_RAY 50 static char *pdp_transition_version = "pdp_transition: version 0.1, two sources transition, written by Yves Degoyon (ydegoyon@free.fr)"; @@ -240,6 +241,22 @@ static void pdp_transition_blend(t_pdp_transition *x, t_floatarg finc, t_floatar x->x_pos = 0; } +static void pdp_transition_page(t_pdp_transition *x, t_floatarg finc ) +{ + if ( x->x_transition_pending ) + { + post ( "pdp_transition : a transition is already pending, retry later...." ); + return; + } + if ( (int) finc > 0 ) + { + x->x_inc = (int)finc; + } + x->x_transition_mode = 10; + x->x_transition_pending = 1; + x->x_pos = x->x_vheight; +} + static void pdp_transition_process_yv12(t_pdp_transition *x) { t_pdp *header0 = pdp_packet_header(x->x_packet0); @@ -249,8 +266,8 @@ static void pdp_transition_process_yv12(t_pdp_transition *x) t_pdp *header; short int *data; t_int tsource, cx=0, cy=0; - t_int px, py, rvalue=0; - t_float factor; + t_int px, py, rvalue=0, h1pos, h2pos, xcent, ycent; + t_float factor, alpha; int i; short int *poY, *poV, *poU, *p0Y, *p0V, *p0U, *p1Y, *p1V, *p1U; @@ -595,6 +612,64 @@ static void pdp_transition_process_yv12(t_pdp_transition *x) x->x_pos += x->x_inc; break; + case 10: // page + xcent = (int) ( (float) ( x->x_vheight - x->x_pos ) * (( float ) x->x_vwidth ) / + ( 2.0 * ( (float) x->x_vheight ) ) ); + ycent = (int) ( ( (float) x->x_pos + (float) x->x_vheight ) / 2.0 ); + for ( px=0; px<x->x_vwidth; px++ ) + { + for ( py=0; py<x->x_vheight; py++ ) + { + if ( ( ((float) py)- + ((float)x->x_vheight)/((float)x->x_vwidth)*((float)px) ) >= x->x_pos ) + { + *(poY+py*x->x_vwidth+px) = *(p1Y+py*x->x_vwidth1+px); + *(poU+(py>>1)*(x->x_vwidth>>1)+(px>>1)) = + *(p1U+(py>>1)*(x->x_vwidth1>>1)+(px>>1)); + *(poV+(py>>1)*(x->x_vwidth>>1)+(px>>1)) = + *(p1V+(py>>1)*(x->x_vwidth1>>1)+(px>>1)); + } + else + { + h1pos = ((float) py) + ((float)x->x_vheight)/((float)x->x_vwidth)*((float)px); + h2pos = ((float) py) - ((float)x->x_vheight)/((float)x->x_vwidth)*((float)px); + alpha = atan( ( (float) x->x_vheight ) / ( (float) x->x_vwidth ) ); + if ( ( h1pos <= x->x_vheight ) && + ( h1pos >= ( (float) x->x_vheight - PAGE_RAY*cos(alpha) ) ) && + ( h2pos >= ( x->x_pos - PAGE_RAY*sin(alpha) ) ) && + ( pow ( px-xcent, 2 ) + pow ( py-(ycent-PAGE_RAY), 2 ) + >= pow( PAGE_RAY*cos(alpha), 2 ) ) ) + { + *(poY+py*x->x_vwidth+px) = 0xff<<7; + *(poU+(py>>1)*(x->x_vwidth>>1)+(px>>1)) = 0xff<<8; + *(poV+(py>>1)*(x->x_vwidth>>1)+(px>>1)) = 0xff<<8; + } + if ( ( h1pos >= x->x_vheight ) && + ( h1pos <= ( (float) x->x_vheight + PAGE_RAY*cos(alpha) ) ) && + ( h2pos >= ( x->x_pos - PAGE_RAY*sin(alpha) ) ) && + ( pow ( px-(xcent+PAGE_RAY), 2 ) + pow ( py-ycent, 2 ) + >= pow( PAGE_RAY*sin(alpha), 2 ) ) ) + { + *(poY+py*x->x_vwidth+px) = 0xff<<7; + *(poU+(py>>1)*(x->x_vwidth>>1)+(px>>1)) = 0xff<<8; + *(poV+(py>>1)*(x->x_vwidth>>1)+(px>>1)) = 0xff<<8; + } + } + } + } + if ( x->x_pos <= -x->x_vheight ) + { + post( "pdp_transition : page transition finished" ); + x->x_transition_pending = 0; + x->x_transition_mode = 0; + tsource = x->x_current_source; + x->x_current_source = x->x_target_source; + x->x_target_source = tsource; + x->x_pos = 0; + } + x->x_pos -= x->x_inc; + break; + default: break; } @@ -763,7 +838,7 @@ extern "C" void pdp_transition_setup(void) { - post( pdp_transition_version ); + // post( pdp_transition_version ); pdp_transition_class = class_new(gensym("pdp_transition"), (t_newmethod)pdp_transition_new, (t_method)pdp_transition_free, sizeof(t_pdp_transition), 0, A_NULL); @@ -778,6 +853,8 @@ void pdp_transition_setup(void) class_addmethod(pdp_transition_class, (t_method)pdp_transition_random, gensym("random"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_transition_class, (t_method)pdp_transition_melt, gensym("melt"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_transition_class, (t_method)pdp_transition_blend, gensym("blend"), A_DEFFLOAT, A_DEFFLOAT, A_NULL); + class_addmethod(pdp_transition_class, (t_method)pdp_transition_page, gensym("page"), A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_transition_class, gensym("pdp_transition.pd") ); } diff --git a/modules/pdp_underwatch.c b/modules/pdp_underwatch.c index 887be29..674582f 100644 --- a/modules/pdp_underwatch.c +++ b/modules/pdp_underwatch.c @@ -236,6 +236,7 @@ void pdp_underwatch_setup(void) class_addmethod(pdp_underwatch_class, (t_method)pdp_underwatch_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_underwatch_class, (t_method)pdp_underwatch_stripsize, gensym("stripsize"), A_FLOAT, A_NULL); + class_sethelpsymbol( pdp_underwatch_class, gensym("pdp_underwatch.pd") ); } diff --git a/modules/pdp_vertigo.c b/modules/pdp_vertigo.c index b6f4e37..ce5295a 100644 --- a/modules/pdp_vertigo.c +++ b/modules/pdp_vertigo.c @@ -341,6 +341,7 @@ void pdp_vertigo_setup(void) class_addmethod(pdp_vertigo_class, (t_method)pdp_vertigo_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_vertigo_class, (t_method)pdp_vertigo_increment, gensym("increment"), A_FLOAT, A_NULL); class_addmethod(pdp_vertigo_class, (t_method)pdp_vertigo_zoomrate, gensym("zoomrate"), A_FLOAT, A_NULL); + class_sethelpsymbol( pdp_vertigo_class, gensym("pdp_vertigo.pd") ); } diff --git a/modules/pdp_warhol.c b/modules/pdp_warhol.c index 8d12f2b..508f659 100644 --- a/modules/pdp_warhol.c +++ b/modules/pdp_warhol.c @@ -277,6 +277,7 @@ void pdp_warhol_setup(void) class_addmethod(pdp_warhol_class, (t_method)pdp_warhol_y, gensym("Y"), A_FLOAT, A_NULL); class_addmethod(pdp_warhol_class, (t_method)pdp_warhol_u, gensym("U"), A_FLOAT, A_NULL); class_addmethod(pdp_warhol_class, (t_method)pdp_warhol_v, gensym("V"), A_FLOAT, A_NULL); + class_sethelpsymbol( pdp_warhol_class, gensym("pdp_warhol.pd") ); } diff --git a/modules/pdp_warp.c b/modules/pdp_warp.c index e3b4311..b179580 100644 --- a/modules/pdp_warp.c +++ b/modules/pdp_warp.c @@ -344,6 +344,7 @@ void pdp_warp_setup(void) class_addmethod(pdp_warp_class, (t_method)pdp_warp_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_warp_class, (t_method)pdp_warp_mode, gensym("mode"), A_FLOAT, A_NULL); class_addmethod(pdp_warp_class, (t_method)pdp_warp_tval, gensym("tval"), A_FLOAT, A_NULL); + class_sethelpsymbol( pdp_warp_class, gensym("pdp_warp.pd") ); } diff --git a/modules/pdp_yqt.c b/modules/pdp_yqt.c index 5f0ebbe..d91ac8e 100644 --- a/modules/pdp_yqt.c +++ b/modules/pdp_yqt.c @@ -436,6 +436,7 @@ void pdp_yqt_setup(void) class_addmethod(pdp_yqt_class, (t_method)pdp_yqt_gain, gensym("gain"), A_FLOAT, A_NULL); class_addmethod(pdp_yqt_class, nullfn, gensym("signal"), 0); class_addmethod(pdp_yqt_class, (t_method)pdp_yqt_dsp, gensym("dsp"), 0); + class_sethelpsymbol( pdp_yqt_class, gensym("pdp_yqt.pd") ); } diff --git a/modules/pdp_yvu2rgb.c b/modules/pdp_yvu2rgb.c index ba22d8b..2a9156c 100644 --- a/modules/pdp_yvu2rgb.c +++ b/modules/pdp_yvu2rgb.c @@ -177,6 +177,7 @@ void pdp_yvu2rgb_setup(void) (t_method)pdp_yvu2rgb_free, sizeof(t_pdp_yvu2rgb), 0, A_NULL); class_addmethod(pdp_yvu2rgb_class, (t_method)pdp_yvu2rgb_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); + class_sethelpsymbol( pdp_yvu2rgb_class, gensym("pdp_yvu2rgb.pd") ); } diff --git a/system/pidip.c b/system/pidip.c index 152313d..23f3b21 100644 --- a/system/pidip.c +++ b/system/pidip.c @@ -55,6 +55,7 @@ extern "C" void pdp_transition_setup(void); void pdp_imgloader_setup(void); void pdp_imgsaver_setup(void); + void pdp_cache_setup(void); /* library setup routine */ @@ -108,6 +109,7 @@ void pidip_setup(void){ pdp_transition_setup(); pdp_imgloader_setup(); pdp_imgsaver_setup(); + pdp_cache_setup(); } |