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