~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/nodes/composite/node_composite_util.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#ifndef __NODE_COMPOSITE_UTIL_H__
34
34
#define __NODE_COMPOSITE_UTIL_H__
35
35
 
36
 
#include <stdlib.h>
37
 
#include <string.h>
38
 
#include <math.h>
39
 
 
40
 
#include "MEM_guardedalloc.h"
41
 
 
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"
52
39
 
53
40
#include "BLI_math.h"
54
41
#include "BLI_blenlib.h"
55
 
#include "BLI_rand.h"
56
 
#include "BLI_threads.h"
57
 
#include "BLI_utildefines.h"
58
 
#include "BLI_utildefines.h"
59
 
 
60
 
#include "BKE_blender.h"
61
 
#include "BKE_camera.h"
 
42
 
 
43
#include "BLF_translation.h"
 
44
 
62
45
#include "BKE_colortools.h"
63
 
#include "BKE_global.h"
64
46
#include "BKE_image.h"
65
 
#include "BKE_main.h"
66
 
#include "BKE_material.h"
67
 
#include "BKE_movieclip.h"
68
 
#include "BKE_node.h"
69
47
#include "BKE_texture.h"
70
48
#include "BKE_tracking.h"
71
49
 
72
 
#include "BKE_library.h"
73
 
#include "BKE_object.h"
74
 
 
75
50
#include "node_util.h"
76
51
 
77
52
#include "IMB_imbuf_types.h"
78
53
#include "IMB_imbuf.h"
79
54
 
80
55
#include "RE_pipeline.h"
81
 
#include "RE_shader_ext.h"
82
 
#include "RE_render_ext.h"
83
56
 
84
57
/* only for forward declarations */
85
58
#include "NOD_composite.h"
86
59
 
87
 
 
88
 
/* *************************** operations support *************************** */
89
 
 
90
 
/* general signal that's in output sockets, and goes over the wires */
91
 
typedef struct CompBuf {
92
 
        float *rect;
93
 
        int x, y, xrad, yrad;
94
 
        short type, malloc;
95
 
        rcti disprect;          /* cropped part of image */
96
 
        int xof, yof;           /* relative to center of target image */
97
 
        
98
 
        void (*rect_procedural)(struct CompBuf *, float *, float, float);
99
 
        float procedural_size[3], procedural_offset[3];
100
 
        int procedural_type;
101
 
        bNode *node;            /* only in use for procedural bufs */
102
 
        
103
 
        struct CompBuf *next, *prev;    /* for pass-on, works nicer than reference counting */
104
 
} CompBuf;
105
 
 
106
 
/* defines also used for pixel size */
107
 
#define CB_RGBA         4
108
 
#define CB_VEC4         4
109
 
#define CB_VEC3         3
110
 
#define CB_VEC2         2
111
 
#define CB_VAL          1
112
 
 
113
 
/* defines for RGBA channels */
114
 
#define CHAN_R  0
115
 
#define CHAN_G  1
116
 
#define CHAN_B  2
117
 
#define CHAN_A  3
118
 
 
119
 
 
120
 
 
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);
127
 
 
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);
132
 
 
133
 
/* **************************************************** */
134
 
 
135
 
float *compbuf_get_pixel(CompBuf *cbuf, float *defcol, float *use, int x, int y, int xrad, int yrad);
136
 
 
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 *), 
140
 
                                                                          int src_type);
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);
145
 
 
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);
150
 
 
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);
156
 
 
157
 
CompBuf *valbuf_from_rgbabuf(CompBuf *cbuf, int channel);
158
 
void generate_preview(void *data, bNode *node, CompBuf *stackbuf);
159
 
 
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);
164
 
 
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);
171
 
 
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);
175
 
 
176
 
extern void node_ID_title_cb(void *node_v, void *unused_v);
177
 
 
178
 
 
179
 
/* utility functions used by glare, tonemap and lens distortion */
180
 
/* soms macros for color handling */
181
 
typedef float fRGB[4];
182
 
/* clear color */
183
 
#define fRGB_clear(c) { c[0]=c[1]=c[2]=0.f; }
184
 
/* copy c2 to c1 */
185
 
#define fRGB_copy(c1, c2) { c1[0]=c2[0];  c1[1]=c2[1];  c1[2]=c2[2]; c1[3]=c2[3]; }
186
 
/* add c2 to c1 */
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;}
205
 
 
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 */
216
 
 
217
 
/* transformations */
218
 
 
219
60
#define CMP_SCALE_MAX   12000
220
61
 
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);
223
 
 
224
 
#endif
 
62
#endif  /* __NODE_COMPOSITE_UTIL_H__ */