Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

Resizing interlaced frame

BatterseaSteve
Beginner
1,538 Views
Hi
I have asked this in another thread but since I had no answers I thought I would start a new thread with this specific problem and code sample.

I am trying to resize an interlaced (padded) frame from SD to HD and am getting a crash. The idea is to use the src/dst Step to first resize the even lines and then the odd lines into the same buffer. In my main code it does actually work and look OK, howver, it crashes. I have isolated the code down to this:
Note that
a) I want to flip the image when I resize
b) The src frame is padded at the end of each line (32bytes)
c) The program crashes on first call to ippiResizeSqrPixel_8u_C1R
d) If I valgrind it it tells me I have an invalid read of 1 byte.

I can't for the life of me work out whats wrong

#include
#include
using namespace std;

Ipp8u *resizeLBuffer = NULL;
Ipp8u *tmpBufferY = NULL;

int xSize = 720;
int yActualSize = 576;
int vxsize = 1920;
int vysize = 1080;
uint8_t *data;
int linesize = 752;
double xFactor = (double)vxsize/(double)xSize;
double yFactor = (double)vysize/(double)yActualSize;
int scaleFilter = IPPI_INTER_NN;

int main(int argc,char **argv)
{
IppiRect srcLRect = {0,0,linesize,yActualSize};
IppiRect dstLRect = {0,0,vxsize,vysize};
int bufsize;

data = (uint8_t *)malloc(linesize*yActualSize*sizeof(uint8_t));

ippiResizeGetBufSize( srcLRect, dstLRect, 1, scaleFilter, &bufsize );
resizeLBuffer = ippsMalloc_8u( bufsize );

tmpBufferY = (Ipp8u *)ippMalloc(vxsize*vysize*sizeof(Ipp8u));

Ipp8u *pSrcE = data+((yActualSize-1)*linesize);
Ipp8u *pSrcO = data+((yActualSize-2)*linesize);
IppStatus retVal = ippStsNoErr;

IppiSize srcL1Size = {linesize,yActualSize};
IppiRect srcL1Rect = {0,0,xSize,yActualSize};
IppiRect dstL1Rect = {0,0,vxsize,vysize-1};

retVal = ippiResizeSqrPixel_8u_C1R(pSrcE, srcL1Size, -linesize*2, srcL1Rect, tmpBufferY, vxsize*2, dstL1Rect, xFactor, yFactor, 0, 0, scaleFilter, resizeLBuffer);
retVal = ippiResizeSqrPixel_8u_C1R(pSrcO, srcL1Size, -linesize*2, srcL1Rect, tmpBufferY+vxsize, vxsize*2, dstL1Rect, xFactor, yFactor, 0, 0, scaleFilter, resizeLBuffer);
}

Any help would be greatly appreciated
Is this at all achievable?
Steve
0 Kudos
6 Replies
BatterseaSteve
Beginner
1,538 Views
Well...
Any suggestions - anyone - at all?
Anyone else interested in knowing the answer?
I'ts a fairly simple question - and if I had source could answer myself.
I know it's probably something obvious - but the trees in the wood
keep getting in the way.

I'm at the point now where I chuck this away and do it by hand...
...having just forked out for 10 IPP licenses.
Steve

0 Kudos
Chao_Y_Intel
Moderator
1,538 Views
Steve,

I am trying to reproduce this problem now. Which version of IPP are you using now? Windows/Linux, 32bit or 64 bit?

thanks,
Chao
0 Kudos
Chao_Y_Intel
Moderator
1,538 Views

Steve,

By reviewing this code, if it only need handle odd/even data, I think the image height should be yActualSize/2, and vysize/2 for src, and dst:

srcLRect = {0,0,linesize,yActualSize/2};
dstLRect = {0,0,vxsize,vysize/2};
srcL1Size = {linesize,yActualSize/2};
srcL1Rect = {0,0,xSize,yActualSize/2};
dstL1Rect = {0,0,vxsize,vysize/2};

...

Is this the problem?

Thanks,
Chao

0 Kudos
BatterseaSteve
Beginner
1,538 Views
Hi Chao
Sorry, yes it's Latest 191.4 version Linux 64 bit
And /2 does fix this - so thanks for that.
I have to say that /2 is not immediately obvious!
Cheers
Steve
0 Kudos
BatterseaSteve
Beginner
1,538 Views
One more question - what size should the reqize buffer be
i.e.
Should the width in the src ROI in the ippiResizeGetBufSize be xsize or padded line size?
Should the height in the src ROI in the ippiResizeGetBufSize be ysize or ysize/2?
Cheers
Steve
0 Kudos
Chao_Y_Intel
Moderator
1,538 Views

Hi Steve,

the input paramter ofippiResizeGetBufSize() function should be the same as ROI size ( xsize, ysize/2).

Thanks,
Chao
0 Kudos
Reply