Blender  V3.3
clip_buttons.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 <stdio.h>
9 #include <string.h>
10 
11 #include "MEM_guardedalloc.h"
12 
13 #include "DNA_scene_types.h"
14 #include "DNA_screen_types.h"
15 #include "DNA_space_types.h"
16 
17 #include "BLI_listbase.h"
18 #include "BLI_math.h"
19 #include "BLI_path_util.h"
20 #include "BLI_string.h"
21 #include "BLI_utildefines.h"
22 
23 #include "BLT_translation.h"
24 
25 #include "BKE_context.h"
26 #include "BKE_movieclip.h"
27 #include "BKE_screen.h"
28 #include "BKE_tracking.h"
29 
30 #include "DEG_depsgraph.h"
31 
32 #include "ED_clip.h"
33 #include "ED_screen.h"
34 
35 #include "UI_interface.h"
36 #include "UI_resources.h"
37 
38 #include "RNA_access.h"
39 
40 #include "WM_api.h"
41 #include "WM_types.h"
42 
43 #include "IMB_imbuf.h"
44 #include "IMB_imbuf_types.h"
45 
46 #include "clip_intern.h" /* own include */
47 
48 /* Panels */
49 
51 {
52  return ED_space_clip_poll((bContext *)C);
53 }
54 
55 static void metadata_panel_context_draw(const bContext *C, Panel *panel)
56 {
57  SpaceClip *space_clip = CTX_wm_space_clip(C);
58  /* NOTE: This might not be exactly the same image buffer as shown in the
59  * clip editor itself, since that might be coming from proxy, or being
60  * postprocessed (stabilized or undistored).
61  * Ideally we need to query metadata from an original image or movie without
62  * reading actual pixels to speed up the process. */
63  ImBuf *ibuf = ED_space_clip_get_buffer(space_clip);
64  if (ibuf != NULL) {
66  IMB_freeImBuf(ibuf);
67  }
68 }
69 
71 {
72  PanelType *pt;
73 
74  pt = MEM_callocN(sizeof(PanelType), "spacetype clip panel metadata");
75  strcpy(pt->idname, "CLIP_PT_metadata");
76  strcpy(pt->label, N_("Metadata"));
77  strcpy(pt->category, "Footage");
82  BLI_addtail(&art->paneltypes, pt);
83 }
84 
85 /********************* MovieClip Template ************************/
86 
88  uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, bool compact)
89 {
90  if (!ptr->data) {
91  return;
92  }
93 
94  PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
95  if (!prop) {
96  printf(
97  "%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname);
98  return;
99  }
100 
101  if (RNA_property_type(prop) != PROP_POINTER) {
102  printf("%s: expected pointer property for %s.%s\n",
103  __func__,
105  propname);
106  return;
107  }
108 
109  PointerRNA clipptr = RNA_property_pointer_get(ptr, prop);
110  MovieClip *clip = clipptr.data;
111 
112  uiLayoutSetContextPointer(layout, "edit_movieclip", &clipptr);
113 
114  if (!compact) {
115  uiTemplateID(layout,
116  C,
117  ptr,
118  propname,
119  NULL,
120  "CLIP_OT_open",
121  NULL,
123  false,
124  NULL);
125  }
126 
127  if (clip) {
128  uiLayout *row = uiLayoutRow(layout, false);
129  uiBlock *block = uiLayoutGetBlock(row);
130  uiDefBut(block, UI_BTYPE_LABEL, 0, IFACE_("File Path:"), 0, 19, 145, 19, NULL, 0, 0, 0, 0, "");
131 
132  row = uiLayoutRow(layout, false);
133  uiLayout *split = uiLayoutSplit(row, 0.0f, false);
134  row = uiLayoutRow(split, true);
135 
136  uiItemR(row, &clipptr, "filepath", 0, "", ICON_NONE);
137  uiItemO(row, "", ICON_FILE_REFRESH, "clip.reload");
138 
139  uiLayout *col = uiLayoutColumn(layout, false);
140  uiTemplateColorspaceSettings(col, &clipptr, "colorspace_settings");
141  }
142 }
143 
144 /********************* Track Template ************************/
145 
146 void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
147 {
148  if (!ptr->data) {
149  return;
150  }
151 
152  PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
153  if (!prop) {
154  printf(
155  "%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname);
156  return;
157  }
158 
159  if (RNA_property_type(prop) != PROP_POINTER) {
160  printf("%s: expected pointer property for %s.%s\n",
161  __func__,
163  propname);
164  return;
165  }
166 
167  PointerRNA scopesptr = RNA_property_pointer_get(ptr, prop);
168  MovieClipScopes *scopes = (MovieClipScopes *)scopesptr.data;
169 
170  if (scopes->track_preview_height < UI_UNIT_Y) {
172  }
173  else if (scopes->track_preview_height > UI_UNIT_Y * 20) {
174  scopes->track_preview_height = UI_UNIT_Y * 20;
175  }
176 
177  uiLayout *col = uiLayoutColumn(layout, true);
178  uiBlock *block = uiLayoutGetBlock(col);
179 
180  uiDefBut(block,
182  0,
183  "",
184  0,
185  0,
186  UI_UNIT_X * 10,
187  scopes->track_preview_height,
188  scopes,
189  0,
190  0,
191  0,
192  0,
193  "");
194 
195  /* Resize grip. */
196  uiDefIconButI(block,
198  0,
199  ICON_GRIP,
200  0,
201  0,
202  UI_UNIT_X * 10,
203  (short)(UI_UNIT_Y * 0.8f),
204  &scopes->track_preview_height,
205  UI_UNIT_Y,
206  UI_UNIT_Y * 20.0f,
207  0.0f,
208  0.0f,
209  "");
210 }
211 
212 /********************* Marker Template ************************/
213 
214 #define B_MARKER_POS 3
215 #define B_MARKER_OFFSET 4
216 #define B_MARKER_PAT_DIM 5
217 #define B_MARKER_SEARCH_POS 6
218 #define B_MARKER_SEARCH_DIM 7
219 #define B_MARKER_FLAG 8
220 
221 typedef struct {
223  int compact;
224 
230 
232  int framenr;
234  float marker_pos[2];
236  float marker_pat[2];
238  float track_offset[2];
240  float marker_search_pos[2], marker_search[2];
244 
245 static void to_pixel_space(float r[2], const float a[2], int width, int height)
246 {
247  copy_v2_v2(r, a);
248  r[0] *= width;
249  r[1] *= height;
250 }
251 
252 static void marker_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
253 {
254  MarkerUpdateCb *cb = (MarkerUpdateCb *)arg_cb;
255 
256  if (!cb->compact) {
257  return;
258  }
259 
260  int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(cb->clip, cb->framenr);
261  MovieTrackingMarker *marker = BKE_tracking_marker_ensure(cb->track, clip_framenr);
262  marker->flag = cb->marker_flag;
263 
265 }
266 
267 static void marker_block_handler(bContext *C, void *arg_cb, int event)
268 {
269  MarkerUpdateCb *cb = (MarkerUpdateCb *)arg_cb;
270  int width, height;
271  bool ok = false;
272 
274 
275  int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(cb->clip, cb->framenr);
276  MovieTrackingMarker *marker = BKE_tracking_marker_ensure(cb->track, clip_framenr);
277 
278  if (event == B_MARKER_POS) {
279  marker->pos[0] = cb->marker_pos[0] / width;
280  marker->pos[1] = cb->marker_pos[1] / height;
281 
282  /* to update position of "parented" objects */
283  DEG_id_tag_update(&cb->clip->id, 0);
285 
286  ok = true;
287  }
288  else if (event == B_MARKER_PAT_DIM) {
289  float dim[2], pat_dim[2], pat_min[2], pat_max[2];
290 
291  BKE_tracking_marker_pattern_minmax(cb->marker, pat_min, pat_max);
292 
293  sub_v2_v2v2(pat_dim, pat_max, pat_min);
294 
295  dim[0] = cb->marker_pat[0] / width;
296  dim[1] = cb->marker_pat[1] / height;
297 
298  float scale_x = dim[0] / pat_dim[0];
299  float scale_y = dim[1] / pat_dim[1];
300 
301  for (int a = 0; a < 4; a++) {
302  cb->marker->pattern_corners[a][0] *= scale_x;
303  cb->marker->pattern_corners[a][1] *= scale_y;
304  }
305 
307 
308  ok = true;
309  }
310  else if (event == B_MARKER_SEARCH_POS) {
311  float delta[2], side[2];
312 
313  sub_v2_v2v2(side, cb->marker->search_max, cb->marker->search_min);
314  mul_v2_fl(side, 0.5f);
315 
316  delta[0] = cb->marker_search_pos[0] / width;
317  delta[1] = cb->marker_search_pos[1] / height;
318 
319  sub_v2_v2v2(cb->marker->search_min, delta, side);
320  add_v2_v2v2(cb->marker->search_max, delta, side);
321 
323 
324  ok = true;
325  }
326  else if (event == B_MARKER_SEARCH_DIM) {
327  float dim[2], search_dim[2];
328 
329  sub_v2_v2v2(search_dim, cb->marker->search_max, cb->marker->search_min);
330 
331  dim[0] = cb->marker_search[0] / width;
332  dim[1] = cb->marker_search[1] / height;
333 
334  sub_v2_v2(dim, search_dim);
335  mul_v2_fl(dim, 0.5f);
336 
337  cb->marker->search_min[0] -= dim[0];
338  cb->marker->search_min[1] -= dim[1];
339 
340  cb->marker->search_max[0] += dim[0];
341  cb->marker->search_max[1] += dim[1];
342 
344 
345  ok = true;
346  }
347  else if (event == B_MARKER_FLAG) {
348  marker->flag = cb->marker_flag;
349 
350  ok = true;
351  }
352  else if (event == B_MARKER_OFFSET) {
353  float offset[2], delta[2];
354 
355  offset[0] = cb->track_offset[0] / width;
356  offset[1] = cb->track_offset[1] / height;
357 
358  sub_v2_v2v2(delta, offset, cb->track->offset);
359  copy_v2_v2(cb->track->offset, offset);
360 
361  for (int i = 0; i < cb->track->markersnr; i++) {
362  sub_v2_v2(cb->track->markers[i].pos, delta);
363  }
364 
365  /* to update position of "parented" objects */
366  DEG_id_tag_update(&cb->clip->id, 0);
368 
369  ok = true;
370  }
371 
372  if (ok) {
374  }
375 }
376 
378  PointerRNA *ptr,
379  const char *propname,
380  PointerRNA *userptr,
381  PointerRNA *trackptr,
382  bool compact)
383 {
384  if (!ptr->data) {
385  return;
386  }
387 
388  PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
389  if (!prop) {
390  printf(
391  "%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname);
392  return;
393  }
394 
395  if (RNA_property_type(prop) != PROP_POINTER) {
396  printf("%s: expected pointer property for %s.%s\n",
397  __func__,
399  propname);
400  return;
401  }
402 
403  PointerRNA clipptr = RNA_property_pointer_get(ptr, prop);
404  MovieClip *clip = (MovieClip *)clipptr.data;
405  MovieClipUser *user = userptr->data;
406  MovieTrackingTrack *track = trackptr->data;
407 
408  int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr);
409  MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_framenr);
410 
411  MarkerUpdateCb *cb = MEM_callocN(sizeof(MarkerUpdateCb), "uiTemplateMarker update_cb");
412  cb->compact = compact;
413  cb->clip = clip;
414  cb->user = user;
415  cb->track = track;
416  cb->marker = marker;
417  cb->marker_flag = marker->flag;
418  cb->framenr = user->framenr;
419 
420  if (compact) {
421  const char *tip;
422  uiBlock *block = uiLayoutGetBlock(layout);
423 
424  if (cb->marker_flag & MARKER_DISABLED) {
425  tip = TIP_("Marker is disabled at current frame");
426  }
427  else {
428  tip = TIP_("Marker is enabled at current frame");
429  }
430 
431  uiBut *bt = uiDefIconButBitI(block,
434  0,
435  ICON_HIDE_OFF,
436  0,
437  0,
438  UI_UNIT_X,
439  UI_UNIT_Y,
440  &cb->marker_flag,
441  0,
442  0,
443  1,
444  0,
445  tip);
448  }
449  else {
450  int width, height;
451 
452  BKE_movieclip_get_size(clip, user, &width, &height);
453 
454  if (track->flag & TRACK_LOCKED) {
455  uiLayoutSetActive(layout, false);
456  uiBlock *block = uiLayoutAbsoluteBlock(layout);
457  uiDefBut(block,
459  0,
460  IFACE_("Track is locked"),
461  0,
462  0,
463  UI_UNIT_X * 15.0f,
464  UI_UNIT_Y,
465  NULL,
466  0,
467  0,
468  0,
469  0,
470  "");
471 
472  return;
473  }
474 
475  float pat_min[2], pat_max[2];
476  float pat_dim[2], search_dim[2], search_pos[2];
477 
478  BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
479 
480  sub_v2_v2v2(pat_dim, pat_max, pat_min);
481  sub_v2_v2v2(search_dim, marker->search_max, marker->search_min);
482 
483  add_v2_v2v2(search_pos, marker->search_max, marker->search_min);
484  mul_v2_fl(search_pos, 0.5);
485 
486  to_pixel_space(cb->marker_pos, marker->pos, width, height);
487  to_pixel_space(cb->marker_pat, pat_dim, width, height);
488  to_pixel_space(cb->marker_search, search_dim, width, height);
489  to_pixel_space(cb->marker_search_pos, search_pos, width, height);
490  to_pixel_space(cb->track_offset, track->offset, width, height);
491 
492  cb->marker_flag = marker->flag;
493 
494  uiBlock *block = uiLayoutAbsoluteBlock(layout);
497 
498  const char *tip;
499  int step = 100;
500  int digits = 2;
501 
502  if (cb->marker_flag & MARKER_DISABLED) {
503  tip = TIP_("Marker is disabled at current frame");
504  }
505  else {
506  tip = TIP_("Marker is enabled at current frame");
507  }
508 
509  uiDefButBitI(block,
513  IFACE_("Enabled"),
514  0.5 * UI_UNIT_X,
515  9.5 * UI_UNIT_Y,
516  7.25 * UI_UNIT_X,
517  UI_UNIT_Y,
518  &cb->marker_flag,
519  0,
520  0,
521  0,
522  0,
523  tip);
524 
525  uiLayout *col = uiLayoutColumn(layout, true);
527 
528  block = uiLayoutAbsoluteBlock(col);
529  UI_block_align_begin(block);
530 
531  uiDefBut(block,
533  0,
534  IFACE_("Position:"),
535  0,
536  10 * UI_UNIT_Y,
537  15 * UI_UNIT_X,
538  UI_UNIT_Y,
539  NULL,
540  0,
541  0,
542  0,
543  0,
544  "");
545  uiBut *bt = uiDefButF(block,
546  UI_BTYPE_NUM,
547  B_MARKER_POS,
548  IFACE_("X:"),
549  0.5 * UI_UNIT_X,
550  9 * UI_UNIT_Y,
551  7.25 * UI_UNIT_X,
552  UI_UNIT_Y,
553  &cb->marker_pos[0],
554  -10 * width,
555  10.0 * width,
556  0,
557  0,
558  TIP_("X-position of marker at frame in screen coordinates"));
559  UI_but_number_step_size_set(bt, step);
560  UI_but_number_precision_set(bt, digits);
561  bt = uiDefButF(block,
562  UI_BTYPE_NUM,
563  B_MARKER_POS,
564  IFACE_("Y:"),
565  8.25 * UI_UNIT_X,
566  9 * UI_UNIT_Y,
567  7.25 * UI_UNIT_X,
568  UI_UNIT_Y,
569  &cb->marker_pos[1],
570  -10 * height,
571  10.0 * height,
572  0,
573  0,
574  TIP_("Y-position of marker at frame in screen coordinates"));
575  UI_but_number_step_size_set(bt, step);
576  UI_but_number_precision_set(bt, digits);
577 
578  uiDefBut(block,
580  0,
581  IFACE_("Offset:"),
582  0,
583  8 * UI_UNIT_Y,
584  15 * UI_UNIT_X,
585  UI_UNIT_Y,
586  NULL,
587  0,
588  0,
589  0,
590  0,
591  "");
592  bt = uiDefButF(block,
593  UI_BTYPE_NUM,
595  IFACE_("X:"),
596  0.5 * UI_UNIT_X,
597  7 * UI_UNIT_Y,
598  7.25 * UI_UNIT_X,
599  UI_UNIT_Y,
600  &cb->track_offset[0],
601  -10 * width,
602  10.0 * width,
603  0,
604  0,
605  TIP_("X-offset to parenting point"));
606  UI_but_number_step_size_set(bt, step);
607  UI_but_number_precision_set(bt, digits);
608  bt = uiDefButF(block,
609  UI_BTYPE_NUM,
611  IFACE_("Y:"),
612  8.25 * UI_UNIT_X,
613  7 * UI_UNIT_Y,
614  7.25 * UI_UNIT_X,
615  UI_UNIT_Y,
616  &cb->track_offset[1],
617  -10 * height,
618  10.0 * height,
619  0,
620  0,
621  TIP_("Y-offset to parenting point"));
622  UI_but_number_step_size_set(bt, step);
623  UI_but_number_precision_set(bt, digits);
624 
625  uiDefBut(block,
627  0,
628  IFACE_("Pattern Area:"),
629  0,
630  6 * UI_UNIT_Y,
631  15 * UI_UNIT_X,
632  UI_UNIT_Y,
633  NULL,
634  0,
635  0,
636  0,
637  0,
638  "");
639  bt = uiDefButF(block,
640  UI_BTYPE_NUM,
642  IFACE_("Width:"),
643  0.5 * UI_UNIT_X,
644  5 * UI_UNIT_Y,
645  15 * UI_UNIT_X,
646  UI_UNIT_Y,
647  &cb->marker_pat[0],
648  3.0f,
649  10.0 * width,
650  0,
651  0,
652  TIP_("Width of marker's pattern in screen coordinates"));
653  UI_but_number_step_size_set(bt, step);
654  UI_but_number_precision_set(bt, digits);
655  bt = uiDefButF(block,
656  UI_BTYPE_NUM,
658  IFACE_("Height:"),
659  0.5 * UI_UNIT_X,
660  4 * UI_UNIT_Y,
661  15 * UI_UNIT_X,
662  UI_UNIT_Y,
663  &cb->marker_pat[1],
664  3.0f,
665  10.0 * height,
666  0,
667  0,
668  TIP_("Height of marker's pattern in screen coordinates"));
669  UI_but_number_step_size_set(bt, step);
670  UI_but_number_precision_set(bt, digits);
671 
672  uiDefBut(block,
674  0,
675  IFACE_("Search Area:"),
676  0,
677  3 * UI_UNIT_Y,
678  15 * UI_UNIT_X,
679  UI_UNIT_Y,
680  NULL,
681  0,
682  0,
683  0,
684  0,
685  "");
686  bt = uiDefButF(block,
687  UI_BTYPE_NUM,
689  IFACE_("X:"),
690  0.5 * UI_UNIT_X,
691  2 * UI_UNIT_Y,
692  7.25 * UI_UNIT_X,
693  UI_UNIT_Y,
694  &cb->marker_search_pos[0],
695  -width,
696  width,
697  0,
698  0,
699  TIP_("X-position of search at frame relative to marker's position"));
700  UI_but_number_step_size_set(bt, step);
701  UI_but_number_precision_set(bt, digits);
702  bt = uiDefButF(block,
703  UI_BTYPE_NUM,
705  IFACE_("Y:"),
706  8.25 * UI_UNIT_X,
707  2 * UI_UNIT_Y,
708  7.25 * UI_UNIT_X,
709  UI_UNIT_Y,
710  &cb->marker_search_pos[1],
711  -height,
712  height,
713  0,
714  0,
715  TIP_("Y-position of search at frame relative to marker's position"));
716  UI_but_number_step_size_set(bt, step);
717  UI_but_number_precision_set(bt, digits);
718  bt = uiDefButF(block,
719  UI_BTYPE_NUM,
721  IFACE_("Width:"),
722  0.5 * UI_UNIT_X,
723  1 * UI_UNIT_Y,
724  15 * UI_UNIT_X,
725  UI_UNIT_Y,
726  &cb->marker_search[0],
727  3.0f,
728  10.0 * width,
729  0,
730  0,
731  TIP_("Width of marker's search in screen coordinates"));
732  UI_but_number_step_size_set(bt, step);
733  UI_but_number_precision_set(bt, digits);
734  bt = uiDefButF(block,
735  UI_BTYPE_NUM,
737  IFACE_("Height:"),
738  0.5 * UI_UNIT_X,
739  0 * UI_UNIT_Y,
740  15 * UI_UNIT_X,
741  UI_UNIT_Y,
742  &cb->marker_search[1],
743  3.0f,
744  10.0 * height,
745  0,
746  0,
747  TIP_("Height of marker's search in screen coordinates"));
748  UI_but_number_step_size_set(bt, step);
749  UI_but_number_precision_set(bt, digits);
750 
751  UI_block_align_end(block);
752  }
753 }
754 
755 /********************* Footage Information Template ************************/
756 
758  PointerRNA *ptr,
759  const char *propname,
760  PointerRNA *userptr)
761 {
762  if (!ptr->data) {
763  return;
764  }
765 
766  PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
767  if (!prop) {
768  printf(
769  "%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname);
770  return;
771  }
772 
773  if (RNA_property_type(prop) != PROP_POINTER) {
774  printf("%s: expected pointer property for %s.%s\n",
775  __func__,
777  propname);
778  return;
779  }
780 
781  PointerRNA clipptr = RNA_property_pointer_get(ptr, prop);
782  MovieClip *clip = (MovieClip *)clipptr.data;
783  MovieClipUser *user = userptr->data;
784 
785  uiLayout *col = uiLayoutColumn(layout, false);
787 
788  ImBuf *ibuf = BKE_movieclip_get_ibuf_flag(clip, user, clip->flag, MOVIECLIP_CACHE_SKIP);
789 
790  int width, height;
791  /* Display frame dimensions, channels number and buffer type. */
792  BKE_movieclip_get_size(clip, user, &width, &height);
793 
794  char str[1024];
795  size_t ofs = 0;
796  ofs += BLI_snprintf_rlen(str + ofs, sizeof(str) - ofs, TIP_("%d x %d"), width, height);
797 
798  if (ibuf) {
799  if (ibuf->rect_float) {
800  if (ibuf->channels != 4) {
801  ofs += BLI_snprintf_rlen(
802  str + ofs, sizeof(str) - ofs, TIP_(", %d float channel(s)"), ibuf->channels);
803  }
804  else if (ibuf->planes == R_IMF_PLANES_RGBA) {
805  ofs += BLI_strncpy_rlen(str + ofs, TIP_(", RGBA float"), sizeof(str) - ofs);
806  }
807  else {
808  ofs += BLI_strncpy_rlen(str + ofs, TIP_(", RGB float"), sizeof(str) - ofs);
809  }
810  }
811  else {
812  if (ibuf->planes == R_IMF_PLANES_RGBA) {
813  ofs += BLI_strncpy_rlen(str + ofs, TIP_(", RGBA byte"), sizeof(str) - ofs);
814  }
815  else {
816  ofs += BLI_strncpy_rlen(str + ofs, TIP_(", RGB byte"), sizeof(str) - ofs);
817  }
818  }
819 
820  if (clip->anim != NULL) {
821  short frs_sec;
822  float frs_sec_base;
823  if (IMB_anim_get_fps(clip->anim, &frs_sec, &frs_sec_base, true)) {
824  ofs += BLI_snprintf_rlen(
825  str + ofs, sizeof(str) - ofs, TIP_(", %.2f fps"), (float)frs_sec / frs_sec_base);
826  }
827  }
828  }
829  else {
830  ofs += BLI_strncpy_rlen(str + ofs, TIP_(", failed to load"), sizeof(str) - ofs);
831  }
832 
833  uiItemL(col, str, ICON_NONE);
834 
835  /* Display current frame number. */
836  int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr);
837  if (framenr <= clip->len) {
838  BLI_snprintf(str, sizeof(str), TIP_("Frame: %d / %d"), framenr, clip->len);
839  }
840  else {
841  BLI_snprintf(str, sizeof(str), TIP_("Frame: - / %d"), clip->len);
842  }
843  uiItemL(col, str, ICON_NONE);
844 
845  /* Display current file name if it's a sequence clip. */
846  if (clip->source == MCLIP_SRC_SEQUENCE) {
847  char filepath[FILE_MAX];
848  const char *file;
849 
850  if (framenr <= clip->len) {
851  BKE_movieclip_filename_for_frame(clip, user, filepath);
852  file = BLI_path_slash_rfind(filepath);
853  }
854  else {
855  file = "-";
856  }
857 
858  BLI_snprintf(str, sizeof(str), TIP_("File: %s"), file);
859 
860  uiItemL(col, str, ICON_NONE);
861  }
862 
863  IMB_freeImBuf(ibuf);
864 }
struct SpaceClip * CTX_wm_space_clip(const bContext *C)
Definition: context.c:923
float BKE_movieclip_remap_scene_to_clip_frame(const struct MovieClip *clip, float framenr)
#define MOVIECLIP_CACHE_SKIP
struct ImBuf * BKE_movieclip_get_ibuf_flag(struct MovieClip *clip, struct MovieClipUser *user, int flag, int cache_flag)
Definition: movieclip.c:1334
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
@ PANEL_TYPE_DEFAULT_CLOSED
Definition: BKE_screen.h:279
struct MovieTrackingMarker * BKE_tracking_marker_ensure(struct MovieTrackingTrack *track, int framenr)
Definition: tracking.c:1468
void BKE_tracking_marker_clamp_search_position(struct MovieTrackingMarker *marker)
Definition: tracking.c:1404
void BKE_tracking_marker_clamp_search_size(struct MovieTrackingMarker *marker)
Definition: tracking.c:1393
void BKE_tracking_marker_pattern_minmax(const struct MovieTrackingMarker *marker, float min[2], float max[2])
struct MovieTrackingMarker * BKE_tracking_marker_get(struct MovieTrackingTrack *track, int framenr)
Definition: tracking.c:1424
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:80
MINLINE void sub_v2_v2(float r[2], const float a[2])
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
#define FILE_MAX
const char * BLI_path_slash_rfind(const char *string) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:1765
size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:120
size_t BLI_snprintf_rlen(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
#define UNUSED(x)
#define TIP_(msgid)
#define IFACE_(msgid)
#define BLT_I18NCONTEXT_DEFAULT_BPYRNA
void DEG_id_tag_update(struct ID *id, int flag)
@ MCLIP_SRC_SEQUENCE
#define R_IMF_PLANES_RGBA
@ MARKER_DISABLED
@ TRACK_LOCKED
bool ED_space_clip_poll(struct bContext *C)
Definition: clip_editor.c:61
struct ImBuf * ED_space_clip_get_buffer(struct SpaceClip *sc)
Definition: clip_editor.c:239
void ED_region_image_metadata_panel_draw(struct ImBuf *ibuf, struct uiLayout *layout)
Definition: area.c:3612
_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 GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
bool IMB_anim_get_fps(struct anim *anim, short *frs_sec, float *frs_sec_base, bool no_av_base)
Definition: anim_movie.c:1678
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
@ PROP_POINTER
Definition: RNA_types.h:64
#define C
Definition: RandGen.cpp:25
@ UI_LAYOUT_ALIGN_RIGHT
@ UI_BUT_ICON_REVERSE
Definition: UI_interface.h:294
#define UI_UNIT_Y
uiBut * uiDefButBitI(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip)
Definition: interface.cc:5102
void uiLayoutSetActive(uiLayout *layout, bool active)
uiBlock * uiLayoutGetBlock(uiLayout *layout)
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
uiBut * uiDefBut(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip)
Definition: interface.cc:4806
uiBut * uiDefButF(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip)
Definition: interface.cc:5042
uiBut * uiDefIconButI(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip)
Definition: interface.cc:5392
void uiTemplateColorspaceSettings(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname)
void uiItemL(uiLayout *layout, const char *name, int icon)
void UI_but_drawflag_enable(uiBut *but, int flag)
Definition: interface.cc:5873
void uiLayoutSetAlignment(uiLayout *layout, char alignment)
uiBlock * uiLayoutAbsoluteBlock(uiLayout *layout)
void UI_but_number_step_size_set(uiBut *but, float step_size)
Definition: interface.cc:6455
void UI_block_func_handle_set(uiBlock *block, uiBlockHandleFunc func, void *arg)
Definition: interface.cc:5953
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
void UI_block_align_begin(uiBlock *block)
Definition: interface.cc:3910
void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname)
void uiLayoutSetContextPointer(uiLayout *layout, const char *name, struct PointerRNA *ptr)
uiLayout * uiLayoutSplit(uiLayout *layout, float percentage, bool align)
void UI_but_number_precision_set(uiBut *but, float precision)
Definition: interface.cc:6464
void uiTemplateID(uiLayout *layout, const struct bContext *C, struct PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int filter, bool live_icon, const char *text)
void UI_but_funcN_set(uiBut *but, uiButHandleNFunc funcN, void *argN, void *arg2)
Definition: interface.cc:6007
#define UI_UNIT_X
uiBut * uiDefIconButBitI(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip)
Definition: interface.cc:5422
@ UI_BTYPE_TOGGLE_N
Definition: UI_interface.h:341
@ UI_BTYPE_LABEL
Definition: UI_interface.h:354
@ UI_BTYPE_CHECKBOX_N
Definition: UI_interface.h:348
@ UI_BTYPE_NUM
Definition: UI_interface.h:337
@ UI_BTYPE_TRACK_PREVIEW
Definition: UI_interface.h:369
@ UI_BTYPE_GRIP
Definition: UI_interface.h:390
void UI_block_funcN_set(uiBlock *block, uiButHandleNFunc funcN, void *argN, void *arg2)
Definition: interface.cc:5972
@ UI_TEMPLATE_ID_FILTER_ALL
void UI_block_align_end(uiBlock *block)
Definition: interface.cc:3923
#define NC_MOVIECLIP
Definition: WM_types.h:347
#define NA_EDITED
Definition: WM_types.h:523
#define ND_SPACE_VIEW3D
Definition: WM_types.h:471
#define NC_SPACE
Definition: WM_types.h:342
#define B_MARKER_POS
Definition: clip_buttons.c:214
#define B_MARKER_SEARCH_DIM
Definition: clip_buttons.c:218
static void marker_block_handler(bContext *C, void *arg_cb, int event)
Definition: clip_buttons.c:267
void ED_clip_buttons_register(ARegionType *art)
Definition: clip_buttons.c:70
void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
Definition: clip_buttons.c:146
#define B_MARKER_SEARCH_POS
Definition: clip_buttons.c:217
void uiTemplateMovieclipInformation(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *userptr)
Definition: clip_buttons.c:757
void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *trackptr, bool compact)
Definition: clip_buttons.c:377
#define B_MARKER_OFFSET
Definition: clip_buttons.c:215
static bool metadata_panel_context_poll(const bContext *C, PanelType *UNUSED(pt))
Definition: clip_buttons.c:50
#define B_MARKER_PAT_DIM
Definition: clip_buttons.c:216
#define B_MARKER_FLAG
Definition: clip_buttons.c:219
static void to_pixel_space(float r[2], const float a[2], int width, int height)
Definition: clip_buttons.c:245
static void marker_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
Definition: clip_buttons.c:252
void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, bool compact)
Definition: clip_buttons.c:87
static void metadata_panel_context_draw(const bContext *C, Panel *panel)
Definition: clip_buttons.c:55
FILE * file
int len
Definition: draw_manager.c:108
#define str(s)
uint col
void IMB_freeImBuf(ImBuf *UNUSED(ibuf))
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
static unsigned a[3]
Definition: RandGen.cpp:78
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
Definition: abc_util.cc:92
const char * RNA_struct_identifier(const StructRNA *type)
Definition: rna_access.c:586
PropertyType RNA_property_type(PropertyRNA *prop)
Definition: rna_access.c:1010
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:3493
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:717
ListBase paneltypes
Definition: BKE_screen.h:198
int channels
unsigned char planes
float * rect_float
MovieTrackingMarker * marker
Definition: clip_buttons.c:229
MovieTrackingTrack * track
Definition: clip_buttons.c:228
float track_offset[2]
Definition: clip_buttons.c:238
float marker_search_pos[2]
Definition: clip_buttons.c:240
MovieClip * clip
Definition: clip_buttons.c:225
float marker_search[2]
Definition: clip_buttons.c:240
float marker_pat[2]
Definition: clip_buttons.c:236
float marker_pos[2]
Definition: clip_buttons.c:234
MovieClipUser * user
Definition: clip_buttons.c:227
struct anim * anim
MovieTrackingMarker * markers
void(* draw)(const struct bContext *C, struct Panel *panel)
Definition: BKE_screen.h:248
bool(* poll)(const struct bContext *C, struct PanelType *pt)
Definition: BKE_screen.h:242
char idname[BKE_ST_MAXNAME]
Definition: BKE_screen.h:223
char translation_context[BKE_ST_MAXNAME]
Definition: BKE_screen.h:226
char category[BKE_ST_MAXNAME]
Definition: BKE_screen.h:228
char label[BKE_ST_MAXNAME]
Definition: BKE_screen.h:224
struct uiLayout * layout
struct StructRNA * type
Definition: RNA_types.h:37
void * data
Definition: RNA_types.h:38
#define N_(msgid)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
PointerRNA * ptr
Definition: wm_files.c:3480