1
/******************************************************************************
3
*******************************************************************************
5
* Copyright (C) 2006,2007,2008 John Varouhakis *
8
* This program is free software; you can redistribute it and/or modify *
9
* it under the terms of the GNU General Public License as published by *
10
* the Free Software Foundation; either version 2 of the License, or *
11
* (at your option) any later version. *
13
* This program is distributed in the hope that it will be useful, *
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16
* GNU General Public License for more details. *
18
* You should have received a copy of the GNU General Public License *
19
* along with this program; if not, write to the Free Software *
20
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
24
* For further information contact me at johnvarouhakis@gmail.com *
25
******************************************************************************/
36
//define which way we are reading a pixmap
37
#if __BYTE_ORDER == __LITTLE_ENDIAN
43
#elif __BYTE_ORDER == __BIG_ENDIAN
51
#error Only little-endian and big-endian systems are supported
54
#define __RVALUE_32(tmp_val) (((tmp_val)&0x00ff0000)>>16)
55
#define __GVALUE_32(tmp_val) (((tmp_val)&0x0000ff00)>>8)
56
#define __BVALUE_32(tmp_val) (((tmp_val)&0x000000ff))
58
#define __R16_MASK 0xf800
59
#define __G16_MASK 0x7e0
60
#define __B16_MASK 0x1f
62
#define __RVALUE_16(tmp_val) ((((tmp_val)&__R16_MASK)>>11)*8)
63
#define __GVALUE_16(tmp_val) ((((tmp_val)&__G16_MASK)>>5)*4)
64
#define __BVALUE_16(tmp_val) ((((tmp_val)&__B16_MASK))*8)
66
//xfixes pointer data are written as unsigned long
67
//(even though the server returns CARD32)
68
//so we need to set the step accordingly to
69
//avoid problems (amd64 has 8byte ulong)
70
#define RMD_ULONG_SIZE_T (sizeof(unsigned long))
72
//size of stride when comparing planes(depending on type)
73
//this is just to avoid thousands of sizeof's
75
#define COMPARE_STRIDE 8
77
#define COMPARE_STRIDE 4
81
#define CACHE_FILE_SIZE_LIMIT (500*1<<20)
82
//minimize hard disk access
83
#define CACHE_OUT_BUFFER_SIZE 4096
86
//The width, in bytes, of the blocks
87
//on which the y,u and v planes are broken.
88
//These blocks are square.
89
#define Y_UNIT_WIDTH 0x0010
90
#define UV_UNIT_WIDTH 0x0008
92
//The number of bytes for every
93
//sub-block of the y,u and v planes.
94
//Since the blocks are square
95
//these are obviously the squares
96
//of the widths(specified above),
97
//but the definitions bellow are only
98
//for convenience anyway.
99
#define Y_UNIT_BYTES 0x0100
100
#define UV_UNIT_BYTES 0x0040
102
#ifdef HAVE_LIBASOUND
103
#define DEFAULT_AUDIO_DEVICE "hw:0,0"
105
#define DEFAULT_AUDIO_DEVICE "/dev/dsp"
110
#define CLIP_EVENT_AREA(e,brwin,wgeom){\
111
if(((e)->area.x<=(brwin)->rgeom.x)&&((e)->area.y<=(brwin)->rgeom.y)&&\
112
((e)->area.width>=(brwin)->rgeom.width)&&\
113
((e)->area.height<(brwin)->rgeom.height)){\
114
(wgeom)->x=(brwin)->rgeom.x;\
115
(wgeom)->y=(brwin)->rgeom.y;\
116
(wgeom)->width=(brwin)->rgeom.width;\
117
(wgeom)->height=(brwin)->rgeom.height;\
120
(wgeom)->x=((((e)->area.x+(e)->area.width>=(brwin)->rgeom.x)&&\
121
((e)->area.x<=(brwin)->rgeom.x+(brwin)->rgeom.width))?\
122
(((e)->area.x<=(brwin)->rgeom.x)?(brwin)->rgeom.x:(e)->area.x):-1);\
124
(wgeom)->y=((((e)->area.y+(e)->area.height>=(brwin)->rgeom.y)&&\
125
((e)->area.y<=(brwin)->rgeom.y+(brwin)->rgeom.height))?\
126
(((e)->area.y<=(brwin)->rgeom.y)?(brwin)->rgeom.y:(e)->area.y):-1);\
128
(wgeom)->width=((e)->area.x<=(brwin)->rgeom.x)?\
129
(e)->area.width-((brwin)->rgeom.x-(e)->area.x):\
130
((e)->area.x<=(brwin)->rgeom.x+(brwin)->rgeom.width)?\
131
(((brwin)->rgeom.width-(e)->area.x+(brwin)->rgeom.x<(e)->area.width)?\
132
(brwin)->rgeom.width-(e)->area.x+(brwin)->rgeom.x:e->area.width):-1;\
134
(wgeom)->height=((e)->area.y<=(brwin)->rgeom.y)?\
135
(e)->area.height-((brwin)->rgeom.y-(e)->area.y):\
136
((e)->area.y<=(brwin)->rgeom.y+(brwin)->rgeom.height)?\
137
(((brwin)->rgeom.height-(e)->area.y+\
138
(brwin)->rgeom.y<(e)->area.height)?\
139
(brwin)->rgeom.height-(e)->area.y+\
140
(brwin)->rgeom.y:(e)->area.height):-1;\
142
if((wgeom)->width>(brwin)->rgeom.width)\
143
(wgeom)->width=(brwin)->rgeom.width;\
144
if((wgeom)->height>(brwin)->rgeom.height)\
145
(wgeom)->height=(brwin)->rgeom.height;\
149
#define CLIP_DUMMY_POINTER_AREA(dummy_p_area,brwin,wgeom){\
150
(wgeom)->x=((((dummy_p_area).x+\
151
(dummy_p_area).width>=(brwin)->rgeom.x)&&\
152
((dummy_p_area).x<=(brwin)->rgeom.x+\
153
(brwin)->rgeom.width))?\
154
(((dummy_p_area).x<=(brwin)->rgeom.x)?\
155
(brwin)->rgeom.x:(dummy_p_area).x):-1);\
156
(wgeom)->y=((((dummy_p_area).y+\
157
(dummy_p_area).height>=(brwin)->rgeom.y)&&\
158
((dummy_p_area).y<=(brwin)->rgeom.y+\
159
(brwin)->rgeom.height))?\
160
(((dummy_p_area).y<=(brwin)->rgeom.y)?\
161
(brwin)->rgeom.y:(dummy_p_area).y):-1);\
162
(wgeom)->width=((dummy_p_area).x<=(brwin)->rgeom.x)?\
163
(dummy_p_area).width-\
164
((brwin)->rgeom.x-(dummy_p_area).x):\
165
((dummy_p_area).x<=(brwin)->rgeom.x+\
166
(brwin)->rgeom.width)?\
167
((brwin)->rgeom.width-(dummy_p_area).x+\
168
(brwin)->rgeom.x<(dummy_p_area).width)?\
169
(brwin)->rgeom.width-(dummy_p_area).x+\
170
(brwin)->rgeom.x:(dummy_p_area).width:-1;\
171
(wgeom)->height=((dummy_p_area).y<=(brwin)->rgeom.y)?\
172
(dummy_p_area).height-\
173
((brwin)->rgeom.y-(dummy_p_area).y):\
174
((dummy_p_area).y<=(brwin)->rgeom.y+\
175
(brwin)->rgeom.height)?\
176
((brwin)->rgeom.height-(dummy_p_area).y+\
177
(brwin)->rgeom.y<(dummy_p_area).height)?\
178
(brwin)->rgeom.height-(dummy_p_area).y+\
179
(brwin)->rgeom.y:(dummy_p_area).height:-1;\
180
if((wgeom)->width>(brwin)->rgeom.width)\
181
(wgeom)->width=(brwin)->rgeom.width;\
182
if((wgeom)->height>(brwin)->rgeom.height)\
183
(wgeom)->height=(brwin)->rgeom.height;\
188
#define DEFAULT_ARGS(args){\
190
if(getenv("DISPLAY")!=NULL){\
191
(args)->display=(char *)malloc(strlen(getenv("DISPLAY"))+1);\
192
strcpy((args)->display,getenv("DISPLAY"));\
195
(args)->display=NULL;\
203
(args)->follow_mouse=\
204
(args)->encOnTheFly=\
211
(args)->jack_nports=0;\
212
(args)->jack_ringbuffer_secs=3.0;\
213
(args)->jack_port_names=NULL;\
214
(args)->zerocompression=\
215
(args)->no_quick_subsample=1;\
216
(args)->filename=(char *)malloc(8);\
217
strcpy((args)->filename,"out.ogv");\
218
(args)->cursor_color=1;\
219
(args)->have_dummy_cursor=0;\
220
(args)->xfixes_cursor=1;\
221
(args)->device=(char *)malloc(strlen(DEFAULT_AUDIO_DEVICE)+1);\
222
strcpy((args)->device,DEFAULT_AUDIO_DEVICE);\
225
(args)->frequency=22050;\
226
(args)->buffsize=4096;\
227
(args)->v_bitrate=45000;\
228
(args)->v_quality=63;\
229
(args)->s_quality=10;\
230
(args)->workdir=(char *)malloc(5);\
231
strcpy((args)->workdir,"/tmp");\
232
(args)->pause_shortcut=(char *)malloc(15);\
233
strcpy((args)->pause_shortcut,"Control+Mod1+p");\
234
(args)->stop_shortcut=(char *)malloc(15);\
235
strcpy((args)->stop_shortcut,"Control+Mod1+s");\
238
#define QUERY_DISPLAY_SPECS(display,specstruct){\
239
(specstruct)->screen=DefaultScreen(display);\
240
(specstruct)->width=DisplayWidth(display,(specstruct)->screen);\
241
(specstruct)->height=DisplayHeight(display,(specstruct)->screen);\
242
(specstruct)->root=RootWindow(display,(specstruct)->screen);\
243
(specstruct)->visual=DefaultVisual(display,(specstruct)->screen);\
244
(specstruct)->gc=DefaultGC(display,(specstruct)->screen);\
245
(specstruct)->depth=DefaultDepth(display,(specstruct)->screen);\
246
(specstruct)->bpixel=XBlackPixel(display,(specstruct)->screen);\
247
(specstruct)->wpixel=XWhitePixel(display,(specstruct)->screen);\
250
#define AVG_4_PIXELS(data_array,width_img,k_tm,i_tm,offset)\
251
((data_array[(k_tm*width_img+i_tm)*RMD_ULONG_SIZE_T+offset]+\
252
data_array[((k_tm-1)*width_img+i_tm)*RMD_ULONG_SIZE_T+offset]+\
253
data_array[(k_tm*width_img+i_tm-1)*RMD_ULONG_SIZE_T+offset]+\
254
data_array[((k_tm-1)*width_img+i_tm-1)*RMD_ULONG_SIZE_T+offset])/4)
257
//the 4 most significant bytes represent the A component which
258
//does not need to be added on t_val, as it is always unused
259
#define CALC_TVAL_AVG_32(t_val,datapi,datapi_next){\
260
register unsigned int t1,t2,t3,t4;\
264
t4=*(datapi_next+1);\
265
t_val=((((t1&0x00ff0000) +(t2&0x00ff0000)+\
266
(t3&0x00ff0000)+(t4&0x00ff0000))/4)&0x00ff0000)+\
267
((((t1&0x0000ff00) +(t2&0x0000ff00)+\
268
(t3&0x0000ff00)+(t4&0x0000ff00))/4)&0x0000ff00)+\
269
((((t1&0x000000ff) +(t2&0x000000ff)+\
270
(t3&0x000000ff)+(t4&0x000000ff))/4)&0x000000ff);\
273
//when adding the r values, we go beyond
274
//the (16 bit)range of the t_val variable, but we are performing
275
//32 bit arithmetics, so there's no problem.
276
//(This note is useless, I'm just adding because
277
//the addition of the A components in CALC_TVAL_AVG_32,
278
//now removed as uneeded, produced an overflow which would have caused
279
//color distrtion, where it one of the R,G or B components)
280
#define CALC_TVAL_AVG_16(t_val,datapi,datapi_next){\
281
register u_int16_t t1,t2,t3,t4;\
285
t4=*(datapi_next+1);\
286
t_val=((((t1&__R16_MASK) +(t2&__R16_MASK)+\
287
(t3&__R16_MASK)+(t4&__R16_MASK))/4)&__R16_MASK)+\
288
((((t1&__G16_MASK) +(t2&__G16_MASK)+\
289
(t3&__G16_MASK)+(t4&__G16_MASK))/4)&__G16_MASK)+\
290
((((t1&__B16_MASK) +(t2&__B16_MASK)+\
291
(t3&__B16_MASK)+(t4&__B16_MASK))/4)&__B16_MASK);\
294
#define POINT_IN_BLOCK(xv,yv,widthv,blocksize) ((yv/blocksize)*\
298
#define UPDATE_Y_PLANE(data,\
306
register u_int##__bit_depth__##_t t_val;\
307
register unsigned char *yuv_y=yuv->y+x_tm+y_tm*yuv->y_width,\
308
*_yr=Yr,*_yg=Yg,*_yb=Yb;\
309
register u_int##__bit_depth__##_t *datapi=(u_int##__bit_depth__##_t *)data;\
310
for(k=0;k<height_tm;k++){\
311
for(i=0;i<width_tm;i++){\
313
*yuv_y=_yr[__RVALUE_##__bit_depth__(t_val)] +\
314
_yg[__GVALUE_##__bit_depth__(t_val)] +\
315
_yb[__BVALUE_##__bit_depth__(t_val)] ;\
319
yuv_y+=yuv->y_width-width_tm;\
323
#define UPDATE_Y_PLANE_DBUF(data,\
332
register u_int##__bit_depth__##_t t_val;\
333
register unsigned char *yuv_y=yuv->y+x_tm+y_tm*yuv->y_width,\
334
*_yr=Yr,*_yg=Yg,*_yb=Yb;\
335
register u_int##__bit_depth__##_t *datapi=(u_int##__bit_depth__##_t *)data,\
336
*datapi_back=(u_int##__bit_depth__##_t *)data_back;\
337
for(k=0;k<height_tm;k++){\
338
for(i=0;i<width_tm;i++){\
339
if(*datapi!=*datapi_back){\
341
*yuv_y=_yr[__RVALUE_##__bit_depth__(t_val)] +\
342
_yg[__GVALUE_##__bit_depth__(t_val)] +\
343
_yb[__BVALUE_##__bit_depth__(t_val)] ;\
344
yblocks[POINT_IN_BLOCK(i,k,width_tm,Y_UNIT_WIDTH)]=1;\
350
yuv_y+=yuv->y_width-width_tm;\
354
#define UPDATE_A_UV_PIXEL(yuv_u,\
359
_ur,_ug,_ubvr,_vg,_vb,\
362
if(__sampling_type==__PXL_AVERAGE){\
363
CALC_TVAL_AVG_##__bit_depth__(t_val,datapi,datapi_next)\
368
_ur[__RVALUE_##__bit_depth__(t_val)] +\
369
_ug[__GVALUE_##__bit_depth__(t_val)] +\
370
_ubvr[__BVALUE_##__bit_depth__(t_val)];\
372
_ubvr[__RVALUE_##__bit_depth__(t_val)] +\
373
_vg[__GVALUE_##__bit_depth__(t_val)] +\
374
_vb[__BVALUE_##__bit_depth__(t_val)];\
377
#define UPDATE_UV_PLANES(data,\
386
register u_int##__bit_depth__##_t t_val;\
387
register unsigned char *yuv_u=yuv->u+x_tm/2+(y_tm*yuv->uv_width)/2,\
388
*yuv_v=yuv->v+x_tm/2+(y_tm*yuv->uv_width)/2,\
389
*_ur=Ur,*_ug=Ug,*_ubvr=UbVr,\
391
register u_int##__bit_depth__##_t *datapi=(u_int##__bit_depth__##_t *)data,\
393
if(__sampling_type==__PXL_AVERAGE){\
394
datapi_next=datapi+width_tm;\
396
for(k=0;k<height_tm;k+=2){\
397
for(i=0;i<width_tm;i+=2){\
398
UPDATE_A_UV_PIXEL( yuv_u,\
403
_ur,_ug,_ubvr,_vg,_vb,\
407
if(__sampling_type==__PXL_AVERAGE)\
412
yuv_u+=(yuv->y_width-width_tm)/2;\
413
yuv_v+=(yuv->y_width-width_tm)/2;\
415
if(__sampling_type==__PXL_AVERAGE)\
416
datapi_next+=width_tm;\
420
#define UPDATE_UV_PLANES_DBUF( data,\
430
register u_int##__bit_depth__##_t t_val;\
431
register unsigned char *yuv_u=yuv->u+x_tm/2+(y_tm*yuv->uv_width)/2,\
432
*yuv_v=yuv->v+x_tm/2+(y_tm*yuv->uv_width)/2,\
433
*_ur=Ur,*_ug=Ug,*_ubvr=UbVr,\
435
register u_int##__bit_depth__##_t *datapi=(u_int##__bit_depth__##_t *)data,\
437
*datapi_back=(u_int##__bit_depth__##_t *)data_back,\
438
*datapi_back_next=NULL;\
439
if(__sampling_type==__PXL_AVERAGE){\
440
datapi_next=datapi+width_tm;\
441
datapi_back_next=datapi_back+width_tm;\
442
for(k=0;k<height_tm;k+=2){\
443
for(i=0;i<width_tm;i+=2){\
444
if(( (*datapi!=*datapi_back) ||\
445
(*(datapi+1)!=*(datapi_back+1)) ||\
446
(*datapi_next!=*datapi_back_next) ||\
447
(*(datapi_next+1)!=*(datapi_back_next+1)))){\
448
UPDATE_A_UV_PIXEL( yuv_u,\
453
_ur,_ug,_ubvr,_vg,_vb,\
456
ublocks[POINT_IN_BLOCK(i,k,width_tm,Y_UNIT_WIDTH)]=1;\
457
vblocks[POINT_IN_BLOCK(i,k,width_tm,Y_UNIT_WIDTH)]=1;\
461
if(__sampling_type==__PXL_AVERAGE){\
463
datapi_back_next+=2;\
468
yuv_u+=(yuv->y_width-width_tm)/2;\
469
yuv_v+=(yuv->y_width-width_tm)/2;\
471
datapi_back+=width_tm;\
472
if(__sampling_type==__PXL_AVERAGE){\
473
datapi_next+=width_tm;\
474
datapi_back_next+=width_tm;\
479
for(k=0;k<height_tm;k+=2){\
480
for(i=0;i<width_tm;i+=2){\
481
if ((*datapi!=*datapi_back)){\
482
UPDATE_A_UV_PIXEL( yuv_u,\
487
_ur,_ug,_ubvr,_vg,_vb,\
490
ublocks[POINT_IN_BLOCK(i,k,width_tm,Y_UNIT_WIDTH)]=1;\
491
vblocks[POINT_IN_BLOCK(i,k,width_tm,Y_UNIT_WIDTH)]=1;\
495
if(__sampling_type==__PXL_AVERAGE){\
497
datapi_back_next+=2;\
502
yuv_u+=(yuv->y_width-width_tm)/2;\
503
yuv_v+=(yuv->y_width-width_tm)/2;\
505
datapi_back+=width_tm;\
506
if(__sampling_type==__PXL_AVERAGE){\
507
datapi_next+=width_tm;\
508
datapi_back_next+=width_tm;\
514
#define UPDATE_YUV_BUFFER(yuv,\
523
if(data_back==NULL){\
524
if((__color_depth==24)||(__color_depth==32)){\
525
UPDATE_Y_PLANE(data,x_tm,y_tm,height_tm,width_tm,yuv,32)\
526
UPDATE_UV_PLANES(data,x_tm,y_tm,height_tm,width_tm,\
527
yuv,__sampling_type,32)\
529
else if(__color_depth==16){\
530
UPDATE_Y_PLANE(data,x_tm,y_tm,height_tm,width_tm,yuv,16)\
531
UPDATE_UV_PLANES(data,x_tm,y_tm,height_tm,width_tm,\
532
yuv,__sampling_type,16)\
536
if((__color_depth==24)||(__color_depth==32)){\
537
UPDATE_Y_PLANE_DBUF(data,data_back,x_tm,y_tm,\
538
height_tm,width_tm,yuv,32)\
539
UPDATE_UV_PLANES_DBUF(data,data_back,x_tm,y_tm,height_tm,width_tm,\
540
yuv,__sampling_type,32)\
542
else if(__color_depth==16){\
543
UPDATE_Y_PLANE_DBUF(data,data_back,x_tm,y_tm,\
544
height_tm,width_tm,yuv,16)\
545
UPDATE_UV_PLANES_DBUF(data,data_back,x_tm,y_tm,height_tm,width_tm,\
546
yuv,__sampling_type,16)\
553
#define XFIXES_POINTER_TO_YUV(yuv,\
561
column_discard_stride){\
563
unsigned char avg0,avg1,avg2,avg3;\
564
int x_2=x_tm/2,y_2=y_tm/2;\
565
for(k=y_offset;k<y_offset+height_tm;k++){\
566
for(i=x_offset;i<x_offset+width_tm;i++){\
567
j=k*(width_tm+column_discard_stride)+i;\
568
yuv->y[x_tm+(i-x_offset)+(k+y_tm-y_offset)*yuv->y_width]=\
569
(yuv->y[x_tm+(i-x_offset)+(k-y_offset+y_tm)*yuv->y_width]*\
570
(UCHAR_MAX-data[(j*RMD_ULONG_SIZE_T)+__ABYTE])+\
571
(Yr[data[(j*RMD_ULONG_SIZE_T)+__RBYTE]]+\
572
Yg[data[(j*RMD_ULONG_SIZE_T)+__GBYTE]] +\
573
Yb[data[(j*RMD_ULONG_SIZE_T)+__BBYTE]])*\
574
data[(j*RMD_ULONG_SIZE_T)+__ABYTE])/UCHAR_MAX ;\
576
avg3=AVG_4_PIXELS(data,\
577
(width_tm+column_discard_stride),\
579
avg2=AVG_4_PIXELS(data,\
580
(width_tm+column_discard_stride),\
582
avg1=AVG_4_PIXELS(data,\
583
(width_tm+column_discard_stride),\
585
avg0=AVG_4_PIXELS(data,\
586
(width_tm+column_discard_stride),\
588
yuv->u[x_2+(i-x_offset)/2+((k-y_offset)/2+y_2)*\
590
(yuv->u[x_2+(i-x_offset)/2+((k-y_offset)/2+y_2)*\
593
(Ur[avg2] + Ug[avg1] +UbVr[avg0])*avg3)/UCHAR_MAX;\
594
yuv->v[x_2+(i-x_offset)/2+((k-y_offset)/2+y_2)*\
596
(yuv->v[x_2+(i-x_offset)/2+((k-y_offset)/2+y_2)*\
599
(UbVr[avg2] + Vg[avg1] +Vb[avg0])*avg3)/UCHAR_MAX;\
605
#define DUMMY_POINTER_TO_YUV(yuv,\
615
int x_2=x_tm/2,y_2=y_tm/2,y_width_2=(yuv)->y_width/2;\
616
for(k=y_offset;k<y_offset+height_tm;k++){\
617
for(i=x_offset;i<x_offset+width_tm;i++){\
619
if(data_tm[(j*4)]!=(no_pixel)){\
620
(yuv)->y[x_tm+(i-x_offset)+((k-y_offset)+y_tm)*(yuv)->y_width]=\
621
Yr[data_tm[(j*4)+__RBYTE]] +\
622
Yg[data_tm[(j*4)+__GBYTE]] +\
623
Yb[data_tm[(j*4)+__BBYTE]];\
625
yuv->u[x_2+(i-x_offset)/2+((k-y_offset)/2+y_2)*y_width_2]=\
626
Ur[data_tm[(k*width_tm+i)*4+__RBYTE]] +\
627
Ug[data_tm[(k*width_tm+i)*4+__GBYTE]] +\
628
UbVr[data_tm[(k*width_tm+i)*4+__BBYTE]];\
629
yuv->v[x_2+(i-x_offset)/2+((k-y_offset)/2+y_2)*y_width_2]=\
630
UbVr[data_tm[(k*width_tm+i)*4+__RBYTE]] +\
631
Vg[data_tm[(k*width_tm+i)*4+__GBYTE]] +\
632
Vb[data_tm[(k*width_tm+i)*4+__BBYTE]] ;\
639
#define MARK_BACK_BUFFER( data,\
646
if((__bit_depth__==24)||(__bit_depth__==32)){\
647
MARK_BACK_BUFFER_C( data,\
656
MARK_BACK_BUFFER_C( data,\
667
#define MARK_BACK_BUFFER_C( data,\
675
register u_int##__bit_depth__##_t\
677
((u_int##__bit_depth__##_t *)data)+y_tm*buffer_width+x_tm;\
678
for(k=0;k<height_tm;k++){\
679
for(i=0;i<width_tm;i++){\
683
datapi+=buffer_width-width_tm;\
687
#define I16TOA(number,buffer){\
688
int t_num=(number),__k=0,__i=0;\
689
char *t_buf=malloc(8);\
690
t_num=t_num&((2<<15)-1);\
693
t_buf[__k]=digit+48;\
699
(buffer)[__i++]=t_buf[--__k];\
704
#define INIT_FRAME(frame_t,fheader_t,yuv_t,\
705
YBlocks_t,UBlocks_t,VBlocks_t){\
706
(frame_t)->header=(fheader_t);\
707
(frame_t)->YBlocks=YBlocks_t;\
708
(frame_t)->UBlocks=UBlocks_t;\
709
(frame_t)->VBlocks=VBlocks_t;\
710
(frame_t)->YData=malloc((yuv_t)->y_width*(yuv_t)->y_height);\
711
(frame_t)->UData=malloc((yuv_t)->uv_width*(yuv_t)->uv_height);\
712
(frame_t)->VData=malloc((yuv_t)->uv_width*(yuv_t)->uv_height);\
715
#define CLEAR_FRAME(frame_t){\
716
free((frame_t)->YData);\
717
free((frame_t)->UData);\
718
free((frame_t)->VData);\
723
#define CHECK_DLERRORS_FATAL(__error_p)\
724
if((__error_p=dlerror())!=NULL){\
725
fprintf(stderr,"%s\n",__error_p);\
729
#define DLSYM_AND_CHECK(lib_handle,__call_name__,__error_p)\
730
__call_name__##_p=dlsym(lib_handle,#__call_name__);\
731
CHECK_DLERRORS_FATAL(__error_p)