summaryrefslogtreecommitdiff
path: root/recordmydesktop
diff options
context:
space:
mode:
authorenselic <enselic@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2008-09-13 15:14:58 +0000
committerenselic <enselic@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2008-09-13 15:14:58 +0000
commit0ae6b7238cca4af9782e9231ed316837e1f5d191 (patch)
tree3b8edd238c162f3b4fca80b545005f2e9b1dadc2 /recordmydesktop
parentba009b32fecf6f9651ab29bf7b980a972f0e2a1b (diff)
include/rmdmacro.h: Move AVG_4_PIXELS(), CALC_TVAL_AVG_16(),
CALC_TVAL_AVG_32() and CLEAR_FRAME() out of here. src/get_frame.c: Put AVG_4_PIXELS() here. src/yuv_utils.h: Put CALC_TVAL_AVG_16() and CALC_TVAL_AVG_32() here. src/load_cache.c: Expand CLEAR_FRAME() here. git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@535 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'recordmydesktop')
-rw-r--r--recordmydesktop/include/rmdmacro.h55
-rw-r--r--recordmydesktop/src/get_frame.c6
-rw-r--r--recordmydesktop/src/load_cache.c7
-rw-r--r--recordmydesktop/src/yuv_utils.h37
4 files changed, 49 insertions, 56 deletions
diff --git a/recordmydesktop/include/rmdmacro.h b/recordmydesktop/include/rmdmacro.h
index db5300d..453fbea 100644
--- a/recordmydesktop/include/rmdmacro.h
+++ b/recordmydesktop/include/rmdmacro.h
@@ -24,7 +24,6 @@
* For further information contact me at johnvarouhakis@gmail.com *
******************************************************************************/
-
#ifndef RMDMACRO_H
#define RMDMACRO_H 1
@@ -79,8 +78,6 @@
#define COMPARE_STRIDE 4
#endif
-
-
//The width, in bytes, of the blocks
//on which the y,u and v planes are broken.
//These blocks are square.
@@ -93,52 +90,6 @@
#define DEFAULT_AUDIO_DEVICE "/dev/dsp"
#endif
-
-#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]+\
- data_array[(k_tm*width_img+i_tm-1)*RMD_ULONG_SIZE_T+offset]+\
- data_array[((k_tm-1)*width_img+i_tm-1)*RMD_ULONG_SIZE_T+offset])/4)
-
-
-//the 4 most significant bytes represent the A component which
-//does not need to be added on t_val, as it is always unused
-#define CALC_TVAL_AVG_32(t_val,datapi,datapi_next){\
- register unsigned int t1,t2,t3,t4;\
- t1=*datapi;\
- t2=*(datapi+1);\
- t3=*datapi_next;\
- t4=*(datapi_next+1);\
- t_val=((((t1&0x00ff0000) +(t2&0x00ff0000)+\
- (t3&0x00ff0000)+(t4&0x00ff0000))/4)&0x00ff0000)+\
- ((((t1&0x0000ff00) +(t2&0x0000ff00)+\
- (t3&0x0000ff00)+(t4&0x0000ff00))/4)&0x0000ff00)+\
- ((((t1&0x000000ff) +(t2&0x000000ff)+\
- (t3&0x000000ff)+(t4&0x000000ff))/4)&0x000000ff);\
-}
-
-//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.
-//(This note is useless, I'm just adding because
-//the addition of the A components in CALC_TVAL_AVG_32,
-//now removed as uneeded, produced an overflow which would have caused
-//color distrtion, where it one of the R,G or B components)
-#define CALC_TVAL_AVG_16(t_val,datapi,datapi_next){\
- register u_int16_t t1,t2,t3,t4;\
- t1=*datapi;\
- t2=*(datapi+1);\
- t3=*datapi_next;\
- t4=*(datapi_next+1);\
- t_val=((((t1&__R16_MASK) +(t2&__R16_MASK)+\
- (t3&__R16_MASK)+(t4&__R16_MASK))/4)&__R16_MASK)+\
- ((((t1&__G16_MASK) +(t2&__G16_MASK)+\
- (t3&__G16_MASK)+(t4&__G16_MASK))/4)&__G16_MASK)+\
- ((((t1&__B16_MASK) +(t2&__B16_MASK)+\
- (t3&__B16_MASK)+(t4&__B16_MASK))/4)&__B16_MASK);\
-}
-
-
#define I16TOA(number,buffer){\
int t_num=(number),__k=0,__i=0;\
char *t_buf=malloc(8);\
@@ -156,11 +107,5 @@
free(t_buf);\
};\
-#define CLEAR_FRAME(frame_t){\
- free((frame_t)->YData);\
- free((frame_t)->UData);\
- free((frame_t)->VData);\
-};
#endif
-
diff --git a/recordmydesktop/src/get_frame.c b/recordmydesktop/src/get_frame.c
index 39bbb36..c732002 100644
--- a/recordmydesktop/src/get_frame.c
+++ b/recordmydesktop/src/get_frame.c
@@ -30,6 +30,12 @@
#include "yuv_utils.h"
+#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]+\
+ data_array[(k_tm*width_img+i_tm-1)*RMD_ULONG_SIZE_T+offset]+\
+ data_array[((k_tm-1)*width_img+i_tm-1)*RMD_ULONG_SIZE_T+offset])/4)
+
#define CLIP_DUMMY_POINTER_AREA(dummy_p_area,brwin,wgeom){\
(wgeom)->x=((((dummy_p_area).x+\
(dummy_p_area).width>=(brwin)->rgeom.x)&&\
diff --git a/recordmydesktop/src/load_cache.c b/recordmydesktop/src/load_cache.c
index d25077e..afd1570 100644
--- a/recordmydesktop/src/load_cache.c
+++ b/recordmydesktop/src/load_cache.c
@@ -306,7 +306,12 @@ void *LoadCache(ProgData *pdata){
pthread_cond_signal(&pdata->vorbis_lib_clean);
pthread_mutex_unlock(&pdata->vorbis_lib_mutex);
fprintf(stdout,"\n");
- CLEAR_FRAME(&frame)
+
+ // Clear frame
+ free(frame.YData);
+ free(frame.UData);
+ free(frame.VData);
+
free(sound_data);
if(!pdata->args.nosound){
diff --git a/recordmydesktop/src/yuv_utils.h b/recordmydesktop/src/yuv_utils.h
index 14809ff..6890a23 100644
--- a/recordmydesktop/src/yuv_utils.h
+++ b/recordmydesktop/src/yuv_utils.h
@@ -35,6 +35,43 @@ extern unsigned char Yr[256], Yg[256], Yb[256],
Vg[256], Vb[256];
+//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.
+//(This note is useless, I'm just adding because
+//the addition of the A components in CALC_TVAL_AVG_32,
+//now removed as uneeded, produced an overflow which would have caused
+//color distrtion, where it one of the R,G or B components)
+#define CALC_TVAL_AVG_16(t_val,datapi,datapi_next){\
+ register u_int16_t t1,t2,t3,t4;\
+ t1=*datapi;\
+ t2=*(datapi+1);\
+ t3=*datapi_next;\
+ t4=*(datapi_next+1);\
+ t_val=((((t1&__R16_MASK) +(t2&__R16_MASK)+\
+ (t3&__R16_MASK)+(t4&__R16_MASK))/4)&__R16_MASK)+\
+ ((((t1&__G16_MASK) +(t2&__G16_MASK)+\
+ (t3&__G16_MASK)+(t4&__G16_MASK))/4)&__G16_MASK)+\
+ ((((t1&__B16_MASK) +(t2&__B16_MASK)+\
+ (t3&__B16_MASK)+(t4&__B16_MASK))/4)&__B16_MASK);\
+}
+
+//the 4 most significant bytes represent the A component which
+//does not need to be added on t_val, as it is always unused
+#define CALC_TVAL_AVG_32(t_val,datapi,datapi_next){\
+ register unsigned int t1,t2,t3,t4;\
+ t1=*datapi;\
+ t2=*(datapi+1);\
+ t3=*datapi_next;\
+ t4=*(datapi_next+1);\
+ t_val=((((t1&0x00ff0000) +(t2&0x00ff0000)+\
+ (t3&0x00ff0000)+(t4&0x00ff0000))/4)&0x00ff0000)+\
+ ((((t1&0x0000ff00) +(t2&0x0000ff00)+\
+ (t3&0x0000ff00)+(t4&0x0000ff00))/4)&0x0000ff00)+\
+ ((((t1&0x000000ff) +(t2&0x000000ff)+\
+ (t3&0x000000ff)+(t4&0x000000ff))/4)&0x000000ff);\
+}
+
#define POINT_IN_BLOCK(xv,yv,widthv,blocksize) ((yv/blocksize)*\
(widthv/blocksize)+\
(xv/blocksize))
© All Rights Reserved