Tue 02 Jul 2013 09:57:55 AM UTC, original submission:
It seems to me that RAPP library ver. 0.7 (but I think the issue was introduced in RAPP 0.6) fails at evaluating the overlap between two pixel buffers if one of them refers to a binary image. Attached you can find a sample code the shows the wrong behavior.
The example I made in the attached source code is the following.
Two images of 108x34 pixels are allocated (this size comes from a real application but you can try with different values). The first image is 1bpp (1 bit per pixel) so it is a binary image. The second is 8bpp (256 gray levels image). I tested this code on my laptop, where the rapp_alignment is 4 byte (the same can be found on artpec3-based Axis cameras). Given this rapp_alignment, the stride for the two images is 108 for the 8bpp image (equal to the image width) and 16 for the 1bpp. Image size is thus 3672 bytes for the 8bpp image and 544 bytes for the 1bpp image.
First, 544 bytes are allocated (with rapp_malloc) for the 1bpp image. Second, 3672 bytes are allocate (with rapp_malloc) for the 8bpp image. Then, a rapp function involving the two pixel buffers is called. I used rapp_thresh_gt_u8 but I think you can use other functions, provided that the source and destination image are 8bpp and 1bpp. These function will check for pixel buffers overlap and return the error code -9 if there is an overlap.
In the attached example, the two buffers are considered by rapp to be overlapped, even though there are more that 544 bytes of distance between the beginning of the first pixel buffer (1bpp) and the second pixel buffer (8bpp).
Please note that the order of memory allocation operation is important. I think the error occurs because RAPP computes a wrong size for the buffer of the binary image. If the gray level image is allocated before the binary image, the error is likely to remain silent.
I think the bug is in rapp_util.h where the macros RAPP_VALIDATE_RESTRICT, RAPP_VALIDATE_RESTRICT_PLUS and RAPP_VALIDATE_RESTRICT_OFFSET are defined. Probably the last one needs to be revised.
regards,
Fabrizio
|