Пример #1
0
// TODO SSE
void MLSignal::sigLerp(const MLSignal& b, const MLSignal& mix)
{
	int n = min(mSize, b.getSize());
	n = min(n, mix.getSize());
	for(int i = 0; i < n; ++i)
	{
		mDataAligned[i] = lerp(mDataAligned[i], b.mDataAligned[i], mix.mDataAligned[i]);
	}
	setConstant(false);
}
Пример #2
0
// TODO SSE
void MLSignal::sigClamp(const MLSignal& a, const MLSignal& b)
{
	int n = min(mSize, a.getSize());
	n = min(n, b.getSize());
	for(int i = 0; i < n; ++i)
	{
		MLSample f = mDataAligned[i];
		mDataAligned[i] = clamp(f, a.mDataAligned[i], b.mDataAligned[i]);
	}
	setConstant(false);
}
Пример #3
0
void MLSignal::sigMax(const MLSignal& b)
{
	int n = min(mSize, b.getSize());
	for(int i = 0; i < n; ++i)
	{
		MLSample f = mDataAligned[i];
		mDataAligned[i] = max(f, b.mDataAligned[i]);
	}
	setConstant(false);
}
Пример #4
0
void MLSignal::copy(const MLSignal& b)
{
	const bool kb = b.isConstant();
	if (kb)
	{
		setToConstant(b.mDataAligned[0]);
	}
	else 
	{
		const int n = min(mSize, b.getSize());
		std::copy(b.mDataAligned, b.mDataAligned + n, mDataAligned);
		setConstant(false);
	}
}
Пример #5
0
// setFrame() - set the 2D frame i to the incoming signal.
void MLSignal::setFrame(int i, const MLSignal& src)
{
	// only valid for 3D signals
	assert(is3D());
	
	// source must be 2D
	assert(src.is2D());
	
	// src signal should match our dimensions
	if((src.getWidth() != mWidth) || (src.getHeight() != mHeight))
	{
		return;
	}
	
	MLSample* pDestFrame = mDataAligned + plane(i);
	const MLSample* pSrc = src.getConstBuffer();
	std::copy(pSrc, pSrc + src.getSize(), pDestFrame);
}
Пример #6
0
// TODO SSE
void MLSignal::divide(const MLSignal& b)
{
	const bool ka = isConstant();
	const bool kb = b.isConstant();
	if (ka && kb)
	{
		setToConstant(mDataAligned[0] + b.mDataAligned[0]);
	}
	else 
	{
		const int n = min(mSize, b.getSize());
		if (ka && !kb)
		{
			MLSample fa = mDataAligned[0];
			for(int i = 0; i < n; ++i)
			{
				mDataAligned[i] = fa / b[i];
			}
		}
		else if (!ka && kb)
		{
			MLSample fb = b[0];
			for(int i = 0; i < n; ++i)
			{
				mDataAligned[i] /= fb;
			}
		}
		else
		{
			for(int i = 0; i < n; ++i)
			{
				mDataAligned[i] /= b.mDataAligned[i];
			}
		}
		setConstant(false);
	}
}