Blender  V3.3
clip_editor.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 <errno.h>
9 #include <fcntl.h>
10 #include <stddef.h>
11 #include <sys/types.h>
12 
13 #ifndef WIN32
14 # include <unistd.h>
15 #else
16 # include <io.h>
17 #endif
18 
19 #include "MEM_guardedalloc.h"
20 
21 #include "DNA_defaults.h"
22 #include "DNA_mask_types.h"
23 
24 #include "BLI_fileops.h"
25 #include "BLI_listbase.h"
26 #include "BLI_math.h"
27 #include "BLI_rect.h"
28 #include "BLI_task.h"
29 #include "BLI_utildefines.h"
30 
31 #include "BKE_context.h"
32 #include "BKE_global.h"
33 #include "BKE_lib_id.h"
34 #include "BKE_main.h"
35 #include "BKE_mask.h"
36 #include "BKE_movieclip.h"
37 #include "BKE_tracking.h"
38 
39 #include "IMB_colormanagement.h"
40 #include "IMB_imbuf.h"
41 #include "IMB_imbuf_types.h"
42 
43 #include "ED_clip.h"
44 #include "ED_mask.h"
45 #include "ED_screen.h"
46 #include "ED_select_utils.h"
47 
48 #include "WM_api.h"
49 #include "WM_types.h"
50 
51 #include "UI_view2d.h"
52 
53 #include "clip_intern.h" /* own include */
54 
55 #include "PIL_time.h"
56 
57 /* -------------------------------------------------------------------- */
62 {
64 
65  if (sc && sc->clip) {
66  return true;
67  }
68 
69  return false;
70 }
71 
73 {
75 
76  if (sc) {
77  return sc->view == SC_VIEW_CLIP;
78  }
79 
80  return false;
81 }
82 
84 {
86 
87  if (sc && sc->clip) {
89  }
90 
91  return false;
92 }
93 
95 {
97 
98  if (sc && sc->clip) {
100  }
101 
102  return false;
103 }
104 
106 {
108  return false;
109  }
110 
111  const SpaceClip *space_clip = CTX_wm_space_clip(C);
112  return space_clip->mask_info.draw_flag & MASK_DRAWFLAG_SPLINE;
113 }
114 
116 {
119 
120  if (clip) {
122 
123  return sc->mask_info.mask != NULL;
124  }
125  }
126 
127  return false;
128 }
129 
131 {
133  return false;
134  }
135 
136  const SpaceClip *space_clip = CTX_wm_space_clip(C);
137  return space_clip->mask_info.draw_flag & MASK_DRAWFLAG_SPLINE;
138 }
139 
142 /* -------------------------------------------------------------------- */
147 {
148  if (sc->clip) {
150  }
151  else {
153  }
154 }
155 
157 {
158  int size_i[2];
159  ED_space_clip_get_size(sc, &size_i[0], &size_i[1]);
160  size[0] = size_i[0];
161  size[1] = size_i[1];
162 }
163 
164 void ED_space_clip_get_zoom(SpaceClip *sc, ARegion *region, float *zoomx, float *zoomy)
165 {
166  int width, height;
167 
169 
170  *zoomx = (float)(BLI_rcti_size_x(&region->winrct) + 1) /
171  (BLI_rctf_size_x(&region->v2d.cur) * width);
172  *zoomy = (float)(BLI_rcti_size_y(&region->winrct) + 1) /
173  (BLI_rctf_size_y(&region->v2d.cur) * height);
174 }
175 
176 void ED_space_clip_get_aspect(SpaceClip *sc, float *aspx, float *aspy)
177 {
178  MovieClip *clip = ED_space_clip_get_clip(sc);
179 
180  if (clip) {
181  BKE_movieclip_get_aspect(clip, aspx, aspy);
182  }
183  else {
184  *aspx = *aspy = 1.0f;
185  }
186 
187  if (*aspx < *aspy) {
188  *aspy = *aspy / *aspx;
189  *aspx = 1.0f;
190  }
191  else {
192  *aspx = *aspx / *aspy;
193  *aspy = 1.0f;
194  }
195 }
196 
197 void ED_space_clip_get_aspect_dimension_aware(SpaceClip *sc, float *aspx, float *aspy)
198 {
199  int w, h;
200 
201  /* most of tools does not require aspect to be returned with dimensions correction
202  * due to they're invariant to this stuff, but some transformation tools like rotation
203  * should be aware of aspect correction caused by different resolution in different
204  * directions.
205  * mainly this is used for transformation stuff
206  */
207 
208  if (!sc->clip) {
209  *aspx = 1.0f;
210  *aspy = 1.0f;
211 
212  return;
213  }
214 
215  ED_space_clip_get_aspect(sc, aspx, aspy);
216  BKE_movieclip_get_size(sc->clip, &sc->user, &w, &h);
217 
218  *aspx *= (float)w;
219  *aspy *= (float)h;
220 
221  if (*aspx < *aspy) {
222  *aspy = *aspy / *aspx;
223  *aspx = 1.0f;
224  }
225  else {
226  *aspx = *aspx / *aspy;
227  *aspy = 1.0f;
228  }
229 }
230 
232 {
233  MovieClip *clip = ED_space_clip_get_clip(sc);
234 
235  /* Caller must ensure space does have a valid clip, otherwise it will crash, see T45017. */
237 }
238 
240 {
241  if (sc->clip) {
242  ImBuf *ibuf;
243 
245 
246  if (ibuf && (ibuf->rect || ibuf->rect_float)) {
247  return ibuf;
248  }
249 
250  if (ibuf) {
251  IMB_freeImBuf(ibuf);
252  }
253  }
254 
255  return NULL;
256 }
257 
258 ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale, float *angle)
259 {
260  if (sc->clip) {
261  ImBuf *ibuf;
262 
264  sc->clip, &sc->user, loc, scale, angle, sc->postproc_flag);
265 
266  if (ibuf && (ibuf->rect || ibuf->rect_float)) {
267  return ibuf;
268  }
269 
270  if (ibuf) {
271  IMB_freeImBuf(ibuf);
272  }
273  }
274 
275  return NULL;
276 }
277 
279  struct ARegion *region,
280  int mval[2],
281  float fpos[2])
282 {
283  ImBuf *ibuf = ED_space_clip_get_buffer(sc);
284  if (!ibuf) {
285  return false;
286  }
287 
288  /* map the mouse coords to the backdrop image space */
289  ED_clip_mouse_pos(sc, region, mval, fpos);
290 
291  IMB_freeImBuf(ibuf);
292  return true;
293 }
294 
295 bool ED_space_clip_color_sample(SpaceClip *sc, ARegion *region, const int mval[2], float r_col[3])
296 {
297  ImBuf *ibuf;
298  float fx, fy, co[2];
299  bool ret = false;
300 
301  ibuf = ED_space_clip_get_buffer(sc);
302  if (!ibuf) {
303  return false;
304  }
305 
306  /* map the mouse coords to the backdrop image space */
307  ED_clip_mouse_pos(sc, region, mval, co);
308 
309  fx = co[0];
310  fy = co[1];
311 
312  if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
313  const float *fp;
314  uchar *cp;
315  int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y);
316 
317  CLAMP(x, 0, ibuf->x - 1);
318  CLAMP(y, 0, ibuf->y - 1);
319 
320  if (ibuf->rect_float) {
321  fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
322  copy_v3_v3(r_col, fp);
323  ret = true;
324  }
325  else if (ibuf->rect) {
326  cp = (uchar *)(ibuf->rect + y * ibuf->x + x);
327  rgb_uchar_to_float(r_col, cp);
329  ret = true;
330  }
331  }
332 
333  IMB_freeImBuf(ibuf);
334 
335  return ret;
336 }
337 
338 void ED_clip_update_frame(const Main *mainp, int cfra)
339 {
340  /* image window, compo node users */
341  for (wmWindowManager *wm = mainp->wm.first; wm; wm = wm->id.next) { /* only 1 wm */
342  LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
343  bScreen *screen = WM_window_get_active_screen(win);
344 
345  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
346  if (area->spacetype == SPACE_CLIP) {
347  SpaceClip *sc = area->spacedata.first;
348 
349  sc->scopes.ok = false;
350 
352  }
353  }
354  }
355  }
356 }
357 
358 bool ED_clip_view_selection(const bContext *C, ARegion *UNUSED(region), bool fit)
359 {
360  float offset_x, offset_y;
361  float zoom;
362  if (!clip_view_calculate_view_selection(C, fit, &offset_x, &offset_y, &zoom)) {
363  return false;
364  }
365 
367  sc->xof = offset_x;
368  sc->yof = offset_y;
369  sc->zoom = zoom;
370 
371  return true;
372 }
373 
374 void ED_clip_select_all(SpaceClip *sc, int action, bool *r_has_selection)
375 {
376  MovieClip *clip = ED_space_clip_get_clip(sc);
377  const int framenr = ED_space_clip_get_clip_frame_number(sc);
378  MovieTracking *tracking = &clip->tracking;
379  MovieTrackingTrack *track = NULL; /* selected track */
380  MovieTrackingPlaneTrack *plane_track = NULL; /* selected plane track */
381  MovieTrackingMarker *marker;
382  ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
383  ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
384  bool has_selection = false;
385 
386  if (action == SEL_TOGGLE) {
387  action = SEL_SELECT;
388 
389  for (track = tracksbase->first; track; track = track->next) {
390  if (TRACK_VIEW_SELECTED(sc, track)) {
391  marker = BKE_tracking_marker_get(track, framenr);
392 
393  if (MARKER_VISIBLE(sc, track, marker)) {
394  action = SEL_DESELECT;
395  break;
396  }
397  }
398  }
399 
400  for (plane_track = plane_tracks_base->first; plane_track; plane_track = plane_track->next) {
401  if (PLANE_TRACK_VIEW_SELECTED(plane_track)) {
402  action = SEL_DESELECT;
403  break;
404  }
405  }
406  }
407 
408  for (track = tracksbase->first; track; track = track->next) {
409  if ((track->flag & TRACK_HIDDEN) == 0) {
410  marker = BKE_tracking_marker_get(track, framenr);
411 
412  if (MARKER_VISIBLE(sc, track, marker)) {
413  switch (action) {
414  case SEL_SELECT:
415  track->flag |= SELECT;
416  track->pat_flag |= SELECT;
417  track->search_flag |= SELECT;
418  break;
419  case SEL_DESELECT:
420  track->flag &= ~SELECT;
421  track->pat_flag &= ~SELECT;
422  track->search_flag &= ~SELECT;
423  break;
424  case SEL_INVERT:
425  track->flag ^= SELECT;
426  track->pat_flag ^= SELECT;
427  track->search_flag ^= SELECT;
428  break;
429  }
430  }
431  }
432 
433  if (TRACK_VIEW_SELECTED(sc, track)) {
434  has_selection = true;
435  }
436  }
437 
438  for (plane_track = plane_tracks_base->first; plane_track; plane_track = plane_track->next) {
439  if ((plane_track->flag & PLANE_TRACK_HIDDEN) == 0) {
440  switch (action) {
441  case SEL_SELECT:
442  plane_track->flag |= SELECT;
443  break;
444  case SEL_DESELECT:
445  plane_track->flag &= ~SELECT;
446  break;
447  case SEL_INVERT:
448  plane_track->flag ^= SELECT;
449  break;
450  }
451  if (plane_track->flag & SELECT) {
452  has_selection = true;
453  }
454  }
455  }
456 
457  if (r_has_selection) {
458  *r_has_selection = has_selection;
459  }
460 }
461 
462 void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[2])
463 {
464  copy_v2_v2(r_co, co);
465 
467  MovieClip *clip = ED_space_clip_get_clip(sc);
468  float aspy = 1.0f / clip->tracking.camera.pixel_aspect;
469  int width, height;
470 
472 
473  r_co[0] *= width;
474  r_co[1] *= height * aspy;
475 
476  BKE_tracking_undistort_v2(&clip->tracking, width, height, r_co, r_co);
477 
478  r_co[0] /= width;
479  r_co[1] /= height * aspy;
480  }
481 }
482 
484  SpaceClip *sc, ARegion *region, float x, float y, float *xr, float *yr)
485 {
486  int sx, sy, width, height;
487  float zoomx, zoomy, pos[3], imat[4][4];
488 
489  ED_space_clip_get_zoom(sc, region, &zoomx, &zoomy);
491 
492  UI_view2d_view_to_region(&region->v2d, 0.0f, 0.0f, &sx, &sy);
493 
494  pos[0] = (x - sx) / zoomx;
495  pos[1] = (y - sy) / zoomy;
496  pos[2] = 0.0f;
497 
498  invert_m4_m4(imat, sc->stabmat);
499  mul_v3_m4v3(pos, imat, pos);
500 
501  *xr = pos[0] / width;
502  *yr = pos[1] / height;
503 
505  MovieClip *clip = ED_space_clip_get_clip(sc);
506  MovieTracking *tracking = &clip->tracking;
507  float aspy = 1.0f / tracking->camera.pixel_aspect;
508  float tmp[2] = {*xr * width, *yr * height * aspy};
509 
510  BKE_tracking_distort_v2(tracking, width, height, tmp, tmp);
511 
512  *xr = tmp[0] / width;
513  *yr = tmp[1] / (height * aspy);
514  }
515 }
516 
518  ARegion *region,
519  const float co[2],
520  float r_co[2])
521 {
522  float zoomx, zoomy;
523  float pos[3];
524  int width, height;
525  int sx, sy;
526 
527  UI_view2d_view_to_region(&region->v2d, 0.0f, 0.0f, &sx, &sy);
529  ED_space_clip_get_zoom(sc, region, &zoomx, &zoomy);
530 
532  pos[2] = 0.0f;
533 
534  /* untested */
535  mul_v3_m4v3(pos, sc->stabmat, pos);
536 
537  r_co[0] = (pos[0] * width * zoomx) + (float)sx;
538  r_co[1] = (pos[1] * height * zoomy) + (float)sy;
539 }
540 
541 void ED_clip_mouse_pos(SpaceClip *sc, ARegion *region, const int mval[2], float co[2])
542 {
543  ED_clip_point_stable_pos(sc, region, mval[0], mval[1], &co[0], &co[1]);
544 }
545 
547 {
548  if (sc) {
549  return sc->mode == SC_MODE_TRACKING;
550  }
551 
552  return false;
553 }
554 
556 {
557  if (sc) {
558  return sc->mode == SC_MODE_MASKEDIT;
559  }
560 
561  return false;
562 }
563 
566 /* -------------------------------------------------------------------- */
571 {
572  return sc->clip;
573 }
574 
576 {
577  MovieClip *old_clip;
578  bool old_clip_visible = false;
579 
580  if (!screen && C) {
581  screen = CTX_wm_screen(C);
582  }
583 
584  old_clip = sc->clip;
585  sc->clip = clip;
586 
587  id_us_ensure_real((ID *)sc->clip);
588 
589  if (screen && sc->view == SC_VIEW_CLIP) {
590  ScrArea *area;
591  SpaceLink *sl;
592 
593  for (area = screen->areabase.first; area; area = area->next) {
594  for (sl = area->spacedata.first; sl; sl = sl->next) {
595  if (sl->spacetype == SPACE_CLIP) {
596  SpaceClip *cur_sc = (SpaceClip *)sl;
597 
598  if (cur_sc != sc) {
599  if (cur_sc->view == SC_VIEW_CLIP) {
600  if (cur_sc->clip == old_clip) {
601  old_clip_visible = true;
602  }
603  }
604  else {
605  if (ELEM(cur_sc->clip, old_clip, NULL)) {
606  cur_sc->clip = clip;
607  }
608  }
609  }
610  }
611  }
612  }
613  }
614 
615  /* If clip is no longer visible on screen, free memory used by its cache */
616  if (old_clip && old_clip != clip && !old_clip_visible) {
617  BKE_movieclip_clear_cache(old_clip);
618  }
619 
620  if (C) {
622  }
623 }
624 
627 /* -------------------------------------------------------------------- */
632 {
633  return sc->mask_info.mask;
634 }
635 
637 {
638  sc->mask_info.mask = mask;
639 
641 
642  if (C) {
644  }
645 }
646 
649 /* -------------------------------------------------------------------- */
653 typedef struct PrefetchJob {
656 
657  /* Local copy of the clip which is used to decouple reading in a way which does not require
658  * threading lock which might "conflict" with the main thread,
659  *
660  * Used, for example, for animation prefetching (`clip->anim` can not be used from multiple
661  * threads and main thread might need it). */
663 
667 
668 typedef struct PrefetchQueue {
671 
672  /* If true pre-fetching goes forward in time,
673  * otherwise it goes backwards in time (starting from current frame).
674  */
675  bool forward;
676 
678 
679  short *stop;
680  short *do_update;
681  float *progress;
683 
684 /* check whether pre-fetching is allowed */
685 static bool check_prefetch_break(void)
686 {
687  return G.is_break;
688 }
689 
690 /* read file for specified frame number to the memory */
692  MovieClip *clip, int current_frame, short render_size, short render_flag, size_t *r_size)
693 {
695  user.framenr = current_frame;
696  user.render_size = render_size;
697  user.render_flag = render_flag;
698 
699  char name[FILE_MAX];
700  BKE_movieclip_filename_for_frame(clip, &user, name);
701 
702  int file = BLI_open(name, O_BINARY | O_RDONLY, 0);
703  if (file == -1) {
704  return NULL;
705  }
706 
707  const size_t size = BLI_file_descriptor_size(file);
708  if (size < 1) {
709  close(file);
710  return NULL;
711  }
712 
713  uchar *mem = MEM_mallocN(size, "movieclip prefetch memory file");
714  if (mem == NULL) {
715  close(file);
716  return NULL;
717  }
718 
719  if (read(file, mem, size) != size) {
720  close(file);
721  MEM_freeN(mem);
722  return NULL;
723  }
724 
725  *r_size = size;
726 
727  close(file);
728 
729  return mem;
730 }
731 
732 /* find first uncached frame within prefetching frame range */
734  int from_frame,
735  int end_frame,
736  short render_size,
737  short render_flag,
738  short direction)
739 {
740  int current_frame;
742 
743  user.render_size = render_size;
744  user.render_flag = render_flag;
745 
746  if (direction > 0) {
747  for (current_frame = from_frame; current_frame <= end_frame; current_frame++) {
748  user.framenr = current_frame;
749 
750  if (!BKE_movieclip_has_cached_frame(clip, &user)) {
751  break;
752  }
753  }
754  }
755  else {
756  for (current_frame = from_frame; current_frame >= end_frame; current_frame--) {
757  user.framenr = current_frame;
758 
759  if (!BKE_movieclip_has_cached_frame(clip, &user)) {
760  break;
761  }
762  }
763  }
764 
765  return current_frame;
766 }
767 
768 /* get memory buffer for first uncached frame within prefetch frame range */
770  MovieClip *clip,
771  size_t *r_size,
772  int *r_current_frame)
773 {
774  uchar *mem = NULL;
775 
776  BLI_spin_lock(&queue->spin);
777  if (!*queue->stop && !check_prefetch_break() &&
778  IN_RANGE_INCL(queue->current_frame, queue->start_frame, queue->end_frame)) {
779  int current_frame;
780 
781  if (queue->forward) {
782  current_frame = prefetch_find_uncached_frame(clip,
783  queue->current_frame + 1,
784  queue->end_frame,
785  queue->render_size,
786  queue->render_flag,
787  1);
788  /* switch direction if read frames from current up to scene end frames */
789  if (current_frame > queue->end_frame) {
790  queue->current_frame = queue->initial_frame;
791  queue->forward = false;
792  }
793  }
794 
795  if (!queue->forward) {
796  current_frame = prefetch_find_uncached_frame(clip,
797  queue->current_frame - 1,
798  queue->start_frame,
799  queue->render_size,
800  queue->render_flag,
801  -1);
802  }
803 
804  if (IN_RANGE_INCL(current_frame, queue->start_frame, queue->end_frame)) {
805  int frames_processed;
806 
808  clip, current_frame, queue->render_size, queue->render_flag, r_size);
809 
810  *r_current_frame = current_frame;
811 
812  queue->current_frame = current_frame;
813 
814  if (queue->forward) {
815  frames_processed = queue->current_frame - queue->initial_frame;
816  }
817  else {
818  frames_processed = (queue->end_frame - queue->initial_frame) +
819  (queue->initial_frame - queue->current_frame);
820  }
821 
822  *queue->do_update = 1;
823  *queue->progress = (float)frames_processed / (queue->end_frame - queue->start_frame);
824  }
825  }
826  BLI_spin_unlock(&queue->spin);
827 
828  return mem;
829 }
830 
831 static void prefetch_task_func(TaskPool *__restrict pool, void *task_data)
832 {
834  MovieClip *clip = (MovieClip *)task_data;
835  uchar *mem;
836  size_t size;
837  int current_frame;
838 
839  while ((mem = prefetch_thread_next_frame(queue, clip, &size, &current_frame))) {
840  ImBuf *ibuf;
843  int result;
844  char *colorspace_name = NULL;
845  const bool use_proxy = (clip->flag & MCLIP_USE_PROXY) &&
846  (queue->render_size != MCLIP_PROXY_RENDER_SIZE_FULL);
847 
848  user.framenr = current_frame;
849  user.render_size = queue->render_size;
850  user.render_flag = queue->render_flag;
851 
852  /* Proxies are stored in the display space. */
853  if (!use_proxy) {
854  colorspace_name = clip->colorspace_settings.name;
855  }
856 
857  ibuf = IMB_ibImageFromMemory(mem, size, flag, colorspace_name, "prefetch frame");
858  if (ibuf == NULL) {
859  continue;
860  }
862 
863  result = BKE_movieclip_put_frame_if_possible(clip, &user, ibuf);
864 
865  IMB_freeImBuf(ibuf);
866 
867  MEM_freeN(mem);
868 
869  if (!result) {
870  /* no more space in the cache, stop reading frames */
871  *queue->stop = 1;
872  break;
873  }
874  }
875 }
876 
878  int start_frame,
879  int current_frame,
880  int end_frame,
881  short render_size,
882  short render_flag,
883  short *stop,
884  short *do_update,
885  float *progress)
886 {
887  int tot_thread = BLI_task_scheduler_num_threads();
888 
889  /* initialize queue */
891  BLI_spin_init(&queue.spin);
892 
893  queue.current_frame = current_frame;
894  queue.initial_frame = current_frame;
895  queue.start_frame = start_frame;
896  queue.end_frame = end_frame;
897  queue.render_size = render_size;
898  queue.render_flag = render_flag;
899  queue.forward = 1;
900 
901  queue.stop = stop;
902  queue.do_update = do_update;
903  queue.progress = progress;
904 
906  for (int i = 0; i < tot_thread; i++) {
908  }
911 
912  BLI_spin_end(&queue.spin);
913 }
914 
915 /* NOTE: Reading happens from `clip_local` into `clip->cache`. */
916 static bool prefetch_movie_frame(MovieClip *clip,
917  MovieClip *clip_local,
918  int frame,
919  short render_size,
920  short render_flag,
921  short *stop)
922 {
924 
925  if (check_prefetch_break() || *stop) {
926  return false;
927  }
928 
929  user.framenr = frame;
930  user.render_size = render_size;
931  user.render_flag = render_flag;
932 
933  if (!BKE_movieclip_has_cached_frame(clip, &user)) {
934  ImBuf *ibuf = BKE_movieclip_anim_ibuf_for_frame_no_lock(clip_local, &user);
935 
936  if (ibuf) {
937  int result;
938 
939  result = BKE_movieclip_put_frame_if_possible(clip, &user, ibuf);
940 
941  if (!result) {
942  /* no more space in the cache, we could stop prefetching here */
943  *stop = 1;
944  }
945 
946  IMB_freeImBuf(ibuf);
947  }
948  else {
949  /* error reading frame, fair enough stop attempting further reading */
950  *stop = 1;
951  }
952  }
953 
954  return true;
955 }
956 
957 static void do_prefetch_movie(MovieClip *clip,
958  MovieClip *clip_local,
959  int start_frame,
960  int current_frame,
961  int end_frame,
962  short render_size,
963  short render_flag,
964  short *stop,
965  short *do_update,
966  float *progress)
967 {
968  int frame;
969  int frames_processed = 0;
970 
971  /* read frames starting from current frame up to scene end frame */
972  for (frame = current_frame; frame <= end_frame; frame++) {
973  if (!prefetch_movie_frame(clip, clip_local, frame, render_size, render_flag, stop)) {
974  return;
975  }
976 
977  frames_processed++;
978 
979  *do_update = 1;
980  *progress = (float)frames_processed / (end_frame - start_frame);
981  }
982 
983  /* read frames starting from current frame up to scene start frame */
984  for (frame = current_frame; frame >= start_frame; frame--) {
985  if (!prefetch_movie_frame(clip, clip_local, frame, render_size, render_flag, stop)) {
986  return;
987  }
988 
989  frames_processed++;
990 
991  *do_update = 1;
992  *progress = (float)frames_processed / (end_frame - start_frame);
993  }
994 }
995 
996 static void prefetch_startjob(void *pjv, short *stop, short *do_update, float *progress)
997 {
998  PrefetchJob *pj = pjv;
999 
1000  if (pj->clip->source == MCLIP_SRC_SEQUENCE) {
1001  /* read sequence files in multiple threads */
1003  pj->start_frame,
1004  pj->current_frame,
1005  pj->end_frame,
1006  pj->render_size,
1007  pj->render_flag,
1008  stop,
1009  do_update,
1010  progress);
1011  }
1012  else if (pj->clip->source == MCLIP_SRC_MOVIE) {
1013  /* read movie in a single thread */
1014  do_prefetch_movie(pj->clip,
1015  pj->clip_local,
1016  pj->start_frame,
1017  pj->current_frame,
1018  pj->end_frame,
1019  pj->render_size,
1020  pj->render_flag,
1021  stop,
1022  do_update,
1023  progress);
1024  }
1025  else {
1026  BLI_assert_msg(0, "Unknown movie clip source when prefetching frames");
1027  }
1028 }
1029 
1030 static void prefetch_freejob(void *pjv)
1031 {
1032  PrefetchJob *pj = pjv;
1033 
1034  MovieClip *clip_local = pj->clip_local;
1035  if (clip_local != NULL) {
1036  BKE_libblock_free_datablock(&clip_local->id, 0);
1037  BKE_libblock_free_data(&clip_local->id, false);
1038  BLI_assert(!clip_local->id.py_instance); /* Or call #BKE_libblock_free_data_py. */
1039  MEM_freeN(clip_local);
1040  }
1041 
1042  MEM_freeN(pj);
1043 }
1044 
1046 {
1048 
1049  return scene->r.sfra;
1050 }
1051 
1053 {
1055  SpaceClip *sc = CTX_wm_space_clip(C);
1056  MovieClip *clip = ED_space_clip_get_clip(sc);
1057  int end_frame;
1058 
1059  /* check whether all the frames from prefetch range are cached */
1060  end_frame = scene->r.efra;
1061 
1062  if (clip->len) {
1063  end_frame = min_ii(end_frame, scene->r.sfra + clip->len - 1);
1064  }
1065 
1066  return end_frame;
1067 }
1068 
1069 /* returns true if early out is possible */
1071 {
1072  SpaceClip *sc = CTX_wm_space_clip(C);
1073  MovieClip *clip = ED_space_clip_get_clip(sc);
1074  int first_uncached_frame, end_frame;
1075  int clip_len;
1076 
1077  if (clip == NULL) {
1078  return true;
1079  }
1080 
1081  clip_len = BKE_movieclip_get_duration(clip);
1082 
1083  /* check whether all the frames from prefetch range are cached */
1084  end_frame = prefetch_get_final_frame(C);
1085 
1086  first_uncached_frame = prefetch_find_uncached_frame(
1087  clip, sc->user.framenr, end_frame, sc->user.render_size, sc->user.render_flag, 1);
1088 
1089  if (first_uncached_frame > end_frame || first_uncached_frame == clip_len) {
1090  int start_frame = prefetch_get_start_frame(C);
1091 
1092  first_uncached_frame = prefetch_find_uncached_frame(
1093  clip, sc->user.framenr, start_frame, sc->user.render_size, sc->user.render_flag, -1);
1094 
1095  if (first_uncached_frame < start_frame) {
1096  return true;
1097  }
1098  }
1099 
1100  return false;
1101 }
1102 
1104 {
1105  wmJob *wm_job;
1106  PrefetchJob *pj;
1107  SpaceClip *sc = CTX_wm_space_clip(C);
1108 
1109  if (prefetch_check_early_out(C)) {
1110  return;
1111  }
1112 
1113  wm_job = WM_jobs_get(CTX_wm_manager(C),
1114  CTX_wm_window(C),
1115  CTX_data_scene(C),
1116  "Prefetching",
1119 
1120  /* create new job */
1121  pj = MEM_callocN(sizeof(PrefetchJob), "prefetch job");
1122  pj->clip = ED_space_clip_get_clip(sc);
1124  pj->current_frame = sc->user.framenr;
1126  pj->render_size = sc->user.render_size;
1127  pj->render_flag = sc->user.render_flag;
1128 
1129  /* Create a local copy of the clip, so that video file (clip->anim) access can happen without
1130  * acquiring the lock which will interfere with the main thread. */
1131  if (pj->clip->source == MCLIP_SRC_MOVIE) {
1133  }
1134 
1136  WM_jobs_timer(wm_job, 0.2, NC_MOVIECLIP | ND_DISPLAY, 0);
1138 
1139  G.is_break = false;
1140 
1141  /* and finally start the job */
1142  WM_jobs_start(CTX_wm_manager(C), wm_job);
1143 }
1144 
1146 {
1147  SpaceClip *space_clip = CTX_wm_space_clip(C);
1148  BLI_assert(space_clip != NULL);
1149 
1150  state->offset_x = space_clip->xof;
1151  state->offset_y = space_clip->yof;
1152  state->zoom = space_clip->zoom;
1153 
1154  state->lock_offset_x = 0.0f;
1155  state->lock_offset_y = 0.0f;
1156 
1157  if ((space_clip->flag & SC_LOCK_SELECTION) == 0) {
1158  return;
1159  }
1160 
1162  C, false, &state->offset_x, &state->offset_y, &state->zoom)) {
1163  return;
1164  }
1165 
1166  state->lock_offset_x = space_clip->xlockof;
1167  state->lock_offset_y = space_clip->ylockof;
1168 }
1169 
1171 {
1172  SpaceClip *space_clip = CTX_wm_space_clip(C);
1173  BLI_assert(space_clip != NULL);
1174 
1175  if ((space_clip->flag & SC_LOCK_SELECTION) == 0) {
1176  return;
1177  }
1178 
1179  float offset_x, offset_y;
1180  float zoom;
1181  if (!clip_view_calculate_view_selection(C, false, &offset_x, &offset_y, &zoom)) {
1182  return;
1183  }
1184 
1185  space_clip->xlockof = state->offset_x + state->lock_offset_x - offset_x;
1186  space_clip->ylockof = state->offset_y + state->lock_offset_y - offset_y;
1187 }
1188 
typedef float(TangentPoint)[2]
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
struct SpaceClip * CTX_wm_space_clip(const bContext *C)
Definition: context.c:923
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:713
struct MovieClip * CTX_data_edit_movieclip(const bContext *C)
Definition: context.c:1385
struct bScreen * CTX_wm_screen(const bContext *C)
Definition: context.c:733
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:723
@ LIB_ID_COPY_LOCALIZE
Definition: BKE_lib_id.h:187
void BKE_libblock_free_data(struct ID *id, bool do_id_user) ATTR_NONNULL()
Definition: lib_id_delete.c:44
struct ID * BKE_id_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, int flag)
void id_us_ensure_real(struct ID *id)
Definition: lib_id.c:260
void BKE_libblock_free_datablock(struct ID *id, int flag) ATTR_NONNULL()
bool BKE_movieclip_put_frame_if_possible(struct MovieClip *clip, struct MovieClipUser *user, struct ImBuf *ibuf)
Definition: movieclip.c:1953
void BKE_movieclip_get_aspect(struct MovieClip *clip, float *aspx, float *aspy)
Definition: movieclip.c:1588
float BKE_movieclip_remap_scene_to_clip_frame(const struct MovieClip *clip, float framenr)
void BKE_movieclip_user_set_frame(struct MovieClipUser *user, int framenr)
Definition: movieclip.c:1614
int BKE_movieclip_get_duration(struct MovieClip *clip)
Definition: movieclip.c:1562
void BKE_movieclip_clear_cache(struct MovieClip *clip)
Definition: movieclip.c:1655
void BKE_movieclip_get_size(struct MovieClip *clip, struct MovieClipUser *user, int *width, int *height)
Definition: movieclip.c:1520
void BKE_movieclip_filename_for_frame(struct MovieClip *clip, struct MovieClipUser *user, char *name)
Definition: movieclip.c:1909
struct ImBuf * BKE_movieclip_anim_ibuf_for_frame_no_lock(struct MovieClip *clip, struct MovieClipUser *user)
Definition: movieclip.c:1931
struct ImBuf * BKE_movieclip_get_stable_ibuf(struct MovieClip *clip, struct MovieClipUser *user, float loc[2], float *scale, float *angle, int postprocess_flag)
Definition: movieclip.c:1447
void BKE_movieclip_convert_multilayer_ibuf(struct ImBuf *ibuf)
Definition: movieclip.c:527
struct ImBuf * BKE_movieclip_get_postprocessed_ibuf(struct MovieClip *clip, struct MovieClipUser *user, int postprocess_flag)
Definition: movieclip.c:1339
bool BKE_movieclip_has_cached_frame(struct MovieClip *clip, struct MovieClipUser *user)
Definition: movieclip.c:1942
struct ListBase * BKE_tracking_get_active_tracks(struct MovieTracking *tracking)
Definition: tracking.c:346
#define PLANE_TRACK_VIEW_SELECTED(plane_track)
Definition: BKE_tracking.h:837
#define MARKER_VISIBLE(sc, track, marker)
Definition: BKE_tracking.h:840
struct ListBase * BKE_tracking_get_active_plane_tracks(struct MovieTracking *tracking)
Definition: tracking.c:357
void BKE_tracking_distort_v2(struct MovieTracking *tracking, int image_width, int image_height, const float co[2], float r_co[2])
Definition: tracking.c:2457
#define TRACK_VIEW_SELECTED(sc, track)
Definition: BKE_tracking.h:831
struct MovieTrackingMarker * BKE_tracking_marker_get(struct MovieTrackingTrack *track, int framenr)
Definition: tracking.c:1424
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
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
File and directory operations.
#define O_BINARY
Definition: BLI_fileops.h:319
size_t BLI_file_descriptor_size(int file) ATTR_WARN_UNUSED_RESULT
Definition: storage.c:178
int BLI_open(const char *filepath, int oflag, int pmode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: fileops.c:920
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
MINLINE int min_ii(int a, int b)
void rgb_uchar_to_float(float r_col[3], const unsigned char col_ub[3])
Definition: math_color.c:376
bool invert_m4_m4(float R[4][4], const float A[4][4])
Definition: math_matrix.c:1287
void mul_v3_m4v3(float r[3], const float M[4][4], const float v[3])
Definition: math_matrix.c:739
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
#define FILE_MAX
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition: BLI_rect.h:190
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition: BLI_rect.h:186
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition: BLI_rect.h:194
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition: BLI_rect.h:198
unsigned char uchar
Definition: BLI_sys_types.h:70
int BLI_task_scheduler_num_threads(void)
@ TASK_PRIORITY_LOW
Definition: BLI_task.h:56
void * BLI_task_pool_user_data(TaskPool *pool)
Definition: task_pool.cc:525
void BLI_task_pool_work_and_wait(TaskPool *pool)
Definition: task_pool.cc:480
TaskPool * BLI_task_pool_create(void *userdata, eTaskPriority priority)
Definition: task_pool.cc:390
void BLI_task_pool_free(TaskPool *pool)
Definition: task_pool.cc:440
void BLI_task_pool_push(TaskPool *pool, TaskRunFunction run, void *taskdata, bool free_taskdata, TaskFreeFunction freedata)
Definition: task_pool.cc:459
pthread_spinlock_t SpinLock
Definition: BLI_threads.h:110
void BLI_spin_init(SpinLock *spin)
Definition: threads.cc:419
void BLI_spin_unlock(SpinLock *spin)
Definition: threads.cc:452
void BLI_spin_lock(SpinLock *spin)
Definition: threads.cc:433
void BLI_spin_end(SpinLock *spin)
Definition: threads.cc:467
#define UNUSED(x)
#define ELEM(...)
#define IN_RANGE_INCL(a, b, c)
#define DNA_struct_default_get(struct_name)
Definition: DNA_defaults.h:29
#define MASK_DRAWFLAG_SPLINE
@ MCLIP_PROXY_RENDER_UNDISTORT
@ MCLIP_PROXY_RENDER_SIZE_FULL
@ MCLIP_SRC_SEQUENCE
@ MCLIP_SRC_MOVIE
@ MCLIP_USE_PROXY
@ SPACE_CLIP
@ SC_VIEW_CLIP
@ SC_MODE_TRACKING
@ SC_MODE_MASKEDIT
@ SC_LOCK_SELECTION
#define IMG_SIZE_FALLBACK
@ PLANE_TRACK_HIDDEN
@ TRACK_HIDDEN
@ SEL_SELECT
@ SEL_INVERT
@ SEL_DESELECT
@ SEL_TOGGLE
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], struct ColorSpace *colorspace)
struct ImBuf * IMB_ibImageFromMemory(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE], const char *descr)
Definition: readimage.c:84
Contains defines and structs used throughout the imbuf module.
@ IB_metadata
@ IB_multilayer
@ IB_alphamode_detect
@ IB_rect
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position CLAMP
Platform independent time functions.
#define C
Definition: RandGen.cpp:25
void UI_view2d_view_to_region(const struct View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL()
@ WM_JOB_PROGRESS
Definition: WM_api.h:1339
@ WM_JOB_TYPE_CLIP_PREFETCH
Definition: WM_api.h:1361
#define ND_DISPLAY
Definition: WM_types.h:439
#define NC_MOVIECLIP
Definition: WM_types.h:347
#define NC_MASK
Definition: WM_types.h:348
#define NA_SELECTED
Definition: WM_types.h:528
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition: btVector3.h:356
static bool prefetch_movie_frame(MovieClip *clip, MovieClip *clip_local, int frame, short render_size, short render_flag, short *stop)
Definition: clip_editor.c:916
void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieClip *clip)
Definition: clip_editor.c:575
void ED_clip_view_lock_state_restore_no_jump(const bContext *C, const ClipViewLockState *state)
Definition: clip_editor.c:1170
ImBuf * ED_space_clip_get_buffer(SpaceClip *sc)
Definition: clip_editor.c:239
void ED_space_clip_get_size(SpaceClip *sc, int *width, int *height)
Definition: clip_editor.c:146
struct PrefetchQueue PrefetchQueue
bool ED_space_clip_get_position(struct SpaceClip *sc, struct ARegion *region, int mval[2], float fpos[2])
Definition: clip_editor.c:278
void ED_space_clip_set_mask(bContext *C, SpaceClip *sc, Mask *mask)
Definition: clip_editor.c:636
void ED_space_clip_get_aspect(SpaceClip *sc, float *aspx, float *aspy)
Definition: clip_editor.c:176
bool ED_space_clip_maskedit_visible_splines_poll(bContext *C)
Definition: clip_editor.c:105
static int prefetch_get_start_frame(const bContext *C)
Definition: clip_editor.c:1045
static bool prefetch_check_early_out(const bContext *C)
Definition: clip_editor.c:1070
void ED_clip_select_all(SpaceClip *sc, int action, bool *r_has_selection)
Definition: clip_editor.c:374
static void prefetch_startjob(void *pjv, short *stop, short *do_update, float *progress)
Definition: clip_editor.c:996
void ED_clip_update_frame(const Main *mainp, int cfra)
Definition: clip_editor.c:338
int ED_space_clip_get_clip_frame_number(SpaceClip *sc)
Definition: clip_editor.c:231
bool ED_space_clip_maskedit_poll(bContext *C)
Definition: clip_editor.c:94
void ED_clip_point_stable_pos(SpaceClip *sc, ARegion *region, float x, float y, float *xr, float *yr)
Definition: clip_editor.c:483
bool ED_space_clip_view_clip_poll(bContext *C)
Definition: clip_editor.c:72
static void prefetch_task_func(TaskPool *__restrict pool, void *task_data)
Definition: clip_editor.c:831
bool ED_space_clip_color_sample(SpaceClip *sc, ARegion *region, const int mval[2], float r_col[3])
Definition: clip_editor.c:295
static int prefetch_get_final_frame(const bContext *C)
Definition: clip_editor.c:1052
static void start_prefetch_threads(MovieClip *clip, int start_frame, int current_frame, int end_frame, short render_size, short render_flag, short *stop, short *do_update, float *progress)
Definition: clip_editor.c:877
void ED_space_clip_get_zoom(SpaceClip *sc, ARegion *region, float *zoomx, float *zoomy)
Definition: clip_editor.c:164
static uchar * prefetch_read_file_to_memory(MovieClip *clip, int current_frame, short render_size, short render_flag, size_t *r_size)
Definition: clip_editor.c:691
bool ED_space_clip_maskedit_mask_poll(bContext *C)
Definition: clip_editor.c:115
void ED_clip_point_stable_pos__reverse(SpaceClip *sc, ARegion *region, const float co[2], float r_co[2])
the reverse of ED_clip_point_stable_pos(), gets the marker region coords. better name here?...
Definition: clip_editor.c:517
static uchar * prefetch_thread_next_frame(PrefetchQueue *queue, MovieClip *clip, size_t *r_size, int *r_current_frame)
Definition: clip_editor.c:769
MovieClip * ED_space_clip_get_clip(SpaceClip *sc)
Definition: clip_editor.c:570
static void prefetch_freejob(void *pjv)
Definition: clip_editor.c:1030
void ED_space_clip_get_aspect_dimension_aware(SpaceClip *sc, float *aspx, float *aspy)
Definition: clip_editor.c:197
bool ED_space_clip_poll(bContext *C)
Definition: clip_editor.c:61
void ED_clip_view_lock_state_store(const bContext *C, ClipViewLockState *state)
Definition: clip_editor.c:1145
ImBuf * ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale, float *angle)
Definition: clip_editor.c:258
void ED_space_clip_get_size_fl(SpaceClip *sc, float size[2])
Definition: clip_editor.c:156
struct PrefetchJob PrefetchJob
void ED_clip_mouse_pos(SpaceClip *sc, ARegion *region, const int mval[2], float co[2])
Definition: clip_editor.c:541
void clip_start_prefetch_job(const bContext *C)
Definition: clip_editor.c:1103
static void do_prefetch_movie(MovieClip *clip, MovieClip *clip_local, int start_frame, int current_frame, int end_frame, short render_size, short render_flag, short *stop, short *do_update, float *progress)
Definition: clip_editor.c:957
void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[2])
Definition: clip_editor.c:462
Mask * ED_space_clip_get_mask(SpaceClip *sc)
Definition: clip_editor.c:631
bool ED_clip_view_selection(const bContext *C, ARegion *UNUSED(region), bool fit)
Definition: clip_editor.c:358
bool ED_space_clip_check_show_trackedit(SpaceClip *sc)
Definition: clip_editor.c:546
bool ED_space_clip_maskedit_mask_visible_splines_poll(bContext *C)
Definition: clip_editor.c:130
static bool check_prefetch_break(void)
Definition: clip_editor.c:685
bool ED_space_clip_check_show_maskedit(SpaceClip *sc)
Definition: clip_editor.c:555
bool ED_space_clip_tracking_poll(bContext *C)
Definition: clip_editor.c:83
static int prefetch_find_uncached_frame(MovieClip *clip, int from_frame, int end_frame, short render_size, short render_flag, short direction)
Definition: clip_editor.c:733
bool clip_view_calculate_view_selection(const struct bContext *C, bool fit, float *r_offset_x, float *r_offset_y, float *r_zoom)
#define SELECT
FILE * file
Scene scene
SyclQueue * queue
TaskPool * task_pool
uint pos
void IMB_freeImBuf(ImBuf *UNUSED(ibuf))
ccl_gpu_kernel_postfix ccl_global float int int sy
const int state
ccl_gpu_kernel_postfix ccl_global float int sx
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
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
#define G(x, y, z)
static void area(int d1, int d2, int e1, int e2, float weights[2])
return ret
Definition: DNA_ID.h:368
void * py_instance
Definition: DNA_ID.h:435
int channels
struct ColorSpace * rect_colorspace
unsigned int * rect
float * rect_float
void * first
Definition: DNA_listBase.h:31
Definition: BKE_main.h:121
ListBase wm
Definition: BKE_main.h:197
struct Mask * mask
struct MovieTracking tracking
ColorManagedColorspaceSettings colorspace_settings
struct MovieTrackingPlaneTrack * next
struct MovieTrackingTrack * next
MovieTrackingCamera camera
short render_size
Definition: clip_editor.c:665
MovieClip * clip
Definition: clip_editor.c:655
short render_flag
Definition: clip_editor.c:665
int current_frame
Definition: clip_editor.c:664
MovieClip * clip_local
Definition: clip_editor.c:662
short * do_update
Definition: clip_editor.c:680
short render_size
Definition: clip_editor.c:670
short render_flag
Definition: clip_editor.c:670
SpinLock spin
Definition: clip_editor.c:677
float * progress
Definition: clip_editor.c:681
short * stop
Definition: clip_editor.c:679
struct RenderData r
struct MovieClipUser user
float stabmat[4][4]
struct MovieClipScopes scopes
struct MovieClip * clip
MaskSpaceInfo mask_info
ListBase areabase
Definition: wm_jobs.c:57
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
Definition: wm_jobs.c:437
void WM_jobs_callbacks(wmJob *wm_job, wm_jobs_start_callback startjob, void(*initjob)(void *), void(*update)(void *), void(*endjob)(void *))
Definition: wm_jobs.c:351
void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void(*free)(void *))
Definition: wm_jobs.c:323
void WM_jobs_timer(wmJob *wm_job, double timestep, unsigned int note, unsigned int endnote)
Definition: wm_jobs.c:339
wmJob * WM_jobs_get(wmWindowManager *wm, wmWindow *win, const void *owner, const char *name, int flag, int job_type)
Definition: wm_jobs.c:184
bScreen * WM_window_get_active_screen(const wmWindow *win)
Definition: wm_window.c:2300