This source file includes following definitions.
- dump
- compareToReferenceImplementation
- prepareNextImage
- compareToReferenceImplementation
- prepareNextImage
#include "dct.h"
void DSPFunc_FDCT_Base::dump(int x,int y)
{
printf("-> ");
for (int yy=0;yy<blkSize;yy++)
for (int xx=0;xx<blkSize;xx++)
printf("%d ", *(residuals+x+xx+(y+yy)*stride));
printf("\n");
printf(" ");
for (int x=0;x<blkSize*blkSize;x++)
printf("%d ", coeffs[x]);
printf("\n");
int32_t out[32*32];
transform_idct_8x8_fallback(out, coeffs, 20-8, 15);
printf(" ");
for (int x=0;x<blkSize*blkSize;x++)
printf("%d ", out[x]);
printf("\n");
}
bool DSPFunc_FDCT_Base::compareToReferenceImplementation()
{
DSPFunc_FDCT_Base* refImpl = dynamic_cast<DSPFunc_FDCT_Base*>(referenceImplementation());
for (int i=0;i<blkSize*blkSize;i++)
if (coeffs[i] != refImpl->coeffs[i])
return false;
return true;
}
bool DSPFunc_FDCT_Base::prepareNextImage(std::shared_ptr<const de265_image> img)
{
if (!curr_image) {
curr_image = img;
return false;
}
prev_image = curr_image;
curr_image = img;
int w = curr_image->get_width(0);
int h = curr_image->get_height(0);
if (residuals==NULL) {
int align=16;
stride = (w+align-1)/align*align;
residuals = new int16_t[stride*h];
}
int cstride = curr_image->get_luma_stride();
int pstride = prev_image->get_luma_stride();
const uint8_t* curr = curr_image->get_image_plane_at_pos(0,0,0);
const uint8_t* prev = prev_image->get_image_plane_at_pos(0,0,0);
for (int y=0;y<h;y++)
for (int x=0;x<w;x++) {
residuals[y*stride+x] = curr[y*cstride+x] - prev[y*pstride+x];
}
return true;
}
bool DSPFunc_IDCT_Base::compareToReferenceImplementation()
{
DSPFunc_IDCT_Base* refImpl = dynamic_cast<DSPFunc_IDCT_Base*>(referenceImplementation());
for (int i=0;i<blkSize*blkSize;i++)
if (out[i] != refImpl->out[i])
return false;
return true;
}
bool DSPFunc_IDCT_Base::prepareNextImage(std::shared_ptr<const de265_image> img)
{
if (!curr_image) {
curr_image = img;
return false;
}
prev_image = curr_image;
curr_image = img;
int w = curr_image->get_width(0);
int h = curr_image->get_height(0);
int align = blkSize;
width = (w+align-1) / align * align;
blksPerRow = w/blkSize;
if (coeffs==NULL) {
coeffs = new int16_t[width*h];
}
int cstride = curr_image->get_luma_stride();
int pstride = prev_image->get_luma_stride();
const uint8_t* curr = curr_image->get_image_plane_at_pos(0,0,0);
const uint8_t* prev = prev_image->get_image_plane_at_pos(0,0,0);
for (int y=0;y<h;y++)
for (int x=0;x<w;x++) {
coeffs[y*w+x] = curr[y*cstride+x] - prev[y*pstride+x];
}
return true;
}