record batch dir path fix, handle yuv in gl masking, sync up maskengine/playback3d...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / overlaysample.h
1 #ifndef __OVERLAYSAMPLE_H__
2 #define __OVERLAYSAMPLE_H__
3 #include "overlayframe.h"
4
5 #define XSAMPLE(FN, temp_type, type, max, components, ofs, round) { \
6         float temp[oh*components]; \
7         temp_type opcty = fade * max + round, trnsp = max - opcty; \
8         type **output_rows = (type**)voutput->get_rows() + o1i; \
9         type **input_rows = (type**)vinput->get_rows(); \
10  \
11         for(int i = pkg->out_col1; i < pkg->out_col2; i++) { \
12                 type *input = input_rows[i - engine->col_out1 + engine->row_in]; \
13                 float *tempp = temp; \
14                 if( !k ) { /* direct copy case */ \
15                         type *ip = input + i1i * components; \
16                         for( int j=oh; --j>=0; ) { \
17                                 *tempp++ = *ip++; \
18                                 *tempp++ = *ip++ - ofs; \
19                                 *tempp++ = *ip++ - ofs; \
20                                 if( components == 4 ) *tempp++ = *ip++; \
21                         } \
22                 } \
23                 else { /* resample */ \
24                         for( int j=0; j<oh; ++j ) { \
25                                 float racc=0.f, gacc=0.f, bacc=0.f, aacc=0.f; \
26                                 int ki = lookup_sk[j], x = lookup_sx0[j]; \
27                                 type *ip = input + x * components; \
28                                 while(x < lookup_sx1[j]) { \
29                                         float kv = k[abs(ki >> INDEX_FRACTION)]; \
30                                         /* handle fractional pixels on edges of input */ \
31                                         if(x == i1i) kv *= i1f; \
32                                         if(++x == i2i) kv *= i2f; \
33                                         racc += kv * *ip++; \
34                                         gacc += kv * (*ip++ - ofs); \
35                                         bacc += kv * (*ip++ - ofs); \
36                                         if( components == 4 ) { aacc += kv * *ip++; } \
37                                         ki += kd; \
38                                 } \
39                                 float wacc = lookup_wacc[j]; \
40                                 *tempp++ = racc * wacc; \
41                                 *tempp++ = gacc * wacc; \
42                                 *tempp++ = bacc * wacc; \
43                                 if( components == 4 ) { *tempp++ = aacc * wacc; } \
44                         } \
45                 } \
46  \
47                 /* handle fractional pixels on edges of output */ \
48                 temp[0] *= o1f;   temp[1] *= o1f;   temp[2] *= o1f; \
49                 if( components == 4 ) temp[3] *= o1f; \
50                 tempp = temp + (oh-1)*components; \
51                 tempp[0] *= o2f;  tempp[1] *= o2f;  tempp[2] *= o2f; \
52                 if( components == 4 ) tempp[3] *= o2f; \
53                 tempp = temp; \
54                 /* blend output */ \
55                 for( int j=0; j<oh; ++j ) { \
56                         type *output = output_rows[j] + i * components; \
57                         if( components == 4 ) { \
58                                 temp_type r, g, b, a; \
59                                 ALPHA4_BLEND(FN, temp_type, tempp, output, max, 0, ofs, round); \
60                                 ALPHA4_STORE(output, ofs, max); \
61                         } \
62                         else { \
63                                 temp_type r, g, b; \
64                                 ALPHA3_BLEND(FN, temp_type, tempp, output, max, 0, ofs, round); \
65                                 ALPHA3_STORE(output, ofs, max); \
66                         } \
67                         tempp += components; \
68                 } \
69         } \
70 } break
71
72 #endif