|
|
|
#include "model/processor/strategies/Cri.h"
|
|
|
|
#include "model/processor/BIP.h"
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QImage>
|
|
|
|
|
|
|
|
Cri::Cri(const Context context,const QString kernelPath,const QObject *parent = Q_NULLPTR) :
|
|
|
|
IProcessStrategy(context, kernelPath, "Cri", parent),
|
|
|
|
_kernelFunctor(KernelFunctor<Image2DArray, Image2D, Cri_t>(_kernel))
|
|
|
|
{
|
|
|
|
memset(&_kernelParameters, 0, sizeof (Cri_t));
|
|
|
|
// _criBuffer = new Image2D()[CRI_MAX_BUFFER_SIZE];
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cri::cpuProcess(Input_t params)
|
|
|
|
{
|
|
|
|
_kernelParameters.criFilterMode = params.criFilterMode;
|
|
|
|
_kernelParameters.scenariFrameNo = params.scenarioFrameNo;
|
|
|
|
_kernelParameters.frameCntr = params.frameCntr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cri::finalize()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Image* Cri::processKernel(Image *frames, Buffer* scratchPad)
|
|
|
|
{
|
|
|
|
auto format = frames->getImageInfo<CL_IMAGE_FORMAT>();
|
|
|
|
auto width = frames->getImageInfo<CL_IMAGE_WIDTH>();
|
|
|
|
auto height = frames->getImageInfo<CL_IMAGE_HEIGHT>();
|
|
|
|
|
|
|
|
_criBuffer[_kernelParameters.scenariFrameNo] = static_cast<Image2D*>(frames);
|
|
|
|
int err = 100;
|
|
|
|
|
|
|
|
// Image2DArray bufferframes = Image2DArray(_CLContext, CL_MEM_READ_WRITE, ImageFormat(format.image_channel_order, format.image_channel_data_type),
|
|
|
|
// 16,
|
|
|
|
// width,
|
|
|
|
// height,
|
|
|
|
// 0,0);
|
|
|
|
// BIP::getInstance()->CLQueue.enqueueWriteImage(*bufferframes, CL_TRUE, array<size_type, 3> {0, 0, 0},
|
|
|
|
// array<size_type, 4> {width, height, 1},
|
|
|
|
// width * sizeof (myflt),
|
|
|
|
// 0,
|
|
|
|
// _criBuffer);
|
|
|
|
auto imgs = new Image2DArray(_CLContext, CL_MEM_READ_WRITE, ImageFormat(format.image_channel_order, format.image_channel_data_type),
|
|
|
|
16,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
width *4* sizeof (myflt),
|
|
|
|
0,
|
|
|
|
_criBuffer,
|
|
|
|
&err);
|
|
|
|
qDebug()<<"erro is : " << err;
|
|
|
|
// cl::enqueueReadImage()
|
|
|
|
|
|
|
|
auto imageOutput = new Image2D(_CLContext,
|
|
|
|
CL_MEM_READ_WRITE,
|
|
|
|
ImageFormat(format.image_channel_order, format.image_channel_data_type),
|
|
|
|
width,
|
|
|
|
height);
|
|
|
|
cl::EnqueueArgs eargs(BIP::getInstance()->CLQueue, cl::NDRange(width, height));
|
|
|
|
|
|
|
|
_openCLHelper.runKernelFunctor<Image2DArray, Image2D, Cri_t>(_kernelFunctor,
|
|
|
|
eargs,
|
|
|
|
*imgs,
|
|
|
|
*imageOutput,
|
|
|
|
_kernelParameters);
|
|
|
|
|
|
|
|
delete imgs;
|
|
|
|
return imageOutput;
|
|
|
|
}
|