summaryrefslogtreecommitdiff
path: root/recordmydesktop
diff options
context:
space:
mode:
authorenselic <enselic@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2008-09-14 07:01:35 +0000
committerenselic <enselic@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2008-09-14 07:01:35 +0000
commitc2da14838a03eb8450d06c0d0b95d38c9acb4964 (patch)
tree184ade625c089371f26f2f4717e50a2104686837 /recordmydesktop
parent2cf3c4864635a5761c5a9f45857abeb9ac363dcd (diff)
src/recordmydesktop.h: Move away the [yuv]blocks globals.
src/yuv_utils.h: Move out the DBUF- and the MARK_BACK_BUFFER_C() macros. src/block_utils.[ch]: New files hosting the [yuv]blocks globals and DBUF-macros. src/get_frame.c: Put MARK_BACK_BUFFER_C() locally here. src/Makefile.am src/rmd_rescue.c src/cache_frame.c src/initialize_data.c: Adapt to changes. git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@540 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'recordmydesktop')
-rw-r--r--recordmydesktop/src/Makefile.am2
-rw-r--r--recordmydesktop/src/block_utils.c35
-rw-r--r--recordmydesktop/src/block_utils.h170
-rw-r--r--recordmydesktop/src/cache_frame.c1
-rw-r--r--recordmydesktop/src/get_frame.c20
-rw-r--r--recordmydesktop/src/initialize_data.c9
-rw-r--r--recordmydesktop/src/recordmydesktop.h6
-rw-r--r--recordmydesktop/src/rmd_rescue.c1
-rw-r--r--recordmydesktop/src/yuv_utils.h154
9 files changed, 238 insertions, 160 deletions
diff --git a/recordmydesktop/src/Makefile.am b/recordmydesktop/src/Makefile.am
index c77a83e..3cbf469 100644
--- a/recordmydesktop/src/Makefile.am
+++ b/recordmydesktop/src/Makefile.am
@@ -1,6 +1,8 @@
bin_PROGRAMS = recordmydesktop
recordmydesktop_SOURCES = \
+ block_utils.c \
+ block_utils.h \
cache_audio.c \
cache_audio.h \
cache_frame.c \
diff --git a/recordmydesktop/src/block_utils.c b/recordmydesktop/src/block_utils.c
new file mode 100644
index 0000000..7cc29e5
--- /dev/null
+++ b/recordmydesktop/src/block_utils.c
@@ -0,0 +1,35 @@
+/******************************************************************************
+* recordMyDesktop *
+*******************************************************************************
+* *
+* Copyright (C) 2006,2007,2008 John Varouhakis *
+* *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the Free Software *
+* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+* *
+* *
+* *
+* For further information contact me at johnvarouhakis@gmail.com *
+******************************************************************************/
+
+#include "block_utils.h"
+
+
+// FIXME: These globals are modified in other source files! We keep
+// thsee here for now. These are the cache blocks. They need to be
+// accesible in the dbuf macros
+u_int32_t *yblocks,
+ *ublocks,
+ *vblocks;
diff --git a/recordmydesktop/src/block_utils.h b/recordmydesktop/src/block_utils.h
new file mode 100644
index 0000000..1c2e429
--- /dev/null
+++ b/recordmydesktop/src/block_utils.h
@@ -0,0 +1,170 @@
+/******************************************************************************
+* recordMyDesktop *
+*******************************************************************************
+* *
+* Copyright (C) 2006,2007,2008 John Varouhakis *
+* *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the Free Software *
+* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+* *
+* *
+* *
+* For further information contact me at johnvarouhakis@gmail.com *
+******************************************************************************/
+
+#ifndef BLOCK_UTILS_H
+#define BLOCK_UTILS_H 1
+
+#include "rmdtypes.h"
+#include "rmdmacro.h"
+#include "yuv_utils.h"
+
+
+// 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))
+
+#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;\
+ }\
+ }\
+ }\
+}
+
+
+#endif
diff --git a/recordmydesktop/src/cache_frame.c b/recordmydesktop/src/cache_frame.c
index c00d314..776e98a 100644
--- a/recordmydesktop/src/cache_frame.c
+++ b/recordmydesktop/src/cache_frame.c
@@ -29,6 +29,7 @@
#include "cache_frame.h"
#include "recordmydesktop.h"
#include "rmd_cache.h"
+#include "block_utils.h"
//minimize hard disk access
diff --git a/recordmydesktop/src/get_frame.c b/recordmydesktop/src/get_frame.c
index 1de3c0e..7bc4ede 100644
--- a/recordmydesktop/src/get_frame.c
+++ b/recordmydesktop/src/get_frame.c
@@ -130,6 +130,26 @@
}\
}
+#define MARK_BACK_BUFFER_C( data,\
+ x_tm,\
+ y_tm,\
+ width_tm,\
+ height_tm,\
+ buffer_width,\
+ __bit_depth__){\
+ int k,i;\
+ register u_int##__bit_depth__##_t\
+ *datapi=\
+ ((u_int##__bit_depth__##_t *)data)+y_tm*buffer_width+x_tm;\
+ for(k=0;k<height_tm;k++){\
+ for(i=0;i<width_tm;i++){\
+ *datapi+=1;\
+ datapi++;\
+ }\
+ datapi+=buffer_width-width_tm;\
+ }\
+}
+
#define MARK_BACK_BUFFER( data,\
x_tm,\
y_tm,\
diff --git a/recordmydesktop/src/initialize_data.c b/recordmydesktop/src/initialize_data.c
index 3ac5c77..4efda69 100644
--- a/recordmydesktop/src/initialize_data.c
+++ b/recordmydesktop/src/initialize_data.c
@@ -24,13 +24,14 @@
* For further information contact me at johnvarouhakis@gmail.com *
******************************************************************************/
-#include "recordmydesktop.h"
-#include "yuv_utils.h"
+#include "block_utils.h"
+#include "init_encoder.h"
#include "make_dummy_pointer.h"
#include "opendev.h"
-#include "rmd_jack.h"
-#include "init_encoder.h"
+#include "recordmydesktop.h"
#include "rmd_cache.h"
+#include "rmd_jack.h"
+#include "yuv_utils.h"
#ifdef HAVE_LIBASOUND
diff --git a/recordmydesktop/src/recordmydesktop.h b/recordmydesktop/src/recordmydesktop.h
index 3ee6e83..8e2e22b 100644
--- a/recordmydesktop/src/recordmydesktop.h
+++ b/recordmydesktop/src/recordmydesktop.h
@@ -36,12 +36,6 @@
//I'll fix it, I promise
#include "rmdtypes.h"
-//These are the cache blocks. They need to be accesible in the
-//dbuf macros
-u_int32_t *yblocks,
- *ublocks,
- *vblocks;
-
#include "rmdmacro.h"
diff --git a/recordmydesktop/src/rmd_rescue.c b/recordmydesktop/src/rmd_rescue.c
index 6f907d3..0b686eb 100644
--- a/recordmydesktop/src/rmd_rescue.c
+++ b/recordmydesktop/src/rmd_rescue.c
@@ -30,6 +30,7 @@
#include "register_callbacks.h"
#include "rmd_rescue.h"
#include "specsfile.h"
+#include "block_utils.h"
int rmdRescue(const char *path){
diff --git a/recordmydesktop/src/yuv_utils.h b/recordmydesktop/src/yuv_utils.h
index 6890a23..7b417b6 100644
--- a/recordmydesktop/src/yuv_utils.h
+++ b/recordmydesktop/src/yuv_utils.h
@@ -27,6 +27,10 @@
#ifndef YUV_UTILS_H
#define YUV_UTILS_H 1
+#include "rmdtypes.h"
+#include "block_utils.h"
+#include "rmdmacro.h"
+
// The macros work directly on this data (for performance reasons I
// suppose) so we keep this global
@@ -72,10 +76,6 @@ extern unsigned char Yr[256], Yg[256], Yb[256],
(t3&0x000000ff)+(t4&0x000000ff))/4)&0x000000ff);\
}
-#define POINT_IN_BLOCK(xv,yv,widthv,blocksize) ((yv/blocksize)*\
- (widthv/blocksize)+\
- (xv/blocksize))
-
#define UPDATE_Y_PLANE(data,\
x_tm,\
y_tm,\
@@ -101,37 +101,6 @@ 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_A_UV_PIXEL(yuv_u,\
yuv_v,\
t_val,\
@@ -198,100 +167,6 @@ extern unsigned char Yr[256], Yg[256], Yb[256],
}\
}
-#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;\
- }\
- }\
- }\
-}
-
#define UPDATE_YUV_BUFFER(yuv,\
data,\
data_back,\
@@ -363,27 +238,6 @@ extern unsigned char Yr[256], Yg[256], Yb[256],
}\
}
-#define MARK_BACK_BUFFER_C( data,\
- x_tm,\
- y_tm,\
- width_tm,\
- height_tm,\
- buffer_width,\
- __bit_depth__){\
- int k,i;\
- register u_int##__bit_depth__##_t\
- *datapi=\
- ((u_int##__bit_depth__##_t *)data)+y_tm*buffer_width+x_tm;\
- for(k=0;k<height_tm;k++){\
- for(i=0;i<width_tm;i++){\
- *datapi+=1;\
- datapi++;\
- }\
- datapi+=buffer_width-width_tm;\
- }\
-}
-
-
/**
* Fill Yr,Yg,Yb,Ur,Ug.Ub,Vr,Vg,Vb arrays(globals) with values.
*/
© All Rights Reserved