summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2007-01-21 01:09:32 +0000
committeriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2007-01-21 01:09:32 +0000
commit265e0bc43c5f057a28a07c2e38da748971d7a993 (patch)
treeef2765011c9bae13a2ed15e66386b702ec8870a8
parentfa96f09ceadcad5247a84245ad933782b4b71ee6 (diff)
Added support for 16bpp color depth.
Currently the UPDATE_*_PLANE(S)_* macros are duplicated, so they might need some reworking (they are perfectly functional though). git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@260 f606c939-3180-4ac9-a4b8-4b8779d57d0a
-rw-r--r--recordmydesktop/include/rmdmacro.h93
-rw-r--r--recordmydesktop/src/get_frame.c3
-rw-r--r--recordmydesktop/src/initialize_data.c3
-rw-r--r--recordmydesktop/src/setbrwindow.c11
-rw-r--r--recordmydesktop/src/update_image.c3
5 files changed, 102 insertions, 11 deletions
diff --git a/recordmydesktop/include/rmdmacro.h b/recordmydesktop/include/rmdmacro.h
index 31cb52d..16b472a 100644
--- a/recordmydesktop/include/rmdmacro.h
+++ b/recordmydesktop/include/rmdmacro.h
@@ -55,6 +55,14 @@
#define __GVALUE_32(tmp_val) (((tmp_val)&0x0000ff00)>>8)
#define __BVALUE_32(tmp_val) (((tmp_val)&0x000000ff))
+#define __R16_MASK 0xf800
+#define __G16_MASK 0x7e0
+#define __B16_MASK 0x1f
+
+#define __RVALUE_16(tmp_val) ((((tmp_val)&__R16_MASK)>>11)*8)
+#define __GVALUE_16(tmp_val) ((((tmp_val)&__G16_MASK)>>5)*4)
+#define __BVALUE_16(tmp_val) ((((tmp_val)&__B16_MASK))*8)
+
//xfixes pointer data are written as unsigned long
//(even though the server returns CARD32)
//so we need to set the step accordingly to
@@ -199,6 +207,20 @@
(t3&0x000000ff)+(t4&0x000000ff))/4)&0x000000ff);\
}
+#define CALC_TVAL_AVG_16(t_val,datapi,datapi_next){\
+ register u_int16_t t1,t2,t3,t4;\
+ t1=*datapi;\
+ t2=*(datapi+1);\
+ t3=*datapi_next;\
+ t4=*(datapi_next+1);\
+ t_val=((((t1&__R16_MASK) +(t2&__R16_MASK)+\
+ (t3&__R16_MASK)+(t4&__R16_MASK))/4)&__R16_MASK) \
+ +((((t1&__G16_MASK) +(t2&__G16_MASK)+\
+ (t3&__G16_MASK)+(t4&__G16_MASK))/4)&__G16_MASK)\
+ +((((t1&__B16_MASK) +(t2&__B16_MASK)+\
+ (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){ \
int k,i;\
register unsigned int t_val;\
@@ -219,6 +241,26 @@
}\
}
+#define UPDATE_Y_PLANE_16(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type){ \
+ 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;\
@@ -258,9 +300,54 @@
}\
}
-#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)\
+#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 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+\
+ ((__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_16(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)];\
+ *yuv_v=\
+ _vr[__RVALUE_16(t_val)] + _vg[__GVALUE_16(t_val)] + _vb[__BVALUE_16(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_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)\
+ }\
+ 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)\
+ }\
}
diff --git a/recordmydesktop/src/get_frame.c b/recordmydesktop/src/get_frame.c
index d3fb2ab..83e3058 100644
--- a/recordmydesktop/src/get_frame.c
+++ b/recordmydesktop/src/get_frame.c
@@ -145,7 +145,8 @@ void *GetFrame(ProgData *pdata){
(pdata->brwin.rgeom.width),
(pdata->brwin.rgeom.height),
pdata->args.noshared,
- pdata->args.no_quick_subsample);
+ pdata->args.no_quick_subsample,
+ pdata->specs.depth);
pthread_mutex_unlock(&pdata->yuv_mutex);
}
if(pdata->args.xfixes_cursor){
diff --git a/recordmydesktop/src/initialize_data.c b/recordmydesktop/src/initialize_data.c
index 2a710b5..93f7858 100644
--- a/recordmydesktop/src/initialize_data.c
+++ b/recordmydesktop/src/initialize_data.c
@@ -125,7 +125,8 @@ int InitializeData(ProgData *pdata,
UPDATE_YUV_BUFFER((&pdata->enc_data->yuv),dtap,
(pdata->enc_data->x_offset),(pdata->enc_data->y_offset),
(pdata->brwin.rgeom.width),(pdata->brwin.rgeom.height),
- __X_IPC,(pdata->args.no_quick_subsample));
+ __X_IPC,(pdata->args.no_quick_subsample),
+ pdata->specs.depth);
pdata->frametime=(1000000)/pdata->args.fps;
diff --git a/recordmydesktop/src/setbrwindow.c b/recordmydesktop/src/setbrwindow.c
index 58dc34c..2b7b694 100644
--- a/recordmydesktop/src/setbrwindow.c
+++ b/recordmydesktop/src/setbrwindow.c
@@ -42,7 +42,7 @@ void SizePack2_8_16(int *start,int *size,int limit){
//32 bit pack align
- //we already have disible by two width,so
+ //we already have disible by two width,so
//it's 2, 4 or 6
octoffset=((*size)%8);
if(octoffset==2){
@@ -61,7 +61,7 @@ void SizePack2_8_16(int *start,int *size,int limit){
(*size)-=4;
}
}
-
+
else if(octoffset==4){
if(((*size)+(*start)+2<=limit)&&((*start)>=2)){
(*start)-=2;
@@ -169,8 +169,9 @@ int SetBRWindow(Display *dpy,BRWindow *brwin,DisplaySpecs *specs,ProgArgs *args)
- brwin->nbytes=(((brwin->rgeom.width+15)>>4)<<4)*(((brwin->rgeom.height+15)>>4)<<4)*4;
-
-
+ brwin->nbytes=(((brwin->rgeom.width+15)>>4)<<4)*(((brwin->rgeom.height+15)>>4)<<4)*
+ ((specs->depth==16)?2:4);
+
+
return 0;
}
diff --git a/recordmydesktop/src/update_image.c b/recordmydesktop/src/update_image.c
index 1bf0cd5..7ae39ff 100644
--- a/recordmydesktop/src/update_image.c
+++ b/recordmydesktop/src/update_image.c
@@ -57,7 +57,8 @@ void UpdateImage(Display * dpy,
(temp->geom.x-brwin->rgeom.x+enc->x_offset),
(temp->geom.y-brwin->rgeom.y+enc->y_offset),
(temp->geom.width),(temp->geom.height),
- noshmem,no_quick_subsample);
+ noshmem,no_quick_subsample,
+ specs->depth);
pthread_mutex_unlock(yuv_mutex);
temp=temp->next;
}while(temp!=NULL);
© All Rights Reserved