Merge branch 'blender2.7'
[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, bool is_camera, int num_tracks, int customdata_size);
59 int tracks_map_get_size(struct TracksMap *map);
60 void tracks_map_get_indexed_element(struct TracksMap *map, int index, struct MovieTrackingTrack **track, void **customdata);
61 void tracks_map_insert(struct TracksMap *map, struct MovieTrackingTrack *track, void *customdata);
62 void tracks_map_free(struct TracksMap *map, void (*customdata_free)(void *customdata));
63 void tracks_map_merge(struct TracksMap *map, struct MovieTracking *tracking);
64
65 /*********************** Space transformation functions *************************/
66
67 void tracking_get_search_origin_frame_pixel(int frame_width, int frame_height,
68                                             const struct MovieTrackingMarker *marker,
69                                             float frame_pixel[2]);
70
71 void tracking_get_marker_coords_for_tracking(int frame_width, int frame_height,
72                                              const struct MovieTrackingMarker *marker,
73                                              double search_pixel_x[5], double search_pixel_y[5]);
74
75 void tracking_set_marker_coords_from_tracking(int frame_width, int frame_height, struct MovieTrackingMarker *marker,
76                                               const double search_pixel_x[5], const double search_pixel_y[5]);
77
78 /*********************** General purpose utility functions *************************/
79
80 void tracking_marker_insert_disabled(struct MovieTrackingTrack *track, const struct MovieTrackingMarker *ref_marker,
81                                      bool before, bool overwrite);
82
83 void tracking_cameraIntrinscisOptionsFromTracking(struct MovieTracking *tracking,
84                                                   int calibration_width, int calibration_height,
85                                                   struct libmv_CameraIntrinsicsOptions *camera_intrinsics_options);
86
87 void tracking_trackingCameraFromIntrinscisOptions(struct MovieTracking *tracking,
88                                                   const struct libmv_CameraIntrinsicsOptions *camera_intrinsics_options);
89
90 struct libmv_TrackRegionOptions;
91
92 void tracking_configure_tracker(const MovieTrackingTrack *track, float *mask,
93                                 struct libmv_TrackRegionOptions *options);
94
95 struct MovieTrackingMarker *tracking_get_keyframed_marker(
96         struct MovieTrackingTrack *track,
97         int current_frame,
98         bool backwards);
99
100 /*********************** Masking *************************/
101
102 float *tracking_track_get_mask_for_region(int frame_width, int frame_height,
103                                           const float region_min[2],
104                                           const float region_max[2],
105                                           MovieTrackingTrack *track);
106
107 /*********************** Frame accessr *************************/
108
109 struct libmv_FrameAccessor;
110
111 #define MAX_ACCESSOR_CLIP 64
112 typedef struct TrackingImageAccessor {
113         struct MovieCache *cache;
114         struct MovieClip *clips[MAX_ACCESSOR_CLIP];
115         int num_clips;
116         struct MovieTrackingTrack **tracks;
117         int num_tracks;
118         int start_frame;
119         struct libmv_FrameAccessor *libmv_accessor;
120         SpinLock cache_lock;
121 } TrackingImageAccessor;
122
123 TrackingImageAccessor *tracking_image_accessor_new(MovieClip *clips[MAX_ACCESSOR_CLIP],
124                                                    int num_clips,
125                                                    MovieTrackingTrack **tracks,
126                                                    int num_tracks,
127                                                    int start_frame);
128 void tracking_image_accessor_destroy(TrackingImageAccessor *accessor);
129
130 #endif  /* __TRACKING_PRIVATE_H__ */