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 DNA
22  */
23 
24 #pragma once
25 
26 #include "DNA_ID.h"
27 #include "DNA_color_types.h" /* for color management */
28 #include "DNA_tracking_types.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 struct AnimData;
35 struct ImBuf;
36 struct MovieClipProxy;
37 struct MovieTrackingMarker;
38 struct MovieTrackingTrack;
39 struct anim;
40 struct bGPdata;
41 
42 typedef struct MovieClipUser {
43   /** Current frame number. */
44   int framenr;
45   /** Proxy render size. */
46   short render_size, render_flag;
47 } MovieClipUser;
48 
49 typedef struct MovieClipProxy {
50   /** 768=FILE_MAXDIR custom directory for index and proxy files (defaults to BL_proxy). */
51   char dir[768];
52 
53   /** Time code in use. */
54   short tc;
55   /** Proxy build quality. */
56   short quality;
57   /** Size flags (see below) of all proxies to build. */
58   short build_size_flag;
59   /** Time code flags (see below) of all tc indices to build. */
60   short build_tc_flag;
61 } MovieClipProxy;
62 
63 typedef struct MovieClip_RuntimeGPUTexture {
64   void *next, *prev;
65   MovieClipUser user;
66   /** Not written in file 3 = TEXTARGET_COUNT. */
67   struct GPUTexture *gputexture[3];
68 } MovieClip_RuntimeGPUTexture;
69 
70 typedef struct MovieClip_Runtime {
71   struct ListBase gputextures;
72 } MovieClip_Runtime;
73 
74 typedef struct MovieClip {
75   ID id;
76   /** Animation data (must be immediately after id for utilities to use it). */
77   struct AnimData *adt;
78 
79   /** File path, 1024 = FILE_MAX. */
80   char filepath[1024];
81 
82   /** Sequence or movie. */
83   int source;
84   /** Last accessed frame number. */
85   int lastframe;
86   /** Size of last accessed frame. */
87   int lastsize[2];
88 
89   /** Display aspect. */
90   float aspx, aspy;
91 
92   /** Movie source data. */
93   struct anim *anim;
94   /** Cache for different stuff, not in file. */
95   struct MovieClipCache *cache;
96   /** Grease pencil data. */
97   struct bGPdata *gpd;
98 
99   /** Data for SfM tracking. */
100   struct MovieTracking tracking;
101   /**
102    * Context of tracking job used to synchronize data
103    * like frame-number in SpaceClip clip user.
104    */
105   void *tracking_context;
106 
107   /** Proxy to clip data. */
108   struct MovieClipProxy proxy;
109   int flag;
110 
111   /** Length of movie. */
112   int len;
113 
114   /**
115    * Scene frame number footage starts playing at affects all data
116    * which is associated with a clip such as motion tracking,
117    * camera Reconstruction and so.
118    */
119   int start_frame;
120   /**
121    * Offset which is adding to a file number when reading frame from a file.
122    * affects only a way how scene frame is mapping to a file name and not
123    * touches other data associated with a clip. */
124   int frame_offset;
125 
126   /* color management */
127   ColorManagedColorspaceSettings colorspace_settings;
128 
129   struct MovieClip_Runtime runtime;
130 } MovieClip;
131 
132 typedef struct MovieClipScopes {
133   /** 1 means scopes are ok and recalculation is unneeded. */
134   short ok;
135   /** Whether track's mask should be applied on preview. */
136   short use_track_mask;
137   /** Height of track preview widget. */
138   int track_preview_height;
139   /** Width and height of frame for which scopes are calculated. */
140   int frame_width, frame_height;
141   /** Undistorted position of marker used for pattern sampling. */
142   struct MovieTrackingMarker undist_marker;
143   /** Search area of a track. */
144   struct ImBuf *track_search;
145   /** #ImBuf displayed in track preview. */
146   struct ImBuf *track_preview;
147   /** Sub-pizel position of marker in track ImBuf. */
148   float track_pos[2];
149   /** Active track is disabled, special notifier should be drawn. */
150   short track_disabled;
151   /** Active track is locked, no transformation should be allowed. */
152   short track_locked;
153   /** Frame number scopes are created for. */
154   int framenr;
155   /** Track scopes are created for. */
156   struct MovieTrackingTrack *track;
157   /** Marker scopes are created for. */
158   struct MovieTrackingMarker *marker;
159   /** Scale used for sliding from previewe area. */
160   float slide_scale[2];
161 } MovieClipScopes;
162 
163 /* MovieClipProxy->build_size_flag */
164 enum {
165   MCLIP_PROXY_SIZE_25 = (1 << 0),
166   MCLIP_PROXY_SIZE_50 = (1 << 1),
167   MCLIP_PROXY_SIZE_75 = (1 << 2),
168   MCLIP_PROXY_SIZE_100 = (1 << 3),
169   MCLIP_PROXY_UNDISTORTED_SIZE_25 = (1 << 4),
170   MCLIP_PROXY_UNDISTORTED_SIZE_50 = (1 << 5),
171   MCLIP_PROXY_UNDISTORTED_SIZE_75 = (1 << 6),
172   MCLIP_PROXY_UNDISTORTED_SIZE_100 = (1 << 7),
173 };
174 
175 /* MovieClip->source */
176 enum {
177   MCLIP_SRC_SEQUENCE = 1,
178   MCLIP_SRC_MOVIE = 2,
179 };
180 
181 /* MovieClip->flag */
182 enum {
183   MCLIP_USE_PROXY = (1 << 0),
184   MCLIP_USE_PROXY_CUSTOM_DIR = (1 << 1),
185   /* MCLIP_CUSTOM_START_FRAME    = (1 << 2), */ /* UNUSED */
186   MCLIP_DATA_EXPAND = (1 << 3),
187 
188   MCLIP_TIMECODE_FLAGS = (MCLIP_USE_PROXY | MCLIP_USE_PROXY_CUSTOM_DIR),
189 };
190 
191 /* MovieClip->render_size */
192 enum {
193   MCLIP_PROXY_RENDER_SIZE_FULL = 0,
194   MCLIP_PROXY_RENDER_SIZE_25 = 1,
195   MCLIP_PROXY_RENDER_SIZE_50 = 2,
196   MCLIP_PROXY_RENDER_SIZE_75 = 3,
197   MCLIP_PROXY_RENDER_SIZE_100 = 4,
198 };
199 
200 /* MovieClip->render_flag */
201 enum {
202   MCLIP_PROXY_RENDER_UNDISTORT = 1,
203   /** Use original, if proxy is not found. */
204   MCLIP_PROXY_RENDER_USE_FALLBACK_RENDER = 2,
205 };
206 
207 #ifdef __cplusplus
208 }
209 #endif
210