ClangFormat: apply to source, most of intern
[blender.git] / source / blender / blenkernel / tracking_private.h
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
20 /** \file
21  * \ingroup bke
22  *
23  * This file contains declarations of function which are used
24  * by multiple tracking files but which should not be public.
25  */
26
27 #ifndef __TRACKING_PRIVATE_H__
28 #define __TRACKING_PRIVATE_H__
29
30 #include "BLI_threads.h"
31
32 struct GHash;
33 struct MovieTracking;
34 struct MovieTrackingMarker;
35
36 struct libmv_CameraIntrinsicsOptions;
37
38 /*********************** Tracks map *************************/
39
40 typedef struct TracksMap {
41   char object_name[MAX_NAME];
42   bool is_camera;
43
44   int num_tracks;
45   int customdata_size;
46
47   char *customdata;
48   MovieTrackingTrack *tracks;
49
50   struct GHash *hash;
51
52   int ptr;
53
54   /* Spin lock is used to sync context during tracking. */
55   SpinLock spin_lock;
56 } TracksMap;
57
58 struct TracksMap *tracks_map_new(const char *object_name,
59                                  bool is_camera,
60                                  int num_tracks,
61                                  int customdata_size);
62 int tracks_map_get_size(struct TracksMap *map);
63 void tracks_map_get_indexed_element(struct TracksMap *map,
64                                     int index,
65                                     struct MovieTrackingTrack **track,
66                                     void **customdata);
67 void tracks_map_insert(struct TracksMap *map, struct MovieTrackingTrack *track, void *customdata);
68 void tracks_map_free(struct TracksMap *map, void (*customdata_free)(void *customdata));
69 void tracks_map_merge(struct TracksMap *map, struct MovieTracking *tracking);
70
71 /*********************** Space transformation functions *************************/
72
73 void tracking_get_search_origin_frame_pixel(int frame_width,
74                                             int frame_height,
75                                             const struct MovieTrackingMarker *marker,
76                                             float frame_pixel[2]);
77
78 void tracking_get_marker_coords_for_tracking(int frame_width,
79                                              int frame_height,
80                                              const struct MovieTrackingMarker *marker,
81                                              double search_pixel_x[5],
82                                              double search_pixel_y[5]);
83
84 void tracking_set_marker_coords_from_tracking(int frame_width,
85                                               int frame_height,
86                                               struct MovieTrackingMarker *marker,
87                                               const double search_pixel_x[5],
88                                               const double search_pixel_y[5]);
89
90 /*********************** General purpose utility functions *************************/
91
92 void tracking_marker_insert_disabled(struct MovieTrackingTrack *track,
93                                      const struct MovieTrackingMarker *ref_marker,
94                                      bool before,
95                                      bool overwrite);
96
97 void tracking_cameraIntrinscisOptionsFromTracking(
98     struct MovieTracking *tracking,
99     int calibration_width,
100     int calibration_height,
101     struct libmv_CameraIntrinsicsOptions *camera_intrinsics_options);
102
103 void tracking_trackingCameraFromIntrinscisOptions(
104     struct MovieTracking *tracking,
105     const struct libmv_CameraIntrinsicsOptions *camera_intrinsics_options);
106
107 struct libmv_TrackRegionOptions;
108
109 void tracking_configure_tracker(const MovieTrackingTrack *track,
110                                 float *mask,
111                                 struct libmv_TrackRegionOptions *options);
112
113 struct MovieTrackingMarker *tracking_get_keyframed_marker(struct MovieTrackingTrack *track,
114                                                           int current_frame,
115                                                           bool backwards);
116
117 /*********************** Masking *************************/
118
119 float *tracking_track_get_mask_for_region(int frame_width,
120                                           int frame_height,
121                                           const float region_min[2],
122                                           const float region_max[2],
123                                           MovieTrackingTrack *track);
124
125 /*********************** Frame accessr *************************/
126
127 struct libmv_FrameAccessor;
128
129 #define MAX_ACCESSOR_CLIP 64
130 typedef struct TrackingImageAccessor {
131   struct MovieCache *cache;
132   struct MovieClip *clips[MAX_ACCESSOR_CLIP];
133   int num_clips;
134   struct MovieTrackingTrack **tracks;
135   int num_tracks;
136   int start_frame;
137   struct libmv_FrameAccessor *libmv_accessor;
138   SpinLock cache_lock;
139 } TrackingImageAccessor;
140
141 TrackingImageAccessor *tracking_image_accessor_new(MovieClip *clips[MAX_ACCESSOR_CLIP],
142                                                    int num_clips,
143                                                    MovieTrackingTrack **tracks,
144                                                    int num_tracks,
145                                                    int start_frame);
146 void tracking_image_accessor_destroy(TrackingImageAccessor *accessor);
147
148 #endif /* __TRACKING_PRIVATE_H__ */