~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/nodes/intern/CMP_util.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * $Id: CMP_util.h 27888 2010-03-31 05:44:21Z broken $
3
 
 *
4
 
 * ***** BEGIN GPL LICENSE BLOCK *****
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or
7
 
 * modify it under the terms of the GNU General Public License
8
 
 * as published by the Free Software Foundation; either version 2
9
 
 * of the License, or (at your option) any later version. 
10
 
 *
11
 
 * This program is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software Foundation,
18
 
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 
 *
20
 
 * The Original Code is Copyright (C) 2006 Blender Foundation.
21
 
 * All rights reserved.
22
 
 *
23
 
 * The Original Code is: all of this file.
24
 
 *
25
 
 * Contributor(s): none yet.
26
 
 *
27
 
 * ***** END GPL LICENSE BLOCK *****
28
 
 */
29
 
 
30
 
#ifndef CMP_NODE_UTILS_H_
31
 
#define CMP_NODE_UTILS_H_
32
 
 
33
 
#include <stdlib.h>
34
 
#include <string.h>
35
 
#include <math.h>
36
 
 
37
 
#include "MEM_guardedalloc.h"
38
 
 
39
 
#include "DNA_camera_types.h" /* qdn: defocus node, need camera info */
40
 
#include "DNA_color_types.h"
41
 
#include "DNA_ID.h"
42
 
#include "DNA_image_types.h"
43
 
#include "DNA_material_types.h"
44
 
#include "DNA_node_types.h"
45
 
#include "DNA_object_types.h"
46
 
#include "DNA_scene_types.h"
47
 
#include "DNA_texture_types.h"
48
 
 
49
 
#include "BKE_blender.h"
50
 
#include "BKE_colortools.h"
51
 
#include "BKE_global.h"
52
 
#include "BKE_image.h"
53
 
#include "BKE_main.h"
54
 
#include "BKE_material.h"
55
 
#include "BKE_texture.h"
56
 
#include "BKE_utildefines.h"
57
 
#include "BKE_library.h"
58
 
#include "BKE_object.h"
59
 
 
60
 
#include "../CMP_node.h"
61
 
#include "node_util.h"
62
 
 
63
 
#include "BLI_math.h"
64
 
#include "BLI_blenlib.h"
65
 
#include "BLI_rand.h"
66
 
#include "BLI_threads.h"
67
 
 
68
 
#include "IMB_imbuf_types.h"
69
 
#include "IMB_imbuf.h"
70
 
 
71
 
#include "RE_pipeline.h"
72
 
#include "RE_shader_ext.h"
73
 
#include "RE_render_ext.h"
74
 
 
75
 
/* *************************** operations support *************************** */
76
 
 
77
 
/* general signal that's in output sockets, and goes over the wires */
78
 
typedef struct CompBuf {
79
 
        float *rect;
80
 
        int x, y, xrad, yrad;
81
 
        short type, malloc;
82
 
        rcti disprect;          /* cropped part of image */
83
 
        int xof, yof;           /* relative to center of target image */
84
 
        
85
 
        void (*rect_procedural)(struct CompBuf *, float *, float, float);
86
 
        float procedural_size[3], procedural_offset[3];
87
 
        int procedural_type;
88
 
        bNode *node;            /* only in use for procedural bufs */
89
 
        
90
 
        struct CompBuf *next, *prev;    /* for pass-on, works nicer than reference counting */
91
 
} CompBuf;
92
 
 
93
 
/* defines also used for pixel size */
94
 
#define CB_RGBA         4
95
 
#define CB_VEC4         4
96
 
#define CB_VEC3         3
97
 
#define CB_VEC2         2
98
 
#define CB_VAL          1
99
 
 
100
 
/* defines for RGBA channels */
101
 
#define CHAN_R  0
102
 
#define CHAN_G  1
103
 
#define CHAN_B  2
104
 
