From a8e7bc2c20f3d404ebc039f573843d8801c30eaa Mon Sep 17 00:00:00 2001 From: Georg Holzmann Date: Fri, 17 Jun 2005 13:45:22 +0000 Subject: added pix_2pdp svn path=/trunk/externals/gem2pdp/; revision=3202 --- help-pix_2pdp.pd | 76 +++++++++++++++++++++++++++++++++++++++ pix_2pdp.cpp | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ pix_2pdp.h | 56 +++++++++++++++++++++++++++++ 3 files changed, 238 insertions(+) create mode 100755 help-pix_2pdp.pd create mode 100755 pix_2pdp.cpp create mode 100755 pix_2pdp.h diff --git a/help-pix_2pdp.pd b/help-pix_2pdp.pd new file mode 100755 index 0000000..3ad42b5 --- /dev/null +++ b/help-pix_2pdp.pd @@ -0,0 +1,76 @@ +#N canvas 140 53 889 703 10; +#X obj 92 298 gemwin; +#X obj 338 264 gemhead; +#X obj 151 557 pix_texture; +#X obj 151 589 rectangle 4 4; +#X obj 501 531 pdp_xv; +#X msg 546 478 create; +#X msg 546 502 destroy; +#X obj 338 398 pix_2pdp; +#X obj 338 341 t a b; +#X obj 338 307 pix_film; +#X floatatom 405 293 5 0 1000 0 - - -; +#X msg 405 237 set open \$1; +#X text 446 293 <- frame; +#X obj 405 214 openpanel; +#X obj 405 194 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X msg 405 262 open /home/Georg/pd-cvs/gem/Gem/examples/data/homer.avi +; +#X msg 92 251 create \, 1; +#X msg 104 273 0 \, destroy; +#X text 90 229 Gem Control:; +#X text 313 223 Gem input:; +#X text 385 341 <- so you can trigger pdp automatically each frame +; +#X text 401 403 pdp outlet; +#X text 261 403 Gem outlet; +#X obj 151 528 spigot; +#X obj 188 508 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 +1; +#X text 210 514 chain to save CPU; +#X obj 368 369 spigot; +#X obj 419 370 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 +1; +#X text 441 370 <- turn on/off pdp processing; +#X text 210 499 cut Gem render-; +#X obj 500 578 pdp_rec~; +#X text 498 598 (record a gem-pix !!!); +#X text 45 321 (Gem rendering must be on \,; +#X text 47 335 but you can cut the Gem; +#X text 48 348 render-chain after pix_2pdp; +#X text 46 362 and hide the Gem-window; +#X text 46 376 to save CPU !); +#X text 264 667 =%)!(%= (c) Georg Holzmann \, 2005 =%)!(%= +; +#X text 27 79 pix_2pdp captures the contents of a Gem pix and transforms +it to a PDP packet with almost no cpu power. So it's possible to convert +from Gem to PDP to Gem to PDP to ... if you use the Gem pix objects! +; +#X text 490 77 So what can you do with it?; +#X text 503 96 - use pix_video/pix_2pdp for firewire input in PDP; +#X text 503 111 - use pix_2pdp/pdp_rec~ to record Gem pixes; +#X text 503 126 - maybe switch between Gem and PDP all the time; +#X text 503 141 - ...; +#X text 395 25 pix_2pdp; +#X connect 1 0 9 0; +#X connect 2 0 3 0; +#X connect 5 0 4 0; +#X connect 6 0 4 0; +#X connect 7 0 23 0; +#X connect 7 1 4 0; +#X connect 7 1 30 0; +#X connect 8 0 7 0; +#X connect 8 1 26 0; +#X connect 9 0 8 0; +#X connect 10 0 9 1; +#X connect 11 0 15 0; +#X connect 13 0 11 0; +#X connect 14 0 13 0; +#X connect 15 0 9 0; +#X connect 16 0 0 0; +#X connect 17 0 0 0; +#X connect 23 0 2 0; +#X connect 24 0 23 1; +#X connect 26 0 7 0; +#X connect 27 0 26 1; diff --git a/pix_2pdp.cpp b/pix_2pdp.cpp new file mode 100755 index 0000000..2fb8903 --- /dev/null +++ b/pix_2pdp.cpp @@ -0,0 +1,106 @@ +/* + * pix_2pdp : pix to pdp bridge + * + * Capture the contents of the Gem pix and transform it to a PDP Packet whenever a bang is received + * + * Based on code of gem2pdp by Yves Degoyon + * Many thanks to IOhannes M Zmölnig + * + * Copyright (c) 2005 Georg Holzmann + * + */ + +#include "pix_2pdp.h" +#include "yuv.h" + +CPPEXTERN_NEW(pix_2pdp) + +pix_2pdp::pix_2pdp(void) +{ + gem_image = NULL; + m_pdpoutlet = outlet_new(this->x_obj, &s_anything); +} + +pix_2pdp::~pix_2pdp() +{ + gem_image = NULL; + gem_xsize = 0; + gem_ysize = 0; + gem_csize = 0; +} + +// Image processing +void pix_2pdp::processImage(imageStruct &image) +{ + gem_image = image.data; + gem_xsize = image.xsize; + gem_ysize = image.ysize; + gem_csize = image.csize; + gem_format = image.format; +} + +// pdp processing +void pix_2pdp::bangMess() +{ + t_int psize, px, py; + short int *pY, *pU, *pV; + unsigned char r,g,b; + t_int helper; + + if(gem_image) + { + if(gem_format == GL_RGBA) + { + // make pdp packet + psize = gem_xsize * gem_ysize; + m_packet0 = pdp_packet_new_image_YCrCb( gem_xsize, gem_ysize); + m_header = pdp_packet_header(m_packet0); + m_data = (short int *)pdp_packet_data(m_packet0); + + pY = m_data; + pV = m_data+psize; + pU = m_data+psize+(psize>>2); + + for ( py=0; py" ); + class_addmethod(classPtr, (t_method)&pix_2pdp::bangMessCallback, + gensym("bang"), A_NULL); +} + +void pix_2pdp::bangMessCallback(void *data) +{ + GetMyClass(data)->bangMess(); +} diff --git a/pix_2pdp.h b/pix_2pdp.h new file mode 100755 index 0000000..64229d6 --- /dev/null +++ b/pix_2pdp.h @@ -0,0 +1,56 @@ +/* + * pix_2pdp : pix to pdp bridge + * + * Capture the contents of the Gem pix and transform it to a PDP Packet whenever a bang is received + * + * Based on code of gem2pdp by Yves Degoyon + * Many thanks to IOhannes M Zmölnig + * + * Copyright (c) 2005 Georg Holzmann + * + */ + +#ifndef INCLUDE_PIX2PDP_H_ +#define INCLUDE_PIX2PDP_H_ + +#include "Base/GemPixObj.h" +#include "pdp-light.h" + +class GEM_EXTERN pix_2pdp : public GemPixObj +{ + CPPEXTERN_HEADER(pix_2pdp, GemPixObj) + + public: + + // Constructor + pix_2pdp(void); + + protected: + + // Destructor + virtual ~pix_2pdp(void); + + // Image processing + virtual void processImage(imageStruct &image); + + // pdp processing + virtual void bangMess(void); + + // the pixBlock with the current image + unsigned char *gem_image; + int gem_xsize; + int gem_ysize; + int gem_csize; + int gem_format; + + // pdp data + t_outlet *m_pdpoutlet; + int m_packet0; + t_pdp *m_header; + short int *m_data; + + private: + static void bangMessCallback(void *data); +}; + +#endif -- cgit v1.2.1