Blender  V2.93
COM_MovieClipOperation.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * Copyright 2011, Blender Foundation.
17  */
18 
19 #include "COM_MovieClipOperation.h"
20 
21 #include "BLI_listbase.h"
22 #include "BLI_math.h"
23 
24 #include "BKE_image.h"
25 #include "BKE_movieclip.h"
26 
27 #include "IMB_imbuf.h"
28 
29 namespace blender::compositor {
30 
32 {
33  this->m_movieClip = nullptr;
34  this->m_movieClipBuffer = nullptr;
35  this->m_movieClipUser = nullptr;
36  this->m_movieClipwidth = 0;
37  this->m_movieClipheight = 0;
38  this->m_framenumber = 0;
39 }
40 
42 {
43  if (this->m_movieClip) {
45  ImBuf *ibuf;
46 
47  if (this->m_cacheFrame) {
49  }
50  else {
53  }
54 
55  if (ibuf) {
56  this->m_movieClipBuffer = ibuf;
57  if (ibuf->rect_float == nullptr || ibuf->userflags & IB_RECT_INVALID) {
58  IMB_float_from_rect(ibuf);
59  ibuf->userflags &= ~IB_RECT_INVALID;
60  }
61  }
62  }
63 }
64 
66 {
67  if (this->m_movieClipBuffer) {
69 
70  this->m_movieClipBuffer = nullptr;
71  }
72 }
73 
74 void MovieClipBaseOperation::determineResolution(unsigned int resolution[2],
75  unsigned int /*preferredResolution*/[2])
76 {
77  resolution[0] = 0;
78  resolution[1] = 0;
79 
80  if (this->m_movieClip) {
81  int width, height;
82 
84 
85  resolution[0] = width;
86  resolution[1] = height;
87  }
88 }
89 
91  float x,
92  float y,
93  PixelSampler sampler)
94 {
95  ImBuf *ibuf = this->m_movieClipBuffer;
96 
97  if (ibuf == nullptr) {
98  zero_v4(output);
99  }
100  else if (ibuf->rect == nullptr && ibuf->rect_float == nullptr) {
101  /* Happens for multilayer exr, i.e. */
102  zero_v4(output);
103  }
104  else {
105  switch (sampler) {
107  nearest_interpolation_color(ibuf, nullptr, output, x, y);
108  break;
110  bilinear_interpolation_color(ibuf, nullptr, output, x, y);
111  break;
113  bicubic_interpolation_color(ibuf, nullptr, output, x, y);
114  break;
115  }
116  }
117 }
118 
120 {
122 }
123 
125 {
127 }
128 
130  float x,
131  float y,
132  PixelSampler sampler)
133 {
134  float result[4];
136  output[0] = result[3];
137 }
138 
139 } // namespace blender::compositor
#define MOVIECLIP_CACHE_SKIP
struct ImBuf * BKE_movieclip_get_ibuf_flag(struct MovieClip *clip, struct MovieClipUser *user, int flag, int cache_flag)
Definition: movieclip.c:1354
void BKE_movieclip_user_set_frame(struct MovieClipUser *user, int framenr)
Definition: movieclip.c:1633
void BKE_movieclip_get_size(struct MovieClip *clip, struct MovieClipUser *user, int *width, int *height)
Definition: movieclip.c:1540
struct ImBuf * BKE_movieclip_get_ibuf(struct MovieClip *clip, struct MovieClipUser *user)
Definition: movieclip.c:1349
MINLINE void zero_v4(float r[4])
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
void IMB_float_from_rect(struct ImBuf *ibuf)
Definition: divers.c:780
void bicubic_interpolation_color(struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
Definition: imageprocess.c:98
void IMB_freeImBuf(struct ImBuf *ibuf)
Definition: allocimbuf.c:211
void bilinear_interpolation_color(struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
Definition: imageprocess.c:130
void nearest_interpolation_color(struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
Definition: imageprocess.c:242
@ IB_RECT_INVALID
#define output
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override
calculate a single pixel
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override
calculate a single pixel
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]) override
void addOutputSocket(DataType datatype)
int userflags
unsigned int * rect
float * rect_float