Merge branch 'master' into blender2.8
[blender.git] / source / blender / blenkernel / tracking_private.h
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2011 Blender Foundation.
19  * All rights reserved.
20  *
21  * Contributor(s): Blender Foundation,
22  *                 Sergey Sharybin
23  *                 Keir Mierle
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 /** \file blender/blenkernel/tracking_private.h
29  *  \ingroup bke
30  *
31  * This file contains declarations of function which are used
32  * by multiple tracking files but which should not be public.
33  */
34
35 #ifndef __TRACKING_PRIVATE_H__
36 #define __TRACKING_PRIVATE_H__
37
38 #include "BLI_threads.h"
39
40 struct GHash;
41 struct MovieTracking;
42 struct MovieTrackingMarker;
43
44 struct libmv_CameraIntrinsicsOptions;
45
46 /*********************** Tracks map *************************/
47
48 typedef struct TracksMap {
49         char object_name[MAX_NAME];
50         bool is_camera;
51
52         int num_tracks;
53         int customdata_size;
54
55         char *customdata;
56         MovieTrackingTrack *tracks;
57
58         struct GHash *hash;
59
60         int ptr;
61
62         /* Spin lock is used to sync context during tracking. */
63         SpinLock spin_lock;
64 } TracksMap;
65
66 struct TracksMap *tracks_map_new(const char *object_name, bool is_camera, int num_tracks, int customdata_size);
67 int tracks_map_get_size(struct TracksMap *map);
68 void tracks_map_get_indexed_element(struct TracksMap *map, int index, struct MovieTrackingTrack **track, void **customdata);
69 void tracks_map_insert(struct TracksMap *map, struct MovieTrackingTrack *track, void *customdata);
70 void tracks_map_free(struct TracksMap *map, void (*customdata_free)(void *customdata));
71 void tracks_map_merge(struct TracksMap *map, struct MovieTracking *tracking);
72
73 /*********************** Space transformation functions *************************/
74
75 void tracking_get_search_origin_frame_pixel(int frame_width, int frame_height,
76                                             const struct MovieTrackingMarker *marker,
77                                             float frame_pixel[2]);
78
79 void tracking_get_marker_coords_for_tracking(int frame_width, int frame_height,
80                                              const struct MovieTrackingMarker *marker,
81                                              double search_pixel_x[5], double search_pixel_y[5]);
82
83 void tracking_set_marker_coords_from_tracking(int frame_width, int frame_height, struct MovieTrackingMarker *marker,
84                                               const double search_pixel_x[5], const double search_pixel_y[5]);
85
86 /*********************** General purpose utility functions *************************/
87
88 void tracking_marker_insert_disabled(struct MovieTrackingTrack *track, const struct MovieTrackingMarker *ref_marker,
89                                      bool before, bool overwrite);
90
91 void tracking_cameraIntrinscisOptionsFromTracking(struct MovieTracking *tracking,
92                                                   int calibration_width, int calibration_height,
93                                                   struct libmv_CameraIntrinsicsOptions *camera_intrinsics_options);
94
95 void tracking_trackingCameraFromIntrinscisOptions(struct MovieTracking *tracking,
96                                                   const struct libmv_CameraIntrinsicsOptions *camera_intrinsics_options);
97
98 struct libmv_TrackRegionOptions;
99
100 void tracking_configure_tracker(const MovieTrackingTrack *track, float *mask,
101                                 struct libmv_TrackRegionOptions *options);
102
103 struct MovieTrackingMarker *tracking_get_keyframed_marker(
104         struct MovieTrackingTrack *track,
105         int current_frame,
106         bool backwards);
107
108 /*********************** Masking *************************/
109
110 float *tracking_track_get_mask_for_region(int frame_width, int frame_height,
111                                           const float region_min[2],
112                                           const float region_max[2],
113                                           MovieTrackingTrack *track);
114
115 /*********************** Frame accessr *************************/
116
117 struct libmv_FrameAccessor;
118
119 #define MAX_ACCESSOR_CLIP 64
120 typedef struct TrackingImageAccessor {
121         struct MovieCache *cache;
122         struct MovieClip *clips[MAX_ACCESSOR_CLIP];
123         int num_clips;
124         struct MovieTrackingTrack **tracks;
125         int num_tracks;
126         int start_frame;
127         struct libmv_FrameAccessor *libmv_accessor;
128         SpinLock cache_lock;
129 } TrackingImageAccessor;
130
131 TrackingImageAccessor *tracking_image_accessor_new(MovieClip *clips[MAX_ACCESSOR_CLIP],
132                                                    int num_clips,
133                                                    MovieTrackingTrack **tracks,
134                                                    int num_tracks,
135                                                    int start_frame);
136 void tracking_image_accessor_destroy(TrackingImageAccessor *accessor);
137
138 #endif  /* __TRACKING_PRIVATE_H__ */