Blender V5.3
rna_movieclip.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10
11#include "DNA_movieclip_types.h"
12#include "DNA_scene_types.h"
13
14#include "RNA_define.hh"
15
16#include "rna_internal.hh"
17
18#include "BKE_movieclip.hh"
19
20#include "WM_types.hh"
21
22#include "MOV_enums.hh"
23#include "MOV_read.hh"
24
25#ifdef RNA_RUNTIME
26
27# include "DEG_depsgraph.hh"
28
29# include "ED_clip.hh"
30
31# include "DNA_screen_types.h"
32# include "DNA_space_types.h"
33
34# include "BKE_scene.hh"
35
36# include "SEQ_relations.hh"
37
38namespace blender {
39
40static void rna_MovieClip_reload_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
41{
42 MovieClip *clip = id_cast<MovieClip *>(ptr->owner_id);
43
45}
46
47static void rna_MovieClip_size_get(PointerRNA *ptr, int *values)
48{
49 MovieClip *clip = id_cast<MovieClip *>(ptr->owner_id);
50
51 values[0] = clip->lastsize[0];
52 values[1] = clip->lastsize[1];
53}
54
55static float rna_MovieClip_fps_get(PointerRNA *ptr)
56{
57 MovieClip *clip = id_cast<MovieClip *>(ptr->owner_id);
58 return BKE_movieclip_get_fps(clip);
59}
60
61static void rna_MovieClip_use_proxy_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
62{
63 MovieClip *clip = id_cast<MovieClip *>(ptr->owner_id);
66}
67
68static void rna_MovieClipUser_proxy_render_settings_update(Main *bmain,
69 Scene * /*scene*/,
70 PointerRNA *ptr)
71{
72 ID *id = ptr->owner_id;
73 MovieClipUser *user = static_cast<MovieClipUser *>(ptr->data);
74
75 /* when changing render settings of space clip user
76 * clear cache for clip, so all the memory is available
77 * for new render settings
78 */
79 if (GS(id->name) == ID_SCR) {
80 bScreen *screen = id_cast<bScreen *>(id);
81 ScrArea *area;
82 SpaceLink *sl;
83
84 for (area = screen->areabase.first(); area; area = area->next) {
85 for (sl = area->spacedata.first(); sl; sl = sl->next) {
86 if (sl->spacetype == SPACE_CLIP) {
87 SpaceClip *sc = reinterpret_cast<SpaceClip *>(sl);
88
89 if (&sc->user == user) {
91
92 if (clip && (clip->flag & MCLIP_USE_PROXY)) {
95 }
96
97 break;
98 }
99 }
100 }
101 }
102 }
103}
104
105static PointerRNA rna_MovieClip_metadata_get(MovieClip *clip)
106{
107 if (clip == nullptr || clip->anim == nullptr) {
108 return {};
109 }
110
112 if (metadata == nullptr) {
113 return {};
114 }
115
116 PointerRNA ptr = RNA_pointer_create_discrete(nullptr, RNA_IDPropertyWrapPtr, metadata);
117 return ptr;
118}
119
120static std::optional<std::string> rna_MovieClipUser_path(const PointerRNA *ptr)
121{
122 if (ptr->owner_id) {
123 // MovieClipUser *mc_user = ptr->data;
124
125 switch (GS(ptr->owner_id->name)) {
126 case ID_CA:
128 default:
129 break;
130 }
131 }
132
133 return "";
134}
135
136} // namespace blender
137
138#else
139
140namespace blender {
141
143{
144 StructRNA *srna;
145 PropertyRNA *prop;
146
147 srna = RNA_def_struct(brna, "MovieClipProxy", nullptr);
148 RNA_def_struct_ui_text(srna, "Movie Clip Proxy", "Proxy parameters for a movie clip");
149 RNA_def_struct_sdna(srna, "MovieClipProxy");
150
151 /* build proxy sized */
152 prop = RNA_def_property(srna, "build_25", PROP_BOOLEAN, PROP_NONE);
153 RNA_def_property_boolean_sdna(prop, nullptr, "build_size_flag", MCLIP_PROXY_SIZE_25);
156 prop, "25%", "Build proxy resolution 25% of the original footage dimension");
157
158 prop = RNA_def_property(srna, "build_50", PROP_BOOLEAN, PROP_NONE);
159 RNA_def_property_boolean_sdna(prop, nullptr, "build_size_flag", MCLIP_PROXY_SIZE_50);
162 prop, "50%", "Build proxy resolution 50% of the original footage dimension");
163
164 prop = RNA_def_property(srna, "build_75", PROP_BOOLEAN, PROP_NONE);
165 RNA_def_property_boolean_sdna(prop, nullptr, "build_size_flag", MCLIP_PROXY_SIZE_75);
168 prop, "75%", "Build proxy resolution 75% of the original footage dimension");
169
170 prop = RNA_def_property(srna, "build_100", PROP_BOOLEAN, PROP_NONE);
171 RNA_def_property_boolean_sdna(prop, nullptr, "build_size_flag", MCLIP_PROXY_SIZE_100);
174 prop, "100%", "Build proxy resolution 100% of the original footage dimension");
175
176 prop = RNA_def_property(srna, "build_undistorted_25", PROP_BOOLEAN, PROP_NONE);
177 RNA_def_property_boolean_sdna(prop, nullptr, "build_size_flag", MCLIP_PROXY_UNDISTORTED_SIZE_25);
180 prop, "25%", "Build proxy resolution 25% of the original undistorted footage dimension");
181
182 prop = RNA_def_property(srna, "build_undistorted_50", PROP_BOOLEAN, PROP_NONE);
183 RNA_def_property_boolean_sdna(prop, nullptr, "build_size_flag", MCLIP_PROXY_UNDISTORTED_SIZE_50);
186 prop, "50%", "Build proxy resolution 50% of the original undistorted footage dimension");
187
188 prop = RNA_def_property(srna, "build_undistorted_75", PROP_BOOLEAN, PROP_NONE);
189 RNA_def_property_boolean_sdna(prop, nullptr, "build_size_flag", MCLIP_PROXY_UNDISTORTED_SIZE_75);
192 prop, "75%", "Build proxy resolution 75% of the original undistorted footage dimension");
193
194 prop = RNA_def_property(srna, "build_undistorted_100", PROP_BOOLEAN, PROP_NONE);
196 prop, nullptr, "build_size_flag", MCLIP_PROXY_UNDISTORTED_SIZE_100);
199 prop, "100%", "Build proxy resolution 100% of the original undistorted footage dimension");
200
201 /* quality of proxied image */
202 prop = RNA_def_property(srna, "quality", PROP_INT, PROP_UNSIGNED);
203 RNA_def_property_int_sdna(prop, nullptr, "quality");
205 RNA_def_property_ui_text(prop, "Quality", "JPEG quality of proxy images");
206 RNA_def_property_ui_range(prop, 1, 100, 1, -1);
207
208 /* directory */
209 prop = RNA_def_property(srna, "directory", PROP_STRING, PROP_DIRPATH);
210 RNA_def_property_string_sdna(prop, nullptr, "dir");
213 RNA_def_property_ui_text(prop, "Directory", "Location to store the proxy files");
214 RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update");
215}
216
218{
219 StructRNA *srna;
220 PropertyRNA *prop;
221
222 static const EnumPropertyItem clip_render_size_items[] = {
223 {MCLIP_PROXY_RENDER_SIZE_25, "PROXY_25", 0, "25%", ""},
224 {MCLIP_PROXY_RENDER_SIZE_50, "PROXY_50", 0, "50%", ""},
225 {MCLIP_PROXY_RENDER_SIZE_75, "PROXY_75", 0, "75%", ""},
226 {MCLIP_PROXY_RENDER_SIZE_100, "PROXY_100", 0, "100%", ""},
227 {MCLIP_PROXY_RENDER_SIZE_FULL, "FULL", 0, "None, full render", ""},
228 {0, nullptr, 0, nullptr, nullptr},
229 };
230
231 srna = RNA_def_struct(brna, "MovieClipUser", nullptr);
233 srna,
234 "Movie Clip User",
235 "Parameters defining how a MovieClip data-block is used by another data-block");
236 RNA_def_struct_path_func(srna, "rna_MovieClipUser_path");
237
239
240 prop = RNA_def_property(srna, "frame_current", PROP_INT, PROP_TIME);
241 RNA_def_property_int_sdna(prop, nullptr, "framenr");
244 prop, "Current Frame", "Current frame number in movie or image sequence");
245
246 /* render size */
247 prop = RNA_def_property(srna, "proxy_render_size", PROP_ENUM, PROP_NONE);
248 RNA_def_property_enum_sdna(prop, nullptr, "render_size");
249 RNA_def_property_enum_items(prop, clip_render_size_items);
251 "Proxy Render Size",
252 "Display preview using full resolution or different proxy resolutions");
254 prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClipUser_proxy_render_settings_update");
255
256 /* render undistorted */
257 prop = RNA_def_property(srna, "use_render_undistorted", PROP_BOOLEAN, PROP_NONE);
258 RNA_def_property_boolean_sdna(prop, nullptr, "render_flag", MCLIP_PROXY_RENDER_UNDISTORT);
259 RNA_def_property_ui_text(prop, "Render Undistorted", "Render preview using undistorted proxy");
261 prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClipUser_proxy_render_settings_update");
262
264}
265
267{
268 StructRNA *srna;
269
270 srna = RNA_def_struct(brna, "MovieClipScopes", nullptr);
271 RNA_def_struct_ui_text(srna, "MovieClipScopes", "Scopes for statistical view of a movie clip");
272}
273
275{
276 StructRNA *srna;
277 PropertyRNA *prop;
278 FunctionRNA *func;
279 PropertyRNA *parm;
280
281 static const EnumPropertyItem clip_source_items[] = {
282 {MCLIP_SRC_SEQUENCE, "SEQUENCE", 0, "Image Sequence", "Multiple image files, as a sequence"},
283 {MCLIP_SRC_MOVIE, "MOVIE", 0, "Movie File", "Movie file"},
284 {0, nullptr, 0, nullptr, nullptr},
285 };
286
287 srna = RNA_def_struct(brna, "MovieClip", "ID");
289 srna, "MovieClip", "MovieClip data-block referencing an external movie file");
290 RNA_def_struct_ui_icon(srna, ICON_SEQUENCE);
291
292 prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
293 RNA_def_property_string_sdna(prop, nullptr, "filepath");
294 RNA_def_property_ui_text(prop, "File Path", "Filename of the movie or sequence file");
296 RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update");
297
298 prop = RNA_def_property(srna, "tracking", PROP_POINTER, PROP_NONE);
299 RNA_def_property_struct_type(prop, "MovieTracking");
300
301 prop = RNA_def_property(srna, "proxy", PROP_POINTER, PROP_NONE);
302 RNA_def_property_struct_type(prop, "MovieClipProxy");
303
304 /* use proxy */
305 prop = RNA_def_property(srna, "use_proxy", PROP_BOOLEAN, PROP_NONE);
306 RNA_def_property_boolean_sdna(prop, nullptr, "flag", MCLIP_USE_PROXY);
308 RNA_def_property_ui_text(prop, "Use Proxy", "Use a preview proxy for this clip");
309 RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_use_proxy_update");
310
311 prop = RNA_def_int_vector(srna,
312 "size",
313 2,
314 nullptr,
315 0,
316 0,
317 "Size",
318 "Width and height in pixels, zero when image data cannot be loaded",
319 0,
320 0);
321 RNA_def_property_int_funcs(prop, "rna_MovieClip_size_get", nullptr, nullptr);
323
324 prop = RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_XYZ);
325 RNA_def_property_float_sdna(prop, nullptr, "aspx");
326 RNA_def_property_array(prop, 2);
327 RNA_def_property_range(prop, 0.1f, FLT_MAX);
328 RNA_def_property_ui_range(prop, 0.1f, 5000.0f, 1, 2);
331 prop, "Display Aspect", "Display Aspect for this clip, does not affect rendering");
333
334 /* source */
335 prop = RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE);
336 RNA_def_property_enum_items(prop, clip_source_items);
337 RNA_def_property_ui_text(prop, "Source", "Where the clip comes from");
339
340 /* custom proxy directory */
341 prop = RNA_def_property(srna, "use_proxy_custom_directory", PROP_BOOLEAN, PROP_NONE);
345 prop,
346 "Proxy Custom Directory",
347 "Create proxy images in a custom directory (default is movie location)");
348 RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update");
349
350 /* annotations */
351 prop = RNA_def_property(srna, "annotation", PROP_POINTER, PROP_NONE);
352 RNA_def_property_pointer_sdna(prop, nullptr, "gpd");
353 RNA_def_property_struct_type(prop, "Annotation");
355 prop, nullptr, nullptr, nullptr, "rna_GPencil_datablocks_annotations_poll");
357 RNA_def_property_ui_text(prop, "Annotation", "Annotation data for this movie clip");
359
360 /* start_frame */
361 prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE);
362 RNA_def_property_int_sdna(prop, nullptr, "start_frame");
364 "Start Frame",
365 "Global scene frame number at which this movie starts playing "
366 "(affects all data associated with a clip)");
368
369 /* frame_offset */
370 prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
371 RNA_def_property_int_sdna(prop, nullptr, "frame_offset");
373 prop,
374 "Frame Offset",
375 "Offset of footage first frame relative to its file name "
376 "(affects only how footage is loading, does not change data associated with a clip)");
378
379 /* length */
380 prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_NONE);
382 RNA_def_property_int_sdna(prop, nullptr, "len");
383 RNA_def_property_ui_text(prop, "Duration", "Detected duration of movie clip in frames");
384
385 /* FPS */
386 prop = RNA_def_property(srna, "fps", PROP_FLOAT, PROP_NONE);
388 RNA_def_property_float_funcs(prop, "rna_MovieClip_fps_get", nullptr, nullptr);
390 prop, "Frame Rate", "Detected frame rate of the movie clip in frames per second");
391
392 /* color management */
393 prop = RNA_def_property(srna, "colorspace_settings", PROP_POINTER, PROP_NONE);
394 RNA_def_property_pointer_sdna(prop, nullptr, "colorspace_settings");
395 RNA_def_property_struct_type(prop, "ColorManagedInputColorspaceSettings");
396 RNA_def_property_ui_text(prop, "Color Space Settings", "Input color space settings");
397
398 /* metadata */
399 func = RNA_def_function(srna, "metadata", "rna_MovieClip_metadata_get");
400 RNA_def_function_ui_description(func, "Retrieve metadata of the movie file");
401 /* return type */
402 parm = RNA_def_pointer(
403 func, "metadata", "IDPropertyWrapPtr", "", "Dict-like object containing the metadata");
405 RNA_def_function_return(func, parm);
406
408}
409
417
418} // namespace blender
419
420#endif
#define MINAFRAME
#define MAXFRAME
#define ND_DISPLAY
Definition WM_types.hh:534
#define NC_MOVIECLIP
Definition WM_types.hh:410
#define FLT_MAX
void relations_invalidate_movieclip_strips(Main *bmain, MovieClip *clip_target)
BMesh Iterators.
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
void BKE_movieclip_clear_cache(MovieClip *clip)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_define_lib_overridable(const bool make_overridable)
PropertyRNA * RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, const int *default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
@ MCLIP_PROXY_RENDER_UNDISTORT
@ MCLIP_PROXY_RENDER_SIZE_FULL
@ MCLIP_PROXY_RENDER_SIZE_100
float BKE_movieclip_get_fps(MovieClip *clip)
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void rna_def_animdata_common(StructRNA *srna)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
@ PROP_BOOLEAN
Definition RNA_types.hh:210
@ PROP_POINTER
Definition RNA_types.hh:215
@ PROP_STRING
Definition RNA_types.hh:213
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void DEG_id_tag_update(ID *id, unsigned int flags)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
static void rna_def_movieClipScopes(BlenderRNA *brna)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
static void rna_def_movieclip(BlenderRNA *brna)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier_c_str, const char *call)
@ MCLIP_PROXY_UNDISTORTED_SIZE_100
@ MCLIP_PROXY_UNDISTORTED_SIZE_50
@ MCLIP_PROXY_UNDISTORTED_SIZE_25
@ MCLIP_PROXY_UNDISTORTED_SIZE_75
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
static void rna_def_movieclip_proxy(BlenderRNA *brna)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
IDProperty * MOV_load_metadata(MovieReader *anim)
Definition movie_read.cc:90
MovieClip * ED_space_clip_get_clip(const SpaceClip *sc)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
@ ID_RECALC_SOURCE
Definition DNA_ID.h:1143
ID_Type GS(const char *name)
Definition DNA_ID.h:410
@ PROP_EDITABLE
Definition RNA_types.hh:376
@ PROP_PATH_SUPPORTS_BLEND_RELATIVE
Definition RNA_types.hh:526
@ PROP_ID_REFCOUNT
Definition RNA_types.hh:434
@ PROP_ANIMATABLE
Definition RNA_types.hh:389
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
static void rna_def_movieclipUser(BlenderRNA *brna)
std::optional< std::string > rna_CameraBackgroundImage_image_or_movieclip_user_path(const PointerRNA *ptr)
@ PROP_FILEPATH
Definition RNA_types.hh:284
@ PROP_DIRPATH
Definition RNA_types.hh:285
@ PROP_UNSIGNED
Definition RNA_types.hh:306
@ PARM_RNAPTR
Definition RNA_types.hh:633
void RNA_def_property_array(PropertyRNA *prop, int length)
void RNA_def_movieclip(BlenderRNA *brna)