summaryrefslogtreecommitdiff
path: root/recordmydesktop/src/rmd_yuv_utils.h
diff options
context:
space:
mode:
authoriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2008-12-13 17:20:24 +0000
committeriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2008-12-13 17:20:24 +0000
commitd7f4fe1de14209b7d2587a602a01dd93f6714fad (patch)
tree29ace7d04af2c02398b7da59b1014a6b7242d77f /recordmydesktop/src/rmd_yuv_utils.h
parent61ab7edf42e5a7ff3b7d663a2661d3b60723cf14 (diff)
Added missing stdio.h and errno.h headers in any
files that needed them (could cause compilation failure on some platforms). Also, rearranged the sequence with which include's happen, so that any missing headers will be more likely to show up as copilation errors, in the future. rmd_yuv_utils.[ch] and rmd_block_utils.[ch] have been merged within the former, as they deal with the same subject (converting rgb buffers to yuv ones, with the only difference that rmd_block_utils had the double-buffer convertions while rmd_yuv_utils dealt with the single-buffered ones). Their headers also had the a circular dependency (rmd_yuv_utils.h included rmd_block_utils.h and vice-versa). rmd_math.[ch] was added. This file holds now the rmdRoundf function which is a portable implementation of roundf (which depends on C99). The reasoning behind the addition of these files, is that they might hold more purely mathematical functions, in the future. git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@583 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'recordmydesktop/src/rmd_yuv_utils.h')
-rw-r--r--recordmydesktop/src/rmd_yuv_utils.h135
1 files changed, 134 insertions, 1 deletions
diff --git a/recordmydesktop/src/rmd_yuv_utils.h b/recordmydesktop/src/rmd_yuv_utils.h
index b1af63b..a8960a4 100644
--- a/recordmydesktop/src/rmd_yuv_utils.h
+++ b/recordmydesktop/src/rmd_yuv_utils.h
@@ -27,7 +27,6 @@
#ifndef YUV_UTILS_H
#define YUV_UTILS_H 1
-#include "rmd_block_utils.h"
#include "rmd_macro.h"
#include "rmd_types.h"
@@ -39,6 +38,15 @@ extern unsigned char Yr[256], Yg[256], Yb[256],
Vg[256], Vb[256];
+// We keep these global for now. FIXME: Isolate them.
+extern u_int32_t *yblocks,
+ *ublocks,
+ *vblocks;
+
+#define POINT_IN_BLOCK(xv,yv,widthv,blocksize) ((yv/blocksize)*\
+ (widthv/blocksize)+\
+ (xv/blocksize))
+
//when adding the r values, we go beyond
//the (16 bit)range of the t_val variable, but we are performing
//32 bit arithmetics, so there's no problem.
@@ -238,6 +246,131 @@ extern unsigned char Yr[256], Yg[256], Yb[256],
}\
}
+#define UPDATE_Y_PLANE_DBUF(data,\
+ data_back,\
+ x_tm,\
+ y_tm,\
+ height_tm,\
+ width_tm,\
+ yuv,\
+ __bit_depth__){ \
+ int k,i;\
+ register u_int##__bit_depth__##_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_int##__bit_depth__##_t *datapi=(u_int##__bit_depth__##_t *)data,\
+ *datapi_back=(u_int##__bit_depth__##_t *)data_back;\
+ for(k=0;k<height_tm;k++){\
+ for(i=0;i<width_tm;i++){\
+ if(*datapi!=*datapi_back){\
+ t_val=*datapi;\
+ *yuv_y=_yr[__RVALUE_##__bit_depth__(t_val)] +\
+ _yg[__GVALUE_##__bit_depth__(t_val)] +\
+ _yb[__BVALUE_##__bit_depth__(t_val)] ;\
+ yblocks[POINT_IN_BLOCK(i,k,width_tm,Y_UNIT_WIDTH)]=1;\
+ }\
+ datapi++;\
+ datapi_back++;\
+ yuv_y++;\
+ }\
+ yuv_y+=yuv->y_width-width_tm;\
+ }\
+}
+
+#define UPDATE_UV_PLANES_DBUF( data,\
+ data_back,\
+ x_tm,\
+ y_tm,\
+ height_tm,\
+ width_tm,\
+ yuv,\
+ __sampling_type,\
+ __bit_depth__){ \
+ int k,i;\
+ register u_int##__bit_depth__##_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,*_ubvr=UbVr,\
+ *_vg=Vg,*_vb=Vb;\
+ register u_int##__bit_depth__##_t *datapi=(u_int##__bit_depth__##_t *)data,\
+ *datapi_next=NULL,\
+ *datapi_back=(u_int##__bit_depth__##_t *)data_back,\
+ *datapi_back_next=NULL;\
+ if(__sampling_type==__PXL_AVERAGE){\
+ datapi_next=datapi+width_tm;\
+ datapi_back_next=datapi_back+width_tm;\
+ for(k=0;k<height_tm;k+=2){\
+ for(i=0;i<width_tm;i+=2){\
+ if(( (*datapi!=*datapi_back) ||\
+ (*(datapi+1)!=*(datapi_back+1)) ||\
+ (*datapi_next!=*datapi_back_next) ||\
+ (*(datapi_next+1)!=*(datapi_back_next+1)))){\
+ UPDATE_A_UV_PIXEL( yuv_u,\
+ yuv_v,\
+ t_val,\
+ datapi,\
+ datapi_next,\
+ _ur,_ug,_ubvr,_vg,_vb,\
+ __sampling_type,\
+ __bit_depth__)\
+ ublocks[POINT_IN_BLOCK(i,k,width_tm,Y_UNIT_WIDTH)]=1;\
+ vblocks[POINT_IN_BLOCK(i,k,width_tm,Y_UNIT_WIDTH)]=1;\
+ }\
+ datapi+=2;\
+ datapi_back+=2;\
+ if(__sampling_type==__PXL_AVERAGE){\
+ datapi_next+=2;\
+ datapi_back_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_back+=width_tm;\
+ if(__sampling_type==__PXL_AVERAGE){\
+ datapi_next+=width_tm;\
+ datapi_back_next+=width_tm;\
+ }\
+ }\
+ }\
+ else{\
+ for(k=0;k<height_tm;k+=2){\
+ for(i=0;i<width_tm;i+=2){\
+ if ((*datapi!=*datapi_back)){\
+ UPDATE_A_UV_PIXEL( yuv_u,\
+ yuv_v,\
+ t_val,\
+ datapi,\
+ datapi_next,\
+ _ur,_ug,_ubvr,_vg,_vb,\
+ __sampling_type,\
+ __bit_depth__)\
+ ublocks[POINT_IN_BLOCK(i,k,width_tm,Y_UNIT_WIDTH)]=1;\
+ vblocks[POINT_IN_BLOCK(i,k,width_tm,Y_UNIT_WIDTH)]=1;\
+ }\
+ datapi+=2;\
+ datapi_back+=2;\
+ if(__sampling_type==__PXL_AVERAGE){\
+ datapi_next+=2;\
+ datapi_back_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_back+=width_tm;\
+ if(__sampling_type==__PXL_AVERAGE){\
+ datapi_next+=width_tm;\
+ datapi_back_next+=width_tm;\
+ }\
+ }\
+ }\
+}
+
/**
* Fill Yr,Yg,Yb,Ur,Ug.Ub,Vr,Vg,Vb arrays(globals) with values.
*/
© All Rights Reserved