summaryrefslogtreecommitdiff
path: root/recordmydesktop
diff options
context:
space:
mode:
authorenselic <enselic@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2008-09-11 19:26:27 +0000
committerenselic <enselic@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2008-09-11 19:26:27 +0000
commit7487ea601384016ed6185e9083ea3e0d1b71fa46 (patch)
tree96ae8bc30fb07f7b06372c2780eeb2671af24e02 /recordmydesktop
parentf635b1be3ea9c3a3892936e95e9306b121d1bb5e (diff)
Started working towards a more clean include hierarchy and
distinguishable program modules. First step: move stuff from global headers that is only used in one source file to those source files. include/rmdfunc.h include/rmdmacro.h include/rmdtypes.h: Move stuff from here src/rmd_jack.c src/get_frame.c src/rmd_cache.c src/load_cache.c src/rectinsert.c src/cache_frame.c src/poll_events.c src/setbrwindow.c src/recordmydesktop.c: To here. git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@508 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'recordmydesktop')
-rw-r--r--recordmydesktop/include/rmdfunc.h131
-rw-r--r--recordmydesktop/include/rmdmacro.h209
-rw-r--r--recordmydesktop/include/rmdtypes.h15
-rw-r--r--recordmydesktop/src/cache_frame.c6
-rw-r--r--recordmydesktop/src/get_frame.c117
-rw-r--r--recordmydesktop/src/load_cache.c37
-rw-r--r--recordmydesktop/src/poll_events.c40
-rw-r--r--recordmydesktop/src/recordmydesktop.c13
-rw-r--r--recordmydesktop/src/rectinsert.c38
-rw-r--r--recordmydesktop/src/rmd_cache.c12
-rw-r--r--recordmydesktop/src/rmd_jack.c80
-rw-r--r--recordmydesktop/src/setbrwindow.c15
12 files changed, 345 insertions, 368 deletions
diff --git a/recordmydesktop/include/rmdfunc.h b/recordmydesktop/include/rmdfunc.h
index 77446e8..f7390b8 100644
--- a/recordmydesktop/include/rmdfunc.h
+++ b/recordmydesktop/include/rmdfunc.h
@@ -103,36 +103,6 @@ void ClearList(RectArea **root);
int RectInsert(RectArea **root,WGeometry *wgeom);
/**
-* Collide two rectangles and dictate most sane action for insertion,
-* as well as provide the updated rectangle(s)
-* \param wgeom1 resident rectangle
-*
-* \param wgeom2 New rectangle
-*
-* \param wgeom_return Pointer to rectangles to be inserted
-*
-* \param ngeoms number of entries in wgeom_return
-*
-* \retval 0 No collision
-*
-* \retval 1 wgeom1 is covered by wgeom2
-*
-* \retval 2 wgeom2 is covered by wgeom1
-*
-* \retval -1 wgeom1 was broken (new is picked up in wgeom_return)
-*
-* \retval -2 wgeom2 was broken (new is picked up in wgeom_return)
-*
-* \retval -10 Grouping the two geoms is possible
-*
-*/
-int CollideRects(WGeometry *wgeom1,
- WGeometry *wgeom2,
- WGeometry **wgeom_return,
- int *ngeoms);
-
-
-/**
* Set up all callbacks and signal handlers
* \param pdata ProgData struct containing all program data
*/
@@ -394,19 +364,6 @@ void InitEncoder(ProgData *pdata,EncData *enc_data_t,int buffer_ready);
* Fill Yr,Yg,Yb,Ur,Ug.Ub,Vr,Vg,Vb arrays(globals) with values.
*/
void MakeMatrices();
-/**
-*Align the recording window to a divisible by 2 pixel start and
-*and a size divisible by 16.
-*
-* \param start x or y of the recording window
-*
-* \param size width or height of the recording window
-*
-* \param limit width or height of the Display
-*
-* \note This is called separately for width and height.
-*/
-void SizePack2_8_16(int *start,int *size,int limit);
/**
* Image caching thread. Copies the yuv buffer, compares with the last one and
@@ -478,18 +435,6 @@ void SyncEncodeSoundBuffer(ProgData *pdata,signed char *buff);
char *rmdWMCheck(Display *dpy,Window root);
/**
-*Construct an number postfixed name
-*
-* \param name base name
-*
-* \param newname modified name
-*
-* \n number to be used as a postfix
-*
-*/
-void CacheFileN(char *name,char **newname,int n);
-
-/**
* Change file pointer to a new file while writting
* (file name is incremented with CacheFileN)
*
@@ -563,84 +508,10 @@ int InitializeData(ProgData *pdata,
CacheData *cache_data);
#ifdef HAVE_JACK_H
-/**
-*
-* Global Fuction Pointers To Jack API Calls
-*
-*/
-jack_client_t *(*jack_client_new_p)(const char *client_name);
-jack_nframes_t (*jack_get_sample_rate_p)(jack_client_t * client);
-int (*jack_set_buffer_size_p)(jack_client_t *client, jack_nframes_t nframes);
-jack_nframes_t (*jack_get_buffer_size_p)(jack_client_t *client);
-int (*jack_set_process_callback_p)(jack_client_t *client,
- JackProcessCallback process_callback,
- void *arg);
-void (*jack_on_shutdown_p)(jack_client_t *client,
- void(*function)(void *arg),
- void *arg);
-int (*jack_activate_p)(jack_client_t *client);
-int (*jack_client_close_p)(jack_client_t *client);
-void *(*jack_port_get_buffer_p)(jack_port_t *port,jack_nframes_t);
-jack_port_t *(*jack_port_register_p)(jack_client_t *client,
- const char *port_name,
- const char *port_type,
- unsigned long flags,
- unsigned long buffer_size);
-int (*jack_connect_p)(jack_client_t *client,
- const char *source_port,
- const char *destination_port);
-const char *(*jack_port_name_p)(const jack_port_t *port);
-int (*jack_port_name_size_p)(void);
-jack_ringbuffer_t *(*jack_ringbuffer_create_p)(size_t sz);
-void (*jack_ringbuffer_free_p)(jack_ringbuffer_t *rb);
+
size_t (*jack_ringbuffer_read_p)(jack_ringbuffer_t *rb,
char *dest, size_t cnt);
size_t (*jack_ringbuffer_read_space_p)(const jack_ringbuffer_t *rb);
-size_t (*jack_ringbuffer_write_p)(jack_ringbuffer_t *rb,
- const char *src,
- size_t cnt);
-/**
-* End Of Function Pointers
-*/
-
-/**
-* Callback for capture through jack
-*
-* \param nframes Number of frames captured
-*
-* \param jdata_t Pointer to JackData struct containing port
-* and client information
-*
-* \returns Zero always
-*/
-int JackCapture(jack_nframes_t nframes,void *jdata_t);
-
-/**
-* Callback for jack server shutdown
-*
-* \param jdata_t Pointer to JackData struct containing port
-* and client information
-*/
-void JackShutdown(void *jdata_t);
-
-/**
-* Register and Activate specified ports
-*
-* \param jdata_t Pointer to JackData struct containing port
-* and client information
-*
-* \returns 0 on Success, 1 on failure
-*/
-int SetupPorts(JackData *jdata);
-
-/**
-* dlopen libjack and dlsym all needed functions
-*
-* \param jack_lib_handle Pointer to handle for jack library
-*
-* \returns 0 on Success, 1 on failure
-*/
-int LoadJackLib(void *jack_lib_handle);
/**
* Load libjack, create and activate client,register ports
diff --git a/recordmydesktop/include/rmdmacro.h b/recordmydesktop/include/rmdmacro.h
index f3dfcd6..13455ed 100644
--- a/recordmydesktop/include/rmdmacro.h
+++ b/recordmydesktop/include/rmdmacro.h
@@ -77,10 +77,6 @@
#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
@@ -89,16 +85,6 @@
#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
-
#ifdef HAVE_LIBASOUND
#define DEFAULT_AUDIO_DEVICE "hw:0,0"
#else
@@ -107,84 +93,6 @@
-#define CLIP_EVENT_AREA(e,brwin,wgeom){\
- if(((e)->area.x<=(brwin)->rgeom.x)&&((e)->area.y<=(brwin)->rgeom.y)&&\
- ((e)->area.width>=(brwin)->rgeom.width)&&\
- ((e)->area.height<(brwin)->rgeom.height)){\
- (wgeom)->x=(brwin)->rgeom.x;\
- (wgeom)->y=(brwin)->rgeom.y;\
- (wgeom)->width=(brwin)->rgeom.width;\
- (wgeom)->height=(brwin)->rgeom.height;\
- }\
- else{\
- (wgeom)->x=((((e)->area.x+(e)->area.width>=(brwin)->rgeom.x)&&\
- ((e)->area.x<=(brwin)->rgeom.x+(brwin)->rgeom.width))?\
- (((e)->area.x<=(brwin)->rgeom.x)?(brwin)->rgeom.x:(e)->area.x):-1);\
- \
- (wgeom)->y=((((e)->area.y+(e)->area.height>=(brwin)->rgeom.y)&&\
- ((e)->area.y<=(brwin)->rgeom.y+(brwin)->rgeom.height))?\
- (((e)->area.y<=(brwin)->rgeom.y)?(brwin)->rgeom.y:(e)->area.y):-1);\
- \
- (wgeom)->width=((e)->area.x<=(brwin)->rgeom.x)?\
- (e)->area.width-((brwin)->rgeom.x-(e)->area.x):\
- ((e)->area.x<=(brwin)->rgeom.x+(brwin)->rgeom.width)?\
- (((brwin)->rgeom.width-(e)->area.x+(brwin)->rgeom.x<(e)->area.width)?\
- (brwin)->rgeom.width-(e)->area.x+(brwin)->rgeom.x:e->area.width):-1;\
- \
- (wgeom)->height=((e)->area.y<=(brwin)->rgeom.y)?\
- (e)->area.height-((brwin)->rgeom.y-(e)->area.y):\
- ((e)->area.y<=(brwin)->rgeom.y+(brwin)->rgeom.height)?\
- (((brwin)->rgeom.height-(e)->area.y+\
- (brwin)->rgeom.y<(e)->area.height)?\
- (brwin)->rgeom.height-(e)->area.y+\
- (brwin)->rgeom.y:(e)->area.height):-1;\
- \
- if((wgeom)->width>(brwin)->rgeom.width)\
- (wgeom)->width=(brwin)->rgeom.width;\
- if((wgeom)->height>(brwin)->rgeom.height)\
- (wgeom)->height=(brwin)->rgeom.height;\
- }\
-}
-
-#define CLIP_DUMMY_POINTER_AREA(dummy_p_area,brwin,wgeom){\
- (wgeom)->x=((((dummy_p_area).x+\
- (dummy_p_area).width>=(brwin)->rgeom.x)&&\
- ((dummy_p_area).x<=(brwin)->rgeom.x+\
- (brwin)->rgeom.width))?\
- (((dummy_p_area).x<=(brwin)->rgeom.x)?\
- (brwin)->rgeom.x:(dummy_p_area).x):-1);\
- (wgeom)->y=((((dummy_p_area).y+\
- (dummy_p_area).height>=(brwin)->rgeom.y)&&\
- ((dummy_p_area).y<=(brwin)->rgeom.y+\
- (brwin)->rgeom.height))?\
- (((dummy_p_area).y<=(brwin)->rgeom.y)?\
- (brwin)->rgeom.y:(dummy_p_area).y):-1);\
- (wgeom)->width=((dummy_p_area).x<=(brwin)->rgeom.x)?\
- (dummy_p_area).width-\
- ((brwin)->rgeom.x-(dummy_p_area).x):\
- ((dummy_p_area).x<=(brwin)->rgeom.x+\
- (brwin)->rgeom.width)?\
- ((brwin)->rgeom.width-(dummy_p_area).x+\
- (brwin)->rgeom.x<(dummy_p_area).width)?\
- (brwin)->rgeom.width-(dummy_p_area).x+\
- (brwin)->rgeom.x:(dummy_p_area).width:-1;\
- (wgeom)->height=((dummy_p_area).y<=(brwin)->rgeom.y)?\
- (dummy_p_area).height-\
- ((brwin)->rgeom.y-(dummy_p_area).y):\
- ((dummy_p_area).y<=(brwin)->rgeom.y+\
- (brwin)->rgeom.height)?\
- ((brwin)->rgeom.height-(dummy_p_area).y+\
- (brwin)->rgeom.y<(dummy_p_area).height)?\
- (brwin)->rgeom.height-(dummy_p_area).y+\
- (brwin)->rgeom.y:(dummy_p_area).height:-1;\
- if((wgeom)->width>(brwin)->rgeom.width)\
- (wgeom)->width=(brwin)->rgeom.width;\
- if((wgeom)->height>(brwin)->rgeom.height)\
- (wgeom)->height=(brwin)->rgeom.height;\
-}
-
-
-
#define DEFAULT_ARGS(args){\
(args)->delay=0;\
if(getenv("DISPLAY")!=NULL){\
@@ -235,18 +143,6 @@
strcpy((args)->stop_shortcut,"Control+Mod1+s");\
}
-#define QUERY_DISPLAY_SPECS(display,specstruct){\
- (specstruct)->screen=DefaultScreen(display);\
- (specstruct)->width=DisplayWidth(display,(specstruct)->screen);\
- (specstruct)->height=DisplayHeight(display,(specstruct)->screen);\
- (specstruct)->root=RootWindow(display,(specstruct)->screen);\
- (specstruct)->visual=DefaultVisual(display,(specstruct)->screen);\
- (specstruct)->gc=DefaultGC(display,(specstruct)->screen);\
- (specstruct)->depth=DefaultDepth(display,(specstruct)->screen);\
- (specstruct)->bpixel=XBlackPixel(display,(specstruct)->screen);\
- (specstruct)->wpixel=XWhitePixel(display,(specstruct)->screen);\
-}
-
#define AVG_4_PIXELS(data_array,width_img,k_tm,i_tm,offset)\
((data_array[(k_tm*width_img+i_tm)*RMD_ULONG_SIZE_T+offset]+\
data_array[((k_tm-1)*width_img+i_tm)*RMD_ULONG_SIZE_T+offset]+\
@@ -550,58 +446,6 @@
-#define XFIXES_POINTER_TO_YUV(yuv,\
- data,\
- x_tm,\
- y_tm,\
- width_tm,\
- height_tm,\
- x_offset,\
- y_offset,\
- column_discard_stride){\
- int i,k,j=0;\
- unsigned char avg0,avg1,avg2,avg3;\
- int x_2=x_tm/2,y_2=y_tm/2;\
- for(k=y_offset;k<y_offset+height_tm;k++){\
- for(i=x_offset;i<x_offset+width_tm;i++){\
- j=k*(width_tm+column_discard_stride)+i;\
- yuv->y[x_tm+(i-x_offset)+(k+y_tm-y_offset)*yuv->y_width]=\
- (yuv->y[x_tm+(i-x_offset)+(k-y_offset+y_tm)*yuv->y_width]*\
- (UCHAR_MAX-data[(j*RMD_ULONG_SIZE_T)+__ABYTE])+\
- (Yr[data[(j*RMD_ULONG_SIZE_T)+__RBYTE]]+\
- Yg[data[(j*RMD_ULONG_SIZE_T)+__GBYTE]] +\
- Yb[data[(j*RMD_ULONG_SIZE_T)+__BBYTE]])*\
- data[(j*RMD_ULONG_SIZE_T)+__ABYTE])/UCHAR_MAX ;\
- if((k%2)&&(i%2)){\
- avg3=AVG_4_PIXELS(data,\
- (width_tm+column_discard_stride),\
- k,i,__ABYTE);\
- avg2=AVG_4_PIXELS(data,\
- (width_tm+column_discard_stride),\
- k,i,__RBYTE);\
- avg1=AVG_4_PIXELS(data,\
- (width_tm+column_discard_stride),\
- k,i,__GBYTE);\
- avg0=AVG_4_PIXELS(data,\
- (width_tm+column_discard_stride),\
- k,i,__BBYTE);\
- yuv->u[x_2+(i-x_offset)/2+((k-y_offset)/2+y_2)*\
- yuv->uv_width]=\
- (yuv->u[x_2+(i-x_offset)/2+((k-y_offset)/2+y_2)*\
- yuv->uv_width]*\
- (UCHAR_MAX-avg3)+\
- (Ur[avg2] + Ug[avg1] +UbVr[avg0])*avg3)/UCHAR_MAX;\
- yuv->v[x_2+(i-x_offset)/2+((k-y_offset)/2+y_2)*\
- yuv->uv_width]=\
- (yuv->v[x_2+(i-x_offset)/2+((k-y_offset)/2+y_2)*\
- yuv->uv_width]*\
- (UCHAR_MAX-avg3)+\
- (UbVr[avg2] + Vg[avg1] +Vb[avg0])*avg3)/UCHAR_MAX;\
- }\
- }\
- }\
-}
-
#define DUMMY_POINTER_TO_YUV(yuv,\
data_tm,\
x_tm,\
@@ -636,34 +480,6 @@
}\
}
-#define MARK_BACK_BUFFER( data,\
- x_tm,\
- y_tm,\
- width_tm,\
- height_tm,\
- buffer_width,\
- __bit_depth__){\
- if((__bit_depth__==24)||(__bit_depth__==32)){\
- MARK_BACK_BUFFER_C( data,\
- x_tm,\
- y_tm,\
- width_tm,\
- height_tm,\
- buffer_width,\
- 32)\
- }\
- else{\
- MARK_BACK_BUFFER_C( data,\
- x_tm,\
- y_tm,\
- width_tm,\
- height_tm,\
- buffer_width,\
- 16)\
- }\
-}\
-
-
#define MARK_BACK_BUFFER_C( data,\
x_tm,\
y_tm,\
@@ -701,36 +517,11 @@
free(t_buf);\
};\
-#define INIT_FRAME(frame_t,fheader_t,yuv_t,\
- YBlocks_t,UBlocks_t,VBlocks_t){\
- (frame_t)->header=(fheader_t);\
- (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)->YData);\
free((frame_t)->UData);\
free((frame_t)->VData);\
};
-#ifdef HAVE_JACK_H
-
-#define CHECK_DLERRORS_FATAL(__error_p)\
- if((__error_p=dlerror())!=NULL){\
- fprintf(stderr,"%s\n",__error_p);\
- return 1;\
- }
-
-#define DLSYM_AND_CHECK(lib_handle,__call_name__,__error_p)\
- __call_name__##_p=dlsym(lib_handle,#__call_name__);\
- CHECK_DLERRORS_FATAL(__error_p)
-
-#endif
-
#endif
diff --git a/recordmydesktop/include/rmdtypes.h b/recordmydesktop/include/rmdtypes.h
index db1e430..08e72dd 100644
--- a/recordmydesktop/include/rmdtypes.h
+++ b/recordmydesktop/include/rmdtypes.h
@@ -371,20 +371,5 @@ typedef struct _FrameHeader{
Vnum; //number of changed blocks in the V plane
}FrameHeader;
-//The frame after retrieval.
-//Based on the Header information
-//we can read the correct amount of bytes.
-
-
-typedef struct _CachedFrame{
- FrameHeader *header;
- u_int32_t *YBlocks, //identifying number on the grid,
- *UBlocks, //starting at top left
- *VBlocks; // >> >>
- unsigned char *YData, //pointer to data for the blocks that have changed,
- *UData, //which have to be remapped
- *VData; //on the buffer when reading
-}CachedFrame;
-
#endif
diff --git a/recordmydesktop/src/cache_frame.c b/recordmydesktop/src/cache_frame.c
index 327318b..5e75700 100644
--- a/recordmydesktop/src/cache_frame.c
+++ b/recordmydesktop/src/cache_frame.c
@@ -27,6 +27,12 @@
#include <recordmydesktop.h>
+//minimize hard disk access
+#define CACHE_OUT_BUFFER_SIZE 4096
+//500 mb file size
+#define CACHE_FILE_SIZE_LIMIT (500*1<<20)
+
+
int FlushBlock(unsigned char *buf,
int blockno,
int width,
diff --git a/recordmydesktop/src/get_frame.c b/recordmydesktop/src/get_frame.c
index f20c995..fd4eda8 100644
--- a/recordmydesktop/src/get_frame.c
+++ b/recordmydesktop/src/get_frame.c
@@ -28,6 +28,123 @@
#include <recordmydesktop.h>
+#define CLIP_DUMMY_POINTER_AREA(dummy_p_area,brwin,wgeom){\
+ (wgeom)->x=((((dummy_p_area).x+\
+ (dummy_p_area).width>=(brwin)->rgeom.x)&&\
+ ((dummy_p_area).x<=(brwin)->rgeom.x+\
+ (brwin)->rgeom.width))?\
+ (((dummy_p_area).x<=(brwin)->rgeom.x)?\
+ (brwin)->rgeom.x:(dummy_p_area).x):-1);\
+ (wgeom)->y=((((dummy_p_area).y+\
+ (dummy_p_area).height>=(brwin)->rgeom.y)&&\
+ ((dummy_p_area).y<=(brwin)->rgeom.y+\
+ (brwin)->rgeom.height))?\
+ (((dummy_p_area).y<=(brwin)->rgeom.y)?\
+ (brwin)->rgeom.y:(dummy_p_area).y):-1);\
+ (wgeom)->width=((dummy_p_area).x<=(brwin)->rgeom.x)?\
+ (dummy_p_area).width-\
+ ((brwin)->rgeom.x-(dummy_p_area).x):\
+ ((dummy_p_area).x<=(brwin)->rgeom.x+\
+ (brwin)->rgeom.width)?\
+ ((brwin)->rgeom.width-(dummy_p_area).x+\
+ (brwin)->rgeom.x<(dummy_p_area).width)?\
+ (brwin)->rgeom.width-(dummy_p_area).x+\
+ (brwin)->rgeom.x:(dummy_p_area).width:-1;\
+ (wgeom)->height=((dummy_p_area).y<=(brwin)->rgeom.y)?\
+ (dummy_p_area).height-\
+ ((brwin)->rgeom.y-(dummy_p_area).y):\
+ ((dummy_p_area).y<=(brwin)->rgeom.y+\
+ (brwin)->rgeom.height)?\
+ ((brwin)->rgeom.height-(dummy_p_area).y+\
+ (brwin)->rgeom.y<(dummy_p_area).height)?\
+ (brwin)->rgeom.height-(dummy_p_area).y+\
+ (brwin)->rgeom.y:(dummy_p_area).height:-1;\
+ if((wgeom)->width>(brwin)->rgeom.width)\
+ (wgeom)->width=(brwin)->rgeom.width;\
+ if((wgeom)->height>(brwin)->rgeom.height)\
+ (wgeom)->height=(brwin)->rgeom.height;\
+}
+
+#define XFIXES_POINTER_TO_YUV(yuv,\
+ data,\
+ x_tm,\
+ y_tm,\
+ width_tm,\
+ height_tm,\
+ x_offset,\
+ y_offset,\
+ column_discard_stride){\
+ int i,k,j=0;\
+ unsigned char avg0,avg1,avg2,avg3;\
+ int x_2=x_tm/2,y_2=y_tm/2;\
+ for(k=y_offset;k<y_offset+height_tm;k++){\
+ for(i=x_offset;i<x_offset+width_tm;i++){\
+ j=k*(width_tm+column_discard_stride)+i;\
+ yuv->y[x_tm+(i-x_offset)+(k+y_tm-y_offset)*yuv->y_width]=\
+ (yuv->y[x_tm+(i-x_offset)+(k-y_offset+y_tm)*yuv->y_width]*\
+ (UCHAR_MAX-data[(j*RMD_ULONG_SIZE_T)+__ABYTE])+\
+ (Yr[data[(j*RMD_ULONG_SIZE_T)+__RBYTE]]+\
+ Yg[data[(j*RMD_ULONG_SIZE_T)+__GBYTE]] +\
+ Yb[data[(j*RMD_ULONG_SIZE_T)+__BBYTE]])*\
+ data[(j*RMD_ULONG_SIZE_T)+__ABYTE])/UCHAR_MAX ;\
+ if((k%2)&&(i%2)){\
+ avg3=AVG_4_PIXELS(data,\
+ (width_tm+column_discard_stride),\
+ k,i,__ABYTE);\
+ avg2=AVG_4_PIXELS(data,\
+ (width_tm+column_discard_stride),\
+ k,i,__RBYTE);\
+ avg1=AVG_4_PIXELS(data,\
+ (width_tm+column_discard_stride),\
+ k,i,__GBYTE);\
+ avg0=AVG_4_PIXELS(data,\
+ (width_tm+column_discard_stride),\
+ k,i,__BBYTE);\
+ yuv->u[x_2+(i-x_offset)/2+((k-y_offset)/2+y_2)*\
+ yuv->uv_width]=\
+ (yuv->u[x_2+(i-x_offset)/2+((k-y_offset)/2+y_2)*\
+ yuv->uv_width]*\
+ (UCHAR_MAX-avg3)+\
+ (Ur[avg2] + Ug[avg1] +UbVr[avg0])*avg3)/UCHAR_MAX;\
+ yuv->v[x_2+(i-x_offset)/2+((k-y_offset)/2+y_2)*\
+ yuv->uv_width]=\
+ (yuv->v[x_2+(i-x_offset)/2+((k-y_offset)/2+y_2)*\
+ yuv->uv_width]*\
+ (UCHAR_MAX-avg3)+\
+ (UbVr[avg2] + Vg[avg1] +Vb[avg0])*avg3)/UCHAR_MAX;\
+ }\
+ }\
+ }\
+}
+
+#define MARK_BACK_BUFFER( data,\
+ x_tm,\
+ y_tm,\
+ width_tm,\
+ height_tm,\
+ buffer_width,\
+ __bit_depth__){\
+ if((__bit_depth__==24)||(__bit_depth__==32)){\
+ MARK_BACK_BUFFER_C( data,\
+ x_tm,\
+ y_tm,\
+ width_tm,\
+ height_tm,\
+ buffer_width,\
+ 32)\
+ }\
+ else{\
+ MARK_BACK_BUFFER_C( data,\
+ x_tm,\
+ y_tm,\
+ width_tm,\
+ height_tm,\
+ buffer_width,\
+ 16)\
+ }\
+}\
+
+
//besides taking the first screenshot, this functions primary purpose is to
//initialize the structures and memory.
int FirstFrame(ProgData *pdata,XImage **image,XShmSegmentInfo *shminfo,
diff --git a/recordmydesktop/src/load_cache.c b/recordmydesktop/src/load_cache.c
index 6973770..020e90f 100644
--- a/recordmydesktop/src/load_cache.c
+++ b/recordmydesktop/src/load_cache.c
@@ -27,6 +27,43 @@
#include <recordmydesktop.h>
+
+//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 INIT_FRAME(frame_t,fheader_t,yuv_t,\
+ YBlocks_t,UBlocks_t,VBlocks_t){\
+ (frame_t)->header=(fheader_t);\
+ (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);\
+};
+
+
+//The frame after retrieval.
+//Based on the Header information
+//we can read the correct amount of bytes.
+typedef struct _CachedFrame{
+ FrameHeader *header;
+ u_int32_t *YBlocks, //identifying number on the grid,
+ *UBlocks, //starting at top left
+ *VBlocks; // >> >>
+ unsigned char *YData, //pointer to data for the blocks that have changed,
+ *UData, //which have to be remapped
+ *VData; //on the buffer when reading
+}CachedFrame;
+
+
void LoadBlock(unsigned char *dest,
unsigned char *source,
int blockno,
diff --git a/recordmydesktop/src/poll_events.c b/recordmydesktop/src/poll_events.c
index fbe862c..7168a5a 100644
--- a/recordmydesktop/src/poll_events.c
+++ b/recordmydesktop/src/poll_events.c
@@ -40,6 +40,46 @@
#include <rmdmacro.h>
+#define CLIP_EVENT_AREA(e,brwin,wgeom){\
+ if(((e)->area.x<=(brwin)->rgeom.x)&&((e)->area.y<=(brwin)->rgeom.y)&&\
+ ((e)->area.width>=(brwin)->rgeom.width)&&\
+ ((e)->area.height<(brwin)->rgeom.height)){\
+ (wgeom)->x=(brwin)->rgeom.x;\
+ (wgeom)->y=(brwin)->rgeom.y;\
+ (wgeom)->width=(brwin)->rgeom.width;\
+ (wgeom)->height=(brwin)->rgeom.height;\
+ }\
+ else{\
+ (wgeom)->x=((((e)->area.x+(e)->area.width>=(brwin)->rgeom.x)&&\
+ ((e)->area.x<=(brwin)->rgeom.x+(brwin)->rgeom.width))?\
+ (((e)->area.x<=(brwin)->rgeom.x)?(brwin)->rgeom.x:(e)->area.x):-1);\
+ \
+ (wgeom)->y=((((e)->area.y+(e)->area.height>=(brwin)->rgeom.y)&&\
+ ((e)->area.y<=(brwin)->rgeom.y+(brwin)->rgeom.height))?\
+ (((e)->area.y<=(brwin)->rgeom.y)?(brwin)->rgeom.y:(e)->area.y):-1);\
+ \
+ (wgeom)->width=((e)->area.x<=(brwin)->rgeom.x)?\
+ (e)->area.width-((brwin)->rgeom.x-(e)->area.x):\
+ ((e)->area.x<=(brwin)->rgeom.x+(brwin)->rgeom.width)?\
+ (((brwin)->rgeom.width-(e)->area.x+(brwin)->rgeom.x<(e)->area.width)?\
+ (brwin)->rgeom.width-(e)->area.x+(brwin)->rgeom.x:e->area.width):-1;\
+ \
+ (wgeom)->height=((e)->area.y<=(brwin)->rgeom.y)?\
+ (e)->area.height-((brwin)->rgeom.y-(e)->area.y):\
+ ((e)->area.y<=(brwin)->rgeom.y+(brwin)->rgeom.height)?\
+ (((brwin)->rgeom.height-(e)->area.y+\
+ (brwin)->rgeom.y<(e)->area.height)?\
+ (brwin)->rgeom.height-(e)->area.y+\
+ (brwin)->rgeom.y:(e)->area.height):-1;\
+ \
+ if((wgeom)->width>(brwin)->rgeom.width)\
+ (wgeom)->width=(brwin)->rgeom.width;\
+ if((wgeom)->height>(brwin)->rgeom.height)\
+ (wgeom)->height=(brwin)->rgeom.height;\
+ }\
+}
+
+
void InitEventsPolling(ProgData *pdata){
Window root_return,
parent_return,
diff --git a/recordmydesktop/src/recordmydesktop.c b/recordmydesktop/src/recordmydesktop.c
index 49ce0ca..c919690 100644
--- a/recordmydesktop/src/recordmydesktop.c
+++ b/recordmydesktop/src/recordmydesktop.c
@@ -28,6 +28,19 @@
#include <recordmydesktop.h>
+#define QUERY_DISPLAY_SPECS(display,specstruct){\
+ (specstruct)->screen=DefaultScreen(display);\
+ (specstruct)->width=DisplayWidth(display,(specstruct)->screen);\
+ (specstruct)->height=DisplayHeight(display,(specstruct)->screen);\
+ (specstruct)->root=RootWindow(display,(specstruct)->screen);\
+ (specstruct)->visual=DefaultVisual(display,(specstruct)->screen);\
+ (specstruct)->gc=DefaultGC(display,(specstruct)->screen);\
+ (specstruct)->depth=DefaultDepth(display,(specstruct)->screen);\
+ (specstruct)->bpixel=XBlackPixel(display,(specstruct)->screen);\
+ (specstruct)->wpixel=XWhitePixel(display,(specstruct)->screen);\
+}
+
+
int main(int argc,char **argv){
ProgData pdata;
diff --git a/recordmydesktop/src/rectinsert.c b/recordmydesktop/src/rectinsert.c
index 1eaa9ef..8685fbb 100644
--- a/recordmydesktop/src/rectinsert.c
+++ b/recordmydesktop/src/rectinsert.c
@@ -26,15 +26,35 @@
#include <recordmydesktop.h>
-//return 1 and null if geom1 in geom2 ,2 and null if geom2 in geom1,
-//0 if they don't collide
-//-1 and two geoms if they collide and geom1 is broken.
-//-2 and one or two geoms if they collide and geom2 is broken.
-//-10 if group and replace is possible
-int CollideRects(WGeometry *wgeom1,
- WGeometry *wgeom2,
- WGeometry **wgeom_return,
- int *ngeoms){
+
+/**
+* Collide two rectangles and dictate most sane action for insertion,
+* as well as provide the updated rectangle(s)
+* \param wgeom1 resident rectangle
+*
+* \param wgeom2 New rectangle
+*
+* \param wgeom_return Pointer to rectangles to be inserted
+*
+* \param ngeoms number of entries in wgeom_return
+*
+* \retval 0 No collision
+*
+* \retval 1 wgeom1 is covered by wgeom2
+*
+* \retval 2 wgeom2 is covered by wgeom1
+*
+* \retval -1 wgeom1 was broken (new is picked up in wgeom_return)
+*
+* \retval -2 wgeom2 was broken (new is picked up in wgeom_return)
+*
+* \retval -10 Grouping the two geoms is possible
+*
+*/
+static int CollideRects(WGeometry *wgeom1,
+ WGeometry *wgeom2,
+ WGeometry **wgeom_return,
+ int *ngeoms) {
//1 fits in 2
if((wgeom1->x>=wgeom2->x)&&
(wgeom1->x+wgeom1->width<=wgeom2->x+wgeom2->width)&&
diff --git a/recordmydesktop/src/rmd_cache.c b/recordmydesktop/src/rmd_cache.c
index 1c22349..ad4388f 100644
--- a/recordmydesktop/src/rmd_cache.c
+++ b/recordmydesktop/src/rmd_cache.c
@@ -27,7 +27,17 @@
#include <recordmydesktop.h>
-void CacheFileN(char *name,char **newname,int n){//nth cache file
+/**
+*Construct an number postfixed name
+*
+* \param name base name
+*
+* \param newname modified name
+*
+* \n number to be used as a postfix
+*
+*/
+static void CacheFileN(char *name, char **newname, int n) { // Nth cache file
char numbuf[8];
strcpy(*newname,name);
strcat(*newname,".");
diff --git a/recordmydesktop/src/rmd_jack.c b/recordmydesktop/src/rmd_jack.c
index 05bcf1a..aacb883 100644
--- a/recordmydesktop/src/rmd_jack.c
+++ b/recordmydesktop/src/rmd_jack.c
@@ -28,7 +28,65 @@
#include <recordmydesktop.h>
#ifdef HAVE_JACK_H
-int JackCapture(jack_nframes_t nframes,void *jdata_t){
+
+
+#define CHECK_DLERRORS_FATAL(__error_p)\
+ if((__error_p=dlerror())!=NULL){\
+ fprintf(stderr,"%s\n",__error_p);\
+ return 1;\
+ }
+
+#define DLSYM_AND_CHECK(lib_handle,__call_name__,__error_p)\
+ __call_name__##_p=dlsym(lib_handle,#__call_name__);\
+ CHECK_DLERRORS_FATAL(__error_p)
+
+
+/**
+*
+* Fuction Pointers To Jack API Calls (shouldn't a jack header provide these?)
+*
+*/
+jack_client_t *(*jack_client_new_p)(const char *client_name);
+jack_nframes_t (*jack_get_sample_rate_p)(jack_client_t * client);
+int (*jack_set_buffer_size_p)(jack_client_t *client, jack_nframes_t nframes);
+jack_nframes_t (*jack_get_buffer_size_p)(jack_client_t *client);
+int (*jack_set_process_callback_p)(jack_client_t *client,
+ JackProcessCallback process_callback,
+ void *arg);
+void (*jack_on_shutdown_p)(jack_client_t *client,
+ void(*function)(void *arg),
+ void *arg);
+int (*jack_activate_p)(jack_client_t *client);
+int (*jack_client_close_p)(jack_client_t *client);
+void *(*jack_port_get_buffer_p)(jack_port_t *port,jack_nframes_t);
+jack_port_t *(*jack_port_register_p)(jack_client_t *client,
+ const char *port_name,
+ const char *port_type,
+ unsigned long flags,
+ unsigned long buffer_size);
+int (*jack_connect_p)(jack_client_t *client,
+ const char *source_port,
+ const char *destination_port);
+const char *(*jack_port_name_p)(const jack_port_t *port);
+int (*jack_port_name_size_p)(void);
+jack_ringbuffer_t *(*jack_ringbuffer_create_p)(size_t sz);
+void (*jack_ringbuffer_free_p)(jack_ringbuffer_t *rb);
+size_t (*jack_ringbuffer_write_p)(jack_ringbuffer_t *rb,
+ const char *src,
+ size_t cnt);
+
+
+/**
+* Callback for capture through jack
+*
+* \param nframes Number of frames captured
+*
+* \param jdata_t Pointer to JackData struct containing port
+* and client information
+*
+* \returns Zero always
+*/
+static int JackCapture(jack_nframes_t nframes,void *jdata_t) {
int i=0;
JackData *jdata=(JackData *)jdata_t;
@@ -59,7 +117,15 @@ int JackCapture(jack_nframes_t nframes,void *jdata_t){
return 0;
}
-int SetupPorts(JackData *jdata){
+/**
+* Register and Activate specified ports
+*
+* \param jdata_t Pointer to JackData struct containing port
+* and client information
+*
+* \returns 0 on Success, 1 on failure
+*/
+static int SetupPorts(JackData *jdata) {
int i=0;
jdata->ports=malloc(sizeof(jack_port_t *)*
jdata->nports);
@@ -94,7 +160,14 @@ int SetupPorts(JackData *jdata){
return 0;
}
-int LoadJackLib(void *jack_lib_handle){
+/**
+* dlopen libjack and dlsym all needed functions
+*
+* \param jack_lib_handle Pointer to handle for jack library
+*
+* \returns 0 on Success, 1 on failure
+*/
+static int LoadJackLib(void *jack_lib_handle) {
char *error;
jack_lib_handle=dlopen("libjack.so",RTLD_LAZY);
if(!jack_lib_handle){
@@ -126,6 +199,7 @@ int LoadJackLib(void *jack_lib_handle){
return 0;
}
+
//in case the jack server shuts down
//the program should stop recording,
//encode the result(if not on the fly)
diff --git a/recordmydesktop/src/setbrwindow.c b/recordmydesktop/src/setbrwindow.c
index 8c8b973..94c1fa0 100644
--- a/recordmydesktop/src/setbrwindow.c
+++ b/recordmydesktop/src/setbrwindow.c
@@ -26,7 +26,20 @@
#include <recordmydesktop.h>
-void SizePack2_8_16(int *start,int *size,int limit){
+
+/**
+*Align the recording window to a divisible by 2 pixel start and
+*and a size divisible by 16.
+*
+* \param start x or y of the recording window
+*
+* \param size width or height of the recording window
+*
+* \param limit width or height of the Display
+*
+* \note This is called separately for width and height.
+*/
+static void SizePack2_8_16(int *start, int *size, int limit) {
int octoffset,hexoffset;
//align in two
© All Rights Reserved