#define CHAN_A  3
105
 
 
106
 
 
107
 
 
108
 
CompBuf *alloc_compbuf(int sizex, int sizey, int type, int alloc);
109
 
CompBuf *dupalloc_compbuf(CompBuf *cbuf);
110
 
CompBuf *pass_on_compbuf(CompBuf *cbuf);
111
 
void free_compbuf(CompBuf *cbuf);
112
 
void print_compbuf(char *str, CompBuf *cbuf);
113
 
void compbuf_set_node(struct CompBuf *cbuf, struct bNode *node);
114
 
void node_compo_pass_on(struct bNode *node, struct bNodeStack **nsin, struct bNodeStack **nsout);
115
 
 
116
 
CompBuf *get_cropped_compbuf(rcti *drect, float *rectf, int rectx, int recty, int type);
117
 
CompBuf *scalefast_compbuf(CompBuf *inbuf, int newx, int newy);
118
 
CompBuf *typecheck_compbuf(CompBuf *inbuf, int type);
119
 
void typecheck_compbuf_color(float *out, float *in, int outtype, int intype);
120
 
float *compbuf_get_pixel(CompBuf *cbuf, float *rectf, int x, int y, int xrad, int yrad);
121
 
 
122
 
/* **************************************************** */
123
 
 
124
 
/* Pixel-to-Pixel operation, 1 Image in, 1 out */
125
 
void composit1_pixel_processor(bNode *node, CompBuf *out, CompBuf *src_buf, float *src_col,
126
 
                                                                          void (*func)(bNode *, float *, float *), 
127
 
                                                                          int src_type);
128
 
/* Pixel-to-Pixel operation, 2 Images in, 1 out */
129
 
void composit2_pixel_processor(bNode *node, CompBuf *out, CompBuf *src_buf, float *src_col,
130
 
                                                                          CompBuf *fac_buf, float *fac, void (*func)(bNode *, float *, float *, float *), 
131
 
                                                                          int src_type, int fac_type);
132
 
 
133
 
/* Pixel-to-Pixel operation, 3 Images in, 1 out */
134
 
void composit3_pixel_processor(bNode *node, CompBuf *out, CompBuf *src1_buf, float *src1_col, CompBuf *src2_buf, float *src2_col, 
135
 
                                                                          CompBuf *fac_buf, float *fac, void (*func)(bNode *, float *, float *, float *, float *), 
136
 
                                                                          int src1_type, int src2_type, int fac_type);
137
 
 
138
 
/* Pixel-to-Pixel operation, 4 Images in, 1 out */
139
 
void composit4_pixel_processor(bNode *node, CompBuf *out, CompBuf *src1_buf, float *src1_col, CompBuf *fac1_buf, float *fac1, 
140
 
                                                                          CompBuf *src2_buf, float *src2_col, CompBuf *fac2_buf, float *fac2, 
141
 
                                                                          void (*func)(bNode *, float *, float *, float *, float *, float *), 
142
 
                                                                          int src1_type, int fac1_type, int src2_type, int fac2_type);
143
 
 
144
 
CompBuf *valbuf_from_rgbabuf(CompBuf *cbuf, int channel);
145
 
void generate_preview(void *data, bNode *node, CompBuf *stackbuf);
146
 
 
147
 
void do_copy_rgba(bNode *node, float *out, float *in);
148
 
void do_copy_rgb(bNode *node, float *out, float *in);
149
 
void do_copy_value(bNode *node, float *out, float *in);
150
 
void do_copy_a_rgba(bNode *node, float *out, float *in, float *fac);
151
 
 
152
 
void do_rgba_to_yuva(bNode *node, float *out, float *in);
153
 
void do_rgba_to_hsva(bNode *node, float *out, float *in);
154
 
void do_rgba_to_ycca(bNode *node, float *out, float *in);
155
 
void do_yuva_to_rgba(bNode *node, float *out, float *in);
156
 
