diff options
author | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2007-01-21 15:12:57 +0000 |
---|---|---|
committer | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2007-01-21 15:12:57 +0000 |
commit | 4613054faf335a84ab8f413506f4b75bbd72e5eb (patch) | |
tree | bf5a627693392a8de1cc36a1ccc4c554cfccba27 | |
parent | 265e0bc43c5f057a28a07c2e38da748971d7a993 (diff) |
removed duplicated code of UPDATE_*_PLANE(S)_*,
which have been replaced with UPDATE_*_PLANE(S) with an extra __bit_depth__ parameter
git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@261 f606c939-3180-4ac9-a4b8-4b8779d57d0a
-rw-r--r-- | recordmydesktop/include/rmdmacro.h | 95 | ||||
-rw-r--r-- | recordmydesktop/include/rmdtypes.h | 3 |
2 files changed, 24 insertions, 74 deletions
diff --git a/recordmydesktop/include/rmdmacro.h b/recordmydesktop/include/rmdmacro.h index 16b472a..3576a3b 100644 --- a/recordmydesktop/include/rmdmacro.h +++ b/recordmydesktop/include/rmdmacro.h @@ -33,7 +33,7 @@ #include "rmdtypes.h" -//define whcih way we are reading a pixmap +//define which way we are reading a pixmap #if __BYTE_ORDER == __LITTLE_ENDIAN #define __ABYTE 3 #define __RBYTE 2 @@ -221,17 +221,19 @@ (t3&__B16_MASK)+(t4&__B16_MASK))/4)&__B16_MASK);\ } -#define UPDATE_Y_PLANE_32(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type){ \ +#define UPDATE_Y_PLANE(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,__bit_depth__){ \ int k,i;\ - register unsigned int t_val;\ + register RMD_TYPE_##__bit_depth__ t_val;\ register unsigned char *yuv_y=yuv->y+x_tm+y_tm*yuv->y_width,\ *_yr=Yr,*_yg=Yg,*_yb=Yb;\ - register unsigned int *datapi=(unsigned int*)data+\ + register RMD_TYPE_##__bit_depth__ *datapi=(RMD_TYPE_##__bit_depth__ *)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_32(t_val)] + _yg[__GVALUE_32(t_val)] + _yb[__BVALUE_32(t_val)] ;\ + *yuv_y=_yr[__RVALUE_##__bit_depth__(t_val)] +\ + _yg[__GVALUE_##__bit_depth__(t_val)] +\ + _yb[__BVALUE_##__bit_depth__(t_val)] ;\ datapi++;\ yuv_y++;\ }\ @@ -241,73 +243,14 @@ }\ } -#define UPDATE_Y_PLANE_16(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type){ \ +#define UPDATE_UV_PLANES(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,__sampling_type,__bit_depth__){ \ int k,i;\ - register u_int16_t t_val;\ - register unsigned char *yuv_y=yuv->y+x_tm+y_tm*yuv->y_width,\ - *_yr=Yr,*_yg=Yg,*_yb=Yb;\ - register u_int16_t *datapi=(u_int16_t *)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_16(t_val)] + _yg[__GVALUE_16(t_val)] + _yb[__BVALUE_16(t_val)] ;\ - datapi++;\ - yuv_y++;\ - }\ - yuv_y+=yuv->y_width-width_tm;\ - if(__copy_type==__X_SHARED)\ - datapi+=yuv->y_width-width_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 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,\ - *_ur=Ur,*_ug=Ug,*_ub=Ub,\ - *_vr=Vr,*_vg=Vg,*_vb=Vb;\ - 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));\ - }\ - for(k=0;k<height_tm;k+=2){\ - for(i=0;i<width_tm;i+=2){\ - if(__sampling_type==__PXL_AVERAGE){\ - CALC_TVAL_AVG_32(t_val,datapi,datapi_next)\ - }\ - else\ - t_val=*datapi;\ - *yuv_u=\ - _ur[__RVALUE_32(t_val)] + _ug[__GVALUE_32(t_val)] + _ub[__BVALUE_32(t_val)];\ - *yuv_v=\ - _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+=((__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_UV_PLANES_16(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,__sampling_type){ \ - int k,i;\ - register u_int16_t t_val;\ + register RMD_TYPE_##__bit_depth__ t_val;\ 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,\ *_ur=Ur,*_ug=Ug,*_ub=Ub,\ *_vr=Vr,*_vg=Vg,*_vb=Vb;\ - register u_int16_t *datapi=(u_int16_t*)data+\ + register RMD_TYPE_##__bit_depth__ *datapi=(RMD_TYPE_##__bit_depth__ *)data+\ ((__copy_type==__X_SHARED)?(x_tm+y_tm*yuv->y_width):0),\ *datapi_next=NULL;\ if(__sampling_type==__PXL_AVERAGE){\ @@ -317,14 +260,18 @@ for(k=0;k<height_tm;k+=2){\ for(i=0;i<width_tm;i+=2){\ if(__sampling_type==__PXL_AVERAGE){\ - CALC_TVAL_AVG_16(t_val,datapi,datapi_next)\ + CALC_TVAL_AVG_##__bit_depth__(t_val,datapi,datapi_next)\ }\ else\ t_val=*datapi;\ *yuv_u=\ - _ur[__RVALUE_16(t_val)] + _ug[__GVALUE_16(t_val)] + _ub[__BVALUE_16(t_val)];\ + _ur[__RVALUE_##__bit_depth__(t_val)] +\ + _ug[__GVALUE_##__bit_depth__(t_val)] +\ + _ub[__BVALUE_##__bit_depth__(t_val)];\ *yuv_v=\ - _vr[__RVALUE_16(t_val)] + _vg[__GVALUE_16(t_val)] + _vb[__BVALUE_16(t_val)];\ + _vr[__RVALUE_##__bit_depth__(t_val)] +\ + _vg[__GVALUE_##__bit_depth__(t_val)] +\ + _vb[__BVALUE_##__bit_depth__(t_val)];\ datapi+=2;\ if(__sampling_type==__PXL_AVERAGE)\ datapi_next+=2;\ @@ -341,12 +288,12 @@ #define UPDATE_YUV_BUFFER(yuv,data,x_tm,y_tm,width_tm,height_tm,__copy_type,__sampling_type,__color_depth){\ if((__color_depth==24)||(__color_depth==32)){\ - 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)\ + UPDATE_Y_PLANE(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,32)\ + UPDATE_UV_PLANES(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,__sampling_type,32)\ }\ else if(__color_depth==16){\ - UPDATE_Y_PLANE_16(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type)\ - UPDATE_UV_PLANES_16(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,__sampling_type)\ + UPDATE_Y_PLANE(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,16)\ + UPDATE_UV_PLANES(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,__sampling_type,16)\ }\ } diff --git a/recordmydesktop/include/rmdtypes.h b/recordmydesktop/include/rmdtypes.h index 870abe4..328532f 100644 --- a/recordmydesktop/include/rmdtypes.h +++ b/recordmydesktop/include/rmdtypes.h @@ -61,6 +61,9 @@ #include <ogg/ogg.h> #include <alsa/asoundlib.h> +typedef u_int16_t RMD_TYPE_16; +typedef u_int32_t RMD_TYPE_32; + //how we obtained the image we are converting to yuv enum{ __X_SHARED, //through MIT/Shm |