Fix T52531: Blender 2D stabilisation node issue when autoscale is selected

Threading conflict, should be safe for 2.79.
This commit is contained in:
Sergey Sharybin 2017-09-04 16:40:55 +02:00 committed by Bastien Montagne
parent fbb4be061c
commit 82466852fe
2 changed files with 44 additions and 39 deletions

View File

@ -28,55 +28,58 @@ extern "C" {
MovieClipAttributeOperation::MovieClipAttributeOperation() : NodeOperation()
{
this->addOutputSocket(COM_DT_VALUE);
this->m_valueSet = false;
this->m_framenumber = 0;
this->m_attribute = MCA_X;
this->m_invert = false;
}
void MovieClipAttributeOperation::initExecution()
{
float loc[2], scale, angle;
loc[0] = 0.0f;
loc[1] = 0.0f;
scale = 1.0f;
angle = 0.0f;
int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(
this->m_clip, this->m_framenumber);
BKE_tracking_stabilization_data_get(this->m_clip,
clip_framenr,
getWidth(), getHeight(),
loc, &scale, &angle);
switch (this->m_attribute) {
case MCA_SCALE:
this->m_value = scale;
break;
case MCA_ANGLE:
this->m_value = angle;
break;
case MCA_X:
this->m_value = loc[0];
break;
case MCA_Y:
this->m_value = loc[1];
break;
}
if (this->m_invert) {
if (this->m_attribute != MCA_SCALE) {
this->m_value = -this->m_value;
}
else {
this->m_value = 1.0f / this->m_value;
}
}
}
void MovieClipAttributeOperation::executePixelSampled(float output[4],
float /*x*/, float /*y*/,
PixelSampler /*sampler*/)
{
/* TODO(sergey): This code isn't really thread-safe. */
if (!this->m_valueSet) {
float loc[2], scale, angle;
loc[0] = 0.0f;
loc[1] = 0.0f;
scale = 1.0f;
angle = 0.0f;
if (this->m_clip) {
int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_clip, this->m_framenumber);
BKE_tracking_stabilization_data_get(this->m_clip, clip_framenr, getWidth(), getHeight(), loc, &scale, &angle);
}
switch (this->m_attribute) {
case MCA_SCALE:
this->m_value = scale;
break;
case MCA_ANGLE:
this->m_value = angle;
break;
case MCA_X:
this->m_value = loc[0];
break;
case MCA_Y:
this->m_value = loc[1];
break;
}
if (this->m_invert) {
if (this->m_attribute != MCA_SCALE) {
this->m_value = -this->m_value;
}
else {
this->m_value = 1.0f / this->m_value;
}
}
this->m_valueSet = true;
}
output[0] = this->m_value;
}
void MovieClipAttributeOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
void MovieClipAttributeOperation::determineResolution(
unsigned int resolution[2],
unsigned int preferredResolution[2])
{
resolution[0] = preferredResolution[0];
resolution[1] = preferredResolution[1];

View File

@ -39,16 +39,18 @@ class MovieClipAttributeOperation : public NodeOperation {
private:
MovieClip *m_clip;
float m_value;
bool m_valueSet;
int m_framenumber;
bool m_invert;
MovieClipAttribute m_attribute;
public:
/**
* Default constructor
*/
MovieClipAttributeOperation();
void initExecution();
/**
* the inner loop of this program
*/