36 int2 calibration_size)
37 : camera(camera), size(size), type(type), calibration_size(calibration_size)
50 a.type ==
b.type && a.calibration_size ==
b.calibration_size;
61 &movie_clip->
tracking, calibration_size.x, calibration_size.y);
65 for (const int64_t y : sub_y_range) {
66 for (const int64_t x : IndexRange(size.x)) {
72 float2 coordinates = ((float2(x, y) + 0.5f) / float2(size)) * float2(calibration_size);
74 if (type == DistortionType::Undistort) {
75 BKE_tracking_distortion_undistort_v2(distortion, coordinates, coordinates);
78 BKE_tracking_distortion_distort_v2(distortion, coordinates, coordinates);
84 distortion_grid[y * size.x + x] = coordinates / float2(calibration_size);
98 *distortion_grid.data());
101DistortionGrid::~DistortionGrid()
106void DistortionGrid::bind_as_texture(
GPUShader *shader,
const char *texture_name)
const
112void DistortionGrid::unbind_as_texture()
const
121void DistortionGridContainer::reset()
124 map_.remove_if([](
auto item) {
return !item.value->needed; });
128 for (
auto &value : map_.values()) {
129 value->needed =
false;
151 auto &distortion_grid = *map_.lookup_or_add_cb(key, [&]() {
152 return std::make_unique<DistortionGrid>(context, movie_clip, size, type, calibration_size);
155 distortion_grid.needed =
true;
156 return distortion_grid;
void BKE_movieclip_user_set_frame(struct MovieClipUser *user, int framenr)
void BKE_movieclip_get_size(struct MovieClip *clip, const struct MovieClipUser *user, int *r_width, int *r_height)
bool BKE_tracking_camera_distortion_equal(const struct MovieTrackingCamera *a, const struct MovieTrackingCamera *b)
void BKE_tracking_distortion_free(struct MovieDistortion *distortion)
uint64_t BKE_tracking_camera_distortion_hash(const struct MovieTrackingCamera *camera)
struct MovieDistortion * BKE_tracking_distortion_new(struct MovieTracking *tracking, int calibration_width, int calibration_height)
#define DNA_struct_default_get(struct_name)
int GPU_shader_get_sampler_binding(GPUShader *shader, const char *name)
void GPU_texture_bind(GPUTexture *texture, int unit)
GPUTexture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_texture_free(GPUTexture *texture)
void GPU_texture_unbind(GPUTexture *texture)
@ GPU_TEXTURE_USAGE_SHADER_READ
struct GPUShader GPUShader
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
DistortionGridKey(const MovieTrackingCamera &camera, int2 size, DistortionType type, int2 calibration_size)
DistortionGrid(Context &context, MovieClip *movie_clip, int2 size, DistortionType type, int2 calibration_size)
static eGPUTextureFormat gpu_texture_format(ResultType type, ResultPrecision precision)
local_group_size(16, 16) .push_constant(Type b
bool operator==(const BokehKernelKey &a, const BokehKernelKey &b)
static int2 get_movie_clip_size(MovieClip *movie_clip, int frame_number)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
uint64_t get_default_hash(const T &v)
unsigned __int64 uint64_t
struct MovieTracking tracking
MovieTrackingCamera camera