Skip to content

Commit

Permalink
fix cv crash (#7671)
Browse files Browse the repository at this point in the history
  • Loading branch information
lxwlaq committed Nov 23, 2021
1 parent 0a23dda commit 3d97475
Showing 1 changed file with 35 additions and 22 deletions.
57 changes: 35 additions & 22 deletions lite/utils/cv/image_convert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ inline void nv12_to_bgr(const uint8_t* src, uint8_t* dst, int srcw, int srch) {
ptr_y1 += 2;
ptr_y2 += 2;
ptr_vu += 2;

if (j + 1 < srcw) {
*ptr_bgr2++ = b3;
*ptr_bgr2++ = g3;
Expand Down Expand Up @@ -790,9 +791,11 @@ inline void nv21_to_bgr(const uint8_t* src, uint8_t* dst, int srcw, int srch) {
g3 = g3 < 0 ? 0 : (g3 > 255) ? 255 : g3;
b3 = b3 < 0 ? 0 : (b3 > 255) ? 255 : b3;

*ptr_bgr1++ = b1;
*ptr_bgr1++ = g1;
*ptr_bgr1++ = r1;
if (j + 1 < srcw) {
*ptr_bgr1++ = b1;
*ptr_bgr1++ = g1;
*ptr_bgr1++ = r1;
}

*ptr_bgr2++ = b2;
*ptr_bgr2++ = g2;
Expand All @@ -802,9 +805,11 @@ inline void nv21_to_bgr(const uint8_t* src, uint8_t* dst, int srcw, int srch) {
ptr_y2 += 2;
ptr_vu += 2;

*ptr_bgr2++ = b3;
*ptr_bgr2++ = g3;
*ptr_bgr2++ = r3;
if (j + 1 < srcw) {
*ptr_bgr2++ = b3;
*ptr_bgr2++ = g3;
*ptr_bgr2++ = r3;
}
}
}
LITE_PARALLEL_COMMON_END();
Expand Down Expand Up @@ -1130,10 +1135,12 @@ inline void nv12_to_bgra(const uint8_t* src, uint8_t* dst, int srcw, int srch) {
g3 = g3 < 0 ? 0 : (g3 > 255) ? 255 : g3;
b3 = b3 < 0 ? 0 : (b3 > 255) ? 255 : b3;

*ptr_bgr1++ = b1;
*ptr_bgr1++ = g1;
*ptr_bgr1++ = r1;
*ptr_bgr1++ = 255;
if (j + 1 < srcw) {
*ptr_bgr1++ = b1;
*ptr_bgr1++ = g1;
*ptr_bgr1++ = r1;
*ptr_bgr1++ = 255;
}

*ptr_bgr2++ = b2;
*ptr_bgr2++ = g2;
Expand All @@ -1144,10 +1151,12 @@ inline void nv12_to_bgra(const uint8_t* src, uint8_t* dst, int srcw, int srch) {
ptr_y2 += 2;
ptr_vu += 2;

*ptr_bgr2++ = b3;
*ptr_bgr2++ = g3;
*ptr_bgr2++ = r3;
*ptr_bgr2++ = 255;
if (j + 1 < srcw) {
*ptr_bgr2++ = b3;
*ptr_bgr2++ = g3;
*ptr_bgr2++ = r3;
*ptr_bgr2++ = 255;
}
}
}
LITE_PARALLEL_COMMON_END();
Expand Down Expand Up @@ -1473,10 +1482,12 @@ inline void nv21_to_bgra(const uint8_t* src, uint8_t* dst, int srcw, int srch) {
g3 = g3 < 0 ? 0 : (g3 > 255) ? 255 : g3;
b3 = b3 < 0 ? 0 : (b3 > 255) ? 255 : b3;

*ptr_bgr1++ = b1;
*ptr_bgr1++ = g1;
*ptr_bgr1++ = r1;
*ptr_bgr1++ = 255;
if (j + 1 < srcw) {
*ptr_bgr1++ = b1;
*ptr_bgr1++ = g1;
*ptr_bgr1++ = r1;
*ptr_bgr1++ = 255;
}

*ptr_bgr2++ = b2;
*ptr_bgr2++ = g2;
Expand All @@ -1487,10 +1498,12 @@ inline void nv21_to_bgra(const uint8_t* src, uint8_t* dst, int srcw, int srch) {
ptr_y2 += 2;
ptr_vu += 2;

*ptr_bgr2++ = b3;
*ptr_bgr2++ = g3;
*ptr_bgr2++ = r3;
*ptr_bgr2++ = 255;
if (j + 1 < srcw) {
*ptr_bgr2++ = b3;
*ptr_bgr2++ = g3;
*ptr_bgr2++ = r3;
*ptr_bgr2++ = 255;
}
}
}
LITE_PARALLEL_COMMON_END();
Expand Down

0 comments on commit 3d97475

Please sign in to comment.