diff options
Diffstat (limited to 'recordmydesktop')
48 files changed, 399 insertions, 340 deletions
diff --git a/recordmydesktop/configure.ac b/recordmydesktop/configure.ac index 72409e8..a18c092 100644 --- a/recordmydesktop/configure.ac +++ b/recordmydesktop/configure.ac @@ -95,8 +95,7 @@ AC_CHECK_LIB([pthread],[pthread_mutex_lock],, AC_MSG_ERROR([Can't find libpthread])) if test x$jack = xtrue ; then -AC_CHECK_LIB([jack],[jack_activate],, - jack_lib_found=false) +AC_CHECK_LIB([jack],[jack_activate],jack_lib_found=true,) fi if test x$oss = xfalse; then @@ -120,8 +119,7 @@ AC_OUTPUT if test x$audio_backend != xOSS; then audio_backend="ALSA" fi -if test x$jack_lib_found != xfalse ; then -# AC_DEFINE([HAVE_JACK_H],1,define to 1 if libjack is found) , +if test x$jack_lib_found = xtrue ; then jack_support="Enabled" else jack_support="Disabled" diff --git a/recordmydesktop/src/Makefile.am b/recordmydesktop/src/Makefile.am index 47b3320..a63c3c4 100644 --- a/recordmydesktop/src/Makefile.am +++ b/recordmydesktop/src/Makefile.am @@ -2,8 +2,6 @@ bin_PROGRAMS = recordmydesktop recordmydesktop_SOURCES = \ rmd.c \ - rmd_block_utils.c \ - rmd_block_utils.h \ rmd_cache.c \ rmd_cache.h \ rmd_cache_audio.c \ @@ -39,6 +37,8 @@ recordmydesktop_SOURCES = \ rmd_macro.h \ rmd_make_dummy_pointer.c \ rmd_make_dummy_pointer.h \ + rmd_math.c \ + rmd_math.h \ rmd_opendev.c \ rmd_opendev.h \ rmd_parseargs.c \ diff --git a/recordmydesktop/src/rmd.c b/recordmydesktop/src/rmd.c index ce36a2b..c945d2f 100644 --- a/recordmydesktop/src/rmd.c +++ b/recordmydesktop/src/rmd.c @@ -26,8 +26,6 @@ #include "config.h" -#include "rmd_types.h" - #include "rmd_cache.h" #include "rmd_encode_cache.h" #include "rmd_error.h" @@ -39,7 +37,13 @@ #include "rmd_shortcuts.h" #include "rmd_threads.h" #include "rmd_wm_is_compositing.h" +#include "rmd_types.h" + +#include <X11/Xlib.h> +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> int main(int argc,char **argv){ ProgData pdata; diff --git a/recordmydesktop/src/rmd_block_utils.h b/recordmydesktop/src/rmd_block_utils.h deleted file mode 100644 index 02aa77f..0000000 --- a/recordmydesktop/src/rmd_block_utils.h +++ /dev/null @@ -1,170 +0,0 @@ -/****************************************************************************** -* 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 "rmd_macro.h" -#include "rmd_types.h" -#include "rmd_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/rmd_cache.c b/recordmydesktop/src/rmd_cache.c index 536d217..56e4301 100644 --- a/recordmydesktop/src/rmd_cache.c +++ b/recordmydesktop/src/rmd_cache.c @@ -25,14 +25,15 @@ ******************************************************************************/ #include "config.h" - -#include <sys/stat.h> - -#include "rmd_types.h" - #include "rmd_cache.h" #include "rmd_specsfile.h" +#include "rmd_types.h" + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <sys/stat.h> /** diff --git a/recordmydesktop/src/rmd_cache.h b/recordmydesktop/src/rmd_cache.h index 01efa21..a4ee79f 100644 --- a/recordmydesktop/src/rmd_cache.h +++ b/recordmydesktop/src/rmd_cache.h @@ -29,6 +29,11 @@ #include "rmd_types.h" +#include <zlib.h> + +#include <stdio.h> + + /** * Change file pointer to a new file while writting diff --git a/recordmydesktop/src/rmd_cache_audio.c b/recordmydesktop/src/rmd_cache_audio.c index d31b607..c061ed3 100644 --- a/recordmydesktop/src/rmd_cache_audio.c +++ b/recordmydesktop/src/rmd_cache_audio.c @@ -25,13 +25,17 @@ ******************************************************************************/ #include "config.h" +#include "rmd_cache_audio.h" + +#include "rmd_jack.h" +#include "rmd_types.h" #include <pthread.h> -#include "rmd_types.h" +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> -#include "rmd_cache_audio.h" -#include "rmd_jack.h" void *CacheSoundBuffer(ProgData *pdata){ diff --git a/recordmydesktop/src/rmd_cache_frame.c b/recordmydesktop/src/rmd_cache_frame.c index 03e3506..92c9955 100644 --- a/recordmydesktop/src/rmd_cache_frame.c +++ b/recordmydesktop/src/rmd_cache_frame.c @@ -25,15 +25,17 @@ ******************************************************************************/ #include "config.h" +#include "rmd_cache_frame.h" -#include <signal.h> -#include <math.h> - +#include "rmd_yuv_utils.h" +#include "rmd_cache.h" #include "rmd_types.h" -#include "rmd_block_utils.h" -#include "rmd_cache.h" -#include "rmd_cache_frame.h" +#include <signal.h> +#include <string.h> +#include <stdio.h> +#include <errno.h> +#include <math.h> #define BYTES_PER_MB (1024 * 1024) diff --git a/recordmydesktop/src/rmd_capture_sound.c b/recordmydesktop/src/rmd_capture_sound.c index b9be47b..33c5814 100644 --- a/recordmydesktop/src/rmd_capture_sound.c +++ b/recordmydesktop/src/rmd_capture_sound.c @@ -25,14 +25,15 @@ ******************************************************************************/ #include "config.h" - -#include <pthread.h> - -#include "rmd_types.h" - #include "rmd_capture_sound.h" + #include "rmd_jack.h" #include "rmd_opendev.h" +#include "rmd_types.h" + +#include <pthread.h> +#include <string.h> +#include <errno.h> void *CaptureSound(ProgData *pdata){ diff --git a/recordmydesktop/src/rmd_encode_cache.c b/recordmydesktop/src/rmd_encode_cache.c index 40b0a8d..1ada5d0 100644 --- a/recordmydesktop/src/rmd_encode_cache.c +++ b/recordmydesktop/src/rmd_encode_cache.c @@ -25,15 +25,18 @@ ******************************************************************************/ #include "config.h" - -#include <pthread.h> - -#include "rmd_types.h" - #include "rmd_encode_cache.h" + #include "rmd_flush_to_ogg.h" #include "rmd_init_encoder.h" #include "rmd_load_cache.h" +#include "rmd_types.h" + +#include <pthread.h> + +#include <stdio.h> +#include <stdlib.h> + void EncodeCache(ProgData *pdata){ diff --git a/recordmydesktop/src/rmd_encode_image_buffer.c b/recordmydesktop/src/rmd_encode_image_buffer.c index 4b91239..957ad66 100644 --- a/recordmydesktop/src/rmd_encode_image_buffer.c +++ b/recordmydesktop/src/rmd_encode_image_buffer.c @@ -25,10 +25,11 @@ ******************************************************************************/ #include "config.h" +#include "rmd_encode_image_buffer.h" #include "rmd_types.h" -#include "rmd_encode_image_buffer.h" +#include <errno.h> void *EncodeImageBuffer(ProgData *pdata){ diff --git a/recordmydesktop/src/rmd_encode_sound_buffer.c b/recordmydesktop/src/rmd_encode_sound_buffer.c index 4a04d71..3a6572c 100644 --- a/recordmydesktop/src/rmd_encode_sound_buffer.c +++ b/recordmydesktop/src/rmd_encode_sound_buffer.c @@ -25,13 +25,15 @@ ******************************************************************************/ #include "config.h" +#include "rmd_encode_sound_buffer.h" -#include <pthread.h> - +#include "rmd_jack.h" #include "rmd_types.h" -#include "rmd_encode_sound_buffer.h" -#include "rmd_jack.h" +#include <pthread.h> + +#include <stdlib.h> +#include <errno.h> void *EncodeSoundBuffer(ProgData *pdata){ diff --git a/recordmydesktop/src/rmd_error.c b/recordmydesktop/src/rmd_error.c index 1640ffe..44144bf 100644 --- a/recordmydesktop/src/rmd_error.c +++ b/recordmydesktop/src/rmd_error.c @@ -25,13 +25,14 @@ ******************************************************************************/ #include "config.h" +#include "rmd_error.h" -#include <stdio.h> -#include <stdlib.h> #include <X11/Xlib.h> #include <X11/Xlibint.h> -#include "rmd_error.h" +#include <stdio.h> +#include <stdlib.h> + int rmdErrorHandler( Display *dpy, XErrorEvent *e ) diff --git a/recordmydesktop/src/rmd_flush_to_ogg.c b/recordmydesktop/src/rmd_flush_to_ogg.c index 1f78115..ae94b2f 100644 --- a/recordmydesktop/src/rmd_flush_to_ogg.c +++ b/recordmydesktop/src/rmd_flush_to_ogg.c @@ -25,14 +25,18 @@ ******************************************************************************/ #include "config.h" +#include "rmd_flush_to_ogg.h" + +#include "rmd_encode_image_buffer.h" +#include "rmd_encode_sound_buffer.h" +#include "rmd_types.h" #include <pthread.h> -#include "rmd_types.h" +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> -#include "rmd_encode_image_buffer.h" -#include "rmd_encode_sound_buffer.h" -#include "rmd_flush_to_ogg.h" //we copy the page because the next call to ogg_stream_pageout diff --git a/recordmydesktop/src/rmd_frame.c b/recordmydesktop/src/rmd_frame.c index ccda02e..740dacf 100644 --- a/recordmydesktop/src/rmd_frame.c +++ b/recordmydesktop/src/rmd_frame.c @@ -25,13 +25,13 @@ ******************************************************************************/ #include "config.h" +#include "rmd_frame.h" -#include <stdio.h> -#include <stdlib.h> #include <X11/Xlib.h> #include <X11/extensions/shape.h> -#include "rmd_frame.h" +#include <stdio.h> +#include <stdlib.h> #define BORDER_WIDTH 6 diff --git a/recordmydesktop/src/rmd_get_frame.c b/recordmydesktop/src/rmd_get_frame.c index acbb6e2..0baff5e 100644 --- a/recordmydesktop/src/rmd_get_frame.c +++ b/recordmydesktop/src/rmd_get_frame.c @@ -25,24 +25,24 @@ ******************************************************************************/ #include "config.h" - -#include <limits.h> -#include <pthread.h> -#include <sys/shm.h> - -#include <X11/extensions/Xfixes.h> -#include <X11/extensions/XShm.h> - -#include "rmd_types.h" +#include "rmd_get_frame.h" #include "rmd_cache.h" #include "rmd_frame.h" -#include "rmd_get_frame.h" #include "rmd_getzpixmap.h" #include "rmd_poll_events.h" #include "rmd_rectinsert.h" #include "rmd_update_image.h" #include "rmd_yuv_utils.h" +#include "rmd_types.h" + +#include <X11/extensions/Xfixes.h> +#include <X11/extensions/XShm.h> + +#include <limits.h> +#include <pthread.h> +#include <sys/shm.h> +#include <errno.h> #define AVG_4_PIXELS(data_array,width_img,k_tm,i_tm,offset)\ diff --git a/recordmydesktop/src/rmd_getzpixmap.c b/recordmydesktop/src/rmd_getzpixmap.c index f001844..33c31c2 100644 --- a/recordmydesktop/src/rmd_getzpixmap.c +++ b/recordmydesktop/src/rmd_getzpixmap.c @@ -25,15 +25,16 @@ ******************************************************************************/ #include "config.h" +#include "rmd_getzpixmap.h" + +#include "rmd_types.h" + #include <X11/Xlib.h> #include <X11/Xlibint.h> #include <X11/extensions/shmstr.h> #include <X11/extensions/XShm.h> -#include "rmd_types.h" - -#include "rmd_getzpixmap.h" int GetZPixmap(Display *dpy, diff --git a/recordmydesktop/src/rmd_getzpixmap.h b/recordmydesktop/src/rmd_getzpixmap.h index b154e5a..81e0025 100644 --- a/recordmydesktop/src/rmd_getzpixmap.h +++ b/recordmydesktop/src/rmd_getzpixmap.h @@ -29,6 +29,7 @@ #include "rmd_types.h" +#include <X11/extensions/XShm.h> /** * Rerieve pixmap data from xserver diff --git a/recordmydesktop/src/rmd_init_encoder.c b/recordmydesktop/src/rmd_init_encoder.c index 2f71ba5..ad4e976 100644 --- a/recordmydesktop/src/rmd_init_encoder.c +++ b/recordmydesktop/src/rmd_init_encoder.c @@ -25,16 +25,19 @@ ******************************************************************************/ #include "config.h" +#include "rmd_init_encoder.h" + +#include "rmd_types.h" + +#include "skeleton.h" #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <sys/stat.h> -#include "skeleton.h" -#include "rmd_types.h" -#include "rmd_init_encoder.h" static void m_add_fishead_packet(ogg_stream_state *m_ogg_state) { diff --git a/recordmydesktop/src/rmd_initialize_data.c b/recordmydesktop/src/rmd_initialize_data.c index 7451866..6754f7b 100644 --- a/recordmydesktop/src/rmd_initialize_data.c +++ b/recordmydesktop/src/rmd_initialize_data.c @@ -25,19 +25,21 @@ ******************************************************************************/ #include "config.h" +#include "rmd_initialize_data.h" -#include <pthread.h> - -#include "rmd_types.h" - -#include "rmd_block_utils.h" #include "rmd_cache.h" #include "rmd_init_encoder.h" #include "rmd_jack.h" #include "rmd_make_dummy_pointer.h" #include "rmd_opendev.h" #include "rmd_yuv_utils.h" +#include "rmd_types.h" + +#include <pthread.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> #ifdef HAVE_LIBASOUND static void FixBufferSize(snd_pcm_uframes_t *buffsize) { diff --git a/recordmydesktop/src/rmd_jack.c b/recordmydesktop/src/rmd_jack.c index 9236ad4..eb9de28 100644 --- a/recordmydesktop/src/rmd_jack.c +++ b/recordmydesktop/src/rmd_jack.c @@ -25,13 +25,13 @@ ******************************************************************************/ #include "config.h" - -#include <pthread.h> +#include "rmd_jack.h" #include "rmd_types.h" -#include "rmd_jack.h" +#include <pthread.h> +#include <string.h> #ifdef HAVE_LIBJACK diff --git a/recordmydesktop/src/rmd_load_cache.c b/recordmydesktop/src/rmd_load_cache.c index c402473..1e527a2 100644 --- a/recordmydesktop/src/rmd_load_cache.c +++ b/recordmydesktop/src/rmd_load_cache.c @@ -25,17 +25,20 @@ ******************************************************************************/ #include "config.h" - -#include <pthread.h> -#include <signal.h> - -#include "rmd_types.h" +#include "rmd_load_cache.h" #include "rmd_cache.h" #include "rmd_encode_image_buffer.h" #include "rmd_encode_sound_buffer.h" -#include "rmd_load_cache.h" #include "rmd_macro.h" +#include "rmd_types.h" + +#include <pthread.h> +#include <signal.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> //The number of bytes for every diff --git a/recordmydesktop/src/rmd_macro.h b/recordmydesktop/src/rmd_macro.h index 262c91c..37c032d 100644 --- a/recordmydesktop/src/rmd_macro.h +++ b/recordmydesktop/src/rmd_macro.h @@ -29,10 +29,10 @@ #include "config.h" -#include <limits.h> - #include "rmd_types.h" +#include <limits.h> + //define which way we are reading a pixmap #if __BYTE_ORDER == __LITTLE_ENDIAN diff --git a/recordmydesktop/src/rmd_make_dummy_pointer.c b/recordmydesktop/src/rmd_make_dummy_pointer.c index 7b409cf..527fe43 100644 --- a/recordmydesktop/src/rmd_make_dummy_pointer.c +++ b/recordmydesktop/src/rmd_make_dummy_pointer.c @@ -25,13 +25,12 @@ ******************************************************************************/ #include "config.h" +#include "rmd_make_dummy_pointer.h" -#include <X11/Xlib.h> - +#include "rmd_macro.h" #include "rmd_types.h" -#include "rmd_macro.h" -#include "rmd_make_dummy_pointer.h" +#include <X11/Xlib.h> unsigned char *MakeDummyPointer(Display *display, diff --git a/recordmydesktop/src/rmd_block_utils.c b/recordmydesktop/src/rmd_math.c index 20b5aac..d344c78 100644 --- a/recordmydesktop/src/rmd_block_utils.c +++ b/recordmydesktop/src/rmd_math.c @@ -1,9 +1,8 @@ /****************************************************************************** -* recordMyDesktop * +* recordMyDesktop - rmd_math.c * ******************************************************************************* * * -* Copyright (C) 2006,2007,2008 John Varouhakis * -* * +* Copyright (C) 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 * @@ -25,13 +24,13 @@ ******************************************************************************/ #include "config.h" +#include "rmd_math.h" + +#include <math.h> -#include "rmd_block_utils.h" +double rmdRoundf(double val){ + + return val < 0.0 ? ceilf( val - 0.5 ) : floorf( val + 0.5 ); +} -// 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/rmd_math.h b/recordmydesktop/src/rmd_math.h new file mode 100644 index 0000000..87c6166 --- /dev/null +++ b/recordmydesktop/src/rmd_math.h @@ -0,0 +1,44 @@ +/****************************************************************************** +* recordMyDesktop - rmd_math.h * +******************************************************************************* +* * +* Copyright (C) 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 RMD_MATH_H +#define RMD_MATH_H 1 + +/* + * Since roundf depends on C99, using it might make + * the code non-portable. rmdRoundf solves this + * problem, by behaving identically with roundf + * and being portable (floorf and ceilf, that are + * used in the implementation, are defined in C89) + * + * \param val Number to be rounded + * + * \returns val rounded + * + */ +double rmdRoundf( double val ); + +#endif + diff --git a/recordmydesktop/src/rmd_opendev.c b/recordmydesktop/src/rmd_opendev.c index 9b334ab..65d3dac 100644 --- a/recordmydesktop/src/rmd_opendev.c +++ b/recordmydesktop/src/rmd_opendev.c @@ -25,11 +25,7 @@ ******************************************************************************/ #include "config.h" - -#include <stdlib.h> -#include <stdio.h> -#include <unistd.h> -#include <fcntl.h> +#include "rmd_opendev.h" #ifdef HAVE_LIBASOUND #include <alsa/asoundlib.h> @@ -38,7 +34,11 @@ #include <sys/soundcard.h> #endif -#include "rmd_opendev.h" +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> +#include <fcntl.h> + #ifdef HAVE_LIBASOUND diff --git a/recordmydesktop/src/rmd_parseargs.c b/recordmydesktop/src/rmd_parseargs.c index 758f515..254a011 100644 --- a/recordmydesktop/src/rmd_parseargs.c +++ b/recordmydesktop/src/rmd_parseargs.c @@ -25,11 +25,14 @@ ******************************************************************************/ #include "config.h" - -#include <stdio.h> +#include "rmd_parseargs.h" #include "rmd_types.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + static void PrintConfig(void) { fprintf(stderr,"\nrecordMyDesktop was compiled with" diff --git a/recordmydesktop/src/rmd_poll_events.c b/recordmydesktop/src/rmd_poll_events.c index 5c29f04..4ba33b6 100644 --- a/recordmydesktop/src/rmd_poll_events.c +++ b/recordmydesktop/src/rmd_poll_events.c @@ -25,21 +25,22 @@ ******************************************************************************/ #include "config.h" +#include "rmd_poll_events.h" + +#include "rmd_frame.h" +#include "rmd_macro.h" +#include "rmd_rectinsert.h" +#include "rmd_types.h" -#include <stdio.h> -#include <stdlib.h> #include <X11/Xlib.h> #include <X11/Xlibint.h> #include <X11/extensions/Xdamage.h> + +#include <stdio.h> +#include <stdlib.h> #include <signal.h> #include <pthread.h> -#include "rmd_frame.h" -#include "rmd_macro.h" -#include "rmd_poll_events.h" -#include "rmd_rectinsert.h" -#include "rmd_types.h" - #define CLIP_EVENT_AREA(e,brwin,xrect){\ if(((e)->area.x<=(brwin)->rrect.x)&&((e)->area.y<=(brwin)->rrect.y)&&\ diff --git a/recordmydesktop/src/rmd_queryextensions.c b/recordmydesktop/src/rmd_queryextensions.c index cc9c69c..3a196d4 100644 --- a/recordmydesktop/src/rmd_queryextensions.c +++ b/recordmydesktop/src/rmd_queryextensions.c @@ -25,14 +25,14 @@ ******************************************************************************/ #include "config.h" +#include "rmd_queryextensions.h" + +#include "rmd_types.h" #include <X11/extensions/shape.h> #include <X11/extensions/Xfixes.h> #include <X11/extensions/Xdamage.h> -#include "rmd_types.h" - -#include "rmd_queryextensions.h" void QueryExtensions(Display *dpy, diff --git a/recordmydesktop/src/rmd_rectinsert.c b/recordmydesktop/src/rmd_rectinsert.c index 1950d65..8b9ea95 100644 --- a/recordmydesktop/src/rmd_rectinsert.c +++ b/recordmydesktop/src/rmd_rectinsert.c @@ -25,10 +25,12 @@ ******************************************************************************/ #include "config.h" - #include "rmd_rectinsert.h" + #include "rmd_types.h" +#include <stdlib.h> + /** * Collide two rectangles and dictate most sane action for insertion, diff --git a/recordmydesktop/src/rmd_register_callbacks.c b/recordmydesktop/src/rmd_register_callbacks.c index 6291825..fa322d5 100644 --- a/recordmydesktop/src/rmd_register_callbacks.c +++ b/recordmydesktop/src/rmd_register_callbacks.c @@ -25,12 +25,11 @@ ******************************************************************************/ #include "config.h" - -#include <signal.h> +#include "rmd_register_callbacks.h" #include "rmd_types.h" -#include "rmd_register_callbacks.h" +#include <signal.h> // There seem to be no way of passing user data to the signal handler, diff --git a/recordmydesktop/src/rmd_rescue.c b/recordmydesktop/src/rmd_rescue.c index 2b48eb0..f8776b0 100644 --- a/recordmydesktop/src/rmd_rescue.c +++ b/recordmydesktop/src/rmd_rescue.c @@ -25,17 +25,18 @@ ******************************************************************************/ #include "config.h" +#include "rmd_rescue.h" -#include <pthread.h> - -#include "rmd_types.h" - -#include "rmd_block_utils.h" +#include "rmd_yuv_utils.h" #include "rmd_encode_cache.h" #include "rmd_initialize_data.h" #include "rmd_register_callbacks.h" -#include "rmd_rescue.h" #include "rmd_specsfile.h" +#include "rmd_types.h" + +#include <pthread.h> + +#include <string.h> int rmdRescue(const char *path){ diff --git a/recordmydesktop/src/rmd_setbrwindow.c b/recordmydesktop/src/rmd_setbrwindow.c index 431ff43..df77620 100644 --- a/recordmydesktop/src/rmd_setbrwindow.c +++ b/recordmydesktop/src/rmd_setbrwindow.c @@ -25,11 +25,10 @@ ******************************************************************************/ #include "config.h" +#include "rmd_setbrwindow.h" #include "rmd_types.h" -#include "rmd_setbrwindow.h" - /** *Align the recording window to a divisible by 2 pixel start and diff --git a/recordmydesktop/src/rmd_shortcuts.c b/recordmydesktop/src/rmd_shortcuts.c index a4031bc..dcd39d0 100644 --- a/recordmydesktop/src/rmd_shortcuts.c +++ b/recordmydesktop/src/rmd_shortcuts.c @@ -25,16 +25,17 @@ ******************************************************************************/ #include "config.h" +#include "rmd_shortcuts.h" + +#include "rmd_types.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> #include <X11/Xlib.h> #include <X11/Xlibint.h> #include <X11/keysym.h> -#include "rmd_shortcuts.h" -#include "rmd_types.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> int RegisterShortcut(Display *dpy, Window root, diff --git a/recordmydesktop/src/rmd_specsfile.c b/recordmydesktop/src/rmd_specsfile.c index c168401..201a36a 100644 --- a/recordmydesktop/src/rmd_specsfile.c +++ b/recordmydesktop/src/rmd_specsfile.c @@ -25,13 +25,13 @@ ******************************************************************************/ #include "config.h" +#include "rmd_specsfile.h" + +#include "rmd_types.h" #include <stdlib.h> #include <stdio.h> -#include "rmd_specsfile.h" -#include "rmd_types.h" - int WriteSpecsFile(ProgData *pdata){ diff --git a/recordmydesktop/src/rmd_threads.c b/recordmydesktop/src/rmd_threads.c index b658a49..6716fe2 100644 --- a/recordmydesktop/src/rmd_threads.c +++ b/recordmydesktop/src/rmd_threads.c @@ -25,13 +25,7 @@ ******************************************************************************/ #include "config.h" - -#include <pthread.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> - -#include "rmd_types.h" +#include "rmd_threads.h" #include "rmd_cache_audio.h" #include "rmd_cache_frame.h" @@ -42,9 +36,14 @@ #include "rmd_get_frame.h" #include "rmd_jack.h" #include "rmd_register_callbacks.h" -#include "rmd_threads.h" #include "rmd_timer.h" +#include "rmd_types.h" + +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> void rmdThreads(ProgData *pdata){ pthread_t image_capture_t, diff --git a/recordmydesktop/src/rmd_timer.c b/recordmydesktop/src/rmd_timer.c index 78de72b..8891cc3 100644 --- a/recordmydesktop/src/rmd_timer.c +++ b/recordmydesktop/src/rmd_timer.c @@ -25,14 +25,15 @@ ******************************************************************************/ #include "config.h" +#include "rmd_timer.h" + +#include "rmd_types.h" #include <pthread.h> + #include <stdio.h> #include <stdlib.h> - -#include "rmd_types.h" - -#include "rmd_timer.h" +#include <errno.h> void *rmdTimer(ProgData *pdata){ diff --git a/recordmydesktop/src/rmd_types.h b/recordmydesktop/src/rmd_types.h index 213745d..3324760 100644 --- a/recordmydesktop/src/rmd_types.h +++ b/recordmydesktop/src/rmd_types.h @@ -27,6 +27,7 @@ #include "config.h" +#include <stdio.h> #include <pthread.h> #include <zlib.h> #include <X11/Xlib.h> diff --git a/recordmydesktop/src/rmd_update_image.c b/recordmydesktop/src/rmd_update_image.c index 458172e..502b859 100644 --- a/recordmydesktop/src/rmd_update_image.c +++ b/recordmydesktop/src/rmd_update_image.c @@ -25,17 +25,16 @@ ******************************************************************************/ #include "config.h" +#include "rmd_update_image.h" + +#include "rmd_getzpixmap.h" +#include "rmd_yuv_utils.h" +#include "rmd_types.h" #include <X11/Xlibint.h> #include <X11/extensions/shmstr.h> #include <X11/extensions/XShm.h> -#include "rmd_types.h" - -#include "rmd_getzpixmap.h" -#include "rmd_update_image.h" -#include "rmd_yuv_utils.h" - void UpdateImage(Display * dpy, yuv_buffer *yuv, diff --git a/recordmydesktop/src/rmd_update_image.h b/recordmydesktop/src/rmd_update_image.h index f31e735..5ffe8fd 100644 --- a/recordmydesktop/src/rmd_update_image.h +++ b/recordmydesktop/src/rmd_update_image.h @@ -29,6 +29,7 @@ #include "rmd_types.h" +#include <X11/extensions/XShm.h> /** * Retrieve and apply all changes, if xdamage is used. diff --git a/recordmydesktop/src/rmd_wm_check.c b/recordmydesktop/src/rmd_wm_check.c index b0692da..39d86da 100644 --- a/recordmydesktop/src/rmd_wm_check.c +++ b/recordmydesktop/src/rmd_wm_check.c @@ -25,12 +25,12 @@ ******************************************************************************/ #include "config.h" - -#include <X11/Xatom.h> +#include "rmd_wm_check.h" #include "rmd_types.h" -#include "rmd_wm_check.h" +#include <X11/Xatom.h> + char *rmdWMCheck(Display *dpy,Window root){ diff --git a/recordmydesktop/src/rmd_wm_is_compositing.c b/recordmydesktop/src/rmd_wm_is_compositing.c index e170835..f893910 100644 --- a/recordmydesktop/src/rmd_wm_is_compositing.c +++ b/recordmydesktop/src/rmd_wm_is_compositing.c @@ -25,14 +25,15 @@ ******************************************************************************/ #include "config.h" +#include "rmd_wm_is_compositing.h" -#include <X11/Xatom.h> - +#include "rmd_wm_check.h" #include "rmd_types.h" -#include "rmd_wm_check.h" +#include <X11/Xatom.h> + +#include <stdlib.h> -#include "rmd_wm_is_compositing.h" boolean rmdWMIsCompositing( Display *dpy, int screen ) { diff --git a/recordmydesktop/src/rmd_yuv_utils.c b/recordmydesktop/src/rmd_yuv_utils.c index 5da501b..dbe87ae 100644 --- a/recordmydesktop/src/rmd_yuv_utils.c +++ b/recordmydesktop/src/rmd_yuv_utils.c @@ -25,14 +25,23 @@ ******************************************************************************/ #include "config.h" - #include "rmd_yuv_utils.h" +#include "rmd_math.h" + + // Keep these global (for performance reasons I assume). unsigned char Yr[256], Yg[256], Yb[256], Ur[256], Ug[256], UbVr[256], Vg[256], Vb[256]; +// 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; + void MakeMatrices (void) { int i; @@ -68,16 +77,16 @@ void MakeMatrices (void) { for( i = 0 ; i < 256 ; i++ ) { - Yr[i] = (unsigned char) roundf( Yoffset + yr * i ); - Yg[i] = (unsigned char) roundf( yg * i ); - Yb[i] = (unsigned char) roundf( yb * i ); + Yr[i] = (unsigned char) rmdRoundf( Yoffset + yr * i ); + Yg[i] = (unsigned char) rmdRoundf( yg * i ); + Yb[i] = (unsigned char) rmdRoundf( yb * i ); - Ur[i] = (unsigned char) roundf( Coffset + ur * i ); - Ug[i] = (unsigned char) roundf( ug * i ); - UbVr[i] = (unsigned char) roundf( ub * i ); + Ur[i] = (unsigned char) rmdRoundf( Coffset + ur * i ); + Ug[i] = (unsigned char) rmdRoundf( ug * i ); + UbVr[i] = (unsigned char) rmdRoundf( ub * i ); - Vg[i] = (unsigned char) roundf( vg * i ); - Vb[i] = (unsigned char) roundf( Coffset + vb * i ); + Vg[i] = (unsigned char) rmdRoundf( vg * i ); + Vb[i] = (unsigned char) rmdRoundf( Coffset + vb * i ); } 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. */ diff --git a/recordmydesktop/src/skeleton.h b/recordmydesktop/src/skeleton.h index 9805cdc..d088e3e 100644 --- a/recordmydesktop/src/skeleton.h +++ b/recordmydesktop/src/skeleton.h @@ -10,6 +10,7 @@ extern "C" { #endif +#include <stdio.h> #include <ogg/ogg.h> #define SKELETON_VERSION_MAJOR 3 diff --git a/recordmydesktop/src/test-rectinsert-data.c b/recordmydesktop/src/test-rectinsert-data.c index 2bb5c4a..9540a5f 100644 --- a/recordmydesktop/src/test-rectinsert-data.c +++ b/recordmydesktop/src/test-rectinsert-data.c @@ -21,9 +21,9 @@ ******************************************************************************/ #include "config.h" +#include "test-rectinsert-data.h" #include "test-rectinsert-types.h" -#include "test-rectinsert-data.h" // Defines to increase readability of test data diff --git a/recordmydesktop/src/test-rectinsert.c b/recordmydesktop/src/test-rectinsert.c index b63e5ce..007cfb9 100644 --- a/recordmydesktop/src/test-rectinsert.c +++ b/recordmydesktop/src/test-rectinsert.c @@ -21,12 +21,12 @@ ******************************************************************************/ #include "config.h" - -#include "rmd_types.h" #include "rmd_rectinsert.h" #include "test-rectinsert-types.h" #include "test-rectinsert-data.h" +#include "rmd_types.h" + static void SetPixel(boolean *state, int x, int y, boolean value) { |