summaryrefslogtreecommitdiff
path: root/recordmydesktop/include
diff options
context:
space:
mode:
authoriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2007-01-20 22:21:28 +0000
committeriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2007-01-20 22:21:28 +0000
commitfa96f09ceadcad5247a84245ad933782b4b71ee6 (patch)
treee4e4b1d3d5d6f95b7122c4c01141fea60b72ce1f /recordmydesktop/include
parent27ef1920cf848e9add94c4106f8a76230efe787a (diff)
Concatated all UPDATE_YUV_BUFFER_* macros into one, UPDATE_YUV_BUFFER.
This one is further broken into UPDATE_(X)_PLANE(S)_(Y) macros, where X is Y or UV and Y is 32 or 16(color depth). This will allow easier incorporation of 16bpp support, without code duplication(where it can be avoided) and without bloating the toplevel calls of these macros with multiple similar blocks of code. Also changed toplevel check of depth, to allow running on 16 bpp git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@259 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'recordmydesktop/include')
-rw-r--r--recordmydesktop/include/rmdmacro.h202
-rw-r--r--recordmydesktop/include/rmdtypes.h14
2 files changed, 60 insertions, 156 deletions
diff --git a/recordmydesktop/include/rmdmacro.h b/recordmydesktop/include/rmdmacro.h
index b8e529a..31cb52d 100644
--- a/recordmydesktop/include/rmdmacro.h
+++ b/recordmydesktop/include/rmdmacro.h
@@ -51,9 +51,9 @@
#error Only little-endian and big-endian systems are supported
#endif
-#define __RVALUE(tmp_val) (((tmp_val)&0x00ff0000)>>16)
-#define __GVALUE(tmp_val) (((tmp_val)&0x0000ff00)>>8)
-#define __BVALUE(tmp_val) (((tmp_val)&0x000000ff))
+#define __RVALUE_32(tmp_val) (((tmp_val)&0x00ff0000)>>16)
+#define __GVALUE_32(tmp_val) (((tmp_val)&0x0000ff00)>>8)
+#define __BVALUE_32(tmp_val) (((tmp_val)&0x000000ff))
//xfixes pointer data are written as unsigned long
//(even though the server returns CARD32)
@@ -183,190 +183,84 @@
data_array[(k_tm*width_img+i_tm-1)*RMD_ULONG_SIZE_T+offset]+\
data_array[((k_tm-1)*width_img+i_tm-1)*RMD_ULONG_SIZE_T+offset])/4)
-#define UPDATE_YUV_BUFFER_SH(yuv,data,x_tm,y_tm,width_tm,height_tm){\
- int k,i;\
- register unsigned int t_val;\
- register unsigned int *datapi=(unsigned int*)data+x_tm+y_tm*yuv->y_width;\
- register unsigned char *yuv_y=yuv->y+x_tm+y_tm*yuv->y_width,\
- *yuv_u=yuv->u+x_tm/2+(y_tm*yuv->uv_width)/2,\
- *yuv_v=yuv->v+x_tm/2+(y_tm*yuv->uv_width)/2,\
- *_yr=Yr,*_yg=Yg,*_yb=Yb,\
- *_ur=Ur,*_ug=Ug,*_ub=Ub,\
- *_vr=Vr,*_vg=Vg,*_vb=Vb;\
-\
- for(k=0;k<height_tm;k++){\
- for(i=0;i<width_tm;i++){\
- t_val=*datapi;\
- *yuv_y=_yr[__RVALUE(t_val)] + _yg[__GVALUE(t_val)] + _yb[__BVALUE(t_val)] ;\
- datapi++;\
- yuv_y++;\
- }\
- yuv_y+=yuv->y_width-width_tm;\
- datapi+=yuv->y_width-width_tm;\
- }\
- datapi=(unsigned int*)data+x_tm+y_tm*yuv->y_width;\
- for(k=0;k<height_tm;k+=2){\
- for(i=0;i<width_tm;i+=2){\
- t_val=*datapi;\
- *yuv_u=\
- _ur[__RVALUE(t_val)] + _ug[__GVALUE(t_val)] + _ub[__BVALUE(t_val)];\
- *yuv_v=\
- _vr[__RVALUE(t_val)] + _vg[__GVALUE(t_val)] + _vb[__BVALUE(t_val)];\
- datapi+=2;\
- yuv_u++;\
- yuv_v++;\
- }\
- yuv_u+=(yuv->y_width-width_tm)/2;\
- yuv_v+=(yuv->y_width-width_tm)/2;\
- datapi+=(2*yuv->y_width-width_tm);\
- }\
+#define CALC_TVAL_AVG_32(t_val,datapi,datapi_next){\
+ register unsigned int t1,t2,t3,t4;\
+ t1=*datapi;\
+ t2=*(datapi+1);\
+ t3=*datapi_next;\
+ t4=*(datapi_next+1);\
+ t_val=((((t1&0xff000000) +(t2&0xff000000)+\
+ (t3&0xff000000)+(t4&0xff000000))/4)&0xff000000) \
+ +((((t1&0x00ff0000) +(t2&0x00ff0000)+\
+ (t3&0x00ff0000)+(t4&0x00ff0000))/4)&0x00ff0000)\
+ +((((t1&0x0000ff00) +(t2&0x0000ff00)+\
+ (t3&0x0000ff00)+(t4&0x0000ff00))/4)&0x0000ff00)\
+ +((((t1&0x000000ff) +(t2&0x000000ff)+\
+ (t3&0x000000ff)+(t4&0x000000ff))/4)&0x000000ff);\
}
-#define UPDATE_YUV_BUFFER_SH_AVG(yuv,data,x_tm,y_tm,width_tm,height_tm){\
+#define UPDATE_Y_PLANE_32(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type){ \
int k,i;\
- register unsigned int t_val,t1,t2,t3,t4;\
- register unsigned int *datapi=(unsigned int*)data+x_tm+y_tm*yuv->y_width,\
- *datapi_next=(unsigned int*)data+x_tm+(y_tm+1)*yuv->y_width;\
+ register unsigned int t_val;\
register unsigned char *yuv_y=yuv->y+x_tm+y_tm*yuv->y_width,\
- *yuv_u=yuv->u+x_tm/2+(y_tm*yuv->uv_width)/2,\
- *yuv_v=yuv->v+x_tm/2+(y_tm*yuv->uv_width)/2,\
- *_yr=Yr,*_yg=Yg,*_yb=Yb,\
- *_ur=Ur,*_ug=Ug,*_ub=Ub,\
- *_vr=Vr,*_vg=Vg,*_vb=Vb;\
-\
+ *_yr=Yr,*_yg=Yg,*_yb=Yb;\
+ register unsigned int *datapi=(unsigned int*)data+\
+ ((__copy_type==__X_SHARED)?(x_tm+y_tm*yuv->y_width):0);\
for(k=0;k<height_tm;k++){\
for(i=0;i<width_tm;i++){\
t_val=*datapi;\
- *yuv_y=_yr[__RVALUE(t_val)] + _yg[__GVALUE(t_val)] + _yb[__BVALUE(t_val)] ;\
+ *yuv_y=_yr[__RVALUE_32(t_val)] + _yg[__GVALUE_32(t_val)] + _yb[__BVALUE_32(t_val)] ;\
datapi++;\
yuv_y++;\
}\
yuv_y+=yuv->y_width-width_tm;\
- datapi+=yuv->y_width-width_tm;\
- }\
- datapi=(unsigned int*)data+x_tm+y_tm*yuv->y_width;\
- for(k=0;k<height_tm;k+=2){\
- for(i=0;i<width_tm;i+=2){\
- t1=*datapi;\
- t2=*(datapi+1);\
- t3=*datapi_next;\
- t4=*(datapi_next+1);\
- t_val=((((t1&0xff000000) +(t2&0xff000000)+\
- (t3&0xff000000)+(t4&0xff000000))/4)&0xff000000) \
- +((((t1&0x00ff0000) +(t2&0x00ff0000)+\
- (t3&0x00ff0000)+(t4&0x00ff0000))/4)&0x00ff0000)\
- +((((t1&0x0000ff00) +(t2&0x0000ff00)+\
- (t3&0x0000ff00)+(t4&0x0000ff00))/4)&0x0000ff00)\
- +((((t1&0x000000ff) +(t2&0x000000ff)+\
- (t3&0x000000ff)+(t4&0x000000ff))/4)&0x000000ff);\
-\
- *yuv_u=\
- _ur[__RVALUE(t_val)] + _ug[__GVALUE(t_val)] + _ub[__BVALUE(t_val)];\
- *yuv_v=\
- _vr[__RVALUE(t_val)] + _vg[__GVALUE(t_val)] + _vb[__BVALUE(t_val)];\
- datapi+=2;\
- datapi_next+=2;\
- yuv_u++;\
- yuv_v++;\
- }\
- yuv_u+=(yuv->y_width-width_tm)/2;\
- yuv_v+=(yuv->y_width-width_tm)/2;\
- datapi+=(2*yuv->y_width-width_tm);\
- datapi_next+=(2*yuv->y_width-width_tm);\
+ if(__copy_type==__X_SHARED)\
+ datapi+=yuv->y_width-width_tm;\
}\
}
-
-
-#define UPDATE_YUV_BUFFER_IM(yuv,data,x_tm,y_tm,width_tm,height_tm){\
+#define UPDATE_UV_PLANES_32(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,__sampling_type){ \
int k,i;\
register unsigned int t_val;\
- register unsigned int *datapi=(unsigned int*)data;\
- register unsigned char *yuv_y=yuv->y+x_tm+y_tm*yuv->y_width,\
- *yuv_u=yuv->u+x_tm/2+(y_tm*yuv->uv_width)/2,\
+ register unsigned char *yuv_u=yuv->u+x_tm/2+(y_tm*yuv->uv_width)/2,\
*yuv_v=yuv->v+x_tm/2+(y_tm*yuv->uv_width)/2,\
- *_yr=Yr,*_yg=Yg,*_yb=Yb,\
*_ur=Ur,*_ug=Ug,*_ub=Ub,\
*_vr=Vr,*_vg=Vg,*_vb=Vb;\
-\
- for(k=0;k<height_tm;k++){\
- for(i=0;i<width_tm;i++){\
- t_val=*datapi;\
- *yuv_y=_yr[__RVALUE(t_val)] + _yg[__GVALUE(t_val)] + _yb[__BVALUE(t_val)] ;\
- datapi++;\
- yuv_y++;\
- }\
- yuv_y+=yuv->y_width-width_tm;\
+ register unsigned int *datapi=(unsigned int*)data+\
+ ((__copy_type==__X_SHARED)?(x_tm+y_tm*yuv->y_width):0),\
+ *datapi_next=NULL;\
+ if(__sampling_type==__PXL_AVERAGE){\
+ datapi_next=datapi+\
+ ((__copy_type==__X_SHARED)?(yuv->y_width):(width_tm));\
}\
- datapi=(unsigned int*)data;\
for(k=0;k<height_tm;k+=2){\
for(i=0;i<width_tm;i+=2){\
- t_val=*datapi;\
+ if(__sampling_type==__PXL_AVERAGE){\
+ CALC_TVAL_AVG_32(t_val,datapi,datapi_next)\
+ }\
+ else\
+ t_val=*datapi;\
*yuv_u=\
- _ur[__RVALUE(t_val)] + _ug[__GVALUE(t_val)] + _ub[__BVALUE(t_val)];\
+ _ur[__RVALUE_32(t_val)] + _ug[__GVALUE_32(t_val)] + _ub[__BVALUE_32(t_val)];\
*yuv_v=\
- _vr[__RVALUE(t_val)] + _vg[__GVALUE(t_val)] + _vb[__BVALUE(t_val)];\
+ _vr[__RVALUE_32(t_val)] + _vg[__GVALUE_32(t_val)] + _vb[__BVALUE_32(t_val)];\
datapi+=2;\
+ if(__sampling_type==__PXL_AVERAGE)\
+ datapi_next+=2;\
yuv_u++;\
yuv_v++;\
}\
yuv_u+=(yuv->y_width-width_tm)/2;\
yuv_v+=(yuv->y_width-width_tm)/2;\
- datapi+=width_tm;\
+ datapi+=((__copy_type==__X_SHARED)?(2*yuv->y_width-width_tm):width_tm);\
+ if(__sampling_type==__PXL_AVERAGE)\
+ datapi_next+=((__copy_type==__X_SHARED)?(2*yuv->y_width-width_tm):width_tm);\
}\
}
-#define UPDATE_YUV_BUFFER_IM_AVG(yuv,data,x_tm,y_tm,width_tm,height_tm){\
- int k,i;\
- register unsigned int t_val,t1,t2,t3,t4;\
- register unsigned int *datapi=(unsigned int*)data,\
- *datapi_next=(unsigned int*)data+width_tm;\
- register unsigned char *yuv_y=yuv->y+x_tm+y_tm*yuv->y_width,\
- *yuv_u=yuv->u+x_tm/2+(y_tm*yuv->uv_width)/2,\
- *yuv_v=yuv->v+x_tm/2+(y_tm*yuv->uv_width)/2,\
- *_yr=Yr,*_yg=Yg,*_yb=Yb,\
- *_ur=Ur,*_ug=Ug,*_ub=Ub,\
- *_vr=Vr,*_vg=Vg,*_vb=Vb;\
-\
- for(k=0;k<height_tm;k++){\
- for(i=0;i<width_tm;i++){\
- t_val=*datapi;\
- *yuv_y=_yr[__RVALUE(t_val)] + _yg[__GVALUE(t_val)] + _yb[__BVALUE(t_val)] ;\
- datapi++;\
- yuv_y++;\
- }\
- yuv_y+=yuv->y_width-width_tm;\
- }\
- datapi=(unsigned int*)data;\
- for(k=0;k<height_tm;k+=2){\
- for(i=0;i<width_tm;i+=2){\
- t1=*datapi;\
- t2=*(datapi+1);\
- t3=*datapi_next;\
- t4=*(datapi_next+1);\
- t_val=((((t1&0xff000000) +(t2&0xff000000)+\
- (t3&0xff000000)+(t4&0xff000000))/4)&0xff000000) \
- +((((t1&0x00ff0000) +(t2&0x00ff0000)+\
- (t3&0x00ff0000)+(t4&0x00ff0000))/4)&0x00ff0000)\
- +((((t1&0x0000ff00) +(t2&0x0000ff00)+\
- (t3&0x0000ff00)+(t4&0x0000ff00))/4)&0x0000ff00)\
- +((((t1&0x000000ff) +(t2&0x000000ff)+\
- (t3&0x000000ff)+(t4&0x000000ff))/4)&0x000000ff);\
-\
- *yuv_u=\
- _ur[__RVALUE(t_val)] + _ug[__GVALUE(t_val)] + _ub[__BVALUE(t_val)];\
- *yuv_v=\
- _vr[__RVALUE(t_val)] + _vg[__GVALUE(t_val)] + _vb[__BVALUE(t_val)];\
- datapi+=2;\
- datapi_next+=2;\
- yuv_u++;\
- yuv_v++;\
- }\
- yuv_u+=(yuv->y_width-width_tm)/2;\
- yuv_v+=(yuv->y_width-width_tm)/2;\
- datapi+=width_tm;\
- datapi_next+=width_tm;\
- }\
+#define UPDATE_YUV_BUFFER(yuv,data,x_tm,y_tm,width_tm,height_tm,__copy_type,__sampling_type){\
+ UPDATE_Y_PLANE_32(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type)\
+ UPDATE_UV_PLANES_32(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,__sampling_type)\
}
diff --git a/recordmydesktop/include/rmdtypes.h b/recordmydesktop/include/rmdtypes.h
index b52817c..870abe4 100644
--- a/recordmydesktop/include/rmdtypes.h
+++ b/recordmydesktop/include/rmdtypes.h
@@ -61,6 +61,18 @@
#include <ogg/ogg.h>
#include <alsa/asoundlib.h>
+//how we obtained the image we are converting to yuv
+enum{
+ __X_SHARED, //through MIT/Shm
+ __X_IPC //through the regular X IPC mechanism
+};
+//type of pixel proccessing for the Cb,Cr planes
+//when converting from full rgb to 4:2:2 Ycbcr
+enum{
+ __PXL_DISCARD, //only select 1 pixel in every block of four
+ __PXL_AVERAGE //calculate the average of all four pixels
+};
+
typedef struct _DisplaySpecs{ //this struct holds some basic information
int screen; //about the display,needed mostly for
uint width; //validity checks at startup
@@ -221,8 +233,6 @@ typedef struct _ProgData{
pthread_mutex_t list_mutex[2],//mutexes for concurrency protection of the lists
sound_buffer_mutex,
libogg_mutex,//libogg is not thread safe,
-// libtheora_mutex,//same for libtheora
-// libvorbis_mutex,//and libvorbis.
yuv_mutex;//this might not be needed since we only have
//one read-only and one write-only thread
//also on previous versions, y component was looped separately
© All Rights Reserved