diff options
author | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2007-01-21 18:05:14 +0000 |
---|---|---|
committer | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2007-01-21 18:05:14 +0000 |
commit | c8beaf22577ee69de28898382d74673a9edcf395 (patch) | |
tree | ca4c00ae4bc56efd3e52a861c1e9396d3c15a173 /recordmydesktop/include | |
parent | 4613054faf335a84ab8f413506f4b75bbd72e5eb (diff) |
changed formatting of the code, to never go beyond column 80
(rule is purely for visual purposes, macro expansions are not taken into account).
git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@262 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'recordmydesktop/include')
-rw-r--r-- | recordmydesktop/include/recordmydesktop.h | 54 | ||||
-rw-r--r-- | recordmydesktop/include/rmdfunc.h | 119 | ||||
-rw-r--r-- | recordmydesktop/include/rmdmacro.h | 222 | ||||
-rw-r--r-- | recordmydesktop/include/rmdtypes.h | 224 |
4 files changed, 374 insertions, 245 deletions
diff --git a/recordmydesktop/include/recordmydesktop.h b/recordmydesktop/include/recordmydesktop.h index ed522db..e97a8c0 100644 --- a/recordmydesktop/include/recordmydesktop.h +++ b/recordmydesktop/include/recordmydesktop.h @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 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 * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 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 RECORDMYDESKTOP_H @@ -48,8 +48,8 @@ unsigned char Yr[256],Yg[256],Yb[256], Vr[256],Vg[256],Vb[256]; //the following values are of no effect //but they might be usefull later for profiling -unsigned int frames_total,//frames calculated by total time expirations - frames_lost;//the value of shame +unsigned int frames_total, //frames calculated by total time expirations + frames_lost; //the value of shame //used to determine frame drop which can //happen on failure to receive a signal over a condition variable int capture_busy, diff --git a/recordmydesktop/include/rmdfunc.h b/recordmydesktop/include/rmdfunc.h index 447351a..a4908d5 100644 --- a/recordmydesktop/include/rmdfunc.h +++ b/recordmydesktop/include/rmdfunc.h @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 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 * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 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 RMDFUNC_H #define RMDFUNC_H 1 @@ -107,7 +107,10 @@ int RectInsert(RectArea **root,WGeometry *wgeom); * \retval -10 Grouping the two geoms is possible * */ -int CollideRects(WGeometry *wgeom1,WGeometry *wgeom2,WGeometry **wgeom_return,int *ngeoms); +int CollideRects(WGeometry *wgeom1, + WGeometry *wgeom2, + WGeometry **wgeom_return, + int *ngeoms); /** * Broadcast time condition variable, increment frame count. @@ -132,7 +135,8 @@ void RegisterCallbacks(ProgArgs *args); * * \param yuv_mutex lock on the buffer * -* \param specs DisplaySpecs struct with information about the display to be recorded +* \param specs DisplaySpecs struct with +* information about the display to be recorded * * \param root Root entry of the list with damaged areas * @@ -140,7 +144,8 @@ void RegisterCallbacks(ProgArgs *args); * * \param enc Encoding options * -* \param datatemp Buffer for pixel data to be retrieved before placed on the yuv buffer +* \param datatemp Buffer for pixel data to be +* retrieved before placed on the yuv buffer * * \param noshmem don't use MIT_Shm extension * @@ -181,7 +186,13 @@ void UpdateImage(Display * dpy, * * \returns 0 on Success 1 on Failure */ -int GetZPixmap(Display *dpy,Window root,char *data,int x,int y,int width,int height); +int GetZPixmap(Display *dpy, + Window root, + char *data, + int x, + int y, + int width, + int height); /** * Fill ProgArgs struct with arguments entered at execution @@ -209,7 +220,10 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return); * * \note Can be an exit point if extensions are not found */ -void QueryExtensions(Display *dpy,ProgArgs *args,int *damage_event,int *damage_error); +void QueryExtensions(Display *dpy, + ProgArgs *args, + int *damage_event, + int *damage_error); /** * Check and align window size @@ -218,43 +232,53 @@ void QueryExtensions(Display *dpy,ProgArgs *args,int *damage_event,int *damage_e * * \param brwin BRWindow struct contaning the initial and final window * -* \param specs DisplaySpecs struct with information about the display to be recorded +* \param specs DisplaySpecs struct with +* information about the display to be recorded * * \param args ProgArgs struct containing the user-set options * * \returns 0 on Success 1 on Failure */ -int SetBRWindow(Display *dpy,BRWindow *brwin,DisplaySpecs *specs,ProgArgs *args); +int SetBRWindow(Display *dpy, + BRWindow *brwin, + DisplaySpecs *specs, + ProgArgs *args); /** * Create an array containing the data for the dummy pointer * -* \param specs DisplaySpecs struct with information about the display to be recorded +* \param specs DisplaySpecs struct with +* information about the display to be recorded * -* \param size Pointer size, always square, always 16.(exists only for the possibility to create -* more dummy cursors) +* \param size Pointer size, always square, always 16.(exists only +* for the possibility to create more dummy cursors) * \param color 0 white, 1 black * * \param type Always 0.(exists only for the possibility to create * more dummy cursors) * -* \param npxl Return of pixel value that denotes non-drawing, while applying the cursor -* on the target image +* \param npxl Return of pixel value that denotes non-drawing, while +* applying the cursor on the target image * * \returns Pointer to pixel data of the cursor */ -unsigned char *MakeDummyPointer(DisplaySpecs *specs,int size,int color,int type,unsigned char *npxl); +unsigned char *MakeDummyPointer(DisplaySpecs *specs, + int size, + int color, + int type, + unsigned char *npxl); /** -* Sound capturing thread. Data are placed on a list to be picked up by other threads. +* Sound capturing thread. Data are placed on a +* list to be picked up by other threads. * * \param pdata ProgData struct containing all program data */ void *CaptureSound(ProgData *pdata); /** -* Sound encoding thread. Picks up data from the buffer queue , encodes and places them -* on the vorbis stream. +* Sound encoding thread. Picks up data from the buffer queue , +* encodes and places them on the vorbis stream. * * \param pdata ProgData struct containing all program data */ @@ -266,7 +290,8 @@ void *EncodeSoundBuffer(ProgData *pdata); * * \param pcm_dev name of the device * -* \param channels desired number of channels(gets modified with the acieved value) +* \param channels desired number of channels +* (gets modified with the acieved value) * * \param frequency desired frequency(gets modified with the acieved value) * @@ -339,7 +364,9 @@ void *CacheImageBuffer(ProgData *pdata); * \param cache_data_t Caching options * */ -void InitCacheData(ProgData *pdata,EncData *enc_data_t,CacheData *cache_data_t); +void InitCacheData(ProgData *pdata, + EncData *enc_data_t, + CacheData *cache_data_t); /** * Sound caching thread. Simply writes the pcm buffers on disk @@ -358,7 +385,8 @@ void *CacheSoundBuffer(ProgData *pdata); void *LoadCache(ProgData *pdata); /** -* As EncodeImageBuffer, only with the assumption that this is not a thread on it's own +* As EncodeImageBuffer, only with the assumption that +* this is not a thread on it's own * * \param pdata ProgData struct containing all program data * @@ -371,7 +399,8 @@ void SyncEncodeImageBuffer(ProgData *pdata); void CancelTimer(void); /** -* As EncodeSoundBuffer, only with the assumption that this is not a thread on it's own +* As EncodeSoundBuffer, only with the assumption that +* this is not a thread on it's own * * \param pdata ProgData struct containing all program data * diff --git a/recordmydesktop/include/rmdmacro.h b/recordmydesktop/include/rmdmacro.h index 3576a3b..87ac39f 100644 --- a/recordmydesktop/include/rmdmacro.h +++ b/recordmydesktop/include/rmdmacro.h @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 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 * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 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 RMDMACRO_H #define RMDMACRO_H 1 @@ -75,7 +75,8 @@ #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)){\ + ((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;\ @@ -99,33 +100,53 @@ (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;\ + (((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;\ + 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)->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;\ + (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;\ + (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;\ } @@ -221,13 +242,21 @@ (t3&__B16_MASK)+(t4&__B16_MASK))/4)&__B16_MASK);\ } -#define UPDATE_Y_PLANE(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,__bit_depth__){ \ +#define UPDATE_Y_PLANE(data,\ + x_tm,\ + y_tm,\ + height_tm,\ + width_tm,\ + yuv,\ + __copy_type,\ + __bit_depth__){ \ int k,i;\ register RMD_TYPE_##__bit_depth__ 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+\ - ((__copy_type==__X_SHARED)?(x_tm+y_tm*yuv->y_width):0);\ + register RMD_TYPE_##__bit_depth__ *datapi=(RMD_TYPE_##__bit_depth__ *)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;\ @@ -243,16 +272,25 @@ }\ } -#define UPDATE_UV_PLANES(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,__sampling_type,__bit_depth__){ \ +#define UPDATE_UV_PLANES(data,\ + x_tm,\ + y_tm,\ + height_tm,\ + width_tm,\ + yuv,\ + __copy_type,\ + __sampling_type,\ + __bit_depth__){ \ int k,i;\ register RMD_TYPE_##__bit_depth__ 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+\ - ((__copy_type==__X_SHARED)?(x_tm+y_tm*yuv->y_width):0),\ - *datapi_next=NULL;\ + register RMD_TYPE_##__bit_depth__ *datapi=(RMD_TYPE_##__bit_depth__ *)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));\ @@ -280,40 +318,69 @@ }\ 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);\ + 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);\ + 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){\ +#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(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,32)\ - UPDATE_UV_PLANES(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,__sampling_type,32)\ + UPDATE_UV_PLANES(data,x_tm,y_tm,height_tm,width_tm,\ + yuv,__copy_type,__sampling_type,32)\ }\ else if(__color_depth==16){\ UPDATE_Y_PLANE(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,16)\ - UPDATE_UV_PLANES(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,__sampling_type,16)\ + UPDATE_UV_PLANES(data,x_tm,y_tm,height_tm,width_tm,\ + yuv,__copy_type,__sampling_type,16)\ }\ } -#define XFIXES_POINTER_TO_YUV(yuv,data,x_tm,y_tm,width_tm,height_tm,column_discard_stride){\ +#define XFIXES_POINTER_TO_YUV(yuv,\ + data,\ + x_tm,\ + y_tm,\ + width_tm,\ + height_tm,\ + 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=0;k<height_tm;k++){\ for(i=0;i<width_tm;i++){\ yuv->y[x_tm+i+(k+y_tm)*yuv->y_width]=\ - (yuv->y[x_tm+i+(k+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 ;\ + (yuv->y[x_tm+i+(k+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);\ + 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/2+(k/2+y_2)*yuv->uv_width]=\ (yuv->u[x_2+i/2+(k/2+y_2)*yuv->uv_width]*(UCHAR_MAX-avg3)+\ (Ur[avg2] + Ug[avg1] +Ub[avg0])*avg3)/UCHAR_MAX;\ @@ -327,16 +394,31 @@ }\ } -#define DUMMY_POINTER_TO_YUV(yuv,data_tm,x_tm,y_tm,width_tm,height_tm,no_pixel){\ +#define DUMMY_POINTER_TO_YUV(yuv,\ + data_tm,\ + x_tm,\ + y_tm,\ + width_tm,\ + height_tm,\ + no_pixel){\ int i,k,j=0;\ int x_2=x_tm/2,y_2=y_tm/2,y_width_2=(yuv)->y_width/2;\ for(k=0;k<height_tm;k++){\ for(i=0;i<width_tm;i++){\ if(data_tm[(j*4)]!=(no_pixel)){\ - (yuv)->y[x_tm+i+(k+y_tm)*(yuv)->y_width]=Yr[data_tm[(j*4)+__RBYTE]] + Yg[data_tm[(j*4)+__GBYTE]] + Yb[data_tm[(j*4)+__BBYTE]];\ + (yuv)->y[x_tm+i+(k+y_tm)*(yuv)->y_width]=\ + Yr[data_tm[(j*4)+__RBYTE]] +\ + Yg[data_tm[(j*4)+__GBYTE]] +\ + Yb[data_tm[(j*4)+__BBYTE]];\ if((k%2)&&(i%2)){\ - yuv->u[x_2+i/2+(k/2+y_2)*y_width_2]=Ur[data_tm[(k*width_tm+i)*4+__RBYTE]] + Ug[data_tm[(k*width_tm+i)*4+__GBYTE]] + Ub[data_tm[(k*width_tm+i)*4+__BBYTE]];\ - yuv->v[x_2+i/2+(k/2+y_2)*y_width_2]=Vr[data_tm[(k*width_tm+i)*4+__RBYTE]] + Vg[data_tm[(k*width_tm+i)*4+__GBYTE]] + Vb[data_tm[(k*width_tm+i)*4+__BBYTE]] ;\ + yuv->u[x_2+i/2+(k/2+y_2)*y_width_2]=\ + Ur[data_tm[(k*width_tm+i)*4+__RBYTE]] +\ + Ug[data_tm[(k*width_tm+i)*4+__GBYTE]] +\ + Ub[data_tm[(k*width_tm+i)*4+__BBYTE]];\ + yuv->v[x_2+i/2+(k/2+y_2)*y_width_2]=\ + Vr[data_tm[(k*width_tm+i)*4+__RBYTE]] +\ + Vg[data_tm[(k*width_tm+i)*4+__GBYTE]] +\ + Vb[data_tm[(k*width_tm+i)*4+__BBYTE]] ;\ }\ }\ j++;\ diff --git a/recordmydesktop/include/rmdtypes.h b/recordmydesktop/include/rmdtypes.h index 328532f..ea1e517 100644 --- a/recordmydesktop/include/rmdtypes.h +++ b/recordmydesktop/include/rmdtypes.h @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 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 * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 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 RMDTYPES_H #define RMDTYPES_H 1 @@ -104,7 +104,7 @@ typedef struct _BRWindow{ //'basic recorded window' specs WGeometry geom; //window attributes WGeometry rgeom; //part of window that is recorded int nbytes; //size of zpixmap when screenshoting - Window windowid; //id + Window windowid; //id }BRWindow; //defaults in the following comment lines may be out of sync with reality @@ -118,14 +118,14 @@ typedef struct _ProgArgs{ int quietmode; //no messages to stderr,stdout char *filename; //output file(default out.[ogg|*]) int cursor_color; //black or white=>1 or 0 - int have_dummy_cursor;//disable/enable drawing of the dummy cursor - int xfixes_cursor; //disable/enable drawing of a cursor obtained - //through the xfixes extension - float fps; //desired framerate(default 15) - unsigned int frequency; //desired frequency (default 22050) - unsigned int channels; //no of channels(default 2) - char *device; //default sound device(default according to alsa or oss) - snd_pcm_uframes_t buffsize;//buffer size(in frames) for sound capturing + int have_dummy_cursor; //disable/enable drawing of the dummy cursor + int xfixes_cursor; //disable/enable drawing of a cursor obtained + //through the xfixes extension + float fps; //desired framerate(default 15) + unsigned int frequency; //desired frequency (default 22050) + unsigned int channels; //no of channels(default 2) + char *device; //default sound device + snd_pcm_uframes_t buffsize; //buffer size(in frames) for sound capturing int nosound; //do not record sound(default 0) int noshared; //do not use shared memory extension(default 1) int nocondshared; //do not use shared memory on large image aquititions @@ -133,25 +133,26 @@ typedef struct _ProgArgs{ //(which changes full-shots and with-shared to 1) int shared_thres; //threshold to use shared memory int full_shots; //do not poll damage, take full screenshots - int no_quick_subsample;//average pixels in chroma planes - int v_bitrate,v_quality,s_quality;//video bitrate,video-sound quality + int no_quick_subsample; //average pixels in chroma planes + int v_bitrate,v_quality,s_quality; //video bitrate,video-sound quality int dropframes; //option for theora encoder int encOnTheFly; //encode while recording, no caching(default 0) char *workdir; //directory to be used for cache files(default $HOME) int zerocompression;//image data are always flushed uncompressed - int overwrite;//overwite a previously existing file(do not add a .number postfix) + int overwrite; //overwite a previously existing file + //(do not add a .number postfix) }ProgArgs; //this struct holds anything related to encoding AND //writting out to file. typedef struct _EncData{ - ogg_stream_state m_ogg_ts;//theora - ogg_stream_state m_ogg_vs;//vorbis - ogg_page m_ogg_pg;//this could be avoided since - // it is used only while initializing - ogg_packet m_ogg_pckt1;//theora stream - ogg_packet m_ogg_pckt2;//vorbis stream + ogg_stream_state m_ogg_ts; //theora + ogg_stream_state m_ogg_vs; //vorbis + ogg_page m_ogg_pg; //this could be avoided since + // it is used only while initializing + ogg_packet m_ogg_pckt1; //theora stream + ogg_packet m_ogg_pckt2; //vorbis stream //theora data theora_state m_th_st; theora_info m_th_inf; @@ -173,13 +174,18 @@ typedef struct _EncData{ //this struct will hold a few basic //information, needed for caching the frames. typedef struct _CacheData{ - char *workdir, //The directory were the project will be stored, while recording. + char *workdir, //The directory were the project + //will be stored, while recording. //Since this will take a lot of space, the user must be //able to change the location. - *projname, //This is the name of the folder that will hold the project. - //It is rMD-session-%d where %d is the pid of the current proccess. - //This way, running two instances will not create problems - //and also, a frontend can identify leftovers from a possible crash + *projname, //This is the name of the folder that + //will hold the project. + //It is rMD-session-%d where %d is the pid + //of the current proccess. + //This way, running two instances + //will not create problems + //and also, a frontend can identify + //leftovers from a possible crash //and delete them *imgdata, //workdir+projname+img.out.gz *audiodata; //workdir+projname+audio.pcm @@ -204,54 +210,67 @@ typedef struct _SndBuffer{ //threads,so they will have access to the program data, avoiding //at the same time usage of any globals. typedef struct _ProgData{ - ProgArgs args;//the program arguments - DisplaySpecs specs;//Display specific information - BRWindow brwin;//recording window - Display *dpy;//curtrent display - char *window_manager;//name of the window manager at program launch - XImage *image;//the image that holds the current full screenshot - XImage *shimage;//the image that holds the current full screenshot(shared memory) + ProgArgs args; //the program arguments + DisplaySpecs specs; //Display specific information + BRWindow brwin; //recording window + Display *dpy; //curtrent display + char *window_manager; //name of the window manager at program launch + XImage *image; //the image that holds the current full screenshot + XImage *shimage; //the image that holds the current + //full screenshot(shared memory) XShmSegmentInfo shminfo;//info structure for the image above. - unsigned char *dummy_pointer;//a dummy pointer to be drawn in every frame - //data is casted to unsigned for later use in YUV buffer - int dummy_p_size;//initially 16x16,always square - unsigned char npxl;//this is the no pixel convention when drawing the dummy pointer - char *datamain,//the data of image - *datash,//the data of shimage - *datatemp;//buffer for the temporary image,which will be - //preallocated in case shared memory is not used. - RectArea *rect_root[2];//the interchanging list roots for storing the changed regions - int list_selector,//selector for the above - damage_event,//damage event base code - damage_error,//damage error base code + unsigned char *dummy_pointer; //a dummy pointer to be drawn + //in every frame + //data is casted to unsigned for + //later use in YUV buffer + int dummy_p_size; //initially 16x16,always square + unsigned char npxl; //this is the no pixel convention + //when drawing the dummy pointer + char *datamain, //the data of image + *datash, //the data of shimage + *datatemp; //buffer for the temporary image,which will be + //preallocated in case shared memory is not used. + RectArea *rect_root[2]; //the interchanging list roots for storing + //the changed regions + int list_selector, //selector for the above + damage_event, //damage event base code + damage_error, //damage error base code running; SndBuffer *sound_buffer; EncData *enc_data; CacheData *cache_data; - int hard_pause;//if sound device doesn't support pause - //we have to close and reopen - int avd;//syncronization among audio and video + int hard_pause; //if sound device doesn't support pause + //we have to close and reopen + int avd; //syncronization among audio and video unsigned int periodtime, frametime; - pthread_mutex_t list_mutex[2],//mutexes for concurrency protection of the lists + pthread_mutex_t list_mutex[2], //mutexes for concurrency + //protection of the lists sound_buffer_mutex, - libogg_mutex,//libogg is not thread safe, - yuv_mutex;//this might not be needed since we only have - //one read-only and one write-only thread - //also on previous versions, y component was looped separately - //and then u and v so this was needed to avoid wrong coloring to render - //Currently this mutex only prevents the cursor from flickering - pthread_cond_t time_cond,//this gets a broadcast by the handler whenever it's time to get a screenshot - pause_cond,//this is blocks execution, when program is paused - sound_buffer_ready,//sound encoding finished - sound_data_read,//a buffer is ready for proccessing - image_buffer_ready,//image encoding finished - theora_lib_clean,//the flush_ogg thread cannot procceed to creating last - vorbis_lib_clean;//packages until these two libs are no longer used, by other threads - int th_encoding_clean,//these indicate a wait condition on the above cond vars + libogg_mutex, //libogg is not thread safe, + yuv_mutex; //this might not be needed since we only have + //one read-only and one write-only thread + //also on previous versions, + //y component was looped separately + //and then u and v so this was needed + //to avoid wrong coloring to render + //Currently this mutex only prevents + //the cursor from flickering + pthread_cond_t time_cond, //this gets a broadcast by the handler + //whenever it's time to get a screenshot + pause_cond, //this is blocks execution, + //when program is paused + sound_buffer_ready, //sound encoding finished + sound_data_read, //a buffer is ready for proccessing + image_buffer_ready, //image encoding finished + theora_lib_clean, //the flush_ogg thread cannot + //procceed to creating last + vorbis_lib_clean; //packages until these two libs + //are no longer used, by other threads + int th_encoding_clean, v_encoding_clean; - int v_enc_thread_waiting, - th_enc_thread_waiting; + int v_enc_thread_waiting, //these indicate a wait + th_enc_thread_waiting; //condition on the above cond vars snd_pcm_t *sound_handle; snd_pcm_uframes_t periodsize; }ProgData; @@ -268,17 +287,16 @@ typedef struct _ProgData{ //number of time expirations at the time of //caching, will enable us to make up for lost frames. -//default 4+4+2+2+2=14!bad! -//me add pad, make god of 2 happy! + typedef struct _FrameHeader{ - char frame_prefix[4];//always FRAM - 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 - Unum,//number of changed blocks in the U plane - Vnum;//number of changed blocks in the V plane - u_int16_t pad;//always zero + char frame_prefix[4]; //always FRAM + 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 + 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; @@ -289,12 +307,12 @@ typedef struct _FrameHeader{ typedef struct _CachedFrame{ FrameHeader *header; - unsigned char *YBlocks;//identifying number on the grid, starting at top left - unsigned char *UBlocks;// >> >> - unsigned char *VBlocks;// >> >> - unsigned char *YData;//pointer to data for the blocks that have changed, - unsigned char *UData;//which have to be remapped on the buffer when reading - unsigned char *VData; + unsigned char *YBlocks; //identifying number on the grid, + unsigned char *UBlocks; //starting at top left + unsigned char *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 }CachedFrame; #endif |