void do_hsva_to_rgba(bNode *node, float *out, float *in);
157
 
void do_ycca_to_rgba(bNode *node, float *out, float *in);
158
 
 
159
 
void gamma_correct_compbuf(CompBuf *img, int inversed);
160
 
void premul_compbuf(CompBuf *img, int inversed);
161
 
void convolve(CompBuf* dst, CompBuf* in1, CompBuf* in2);
162
 
 
163
 
extern void node_ID_title_cb(void *node_v, void *unused_v);
164
 
 
165
 
 
166
 
/* utility functions used by glare, tonemap and lense distortion */
167
 
/* soms macros for color handling */
168
 
typedef float fRGB[4];
169
 
/* clear color */
170
 
#define fRGB_clear(c) { c[0]=c[1]=c[2]=0.f; }
171
 
/* copy c2 to c1 */
172
 
#define fRGB_copy(c1, c2) { c1[0]=c2[0];  c1[1]=c2[1];  c1[2]=c2[2]; c1[3]=c2[3]; }
173
 
/* add c2 to c1 */
174
 
#define fRGB_add(c1, c2) { c1[0]+=c2[0];  c1[1]+=c2[1];  c1[2]+=c2[2]; }
175
 
/* subtract c2 from c1 */
176
 
#define fRGB_sub(c1, c2) { c1[0]-=c2[0];  c1[1]-=c2[1];  c1[2]-=c2[2]; }
177
 
/* multiply c by float value s */
178
 
#define fRGB_mult(c, s) { c[0]*=s;  c[1]*=s;  c[2]*=s; }
179
 
/* multiply c2 by s and add to c1 */
180
 
#define fRGB_madd(c1, c2, s) { c1[0]+=c2[0]*s;  c1[1]+=c2[1]*s;  c1[2]+=c2[2]*s; }
181
 
/* multiply c2 by color c1 */
182
 
#define fRGB_colormult(c, cs) { c[0]*=cs[0];  c[1]*=cs[1];  c[2]*=cs[2]; }
183
 
/* multiply c2 by color c3 and add to c1 */
184
 
#define fRGB_colormadd(c1, c2, c3) { c1[0]+=c2[0]*c3[0];  c1[1]+=c2[1]*c3[1];  c1[2]+=c2[2]*c3[2]; }
185
 
/* multiply c2 by color rgb, rgb as separate arguments */
186
 
#define fRGB_rgbmult(c, r, g, b) { c[0]*=(r);  c[1]*=(g);  c[2]*=(b); }
187
 
/* swap colors c1 & c2 */
188
 
#define fRGB_swap(c1, c2) { float _t=c1[0];  c1[0]=c2[0];  c2[0]=_t;\
189
 
                                                                  _t=c1[1];  c1[1]=c2[1];  c2[1]=_t;\
190
 
                                                                  _t=c1[2];  c1[2]=c2[2];  c2[2]=_t;\
191
 
                                                                  _t=c1[3];  c1[3]=c2[3];  c3[3]=_t;}
192
 
 
193
 
void qd_getPixel(CompBuf* src, int x, int y, float* col);
194
 
void qd_setPixel(CompBuf* src, int x, int y, float* col);
195
 
void qd_addPixel(CompBuf* src, int x, int y, float* col);
196
 
void qd_multPixel(CompBuf* src, int x, int y, float f);
197
 
void qd_getPixelLerpWrap(CompBuf* src, float u, float v, float* col);
198
 
void qd_getPixelLerp(CompBuf* src, float u, float v, float* col);
199
 
void qd_getPixelLerpChan(CompBuf* src, float u, float v, int chan, float* out);
200
 
CompBuf* qd_downScaledCopy(CompBuf* src, int scale);
201
 
void IIR_gauss(CompBuf* src, float sigma, int chan, int xy);
202
 
/* end utility funcs */
203
 
 
204
 
#endif