[GEM-cvs] Gem/src/Pixes pix_buffer_read.cpp,1.3,1.4
Brought to you by:
zmoelnig
From: IOhannes m z. <zmo...@us...> - 2005-08-25 16:55:41
|
Update of /cvsroot/pd-gem/Gem/src/Pixes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31597 Modified Files: pix_buffer_read.cpp Log Message: further performance improvements (without crashes) Index: pix_buffer_read.cpp =================================================================== RCS file: /cvsroot/pd-gem/Gem/src/Pixes/pix_buffer_read.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pix_buffer_read.cpp 24 Aug 2005 13:20:37 -0000 1.3 --- pix_buffer_read.cpp 25 Aug 2005 16:55:34 -0000 1.4 *************** *** 44,53 **** pix_buffer_read :: pix_buffer_read(t_symbol *s) : m_frame(0.f), m_auto(0.f), m_loop(0), m_bindname(NULL), ! m_buffer(NULL), m_haveImage(false) { setMess(s); inlet_new(this->x_obj, &this->x_obj->ob_pd, gensym("float"), gensym("frame")); } ! //////////////////////////////////////////////////////// // Destructor // --- 44,53 ---- pix_buffer_read :: pix_buffer_read(t_symbol *s) : m_frame(0.f), m_auto(0.f), m_loop(0), m_bindname(NULL), ! m_haveImage(false) { setMess(s); inlet_new(this->x_obj, &this->x_obj->ob_pd, gensym("float"), gensym("frame")); } ! ///////////////////////////////////////////////////////// // Destructor // *************** *** 57,64 **** } ! //////////////////////////////////////////////////////// // setMess // ! //////////////////////////////////////////////////////// void pix_buffer_read :: setMess(t_symbol*s){ if (s!=&s_){ --- 57,64 ---- } ! ///////////////////////////////////////////////////////// // setMess // ! ///////////////////////////////////////////////////////// void pix_buffer_read :: setMess(t_symbol*s){ if (s!=&s_){ *************** *** 67,74 **** update_image(); } ! /////////////////////////////////////////////////////// // frameMess // ! /////////////////////////////////////////////////////// void pix_buffer_read :: frameMess(t_float f){ if (f<0.){ --- 67,74 ---- update_image(); } ! ///////////////////////////////////////////////////////// // frameMess // ! ///////////////////////////////////////////////////////// void pix_buffer_read :: frameMess(t_float f){ if (f<0.){ *************** *** 78,86 **** update_image(); } ! //////////////////////////////////////////////////////// // autoMess // specify an incrementor to proceed to the next image // ! //////////////////////////////////////////////////////// void pix_buffer_read :: autoMess(t_float f){ m_auto=f; --- 78,86 ---- update_image(); } ! ///////////////////////////////////////////////////////// // autoMess // specify an incrementor to proceed to the next image // ! ///////////////////////////////////////////////////////// void pix_buffer_read :: autoMess(t_float f){ m_auto=f; *************** *** 96,138 **** ///////////////////////////////////////////////////////// ! // update current pix_buffer ///////////////////////////////////////////////////////// ! void pix_buffer_read :: update_pix_buffer() { if(m_bindname==NULL || m_bindname->s_name==NULL) { post("pix_buffer_read: you must set a buffer name!"); - m_buffer = NULL; return; } ! Obj_header*ohead=(Obj_header*)pd_findbyclass(m_bindname, pix_buffer_class); if(ohead==NULL) { post("pix_buffer_read: couldn't find pix_buffer '%s'", m_bindname->s_name); - m_buffer = NULL; return; } ! m_buffer=(pix_buffer *)(ohead)->data; ! } ! ! ///////////////////////////////////////////////////////// ! // update current image ! ///////////////////////////////////////////////////////// ! void pix_buffer_read :: update_image() ! { ! update_pix_buffer(); ! m_haveImage=false; ! if (!m_buffer) return; - imageStruct *img=NULL; if(m_loop) { ! int numFrames=m_buffer->numFrames(); m_frame=fmod(m_frame, numFrames); if(m_frame<0.f)m_frame+=numFrames; } ! img=m_buffer->getMess((int)m_frame); if (img && img->data) --- 96,133 ---- ///////////////////////////////////////////////////////// ! // update current image ///////////////////////////////////////////////////////// ! void pix_buffer_read :: update_image() { + imageStruct *img=NULL; + Obj_header*ohead=NULL; + pix_buffer *buffer=NULL; + + m_haveImage=false; + if(m_bindname==NULL || m_bindname->s_name==NULL) { post("pix_buffer_read: you must set a buffer name!"); return; } ! ohead=(Obj_header*)pd_findbyclass(m_bindname, pix_buffer_class); if(ohead==NULL) { post("pix_buffer_read: couldn't find pix_buffer '%s'", m_bindname->s_name); return; } ! buffer=(pix_buffer *)(ohead)->data; ! if (!buffer) return; if(m_loop) { ! int numFrames=buffer->numFrames(); m_frame=fmod(m_frame, numFrames); if(m_frame<0.f)m_frame+=numFrames; } ! ! img=buffer->getMess((int)m_frame); if (img && img->data) *************** *** 151,165 **** { // if we don't have an image, just return ! if (!m_haveImage || !m_buffer) return; ! // make sure, that the pix_buffer still exists ?? ! update_pix_buffer(); ! if (!m_haveImage || !m_buffer) return; - /* push the incoming state->image into a temporary memory */ orgPixBlock = state->image; ! /* the new image */ state->image = &m_pixBlock; } --- 146,164 ---- { // if we don't have an image, just return ! if (!m_haveImage) return; /* push the incoming state->image into a temporary memory */ orgPixBlock = state->image; ! /* ! pd_findbyclass costs at least 2 if's ! if m_bindname is also used for other classes too, we get an ! additional penalty for traversing the list of classes; ! all in all, msp has done a good job ! */ ! if (NULL==pd_findbyclass(m_bindname, pix_buffer_class)) return; ! state->image = &m_pixBlock; + } *************** *** 169,179 **** void pix_buffer_read :: postrender(GemState *state) { // auto-mode logic: ! if(m_auto!=0.f) { m_frame+=m_auto; update_image(); ! } else ! m_pixBlock.newimage = 0; /* restore the original incoming image */ --- 168,179 ---- void pix_buffer_read :: postrender(GemState *state) { + m_pixBlock.newimage = 0; + // auto-mode logic: ! if(m_auto > 0.00001 || m_auto < -0.00001) { m_frame+=m_auto; update_image(); ! } /* restore the original incoming image */ |