1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

imgproc: catch NaNs in clip(), use table index debug check

- no NaN propagation guarantee
This commit is contained in:
Alexander Alekhin
2021-12-11 17:28:21 +00:00
parent 16b674b984
commit 72c55b56f2
2 changed files with 26 additions and 1 deletions
+6 -1
View File
@@ -978,8 +978,9 @@ static struct LUVLUT_T {
const long long int *LvToVpl_b;
} LUVLUT = {0, 0, 0};
/* NB: no NaN propagation guarantee */
#define clip(value) \
value < 0.0f ? 0.0f : value > 1.0f ? 1.0f : value;
value < 0.0f ? 0.0f : value <= 1.0f ? value : 1.0f;
//all constants should be presented through integers to keep bit-exactness
static const softdouble gammaThreshold = softdouble(809)/softdouble(20000); // 0.04045
@@ -1330,6 +1331,10 @@ static inline void trilinearInterpolate(int cx, int cy, int cz, const int16_t* L
int ty = cy >> (lab_base_shift - lab_lut_shift);
int tz = cz >> (lab_base_shift - lab_lut_shift);
CV_DbgCheck(tx, tx >= 0 && tx < LAB_LUT_DIM, "");
CV_DbgCheck(ty, ty >= 0 && ty < LAB_LUT_DIM, "");
CV_DbgCheck(tz, tz >= 0 && tz < LAB_LUT_DIM, "");
const int16_t* baseLUT = &LUT[3*8*tx + (3*8*LAB_LUT_DIM)*ty + (3*8*LAB_LUT_DIM*LAB_LUT_DIM)*tz];
int aa[8], bb[8], cc[8];
for(int i = 0; i < 8; i++)