- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello all,
I'm having some trouble using ippiDilate3x3_8u_C1R(). When I use non-32byte-aligned memory, the function reads up to 14 bytes of data beyond the end of the buffer, causing the program to crash. I have a one pixel border around the ROI, so that should be OK. Any ideas on this behaviour? I will try to make a short example program and post it here.
Thanks,
Per
I'm having some trouble using ippiDilate3x3_8u_C1R(). When I use non-32byte-aligned memory, the function reads up to 14 bytes of data beyond the end of the buffer, causing the program to crash. I have a one pixel border around the ROI, so that should be OK. Any ideas on this behaviour? I will try to make a short example program and post it here.
Thanks,
Per
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Per,
what version of IPP do you use and what is your target platform l(processor and operating system)?
Could you please share a piece of code which cause problem?
Regards,
Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm using IPP 5.1 on a Core2Duo system using WinXP. (Still working on the example code.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for updating. By the way, any particular reasons you did not move to the latest IPP version, which is 5.2?
I recall there was such an issue with this function, I'm checking now when it was fixed.
Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is the code. boundsCheckAlloc() is a function that write-protects
the page following the allocation, thus enabling me to detect out-of-buffer
reads.
If i change the row
tmpimg = boundsCheckAlloc(tmpWidth*tmpHeight);
to
tmpimg = boundsCheckAlloc(tmpWidth*tmpHeight+14);
The code works fine.
#include/* malloc */
#include "ipp.h"
#include "windows.h"
#include
static void *boundsCheckAlloc(int memSize) {
DWORD t;
BOOL res;
static unsigned char* memarea = NULL;
const int NUM_PAGES = 100;
const int PAGE_SIZE = 4096; // True for XP at least
assert(memSize < PAGE_SIZE*(NUM_PAGES-1));
if(!memarea) {
memarea = VirtualAlloc(0, PAGE_SIZE*NUM_PAGES, MEM_COMMIT, PAGE_READWRITE);
assert(memarea);
/// Read and write protect last page.
res = VirtualProtect(memarea+PAGE_SIZE*(NUM_PAGES-1), PAGE_SIZE, PAGE_NOACCESS, &t);
assert(res);
}
return memarea + PAGE_SIZE*(NUM_PAGES-1) - memSize;
}
int main(int argc, char** argv) {
IppStatus ippRes;
const int width = 256;
const int height = 20;
const int tmpWidth = width + 2;
const int tmpHeight = height + 2;
unsigned char* input;
unsigned char* tmpimg;
unsigned char* output;
const IppiSize roi = {width, height};
const IppiSize tmproi = {tmpWidth, tmpHeight};
input = malloc(width*height);
memset(input, 0, width*height);
output = malloc(width*height);
tmpimg = boundsCheckAlloc(tmpWidth*tmpHeight);
ippRes = ippiCopyConstBorder_8u_C1R(input, width, roi,
tmpimg, tmpWidth, tmproi,
1, 1, 0);
assert(ippRes == ippStsNoErr);
ippRes = ippiErode3x3_8u_C1R(tmpimg+tmpWidth+1, tmpWidth, output, width, roi);
assert(ippRes == ippStsNoErr);
free(input);
//free(tmpimg);
free(output);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You could use ippiFilterMaxBorderBorderReplicate_8u_C1R function. It does not require the boreder in memory and is generally faster
Thanks,
Alexander
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page