Blender  V3.3
movieclip.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. All rights reserved. */
3 
8 #include <fcntl.h>
9 #include <stdio.h>
10 #include <string.h>
11 
12 #ifndef WIN32
13 # include <unistd.h>
14 #else
15 # include <io.h>
16 #endif
17 
18 #include <time.h>
19 
20 #include "MEM_guardedalloc.h"
21 
22 /* Allow using deprecated functionality for .blend file I/O. */
23 #define DNA_DEPRECATED_ALLOW
24 
25 #include "DNA_defaults.h"
26 
27 #include "DNA_constraint_types.h"
28 #include "DNA_gpencil_types.h"
29 #include "DNA_movieclip_types.h"
30 #include "DNA_node_types.h"
31 #include "DNA_object_types.h"
32 #include "DNA_scene_types.h"
33 #include "DNA_screen_types.h"
34 #include "DNA_space_types.h"
35 #include "DNA_view3d_types.h"
36 
37 #include "BLI_utildefines.h"
38 
39 #include "BLI_blenlib.h"
40 #include "BLI_ghash.h"
41 #include "BLI_math.h"
42 #include "BLI_threads.h"
43 
44 #include "BLT_translation.h"
45 
46 #include "BKE_anim_data.h"
47 #include "BKE_bpath.h"
48 #include "BKE_colortools.h"
49 #include "BKE_global.h"
50 #include "BKE_idtype.h"
51 #include "BKE_image.h" /* openanim */
52 #include "BKE_lib_id.h"
53 #include "BKE_lib_query.h"
54 #include "BKE_main.h"
55 #include "BKE_movieclip.h"
56 #include "BKE_node.h"
57 #include "BKE_node_tree_update.h"
58 #include "BKE_tracking.h"
59 
60 #include "IMB_imbuf.h"
61 #include "IMB_imbuf_types.h"
62 #include "IMB_moviecache.h"
63 #include "IMB_openexr.h"
64 
65 #include "DEG_depsgraph.h"
66 #include "DEG_depsgraph_query.h"
67 
68 #include "GPU_texture.h"
69 
70 #include "BLO_read_write.h"
71 
72 static void free_buffers(MovieClip *clip);
73 
74 static void movie_clip_init_data(ID *id)
75 {
76  MovieClip *movie_clip = (MovieClip *)id;
77  BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(movie_clip, id));
78 
80 
83 }
84 
85 static void movie_clip_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, const int flag)
86 {
87  MovieClip *movie_clip_dst = (MovieClip *)id_dst;
88  const MovieClip *movie_clip_src = (const MovieClip *)id_src;
89 
90  /* We never handle user-count here for own data. */
91  const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
92 
93  movie_clip_dst->anim = NULL;
94  movie_clip_dst->cache = NULL;
95 
96  BKE_tracking_copy(&movie_clip_dst->tracking, &movie_clip_src->tracking, flag_subdata);
97  movie_clip_dst->tracking_context = NULL;
98 
100  &movie_clip_src->colorspace_settings);
101 }
102 
103 static void movie_clip_free_data(ID *id)
104 {
105  MovieClip *movie_clip = (MovieClip *)id;
106 
107  /* Also frees animdata. */
108  free_buffers(movie_clip);
109 
110  BKE_tracking_free(&movie_clip->tracking);
111 }
112 
114 {
115  MovieClip *movie_clip = (MovieClip *)id;
116  MovieTracking *tracking = &movie_clip->tracking;
117 
119 
120  LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking->tracks) {
122  }
123  LISTBASE_FOREACH (MovieTrackingObject *, object, &tracking->objects) {
124  LISTBASE_FOREACH (MovieTrackingTrack *, track, &object->tracks) {
126  }
127  }
128 
129  LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, &tracking->plane_tracks) {
131  }
132 }
133 
134 static void movie_clip_foreach_cache(ID *id,
135  IDTypeForeachCacheFunctionCallback function_callback,
136  void *user_data)
137 {
138  MovieClip *movie_clip = (MovieClip *)id;
139  IDCacheKey key = {
140  .id_session_uuid = id->session_uuid,
141  .offset_in_ID = offsetof(MovieClip, cache),
142  };
143  function_callback(id, &key, (void **)&movie_clip->cache, 0, user_data);
144 
145  key.offset_in_ID = offsetof(MovieClip, tracking.camera.intrinsics);
146  function_callback(id, &key, (void **)&movie_clip->tracking.camera.intrinsics, 0, user_data);
147 }
148 
149 static void movie_clip_foreach_path(ID *id, BPathForeachPathData *bpath_data)
150 {
151  MovieClip *movie_clip = (MovieClip *)id;
152  BKE_bpath_foreach_path_fixed_process(bpath_data, movie_clip->filepath);
153 }
154 
156 {
157  MovieTrackingTrack *track;
158 
159  track = tracks->first;
160  while (track) {
161  BLO_write_struct(writer, MovieTrackingTrack, track);
162 
163  if (track->markers) {
165  }
166 
167  track = track->next;
168  }
169 }
170 
171 static void write_moviePlaneTracks(BlendWriter *writer, ListBase *plane_tracks_base)
172 {
173  MovieTrackingPlaneTrack *plane_track;
174 
175  for (plane_track = plane_tracks_base->first; plane_track; plane_track = plane_track->next) {
176  BLO_write_struct(writer, MovieTrackingPlaneTrack, plane_track);
177 
178  BLO_write_pointer_array(writer, plane_track->point_tracksnr, plane_track->point_tracks);
180  writer, MovieTrackingPlaneMarker, plane_track->markersnr, plane_track->markers);
181  }
182 }
183 
186 {
187  if (reconstruction->camnr) {
189  writer, MovieReconstructedCamera, reconstruction->camnr, reconstruction->cameras);
190  }
191 }
192 
193 static void movieclip_blend_write(BlendWriter *writer, ID *id, const void *id_address)
194 {
195  MovieClip *clip = (MovieClip *)id;
196 
197  /* Clean up, important in undo case to reduce false detection of changed datablocks. */
198  clip->anim = NULL;
199  clip->tracking_context = NULL;
200  clip->tracking.stats = NULL;
201 
202  MovieTracking *tracking = &clip->tracking;
203  MovieTrackingObject *object;
204 
205  BLO_write_id_struct(writer, MovieClip, id_address, &clip->id);
206  BKE_id_blend_write(writer, &clip->id);
207 
208  if (clip->adt) {
209  BKE_animdata_blend_write(writer, clip->adt);
210  }
211 
212  write_movieTracks(writer, &tracking->tracks);
213  write_moviePlaneTracks(writer, &tracking->plane_tracks);
214  write_movieReconstruction(writer, &tracking->reconstruction);
215 
216  object = tracking->objects.first;
217  while (object) {
218  BLO_write_struct(writer, MovieTrackingObject, object);
219 
220  write_movieTracks(writer, &object->tracks);
221  write_moviePlaneTracks(writer, &object->plane_tracks);
222  write_movieReconstruction(writer, &object->reconstruction);
223 
224  object = object->next;
225  }
226 }
227 
230 {
231  BLO_read_data_address(reader, &reconstruction->cameras);
232 }
233 
234 static void direct_link_movieTracks(BlendDataReader *reader, ListBase *tracksbase)
235 {
236  BLO_read_list(reader, tracksbase);
237 
238  LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) {
239  BLO_read_data_address(reader, &track->markers);
240  }
241 }
242 
243 static void direct_link_moviePlaneTracks(BlendDataReader *reader, ListBase *plane_tracks_base)
244 {
245  BLO_read_list(reader, plane_tracks_base);
246 
247  LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, plane_tracks_base) {
248  BLO_read_pointer_array(reader, (void **)&plane_track->point_tracks);
249  for (int i = 0; i < plane_track->point_tracksnr; i++) {
250  BLO_read_data_address(reader, &plane_track->point_tracks[i]);
251  }
252 
253  BLO_read_data_address(reader, &plane_track->markers);
254  }
255 }
256 
258 {
259  MovieClip *clip = (MovieClip *)id;
260  MovieTracking *tracking = &clip->tracking;
261 
262  BLO_read_data_address(reader, &clip->adt);
263  BKE_animdata_blend_read_data(reader, clip->adt);
264 
265  direct_link_movieTracks(reader, &tracking->tracks);
266  direct_link_moviePlaneTracks(reader, &tracking->plane_tracks);
268 
269  BLO_read_data_address(reader, &clip->tracking.act_track);
271 
272  clip->anim = NULL;
273  clip->tracking_context = NULL;
274  clip->tracking.stats = NULL;
275 
276  /* TODO: we could store those in undo cache storage as well, and preserve them instead of
277  * re-creating them... */
279 
280  /* Needed for proper versioning, will be NULL for all newer files anyway. */
281  BLO_read_data_address(reader, &clip->tracking.stabilization.rot_track);
282 
283  clip->tracking.dopesheet.ok = 0;
286 
287  BLO_read_list(reader, &tracking->objects);
288 
289  LISTBASE_FOREACH (MovieTrackingObject *, object, &tracking->objects) {
290  direct_link_movieTracks(reader, &object->tracks);
291  direct_link_moviePlaneTracks(reader, &object->plane_tracks);
292  direct_link_movieReconstruction(reader, &object->reconstruction);
293  }
294 }
295 
296 static void lib_link_movieTracks(BlendLibReader *reader, MovieClip *clip, ListBase *tracksbase)
297 {
298  LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) {
299  BLO_read_id_address(reader, clip->id.lib, &track->gpd);
300  }
301 }
302 
304  MovieClip *clip,
305  ListBase *tracksbase)
306 {
307  LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, tracksbase) {
308  BLO_read_id_address(reader, clip->id.lib, &plane_track->image);
309  }
310 }
311 
312 static void movieclip_blend_read_lib(BlendLibReader *reader, ID *id)
313 {
314  MovieClip *clip = (MovieClip *)id;
315  MovieTracking *tracking = &clip->tracking;
316 
317  BLO_read_id_address(reader, clip->id.lib, &clip->gpd);
318 
319  lib_link_movieTracks(reader, clip, &tracking->tracks);
320  lib_link_moviePlaneTracks(reader, clip, &tracking->plane_tracks);
321 
322  LISTBASE_FOREACH (MovieTrackingObject *, object, &tracking->objects) {
323  lib_link_movieTracks(reader, clip, &object->tracks);
324  lib_link_moviePlaneTracks(reader, clip, &object->plane_tracks);
325  }
326 }
327 
329  .id_code = ID_MC,
330  .id_filter = FILTER_ID_MC,
331  .main_listbase_index = INDEX_ID_MC,
332  .struct_size = sizeof(MovieClip),
333  .name = "MovieClip",
334  .name_plural = "movieclips",
335  .translation_context = BLT_I18NCONTEXT_ID_MOVIECLIP,
337  .asset_type_info = NULL,
338 
340  .copy_data = movie_clip_copy_data,
341  .free_data = movie_clip_free_data,
342  .make_local = NULL,
343  .foreach_id = movie_clip_foreach_id,
344  .foreach_cache = movie_clip_foreach_cache,
345  .foreach_path = movie_clip_foreach_path,
346  .owner_get = NULL,
347 
348  .blend_write = movieclip_blend_write,
349  .blend_read_data = movieclip_blend_read_data,
350  .blend_read_lib = movieclip_blend_read_lib,
351  .blend_read_expand = NULL,
352 
353  .blend_read_undo_preserve = NULL,
354 
355  .lib_override_apply_post = NULL,
356 };
357 
358 /*********************** movieclip buffer loaders *************************/
359 
360 static int sequence_guess_offset(const char *full_name, int head_len, unsigned short numlen)
361 {
362  char num[FILE_MAX] = {0};
363 
364  BLI_strncpy(num, full_name + head_len, numlen + 1);
365 
366  return atoi(num);
367 }
368 
369 static int rendersize_to_proxy(const MovieClipUser *user, int flag)
370 {
371  if ((flag & MCLIP_USE_PROXY) == 0) {
372  return IMB_PROXY_NONE;
373  }
374 
375  switch (user->render_size) {
377  return IMB_PROXY_25;
378 
380  return IMB_PROXY_50;
381 
383  return IMB_PROXY_75;
384 
386  return IMB_PROXY_100;
387 
389  return IMB_PROXY_NONE;
390  }
391 
392  return IMB_PROXY_NONE;
393 }
394 
395 static int rendersize_to_number(int render_size)
396 {
397  switch (render_size) {
399  return 25;
400 
402  return 50;
403 
405  return 75;
406 
408  return 100;
409 
411  return 100;
412  }
413 
414  return 100;
415 }
416 
417 static int get_timecode(MovieClip *clip, int flag)
418 {
419  if ((flag & MCLIP_USE_PROXY) == 0) {
420  return IMB_TC_NONE;
421  }
422 
423  return clip->proxy.tc;
424 }
425 
426 static void get_sequence_fname(const MovieClip *clip, const int framenr, char *name)
427 {
428  unsigned short numlen;
429  char head[FILE_MAX], tail[FILE_MAX];
430  int offset;
431 
432  BLI_strncpy(name, clip->filepath, sizeof(clip->filepath));
433  BLI_path_sequence_decode(name, head, tail, &numlen);
434 
435  /* Movie-clips always points to first image from sequence, auto-guess offset for now.
436  * Could be something smarter in the future. */
437  offset = sequence_guess_offset(clip->filepath, strlen(head), numlen);
438 
439  if (numlen) {
441  name, head, tail, numlen, offset + framenr - clip->start_frame + clip->frame_offset);
442  }
443  else {
444  BLI_strncpy(name, clip->filepath, sizeof(clip->filepath));
445  }
446 
448 }
449 
450 /* supposed to work with sequences only */
451 static void get_proxy_fname(
452  const MovieClip *clip, int proxy_render_size, bool undistorted, int framenr, char *name)
453 {
454  int size = rendersize_to_number(proxy_render_size);
455  char dir[FILE_MAX], clipdir[FILE_MAX], clipfile[FILE_MAX];
456  int proxynr = framenr - clip->start_frame + 1 + clip->frame_offset;
457 
458  BLI_split_dirfile(clip->filepath, clipdir, clipfile, FILE_MAX, FILE_MAX);
459 
460  if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) {
461  BLI_strncpy(dir, clip->proxy.dir, sizeof(dir));
462  }
463  else {
464  BLI_snprintf(dir, FILE_MAX, "%s/BL_proxy", clipdir);
465  }
466 
467  if (undistorted) {
468  BLI_snprintf(name, FILE_MAX, "%s/%s/proxy_%d_undistorted/%08d", dir, clipfile, size, proxynr);
469  }
470  else {
471  BLI_snprintf(name, FILE_MAX, "%s/%s/proxy_%d/%08d", dir, clipfile, size, proxynr);
472  }
473 
475  BLI_path_frame(name, 1, 0);
476 
477  strcat(name, ".jpg");
478 }
479 
480 #ifdef WITH_OPENEXR
481 
482 typedef struct MultilayerConvertContext {
483  float *combined_pass;
484  int num_combined_channels;
486 
487 static void *movieclip_convert_multilayer_add_view(void *UNUSED(ctx_v),
488  const char *UNUSED(view_name))
489 {
490  return NULL;
491 }
492 
493 static void *movieclip_convert_multilayer_add_layer(void *ctx_v, const char *UNUSED(layer_name))
494 {
495  /* Return dummy non-NULL value, we don't use layer handle but need to return
496  * something, so render API invokes the add_pass() callbacks. */
497  return ctx_v;
498 }
499 
500 static void movieclip_convert_multilayer_add_pass(void *UNUSED(layer),
501  void *ctx_v,
502  const char *pass_name,
503  float *rect,
504  int num_channels,
505  const char *chan_id,
506  const char *UNUSED(view_name))
507 {
508  /* NOTE: This function must free pass pixels data if it is not used, this
509  * is how IMB_exr_multilayer_convert() is working. */
510  MultilayerConvertContext *ctx = ctx_v;
511  /* If we've found a first combined pass, skip all the rest ones. */
512  if (ctx->combined_pass != NULL) {
513  MEM_freeN(rect);
514  return;
515  }
516  if (STREQ(pass_name, RE_PASSNAME_COMBINED) || STR_ELEM(chan_id, "RGBA", "RGB")) {
517  ctx->combined_pass = rect;
518  ctx->num_combined_channels = num_channels;
519  }
520  else {
521  MEM_freeN(rect);
522  }
523 }
524 
525 #endif /* WITH_OPENEXR */
526 
528 {
529  if (ibuf == NULL) {
530  return;
531  }
532 #ifdef WITH_OPENEXR
533  if (ibuf->ftype != IMB_FTYPE_OPENEXR || ibuf->userdata == NULL) {
534  return;
535  }
537  ctx.combined_pass = NULL;
538  ctx.num_combined_channels = 0;
540  &ctx,
541  movieclip_convert_multilayer_add_view,
542  movieclip_convert_multilayer_add_layer,
543  movieclip_convert_multilayer_add_pass);
544  if (ctx.combined_pass != NULL) {
545  BLI_assert(ibuf->rect_float == NULL);
546  ibuf->rect_float = ctx.combined_pass;
547  ibuf->channels = ctx.num_combined_channels;
548  ibuf->flags |= IB_rectfloat;
549  ibuf->mall |= IB_rectfloat;
550  }
551  IMB_exr_close(ibuf->userdata);
552  ibuf->userdata = NULL;
553 #endif
554 }
555 
557  const MovieClipUser *user,
558  int framenr,
559  int flag)
560 {
561  struct ImBuf *ibuf;
562  char name[FILE_MAX];
563  int loadflag;
564  bool use_proxy = false;
565  char *colorspace;
566 
567  use_proxy = (flag & MCLIP_USE_PROXY) && user->render_size != MCLIP_PROXY_RENDER_SIZE_FULL;
568  if (use_proxy) {
569  int undistort = user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT;
570  get_proxy_fname(clip, user->render_size, undistort, framenr, name);
571 
572  /* Well, this is a bit weird, but proxies for movie sources
573  * are built in the same exact color space as the input,
574  *
575  * But image sequences are built in the display space.
576  */
577  if (clip->source == MCLIP_SRC_MOVIE) {
578  colorspace = clip->colorspace_settings.name;
579  }
580  else {
581  colorspace = NULL;
582  }
583  }
584  else {
585  get_sequence_fname(clip, framenr, name);
586  colorspace = clip->colorspace_settings.name;
587  }
588 
590 
591  /* read ibuf */
592  ibuf = IMB_loadiffname(name, loadflag, colorspace);
594 
595  return ibuf;
596 }
597 
599 {
600  char str[FILE_MAX];
601 
602  if (!clip->anim) {
603  BLI_strncpy(str, clip->filepath, FILE_MAX);
605 
606  /* FIXME: make several stream accessible in image editor, too */
607  clip->anim = openanim(str, IB_rect, 0, clip->colorspace_settings.name);
608 
609  if (clip->anim) {
610  if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) {
611  char dir[FILE_MAX];
612  BLI_strncpy(dir, clip->proxy.dir, sizeof(dir));
614  IMB_anim_set_index_dir(clip->anim, dir);
615  }
616  }
617  }
618 }
619 
621  const MovieClipUser *user,
622  int framenr,
623  int flag)
624 {
625  ImBuf *ibuf = NULL;
626  int tc = get_timecode(clip, flag);
627  int proxy = rendersize_to_proxy(user, flag);
628 
630 
631  if (clip->anim) {
632  int fra = framenr - clip->start_frame + clip->frame_offset;
633 
634  ibuf = IMB_anim_absolute(clip->anim, fra, tc, proxy);
635  }
636 
637  return ibuf;
638 }
639 
641 {
642  if (clip->source == MCLIP_SRC_MOVIE) {
644 
645  if (clip->anim) {
646  clip->len = IMB_anim_get_duration(clip->anim, clip->proxy.tc);
647  }
648  }
649  else if (clip->source == MCLIP_SRC_SEQUENCE) {
650  unsigned short numlen;
651  char name[FILE_MAX], head[FILE_MAX], tail[FILE_MAX];
652 
653  BLI_path_sequence_decode(clip->filepath, head, tail, &numlen);
654 
655  if (numlen == 0) {
656  /* there's no number group in file name, assume it's single framed sequence */
657  clip->len = 1;
658  }
659  else {
660  clip->len = 0;
661  for (;;) {
662  get_sequence_fname(clip, clip->len + clip->start_frame, name);
663 
664  if (BLI_exists(name)) {
665  clip->len++;
666  }
667  else {
668  break;
669  }
670  }
671  }
672  }
673 }
674 
675 /*********************** image buffer cache *************************/
676 
677 typedef struct MovieClipCache {
678  /* regular movie cache */
680 
681  /* cached postprocessed shot */
682  struct {
684  int framenr;
685  int flag;
686 
687  /* cache for undistorted shot */
689  float principal[2];
690  float polynomial_k[3];
691  float division_k[2];
692  float nuke_k[2];
693  float brown_k[4];
694  float brown_p[2];
697 
698  int proxy;
699  short render_flag;
701 
702  /* cache for stable shot */
703  struct {
705 
706  ImBuf *ibuf;
707  int framenr;
709 
710  float loc[2], scale, angle, aspect;
711  int proxy, filter;
712  short render_flag;
714 
716 
719 
720 typedef struct MovieClipImBufCacheKey {
721  int framenr;
722  int proxy;
723  short render_flag;
725 
727  int framenr;
729 
730 static int user_frame_to_cache_frame(MovieClip *clip, int framenr)
731 {
732  int index;
733 
734  index = framenr - clip->start_frame + clip->frame_offset;
735 
736  if (clip->source == MCLIP_SRC_SEQUENCE) {
737  if (clip->cache->sequence_offset == -1) {
738  unsigned short numlen;
739  char head[FILE_MAX], tail[FILE_MAX];
740 
741  BLI_path_sequence_decode(clip->filepath, head, tail, &numlen);
742 
743  /* see comment in get_sequence_fname */
744  clip->cache->sequence_offset = sequence_guess_offset(clip->filepath, strlen(head), numlen);
745  }
746 
747  index += clip->cache->sequence_offset;
748  }
749 
750  if (index < 0) {
751  return framenr - index;
752  }
753 
754  return framenr;
755 }
756 
757 static void moviecache_keydata(void *userkey, int *framenr, int *proxy, int *render_flags)
758 {
759  const MovieClipImBufCacheKey *key = userkey;
760 
761  *framenr = key->framenr;
762  *proxy = key->proxy;
763  *render_flags = key->render_flag;
764 }
765 
766 static unsigned int moviecache_hashhash(const void *keyv)
767 {
768  const MovieClipImBufCacheKey *key = keyv;
769  int rval = key->framenr;
770 
771  return rval;
772 }
773 
774 static bool moviecache_hashcmp(const void *av, const void *bv)
775 {
776  const MovieClipImBufCacheKey *a = av;
777  const MovieClipImBufCacheKey *b = bv;
778 
779  return ((a->framenr != b->framenr) || (a->proxy != b->proxy) ||
780  (a->render_flag != b->render_flag));
781 }
782 
783 static void *moviecache_getprioritydata(void *key_v)
784 {
786  MovieClipCachePriorityData *priority_data;
787 
788  priority_data = MEM_callocN(sizeof(*priority_data), "movie cache clip priority data");
789  priority_data->framenr = key->framenr;
790 
791  return priority_data;
792 }
793 
794 static int moviecache_getitempriority(void *last_userkey_v, void *priority_data_v)
795 {
796  MovieClipImBufCacheKey *last_userkey = (MovieClipImBufCacheKey *)last_userkey_v;
797  MovieClipCachePriorityData *priority_data = (MovieClipCachePriorityData *)priority_data_v;
798 
799  return -abs(last_userkey->framenr - priority_data->framenr);
800 }
801 
802 static void moviecache_prioritydeleter(void *priority_data_v)
803 {
804  MovieClipCachePriorityData *priority_data = (MovieClipCachePriorityData *)priority_data_v;
805 
806  MEM_freeN(priority_data);
807 }
808 
809 static ImBuf *get_imbuf_cache(MovieClip *clip, const MovieClipUser *user, int flag)
810 {
811  if (clip->cache) {
813 
814  if (!clip->cache->is_still_sequence) {
815  key.framenr = user_frame_to_cache_frame(clip, user->framenr);
816  }
817  else {
818  key.framenr = 1;
819  }
820 
821  if (flag & MCLIP_USE_PROXY) {
822  key.proxy = rendersize_to_proxy(user, flag);
823  key.render_flag = user->render_flag;
824  }
825  else {
826  key.proxy = IMB_PROXY_NONE;
827  key.render_flag = 0;
828  }
829 
830  return IMB_moviecache_get(clip->cache->moviecache, &key, NULL);
831  }
832 
833  return NULL;
834 }
835 
836 static bool has_imbuf_cache(MovieClip *clip, MovieClipUser *user, int flag)
837 {
838  if (clip->cache) {
840 
841  key.framenr = user_frame_to_cache_frame(clip, user->framenr);
842 
843  if (flag & MCLIP_USE_PROXY) {
844  key.proxy = rendersize_to_proxy(user, flag);
845  key.render_flag = user->render_flag;
846  }
847  else {
848  key.proxy = IMB_PROXY_NONE;
849  key.render_flag = 0;
850  }
851 
852  return IMB_moviecache_has_frame(clip->cache->moviecache, &key);
853  }
854 
855  return false;
856 }
857 
858 static bool put_imbuf_cache(
859  MovieClip *clip, const MovieClipUser *user, ImBuf *ibuf, int flag, bool destructive)
860 {
862 
863  if (clip->cache == NULL) {
864  struct MovieCache *moviecache;
865 
866  // char cache_name[64];
867  // BLI_snprintf(cache_name, sizeof(cache_name), "movie %s", clip->id.name);
868 
869  clip->cache = MEM_callocN(sizeof(MovieClipCache), "movieClipCache");
870 
871  moviecache = IMB_moviecache_create(
873 
879 
880  clip->cache->moviecache = moviecache;
881  clip->cache->sequence_offset = -1;
882  if (clip->source == MCLIP_SRC_SEQUENCE) {
883  unsigned short numlen;
884  BLI_path_sequence_decode(clip->filepath, NULL, NULL, &numlen);
885  clip->cache->is_still_sequence = (numlen == 0);
886  }
887  }
888 
889  if (!clip->cache->is_still_sequence) {
890  key.framenr = user_frame_to_cache_frame(clip, user->framenr);
891  }
892  else {
893  key.framenr = 1;
894  }
895 
896  if (flag & MCLIP_USE_PROXY) {
897  key.proxy = rendersize_to_proxy(user, flag);
898  key.render_flag = user->render_flag;
899  }
900  else {
901  key.proxy = IMB_PROXY_NONE;
902  key.render_flag = 0;
903  }
904 
905  if (destructive) {
906  IMB_moviecache_put(clip->cache->moviecache, &key, ibuf);
907  return true;
908  }
909 
910  return IMB_moviecache_put_if_possible(clip->cache->moviecache, &key, ibuf);
911 }
912 
913 static bool moviecache_check_free_proxy(ImBuf *UNUSED(ibuf), void *userkey, void *UNUSED(userdata))
914 {
916 
917  return !(key->proxy == IMB_PROXY_NONE && key->render_flag == 0);
918 }
919 
920 /*********************** common functions *************************/
921 
922 /* only image block itself */
923 static MovieClip *movieclip_alloc(Main *bmain, const char *name)
924 {
925  MovieClip *clip;
926 
927  clip = BKE_id_new(bmain, ID_MC, name);
928 
929  return clip;
930 }
931 
933 {
934  int width, height;
936 
938  BKE_movieclip_get_size(clip, &user, &width, &height);
939 
940  if (width && height) {
941  clip->tracking.camera.principal[0] = ((float)width) / 2.0f;
942  clip->tracking.camera.principal[1] = ((float)height) / 2.0f;
943  }
944  else {
945  clip->lastsize[0] = clip->lastsize[1] = IMG_SIZE_FALLBACK;
946  }
947 }
948 
949 static void detect_clip_source(Main *bmain, MovieClip *clip)
950 {
951  ImBuf *ibuf;
952  char name[FILE_MAX];
953 
954  BLI_strncpy(name, clip->filepath, sizeof(name));
956 
958  if (ibuf) {
959  clip->source = MCLIP_SRC_SEQUENCE;
960  IMB_freeImBuf(ibuf);
961  }
962  else {
963  clip->source = MCLIP_SRC_MOVIE;
964  }
965 }
966 
968 {
969  MovieClip *clip;
970  int file;
971  char str[FILE_MAX];
972 
973  BLI_strncpy(str, name, sizeof(str));
975 
976  /* exists? */
977  file = BLI_open(str, O_BINARY | O_RDONLY, 0);
978  if (file == -1) {
979  return NULL;
980  }
981  close(file);
982 
983  /* ** add new movieclip ** */
984 
985  /* create a short library name */
986  clip = movieclip_alloc(bmain, BLI_path_basename(name));
987  BLI_strncpy(clip->filepath, name, sizeof(clip->filepath));
988 
989  detect_clip_source(bmain, clip);
990 
992  if (clip->lastsize[0]) {
993  int width = clip->lastsize[0];
994 
995  clip->tracking.camera.focal = 24.0f * width / clip->tracking.camera.sensor_width;
996  }
997 
998  movieclip_calc_length(clip);
999 
1000  return clip;
1001 }
1002 
1003 MovieClip *BKE_movieclip_file_add_exists_ex(Main *bmain, const char *filepath, bool *r_exists)
1004 {
1005  MovieClip *clip;
1006  char str[FILE_MAX], strtest[FILE_MAX];
1007 
1008  BLI_strncpy(str, filepath, sizeof(str));
1010 
1011  /* first search an identical filepath */
1012  for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
1013  BLI_strncpy(strtest, clip->filepath, sizeof(clip->filepath));
1014  BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &clip->id));
1015 
1016  if (BLI_path_cmp(strtest, str) == 0) {
1017  id_us_plus(&clip->id); /* officially should not, it doesn't link here! */
1018  if (r_exists) {
1019  *r_exists = true;
1020  }
1021  return clip;
1022  }
1023  }
1024 
1025  if (r_exists) {
1026  *r_exists = false;
1027  }
1028  return BKE_movieclip_file_add(bmain, filepath);
1029 }
1030 
1031 MovieClip *BKE_movieclip_file_add_exists(Main *bmain, const char *filepath)
1032 {
1033  return BKE_movieclip_file_add_exists_ex(bmain, filepath, NULL);
1034 }
1035 
1036 static void real_ibuf_size(
1037  const MovieClip *clip, const MovieClipUser *user, const ImBuf *ibuf, int *width, int *height)
1038 {
1039  *width = ibuf->x;
1040  *height = ibuf->y;
1041 
1042  if (clip->flag & MCLIP_USE_PROXY) {
1043  switch (user->render_size) {
1045  (*width) *= 4;
1046  (*height) *= 4;
1047  break;
1048 
1050  (*width) *= 2.0f;
1051  (*height) *= 2.0f;
1052  break;
1053 
1055  *width = ((float)*width) * 4.0f / 3.0f;
1056  *height = ((float)*height) * 4.0f / 3.0f;
1057  break;
1058  }
1059  }
1060 }
1061 
1063  struct MovieDistortion *distortion,
1064  ImBuf *ibuf)
1065 {
1066  ImBuf *undistibuf;
1067 
1068  if (distortion) {
1069  undistibuf = BKE_tracking_distortion_exec(
1070  distortion, &clip->tracking, ibuf, ibuf->x, ibuf->y, 0.0f, 1);
1071  }
1072  else {
1073  undistibuf = BKE_tracking_undistort_frame(&clip->tracking, ibuf, ibuf->x, ibuf->y, 0.0f);
1074  }
1075 
1076  IMB_scaleImBuf(undistibuf, ibuf->x, ibuf->y);
1077 
1078  return undistibuf;
1079 }
1080 
1081 static bool need_undistortion_postprocess(const MovieClipUser *user, int clip_flag)
1082 {
1083  bool result = 0;
1084  const bool uses_full_frame = ((clip_flag & MCLIP_USE_PROXY) == 0) ||
1086  /* Only full undistorted render can be used as on-fly undistorting image. */
1087  result |= uses_full_frame && (user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT) != 0;
1088  return result;
1089 }
1090 
1091 static bool need_postprocessed_frame(const MovieClipUser *user,
1092  int clip_flag,
1093  int postprocess_flag)
1094 {
1095  bool result = (postprocess_flag != 0);
1096  result |= need_undistortion_postprocess(user, clip_flag);
1097  return result;
1098 }
1099 
1101 {
1102  const MovieClipCache *cache = clip->cache;
1103  const MovieTrackingCamera *camera = &clip->tracking.camera;
1104 
1105  if (camera->focal != cache->postprocessed.focal_length) {
1106  return false;
1107  }
1108 
1109  /* check for distortion model changes */
1110  if (!equals_v2v2(camera->principal, cache->postprocessed.principal)) {
1111  return false;
1112  }
1113 
1114  if (camera->distortion_model != cache->postprocessed.distortion_model) {
1115  return false;
1116  }
1117 
1118  if (!equals_v3v3(&camera->k1, cache->postprocessed.polynomial_k)) {
1119  return false;
1120  }
1121 
1122  if (!equals_v2v2(&camera->division_k1, cache->postprocessed.division_k)) {
1123  return false;
1124  }
1125 
1126  if (!equals_v2v2(&camera->nuke_k1, cache->postprocessed.nuke_k)) {
1127  return false;
1128  }
1129 
1130  if (!equals_v4v4(&camera->brown_k1, cache->postprocessed.brown_k)) {
1131  return false;
1132  }
1133  if (!equals_v2v2(&camera->brown_p1, cache->postprocessed.brown_p)) {
1134  return false;
1135  }
1136 
1137  return true;
1138 }
1139 
1141  const MovieClipUser *user,
1142  int flag,
1143  int postprocess_flag)
1144 {
1145  const MovieClipCache *cache = clip->cache;
1146  int framenr = user->framenr;
1147  short proxy = IMB_PROXY_NONE;
1148  int render_flag = 0;
1149 
1150  if (flag & MCLIP_USE_PROXY) {
1151  proxy = rendersize_to_proxy(user, flag);
1152  render_flag = user->render_flag;
1153  }
1154 
1155  /* no cache or no cached postprocessed image */
1156  if (!clip->cache || !clip->cache->postprocessed.ibuf) {
1157  return NULL;
1158  }
1159 
1160  /* Postprocessing happened for other frame. */
1161  if (cache->postprocessed.framenr != framenr) {
1162  return NULL;
1163  }
1164 
1165  /* cached ibuf used different proxy settings */
1166  if (cache->postprocessed.render_flag != render_flag || cache->postprocessed.proxy != proxy) {
1167  return NULL;
1168  }
1169 
1170  if (cache->postprocessed.flag != postprocess_flag) {
1171  return NULL;
1172  }
1173 
1174  if (need_undistortion_postprocess(user, flag)) {
1175  if (!check_undistortion_cache_flags(clip)) {
1176  return NULL;
1177  }
1178  }
1179  else if (cache->postprocessed.undistortion_used) {
1180  return NULL;
1181  }
1182 
1184 
1185  return cache->postprocessed.ibuf;
1186 }
1187 
1189  MovieClip *clip, const MovieClipUser *user, ImBuf *ibuf, int flag, int postprocess_flag)
1190 {
1191  ImBuf *postproc_ibuf = NULL;
1192 
1193  if (need_undistortion_postprocess(user, flag)) {
1194  postproc_ibuf = get_undistorted_ibuf(clip, NULL, ibuf);
1195  }
1196  else {
1197  postproc_ibuf = IMB_dupImBuf(ibuf);
1198  }
1199 
1200  if (postprocess_flag) {
1201  bool disable_red = (postprocess_flag & MOVIECLIP_DISABLE_RED) != 0;
1202  bool disable_green = (postprocess_flag & MOVIECLIP_DISABLE_GREEN) != 0;
1203  bool disable_blue = (postprocess_flag & MOVIECLIP_DISABLE_BLUE) != 0;
1204  bool grayscale = (postprocess_flag & MOVIECLIP_PREVIEW_GRAYSCALE) != 0;
1205 
1206  if (disable_red || disable_green || disable_blue || grayscale) {
1207  BKE_tracking_disable_channels(postproc_ibuf, disable_red, disable_green, disable_blue, 1);
1208  }
1209  }
1210 
1211  return postproc_ibuf;
1212 }
1213 
1215  MovieClip *clip, const MovieClipUser *user, ImBuf *ibuf, int flag, int postprocess_flag)
1216 {
1217  MovieClipCache *cache = clip->cache;
1219 
1220  cache->postprocessed.framenr = user->framenr;
1221  cache->postprocessed.flag = postprocess_flag;
1222 
1223  if (flag & MCLIP_USE_PROXY) {
1224  cache->postprocessed.proxy = rendersize_to_proxy(user, flag);
1225  cache->postprocessed.render_flag = user->render_flag;
1226  }
1227  else {
1229  cache->postprocessed.render_flag = 0;
1230  }
1231 
1232  if (need_undistortion_postprocess(user, flag)) {
1233  cache->postprocessed.distortion_model = camera->distortion_model;
1234  cache->postprocessed.focal_length = camera->focal;
1235  copy_v2_v2(cache->postprocessed.principal, camera->principal);
1237  copy_v2_v2(cache->postprocessed.division_k, &camera->division_k1);
1238  copy_v2_v2(cache->postprocessed.nuke_k, &camera->nuke_k1);
1239  copy_v4_v4(cache->postprocessed.brown_k, &camera->brown_k1);
1240  copy_v2_v2(cache->postprocessed.brown_p, &camera->brown_p1);
1241  cache->postprocessed.undistortion_used = true;
1242  }
1243  else {
1244  cache->postprocessed.undistortion_used = false;
1245  }
1246 
1247  IMB_refImBuf(ibuf);
1248 
1249  if (cache->postprocessed.ibuf) {
1251  }
1252 
1253  cache->postprocessed.ibuf = ibuf;
1254 }
1255 
1257  MovieClip *clip, const MovieClipUser *user, int flag, int postprocess_flag, int cache_flag)
1258 {
1259  ImBuf *ibuf = NULL;
1260  int framenr = user->framenr;
1261  bool need_postprocess = false;
1262 
1263  /* cache isn't threadsafe itself and also loading of movies
1264  * can't happen from concurrent threads that's why we use lock here */
1266 
1267  /* try to obtain cached postprocessed frame first */
1268  if (need_postprocessed_frame(user, flag, postprocess_flag)) {
1269  ibuf = get_postprocessed_cached_frame(clip, user, flag, postprocess_flag);
1270 
1271  if (!ibuf) {
1272  need_postprocess = true;
1273  }
1274  }
1275 
1276  if (!ibuf) {
1277  ibuf = get_imbuf_cache(clip, user, flag);
1278  }
1279 
1280  if (!ibuf) {
1281  bool use_sequence = false;
1282 
1283  /* undistorted proxies for movies should be read as image sequence */
1284  use_sequence = (user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT) &&
1286 
1287  if (clip->source == MCLIP_SRC_SEQUENCE || use_sequence) {
1288  ibuf = movieclip_load_sequence_file(clip, user, framenr, flag);
1289  }
1290  else {
1291  ibuf = movieclip_load_movie_file(clip, user, framenr, flag);
1292  }
1293 
1294  if (ibuf && (cache_flag & MOVIECLIP_CACHE_SKIP) == 0) {
1295  put_imbuf_cache(clip, user, ibuf, flag, true);
1296  }
1297  }
1298 
1299  if (ibuf) {
1300  clip->lastframe = framenr;
1301  real_ibuf_size(clip, user, ibuf, &clip->lastsize[0], &clip->lastsize[1]);
1302 
1303  /* Post-process frame and put to cache if needed. */
1304  if (need_postprocess) {
1305  ImBuf *tmpibuf = ibuf;
1306  ibuf = postprocess_frame(clip, user, tmpibuf, flag, postprocess_flag);
1307  IMB_freeImBuf(tmpibuf);
1308  if (ibuf && (cache_flag & MOVIECLIP_CACHE_SKIP) == 0) {
1309  put_postprocessed_frame_to_cache(clip, user, ibuf, flag, postprocess_flag);
1310  }
1311  }
1312  }
1313 
1315 
1316  /* Fallback render in case proxies are not enabled or built */
1317  if (!ibuf && user->render_flag & MCLIP_PROXY_RENDER_USE_FALLBACK_RENDER &&
1319  MovieClipUser user_fallback = *user;
1320  user_fallback.render_size = MCLIP_PROXY_RENDER_SIZE_FULL;
1321 
1323  clip, &user_fallback, flag, postprocess_flag, cache_flag);
1324  }
1325 
1326  return ibuf;
1327 }
1328 
1330 {
1331  return BKE_movieclip_get_ibuf_flag(clip, user, clip->flag, 0);
1332 }
1333 
1334 ImBuf *BKE_movieclip_get_ibuf_flag(MovieClip *clip, MovieClipUser *user, int flag, int cache_flag)
1335 {
1336  return movieclip_get_postprocessed_ibuf(clip, user, flag, 0, cache_flag);
1337 }
1338 
1340  MovieClipUser *user,
1341  int postprocess_flag)
1342 {
1343  return movieclip_get_postprocessed_ibuf(clip, user, clip->flag, postprocess_flag, 0);
1344 }
1345 
1347  MovieClip *clip, MovieClipUser *user, ImBuf *reference_ibuf, int framenr, int postprocess_flag)
1348 {
1349  MovieClipCache *cache = clip->cache;
1350  MovieTracking *tracking = &clip->tracking;
1351  ImBuf *stableibuf;
1352  float tloc[2], tscale, tangle;
1353  short proxy = IMB_PROXY_NONE;
1354  int render_flag = 0;
1355  int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, framenr);
1356 
1357  if (clip->flag & MCLIP_USE_PROXY) {
1358  proxy = rendersize_to_proxy(user, clip->flag);
1359  render_flag = user->render_flag;
1360  }
1361 
1362  /* there's no cached frame or it was calculated for another frame */
1363  if (!cache->stabilized.ibuf || cache->stabilized.framenr != framenr) {
1364  return NULL;
1365  }
1366 
1367  if (cache->stabilized.reference_ibuf != reference_ibuf) {
1368  return NULL;
1369  }
1370 
1371  /* cached ibuf used different proxy settings */
1372  if (cache->stabilized.render_flag != render_flag || cache->stabilized.proxy != proxy) {
1373  return NULL;
1374  }
1375 
1376  if (cache->stabilized.postprocess_flag != postprocess_flag) {
1377  return NULL;
1378  }
1379 
1380  /* stabilization also depends on pixel aspect ratio */
1381  if (cache->stabilized.aspect != tracking->camera.pixel_aspect) {
1382  return NULL;
1383  }
1384 
1385  if (cache->stabilized.filter != tracking->stabilization.filter) {
1386  return NULL;
1387  }
1388 
1389  stableibuf = cache->stabilized.ibuf;
1390 
1392  clip, clip_framenr, stableibuf->x, stableibuf->y, tloc, &tscale, &tangle);
1393 
1394  /* check for stabilization parameters */
1395  if (tscale != cache->stabilized.scale || tangle != cache->stabilized.angle ||
1396  !equals_v2v2(tloc, cache->stabilized.loc)) {
1397  return NULL;
1398  }
1399 
1400  IMB_refImBuf(stableibuf);
1401 
1402  return stableibuf;
1403 }
1404 
1406  MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, int framenr, int postprocess_flag)
1407 {
1408  MovieClipCache *cache = clip->cache;
1409  MovieTracking *tracking = &clip->tracking;
1410  ImBuf *stableibuf;
1411  float tloc[2], tscale, tangle;
1412  int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, framenr);
1413 
1414  stableibuf = BKE_tracking_stabilize_frame(clip, clip_framenr, ibuf, tloc, &tscale, &tangle);
1415 
1416  copy_v2_v2(cache->stabilized.loc, tloc);
1417 
1418  cache->stabilized.reference_ibuf = ibuf;
1419  cache->stabilized.scale = tscale;
1420  cache->stabilized.angle = tangle;
1421  cache->stabilized.framenr = framenr;
1422  cache->stabilized.aspect = tracking->camera.pixel_aspect;
1423  cache->stabilized.filter = tracking->stabilization.filter;
1424 
1425  if (clip->flag & MCLIP_USE_PROXY) {
1426  cache->stabilized.proxy = rendersize_to_proxy(user, clip->flag);
1427  cache->stabilized.render_flag = user->render_flag;
1428  }
1429  else {
1430  cache->stabilized.proxy = IMB_PROXY_NONE;
1431  cache->stabilized.render_flag = 0;
1432  }
1433 
1434  cache->stabilized.postprocess_flag = postprocess_flag;
1435 
1436  if (cache->stabilized.ibuf) {
1437  IMB_freeImBuf(cache->stabilized.ibuf);
1438  }
1439 
1440  cache->stabilized.ibuf = stableibuf;
1441 
1442  IMB_refImBuf(stableibuf);
1443 
1444  return stableibuf;
1445 }
1446 
1448  MovieClipUser *user,
1449  float loc[2],
1450  float *scale,
1451  float *angle,
1452  int postprocess_flag)
1453 {
1454  ImBuf *ibuf, *stableibuf = NULL;
1455  int framenr = user->framenr;
1456 
1457  ibuf = BKE_movieclip_get_postprocessed_ibuf(clip, user, postprocess_flag);
1458 
1459  if (!ibuf) {
1460  return NULL;
1461  }
1462 
1464  MovieClipCache *cache = clip->cache;
1465 
1466  stableibuf = get_stable_cached_frame(clip, user, ibuf, framenr, postprocess_flag);
1467 
1468  if (!stableibuf) {
1469  stableibuf = put_stabilized_frame_to_cache(clip, user, ibuf, framenr, postprocess_flag);
1470  }
1471 
1472  if (loc) {
1473  copy_v2_v2(loc, cache->stabilized.loc);
1474  }
1475 
1476  if (scale) {
1477  *scale = cache->stabilized.scale;
1478  }
1479 
1480  if (angle) {
1481  *angle = cache->stabilized.angle;
1482  }
1483  }
1484  else {
1485  if (loc) {
1486  zero_v2(loc);
1487  }
1488 
1489  if (scale) {
1490  *scale = 1.0f;
1491  }
1492 
1493  if (angle) {
1494  *angle = 0.0f;
1495  }
1496 
1497  stableibuf = ibuf;
1498  }
1499 
1500  if (stableibuf != ibuf) {
1501  IMB_freeImBuf(ibuf);
1502  ibuf = stableibuf;
1503  }
1504 
1505  return ibuf;
1506 }
1507 
1509 {
1510  ImBuf *ibuf = BKE_movieclip_get_ibuf(clip, user);
1511 
1512  if (ibuf) {
1513  IMB_freeImBuf(ibuf);
1514  return true;
1515  }
1516 
1517  return false;
1518 }
1519 
1521 {
1522 #if 0
1523  /* originally was needed to support image sequences with different image dimensions,
1524  * which might be useful for such things as reconstruction of unordered image sequence,
1525  * or painting/rotoscoping of non-equal-sized images, but this ended up in unneeded
1526  * cache lookups and even unwanted non-proxied files loading when doing mask parenting,
1527  * so let's disable this for now and assume image sequence consists of images with
1528  * equal sizes (sergey)
1529  * TODO(sergey): Support reading sequences of different resolution.
1530  */
1531  if (user->framenr == clip->lastframe) {
1532 #endif
1533  if (clip->lastsize[0] != 0 && clip->lastsize[1] != 0) {
1534  *width = clip->lastsize[0];
1535  *height = clip->lastsize[1];
1536  }
1537  else {
1538  ImBuf *ibuf = BKE_movieclip_get_ibuf(clip, user);
1539 
1540  if (ibuf && ibuf->x && ibuf->y) {
1541  real_ibuf_size(clip, user, ibuf, width, height);
1542  }
1543  else {
1544  *width = clip->lastsize[0];
1545  *height = clip->lastsize[1];
1546  }
1547 
1548  if (ibuf) {
1549  IMB_freeImBuf(ibuf);
1550  }
1551  }
1552 }
1554 {
1555  int width, height;
1556  BKE_movieclip_get_size(clip, user, &width, &height);
1557 
1558  size[0] = (float)width;
1559  size[1] = (float)height;
1560 }
1561 
1563 {
1564  if (!clip->len) {
1565  movieclip_calc_length(clip);
1566  }
1567 
1568  return clip->len;
1569 }
1570 
1572 {
1573  if (clip->source != MCLIP_SRC_MOVIE) {
1574  return 0.0f;
1575  }
1577  if (clip->anim == NULL) {
1578  return 0.0f;
1579  }
1580  short frs_sec;
1581  float frs_sec_base;
1582  if (IMB_anim_get_fps(clip->anim, &frs_sec, &frs_sec_base, true)) {
1583  return (float)frs_sec / frs_sec_base;
1584  }
1585  return 0.0f;
1586 }
1587 
1588 void BKE_movieclip_get_aspect(MovieClip *clip, float *aspx, float *aspy)
1589 {
1590  *aspx = 1.0;
1591 
1592  /* x is always 1 */
1593  *aspy = clip->aspy / clip->aspx / clip->tracking.camera.pixel_aspect;
1594 }
1595 
1597  MovieClipUser *user,
1598  int *r_totseg,
1599  int **r_points)
1600 {
1601  *r_totseg = 0;
1602  *r_points = NULL;
1603 
1604  if (clip->cache) {
1605  int proxy = rendersize_to_proxy(user, clip->flag);
1606 
1609  clip->cache->moviecache, proxy, user->render_flag, r_totseg, r_points);
1611  }
1612 }
1613 
1615 {
1616  /* TODO: clamp framenr here? */
1617 
1618  iuser->framenr = framenr;
1619 }
1620 
1621 static void free_buffers(MovieClip *clip)
1622 {
1623  if (clip->cache) {
1625 
1626  if (clip->cache->postprocessed.ibuf) {
1628  }
1629 
1630  if (clip->cache->stabilized.ibuf) {
1632  }
1633 
1634  MEM_freeN(clip->cache);
1635  clip->cache = NULL;
1636  }
1637 
1638  if (clip->anim) {
1639  IMB_free_anim(clip->anim);
1640  clip->anim = NULL;
1641  }
1642 
1644  for (tex = clip->runtime.gputextures.first; tex; tex = tex->next) {
1645  for (int i = 0; i < TEXTARGET_COUNT; i++) {
1646  if (tex->gputexture[i] != NULL) {
1647  GPU_texture_free(tex->gputexture[i]);
1648  tex->gputexture[i] = NULL;
1649  }
1650  }
1651  }
1653 }
1654 
1656 {
1657  free_buffers(clip);
1658 }
1659 
1661 {
1662  if (clip->cache && clip->cache->moviecache) {
1664  }
1665 }
1666 
1668 {
1669  /* clear cache */
1670  free_buffers(clip);
1671 
1672  /* update clip source */
1673  detect_clip_source(bmain, clip);
1674 
1675  clip->lastsize[0] = clip->lastsize[1] = 0;
1677 
1678  movieclip_calc_length(clip);
1679 
1680  BKE_ntree_update_tag_id_changed(bmain, &clip->id);
1681 }
1682 
1684 {
1685  if (scopes->ok) {
1686  return;
1687  }
1688 
1689  if (scopes->track_preview) {
1690  IMB_freeImBuf(scopes->track_preview);
1691  scopes->track_preview = NULL;
1692  }
1693 
1694  if (scopes->track_search) {
1695  IMB_freeImBuf(scopes->track_search);
1696  scopes->track_search = NULL;
1697  }
1698 
1699  scopes->marker = NULL;
1700  scopes->track = NULL;
1701  scopes->track_locked = true;
1702 
1703  scopes->scene_framenr = user->framenr;
1704  scopes->ok = true;
1705 
1706  if (clip == NULL) {
1707  return;
1708  }
1709 
1711  if (track == NULL) {
1712  return;
1713  }
1714 
1715  const int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr);
1716  MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
1717 
1718  scopes->marker = marker;
1719  scopes->track = track;
1720 
1721  if (marker->flag & MARKER_DISABLED) {
1722  scopes->track_disabled = true;
1723  }
1724  else {
1725  ImBuf *ibuf = BKE_movieclip_get_ibuf(clip, user);
1726 
1727  scopes->track_disabled = false;
1728 
1729  if (ibuf && (ibuf->rect || ibuf->rect_float)) {
1730  MovieTrackingMarker undist_marker = *marker;
1731 
1733  int width, height;
1734  float aspy = 1.0f / clip->tracking.camera.pixel_aspect;
1735 
1736  BKE_movieclip_get_size(clip, user, &width, &height);
1737 
1738  undist_marker.pos[0] *= width;
1739  undist_marker.pos[1] *= height * aspy;
1740 
1742  &clip->tracking, width, height, undist_marker.pos, undist_marker.pos);
1743 
1744  undist_marker.pos[0] /= width;
1745  undist_marker.pos[1] /= height * aspy;
1746  }
1747 
1749  ibuf, track, &undist_marker, true, true);
1750 
1751  scopes->undist_marker = undist_marker;
1752 
1753  scopes->frame_width = ibuf->x;
1754  scopes->frame_height = ibuf->y;
1755 
1756  scopes->use_track_mask = (track->flag & TRACK_PREVIEW_ALPHA) != 0;
1757  }
1758 
1759  IMB_freeImBuf(ibuf);
1760  }
1761 
1762  if ((track->flag & TRACK_LOCKED) == 0) {
1763  float pat_min[2], pat_max[2];
1764 
1765  scopes->track_locked = false;
1766 
1767  /* XXX: would work fine with non-transformed patterns, but would likely fail
1768  * with transformed patterns, but that would be easier to debug when
1769  * we'll have real pattern sampling (at least to test) */
1770  BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
1771 
1772  scopes->slide_scale[0] = pat_max[0] - pat_min[0];
1773  scopes->slide_scale[1] = pat_max[1] - pat_min[1];
1774  }
1775 }
1776 
1778  MovieClip *clip, ImBuf *ibuf, int cfra, int proxy_render_size, bool undistorted, bool threaded)
1779 {
1780  char name[FILE_MAX];
1781  int quality, rectx, recty;
1782  int size = rendersize_to_number(proxy_render_size);
1783  ImBuf *scaleibuf;
1784 
1785  get_proxy_fname(clip, proxy_render_size, undistorted, cfra, name);
1786 
1787  rectx = ibuf->x * size / 100.0f;
1788  recty = ibuf->y * size / 100.0f;
1789 
1790  scaleibuf = IMB_dupImBuf(ibuf);
1791 
1792  if (threaded) {
1793  IMB_scaleImBuf_threaded(scaleibuf, (short)rectx, (short)recty);
1794  }
1795  else {
1796  IMB_scaleImBuf(scaleibuf, (short)rectx, (short)recty);
1797  }
1798 
1799  quality = clip->proxy.quality;
1800  scaleibuf->ftype = IMB_FTYPE_JPG;
1801  scaleibuf->foptions.quality = quality;
1802  /* unsupported feature only confuses other s/w */
1803  if (scaleibuf->planes == 32) {
1804  scaleibuf->planes = 24;
1805  }
1806 
1807  /* TODO: currently the most weak part of multi-threaded proxies,
1808  * could be solved in a way that thread only prepares memory
1809  * buffer and write to disk happens separately
1810  */
1812 
1814  if (IMB_saveiff(scaleibuf, name, IB_rect) == 0) {
1815  perror(name);
1816  }
1817 
1819 
1820  IMB_freeImBuf(scaleibuf);
1821 }
1822 
1824  int clip_flag,
1825  struct MovieDistortion *distortion,
1826  int cfra,
1827  int *build_sizes,
1828  int build_count,
1829  bool undistorted)
1830 {
1831  ImBuf *ibuf;
1832  MovieClipUser user;
1833 
1834  if (!build_count) {
1835  return;
1836  }
1837 
1838  user.framenr = cfra;
1839  user.render_flag = 0;
1841 
1842  ibuf = BKE_movieclip_get_ibuf_flag(clip, &user, clip_flag, MOVIECLIP_CACHE_SKIP);
1843 
1844  if (ibuf) {
1845  ImBuf *tmpibuf = ibuf;
1846  int i;
1847 
1848  if (undistorted) {
1849  tmpibuf = get_undistorted_ibuf(clip, distortion, ibuf);
1850  }
1851 
1852  for (i = 0; i < build_count; i++) {
1853  movieclip_build_proxy_ibuf(clip, tmpibuf, cfra, build_sizes[i], undistorted, true);
1854  }
1855 
1856  IMB_freeImBuf(ibuf);
1857 
1858  if (tmpibuf != ibuf) {
1859  IMB_freeImBuf(tmpibuf);
1860  }
1861  }
1862 }
1863 
1865  ImBuf *ibuf,
1866  struct MovieDistortion *distortion,
1867  int cfra,
1868  int *build_sizes,
1869  int build_count,
1870  bool undistorted)
1871 {
1872  if (!build_count) {
1873  return;
1874  }
1875 
1876  if (ibuf) {
1877  ImBuf *tmpibuf = ibuf;
1878  int i;
1879 
1880  if (undistorted) {
1881  tmpibuf = get_undistorted_ibuf(clip, distortion, ibuf);
1882  }
1883 
1884  for (i = 0; i < build_count; i++) {
1885  movieclip_build_proxy_ibuf(clip, tmpibuf, cfra, build_sizes[i], undistorted, false);
1886  }
1887 
1888  if (tmpibuf != ibuf) {
1889  IMB_freeImBuf(tmpibuf);
1890  }
1891  }
1892 }
1893 
1895 {
1896  return clip->flag & MCLIP_USE_PROXY;
1897 }
1898 
1899 float BKE_movieclip_remap_scene_to_clip_frame(const MovieClip *clip, float framenr)
1900 {
1901  return framenr - (float)clip->start_frame + 1.0f;
1902 }
1903 
1904 float BKE_movieclip_remap_clip_to_scene_frame(const MovieClip *clip, float framenr)
1905 {
1906  return framenr + (float)clip->start_frame - 1.0f;
1907 }
1908 
1910 {
1911  if (clip->source == MCLIP_SRC_SEQUENCE) {
1912  int use_proxy;
1913 
1914  use_proxy = (clip->flag & MCLIP_USE_PROXY) &&
1916 
1917  if (use_proxy) {
1918  int undistort = user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT;
1919  get_proxy_fname(clip, user->render_size, undistort, user->framenr, name);
1920  }
1921  else {
1922  get_sequence_fname(clip, user->framenr, name);
1923  }
1924  }
1925  else {
1926  BLI_strncpy(name, clip->filepath, FILE_MAX);
1928  }
1929 }
1930 
1932 {
1933  ImBuf *ibuf = NULL;
1934 
1935  if (clip->source == MCLIP_SRC_MOVIE) {
1936  ibuf = movieclip_load_movie_file(clip, user, user->framenr, clip->flag);
1937  }
1938 
1939  return ibuf;
1940 }
1941 
1943 {
1944  bool has_frame = false;
1945 
1947  has_frame = has_imbuf_cache(clip, user, clip->flag);
1949 
1950  return has_frame;
1951 }
1952 
1954 {
1955  bool result;
1956 
1958  result = put_imbuf_cache(clip, user, ibuf, clip->flag, false);
1960 
1961  return result;
1962 }
1963 
1964 static void movieclip_selection_sync(MovieClip *clip_dst, const MovieClip *clip_src)
1965 {
1966  BLI_assert(clip_dst != clip_src);
1967  MovieTracking *tracking_dst = &clip_dst->tracking, tracking_src = clip_src->tracking;
1968  /* Syncs the active object, track and plane track. */
1969  tracking_dst->objectnr = tracking_src.objectnr;
1970  const int active_track_index = BLI_findindex(&tracking_src.tracks, tracking_src.act_track);
1971  const int active_plane_track_index = BLI_findindex(&tracking_src.plane_tracks,
1972  tracking_src.act_plane_track);
1973  tracking_dst->act_track = BLI_findlink(&tracking_dst->tracks, active_track_index);
1974  tracking_dst->act_plane_track = BLI_findlink(&tracking_dst->plane_tracks,
1975  active_plane_track_index);
1976 
1977  /* Syncs the tracking selection flag. */
1978  MovieTrackingObject *tracking_object_dst, *tracking_object_src;
1979  tracking_object_src = tracking_src.objects.first;
1980 
1981  for (tracking_object_dst = tracking_dst->objects.first; tracking_object_dst != NULL;
1982  tracking_object_dst = tracking_object_dst->next,
1983  tracking_object_src = tracking_object_src->next) {
1984  ListBase *tracksbase_dst, *tracksbase_src;
1985  tracksbase_dst = BKE_tracking_object_get_tracks(tracking_dst, tracking_object_dst);
1986  tracksbase_src = BKE_tracking_object_get_tracks(&tracking_src, tracking_object_src);
1987 
1988  MovieTrackingTrack *track_dst, *track_src;
1989  track_src = tracksbase_src->first;
1990  for (track_dst = tracksbase_dst->first; track_dst != NULL;
1991  track_dst = track_dst->next, track_src = track_src->next) {
1992  track_dst->flag = track_src->flag;
1993  track_dst->pat_flag = track_src->pat_flag;
1994  track_dst->search_flag = track_src->search_flag;
1995  }
1996  }
1997 }
1998 
2000 {
2001  BKE_movieclip_reload(bmain, clip);
2002  if (DEG_is_active(depsgraph)) {
2003  MovieClip *clip_orig = (MovieClip *)DEG_get_original_id(&clip->id);
2004  BKE_movieclip_reload(bmain, clip_orig);
2005  }
2006 }
2007 
2009 {
2011  if (DEG_is_active(depsgraph)) {
2012  MovieClip *clip_orig = (MovieClip *)DEG_get_original_id(&clip->id);
2014  }
2015 }
2016 
2018 {
2019  DEG_debug_print_eval(depsgraph, __func__, clip->id.name, clip);
2020  if (clip->id.recalc & ID_RECALC_SOURCE) {
2022  }
2023  else {
2025  }
2026 }
2027 
2029 {
2030  DEG_debug_print_eval(depsgraph, __func__, clip->id.name, clip);
2031  movieclip_selection_sync(clip, (MovieClip *)clip->id.orig_id);
2032 }
2033 
2034 /* -------------------------------------------------------------------- */
2039  MovieClipUser *cuser,
2040  eGPUTextureTarget textarget)
2041 {
2042  /* Check if we have an existing entry for that clip user. */
2044  for (tex = clip->runtime.gputextures.first; tex; tex = tex->next) {
2045  if (memcmp(&tex->user, cuser, sizeof(MovieClipUser)) == 0) {
2046  break;
2047  }
2048  }
2049 
2050  /* If not, allocate a new one. */
2051  if (tex == NULL) {
2053  __func__);
2054 
2055  for (int i = 0; i < TEXTARGET_COUNT; i++) {
2056  tex->gputexture[i] = NULL;
2057  }
2058 
2059  memcpy(&tex->user, cuser, sizeof(MovieClipUser));
2061  }
2062 
2063  return &tex->gputexture[textarget];
2064 }
2065 
2067 {
2068  if (clip == NULL) {
2069  return NULL;
2070  }
2071 
2073  if (*tex) {
2074  return *tex;
2075  }
2076 
2077  /* check if we have a valid image buffer */
2078  ImBuf *ibuf = BKE_movieclip_get_ibuf(clip, cuser);
2079  if (ibuf == NULL) {
2080  fprintf(stderr, "GPUTexture: Blender Texture Not Loaded!\n");
2081  *tex = GPU_texture_create_error(2, false);
2082  return *tex;
2083  }
2084 
2085  /* This only means RGBA16F instead of RGBA32F. */
2086  const bool high_bitdepth = false;
2087  const bool store_premultiplied = ibuf->rect_float ? false : true;
2088  *tex = IMB_create_gpu_texture(clip->id.name + 2, ibuf, high_bitdepth, store_premultiplied);
2089 
2090  /* Do not generate mips for movieclips... too slow. */
2091  GPU_texture_mipmap_mode(*tex, false, true);
2092 
2093  IMB_freeImBuf(ibuf);
2094 
2095  return *tex;
2096 }
2097 
2099 {
2100  /* Number of gpu textures to keep around as cache.
2101  * We don't want to keep too many GPU textures for
2102  * movie clips around, as they can be large. */
2103  const int MOVIECLIP_NUM_GPUTEXTURES = 1;
2104 
2105  while (BLI_listbase_count(&clip->runtime.gputextures) > MOVIECLIP_NUM_GPUTEXTURES) {
2107  &clip->runtime.gputextures);
2108  for (int i = 0; i < TEXTARGET_COUNT; i++) {
2109  /* free glsl image binding */
2110  if (tex->gputexture[i]) {
2111  GPU_texture_free(tex->gputexture[i]);
2112  tex->gputexture[i] = NULL;
2113  }
2114  }
2115  MEM_freeN(tex);
2116  }
2117 }
2118 
typedef float(TangentPoint)[2]
void BKE_animdata_blend_read_data(struct BlendDataReader *reader, struct AnimData *adt)
Definition: anim_data.c:1443
void BKE_animdata_blend_write(struct BlendWriter *writer, struct AnimData *adt)
Definition: anim_data.c:1421
bool BKE_bpath_foreach_path_fixed_process(struct BPathForeachPathData *bpath_data, char *path)
Definition: bpath.c:121
void BKE_color_managed_colorspace_settings_copy(struct ColorManagedColorspaceSettings *colorspace_settings, const struct ColorManagedColorspaceSettings *settings)
void BKE_color_managed_colorspace_settings_init(struct ColorManagedColorspaceSettings *colorspace_settings)
Definition: colortools.c:1882
@ IDTYPE_FLAGS_APPEND_IS_REUSABLE
Definition: BKE_idtype.h:39
void(* IDTypeForeachCacheFunctionCallback)(struct ID *id, const struct IDCacheKey *cache_key, void **cache_p, uint flags, void *user_data)
Definition: BKE_idtype.h:77
struct anim * openanim(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE])
@ LIB_ID_CREATE_NO_USER_REFCOUNT
Definition: BKE_lib_id.h:126
void id_us_plus(struct ID *id)
Definition: lib_id.c:305
void BKE_id_blend_write(struct BlendWriter *writer, struct ID *id)
Definition: lib_id.c:2008
void * BKE_id_new(struct Main *bmain, short type, const char *name)
Definition: lib_id.c:1159
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(_data, _id_super, _cb_flag)
@ IDWALK_CB_USER
Definition: BKE_lib_query.h:73
const char * BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL()
const char * BKE_main_blendfile_path_from_global(void)
Definition: main.c:562
#define MOVIECLIP_CACHE_SKIP
#define MOVIECLIP_PREVIEW_GRAYSCALE
#define MOVIECLIP_DISABLE_BLUE
#define MOVIECLIP_DISABLE_RED
#define MOVIECLIP_DISABLE_GREEN
void BKE_ntree_update_tag_id_changed(struct Main *bmain, struct ID *id)
struct ImBuf * BKE_tracking_undistort_frame(struct MovieTracking *tracking, struct ImBuf *ibuf, int calibration_width, int calibration_height, float overscan)
Definition: tracking.c:2499
void BKE_tracking_settings_init(struct MovieTracking *tracking)
Definition: tracking.c:305
void BKE_tracking_disable_channels(struct ImBuf *ibuf, bool disable_red, bool disable_green, bool disable_blue, bool grayscale)
Definition: tracking.c:2891
struct ImBuf * BKE_tracking_stabilize_frame(struct MovieClip *clip, int framenr, struct ImBuf *ibuf, float translation[2], float *scale, float *angle)
void BKE_tracking_free(struct MovieTracking *tracking)
Definition: tracking.c:150
struct MovieTrackingTrack * BKE_tracking_track_get_active(struct MovieTracking *tracking)
Definition: tracking.c:1089
void BKE_tracking_dopesheet_tag_update(struct MovieTracking *tracking)
Definition: tracking.c:3411
void BKE_tracking_copy(struct MovieTracking *tracking_dst, const struct MovieTracking *tracking_src, int flag)
struct ImBuf * BKE_tracking_get_search_imbuf(struct ImBuf *ibuf, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker, bool anchored, bool disable_channels)
Definition: tracking.c:2760
void BKE_tracking_stabilization_data_get(struct MovieClip *clip, int framenr, int width, int height, float translation[2], float *scale, float *angle)
struct ListBase * BKE_tracking_object_get_tracks(struct MovieTracking *tracking, struct MovieTrackingObject *object)
Definition: tracking.c:2112
void BKE_tracking_marker_pattern_minmax(const struct MovieTrackingMarker *marker, float min[2], float max[2])
struct MovieTrackingMarker * BKE_tracking_marker_get(struct MovieTrackingTrack *track, int framenr)
Definition: tracking.c:1424
struct ImBuf * BKE_tracking_distortion_exec(struct MovieDistortion *distortion, struct MovieTracking *tracking, struct ImBuf *ibuf, int width, int height, float overscan, bool undistort)
Definition: tracking.c:2358
void BKE_tracking_undistort_v2(struct MovieTracking *tracking, int image_width, int image_height, const float co[2], float r_co[2])
Definition: tracking.c:2480
#define BLI_assert(a)
Definition: BLI_assert.h:46
int BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: storage.c:314
#define O_BINARY
Definition: BLI_fileops.h:319
int BLI_open(const char *filepath, int oflag, int pmode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: fileops.c:920
void * BLI_pophead(ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:221
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
Definition: BLI_listbase.h:273
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:466
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:80
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE bool equals_v4v4(const float a[4], const float b[4]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE bool equals_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void zero_v2(float r[2])
MINLINE bool equals_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
int BLI_path_sequence_decode(const char *string, char *head, char *tail, unsigned short *r_digits_len)
Definition: path_util.c:56
const char * BLI_path_basename(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:1653
bool BLI_path_frame(char *path, int frame, int digits) ATTR_NONNULL()
Definition: path_util.c:709
bool BLI_make_existing_file(const char *name)
Definition: path_util.c:1197
void BLI_split_dirfile(const char *string, char *dir, char *file, size_t dirlen, size_t filelen)
Definition: path_util.c:1465
#define FILE_MAX
void BLI_path_sequence_encode(char *string, const char *head, const char *tail, unsigned short numlen, int pic)
Definition: path_util.c:123
bool BLI_path_abs(char *path, const char *basepath) ATTR_NONNULL()
Definition: path_util.c:897
#define BLI_path_cmp
#define STR_ELEM(...)
Definition: BLI_string.h:539
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
void BLI_thread_unlock(int type)
Definition: threads.cc:361
@ LOCK_MOVIECLIP
Definition: BLI_threads.h:71
void BLI_thread_lock(int type)
Definition: threads.cc:356
#define UNUSED(x)
#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member)
#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member)
#define STREQ(a, b)
#define BLO_read_data_address(reader, ptr_p)
#define BLO_write_id_struct(writer, struct_name, id_address, id)
#define BLO_write_struct(writer, struct_name, data_ptr)
void BLO_read_list(BlendDataReader *reader, struct ListBase *list)
Definition: readfile.c:5172
#define BLO_read_id_address(reader, lib, id_ptr_p)
#define BLO_write_struct_array(writer, struct_name, array_size, data_ptr)
void BLO_read_pointer_array(BlendDataReader *reader, void **ptr_p)
Definition: readfile.c:5245
void BLO_write_pointer_array(BlendWriter *writer, uint num, const void *data_ptr)
Definition: writefile.c:1591
#define BLT_I18NCONTEXT_ID_MOVIECLIP
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
bool DEG_is_active(const struct Depsgraph *depsgraph)
Definition: depsgraph.cc:312
void DEG_debug_print_eval(struct Depsgraph *depsgraph, const char *function_name, const char *object_name, const void *object_address)
struct ID * DEG_get_original_id(struct ID *id)
#define FILTER_ID_MC
Definition: DNA_ID.h:912
@ ID_RECALC_SOURCE
Definition: DNA_ID.h:859
@ INDEX_ID_MC
Definition: DNA_ID.h:1008
#define ID_BLEND_PATH_FROM_GLOBAL(_id)
Definition: DNA_ID.h:561
#define ID_BLEND_PATH(_bmain, _id)
Definition: DNA_ID.h:559
@ ID_MC
Definition: DNA_ID_enums.h:73
#define DNA_struct_default_get(struct_name)
Definition: DNA_defaults.h:29
eGPUTextureTarget
@ TEXTARGET_2D
@ TEXTARGET_COUNT
@ MCLIP_PROXY_RENDER_USE_FALLBACK_RENDER
@ 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_SRC_SEQUENCE
@ MCLIP_SRC_MOVIE
struct MovieClip MovieClip
@ MCLIP_USE_PROXY_CUSTOM_DIR
@ MCLIP_USE_PROXY
Object is a sort of wrapper for general info.
#define RE_PASSNAME_COMBINED
#define IMG_SIZE_FALLBACK
@ TRACKING_2D_STABILIZATION
@ MARKER_DISABLED
@ TRACK_PREVIEW_ALPHA
@ TRACK_LOCKED
_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 GLsizei width
struct GPUTexture GPUTexture
Definition: GPU_texture.h:17
void GPU_texture_mipmap_mode(GPUTexture *tex, bool use_mipmap, bool use_filter)
Definition: gpu_texture.cc:527
void GPU_texture_free(GPUTexture *tex)
Definition: gpu_texture.cc:564
GPUTexture * GPU_texture_create_error(int dimension, bool array)
Definition: gpu_texture.cc:374
bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
Definition: scaling.c:1644
struct GPUTexture * IMB_create_gpu_texture(const char *name, struct ImBuf *ibuf, bool use_high_bitdepth, bool use_premult)
Definition: util_gpu.c:227
bool IMB_anim_get_fps(struct anim *anim, short *frs_sec, float *frs_sec_base, bool no_av_base)
Definition: anim_movie.c:1678
void IMB_free_anim(struct anim *anim)
Definition: anim_movie.c:193
struct ImBuf * IMB_dupImBuf(const struct ImBuf *ibuf1)
@ IMB_PROXY_100
Definition: IMB_imbuf.h:345
@ IMB_PROXY_75
Definition: IMB_imbuf.h:344
@ IMB_PROXY_50
Definition: IMB_imbuf.h:343
@ IMB_PROXY_25
Definition: IMB_imbuf.h:342
@ IMB_PROXY_NONE
Definition: IMB_imbuf.h:341
void IMB_anim_set_index_dir(struct anim *anim, const char *dir)
Definition: indexer.c:1527
void IMB_refImBuf(struct ImBuf *ibuf)
Definition: allocimbuf.c:220
struct ImBuf * IMB_testiffname(const char *filepath, int flags)
Definition: readimage.c:294
struct ImBuf * IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE])
Definition: readimage.c:209
void IMB_scaleImBuf_threaded(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
Definition: scaling.c:1863
struct ImBuf * IMB_anim_absolute(struct anim *anim, int position, IMB_Timecode_Type tc, IMB_Proxy_Size preview_size)
Definition: anim_movie.c:1571
bool IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags)
Definition: writeimage.c:22
int IMB_anim_get_duration(struct anim *anim, IMB_Timecode_Type tc)
Definition: anim_movie.c:1658
@ IMB_TC_NONE
Definition: IMB_imbuf.h:318
Contains defines and structs used throughout the imbuf module.
@ IB_rectfloat
@ IB_metadata
@ IB_multilayer
@ IB_alphamode_detect
@ IB_rect
bool IMB_moviecache_has_frame(struct MovieCache *cache, void *userkey)
Definition: moviecache.cc:432
struct MovieCache * IMB_moviecache_create(const char *name, int keysize, GHashHashFP hashfp, GHashCmpFP cmpfp)
Definition: moviecache.cc:265
struct ImBuf * IMB_moviecache_get(struct MovieCache *cache, void *userkey, bool *r_is_cached_empty)
Definition: moviecache.cc:401
void IMB_moviecache_set_getdata_callback(struct MovieCache *cache, MovieCacheGetKeyDataFP getdatafp)
Definition: moviecache.cc:292
void IMB_moviecache_cleanup(struct MovieCache *cache, bool(cleanup_check_cb)(struct ImBuf *ibuf, void *userkey, void *userdata), void *userdata)
void IMB_moviecache_put(struct MovieCache *cache, void *userkey, struct ImBuf *ibuf)
Definition: moviecache.cc:367
void IMB_moviecache_free(struct MovieCache *cache)
Definition: moviecache.cc:444
void IMB_moviecache_get_cache_segments(struct MovieCache *cache, int proxy, int render_flags, int *r_totseg, int **r_points)
Definition: moviecache.cc:489
bool IMB_moviecache_put_if_possible(struct MovieCache *cache, void *userkey, struct ImBuf *ibuf)
Definition: moviecache.cc:372
void IMB_moviecache_set_priority_callback(struct MovieCache *cache, MovieCacheGetPriorityDataFP getprioritydatafp, MovieCacheGetItemPriorityFP getitempriorityfp, MovieCachePriorityDeleterFP prioritydeleterfp)
Definition: moviecache.cc:297
void IMB_exr_close(void *handle)
void IMB_exr_multilayer_convert(void *handle, void *base, void *(*addview)(void *base, const char *str), void *(*addlayer)(void *base, const char *str), void(*addpass)(void *base, void *lay, const char *str, float *rect, int totchan, const char *chan_id, const char *view))
Read Guarded memory(de)allocation.
static void init_data(ModifierData *md)
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between camera
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition: btVector3.h:356
FILE * file
const Depsgraph * depsgraph
void * user_data
#define str(s)
void IMB_freeImBuf(ImBuf *UNUSED(ibuf))
@ IMB_FTYPE_JPG
@ IMB_FTYPE_OPENEXR
const ProjectiveReconstruction & reconstruction
Definition: intersect.cc:198
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
static void movie_clip_foreach_path(ID *id, BPathForeachPathData *bpath_data)
Definition: movieclip.c:149
static void movieclip_calc_length(MovieClip *clip)
Definition: movieclip.c:640
bool BKE_movieclip_has_cached_frame(MovieClip *clip, MovieClipUser *user)
Definition: movieclip.c:1942
static bool need_undistortion_postprocess(const MovieClipUser *user, int clip_flag)
Definition: movieclip.c:1081
static void direct_link_movieTracks(BlendDataReader *reader, ListBase *tracksbase)
Definition: movieclip.c:234
static void direct_link_movieReconstruction(BlendDataReader *reader, MovieTrackingReconstruction *reconstruction)
Definition: movieclip.c:228
static void movieclip_blend_read_lib(BlendLibReader *reader, ID *id)
Definition: movieclip.c:312
static void * moviecache_getprioritydata(void *key_v)
Definition: movieclip.c:783
MovieClip * BKE_movieclip_file_add_exists(Main *bmain, const char *filepath)
Definition: movieclip.c:1031
void BKE_movieclip_reload(Main *bmain, MovieClip *clip)
Definition: movieclip.c:1667
static bool moviecache_hashcmp(const void *av, const void *bv)
Definition: movieclip.c:774
static void movieclip_eval_update_reload(struct Depsgraph *depsgraph, Main *bmain, MovieClip *clip)
Definition: movieclip.c:1999
static void movie_clip_foreach_cache(ID *id, IDTypeForeachCacheFunctionCallback function_callback, void *user_data)
Definition: movieclip.c:134
float BKE_movieclip_get_fps(MovieClip *clip)
Definition: movieclip.c:1571
static bool put_imbuf_cache(MovieClip *clip, const MovieClipUser *user, ImBuf *ibuf, int flag, bool destructive)
Definition: movieclip.c:858
static void direct_link_moviePlaneTracks(BlendDataReader *reader, ListBase *plane_tracks_base)
Definition: movieclip.c:243
static GPUTexture ** movieclip_get_gputexture_ptr(MovieClip *clip, MovieClipUser *cuser, eGPUTextureTarget textarget)
Definition: movieclip.c:2038
static MovieClip * movieclip_alloc(Main *bmain, const char *name)
Definition: movieclip.c:923
struct MovieClipCachePriorityData MovieClipCachePriorityData
static ImBuf * movieclip_get_postprocessed_ibuf(MovieClip *clip, const MovieClipUser *user, int flag, int postprocess_flag, int cache_flag)
Definition: movieclip.c:1256
static void free_buffers(MovieClip *clip)
Definition: movieclip.c:1621
static bool check_undistortion_cache_flags(const MovieClip *clip)
Definition: movieclip.c:1100
void BKE_movieclip_clear_proxy_cache(MovieClip *clip)
Definition: movieclip.c:1660
void BKE_movieclip_build_proxy_frame_for_ibuf(MovieClip *clip, ImBuf *ibuf, struct MovieDistortion *distortion, int cfra, int *build_sizes, int build_count, bool undistorted)
Definition: movieclip.c:1864
ImBuf * BKE_movieclip_get_ibuf_flag(MovieClip *clip, MovieClipUser *user, int flag, int cache_flag)
Definition: movieclip.c:1334
ImBuf * BKE_movieclip_get_stable_ibuf(MovieClip *clip, MovieClipUser *user, float loc[2], float *scale, float *angle, int postprocess_flag)
Definition: movieclip.c:1447
void BKE_movieclip_clear_cache(MovieClip *clip)
Definition: movieclip.c:1655
static void moviecache_prioritydeleter(void *priority_data_v)
Definition: movieclip.c:802
void BKE_movieclip_filename_for_frame(MovieClip *clip, MovieClipUser *user, char *name)
Definition: movieclip.c:1909
static void movieclip_load_get_size(MovieClip *clip)
Definition: movieclip.c:932
static void write_movieReconstruction(BlendWriter *writer, MovieTrackingReconstruction *reconstruction)
Definition: movieclip.c:184
static ImBuf * postprocess_frame(MovieClip *clip, const MovieClipUser *user, ImBuf *ibuf, int flag, int postprocess_flag)
Definition: movieclip.c:1188
static int rendersize_to_proxy(const MovieClipUser *user, int flag)
Definition: movieclip.c:369
ImBuf * BKE_movieclip_get_ibuf(MovieClip *clip, MovieClipUser *user)
Definition: movieclip.c:1329
bool BKE_movieclip_proxy_enabled(MovieClip *clip)
Definition: movieclip.c:1894
static bool need_postprocessed_frame(const MovieClipUser *user, int clip_flag, int postprocess_flag)
Definition: movieclip.c:1091
static ImBuf * movieclip_load_sequence_file(MovieClip *clip, const MovieClipUser *user, int framenr, int flag)
Definition: movieclip.c:556
void BKE_movieclip_get_cache_segments(MovieClip *clip, MovieClipUser *user, int *r_totseg, int **r_points)
Definition: movieclip.c:1596
static ImBuf * movieclip_load_movie_file(MovieClip *clip, const MovieClipUser *user, int framenr, int flag)
Definition: movieclip.c:620
static void put_postprocessed_frame_to_cache(MovieClip *clip, const MovieClipUser *user, ImBuf *ibuf, int flag, int postprocess_flag)
Definition: movieclip.c:1214
static void moviecache_keydata(void *userkey, int *framenr, int *proxy, int *render_flags)
Definition: movieclip.c:757
static ImBuf * get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, ImBuf *reference_ibuf, int framenr, int postprocess_flag)
Definition: movieclip.c:1346
static unsigned int moviecache_hashhash(const void *keyv)
Definition: movieclip.c:766
static void get_proxy_fname(const MovieClip *clip, int proxy_render_size, bool undistorted, int framenr, char *name)
Definition: movieclip.c:451
void BKE_movieclip_eval_update(struct Depsgraph *depsgraph, Main *bmain, MovieClip *clip)
Definition: movieclip.c:2017
void BKE_movieclip_get_size(MovieClip *clip, MovieClipUser *user, int *width, int *height)
Definition: movieclip.c:1520
static void lib_link_movieTracks(BlendLibReader *reader, MovieClip *clip, ListBase *tracksbase)
Definition: movieclip.c:296
MovieClip * BKE_movieclip_file_add(Main *bmain, const char *name)
Definition: movieclip.c:967
void BKE_movieclip_eval_selection_update(struct Depsgraph *depsgraph, MovieClip *clip)
Definition: movieclip.c:2028
static void detect_clip_source(Main *bmain, MovieClip *clip)
Definition: movieclip.c:949
static ImBuf * get_imbuf_cache(MovieClip *clip, const MovieClipUser *user, int flag)
Definition: movieclip.c:809
static int get_timecode(MovieClip *clip, int flag)
Definition: movieclip.c:417
static void movie_clip_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, const int flag)
Definition: movieclip.c:85
float BKE_movieclip_remap_clip_to_scene_frame(const MovieClip *clip, float framenr)
Definition: movieclip.c:1904
static void write_moviePlaneTracks(BlendWriter *writer, ListBase *plane_tracks_base)
Definition: movieclip.c:171
ImBuf * BKE_movieclip_anim_ibuf_for_frame_no_lock(MovieClip *clip, MovieClipUser *user)
Definition: movieclip.c:1931
static void movieclip_build_proxy_ibuf(MovieClip *clip, ImBuf *ibuf, int cfra, int proxy_render_size, bool undistorted, bool threaded)
Definition: movieclip.c:1777
bool BKE_movieclip_put_frame_if_possible(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf)
Definition: movieclip.c:1953
struct MovieClipCache MovieClipCache
static void movieclip_open_anim_file(MovieClip *clip)
Definition: movieclip.c:598
int BKE_movieclip_get_duration(MovieClip *clip)
Definition: movieclip.c:1562
void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClipScopes *scopes)
Definition: movieclip.c:1683
GPUTexture * BKE_movieclip_get_gpu_texture(MovieClip *clip, MovieClipUser *cuser)
Definition: movieclip.c:2066
static ImBuf * put_stabilized_frame_to_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, int framenr, int postprocess_flag)
Definition: movieclip.c:1405
IDTypeInfo IDType_ID_MC
Definition: movieclip.c:328
void BKE_movieclip_build_proxy_frame(MovieClip *clip, int clip_flag, struct MovieDistortion *distortion, int cfra, int *build_sizes, int build_count, bool undistorted)
Definition: movieclip.c:1823
struct MovieClipImBufCacheKey MovieClipImBufCacheKey
static bool has_imbuf_cache(MovieClip *clip, MovieClipUser *user, int flag)
Definition: movieclip.c:836
static ImBuf * get_undistorted_ibuf(MovieClip *clip, struct MovieDistortion *distortion, ImBuf *ibuf)
Definition: movieclip.c:1062
MovieClip * BKE_movieclip_file_add_exists_ex(Main *bmain, const char *filepath, bool *r_exists)
Definition: movieclip.c:1003
bool BKE_movieclip_has_frame(MovieClip *clip, MovieClipUser *user)
Definition: movieclip.c:1508
static void movieclip_blend_read_data(BlendDataReader *reader, ID *id)
Definition: movieclip.c:257
static int sequence_guess_offset(const char *full_name, int head_len, unsigned short numlen)
Definition: movieclip.c:360
float BKE_movieclip_remap_scene_to_clip_frame(const MovieClip *clip, float framenr)
Definition: movieclip.c:1899
void BKE_movieclip_get_size_fl(MovieClip *clip, MovieClipUser *user, float size[2])
Definition: movieclip.c:1553
static int rendersize_to_number(int render_size)
Definition: movieclip.c:395
static int moviecache_getitempriority(void *last_userkey_v, void *priority_data_v)
Definition: movieclip.c:794
void BKE_movieclip_convert_multilayer_ibuf(struct ImBuf *ibuf)
Definition: movieclip.c:527
static void movieclip_blend_write(BlendWriter *writer, ID *id, const void *id_address)
Definition: movieclip.c:193
static void movie_clip_init_data(ID *id)
Definition: movieclip.c:74
static void get_sequence_fname(const MovieClip *clip, const int framenr, char *name)
Definition: movieclip.c:426
static void movieclip_selection_sync(MovieClip *clip_dst, const MovieClip *clip_src)
Definition: movieclip.c:1964
static bool moviecache_check_free_proxy(ImBuf *UNUSED(ibuf), void *userkey, void *UNUSED(userdata))
Definition: movieclip.c:913
void BKE_movieclip_user_set_frame(MovieClipUser *iuser, int framenr)
Definition: movieclip.c:1614
void BKE_movieclip_free_gputexture(struct MovieClip *clip)
Definition: movieclip.c:2098
static void movie_clip_foreach_id(ID *id, LibraryForeachIDData *data)
Definition: movieclip.c:113
void BKE_movieclip_get_aspect(MovieClip *clip, float *aspx, float *aspy)
Definition: movieclip.c:1588
static void movieclip_eval_update_generic(struct Depsgraph *depsgraph, MovieClip *clip)
Definition: movieclip.c:2008
static void real_ibuf_size(const MovieClip *clip, const MovieClipUser *user, const ImBuf *ibuf, int *width, int *height)
Definition: movieclip.c:1036
static void write_movieTracks(BlendWriter *writer, ListBase *tracks)
Definition: movieclip.c:155
static int user_frame_to_cache_frame(MovieClip *clip, int framenr)
Definition: movieclip.c:730
ImBuf * BKE_movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *user, int postprocess_flag)
Definition: movieclip.c:1339
static ImBuf * get_postprocessed_cached_frame(const MovieClip *clip, const MovieClipUser *user, int flag, int postprocess_flag)
Definition: movieclip.c:1140
static void lib_link_moviePlaneTracks(BlendLibReader *reader, MovieClip *clip, ListBase *tracksbase)
Definition: movieclip.c:303
static void movie_clip_free_data(ID *id)
Definition: movieclip.c:103
static unsigned a[3]
Definition: RandGen.cpp:78
T abs(const T &a)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
unsigned int id_session_uuid
Definition: BKE_idtype.h:46
size_t offset_in_ID
Definition: BKE_idtype.h:49
short id_code
Definition: BKE_idtype.h:114
Definition: DNA_ID.h:368
struct Library * lib
Definition: DNA_ID.h:372
int recalc
Definition: DNA_ID.h:390
struct ID * orig_id
Definition: DNA_ID.h:419
void * next
Definition: DNA_ID.h:369
char name[66]
Definition: DNA_ID.h:378
void * userdata
int channels
ImbFormatOptions foptions
unsigned char planes
char name[IMB_FILENAME_SIZE]
enum eImbFileType ftype
unsigned int * rect
float * rect_float
void * first
Definition: DNA_listBase.h:31
Definition: BKE_main.h:121
ListBase movieclips
Definition: BKE_main.h:199
char name[64]
Definition: moviecache.cc:47
float loc[2]
Definition: movieclip.c:710
ImBuf * ibuf
Definition: movieclip.c:683
short render_flag
Definition: movieclip.c:699
int postprocess_flag
Definition: movieclip.c:708
float principal[2]
Definition: movieclip.c:689
float nuke_k[2]
Definition: movieclip.c:692
short distortion_model
Definition: movieclip.c:695
float division_k[2]
Definition: movieclip.c:691
float brown_p[2]
Definition: movieclip.c:694
struct MovieClipCache::@97 postprocessed
int sequence_offset
Definition: movieclip.c:715
ImBuf * reference_ibuf
Definition: movieclip.c:704
bool undistortion_used
Definition: movieclip.c:696
struct MovieClipCache::@98 stabilized
float focal_length
Definition: movieclip.c:688
float brown_k[4]
Definition: movieclip.c:693
struct MovieCache * moviecache
Definition: movieclip.c:679
bool is_still_sequence
Definition: movieclip.c:717
float polynomial_k[3]
Definition: movieclip.c:690
struct ImBuf * track_preview
struct ImBuf * track_search
struct MovieTrackingMarker undist_marker
struct MovieTrackingMarker * marker
struct MovieTrackingTrack * track
struct ListBase gputextures
struct MovieClipCache * cache
char filepath[1024]
void * tracking_context
struct anim * anim
struct MovieClipProxy proxy
struct MovieClip_Runtime runtime
struct MovieTracking tracking
struct AnimData * adt
struct bGPdata * gpd
ColorManagedColorspaceSettings colorspace_settings
MovieTrackingReconstruction reconstruction
struct MovieTrackingObject * next
struct MovieTrackingPlaneTrack * next
MovieTrackingTrack ** point_tracks
MovieTrackingPlaneMarker * markers
MovieTrackingMarker * markers
struct MovieTrackingTrack * next
MovieTrackingReconstruction reconstruction
MovieTrackingPlaneTrack * act_plane_track
MovieTrackingDopesheet dopesheet
MovieTrackingStats * stats
MovieTrackingTrack * act_track
MovieTrackingStabilization stabilization
MovieTrackingCamera camera
struct MultilayerConvertContext MultilayerConvertContext
ListBase tracks
Definition: tracking.c:60