Toshihiro Shimizu 890ddd
#if !defined(PIXEL_OP_HPP__)
Toshihiro Shimizu 890ddd
#define PIXEL_OP_HPP__
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <functional></functional>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename component="" int="" t,=""></typename>
Toshihiro Shimizu 890ddd
void hv_op(T *__restrict ptr, const T *__restrict src, int w, int h, int dst_stride, int src_stride, std::function<t(t &&)="" &&,="" t=""> &&f)</t(t>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	for (int i = 0; i < h; i++) {
Toshihiro Shimizu 890ddd
		for (int j = 0; j < w; j++) {
Toshihiro Shimizu 890ddd
			T c0 = src[j * component];
Toshihiro Shimizu 890ddd
			T c1 = src[j * component + 1];
Toshihiro Shimizu 890ddd
			T c2 = src[j * component + 2];
Toshihiro Shimizu 890ddd
			ptr[j] = f(std::move(c0), std::move(c1), std::move(c2));
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		src += src_stride;
Toshihiro Shimizu 890ddd
		ptr += dst_stride;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename component="" int="" t,=""></typename>
Toshihiro Shimizu 890ddd
void hv_op(const T *__restrict src, int w, int h, int stride, std::function<void(t &&,="" int)="" int,="" t=""> &&f)</void(t>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	for (int i = 0; i < h; i++) {
Toshihiro Shimizu 890ddd
		for (int j = 0; j < w; j++) {
Toshihiro Shimizu 890ddd
			T c0 = src[j * component];
Toshihiro Shimizu 890ddd
			T c1 = src[j * component + 1];
Toshihiro Shimizu 890ddd
			T c2 = src[j * component + 2];
Toshihiro Shimizu 890ddd
			f(std::move(c0), std::move(c1), std::move(c2), j, i);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		src += stride;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename t=""></typename>
Toshihiro Shimizu 890ddd
void hv_op(T *__restrict ptr, const T *__restrict src, int w, int h, int stride, std::function<t(t &&,="" int="" x,="" y)=""> &&f)</t(t>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	for (int i = 0; i < h; i++) {
Toshihiro Shimizu 890ddd
		for (int j = 0; j < w; j++) {
Toshihiro Shimizu 890ddd
			T c0 = src[j];
Toshihiro Shimizu 890ddd
			ptr[j] = f(std::move(c0), j, i);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		src += stride;
Toshihiro Shimizu 890ddd
		ptr += stride;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename t=""></typename>
Toshihiro Shimizu 890ddd
void hv_kernel(T *__restrict ptr, const T *__restrict src, int w, int h, int stride, std::function<t(const *,="" int)="" int,="" t=""> &&f)</t(const>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	for (int i = 0; i < h; i++) {
Toshihiro Shimizu 890ddd
		for (int j = 0; j < w; j++) {
Toshihiro Shimizu 890ddd
			ptr[j] = f(src + j, stride, j, i);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		src += stride;
Toshihiro Shimizu 890ddd
		ptr += stride;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename components="" int="" t,=""></typename>
Toshihiro Shimizu 890ddd
void hv_kernel(T *__restrict ptr, const T *__restrict src, int w, int h, int dstride, int sstride, std::function<void(t[components], *,="" const="" int)="" int,="" t=""> &&f)</void(t[components],>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	for (int i = 0; i < h * components; i += components) {
Toshihiro Shimizu 890ddd
		for (int j = 0; j < w * components; j += components) {
Toshihiro Shimizu 890ddd
			T channels[components];
Toshihiro Shimizu 890ddd
			f(channels, src + j, sstride, j, i);
Toshihiro Shimizu 890ddd
			for (int k = 0; k < components; k++)
Toshihiro Shimizu 890ddd
				ptr[j + k] = channels[k];
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		src += sstride;
Toshihiro Shimizu 890ddd
		ptr += dstride;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif