Blender V5.0
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.h"
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
38static void rna_MovieClip_reload_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
39{
40 MovieClip *clip = (MovieClip *)ptr->owner_id;
41
43}
44
45static void rna_MovieClip_size_get(PointerRNA *ptr, int *values)
46{
47 MovieClip *clip = (MovieClip *)ptr->owner_id;
48
49 values[0] = clip->lastsize[0];
50 values[1] = clip->lastsize[1];
51}
52
53static float rna_MovieClip_fps_get(PointerRNA *ptr)
54{
55 MovieClip *clip = (MovieClip *)ptr->owner_id;
56 return BKE_movieclip_get_fps(clip);
57}
58
59static void rna_MovieClip_use_proxy_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
60{
61 MovieClip *clip = (MovieClip *)ptr->owner_id;
64}
65
66static void rna_MovieClipUser_proxy_render_settings_update(Main *bmain,
67 Scene * /*scene*/,
69{
70 ID *id = ptr->owner_id;
71 MovieClipUser *user = (MovieClipUser *)ptr->data;
72
73 /* when changing render settings of space clip user
74 * clear cache for clip, so all the memory is available
75 * for new render settings
76 */
77 if (GS(id->name) == ID_SCR) {
78 bScreen *screen = (bScreen *)id;
79 ScrArea *area;
80 SpaceLink *sl;
81
82 for (area = static_cast<ScrArea *>(screen->areabase.first); area; area = area->next) {
83 for (sl = static_cast<SpaceLink *>(area->spacedata.first); sl; sl = sl->next) {
84 if (sl->spacetype == SPACE_CLIP) {
85 SpaceClip *sc = (SpaceClip *)sl;
86
87 if (&sc->user == user) {
89
90 if (clip && (clip->flag & MCLIP_USE_PROXY)) {
93 }
94
95 break;
96 }
97 }
98 }
99 }
100 }
101}
102
103static PointerRNA rna_MovieClip_metadata_get(MovieClip *clip)
104{
105 if (clip == nullptr || clip->anim == nullptr) {
106 return PointerRNA_NULL;
107 }
108
109 IDProperty *metadata = MOV_load_metadata(clip->anim);
110 if (metadata == nullptr) {
111 return PointerRNA_NULL;
112 }
113
114 PointerRNA ptr = RNA_pointer_create_discrete(nullptr, &RNA_IDPropertyWrapPtr, metadata);
115 return ptr;
116}
117
118static std::optional<std::string> rna_MovieClipUser_path(const PointerRNA *ptr)
119{
120 if (ptr->owner_id) {
121 // MovieClipUser *mc_user = ptr->data;
122
123 switch (GS(ptr->owner_id->name)) {
124 case ID_CA:
126 default:
127 break;
128 }
129 }
130
131 return "";
132}
133
134#else
135
137{
138 StructRNA *srna;
139 PropertyRNA *prop;
140
141 static const EnumPropertyItem clip_tc_items[] = {
143 "NONE",
144 0,
145 "None",
146 "Ignore generated timecodes, seek in movie stream based on calculated timestamp"},
148 "RECORD_RUN",
149 0,
150 "Record Run",
151 "Seek based on timestamps read from movie stream, giving the best match between scene and "
152 "movie times"},
154 "FREE_RUN_NO_GAPS",
155 0,
156 "Record Run No Gaps",
157 "Effectively convert movie to an image sequence, ignoring incomplete or dropped frames, "
158 "and changes in frame rate"},
159 {0, nullptr, 0, nullptr, nullptr},
160 };
161
162 srna = RNA_def_struct(brna, "MovieClipProxy", nullptr);
163 RNA_def_struct_ui_text(srna, "Movie Clip Proxy", "Proxy parameters for a movie clip");
164 RNA_def_struct_sdna(srna, "MovieClipProxy");
165
166 /* build proxy sized */
167 prop = RNA_def_property(srna, "build_25", PROP_BOOLEAN, PROP_NONE);
168 RNA_def_property_boolean_sdna(prop, nullptr, "build_size_flag", MCLIP_PROXY_SIZE_25);
171 prop, "25%", "Build proxy resolution 25% of the original footage dimension");
172
173 prop = RNA_def_property(srna, "build_50", PROP_BOOLEAN, PROP_NONE);
174 RNA_def_property_boolean_sdna(prop, nullptr, "build_size_flag", MCLIP_PROXY_SIZE_50);
177 prop, "50%", "Build proxy resolution 50% of the original footage dimension");
178
179 prop = RNA_def_property(srna, "build_75", PROP_BOOLEAN, PROP_NONE);
180 RNA_def_property_boolean_sdna(prop, nullptr, "build_size_flag", MCLIP_PROXY_SIZE_75);
183 prop, "75%", "Build proxy resolution 75% of the original footage dimension");
184
185 prop = RNA_def_property(srna, "build_100", PROP_BOOLEAN, PROP_NONE);
186 RNA_def_property_boolean_sdna(prop, nullptr, "build_size_flag", MCLIP_PROXY_SIZE_100);
189 prop, "100%", "Build proxy resolution 100% of the original footage dimension");
190
191 prop = RNA_def_property(srna, "build_undistorted_25", PROP_BOOLEAN, PROP_NONE);
192 RNA_def_property_boolean_sdna(prop, nullptr, "build_size_flag", MCLIP_PROXY_UNDISTORTED_SIZE_25);
195 prop, "25%", "Build proxy resolution 25% of the original undistorted footage dimension");
196
197 prop = RNA_def_property(srna, "build_undistorted_50", PROP_BOOLEAN, PROP_NONE);
198 RNA_def_property_boolean_sdna(prop, nullptr, "build_size_flag", MCLIP_PROXY_UNDISTORTED_SIZE_50);
201 prop, "50%", "Build proxy resolution 50% of the original undistorted footage dimension");
202
203 prop = RNA_def_property(srna, "build_undistorted_75", PROP_BOOLEAN, PROP_NONE);
204 RNA_def_property_boolean_sdna(prop, nullptr, "build_size_flag", MCLIP_PROXY_UNDISTORTED_SIZE_75);
207 prop, "75%", "Build proxy resolution 75% of the original undistorted footage dimension");
208
209 prop = RNA_def_property(srna, "build_undistorted_100", PROP_BOOLEAN, PROP_NONE);
211 prop, nullptr, "build_size_flag", MCLIP_PROXY_UNDISTORTED_SIZE_100);
214 prop, "100%", "Build proxy resolution 100% of the original undistorted footage dimension");
215
216 /* Build time-codes. */
217 prop = RNA_def_property(srna, "build_record_run", PROP_BOOLEAN, PROP_NONE);
218 RNA_def_property_boolean_sdna(prop, nullptr, "build_tc_flag", IMB_TC_RECORD_RUN);
220 RNA_def_property_ui_text(prop, "Rec Run", "Build record run time code index");
221
222 /* quality of proxied image */
223 prop = RNA_def_property(srna, "quality", PROP_INT, PROP_UNSIGNED);
224 RNA_def_property_int_sdna(prop, nullptr, "quality");
226 RNA_def_property_ui_text(prop, "Quality", "JPEG quality of proxy images");
227 RNA_def_property_ui_range(prop, 1, 100, 1, -1);
228
229 prop = RNA_def_property(srna, "timecode", PROP_ENUM, PROP_NONE);
230 RNA_def_property_enum_sdna(prop, nullptr, "tc");
232 RNA_def_property_enum_items(prop, clip_tc_items);
233 RNA_def_property_ui_text(prop, "Timecode", "");
234 RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update");
235
236 /* directory */
237 prop = RNA_def_property(srna, "directory", PROP_STRING, PROP_DIRPATH);
238 RNA_def_property_string_sdna(prop, nullptr, "dir");
241 RNA_def_property_ui_text(prop, "Directory", "Location to store the proxy files");
242 RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update");
243}
244
246{
247 StructRNA *srna;
248 PropertyRNA *prop;
249
250 static const EnumPropertyItem clip_render_size_items[] = {
251 {MCLIP_PROXY_RENDER_SIZE_25, "PROXY_25", 0, "25%", ""},
252 {MCLIP_PROXY_RENDER_SIZE_50, "PROXY_50", 0, "50%", ""},
253 {MCLIP_PROXY_RENDER_SIZE_75, "PROXY_75", 0, "75%", ""},
254 {MCLIP_PROXY_RENDER_SIZE_100, "PROXY_100", 0, "100%", ""},
255 {MCLIP_PROXY_RENDER_SIZE_FULL, "FULL", 0, "None, full render", ""},
256 {0, nullptr, 0, nullptr, nullptr},
257 };
258
259 srna = RNA_def_struct(brna, "MovieClipUser", nullptr);
261 srna,
262 "Movie Clip User",
263 "Parameters defining how a MovieClip data-block is used by another data-block");
264 RNA_def_struct_path_func(srna, "rna_MovieClipUser_path");
265
267
268 prop = RNA_def_property(srna, "frame_current", PROP_INT, PROP_TIME);
269 RNA_def_property_int_sdna(prop, nullptr, "framenr");
272 prop, "Current Frame", "Current frame number in movie or image sequence");
273
274 /* render size */
275 prop = RNA_def_property(srna, "proxy_render_size", PROP_ENUM, PROP_NONE);
276 RNA_def_property_enum_sdna(prop, nullptr, "render_size");
277 RNA_def_property_enum_items(prop, clip_render_size_items);
279 "Proxy Render Size",
280 "Display preview using full resolution or different proxy resolutions");
282 prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClipUser_proxy_render_settings_update");
283
284 /* render undistorted */
285 prop = RNA_def_property(srna, "use_render_undistorted", PROP_BOOLEAN, PROP_NONE);
286 RNA_def_property_boolean_sdna(prop, nullptr, "render_flag", MCLIP_PROXY_RENDER_UNDISTORT);
287 RNA_def_property_ui_text(prop, "Render Undistorted", "Render preview using undistorted proxy");
289 prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClipUser_proxy_render_settings_update");
290
292}
293
295{
296 StructRNA *srna;
297
298 srna = RNA_def_struct(brna, "MovieClipScopes", nullptr);
299 RNA_def_struct_ui_text(srna, "MovieClipScopes", "Scopes for statistical view of a movie clip");
300}
301
303{
304 StructRNA *srna;
305 PropertyRNA *prop;
306 FunctionRNA *func;
307 PropertyRNA *parm;
308
309 static const EnumPropertyItem clip_source_items[] = {
310 {MCLIP_SRC_SEQUENCE, "SEQUENCE", 0, "Image Sequence", "Multiple image files, as a sequence"},
311 {MCLIP_SRC_MOVIE, "MOVIE", 0, "Movie File", "Movie file"},
312 {0, nullptr, 0, nullptr, nullptr},
313 };
314
315 srna = RNA_def_struct(brna, "MovieClip", "ID");
317 srna, "MovieClip", "MovieClip data-block referencing an external movie file");
318 RNA_def_struct_ui_icon(srna, ICON_SEQUENCE);
319
320 prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
321 RNA_def_property_string_sdna(prop, nullptr, "filepath");
322 RNA_def_property_ui_text(prop, "File Path", "Filename of the movie or sequence file");
324 RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update");
325
326 prop = RNA_def_property(srna, "tracking", PROP_POINTER, PROP_NONE);
327 RNA_def_property_struct_type(prop, "MovieTracking");
328
329 prop = RNA_def_property(srna, "proxy", PROP_POINTER, PROP_NONE);
330 RNA_def_property_struct_type(prop, "MovieClipProxy");
331
332 /* use proxy */
333 prop = RNA_def_property(srna, "use_proxy", PROP_BOOLEAN, PROP_NONE);
334 RNA_def_property_boolean_sdna(prop, nullptr, "flag", MCLIP_USE_PROXY);
337 prop, "Use Proxy / Timecode", "Use a preview proxy and/or timecode index for this clip");
338 RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_use_proxy_update");
339
340 prop = RNA_def_int_vector(srna,
341 "size",
342 2,
343 nullptr,
344 0,
345 0,
346 "Size",
347 "Width and height in pixels, zero when image data cannot be loaded",
348 0,
349 0);
350 RNA_def_property_int_funcs(prop, "rna_MovieClip_size_get", nullptr, nullptr);
352
353 prop = RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_XYZ);
354 RNA_def_property_float_sdna(prop, nullptr, "aspx");
355 RNA_def_property_array(prop, 2);
356 RNA_def_property_range(prop, 0.1f, FLT_MAX);
357 RNA_def_property_ui_range(prop, 0.1f, 5000.0f, 1, 2);
360 prop, "Display Aspect", "Display Aspect for this clip, does not affect rendering");
362
363 /* source */
364 prop = RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE);
365 RNA_def_property_enum_items(prop, clip_source_items);
366 RNA_def_property_ui_text(prop, "Source", "Where the clip comes from");
368
369 /* custom proxy directory */
370 prop = RNA_def_property(srna, "use_proxy_custom_directory", PROP_BOOLEAN, PROP_NONE);
374 prop,
375 "Proxy Custom Directory",
376 "Create proxy images in a custom directory (default is movie location)");
377 RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update");
378
379 /* annotations */
380 prop = RNA_def_property(srna, "annotation", PROP_POINTER, PROP_NONE);
381 RNA_def_property_pointer_sdna(prop, nullptr, "gpd");
382 RNA_def_property_struct_type(prop, "Annotation");
384 prop, nullptr, nullptr, nullptr, "rna_GPencil_datablocks_annotations_poll");
386 RNA_def_property_ui_text(prop, "Annotation", "Annotation data for this movie clip");
388
389 /* start_frame */
390 prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE);
391 RNA_def_property_int_sdna(prop, nullptr, "start_frame");
393 "Start Frame",
394 "Global scene frame number at which this movie starts playing "
395 "(affects all data associated with a clip)");
397
398 /* frame_offset */
399 prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
400 RNA_def_property_int_sdna(prop, nullptr, "frame_offset");
402 prop,
403 "Frame Offset",
404 "Offset of footage first frame relative to its file name "
405 "(affects only how footage is loading, does not change data associated with a clip)");
407
408 /* length */
409 prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_NONE);
411 RNA_def_property_int_sdna(prop, nullptr, "len");
412 RNA_def_property_ui_text(prop, "Duration", "Detected duration of movie clip in frames");
413
414 /* FPS */
415 prop = RNA_def_property(srna, "fps", PROP_FLOAT, PROP_NONE);
417 RNA_def_property_float_funcs(prop, "rna_MovieClip_fps_get", nullptr, nullptr);
419 prop, "Frame Rate", "Detected frame rate of the movie clip in frames per second");
420
421 /* color management */
422 prop = RNA_def_property(srna, "colorspace_settings", PROP_POINTER, PROP_NONE);
423 RNA_def_property_pointer_sdna(prop, nullptr, "colorspace_settings");
424 RNA_def_property_struct_type(prop, "ColorManagedInputColorspaceSettings");
425 RNA_def_property_ui_text(prop, "Color Space Settings", "Input color space settings");
426
427 /* metadata */
428 func = RNA_def_function(srna, "metadata", "rna_MovieClip_metadata_get");
429 RNA_def_function_ui_description(func, "Retrieve metadata of the movie file");
430 /* return type */
431 parm = RNA_def_pointer(
432 func, "metadata", "IDPropertyWrapPtr", "", "Dict-like object containing the metadata");
434 RNA_def_function_return(func, parm);
435
437}
438
446
447#endif
void BKE_movieclip_clear_cache(struct MovieClip *clip)
float BKE_movieclip_get_fps(struct MovieClip *clip)
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_RECALC_SOURCE
Definition DNA_ID.h:1143
@ ID_CA
@ ID_SCR
@ MCLIP_USE_PROXY_CUSTOM_DIR
@ MCLIP_USE_PROXY
@ MCLIP_PROXY_RENDER_UNDISTORT
@ MCLIP_PROXY_RENDER_SIZE_75
@ MCLIP_PROXY_RENDER_SIZE_100
@ MCLIP_PROXY_RENDER_SIZE_50
@ MCLIP_PROXY_RENDER_SIZE_FULL
@ MCLIP_PROXY_RENDER_SIZE_25
@ MCLIP_PROXY_SIZE_75
@ MCLIP_PROXY_UNDISTORTED_SIZE_100
@ MCLIP_PROXY_UNDISTORTED_SIZE_75
@ MCLIP_PROXY_SIZE_25
@ MCLIP_PROXY_SIZE_100
@ MCLIP_PROXY_UNDISTORTED_SIZE_50
@ MCLIP_PROXY_SIZE_50
@ MCLIP_PROXY_UNDISTORTED_SIZE_25
@ MCLIP_SRC_SEQUENCE
@ MCLIP_SRC_MOVIE
#define MINAFRAME
#define MAXFRAME
@ SPACE_CLIP
MovieClip * ED_space_clip_get_clip(const SpaceClip *sc)
@ IMB_TC_RECORD_RUN_NO_GAPS
Definition MOV_enums.hh:61
@ IMB_TC_NONE
Definition MOV_enums.hh:46
@ IMB_TC_RECORD_RUN
Definition MOV_enums.hh:54
@ PARM_RNAPTR
Definition RNA_types.hh:547
@ PROP_FLOAT
Definition RNA_types.hh:164
@ PROP_BOOLEAN
Definition RNA_types.hh:162
@ PROP_ENUM
Definition RNA_types.hh:166
@ PROP_INT
Definition RNA_types.hh:163
@ PROP_STRING
Definition RNA_types.hh:165
@ PROP_POINTER
Definition RNA_types.hh:167
PropertyFlag
Definition RNA_types.hh:300
@ PROP_ANIMATABLE
Definition RNA_types.hh:319
@ PROP_PATH_SUPPORTS_BLEND_RELATIVE
Definition RNA_types.hh:456
@ PROP_EDITABLE
Definition RNA_types.hh:306
@ PROP_ID_REFCOUNT
Definition RNA_types.hh:364
@ PROP_TIME
Definition RNA_types.hh:253
@ PROP_XYZ
Definition RNA_types.hh:269
@ PROP_NONE
Definition RNA_types.hh:233
@ PROP_DIRPATH
Definition RNA_types.hh:237
@ PROP_UNSIGNED
Definition RNA_types.hh:249
@ PROP_FILEPATH
Definition RNA_types.hh:236
#define ND_DISPLAY
Definition WM_types.hh:491
#define NC_MOVIECLIP
Definition WM_types.hh:397
#define GS(x)
IDProperty * MOV_load_metadata(MovieReader *anim)
Definition movie_read.cc:86
void relations_invalidate_movieclip_strips(Main *bmain, MovieClip *clip_target)
const PointerRNA PointerRNA_NULL
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
void rna_def_animdata_common(StructRNA *srna)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_define_lib_overridable(const bool make_overridable)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
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)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_property_array(PropertyRNA *prop, int length)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
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)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
std::optional< std::string > rna_CameraBackgroundImage_image_or_movieclip_user_path(const PointerRNA *ptr)
static void rna_def_movieclip(BlenderRNA *brna)
static void rna_def_movieclip_proxy(BlenderRNA *brna)
void RNA_def_movieclip(BlenderRNA *brna)
static void rna_def_movieclipUser(BlenderRNA *brna)
static void rna_def_movieClipScopes(BlenderRNA *brna)
#define FLT_MAX
Definition stdcycles.h:14
Definition DNA_ID.h:414
void * first
struct MovieReader * anim
ListBase spacedata
struct ScrArea * next
struct MovieClipUser user
ListBase areabase
PointerRNA * ptr
Definition wm_files.cc:4238