Example #1
0
	bool CObject::SetU16(const char* name, _U32 index, _U16 val)
	{
		return SetU16(Zion::StringFormat("%s[%d]", name, index).c_str(), val);
	}
        void ShiftBilinear(const uint8_t *src, size_t srcStride, size_t width, size_t height, size_t channelCount,
            int fDx, int fDy, uint8_t *dst, size_t dstStride)
        {
            size_t size = width*channelCount;
            size_t alignedSize = AlignLo(size, A);

            if (fDy)
            {
                if (fDx)
                {
                    v128_u16 k[2][2], s[2][2][2];
                    k[0][0] = SetU16((Base::FRACTION_RANGE - fDx)*(Base::FRACTION_RANGE - fDy));
                    k[0][1] = SetU16(fDx*(Base::FRACTION_RANGE - fDy));
                    k[1][0] = SetU16((Base::FRACTION_RANGE - fDx)*fDy);
                    k[1][1] = SetU16(fDx*fDy);
                    for (size_t row = 0; row < height; ++row)
                    {
                        for (size_t col = 0; col < alignedSize; col += A)
                        {
                            LoadBlock(src + col, channelCount, srcStride, s);
                            Store<false>(dst + col, Interpolate(s, k));
                        }
                        if (size != alignedSize)
                        {
                            LoadBlock(src + size - A, channelCount, srcStride, s);
                            Store<false>(dst + size - A, Interpolate(s, k));
                        }
                        src += srcStride;
                        dst += dstStride;
                    }
                }
                else
                {
                    v128_u16 k[2], s[2][2];
                    k[0] = SetU16(Base::FRACTION_RANGE - fDy);
                    k[1] = SetU16(fDy);
                    for (size_t row = 0; row < height; ++row)
                    {
                        for (size_t col = 0; col < alignedSize; col += A)
                        {
                            LoadBlock(src + col, srcStride, s);
                            Store<false>(dst + col, Interpolate(s, k));
                        }
                        if (size != alignedSize)
                        {
                            LoadBlock(src + size - A, srcStride, s);
                            Store<false>(dst + size - A, Interpolate(s, k));
                        }
                        src += srcStride;
                        dst += dstStride;
                    }
                }
            }
            else
            {
                if (fDx)
                {
                    v128_u16 k[2], s[2][2];
                    k[0] = SetU16(Base::FRACTION_RANGE - fDx);
                    k[1] = SetU16(fDx);
                    for (size_t row = 0; row < height; ++row)
                    {
                        for (size_t col = 0; col < alignedSize; col += A)
                        {
                            LoadBlock(src + col, channelCount, s);
                            Store<false>(dst + col, Interpolate(s, k));
                        }
                        if (size != alignedSize)
                        {
                            LoadBlock(src + size - A, channelCount, s);
                            Store<false>(dst + size - A, Interpolate(s, k));
                        }
                        src += srcStride;
                        dst += dstStride;
                    }
                }
                else
                {
                    for (size_t row = 0; row < height; ++row)
                    {
                        memcpy(dst, src, size);
                        src += srcStride;
                        dst += dstStride;
                    }
                }
            }
        }