Video Filter:
- When changing source image size, force the construction of a new buffer. Fixes [bugs:#1384] introduced in [r4987].
This commit is contained in:
parent
4e5b6e6d6f
commit
e9da2c318c
|
@ -149,6 +149,7 @@ VideoFilter::~VideoFilter()
|
|||
bool VideoFilter::SetSourceSize(const size_t width, const size_t height)
|
||||
{
|
||||
bool result = false;
|
||||
bool sizeChanged = false;
|
||||
|
||||
ThreadLockLock(&this->_lockSrc);
|
||||
|
||||
|
@ -160,6 +161,10 @@ bool VideoFilter::SetSourceSize(const size_t width, const size_t height)
|
|||
return result;
|
||||
}
|
||||
|
||||
if (this->_vfSrcSurface.Width != width || this->_vfSrcSurface.Height != height)
|
||||
{
|
||||
sizeChanged = true;
|
||||
}
|
||||
this->_vfSrcSurface.Width = width;
|
||||
this->_vfSrcSurface.Height = height;
|
||||
this->_vfSrcSurface.Pitch = width * 2;
|
||||
|
@ -189,7 +194,7 @@ bool VideoFilter::SetSourceSize(const size_t width, const size_t height)
|
|||
ThreadLockUnlock(&this->_lockSrc);
|
||||
|
||||
const VideoFilterAttributes vfAttr = this->GetAttributes();
|
||||
result = this->ChangeFilterByAttributes(vfAttr);
|
||||
result = this->ChangeFilterByAttributes(vfAttr, sizeChanged);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -216,7 +221,7 @@ bool VideoFilter::ChangeFilterByID(const VideoFilterTypeID typeID)
|
|||
return result;
|
||||
}
|
||||
|
||||
result = this->ChangeFilterByAttributes(VideoFilterAttributesList[typeID]);
|
||||
result = this->ChangeFilterByAttributes(VideoFilterAttributesList[typeID], false);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -233,7 +238,7 @@ bool VideoFilter::ChangeFilterByID(const VideoFilterTypeID typeID)
|
|||
A bool that reports if the filter change was successful. A value of true means
|
||||
success, while a value of false means failure.
|
||||
********************************************************************************************/
|
||||
bool VideoFilter::ChangeFilterByAttributes(const VideoFilterAttributes &vfAttr)
|
||||
bool VideoFilter::ChangeFilterByAttributes(const VideoFilterAttributes &vfAttr, const bool forceRealloc)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
|
@ -242,7 +247,7 @@ bool VideoFilter::ChangeFilterByAttributes(const VideoFilterAttributes &vfAttr)
|
|||
return result;
|
||||
}
|
||||
|
||||
if (this->_vfDstSurface.Surface != NULL && this->_vfAttributes.scaleMultiply == vfAttr.scaleMultiply && this->_vfAttributes.scaleDivide == vfAttr.scaleDivide)
|
||||
if (!forceRealloc && this->_vfDstSurface.Surface != NULL && this->_vfAttributes.scaleMultiply == vfAttr.scaleMultiply && this->_vfAttributes.scaleDivide == vfAttr.scaleDivide)
|
||||
{
|
||||
// If we have an existing buffer and the new size is identical to the old size,
|
||||
// we can skip the costly construction of the buffer and simply clear it instead.
|
||||
|
|
|
@ -188,7 +188,7 @@ public:
|
|||
|
||||
bool SetSourceSize(const size_t width, const size_t height);
|
||||
bool ChangeFilterByID(const VideoFilterTypeID typeID);
|
||||
bool ChangeFilterByAttributes(const VideoFilterAttributes &vfAttr);
|
||||
bool ChangeFilterByAttributes(const VideoFilterAttributes &vfAttr, const bool forceRealloc);
|
||||
uint32_t* RunFilter();
|
||||
|
||||
static void RunFilterCustomByID(const uint32_t *__restrict srcBuffer, uint32_t *__restrict dstBuffer, const size_t srcWidth, const size_t srcHeight, const VideoFilterTypeID typeID);
|
||||
|
|
Loading…
Reference in New Issue