Dears,
I have the question about VICP signal processing library. It seems there are 2
bugs in library's source code. Could anyone confirm the bugs?
I wrote two programs to invoke the VICP signal processing library's API
CPIS_colorSpcConv(). My first program runs smoothly but the second one always
gets the return code -1 with CPIS_errorno = 5 (CPIS_NOSUPPORTDIM_ERROR).
When I traced into CPIS_colorSpcConv(), I found the there is an abnormal array
access in function _CPIS_sizeof() (in file _cpisCore.c).
Here is the excert of the function _CPIS_sizeof():
01: Int16 _CPIS_sizeof(CPIS_Format format){
02:
03: Uint16 trueFormat, alphaOn;
04:
05: trueFormat= format & ~CPIS_ALPHA;
06: alphaOn= format & CPIS_ALPHA;
07:
08: if (alphaOn && trueFormat== CPIS_RGB_888)
09: return 4;
00: else
11: return (_CPIS2VICP_sizeOfFormat[trueFormat - CPIS_YUV_422IBE]);
12:
13: }
and the array _CPIS2VICP_sizeOfFormat[] is defined as (in file _cpisCore.c):
14: static Int16 _CPIS2VICP_sizeOfFormat[]= { 2, 2, 2, 2, 2, 3, 3, 3, 1, 1, 2,
15: 4, 8, 1, 2, 4, 8, -8, 1, 2, 4, 8, 2, 4, 8};
[bug1] (line 11) The array index (trueFormat - CPIS_YUV_422IBE) becomes
negative when trueFormat = CPIS_RGB_P or CPIS_YUV_444P. (the value of enum
CPIS_RGB_P, CPIS_YUV_444P and CPIS_YUV_422IB is 5, 1 and 7, respectively.
Note that the user guide said that CPIS_RGB_P or CPIS_YUV_444P are the native
format in function CPIS_colorSpcConv().)
[bug2] (line 14) Why there is a negative entry in the arrary
_CPIS2VICP_sizeOfFormatat[]?
I observed that my first program has the good luck to get the valid value when
accessing the data outside the array. However, my second program which always
returns error code should be the normal case.
The VICP Signal Processing Library I used is from
VisionMid_embeddedVisionFramework, version 0.6
-------------------------------------------------------------------------.
For addition information about this question, here is the code snippet to
invoking CPIS_colorSpcConv() in my two programs.
100: // To perform RGB to YUV conversion
101: base.srcFormat[0] = CPIS_RGB_P;
102: base.srcBuf[0].ptr = img_in;
103: base.srcBuf[0].stride = img_width;
104: base.srcBuf[1].ptr = base_param.srcBuf[0].ptr + img_width * img_height;
105: base.srcBuf[1].stride = img_width;
106: base.srcBuf[2].ptr = base_param.srcBuf[1].ptr + img_width * img_height;
107: base.srcBuf[2].stride = img_width;
108:
109: base.dstFormat[0] = CPIS_YUV_444P;
110: base.dstBuf[0].ptr = img_out;
111: base.dstBuf[0].stride = img_width;
112: base.dstBuf[1].ptr = base_param.dstBuf[0].ptr + img_width * img_height;
113: base.dstBuf[1].stride = img_width;
114: base.dstBuf[2].ptr = base_param.dstBuf[1].ptr + img_width * img_height;
115: base.dstBuf[2].stride = img_width;
116:
117: base.roiSize.width = img_width;
118: base.roiSize.height = img_height;
119:
120: base.procBlockSize.width = 16;
121: base.procBlockSize.height = 16;
122:
123: // function specific parameter 1 assignment
124: for(i=0; i<9; i++)
125: {
126: param.matrix[i] = (Int16)(rgb2yuv_matrix[i] * 32768.0);
127: }
128: param.qShift = 15 ;
129: param.preOffset[0] = 0;
130: param.preOffset[1] = 0;
131: param.preOffset[2] = 0;
132: param.postOffset[0] = 0;
133: param.postOffset[1] = 128;
134: param.postOffset[2] = 128;
135: param.signedInput[0] = 0;
136: param.signedInput[1] = 0;
137: param.signedInput[2] = 0;
138: param.signedOutput[0] = 0;
139: param.signedOutput[1] = 1;
140: param.signedOutput[2] = 1;
141: param.colorDsMode = CPIS_DS_NONE;
142:
143: ret_code = CPIS_colorSpcConv(&handle, &base &spec, CPIS_ASYNC);