Update of /cvsroot/pure-data/externals/gem2pdp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1867
Modified Files: pdp2gem.cpp Log Message: forgot pthread_mutex_lock() (oops), tightened screws (cleanup), some comments
Index: pdp2gem.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/gem2pdp/pdp2gem.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pdp2gem.cpp 12 Apr 2005 16:43:13 -0000 1.4 --- pdp2gem.cpp 14 Apr 2005 16:03:28 -0000 1.5 *************** *** 16,20 **** --- 16,23 ----
pdp2gem :: pdp2gem(t_symbol *colorspace) + : m_colorspace(GL_YUV422_GEM) { + // csMess allows us to select what colorspace to convert + // the YV12 pixels into while handing it over to GEM csMess(colorspace->s_name);
*************** *** 32,36 **** }else if ( m_colorspace == GL_YUV422_GEM ){ m_pixBlock.image.csize = 2; ! m_pixBlock.image.format = GL_YCBCR_422_GEM; #ifdef __APPLE__ m_pixBlock.image.type = GL_UNSIGNED_SHORT_8_8_REV_APPLE; --- 35,39 ---- }else if ( m_colorspace == GL_YUV422_GEM ){ m_pixBlock.image.csize = 2; ! m_pixBlock.image.format = GL_YUV422_GEM; #ifdef __APPLE__ m_pixBlock.image.type = GL_UNSIGNED_SHORT_8_8_REV_APPLE; *************** *** 148,152 **** { if (pdp_packet_header(m_packet0)->info.image.encoding == PDP_IMAGE_YV12 ! && (m_colorspace == GL_RGB || m_colorspace == GL_BGR_EXT) ) { if ( ( m_xsize != (int)m_header->info.image.width ) || --- 151,155 ---- { if (pdp_packet_header(m_packet0)->info.image.encoding == PDP_IMAGE_YV12 ! && (m_colorspace == GL_RGB || m_colorspace == GL_BGR_EXT) ) { if ( ( m_xsize != (int)m_header->info.image.width ) || *************** *** 158,198 **** } m_pdpdata = (short int *)pdp_packet_data(m_packet0); - #if 0 - psize = m_xsize*m_ysize; - pY = m_pdpdata; - pV = m_pdpdata+psize; - pU = m_pdpdata+psize+(psize>>2); - - // lock mutex - pthread_mutex_lock(m_mutex);
! // copy image data ! for ( py=0; py<m_ysize; py++) ! { ! for ( px=0; px<m_xsize; px++) ! { ! cpt=((m_ysize-py)*m_xsize+px)*3; ! y = *(pY)>>7; ! v = (*(pV)>>8)+128; ! u = (*(pU)>>8)+128; ! #ifdef __APPLE__ ! m_data[cpt++] = yuv_YUVtoB( y, u, v ); ! m_data[cpt++] = yuv_YUVtoG( y, u, v ); ! m_data[cpt] = yuv_YUVtoR( y, u, v ); ! #else ! m_data[cpt++] = yuv_YUVtoR( y, u, v ); ! m_data[cpt++] = yuv_YUVtoG( y, u, v ); ! m_data[cpt] = yuv_YUVtoB( y, u, v ); ! #endif ! pY++; ! if ( (px%2==0) && (py%2==0) ) ! { ! pV++; pU++; ! } ! } ! } ! #else m_pixBlock.image.fromYV12(m_pdpdata); ! #endif // unlock mutex pthread_mutex_unlock(m_mutex); --- 161,171 ---- } m_pdpdata = (short int *)pdp_packet_data(m_packet0);
! // lock mutex ! pthread_mutex_lock(m_mutex); ! ! // convert pixels from yv12 to RGB/BGR m_pixBlock.image.fromYV12(m_pdpdata); ! // unlock mutex pthread_mutex_unlock(m_mutex); *************** *** 201,207 **** pdp_packet_mark_unused(m_packet0); m_packet0 = -1; ! } else if (pdp_packet_header(m_packet0)->info.image.encoding == PDP_IMAGE_YV12 ! && (m_colorspace == GL_RGBA || m_colorspace == GL_BGRA_EXT) ) ! { if ( ( m_xsize != (int)m_header->info.image.width ) || ( m_ysize != (int)m_header->info.image.height ) ) --- 174,181 ---- pdp_packet_mark_unused(m_packet0); m_packet0 = -1; ! ! } else if (pdp_packet_header(m_packet0)->info.image.encoding == PDP_IMAGE_YV12 ! && (m_colorspace == GL_RGBA || m_colorspace == GL_BGRA_EXT) ) ! { if ( ( m_xsize != (int)m_header->info.image.width ) || ( m_ysize != (int)m_header->info.image.height ) ) *************** *** 212,246 **** } m_pdpdata = (short int *)pdp_packet_data(m_packet0); - #if 0 - psize = m_xsize*m_ysize; - pY = m_pdpdata; - pV = m_pdpdata+psize; - pU = m_pdpdata+psize+(psize>>2);
// lock mutex pthread_mutex_lock(m_mutex); ! ! // copy image data ! for ( py=0; py<m_ysize; py++) ! { ! for ( px=0; px<m_xsize; px++) ! { ! cpt=((m_ysize-py)*m_xsize+px)*4; ! y = *(pY)>>7; ! v = (*(pV)>>8)+128; ! u = (*(pU)>>8)+128; ! m_data[cpt++] = yuv_YUVtoR( y, u, v ); ! m_data[cpt++] = yuv_YUVtoG( y, u, v ); ! m_data[cpt] = yuv_YUVtoB( y, u, v ); ! pY++; ! if ( (px%2==0) && (py%2==0) ) ! { ! pV++; pU++; ! } ! } ! } ! #else m_pixBlock.image.fromYV12(m_pdpdata); ! #endif // unlock mutex pthread_mutex_unlock(m_mutex); --- 186,196 ---- } m_pdpdata = (short int *)pdp_packet_data(m_packet0);
// lock mutex pthread_mutex_lock(m_mutex); ! ! // convert pixels from yv12 to RGBA/BGRA m_pixBlock.image.fromYV12(m_pdpdata); ! // unlock mutex pthread_mutex_unlock(m_mutex); *************** *** 249,255 **** pdp_packet_mark_unused(m_packet0); m_packet0 = -1; ! } else if (pdp_packet_header(m_packet0)->info.image.encoding == PDP_IMAGE_YV12 ! && m_colorspace == GL_YCBCR_422_GEM) ! { if ( ( m_xsize != (int)m_header->info.image.width ) || ( m_ysize != (int)m_header->info.image.height ) ) --- 199,206 ---- pdp_packet_mark_unused(m_packet0); m_packet0 = -1; ! ! } else if (pdp_packet_header(m_packet0)->info.image.encoding == PDP_IMAGE_YV12 ! && m_colorspace == GL_YUV422_GEM) ! { if ( ( m_xsize != (int)m_header->info.image.width ) || ( m_ysize != (int)m_header->info.image.height ) ) *************** *** 260,302 **** } m_pdpdata = (short int *)pdp_packet_data(m_packet0); - #if 0 - psize = m_xsize*m_ysize; - pY = m_pdpdata; - pY2= m_pdpdata+m_xsize; - pV = m_pdpdata+psize; - pU = m_pdpdata+psize+(psize>>2); - unsigned char *pixels1 = m_data; - unsigned char *pixels2 = m_data + m_xsize * 2; - short *py1 = pY; - short *py2 = pY+m_xsize; // plane_1 is luma - short *pu = pU; - short *pv = pV; - int row = m_ysize>>1; - int cols = m_xsize>>1; - unsigned char u,v;
! // lock mutex ! pthread_mutex_lock(m_mutex); ! ! // copy image data ! while(row--){ ! int col=cols; ! while(col--){ ! u=((*pu++)>>8)+128; v=((*pv++)>>8)+128; ! *pixels1++=u; ! *pixels1++=(*py1++)>>7; ! *pixels1++=v; ! *pixels1++=(*py1++)>>7; ! *pixels2++=u; ! *pixels2++=(*py2++)>>7; ! *pixels2++=v; ! *pixels2++=(*py2++)>>7; ! } ! pixels1+= m_xsize*m_csize; pixels2+= m_xsize*m_csize; ! py1+=m_xsize*1; py2+=m_xsize*1; ! } ! #else m_pixBlock.image.fromYV12(m_pdpdata); ! #endif // unlock mutex pthread_mutex_unlock(m_mutex); --- 211,221 ---- } m_pdpdata = (short int *)pdp_packet_data(m_packet0);
! // lock mutex ! pthread_mutex_lock(m_mutex); ! ! // convert pixels from yv12 to uyvy m_pixBlock.image.fromYV12(m_pdpdata); ! // unlock mutex pthread_mutex_unlock(m_mutex); *************** *** 346,350 **** { if (!strcmp(format, "YUV")){ ! m_colorspace = GL_YCBCR_422_GEM; post("pdp2gem: colorspace is YUV %d",m_colorspace); m_csize = 2; --- 265,269 ---- { if (!strcmp(format, "YUV")){ ! m_colorspace = GL_YUV422_GEM; post("pdp2gem: colorspace is YUV %d",m_colorspace); m_csize = 2; *************** *** 386,393 **** } else {
! post("pdp2gem: colorspace is unknown %d",m_colorspace); post("pdp2gem: using default colorspace: YUV"); m_csize = 2; ! m_colorspace = GL_YCBCR_422_GEM; m_format = GL_YUV422_GEM; createBuffer(); --- 305,312 ---- } else {
! //post("pdp2gem: colorspace is unknown %d",m_colorspace); post("pdp2gem: using default colorspace: YUV"); m_csize = 2; ! m_colorspace = GL_YUV422_GEM; m_format = GL_YUV422_GEM; createBuffer();