33
33
#ifndef __NODE_COMPOSITE_UTIL_H__
34
34
#define __NODE_COMPOSITE_UTIL_H__
40
#include "MEM_guardedalloc.h"
42
#include "DNA_camera_types.h" /* qdn: defocus node, need camera info */
43
#include "DNA_color_types.h"
44
36
#include "DNA_ID.h"
45
#include "DNA_image_types.h"
46
#include "DNA_material_types.h"
47
37
#include "DNA_movieclip_types.h"
48
38
#include "DNA_node_types.h"
49
#include "DNA_object_types.h"
50
#include "DNA_scene_types.h"
51
#include "DNA_texture_types.h"
53
40
#include "BLI_math.h"
54
41
#include "BLI_blenlib.h"
56
#include "BLI_threads.h"
57
#include "BLI_utildefines.h"
58
#include "BLI_utildefines.h"
60
#include "BKE_blender.h"
61
#include "BKE_camera.h"
43
#include "BLF_translation.h"
62
45
#include "BKE_colortools.h"
63
#include "BKE_global.h"
64
46
#include "BKE_image.h"
66
#include "BKE_material.h"
67
#include "BKE_movieclip.h"
69
47
#include "BKE_texture.h"
70
48
#include "BKE_tracking.h"
72
#include "BKE_library.h"
73
#include "BKE_object.h"
75
50
#include "node_util.h"
77
52
#include "IMB_imbuf_types.h"
78
53
#include "IMB_imbuf.h"
80
55
#include "RE_pipeline.h"
81
#include "RE_shader_ext.h"
82
#include "RE_render_ext.h"
84
57
/* only for forward declarations */
85
58
#include "NOD_composite.h"
88
/* *************************** operations support *************************** */
90
/* general signal that's in output sockets, and goes over the wires */
91
typedef struct CompBuf {
95
rcti disprect; /* cropped part of image */
96
int xof, yof; /* relative to center of target image */
98
void (*rect_procedural)(struct CompBuf *, float *, float, float);
99
float procedural_size[3], procedural_offset[3];
101
bNode *node; /* only in use for procedural bufs */
103
struct CompBuf *next, *prev; /* for pass-on, works nicer than reference counting */
106
/* defines also used for pixel size */
113
/* defines for RGBA channels */
121
CompBuf *alloc_compbuf(int sizex, int sizey, int type, int alloc);
122
CompBuf *dupalloc_compbuf(CompBuf *cbuf);
123
CompBuf *pass_on_compbuf(CompBuf *cbuf);
124
void free_compbuf(CompBuf *cbuf);
125
void print_compbuf(char *str, CompBuf *cbuf);
126
void compbuf_set_node(struct CompBuf *cbuf, struct bNode *node);
128
CompBuf *get_cropped_compbuf(rcti *drect, float *rectf, int rectx, int recty, int type);
129
CompBuf *scalefast_compbuf(CompBuf *inbuf, int newx, int newy);
130
CompBuf *typecheck_compbuf(CompBuf *inbuf, int type);
131
void typecheck_compbuf_color(float *out, float *in, int outtype, int intype);
133
/* **************************************************** */
135
float *compbuf_get_pixel(CompBuf *cbuf, float *defcol, float *use, int x, int y, int xrad, int yrad);
137
/* Pixel-to-Pixel operation, 1 Image in, 1 out */
138
void composit1_pixel_processor(bNode *node, CompBuf *out, CompBuf *src_buf, float *src_col,
139
void (*func)(bNode *, float *, float *),
141
/* Pixel-to-Pixel operation, 2 Images in, 1 out */
142
void composit2_pixel_processor(bNode *node, CompBuf *out, CompBuf *src_buf, float *src_col,
143
CompBuf *fac_buf, float *fac, void (*func)(bNode *, float *, float *, float *),
144
int src_type, int fac_type);
146
/* Pixel-to-Pixel operation, 3 Images in, 1 out */
147
void composit3_pixel_processor(bNode *node, CompBuf *out, CompBuf *src1_buf, float *src1_col, CompBuf *src2_buf, float *src2_col,
148
CompBuf *fac_buf, float *fac, void (*func)(bNode *, float *, float *, float *, float *),
149
int src1_type, int src2_type, int fac_type);
151
/* Pixel-to-Pixel operation, 4 Images in, 1 out */
152
void composit4_pixel_processor(bNode *node, CompBuf *out, CompBuf *src1_buf, float *src1_col, CompBuf *fac1_buf, float *fac1,
153
CompBuf *src2_buf, float *src2_col, CompBuf *fac2_buf, float *fac2,
154
void (*func)(bNode *, float *, float *, float *, float *, float *),
155
int src1_type, int fac1_type, int src2_type, int fac2_type);
157
CompBuf *valbuf_from_rgbabuf(CompBuf *cbuf, int channel);
158
void generate_preview(void *data, bNode *node, CompBuf *stackbuf);
160
void do_copy_rgba(bNode *node, float *out, float *in);
161
void do_copy_rgb(bNode *node, float *out, float *in);
162
void do_copy_value(bNode *node, float *out, float *in);
163
void do_copy_a_rgba(bNode *node, float *out, float *in, float *fac);
165
void do_rgba_to_yuva(bNode *node, float *out, float *in);
166
void do_rgba_to_hsva(bNode *node, float *out, float *in);
167
void do_rgba_to_ycca(bNode *node, float *out, float *in);
168
void do_yuva_to_rgba(bNode *node, float *out, float *in);
169
void do_hsva_to_rgba(bNode *node, float *out, float *in);
170
void do_ycca_to_rgba(bNode *node, float *out, float *in);
172
void gamma_correct_compbuf(CompBuf *img, int inversed);
173
void premul_compbuf(CompBuf *img, int inversed);
174
void convolve(CompBuf* dst, CompBuf* in1, CompBuf* in2);
176
extern void node_ID_title_cb(void *node_v, void *unused_v);
179
/* utility functions used by glare, tonemap and lens distortion */
180
/* soms macros for color handling */
181
typedef float fRGB[4];
183
#define fRGB_clear(c) { c[0]=c[1]=c[2]=0.f; }
185
#define fRGB_copy(c1, c2) { c1[0]=c2[0]; c1[1]=c2[1]; c1[2]=c2[2]; c1[3]=c2[3]; }
187
#define fRGB_add(c1, c2) { c1[0]+=c2[0]; c1[1]+=c2[1]; c1[2]+=c2[2]; }
188
/* subtract c2 from c1 */
189
#define fRGB_sub(c1, c2) { c1[0]-=c2[0]; c1[1]-=c2[1]; c1[2]-=c2[2]; }
190
/* multiply c by float value s */
191
#define fRGB_mult(c, s) { c[0]*=s; c[1]*=s; c[2]*=s; }
192
/* multiply c2 by s and add to c1 */
193
#define fRGB_madd(c1, c2, s) { c1[0]+=c2[0]*s; c1[1]+=c2[1]*s; c1[2]+=c2[2]*s; }
194
/* multiply c2 by color c1 */
195
#define fRGB_colormult(c, cs) { c[0]*=cs[0]; c[1]*=cs[1]; c[2]*=cs[2]; }
196
/* multiply c2 by color c3 and add to c1 */
197
#define fRGB_colormadd(c1, c2, c3) { c1[0]+=c2[0]*c3[0]; c1[1]+=c2[1]*c3[1]; c1[2]+=c2[2]*c3[2]; }
198
/* multiply c2 by color rgb, rgb as separate arguments */
199
#define fRGB_rgbmult(c, r, g, b) { c[0]*=(r); c[1]*=(g); c[2]*=(b); }
200
/* swap colors c1 & c2 */
201
#define fRGB_swap(c1, c2) { float _t=c1[0]; c1[0]=c2[0]; c2[0]=_t;\
202
_t=c1[1]; c1[1]=c2[1]; c2[1]=_t;\
203
_t=c1[2]; c1[2]=c2[2]; c2[2]=_t;\
204
_t=c1[3]; c1[3]=c2[3]; c3[3]=_t;}
206
void qd_getPixel(CompBuf* src, int x, int y, float* col);
207
void qd_setPixel(CompBuf* src, int x, int y, float* col);
208
void qd_addPixel(CompBuf* src, int x, int y, float* col);
209
void qd_multPixel(CompBuf* src, int x, int y, float f);
210
void qd_getPixelLerpWrap(CompBuf* src, float u, float v, float* col);
211
void qd_getPixelLerp(CompBuf* src, float u, float v, float* col);
212
void qd_getPixelLerpChan(CompBuf* src, float u, float v, int chan, float* out);
213
CompBuf* qd_downScaledCopy(CompBuf* src, int scale);
214
void IIR_gauss(CompBuf* src, float sigma, int chan, int xy);
215
/* end utility funcs */
217
/* transformations */
219
60
#define CMP_SCALE_MAX 12000
221
CompBuf* node_composit_transform(CompBuf *cbuf, float x, float y, float angle, float scale, int filter_type);
222
float *node_composit_get_float_buffer(RenderData *rd, ImBuf *ibuf, int *alloc);
62
#endif /* __NODE_COMPOSITE_UTIL_H__ */