diff options
Diffstat (limited to 'recordmydesktop/src/yuv_utils.h')
-rw-r--r-- | recordmydesktop/src/yuv_utils.h | 37 |
1 files changed, 37 insertions, 0 deletions
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)) |