summaryrefslogtreecommitdiff
path: root/recordmydesktop/include
diff options
context:
space:
mode:
authoriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2007-01-27 17:18:58 +0000
committeriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2007-01-27 17:18:58 +0000
commitc1a890715d4791b75b9512c1d9b02cb691c5de39 (patch)
tree5c641a197c75428192b8df06187895668aa6ee4c /recordmydesktop/include
parentee224df6f5e9871e9b7b516a53161198960cc4fb (diff)
Changed cache format to utilize better interframe encoding
and thus require sufficiently less hard disk space. Instead of the old (plane_width/16)*(plane_height/16) blocksize, now we are using 16x16 for the y plane and 8x8 blocks for the u,v planes. Also this byte alignment allows comparing of blocks to happen by first casting into a larger datatype(u_int64_t if available, u_int32_t else). This way we do as little as 1/8 or 1/4 of comparisons. This essentially offsets the higher CPU required to check the now increased number of blocks, and even provides a slight performance boost from the previous way of caching. Also, the load cache loop has been debloated, by moving much of the functionality that previously resided in an if evaluation statement, into anew function(ReadFrame). For further abstraction, ReadFrame utilizes ReadZF to do the actual reading. ReadZF determines if a gzread or an fread has to be done. Another improvement in the program is that, now, write operations on the disk, happen in 4 kbytes pages, minimizing thus the overall cost of access. Last change in this set is that the indexes in the CachedFrame and FrameHeader datatypes, are now u_int32_t's, to accomodate the possibly large number of blocks(could have been 16 bit types but that would give 4096*4096 max resolution, which might have caused problems in the future) git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@266 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'recordmydesktop/include')
-rw-r--r--recordmydesktop/include/rmdmacro.h47
-rw-r--r--recordmydesktop/include/rmdtypes.h26
2 files changed, 54 insertions, 19 deletions
diff --git a/recordmydesktop/include/rmdmacro.h b/recordmydesktop/include/rmdmacro.h
index 87ac39f..c14785f 100644
--- a/recordmydesktop/include/rmdmacro.h
+++ b/recordmydesktop/include/rmdmacro.h
@@ -69,8 +69,35 @@
//avoid problems (amd64 has 8byte ulong)
#define RMD_ULONG_SIZE_T (sizeof(unsigned long))
+//size of stride when comparing planes(depending on type)
+//this is just to avoid thousands of sizeof's
+#ifdef HAVE_U_INT64_T
+ #define COMPARE_STRIDE 8
+#else
+ #define COMPARE_STRIDE 4
+#endif
+
//500 mb file size
#define CACHE_FILE_SIZE_LIMIT (500*1<<20)
+//minimize hard disk access
+#define CACHE_OUT_BUFFER_SIZE 4096
+
+
+//The width, in bytes, of the blocks
+//on which the y,u and v planes are broken.
+//These blocks are square.
+#define Y_UNIT_WIDTH 0x0010
+#define UV_UNIT_WIDTH 0x0008
+
+//The number of bytes for every
+//sub-block of the y,u and v planes.
+//Since the blocks are square
+//these are obviously the squares
+//of the widths(specified above),
+//but the definitions bellow are only
+//for convenience anyway.
+#define Y_UNIT_BYTES 0x0100
+#define UV_UNIT_BYTES 0x0040
#define CLIP_EVENT_AREA(e,brwin,wgeom){\
@@ -251,10 +278,10 @@
__copy_type,\
__bit_depth__){ \
int k,i;\
- register RMD_TYPE_##__bit_depth__ t_val;\
+ 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 RMD_TYPE_##__bit_depth__ *datapi=(RMD_TYPE_##__bit_depth__ *)data\
+ register u_int##__bit_depth__##_t *datapi=(u_int##__bit_depth__##_t *)data\
+((__copy_type==__X_SHARED)?\
(x_tm+y_tm*yuv->y_width):0);\
for(k=0;k<height_tm;k++){\
@@ -282,12 +309,12 @@
__sampling_type,\
__bit_depth__){ \
int k,i;\
- register RMD_TYPE_##__bit_depth__ t_val;\
+ 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,*_ub=Ub,\
*_vr=Vr,*_vg=Vg,*_vb=Vb;\
- register RMD_TYPE_##__bit_depth__ *datapi=(RMD_TYPE_##__bit_depth__ *)data\
+ register u_int##__bit_depth__##_t *datapi=(u_int##__bit_depth__##_t *)data\
+((__copy_type==__X_SHARED)?\
(x_tm+y_tm*yuv->y_width):0),\
*datapi_next=NULL;\
@@ -445,20 +472,18 @@
free(t_buf);\
};\
-#define INIT_FRAME(frame_t,fheader_t,yuv_t){\
+#define INIT_FRAME(frame_t,fheader_t,yuv_t,\
+ YBlocks_t,UBlocks_t,VBlocks_t){\
(frame_t)->header=(fheader_t);\
- (frame_t)->YBlocks=malloc(256);\
- (frame_t)->UBlocks=malloc(64);\
- (frame_t)->VBlocks=malloc(64);\
+ (frame_t)->YBlocks=YBlocks_t;\
+ (frame_t)->UBlocks=UBlocks_t;\
+ (frame_t)->VBlocks=VBlocks_t;\
(frame_t)->YData=malloc((yuv_t)->y_width*(yuv_t)->y_height);\
(frame_t)->UData=malloc((yuv_t)->uv_width*(yuv_t)->uv_height);\
(frame_t)->VData=malloc((yuv_t)->uv_width*(yuv_t)->uv_height);\
};
#define CLEAR_FRAME(frame_t){\
- free((frame_t)->YBlocks);\
- free((frame_t)->UBlocks);\
- free((frame_t)->VBlocks);\
free((frame_t)->YData);\
free((frame_t)->UData);\
free((frame_t)->VData);\
diff --git a/recordmydesktop/include/rmdtypes.h b/recordmydesktop/include/rmdtypes.h
index ea1e517..7da30e9 100644
--- a/recordmydesktop/include/rmdtypes.h
+++ b/recordmydesktop/include/rmdtypes.h
@@ -31,6 +31,7 @@
#include <config.h>
#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -61,8 +62,19 @@
#include <ogg/ogg.h>
#include <alsa/asoundlib.h>
-typedef u_int16_t RMD_TYPE_16;
-typedef u_int32_t RMD_TYPE_32;
+//this type exists only
+//for comparing the planes at caching.
+//u_int64_t mught not be available everywhere.
+//The performance gain comes from casting the unsigned char
+//buffers to this type before comparing the two blocks.
+//This is made possible by the fact that blocks
+//for the Y plane are 16 bytes in width and blocks
+//for the U,V planes are 8 bytes in width
+#ifdef HAVE_U_INT64_T
+typedef u_int64_t cmp_int_t;
+#else
+typedef u_int32_t cmp_int_t;
+#endif
//how we obtained the image we are converting to yuv
enum{
@@ -293,11 +305,9 @@ typedef struct _FrameHeader{
u_int32_t frameno, //number of frame(cached frames)
current_total; //number of frames that should have been
//taken at time of caching this one
- u_int16_t Ynum, //number of changed blocks in the Y plane
+ u_int32_t Ynum, //number of changed blocks in the Y plane
Unum, //number of changed blocks in the U plane
Vnum; //number of changed blocks in the V plane
- u_int16_t pad; //always zero
-
}FrameHeader;
//The frame after retrieval.
@@ -307,9 +317,9 @@ typedef struct _FrameHeader{
typedef struct _CachedFrame{
FrameHeader *header;
- unsigned char *YBlocks; //identifying number on the grid,
- unsigned char *UBlocks; //starting at top left
- unsigned char *VBlocks; // >> >>
+ u_int32_t *YBlocks; //identifying number on the grid,
+ u_int32_t *UBlocks; //starting at top left
+ u_int32_t *VBlocks; // >> >>
unsigned char *YData; //pointer to data for the blocks that have changed,
unsigned char *UData; //which have to be remapped
unsigned char *VData; //on the buffer when reading
© All Rights Reserved