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