diff options
Diffstat (limited to 'source/blender/compositor')
10 files changed, 667 insertions, 0 deletions
diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt index c1b99274bed..a119a89c842 100644 --- a/source/blender/compositor/CMakeLists.txt +++ b/source/blender/compositor/CMakeLists.txt @@ -184,6 +184,9 @@ set(SRC nodes/COM_GlareNode.cpp nodes/COM_GlareNode.h + nodes/COM_PlaneTrackDeformNode.cpp + nodes/COM_PlaneTrackDeformNode.h + nodes/COM_CropNode.cpp nodes/COM_CropNode.h operations/COM_CropOperation.cpp @@ -595,6 +598,12 @@ set(SRC operations/COM_ProjectorLensDistortionOperation.h operations/COM_ScreenLensDistortionOperation.cpp operations/COM_ScreenLensDistortionOperation.h + operations/COM_PlaneTrackCommonOperation.cpp + operations/COM_PlaneTrackCommonOperation.h + operations/COM_PlaneTrackMaskOperation.cpp + operations/COM_PlaneTrackMaskOperation.h + operations/COM_PlaneTrackWarpImageOperation.cpp + operations/COM_PlaneTrackWarpImageOperation.h #Filter operations operations/COM_ConvolutionFilterOperation.h diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp index 80ae952b87f..db0cdd1692e 100644 --- a/source/blender/compositor/intern/COM_Converter.cpp +++ b/source/blender/compositor/intern/COM_Converter.cpp @@ -121,6 +121,7 @@ #include "COM_ViewerNode.h" #include "COM_ZCombineNode.h" #include "COM_PixelateNode.h" +#include "COM_PlaneTrackDeformNode.h" Node *Converter::convert(bNode *b_node, bool fast) { @@ -402,6 +403,9 @@ Node *Converter::convert(bNode *b_node, bool fast) case CMP_NODE_PIXELATE: node = new PixelateNode(b_node); break; + case CMP_NODE_PLANETRACKDEFORM: + node = new PlaneTrackDeformNode(b_node); + break; default: node = new MuteNode(b_node); break; diff --git a/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp b/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp new file mode 100644 index 00000000000..d6434c26c7d --- /dev/null +++ b/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp @@ -0,0 +1,81 @@ +/* + * Copyright 2013, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + * Sergey Sharybin + */ + +#include "COM_PlaneTrackDeformNode.h" +#include "COM_ExecutionSystem.h" + +#include "COM_PlaneTrackMaskOperation.h" +#include "COM_PlaneTrackWarpImageOperation.h" + +extern "C" { + #include "BKE_node.h" + #include "BKE_movieclip.h" + #include "BKE_tracking.h" +} + +PlaneTrackDeformNode::PlaneTrackDeformNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void PlaneTrackDeformNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) +{ + InputSocket *input_image = this->getInputSocket(0); + + OutputSocket *output_warped_image = this->getOutputSocket(0); + OutputSocket *output_plane = this->getOutputSocket(1); + + bNode *editorNode = this->getbNode(); + MovieClip *clip = (MovieClip *) editorNode->id; + + NodePlaneTrackDeformData *data = (NodePlaneTrackDeformData *) editorNode->storage; + + int frame_number = context->getFramenumber(); + + if (output_warped_image->isConnected()) { + PlaneTrackWarpImageOperation *warp_image_operation = new PlaneTrackWarpImageOperation(); + + warp_image_operation->setMovieClip(clip); + warp_image_operation->setTrackingObject(data->tracking_object); + warp_image_operation->setPlaneTrackName(data->plane_track_name); + warp_image_operation->setFramenumber(frame_number); + + input_image->relinkConnections(warp_image_operation->getInputSocket(0), 0, graph); + output_warped_image->relinkConnections(warp_image_operation->getOutputSocket()); + + graph->addOperation(warp_image_operation); + } + + if (output_plane->isConnected()) { + PlaneTrackMaskOperation *plane_mask_operation = new PlaneTrackMaskOperation(); + + plane_mask_operation->setMovieClip(clip); + plane_mask_operation->setTrackingObject(data->tracking_object); + plane_mask_operation->setPlaneTrackName(data->plane_track_name); + plane_mask_operation->setFramenumber(frame_number); + + output_plane->relinkConnections(plane_mask_operation->getOutputSocket()); + + graph->addOperation(plane_mask_operation); + } +} diff --git a/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.h b/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.h new file mode 100644 index 00000000000..cf173cd19f9 --- /dev/null +++ b/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2013, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Sergey Sharybin + */ + +#include "COM_Node.h" +#include "DNA_node_types.h" + +extern "C" { + #include "DNA_movieclip_types.h" + #include "DNA_node_types.h" +} + +/** + * @brief PlaneTrackDeformNode + * @ingroup Node + */ +class PlaneTrackDeformNode : public Node { +public: + PlaneTrackDeformNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext *context); +}; diff --git a/source/blender/compositor/operations/COM_PlaneTrackCommonOperation.cpp b/source/blender/compositor/operations/COM_PlaneTrackCommonOperation.cpp new file mode 100644 index 00000000000..51e803f696b --- /dev/null +++ b/source/blender/compositor/operations/COM_PlaneTrackCommonOperation.cpp @@ -0,0 +1,95 @@ +/* + * Copyright 2013, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Sergey Sharybin + */ + +#include "COM_PlaneTrackMaskOperation.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_listbase.h" +#include "BLI_math.h" +#include "BLI_math_color.h" + +extern "C" { + #include "BKE_movieclip.h" + #include "BKE_node.h" + #include "BKE_tracking.h" +} + +PlaneTrackCommonOperation::PlaneTrackCommonOperation() : NodeOperation() +{ + this->m_movieClip = NULL; + this->m_framenumber = 0; + this->m_trackingObjectName[0] = '\0'; + this->m_planeTrackName[0] = '\0'; +} + +void PlaneTrackCommonOperation::initExecution() +{ + MovieTracking *tracking; + MovieTrackingObject *object; + + memset(this->m_corners, 0, sizeof(this->m_corners)); + memset(this->m_frameSpaceCorners, 0, sizeof(this->m_frameSpaceCorners)); + + if (!this->m_movieClip) + return; + + tracking = &this->m_movieClip->tracking; + + object = BKE_tracking_object_get_named(tracking, this->m_trackingObjectName); + if (object) { + MovieTrackingPlaneTrack *plane_track; + + plane_track = BKE_tracking_plane_track_get_named(tracking, object, this->m_planeTrackName); + + if (plane_track) { + MovieTrackingPlaneMarker *plane_marker; + int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip, this->m_framenumber); + + plane_marker = BKE_tracking_plane_marker_get(plane_track, clip_framenr); + memcpy(this->m_corners, plane_marker->corners, sizeof(this->m_corners)); + } + } + + for (int i = 0; i < 4; i++) { + this->m_frameSpaceCorners[i][0] = this->m_corners[i][0] * this->getWidth(); + this->m_frameSpaceCorners[i][1] = this->m_corners[i][1] * this->getHeight(); + } +} + +void PlaneTrackCommonOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]) +{ + NodeOperation::determineResolution(resolution, preferredResolution); + + resolution[0] = 0; + resolution[1] = 0; + + if (this->m_movieClip) { + int width, height; + MovieClipUser user = {0}; + + BKE_movieclip_user_set_frame(&user, this->m_framenumber); + BKE_movieclip_get_size(this->m_movieClip, &user, &width, &height); + + resolution[0] = width; + resolution[1] = height; + } +} diff --git a/source/blender/compositor/operations/COM_PlaneTrackCommonOperation.h b/source/blender/compositor/operations/COM_PlaneTrackCommonOperation.h new file mode 100644 index 00000000000..705bdf4bd81 --- /dev/null +++ b/source/blender/compositor/operations/COM_PlaneTrackCommonOperation.h @@ -0,0 +1,62 @@ + +/* + * Copyright 2013, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Sergey Sharybin + */ + +#ifndef _COM_PlaneTrackCommonOperation_h +#define _COM_PlaneTrackCommonOperation_h + +#include <string.h> + +#include "COM_NodeOperation.h" + +#include "DNA_movieclip_types.h" +#include "DNA_tracking_types.h" + +#include "BLI_listbase.h" +#include "BLI_string.h" + +class PlaneTrackCommonOperation : public NodeOperation { +protected: + MovieClip *m_movieClip; + int m_framenumber; + char m_trackingObjectName[64]; + char m_planeTrackName[64]; + + float m_corners[4][2]; /* Corners coordinates in normalized space. */ + float m_frameSpaceCorners[4][2]; /* Corners coordinates in pixel space. */ + + /** + * Determine the output resolution. The resolution is retrieved from the Renderer + */ + void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]); + +public: + PlaneTrackCommonOperation(); + + void setMovieClip(MovieClip *clip) {this->m_movieClip = clip;} + void setTrackingObject(char *object) { BLI_strncpy(this->m_trackingObjectName, object, sizeof(this->m_trackingObjectName)); } + void setPlaneTrackName(char *plane_track) { BLI_strncpy(this->m_planeTrackName, plane_track, sizeof(this->m_planeTrackName)); } + void setFramenumber(int framenumber) {this->m_framenumber = framenumber;} + + void initExecution(); +}; + +#endif diff --git a/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.cpp b/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.cpp new file mode 100644 index 00000000000..fe794cb769f --- /dev/null +++ b/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.cpp @@ -0,0 +1,69 @@ +/* + * Copyright 2013, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Sergey Sharybin + */ + +#include "COM_PlaneTrackMaskOperation.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_listbase.h" +#include "BLI_math.h" +#include "BLI_math_color.h" + +extern "C" { + #include "BLI_jitter.h" + + #include "BKE_movieclip.h" + #include "BKE_node.h" + #include "BKE_tracking.h" +} + +PlaneTrackMaskOperation::PlaneTrackMaskOperation() : PlaneTrackCommonOperation() +{ + this->addOutputSocket(COM_DT_VALUE); +} + +void PlaneTrackMaskOperation::initExecution() +{ + PlaneTrackCommonOperation::initExecution(); + + const int osa = 8; + this->m_osa = osa; + BLI_jitter_init(this->m_jitter[0], osa); +} + +void PlaneTrackMaskOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +{ + float point[2]; + + int inside_counter = 0; + for (int sample = 0; sample < this->m_osa; sample++) { + point[0] = x + this->m_jitter[sample][0]; + point[1] = y + this->m_jitter[sample][1]; + + if (isect_point_tri_v2(point, this->m_frameSpaceCorners[0], this->m_frameSpaceCorners[1], this->m_frameSpaceCorners[2]) || + isect_point_tri_v2(point, this->m_frameSpaceCorners[0], this->m_frameSpaceCorners[2], this->m_frameSpaceCorners[3])) + { + inside_counter++; + } + } + + output[0] = (float) inside_counter / this->m_osa; +} diff --git a/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.h b/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.h new file mode 100644 index 00000000000..db32f9830e0 --- /dev/null +++ b/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.h @@ -0,0 +1,49 @@ + +/* + * Copyright 2013, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Sergey Sharybin + */ + +#ifndef _COM_PlaneTrackMaskOperation_h +#define _COM_PlaneTrackMaskOperation_h + +#include <string.h> + +#include "COM_PlaneTrackCommonOperation.h" + +#include "DNA_movieclip_types.h" +#include "DNA_tracking_types.h" + +#include "BLI_listbase.h" +#include "BLI_string.h" + +class PlaneTrackMaskOperation : public PlaneTrackCommonOperation { +protected: + int m_osa; + float m_jitter[32][2]; + +public: + PlaneTrackMaskOperation(); + + void initExecution(); + + void executePixel(float output[4], float x, float y, PixelSampler sampler); +}; + +#endif diff --git a/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.cpp b/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.cpp new file mode 100644 index 00000000000..9bbf45682f2 --- /dev/null +++ b/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.cpp @@ -0,0 +1,207 @@ +/* + * Copyright 2013, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Sergey Sharybin + */ + +#include "COM_PlaneTrackWarpImageOperation.h" +#include "COM_ReadBufferOperation.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_listbase.h" +#include "BLI_math.h" +#include "BLI_math_color.h" + +extern "C" { + #include "BLI_jitter.h" + + #include "BKE_movieclip.h" + #include "BKE_node.h" + #include "BKE_tracking.h" +} + +BLI_INLINE bool isPointInsideQuad(const float x, const float y, const float corners[4][2]) +{ + float point[2]; + + point[0] = x; + point[1] = y; + + return isect_point_tri_v2(point, corners[0], corners[1], corners[2]) || + isect_point_tri_v2(point, corners[0], corners[2], corners[3]); +} + +BLI_INLINE bool resolveUV(const float x, const float y, const float corners[4][2], float uv[2]) +{ + float point[2]; + bool inside; + + inside = isPointInsideQuad(x, y, corners); + + point[0] = x; + point[1] = y; + + /* Use reverse bilinear to get UV coordinates within original frame */ + resolve_quad_uv(uv, point, corners[0], corners[1], corners[2], corners[3]); + + return inside; +} + +BLI_INLINE void resolveUVAndDxDy(const float x, const float y, const float corners[4][2], + float *u_r, float *v_r, float *dx_r, float *dy_r) +{ + float inputUV[2]; + float uv_a[2], uv_b[2]; + + float dx, dy; + float uv_l, uv_r; + float uv_u, uv_d; + + bool ok1, ok2; + + resolveUV(x, y, corners, inputUV); + + /* adaptive sampling, red (U) channel */ + ok1 = resolveUV(x - 1, y, corners, uv_a); + ok2 = resolveUV(x + 1, y, corners, uv_b); + uv_l = ok1 ? fabsf(inputUV[0] - uv_a[0]) : 0.0f; + uv_r = ok2 ? fabsf(inputUV[0] - uv_b[0]) : 0.0f; + + dx = 0.5f * (uv_l + uv_r); + + /* adaptive sampling, green (V) channel */ + ok1 = resolveUV(x, y - 1, corners, uv_a); + ok2 = resolveUV(x, y + 1, corners, uv_b); + uv_u = ok1 ? fabsf(inputUV[1] - uv_a[1]) : 0.f; + uv_d = ok2 ? fabsf(inputUV[1] - uv_b[1]) : 0.f; + + dy = 0.5f * (uv_u + uv_d); + + /* more adaptive sampling, red and green (UV) channels */ + ok1 = resolveUV(x - 1, y - 1, corners, uv_a); + ok2 = resolveUV(x - 1, y + 1, corners, uv_b); + uv_l = ok1 ? fabsf(inputUV[0] - uv_a[0]) : 0.f; + uv_r = ok2 ? fabsf(inputUV[0] - uv_b[0]) : 0.f; + uv_u = ok1 ? fabsf(inputUV[1] - uv_a[1]) : 0.f; + uv_d = ok2 ? fabsf(inputUV[1] - uv_b[1]) : 0.f; + + dx += 0.25f * (uv_l + uv_r); + dy += 0.25f * (uv_u + uv_d); + + ok1 = resolveUV(x + 1, y - 1, corners, uv_a); + ok2 = resolveUV(x + 1, y + 1, corners, uv_b); + uv_l = ok1 ? fabsf(inputUV[0] - uv_a[0]) : 0.f; + uv_r = ok2 ? fabsf(inputUV[0] - uv_b[0]) : 0.f; + uv_u = ok1 ? fabsf(inputUV[1] - uv_a[1]) : 0.f; + uv_d = ok2 ? fabsf(inputUV[1] - uv_b[1]) : 0.f; + + dx += 0.25f * (uv_l + uv_r); + dy += 0.25f * (uv_u + uv_d); + + /* should use mipmap */ + *dx_r = min(dx, 0.2f); + *dy_r = min(dy, 0.2f); + + *u_r = inputUV[0]; + *v_r = inputUV[1]; +} + +PlaneTrackWarpImageOperation::PlaneTrackWarpImageOperation() : PlaneTrackCommonOperation() +{ + this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); + this->addOutputSocket(COM_DT_COLOR); + this->m_pixelReader = NULL; + this->setComplex(true); +} + +void PlaneTrackWarpImageOperation::initExecution() +{ + PlaneTrackCommonOperation::initExecution(); + + this->m_pixelReader = this->getInputSocketReader(0); + + const int osa = 8; + this->m_osa = osa; + BLI_jitter_init(this->m_jitter[0], osa); +} + +void PlaneTrackWarpImageOperation::deinitExecution() +{ + this->m_pixelReader = NULL; +} + +void PlaneTrackWarpImageOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +{ + float color_accum[4]; + + zero_v4(color_accum); + for (int sample = 0; sample < this->m_osa; sample++) { + float current_x = x + this->m_jitter[sample][0], + current_y = y + this->m_jitter[sample][1]; + if (isPointInsideQuad(current_x, current_y, this->m_frameSpaceCorners)) { + float current_color[4]; + float u, v, dx, dy; + + resolveUVAndDxDy(current_x, current_y, this->m_frameSpaceCorners, &u, &v, &dx, &dy); + + u *= this->m_pixelReader->getWidth(); + v *= this->m_pixelReader->getHeight(); + + this->m_pixelReader->read(current_color, u, v, dx, dy, COM_PS_BICUBIC); + premul_to_straight_v4(current_color); + add_v4_v4(color_accum, current_color); + } + } + + mul_v4_v4fl(output, color_accum, 1.0f / this->m_osa); + straight_to_premul_v4(output); +} + +bool PlaneTrackWarpImageOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) +{ + float frame_space_corners[4][2]; + + for (int i = 0; i < 4; i++) { + frame_space_corners[i][0] = this->m_corners[i][0] * this->getWidth(); + frame_space_corners[i][1] = this->m_corners[i][1] * this->getHeight(); + } + + float UVs[4][2]; + + /* TODO(sergey): figure out proper way to do this. */ + resolveUV(input->xmin - 2, input->ymin - 2, frame_space_corners, UVs[0]); + resolveUV(input->xmax + 2, input->ymin - 2, frame_space_corners, UVs[1]); + resolveUV(input->xmax + 2, input->ymax + 2, frame_space_corners, UVs[2]); + resolveUV(input->xmin - 2, input->ymax + 2, frame_space_corners, UVs[3]); + + float min[2], max[2]; + INIT_MINMAX2(min, max); + for (int i = 0; i < 4; i++) { + minmax_v2v2_v2(min, max, UVs[i]); + } + + rcti newInput; + + newInput.xmin = min[0] * readOperation->getWidth() - 1; + newInput.ymin = min[1] * readOperation->getHeight() - 1; + newInput.xmax = max[0] * readOperation->getWidth() + 1; + newInput.ymax = max[1] * readOperation->getHeight() + 1; + + return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); +} diff --git a/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.h b/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.h new file mode 100644 index 00000000000..a92ff3f9ddf --- /dev/null +++ b/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.h @@ -0,0 +1,53 @@ + +/* + * Copyright 2013, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Sergey Sharybin + */ + +#ifndef _COM_PlaneTrackWarpImageOperation_h +#define _COM_PlaneTrackWarpImageOperation_h + +#include <string.h> + +#include "COM_PlaneTrackCommonOperation.h" + +#include "DNA_movieclip_types.h" +#include "DNA_tracking_types.h" + +#include "BLI_listbase.h" +#include "BLI_string.h" + +class PlaneTrackWarpImageOperation : public PlaneTrackCommonOperation { +protected: + SocketReader *m_pixelReader; + int m_osa; + float m_jitter[32][2]; + +public: + PlaneTrackWarpImageOperation(); + + void initExecution(); + void deinitExecution(); + + void executePixel(float output[4], float x, float y, PixelSampler sampler); + + bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); +}; + +#endif |