Blender  V3.3
COM_MovieClipOperation.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. */
3 
5 
6 #include "BKE_image.h"
7 #include "BKE_movieclip.h"
8 
9 #include "IMB_imbuf.h"
10 
11 namespace blender::compositor {
12 
14 {
15  movie_clip_ = nullptr;
16  movie_clip_buffer_ = nullptr;
17  movie_clip_user_ = nullptr;
18  movie_clipwidth_ = 0;
20  framenumber_ = 0;
21 }
22 
24 {
25  if (movie_clip_) {
27  ImBuf *ibuf;
28 
29  if (cache_frame_) {
31  }
32  else {
35  }
36 
37  if (ibuf) {
38  movie_clip_buffer_ = ibuf;
39  if (ibuf->rect_float == nullptr || ibuf->userflags & IB_RECT_INVALID) {
40  IMB_float_from_rect(ibuf);
41  ibuf->userflags &= ~IB_RECT_INVALID;
42  }
43  }
44  }
45 }
46 
48 {
49  if (movie_clip_buffer_) {
51 
52  movie_clip_buffer_ = nullptr;
53  }
54 }
55 
56 void MovieClipBaseOperation::determine_canvas(const rcti &UNUSED(preferred_area), rcti &r_area)
57 {
58  r_area = COM_AREA_NONE;
59  if (movie_clip_) {
60  int width, height;
62  BLI_rcti_init(&r_area, 0, width, 0, height);
63  }
64 }
65 
67  float x,
68  float y,
70 {
71  ImBuf *ibuf = movie_clip_buffer_;
72 
73  if (ibuf == nullptr) {
74  zero_v4(output);
75  }
76  else if (ibuf->rect == nullptr && ibuf->rect_float == nullptr) {
77  /* Happens for multilayer exr, i.e. */
78  zero_v4(output);
79  }
80  else {
81  switch (sampler) {
83  nearest_interpolation_color(ibuf, nullptr, output, x, y);
84  break;
86  bilinear_interpolation_color(ibuf, nullptr, output, x, y);
87  break;
89  bicubic_interpolation_color(ibuf, nullptr, output, x, y);
90  break;
91  }
92  }
93 }
94 
96  const rcti &area,
98 {
99  if (movie_clip_buffer_) {
100  output->copy_from(movie_clip_buffer_, area);
101  }
102  else {
104  }
105 }
106 
108 {
110 }
111 
113 {
115 }
116 
118  float x,
119  float y,
121 {
122  float result[4];
124  output[0] = result[3];
125 }
126 
128  const rcti &area,
130 {
131  if (movie_clip_buffer_) {
133  }
134  else {
135  output->fill(area, COM_VALUE_ZERO);
136  }
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:1334
void BKE_movieclip_user_set_frame(struct MovieClipUser *user, int framenr)
Definition: movieclip.c:1614
void BKE_movieclip_get_size(struct MovieClip *clip, struct MovieClipUser *user, int *width, int *height)
Definition: movieclip.c:1520
struct ImBuf * BKE_movieclip_get_ibuf(struct MovieClip *clip, struct MovieClipUser *user)
Definition: movieclip.c:1329
MINLINE void zero_v4(float r[4])
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
Definition: rct.c:417
#define UNUSED(x)
_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
_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
void IMB_float_from_rect(struct ImBuf *ibuf)
Definition: divers.c:805
void bicubic_interpolation_color(const struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
Definition: imageprocess.c:80
void nearest_interpolation_color(const struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
Definition: imageprocess.c:278
void bilinear_interpolation_color(const struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
Definition: imageprocess.c:128
@ IB_RECT_INVALID
a MemoryBuffer contains access to the data of a chunk
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override
calculate a single pixel
void update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span< MemoryBuffer * > inputs) override
void determine_canvas(const rcti &preferred_area, rcti &r_area) override
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override
calculate a single pixel
void update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span< MemoryBuffer * > inputs) override
void add_output_socket(DataType datatype)
depth_tx sampler(1, ImageType::FLOAT_2D, "combined_tx") .sampler(2
void IMB_freeImBuf(ImBuf *UNUSED(ibuf))
ccl_global KernelShaderEvalInput ccl_global float * output
static void area(int d1, int d2, int e1, int e2, float weights[2])
constexpr int COM_DATA_TYPE_VALUE_CHANNELS
Definition: COM_defines.h:60
constexpr float COM_VALUE_ZERO[1]
Definition: COM_defines.h:67
constexpr rcti COM_AREA_NONE
Definition: COM_defines.h:112
constexpr float COM_COLOR_TRANSPARENT[4]
Definition: COM_defines.h:64
static bNodeSocketTemplate inputs[]
int userflags
unsigned int * rect
float * rect_float