Originally issue was discovered when using stabilization and movie distortion nodes, but in fact issue was caused by render layer node always doing nearest interpolation. Now made it so this node will respect sampler passed to it's executePixel function and do an interpolation. Added two new functions to do bilinear/bicubic interpolation in float buffer with variable number of components per element, so it could interpolate 1, 3 and 4 component vectors. This functions currently mostly duplicates the same functions from imageprocess.c and it should actually be de-duplicated. Think it's ok to leave a bit of time with such duplication, since functions should be generalized one more time to support byte buffers, which could backfire on readability. Also removed mark as complex from stabilization node, which isn't needed sine int fact this node is not complex.
103 lines
3.2 KiB
C++
103 lines
3.2 KiB
C++
/*
|
|
* Copyright 2011, 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
|
|
*/
|
|
|
|
#ifndef _COM_ScaleOperation_h_
|
|
#define _COM_ScaleOperation_h_
|
|
|
|
#include "COM_NodeOperation.h"
|
|
|
|
class BaseScaleOperation : public NodeOperation {
|
|
public:
|
|
void setSampler(PixelSampler sampler) { this->m_sampler = (int) sampler; }
|
|
|
|
protected:
|
|
BaseScaleOperation();
|
|
|
|
PixelSampler getEffectiveSampler(PixelSampler sampler) { return (m_sampler == -1) ? sampler : (PixelSampler) m_sampler; }
|
|
|
|
int m_sampler;
|
|
};
|
|
|
|
class ScaleOperation : public BaseScaleOperation {
|
|
private:
|
|
SocketReader *m_inputOperation;
|
|
SocketReader *m_inputXOperation;
|
|
SocketReader *m_inputYOperation;
|
|
float m_centerX;
|
|
float m_centerY;
|
|
public:
|
|
ScaleOperation();
|
|
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
|
|
void executePixel(float output[4], float x, float y, PixelSampler sampler);
|
|
|
|
void initExecution();
|
|
void deinitExecution();
|
|
};
|
|
|
|
class ScaleAbsoluteOperation : public BaseScaleOperation {
|
|
SocketReader *m_inputOperation;
|
|
SocketReader *m_inputXOperation;
|
|
SocketReader *m_inputYOperation;
|
|
float m_centerX;
|
|
float m_centerY;
|
|
|
|
public:
|
|
ScaleAbsoluteOperation();
|
|
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
|
|
void executePixel(float output[4], float x, float y, PixelSampler sampler);
|
|
|
|
void initExecution();
|
|
void deinitExecution();
|
|
};
|
|
|
|
class ScaleFixedSizeOperation : public BaseScaleOperation {
|
|
SocketReader *m_inputOperation;
|
|
int m_newWidth;
|
|
int m_newHeight;
|
|
float m_relX;
|
|
float m_relY;
|
|
|
|
/* center is only used for aspect correction */
|
|
float m_offsetX;
|
|
float m_offsetY;
|
|
bool m_is_aspect;
|
|
bool m_is_crop;
|
|
/* set from other properties on initialization,
|
|
* check if we need to apply offset */
|
|
bool m_is_offset;
|
|
public:
|
|
ScaleFixedSizeOperation();
|
|
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
|
|
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
|
|
void executePixel(float output[4], float x, float y, PixelSampler sampler);
|
|
|
|
void initExecution();
|
|
void deinitExecution();
|
|
void setNewWidth(int width) { this->m_newWidth = width; }
|
|
void setNewHeight(int height) { this->m_newHeight = height; }
|
|
void setIsAspect(bool is_aspect) { this->m_is_aspect = is_aspect; }
|
|
void setIsCrop(bool is_crop) { this->m_is_crop = is_crop; }
|
|
void setOffset(float x, float y) { this->m_offsetX = x; this->m_offsetY = y; }
|
|
};
|
|
|
|
#endif
|