mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2026-06-15 00:16:08 +08:00
Fix integer overflow when flipping negative height
Treat height == INT_MIN as invalid. Omit explicit height == INT_MIN check if we disallow height < 32768. Perform multiplications of stride in the ptrdiff_t type. Add checks for invalid width and height to some functions. Bug: 518806561 Change-Id: I5e39fffed7f806852a8758d4b59df919839c0a3b Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/7891415 Reviewed-by: Frank Barchard <fbarchard@google.com> Commit-Queue: Wan-Teh Chang <wtc@google.com>
This commit is contained in:
parent
e14b0e2c60
commit
62fffa9eeb
@ -100,16 +100,16 @@ int I420Copy(const uint8_t* src_y,
|
|||||||
int halfwidth = (width + 1) >> 1;
|
int halfwidth = (width + 1) >> 1;
|
||||||
int halfheight = (height + 1) >> 1;
|
int halfheight = (height + 1) >> 1;
|
||||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
halfheight = (height + 1) >> 1;
|
halfheight = (height + 1) >> 1;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (halfheight - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(halfheight - 1) * src_stride_u;
|
||||||
src_v = src_v + (halfheight - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(halfheight - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
@ -143,16 +143,16 @@ int I010Copy(const uint16_t* src_y,
|
|||||||
int halfwidth = (width + 1) >> 1;
|
int halfwidth = (width + 1) >> 1;
|
||||||
int halfheight = (height + 1) >> 1;
|
int halfheight = (height + 1) >> 1;
|
||||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
halfheight = (height + 1) >> 1;
|
halfheight = (height + 1) >> 1;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (halfheight - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(halfheight - 1) * src_stride_u;
|
||||||
src_v = src_v + (halfheight - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(halfheight - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
@ -188,16 +188,16 @@ static int Planar16bitTo8bit(const uint16_t* src_y,
|
|||||||
int uv_height = SUBSAMPLE(height, subsample_y, subsample_y);
|
int uv_height = SUBSAMPLE(height, subsample_y, subsample_y);
|
||||||
int scale = 1 << (24 - depth);
|
int scale = 1 << (24 - depth);
|
||||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
uv_height = -uv_height;
|
uv_height = -uv_height;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (uv_height - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(uv_height - 1) * src_stride_u;
|
||||||
src_v = src_v + (uv_height - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(uv_height - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
@ -233,15 +233,15 @@ static int I41xToI420(const uint16_t* src_y,
|
|||||||
int depth) {
|
int depth) {
|
||||||
const int scale = 1 << (24 - depth);
|
const int scale = 1 << (24 - depth);
|
||||||
|
|
||||||
if (width <= 0 || height == 0) {
|
if (width <= 0 || height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (height - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(height - 1) * src_stride_u;
|
||||||
src_v = src_v + (height - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(height - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
@ -278,15 +278,15 @@ static int I21xToI420(const uint16_t* src_y,
|
|||||||
int depth) {
|
int depth) {
|
||||||
const int scale = 1 << (24 - depth);
|
const int scale = 1 << (24 - depth);
|
||||||
|
|
||||||
if (width <= 0 || height == 0) {
|
if (width <= 0 || height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (height - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(height - 1) * src_stride_u;
|
||||||
src_v = src_v + (height - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(height - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
@ -541,7 +541,7 @@ static int Ix10ToI010(const uint16_t* src_y,
|
|||||||
const int dst_uv_height = SUBSAMPLE(dst_y_height, 1, 1);
|
const int dst_uv_height = SUBSAMPLE(dst_y_height, 1, 1);
|
||||||
int r;
|
int r;
|
||||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (dst_y) {
|
if (dst_y) {
|
||||||
@ -615,7 +615,7 @@ static int IxxxToPxxx(const uint16_t* src_y,
|
|||||||
int depth) {
|
int depth) {
|
||||||
const int uv_width = SUBSAMPLE(width, subsample_x, subsample_x);
|
const int uv_width = SUBSAMPLE(width, subsample_x, subsample_x);
|
||||||
const int uv_height = SUBSAMPLE(height, subsample_y, subsample_y);
|
const int uv_height = SUBSAMPLE(height, subsample_y, subsample_y);
|
||||||
if (width <= 0 || height == 0) {
|
if (width <= 0 || height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,16 +666,16 @@ int I010ToNV12(const uint16_t* src_y,
|
|||||||
void (*MergeUVRow)(const uint8_t* src_u, const uint8_t* src_v,
|
void (*MergeUVRow)(const uint8_t* src_u, const uint8_t* src_v,
|
||||||
uint8_t* dst_uv, int width) = MergeUVRow_C;
|
uint8_t* dst_uv, int width) = MergeUVRow_C;
|
||||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_uv || width <= 0 ||
|
if ((!src_y && dst_y) || !src_u || !src_v || !dst_uv || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
halfheight = (height + 1) >> 1;
|
halfheight = (height + 1) >> 1;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (halfheight - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(halfheight - 1) * src_stride_u;
|
||||||
src_v = src_v + (halfheight - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(halfheight - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
@ -889,15 +889,15 @@ int I422ToI210(const uint8_t* src_y,
|
|||||||
int height) {
|
int height) {
|
||||||
int halfwidth = (width + 1) >> 1;
|
int halfwidth = (width + 1) >> 1;
|
||||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (height - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(height - 1) * src_stride_u;
|
||||||
src_v = src_v + (height - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(height - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
@ -928,15 +928,19 @@ int I422ToNV21(const uint8_t* src_y,
|
|||||||
int dst_stride_vu,
|
int dst_stride_vu,
|
||||||
int width,
|
int width,
|
||||||
int height) {
|
int height) {
|
||||||
|
int r;
|
||||||
|
if (width <= 0 || height == 0 || height == INT_MIN) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
int halfwidth = (width + 1) >> 1;
|
int halfwidth = (width + 1) >> 1;
|
||||||
int halfheight = (height + 1) >> 1;
|
int halfheight = (height + 1) >> 1;
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
halfheight = (height + 1) >> 1;
|
halfheight = (height + 1) >> 1;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (height - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(height - 1) * src_stride_u;
|
||||||
src_v = src_v + (height - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(height - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
@ -951,9 +955,12 @@ int I422ToNV21(const uint8_t* src_y,
|
|||||||
return 1;
|
return 1;
|
||||||
uint8_t* plane_v = plane_u + (size_t)plane_size;
|
uint8_t* plane_v = plane_u + (size_t)plane_size;
|
||||||
|
|
||||||
I422ToI420(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v,
|
r = I422ToI420(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v,
|
||||||
dst_y, dst_stride_y, plane_u, halfwidth, plane_v, halfwidth, width,
|
dst_y, dst_stride_y, plane_u, halfwidth, plane_v, halfwidth,
|
||||||
height);
|
width, height);
|
||||||
|
if (r != 0) {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
MergeUVPlane(plane_v, halfwidth, plane_u, halfwidth, dst_vu, dst_stride_vu,
|
MergeUVPlane(plane_v, halfwidth, plane_u, halfwidth, dst_vu, dst_stride_vu,
|
||||||
halfwidth, halfheight);
|
halfwidth, halfheight);
|
||||||
free_aligned_buffer_64(plane_u);
|
free_aligned_buffer_64(plane_u);
|
||||||
@ -1047,7 +1054,7 @@ int MT2TToP010(const uint8_t* src_y,
|
|||||||
int dst_stride_uv,
|
int dst_stride_uv,
|
||||||
int width,
|
int width,
|
||||||
int height) {
|
int height) {
|
||||||
if (width <= 0 || !height || !src_uv || !dst_uv) {
|
if (width <= 0 || height == 0 || height == INT_MIN || !src_uv || !dst_uv) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1078,10 +1085,10 @@ int MT2TToP010(const uint8_t* src_y,
|
|||||||
height = -height;
|
height = -height;
|
||||||
uv_height = (height + 1) / 2;
|
uv_height = (height + 1) / 2;
|
||||||
if (dst_y) {
|
if (dst_y) {
|
||||||
dst_y = dst_y + (height - 1) * dst_stride_y;
|
dst_y = dst_y + (ptrdiff_t)(height - 1) * dst_stride_y;
|
||||||
dst_stride_y = -dst_stride_y;
|
dst_stride_y = -dst_stride_y;
|
||||||
}
|
}
|
||||||
dst_uv = dst_uv + (uv_height - 1) * dst_stride_uv;
|
dst_uv = dst_uv + (ptrdiff_t)(uv_height - 1) * dst_stride_uv;
|
||||||
dst_stride_uv = -dst_stride_uv;
|
dst_stride_uv = -dst_stride_uv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1147,16 +1154,16 @@ int I422ToNV21(const uint8_t* src_y,
|
|||||||
int halfwidth = (width + 1) >> 1;
|
int halfwidth = (width + 1) >> 1;
|
||||||
int halfheight = (height + 1) >> 1;
|
int halfheight = (height + 1) >> 1;
|
||||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_vu || width <= 0 ||
|
if ((!src_y && dst_y) || !src_u || !src_v || !dst_vu || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
halfheight = (height + 1) >> 1;
|
halfheight = (height + 1) >> 1;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (halfheight - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(halfheight - 1) * src_stride_u;
|
||||||
src_v = src_v + (halfheight - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(halfheight - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
@ -1311,15 +1318,15 @@ int I444ToNV12(const uint8_t* src_y,
|
|||||||
int width,
|
int width,
|
||||||
int height) {
|
int height) {
|
||||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_uv || width <= 0 ||
|
if ((!src_y && dst_y) || !src_u || !src_v || !dst_uv || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (height - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(height - 1) * src_stride_u;
|
||||||
src_v = src_v + (height - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(height - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
@ -1364,14 +1371,15 @@ int I400ToI420(const uint8_t* src_y,
|
|||||||
int height) {
|
int height) {
|
||||||
int halfwidth = (width + 1) >> 1;
|
int halfwidth = (width + 1) >> 1;
|
||||||
int halfheight = (height + 1) >> 1;
|
int halfheight = (height + 1) >> 1;
|
||||||
if ((!src_y && dst_y) || !dst_u || !dst_v || width <= 0 || height == 0) {
|
if ((!src_y && dst_y) || !dst_u || !dst_v || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
halfheight = (height + 1) >> 1;
|
halfheight = (height + 1) >> 1;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
}
|
}
|
||||||
if (dst_y) {
|
if (dst_y) {
|
||||||
@ -1394,14 +1402,15 @@ int I400ToNV21(const uint8_t* src_y,
|
|||||||
int height) {
|
int height) {
|
||||||
int halfwidth = (width + 1) >> 1;
|
int halfwidth = (width + 1) >> 1;
|
||||||
int halfheight = (height + 1) >> 1;
|
int halfheight = (height + 1) >> 1;
|
||||||
if ((!src_y && dst_y) || !dst_vu || width <= 0 || height == 0) {
|
if ((!src_y && dst_y) || !dst_vu || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
halfheight = (height + 1) >> 1;
|
halfheight = (height + 1) >> 1;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
}
|
}
|
||||||
if (dst_y) {
|
if (dst_y) {
|
||||||
@ -1429,15 +1438,15 @@ int NV12ToI420(const uint8_t* src_y,
|
|||||||
int halfwidth = (width + 1) >> 1;
|
int halfwidth = (width + 1) >> 1;
|
||||||
int halfheight = (height + 1) >> 1;
|
int halfheight = (height + 1) >> 1;
|
||||||
if ((!src_y && dst_y) || !src_uv || !dst_u || !dst_v || width <= 0 ||
|
if ((!src_y && dst_y) || !src_uv || !dst_u || !dst_v || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
halfheight = (height + 1) >> 1;
|
halfheight = (height + 1) >> 1;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_uv = src_uv + (halfheight - 1) * src_stride_uv;
|
src_uv = src_uv + (ptrdiff_t)(halfheight - 1) * src_stride_uv;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_uv = -src_stride_uv;
|
src_stride_uv = -src_stride_uv;
|
||||||
}
|
}
|
||||||
@ -1499,7 +1508,8 @@ int NV12ToNV24(const uint8_t* src_y,
|
|||||||
int width,
|
int width,
|
||||||
int height) {
|
int height) {
|
||||||
int r;
|
int r;
|
||||||
if ((!src_y && dst_y) || !src_uv || !dst_uv || width <= 0 || height == 0) {
|
if ((!src_y && dst_y) || !src_uv || !dst_uv || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1524,7 +1534,8 @@ int NV16ToNV24(const uint8_t* src_y,
|
|||||||
int width,
|
int width,
|
||||||
int height) {
|
int height) {
|
||||||
int r;
|
int r;
|
||||||
if ((!src_y && dst_y) || !src_uv || !dst_uv || width <= 0 || height == 0) {
|
if ((!src_y && dst_y) || !src_uv || !dst_uv || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1555,7 +1566,7 @@ static int PxxxToIxxx(const uint16_t* src_y,
|
|||||||
const int uv_width = SUBSAMPLE(width, subsample_x, subsample_x);
|
const int uv_width = SUBSAMPLE(width, subsample_x, subsample_x);
|
||||||
const int uv_height = SUBSAMPLE(height, subsample_y, subsample_y);
|
const int uv_height = SUBSAMPLE(height, subsample_y, subsample_y);
|
||||||
if (!src_y || !dst_y || !src_uv || !dst_u || !dst_v || width <= 0 ||
|
if (!src_y || !dst_y || !src_uv || !dst_u || !dst_v || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ConvertToLSBPlane_16(src_y, src_stride_y, dst_y, dst_stride_y, width, height,
|
ConvertToLSBPlane_16(src_y, src_stride_y, dst_y, dst_stride_y, width, height,
|
||||||
@ -1613,7 +1624,8 @@ int P010ToP410(const uint16_t* src_y,
|
|||||||
int width,
|
int width,
|
||||||
int height) {
|
int height) {
|
||||||
int r;
|
int r;
|
||||||
if ((!src_y && dst_y) || !src_uv || !dst_uv || width <= 0 || height == 0) {
|
if ((!src_y && dst_y) || !src_uv || !dst_uv || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1638,7 +1650,8 @@ int P210ToP410(const uint16_t* src_y,
|
|||||||
int width,
|
int width,
|
||||||
int height) {
|
int height) {
|
||||||
int r;
|
int r;
|
||||||
if ((!src_y && dst_y) || !src_uv || !dst_uv || width <= 0 || height == 0) {
|
if ((!src_y && dst_y) || !src_uv || !dst_uv || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1668,10 +1681,13 @@ int YUY2ToI420(const uint8_t* src_yuy2,
|
|||||||
YUY2ToUVRow_C;
|
YUY2ToUVRow_C;
|
||||||
void (*YUY2ToYRow)(const uint8_t* src_yuy2, uint8_t* dst_y, int width) =
|
void (*YUY2ToYRow)(const uint8_t* src_yuy2, uint8_t* dst_y, int width) =
|
||||||
YUY2ToYRow_C;
|
YUY2ToYRow_C;
|
||||||
|
if (width <= 0 || height == 0 || height == INT_MIN) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_yuy2 = src_yuy2 + (height - 1) * src_stride_yuy2;
|
src_yuy2 = src_yuy2 + (ptrdiff_t)(height - 1) * src_stride_yuy2;
|
||||||
src_stride_yuy2 = -src_stride_yuy2;
|
src_stride_yuy2 = -src_stride_yuy2;
|
||||||
}
|
}
|
||||||
#if defined(HAS_YUY2TOYROW_SSE2)
|
#if defined(HAS_YUY2TOYROW_SSE2)
|
||||||
@ -1759,10 +1775,13 @@ int UYVYToI420(const uint8_t* src_uyvy,
|
|||||||
UYVYToUVRow_C;
|
UYVYToUVRow_C;
|
||||||
void (*UYVYToYRow)(const uint8_t* src_uyvy, uint8_t* dst_y, int width) =
|
void (*UYVYToYRow)(const uint8_t* src_uyvy, uint8_t* dst_y, int width) =
|
||||||
UYVYToYRow_C;
|
UYVYToYRow_C;
|
||||||
|
if (width <= 0 || height == 0 || height == INT_MIN) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_uyvy = src_uyvy + (height - 1) * src_stride_uyvy;
|
src_uyvy = src_uyvy + (ptrdiff_t)(height - 1) * src_stride_uyvy;
|
||||||
src_stride_uyvy = -src_stride_uyvy;
|
src_stride_uyvy = -src_stride_uyvy;
|
||||||
}
|
}
|
||||||
#if defined(HAS_UYVYTOYROW_SSE2)
|
#if defined(HAS_UYVYTOYROW_SSE2)
|
||||||
@ -1857,10 +1876,13 @@ int AYUVToNV12(const uint8_t* src_ayuv,
|
|||||||
uint8_t* dst_uv, int width) = AYUVToUVRow_C;
|
uint8_t* dst_uv, int width) = AYUVToUVRow_C;
|
||||||
void (*AYUVToYRow)(const uint8_t* src_ayuv, uint8_t* dst_y, int width) =
|
void (*AYUVToYRow)(const uint8_t* src_ayuv, uint8_t* dst_y, int width) =
|
||||||
AYUVToYRow_C;
|
AYUVToYRow_C;
|
||||||
|
if (width <= 0 || height == 0 || height == INT_MIN) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_ayuv = src_ayuv + (height - 1) * src_stride_ayuv;
|
src_ayuv = src_ayuv + (ptrdiff_t)(height - 1) * src_stride_ayuv;
|
||||||
src_stride_ayuv = -src_stride_ayuv;
|
src_stride_ayuv = -src_stride_ayuv;
|
||||||
}
|
}
|
||||||
// place holders for future intel code
|
// place holders for future intel code
|
||||||
@ -1934,10 +1956,13 @@ int AYUVToNV21(const uint8_t* src_ayuv,
|
|||||||
uint8_t* dst_vu, int width) = AYUVToVURow_C;
|
uint8_t* dst_vu, int width) = AYUVToVURow_C;
|
||||||
void (*AYUVToYRow)(const uint8_t* src_ayuv, uint8_t* dst_y, int width) =
|
void (*AYUVToYRow)(const uint8_t* src_ayuv, uint8_t* dst_y, int width) =
|
||||||
AYUVToYRow_C;
|
AYUVToYRow_C;
|
||||||
|
if (width <= 0 || height == 0 || height == INT_MIN) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_ayuv = src_ayuv + (height - 1) * src_stride_ayuv;
|
src_ayuv = src_ayuv + (ptrdiff_t)(height - 1) * src_stride_ayuv;
|
||||||
src_stride_ayuv = -src_stride_ayuv;
|
src_stride_ayuv = -src_stride_ayuv;
|
||||||
}
|
}
|
||||||
// place holders for future intel code
|
// place holders for future intel code
|
||||||
@ -2150,13 +2175,13 @@ ARGBToUVMatrixRow_C;
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!src_argb || !dst_y || !dst_u || !dst_v || !argbconstants || width <= 0 ||
|
if (!src_argb || !dst_y || !dst_u || !dst_v || !argbconstants || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb = src_argb + (height - 1) * src_stride_argb;
|
src_argb = src_argb + (ptrdiff_t)(height - 1) * src_stride_argb;
|
||||||
src_stride_argb = -src_stride_argb;
|
src_stride_argb = -src_stride_argb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2226,13 +2251,13 @@ int ARGBToI420Alpha(const uint8_t* src_argb,
|
|||||||
void (*ARGBExtractAlphaRow)(const uint8_t* src_argb, uint8_t* dst_a,
|
void (*ARGBExtractAlphaRow)(const uint8_t* src_argb, uint8_t* dst_a,
|
||||||
int width) = ARGBExtractAlphaRow_C;
|
int width) = ARGBExtractAlphaRow_C;
|
||||||
if (!src_argb || !dst_y || !dst_u || !dst_v || !dst_a || width <= 0 ||
|
if (!src_argb || !dst_y || !dst_u || !dst_v || !dst_a || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb = src_argb + (height - 1) * src_stride_argb;
|
src_argb = src_argb + (ptrdiff_t)(height - 1) * src_stride_argb;
|
||||||
src_stride_argb = -src_stride_argb;
|
src_stride_argb = -src_stride_argb;
|
||||||
}
|
}
|
||||||
#if defined(HAS_ARGBTOYROW_NEON)
|
#if defined(HAS_ARGBTOYROW_NEON)
|
||||||
@ -2566,13 +2591,14 @@ int RGB24ToI420(const uint8_t* src_rgb24,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!src_rgb24 || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) {
|
if (!src_rgb24 || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_rgb24 = src_rgb24 + (height - 1) * src_stride_rgb24;
|
src_rgb24 = src_rgb24 + (ptrdiff_t)(height - 1) * src_stride_rgb24;
|
||||||
src_stride_rgb24 = -src_stride_rgb24;
|
src_stride_rgb24 = -src_stride_rgb24;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2626,13 +2652,14 @@ int RGB24ToJ420(const uint8_t* src_rgb24,
|
|||||||
void (*ARGBToYJRow)(const uint8_t* src_argb, uint8_t* dst_y, int width) =
|
void (*ARGBToYJRow)(const uint8_t* src_argb, uint8_t* dst_y, int width) =
|
||||||
ARGBToYJRow_C;
|
ARGBToYJRow_C;
|
||||||
#endif
|
#endif
|
||||||
if (!src_rgb24 || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) {
|
if (!src_rgb24 || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_rgb24 = src_rgb24 + (height - 1) * src_stride_rgb24;
|
src_rgb24 = src_rgb24 + (ptrdiff_t)(height - 1) * src_stride_rgb24;
|
||||||
src_stride_rgb24 = -src_stride_rgb24;
|
src_stride_rgb24 = -src_stride_rgb24;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2881,13 +2908,14 @@ int RAWToI420(const uint8_t* src_rgb24,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!src_rgb24 || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) {
|
if (!src_rgb24 || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_rgb24 = src_rgb24 + (height - 1) * src_stride_rgb24;
|
src_rgb24 = src_rgb24 + (ptrdiff_t)(height - 1) * src_stride_rgb24;
|
||||||
src_stride_rgb24 = -src_stride_rgb24;
|
src_stride_rgb24 = -src_stride_rgb24;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2941,13 +2969,14 @@ int RAWToJ420(const uint8_t* src_raw,
|
|||||||
void (*ARGBToYJRow)(const uint8_t* src_argb, uint8_t* dst_y, int width) =
|
void (*ARGBToYJRow)(const uint8_t* src_argb, uint8_t* dst_y, int width) =
|
||||||
ARGBToYJRow_C;
|
ARGBToYJRow_C;
|
||||||
#endif
|
#endif
|
||||||
if (!src_raw || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) {
|
if (!src_raw || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_raw = src_raw + (height - 1) * src_stride_raw;
|
src_raw = src_raw + (ptrdiff_t)(height - 1) * src_stride_raw;
|
||||||
src_stride_raw = -src_stride_raw;
|
src_stride_raw = -src_stride_raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3149,12 +3178,13 @@ int RAWToI444(const uint8_t* src_raw,
|
|||||||
ARGBToYRow_C;
|
ARGBToYRow_C;
|
||||||
void (*ARGBToUV444Row)(const uint8_t* src_raw, uint8_t* dst_u, uint8_t* dst_v,
|
void (*ARGBToUV444Row)(const uint8_t* src_raw, uint8_t* dst_u, uint8_t* dst_v,
|
||||||
int width) = ARGBToUV444Row_C;
|
int width) = ARGBToUV444Row_C;
|
||||||
if (!src_raw || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) {
|
if (!src_raw || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_raw = src_raw + (height - 1) * src_stride_raw;
|
src_raw = src_raw + (ptrdiff_t)(height - 1) * src_stride_raw;
|
||||||
src_stride_raw = -src_stride_raw;
|
src_stride_raw = -src_stride_raw;
|
||||||
}
|
}
|
||||||
// TODO: add row coalesce when main loop handles large width in blocks
|
// TODO: add row coalesce when main loop handles large width in blocks
|
||||||
@ -3377,12 +3407,13 @@ int RAWToJ444(const uint8_t* src_raw,
|
|||||||
ARGBToYJRow_C;
|
ARGBToYJRow_C;
|
||||||
void (*ARGBToUVJ444Row)(const uint8_t* src_raw, uint8_t* dst_u,
|
void (*ARGBToUVJ444Row)(const uint8_t* src_raw, uint8_t* dst_u,
|
||||||
uint8_t* dst_v, int width) = ARGBToUVJ444Row_C;
|
uint8_t* dst_v, int width) = ARGBToUVJ444Row_C;
|
||||||
if (!src_raw || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) {
|
if (!src_raw || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_raw = src_raw + (height - 1) * src_stride_raw;
|
src_raw = src_raw + (ptrdiff_t)(height - 1) * src_stride_raw;
|
||||||
src_stride_raw = -src_stride_raw;
|
src_stride_raw = -src_stride_raw;
|
||||||
}
|
}
|
||||||
// TODO: add row coalesce when main loop handles large width in blocks
|
// TODO: add row coalesce when main loop handles large width in blocks
|
||||||
@ -3628,13 +3659,14 @@ int RGB565ToI420(const uint8_t* src_rgb565,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!src_rgb565 || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) {
|
if (!src_rgb565 || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_rgb565 = src_rgb565 + (height - 1) * src_stride_rgb565;
|
src_rgb565 = src_rgb565 + (ptrdiff_t)(height - 1) * src_stride_rgb565;
|
||||||
src_stride_rgb565 = -src_stride_rgb565;
|
src_stride_rgb565 = -src_stride_rgb565;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3707,13 +3739,14 @@ int ARGB1555ToI420(const uint8_t* src_argb1555,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!src_argb1555 || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) {
|
if (!src_argb1555 || !dst_y || !dst_u || !dst_v || width <= 0 ||
|
||||||
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb1555 = src_argb1555 + (height - 1) * src_stride_argb1555;
|
src_argb1555 = src_argb1555 + (ptrdiff_t)(height - 1) * src_stride_argb1555;
|
||||||
src_stride_argb1555 = -src_stride_argb1555;
|
src_stride_argb1555 = -src_stride_argb1555;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3786,13 +3819,14 @@ int ARGB4444ToI420(const uint8_t* src_argb4444,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!src_argb4444 || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) {
|
if (!src_argb4444 || !dst_y || !dst_u || !dst_v || width <= 0 ||
|
||||||
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb4444 = src_argb4444 + (height - 1) * src_stride_argb4444;
|
src_argb4444 = src_argb4444 + (ptrdiff_t)(height - 1) * src_stride_argb4444;
|
||||||
src_stride_argb4444 = -src_stride_argb4444;
|
src_stride_argb4444 = -src_stride_argb4444;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3886,12 +3920,12 @@ int RGB24ToJ400(const uint8_t* src_rgb24,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!src_rgb24 || !dst_yj || width <= 0 || height == 0) {
|
if (!src_rgb24 || !dst_yj || width <= 0 || height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_rgb24 = src_rgb24 + (height - 1) * src_stride_rgb24;
|
src_rgb24 = src_rgb24 + (ptrdiff_t)(height - 1) * src_stride_rgb24;
|
||||||
src_stride_rgb24 = -src_stride_rgb24;
|
src_stride_rgb24 = -src_stride_rgb24;
|
||||||
}
|
}
|
||||||
// Coalesce rows.
|
// Coalesce rows.
|
||||||
@ -4052,12 +4086,12 @@ int RAWToJ400(const uint8_t* src_raw,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!src_raw || !dst_yj || width <= 0 || height == 0) {
|
if (!src_raw || !dst_yj || width <= 0 || height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_raw = src_raw + (height - 1) * src_stride_raw;
|
src_raw = src_raw + (ptrdiff_t)(height - 1) * src_stride_raw;
|
||||||
src_stride_raw = -src_stride_raw;
|
src_stride_raw = -src_stride_raw;
|
||||||
}
|
}
|
||||||
// Coalesce rows.
|
// Coalesce rows.
|
||||||
@ -4185,15 +4219,16 @@ static int Biplanar16bitTo8bit(const uint16_t* src_y,
|
|||||||
int uv_width = SUBSAMPLE(width, subsample_x, subsample_x);
|
int uv_width = SUBSAMPLE(width, subsample_x, subsample_x);
|
||||||
int uv_height = SUBSAMPLE(height, subsample_y, subsample_y);
|
int uv_height = SUBSAMPLE(height, subsample_y, subsample_y);
|
||||||
int scale = 1 << (24 - depth);
|
int scale = 1 << (24 - depth);
|
||||||
if ((!src_y && dst_y) || !src_uv || !dst_uv || width <= 0 || height == 0) {
|
if ((!src_y && dst_y) || !src_uv || !dst_uv || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
uv_height = -uv_height;
|
uv_height = -uv_height;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_uv = src_uv + (uv_height - 1) * src_stride_uv;
|
src_uv = src_uv + (ptrdiff_t)(uv_height - 1) * src_stride_uv;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_uv = -src_stride_uv;
|
src_stride_uv = -src_stride_uv;
|
||||||
}
|
}
|
||||||
@ -4251,16 +4286,16 @@ static int Planar8bitTo8bit(const uint8_t* src_y,
|
|||||||
int uv_width = SUBSAMPLE(width, subsample_x, subsample_x);
|
int uv_width = SUBSAMPLE(width, subsample_x, subsample_x);
|
||||||
int uv_height = SUBSAMPLE(height, subsample_y, subsample_y);
|
int uv_height = SUBSAMPLE(height, subsample_y, subsample_y);
|
||||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
uv_height = -uv_height;
|
uv_height = -uv_height;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (uv_height - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(uv_height - 1) * src_stride_u;
|
||||||
src_v = src_v + (uv_height - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(uv_height - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -89,16 +89,16 @@ int I420ToI010(const uint8_t* src_y,
|
|||||||
int halfwidth = (width + 1) >> 1;
|
int halfwidth = (width + 1) >> 1;
|
||||||
int halfheight = (height + 1) >> 1;
|
int halfheight = (height + 1) >> 1;
|
||||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
halfheight = (height + 1) >> 1;
|
halfheight = (height + 1) >> 1;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (halfheight - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(halfheight - 1) * src_stride_u;
|
||||||
src_v = src_v + (halfheight - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(halfheight - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
@ -134,16 +134,16 @@ int I420ToI012(const uint8_t* src_y,
|
|||||||
int halfwidth = (width + 1) >> 1;
|
int halfwidth = (width + 1) >> 1;
|
||||||
int halfheight = (height + 1) >> 1;
|
int halfheight = (height + 1) >> 1;
|
||||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
halfheight = (height + 1) >> 1;
|
halfheight = (height + 1) >> 1;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (halfheight - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(halfheight - 1) * src_stride_u;
|
||||||
src_v = src_v + (halfheight - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(halfheight - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
@ -228,7 +228,7 @@ int I010ToI410(const uint16_t* src_y,
|
|||||||
int height) {
|
int height) {
|
||||||
int r;
|
int r;
|
||||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ int I210ToI410(const uint16_t* src_y,
|
|||||||
int height) {
|
int height) {
|
||||||
int r;
|
int r;
|
||||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,7 +301,7 @@ int I422ToI444(const uint8_t* src_y,
|
|||||||
int height) {
|
int height) {
|
||||||
int r;
|
int r;
|
||||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,7 +326,7 @@ int I400Copy(const uint8_t* src_y,
|
|||||||
int dst_stride_y,
|
int dst_stride_y,
|
||||||
int width,
|
int width,
|
||||||
int height) {
|
int height) {
|
||||||
if (!src_y || !dst_y || width <= 0 || height == 0) {
|
if (!src_y || !dst_y || width <= 0 || height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||||
@ -348,13 +348,14 @@ int I422ToYUY2(const uint8_t* src_y,
|
|||||||
void (*I422ToYUY2Row)(const uint8_t* src_y, const uint8_t* src_u,
|
void (*I422ToYUY2Row)(const uint8_t* src_y, const uint8_t* src_u,
|
||||||
const uint8_t* src_v, uint8_t* dst_yuy2, int width) =
|
const uint8_t* src_v, uint8_t* dst_yuy2, int width) =
|
||||||
I422ToYUY2Row_C;
|
I422ToYUY2Row_C;
|
||||||
if (!src_y || !src_u || !src_v || !dst_yuy2 || width <= 0 || height == 0) {
|
if (!src_y || !src_u || !src_v || !dst_yuy2 || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
dst_yuy2 = dst_yuy2 + (height - 1) * dst_stride_yuy2;
|
dst_yuy2 = dst_yuy2 + (ptrdiff_t)(height - 1) * dst_stride_yuy2;
|
||||||
dst_stride_yuy2 = -dst_stride_yuy2;
|
dst_stride_yuy2 = -dst_stride_yuy2;
|
||||||
}
|
}
|
||||||
// Coalesce rows.
|
// Coalesce rows.
|
||||||
@ -415,13 +416,14 @@ int I420ToYUY2(const uint8_t* src_y,
|
|||||||
void (*I422ToYUY2Row)(const uint8_t* src_y, const uint8_t* src_u,
|
void (*I422ToYUY2Row)(const uint8_t* src_y, const uint8_t* src_u,
|
||||||
const uint8_t* src_v, uint8_t* dst_yuy2, int width) =
|
const uint8_t* src_v, uint8_t* dst_yuy2, int width) =
|
||||||
I422ToYUY2Row_C;
|
I422ToYUY2Row_C;
|
||||||
if (!src_y || !src_u || !src_v || !dst_yuy2 || width <= 0 || height == 0) {
|
if (!src_y || !src_u || !src_v || !dst_yuy2 || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
dst_yuy2 = dst_yuy2 + (height - 1) * dst_stride_yuy2;
|
dst_yuy2 = dst_yuy2 + (ptrdiff_t)(height - 1) * dst_stride_yuy2;
|
||||||
dst_stride_yuy2 = -dst_stride_yuy2;
|
dst_stride_yuy2 = -dst_stride_yuy2;
|
||||||
}
|
}
|
||||||
#if defined(HAS_I422TOYUY2ROW_SSE2)
|
#if defined(HAS_I422TOYUY2ROW_SSE2)
|
||||||
@ -495,13 +497,14 @@ int I422ToUYVY(const uint8_t* src_y,
|
|||||||
void (*I422ToUYVYRow)(const uint8_t* src_y, const uint8_t* src_u,
|
void (*I422ToUYVYRow)(const uint8_t* src_y, const uint8_t* src_u,
|
||||||
const uint8_t* src_v, uint8_t* dst_uyvy, int width) =
|
const uint8_t* src_v, uint8_t* dst_uyvy, int width) =
|
||||||
I422ToUYVYRow_C;
|
I422ToUYVYRow_C;
|
||||||
if (!src_y || !src_u || !src_v || !dst_uyvy || width <= 0 || height == 0) {
|
if (!src_y || !src_u || !src_v || !dst_uyvy || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
dst_uyvy = dst_uyvy + (height - 1) * dst_stride_uyvy;
|
dst_uyvy = dst_uyvy + (ptrdiff_t)(height - 1) * dst_stride_uyvy;
|
||||||
dst_stride_uyvy = -dst_stride_uyvy;
|
dst_stride_uyvy = -dst_stride_uyvy;
|
||||||
}
|
}
|
||||||
// Coalesce rows.
|
// Coalesce rows.
|
||||||
@ -578,13 +581,14 @@ int I420ToUYVY(const uint8_t* src_y,
|
|||||||
void (*I422ToUYVYRow)(const uint8_t* src_y, const uint8_t* src_u,
|
void (*I422ToUYVYRow)(const uint8_t* src_y, const uint8_t* src_u,
|
||||||
const uint8_t* src_v, uint8_t* dst_uyvy, int width) =
|
const uint8_t* src_v, uint8_t* dst_uyvy, int width) =
|
||||||
I422ToUYVYRow_C;
|
I422ToUYVYRow_C;
|
||||||
if (!src_y || !src_u || !src_v || !dst_uyvy || width <= 0 || height == 0) {
|
if (!src_y || !src_u || !src_v || !dst_uyvy || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
dst_uyvy = dst_uyvy + (height - 1) * dst_stride_uyvy;
|
dst_uyvy = dst_uyvy + (ptrdiff_t)(height - 1) * dst_stride_uyvy;
|
||||||
dst_stride_uyvy = -dst_stride_uyvy;
|
dst_stride_uyvy = -dst_stride_uyvy;
|
||||||
}
|
}
|
||||||
#if defined(HAS_I422TOUYVYROW_SSE2)
|
#if defined(HAS_I422TOUYVYROW_SSE2)
|
||||||
@ -659,16 +663,16 @@ int I420ToNV12(const uint8_t* src_y,
|
|||||||
int halfwidth = (width + 1) / 2;
|
int halfwidth = (width + 1) / 2;
|
||||||
int halfheight = (height + 1) / 2;
|
int halfheight = (height + 1) / 2;
|
||||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_uv || width <= 0 ||
|
if ((!src_y && dst_y) || !src_u || !src_v || !dst_uv || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
halfheight = (height + 1) >> 1;
|
halfheight = (height + 1) >> 1;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (halfheight - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(halfheight - 1) * src_stride_u;
|
||||||
src_v = src_v + (halfheight - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(halfheight - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
@ -714,7 +718,8 @@ int ConvertFromI420(const uint8_t* y,
|
|||||||
uint32_t fourcc) {
|
uint32_t fourcc) {
|
||||||
uint32_t format = CanonicalFourCC(fourcc);
|
uint32_t format = CanonicalFourCC(fourcc);
|
||||||
int r = 0;
|
int r = 0;
|
||||||
if (!y || !u || !v || !dst_sample || width <= 0 || height == 0) {
|
if (!y || !u || !v || !dst_sample || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
switch (format) {
|
switch (format) {
|
||||||
|
|||||||
@ -154,13 +154,13 @@ ARGBToUV444MatrixRow_C;
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!src_argb || !dst_y || !dst_u || !dst_v || !argbconstants || width <= 0 ||
|
if (!src_argb || !dst_y || !dst_u || !dst_v || !argbconstants || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb = src_argb + (height - 1) * src_stride_argb;
|
src_argb = src_argb + (ptrdiff_t)(height - 1) * src_stride_argb;
|
||||||
src_stride_argb = -src_stride_argb;
|
src_stride_argb = -src_stride_argb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,13 +329,13 @@ ARGBToUVMatrixRow_C;
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!src_argb || !dst_y || !dst_u || !dst_v || !argbconstants || width <= 0 ||
|
if (!src_argb || !dst_y || !dst_u || !dst_v || !argbconstants || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb = src_argb + (height - 1) * src_stride_argb;
|
src_argb = src_argb + (ptrdiff_t)(height - 1) * src_stride_argb;
|
||||||
src_stride_argb = -src_stride_argb;
|
src_stride_argb = -src_stride_argb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,13 +493,13 @@ ARGBToUVMatrixRow_C;
|
|||||||
void (*MergeUVRow)(const uint8_t* src_u, const uint8_t* src_v,
|
void (*MergeUVRow)(const uint8_t* src_u, const uint8_t* src_v,
|
||||||
uint8_t* dst_uv, int width) = MergeUVRow_C;
|
uint8_t* dst_uv, int width) = MergeUVRow_C;
|
||||||
if (!src_argb || !dst_y || !dst_uv || !argbconstants || width <= 0 ||
|
if (!src_argb || !dst_y || !dst_uv || !argbconstants || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb = src_argb + (height - 1) * src_stride_argb;
|
src_argb = src_argb + (ptrdiff_t)(height - 1) * src_stride_argb;
|
||||||
src_stride_argb = -src_stride_argb;
|
src_stride_argb = -src_stride_argb;
|
||||||
}
|
}
|
||||||
#if defined(HAS_MERGEUVROW_SSE2)
|
#if defined(HAS_MERGEUVROW_SSE2)
|
||||||
@ -708,13 +708,13 @@ ARGBToUVMatrixRow_C;
|
|||||||
void (*MergeUVRow)(const uint8_t* src_u, const uint8_t* src_v,
|
void (*MergeUVRow)(const uint8_t* src_u, const uint8_t* src_v,
|
||||||
uint8_t* dst_vu, int width) = MergeUVRow_C;
|
uint8_t* dst_vu, int width) = MergeUVRow_C;
|
||||||
if (!src_argb || !dst_y || !dst_vu || !argbconstants || width <= 0 ||
|
if (!src_argb || !dst_y || !dst_vu || !argbconstants || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb = src_argb + (height - 1) * src_stride_argb;
|
src_argb = src_argb + (ptrdiff_t)(height - 1) * src_stride_argb;
|
||||||
src_stride_argb = -src_stride_argb;
|
src_stride_argb = -src_stride_argb;
|
||||||
}
|
}
|
||||||
#if defined(HAS_MERGEUVROW_SSE2)
|
#if defined(HAS_MERGEUVROW_SSE2)
|
||||||
@ -804,12 +804,13 @@ int ARGBToI400Matrix(const uint8_t* src_argb,
|
|||||||
int y;
|
int y;
|
||||||
void (*ARGBToYMatrixRow)(const uint8_t* src_argb, uint8_t* dst_y, int width,
|
void (*ARGBToYMatrixRow)(const uint8_t* src_argb, uint8_t* dst_y, int width,
|
||||||
const struct ArgbConstants* c) = ARGBToYMatrixRow_C;
|
const struct ArgbConstants* c) = ARGBToYMatrixRow_C;
|
||||||
if (!src_argb || !dst_y || !constants || width <= 0 || height == 0) {
|
if (!src_argb || !dst_y || !constants || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb = src_argb + (height - 1) * src_stride_argb;
|
src_argb = src_argb + (ptrdiff_t)(height - 1) * src_stride_argb;
|
||||||
src_stride_argb = -src_stride_argb;
|
src_stride_argb = -src_stride_argb;
|
||||||
}
|
}
|
||||||
#if defined(HAS_ARGBTOYMATRIXROW_AVX2)
|
#if defined(HAS_ARGBTOYMATRIXROW_AVX2)
|
||||||
@ -870,12 +871,13 @@ int ARGBToYUY2Matrix(const uint8_t* src_argb,
|
|||||||
const uint8_t* src_v, uint8_t* dst_yuy2, int width) =
|
const uint8_t* src_v, uint8_t* dst_yuy2, int width) =
|
||||||
I422ToYUY2Row_C;
|
I422ToYUY2Row_C;
|
||||||
|
|
||||||
if (!src_argb || !dst_yuy2 || !constants || width <= 0 || height == 0) {
|
if (!src_argb || !dst_yuy2 || !constants || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
dst_yuy2 = dst_yuy2 + (height - 1) * dst_stride_yuy2;
|
dst_yuy2 = dst_yuy2 + (ptrdiff_t)(height - 1) * dst_stride_yuy2;
|
||||||
dst_stride_yuy2 = -dst_stride_yuy2;
|
dst_stride_yuy2 = -dst_stride_yuy2;
|
||||||
}
|
}
|
||||||
#if defined(HAS_ARGBTOYMATRIXROW_AVX2)
|
#if defined(HAS_ARGBTOYMATRIXROW_AVX2)
|
||||||
@ -981,12 +983,13 @@ int ARGBToUYVYMatrix(const uint8_t* src_argb,
|
|||||||
const uint8_t* src_v, uint8_t* dst_uyvy, int width) =
|
const uint8_t* src_v, uint8_t* dst_uyvy, int width) =
|
||||||
I422ToUYVYRow_C;
|
I422ToUYVYRow_C;
|
||||||
|
|
||||||
if (!src_argb || !dst_uyvy || !constants || width <= 0 || height == 0) {
|
if (!src_argb || !dst_uyvy || !constants || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
dst_uyvy = dst_uyvy + (height - 1) * dst_stride_uyvy;
|
dst_uyvy = dst_uyvy + (ptrdiff_t)(height - 1) * dst_stride_uyvy;
|
||||||
dst_stride_uyvy = -dst_stride_uyvy;
|
dst_stride_uyvy = -dst_stride_uyvy;
|
||||||
}
|
}
|
||||||
#if defined(HAS_ARGBTOYMATRIXROW_AVX2)
|
#if defined(HAS_ARGBTOYMATRIXROW_AVX2)
|
||||||
@ -1181,12 +1184,13 @@ int ARGBToRGBA(const uint8_t* src_argb,
|
|||||||
int y;
|
int y;
|
||||||
void (*ARGBToRGBARow)(const uint8_t* src_argb, uint8_t* dst_rgba, int width) =
|
void (*ARGBToRGBARow)(const uint8_t* src_argb, uint8_t* dst_rgba, int width) =
|
||||||
ARGBToRGBARow_C;
|
ARGBToRGBARow_C;
|
||||||
if (!src_argb || !dst_rgba || width <= 0 || height == 0) {
|
if (!src_argb || !dst_rgba || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb = src_argb + (height - 1) * src_stride_argb;
|
src_argb = src_argb + (ptrdiff_t)(height - 1) * src_stride_argb;
|
||||||
src_stride_argb = -src_stride_argb;
|
src_stride_argb = -src_stride_argb;
|
||||||
}
|
}
|
||||||
// Coalesce rows.
|
// Coalesce rows.
|
||||||
@ -1223,12 +1227,13 @@ int ARGBToRGB24(const uint8_t* src_argb,
|
|||||||
int y;
|
int y;
|
||||||
void (*ARGBToRGB24Row)(const uint8_t* src_argb, uint8_t* dst_rgb, int width) =
|
void (*ARGBToRGB24Row)(const uint8_t* src_argb, uint8_t* dst_rgb, int width) =
|
||||||
ARGBToRGB24Row_C;
|
ARGBToRGB24Row_C;
|
||||||
if (!src_argb || !dst_rgb24 || width <= 0 || height == 0) {
|
if (!src_argb || !dst_rgb24 || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb = src_argb + (height - 1) * src_stride_argb;
|
src_argb = src_argb + (ptrdiff_t)(height - 1) * src_stride_argb;
|
||||||
src_stride_argb = -src_stride_argb;
|
src_stride_argb = -src_stride_argb;
|
||||||
}
|
}
|
||||||
// Coalesce rows.
|
// Coalesce rows.
|
||||||
@ -1316,12 +1321,12 @@ int ARGBToRAW(const uint8_t* src_argb,
|
|||||||
int y;
|
int y;
|
||||||
void (*ARGBToRAWRow)(const uint8_t* src_argb, uint8_t* dst_rgb, int width) =
|
void (*ARGBToRAWRow)(const uint8_t* src_argb, uint8_t* dst_rgb, int width) =
|
||||||
ARGBToRAWRow_C;
|
ARGBToRAWRow_C;
|
||||||
if (!src_argb || !dst_raw || width <= 0 || height == 0) {
|
if (!src_argb || !dst_raw || width <= 0 || height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb = src_argb + (height - 1) * src_stride_argb;
|
src_argb = src_argb + (ptrdiff_t)(height - 1) * src_stride_argb;
|
||||||
src_stride_argb = -src_stride_argb;
|
src_stride_argb = -src_stride_argb;
|
||||||
}
|
}
|
||||||
// Coalesce rows.
|
// Coalesce rows.
|
||||||
@ -1408,12 +1413,13 @@ int ARGBToRGB565Dither(const uint8_t* src_argb,
|
|||||||
void (*ARGBToRGB565DitherRow)(const uint8_t* src_argb, uint8_t* dst_rgb,
|
void (*ARGBToRGB565DitherRow)(const uint8_t* src_argb, uint8_t* dst_rgb,
|
||||||
uint32_t dither4, int width) =
|
uint32_t dither4, int width) =
|
||||||
ARGBToRGB565DitherRow_C;
|
ARGBToRGB565DitherRow_C;
|
||||||
if (!src_argb || !dst_rgb565 || width <= 0 || height == 0) {
|
if (!src_argb || !dst_rgb565 || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb = src_argb + (height - 1) * src_stride_argb;
|
src_argb = src_argb + (ptrdiff_t)(height - 1) * src_stride_argb;
|
||||||
src_stride_argb = -src_stride_argb;
|
src_stride_argb = -src_stride_argb;
|
||||||
}
|
}
|
||||||
if (!dither4x4) {
|
if (!dither4x4) {
|
||||||
@ -1480,12 +1486,13 @@ int ARGBToRGB565(const uint8_t* src_argb,
|
|||||||
int y;
|
int y;
|
||||||
void (*ARGBToRGB565Row)(const uint8_t* src_argb, uint8_t* dst_rgb,
|
void (*ARGBToRGB565Row)(const uint8_t* src_argb, uint8_t* dst_rgb,
|
||||||
int width) = ARGBToRGB565Row_C;
|
int width) = ARGBToRGB565Row_C;
|
||||||
if (!src_argb || !dst_rgb565 || width <= 0 || height == 0) {
|
if (!src_argb || !dst_rgb565 || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb = src_argb + (height - 1) * src_stride_argb;
|
src_argb = src_argb + (ptrdiff_t)(height - 1) * src_stride_argb;
|
||||||
src_stride_argb = -src_stride_argb;
|
src_stride_argb = -src_stride_argb;
|
||||||
}
|
}
|
||||||
// Coalesce rows.
|
// Coalesce rows.
|
||||||
@ -1554,12 +1561,13 @@ int ARGBToARGB1555(const uint8_t* src_argb,
|
|||||||
int y;
|
int y;
|
||||||
void (*ARGBToARGB1555Row)(const uint8_t* src_argb, uint8_t* dst_rgb,
|
void (*ARGBToARGB1555Row)(const uint8_t* src_argb, uint8_t* dst_rgb,
|
||||||
int width) = ARGBToARGB1555Row_C;
|
int width) = ARGBToARGB1555Row_C;
|
||||||
if (!src_argb || !dst_argb1555 || width <= 0 || height == 0) {
|
if (!src_argb || !dst_argb1555 || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb = src_argb + (height - 1) * src_stride_argb;
|
src_argb = src_argb + (ptrdiff_t)(height - 1) * src_stride_argb;
|
||||||
src_stride_argb = -src_stride_argb;
|
src_stride_argb = -src_stride_argb;
|
||||||
}
|
}
|
||||||
// Coalesce rows.
|
// Coalesce rows.
|
||||||
@ -1622,12 +1630,13 @@ int ARGBToARGB4444(const uint8_t* src_argb,
|
|||||||
int y;
|
int y;
|
||||||
void (*ARGBToARGB4444Row)(const uint8_t* src_argb, uint8_t* dst_rgb,
|
void (*ARGBToARGB4444Row)(const uint8_t* src_argb, uint8_t* dst_rgb,
|
||||||
int width) = ARGBToARGB4444Row_C;
|
int width) = ARGBToARGB4444Row_C;
|
||||||
if (!src_argb || !dst_argb4444 || width <= 0 || height == 0) {
|
if (!src_argb || !dst_argb4444 || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb = src_argb + (height - 1) * src_stride_argb;
|
src_argb = src_argb + (ptrdiff_t)(height - 1) * src_stride_argb;
|
||||||
src_stride_argb = -src_stride_argb;
|
src_stride_argb = -src_stride_argb;
|
||||||
}
|
}
|
||||||
// Coalesce rows.
|
// Coalesce rows.
|
||||||
@ -1690,12 +1699,13 @@ int ABGRToAR30(const uint8_t* src_abgr,
|
|||||||
int y;
|
int y;
|
||||||
void (*ABGRToAR30Row)(const uint8_t* src_abgr, uint8_t* dst_rgb, int width) =
|
void (*ABGRToAR30Row)(const uint8_t* src_abgr, uint8_t* dst_rgb, int width) =
|
||||||
ABGRToAR30Row_C;
|
ABGRToAR30Row_C;
|
||||||
if (!src_abgr || !dst_ar30 || width <= 0 || height == 0) {
|
if (!src_abgr || !dst_ar30 || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_abgr = src_abgr + (height - 1) * src_stride_abgr;
|
src_abgr = src_abgr + (ptrdiff_t)(height - 1) * src_stride_abgr;
|
||||||
src_stride_abgr = -src_stride_abgr;
|
src_stride_abgr = -src_stride_abgr;
|
||||||
}
|
}
|
||||||
// Coalesce rows.
|
// Coalesce rows.
|
||||||
@ -1748,12 +1758,13 @@ int ARGBToAR30(const uint8_t* src_argb,
|
|||||||
int y;
|
int y;
|
||||||
void (*ARGBToAR30Row)(const uint8_t* src_argb, uint8_t* dst_rgb, int width) =
|
void (*ARGBToAR30Row)(const uint8_t* src_argb, uint8_t* dst_rgb, int width) =
|
||||||
ARGBToAR30Row_C;
|
ARGBToAR30Row_C;
|
||||||
if (!src_argb || !dst_ar30 || width <= 0 || height == 0) {
|
if (!src_argb || !dst_ar30 || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb = src_argb + (height - 1) * src_stride_argb;
|
src_argb = src_argb + (ptrdiff_t)(height - 1) * src_stride_argb;
|
||||||
src_stride_argb = -src_stride_argb;
|
src_stride_argb = -src_stride_argb;
|
||||||
}
|
}
|
||||||
// Coalesce rows.
|
// Coalesce rows.
|
||||||
@ -1869,12 +1880,12 @@ int RGBAToJ400(const uint8_t* src_rgba,
|
|||||||
int y;
|
int y;
|
||||||
void (*RGBAToYJRow)(const uint8_t* src_rgba, uint8_t* dst_yj, int width) =
|
void (*RGBAToYJRow)(const uint8_t* src_rgba, uint8_t* dst_yj, int width) =
|
||||||
RGBAToYJRow_C;
|
RGBAToYJRow_C;
|
||||||
if (!src_rgba || !dst_yj || width <= 0 || height == 0) {
|
if (!src_rgba || !dst_yj || width <= 0 || height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_rgba = src_rgba + (height - 1) * src_stride_rgba;
|
src_rgba = src_rgba + (ptrdiff_t)(height - 1) * src_stride_rgba;
|
||||||
src_stride_rgba = -src_stride_rgba;
|
src_stride_rgba = -src_stride_rgba;
|
||||||
}
|
}
|
||||||
// Coalesce rows.
|
// Coalesce rows.
|
||||||
@ -2011,13 +2022,14 @@ int ARGBToAR64(const uint8_t* src_argb,
|
|||||||
int y;
|
int y;
|
||||||
void (*ARGBToAR64Row)(const uint8_t* src_argb, uint16_t* dst_ar64,
|
void (*ARGBToAR64Row)(const uint8_t* src_argb, uint16_t* dst_ar64,
|
||||||
int width) = ARGBToAR64Row_C;
|
int width) = ARGBToAR64Row_C;
|
||||||
if (!src_argb || !dst_ar64 || width <= 0 || height == 0) {
|
if (!src_argb || !dst_ar64 || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb = src_argb + (height - 1) * src_stride_argb;
|
src_argb = src_argb + (ptrdiff_t)(height - 1) * src_stride_argb;
|
||||||
src_stride_argb = -src_stride_argb;
|
src_stride_argb = -src_stride_argb;
|
||||||
}
|
}
|
||||||
// Coalesce rows.
|
// Coalesce rows.
|
||||||
@ -2076,13 +2088,14 @@ int ARGBToAB64(const uint8_t* src_argb,
|
|||||||
int y;
|
int y;
|
||||||
void (*ARGBToAB64Row)(const uint8_t* src_argb, uint16_t* dst_ar64,
|
void (*ARGBToAB64Row)(const uint8_t* src_argb, uint16_t* dst_ar64,
|
||||||
int width) = ARGBToAB64Row_C;
|
int width) = ARGBToAB64Row_C;
|
||||||
if (!src_argb || !dst_ab64 || width <= 0 || height == 0) {
|
if (!src_argb || !dst_ab64 || width <= 0 || height == 0 ||
|
||||||
|
height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb = src_argb + (height - 1) * src_stride_argb;
|
src_argb = src_argb + (ptrdiff_t)(height - 1) * src_stride_argb;
|
||||||
src_stride_argb = -src_stride_argb;
|
src_stride_argb = -src_stride_argb;
|
||||||
}
|
}
|
||||||
// Coalesce rows.
|
// Coalesce rows.
|
||||||
@ -2215,14 +2228,14 @@ int RAWToNV21Matrix(const uint8_t* src_raw,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!src_raw || !dst_y || !dst_vu || !argbconstants || width <= 0 ||
|
||||||
if (!src_raw || !dst_y || !dst_vu || !argbconstants || width <= 0 || height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_raw = src_raw + (height - 1) * src_stride_raw;
|
src_raw = src_raw + (ptrdiff_t)(height - 1) * src_stride_raw;
|
||||||
src_stride_raw = -src_stride_raw;
|
src_stride_raw = -src_stride_raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -72,7 +72,8 @@ int ConvertToARGB(const uint8_t* sample,
|
|||||||
|
|
||||||
if (dst_argb == NULL || sample == NULL || src_width <= 0 ||
|
if (dst_argb == NULL || sample == NULL || src_width <= 0 ||
|
||||||
src_width > INT_MAX / 4 || crop_width <= 0 || crop_width > INT_MAX / 4 ||
|
src_width > INT_MAX / 4 || crop_width <= 0 || crop_width > INT_MAX / 4 ||
|
||||||
src_height == 0 || crop_height == 0) {
|
src_height == 0 || src_height == INT_MIN || crop_height == 0 ||
|
||||||
|
crop_height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (src_height < 0) {
|
if (src_height < 0) {
|
||||||
|
|||||||
@ -66,7 +66,8 @@ int ConvertToI420(const uint8_t* sample,
|
|||||||
|
|
||||||
if (!dst_y || !dst_u || !dst_v || !sample || src_width <= 0 ||
|
if (!dst_y || !dst_u || !dst_v || !sample || src_width <= 0 ||
|
||||||
src_width > INT_MAX / 4 || crop_width <= 0 || src_height == 0 ||
|
src_width > INT_MAX / 4 || crop_width <= 0 || src_height == 0 ||
|
||||||
crop_height == 0 || crop_x < 0 || crop_y < 0 || crop_width > src_width ||
|
src_height == INT_MIN || crop_height == 0 || crop_height == INT_MIN ||
|
||||||
|
crop_x < 0 || crop_y < 0 || crop_width > src_width ||
|
||||||
crop_x > src_width - crop_width || abs_crop_height > abs_src_height ||
|
crop_x > src_width - crop_width || abs_crop_height > abs_src_height ||
|
||||||
crop_y > abs_src_height - abs_crop_height) {
|
crop_y > abs_src_height - abs_crop_height) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#include "libyuv/rotate.h"
|
#include "libyuv/rotate.h"
|
||||||
|
|
||||||
@ -431,14 +432,15 @@ int SplitRotateUV(const uint8_t* src_uv,
|
|||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
enum RotationMode mode) {
|
enum RotationMode mode) {
|
||||||
if (!src_uv || width <= 0 || height == 0 || !dst_u || !dst_v) {
|
if (!src_uv || width <= 0 || height == 0 || height == INT_MIN || !dst_u ||
|
||||||
|
!dst_v) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_uv = src_uv + (height - 1) * src_stride_uv;
|
src_uv = src_uv + (ptrdiff_t)(height - 1) * src_stride_uv;
|
||||||
src_stride_uv = -src_stride_uv;
|
src_stride_uv = -src_stride_uv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,14 +475,14 @@ int RotatePlane(const uint8_t* src,
|
|||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
enum RotationMode mode) {
|
enum RotationMode mode) {
|
||||||
if (!src || width <= 0 || height == 0 || !dst) {
|
if (!src || width <= 0 || height == 0 || height == INT_MIN || !dst) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src = src + (height - 1) * src_stride;
|
src = src + (ptrdiff_t)(height - 1) * src_stride;
|
||||||
src_stride = -src_stride;
|
src_stride = -src_stride;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,14 +593,14 @@ int RotatePlane_16(const uint16_t* src,
|
|||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
enum RotationMode mode) {
|
enum RotationMode mode) {
|
||||||
if (!src || width <= 0 || height == 0 || !dst) {
|
if (!src || width <= 0 || height == 0 || height == INT_MIN || !dst) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src = src + (height - 1) * src_stride;
|
src = src + (ptrdiff_t)(height - 1) * src_stride;
|
||||||
src_stride = -src_stride;
|
src_stride = -src_stride;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,7 +643,7 @@ int I420Rotate(const uint8_t* src_y,
|
|||||||
int halfwidth = (width + 1) >> 1;
|
int halfwidth = (width + 1) >> 1;
|
||||||
int halfheight = (height + 1) >> 1;
|
int halfheight = (height + 1) >> 1;
|
||||||
if ((!src_y && dst_y) || !src_u || !src_v || width <= 0 || height == 0 ||
|
if ((!src_y && dst_y) || !src_u || !src_v || width <= 0 || height == 0 ||
|
||||||
!dst_y || !dst_u || !dst_v) {
|
height == INT_MIN || !dst_y || !dst_u || !dst_v) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -649,9 +651,9 @@ int I420Rotate(const uint8_t* src_y,
|
|||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
halfheight = (height + 1) >> 1;
|
halfheight = (height + 1) >> 1;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (halfheight - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(halfheight - 1) * src_stride_u;
|
||||||
src_v = src_v + (halfheight - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(halfheight - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
@ -711,16 +713,16 @@ int I422Rotate(const uint8_t* src_y,
|
|||||||
int halfwidth = (width + 1) >> 1;
|
int halfwidth = (width + 1) >> 1;
|
||||||
int halfheight = (height + 1) >> 1;
|
int halfheight = (height + 1) >> 1;
|
||||||
int r;
|
int r;
|
||||||
if (!src_y || !src_u || !src_v || width <= 0 || height == 0 || !dst_y ||
|
if (!src_y || !src_u || !src_v || width <= 0 || height == 0 ||
|
||||||
!dst_u || !dst_v) {
|
height == INT_MIN || !dst_y || !dst_u || !dst_v) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (height - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(height - 1) * src_stride_u;
|
||||||
src_v = src_v + (height - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(height - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
@ -806,17 +808,17 @@ int I444Rotate(const uint8_t* src_y,
|
|||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
enum RotationMode mode) {
|
enum RotationMode mode) {
|
||||||
if (!src_y || !src_u || !src_v || width <= 0 || height == 0 || !dst_y ||
|
if (!src_y || !src_u || !src_v || width <= 0 || height == 0 ||
|
||||||
!dst_u || !dst_v) {
|
height == INT_MIN || !dst_y || !dst_u || !dst_v) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (height - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(height - 1) * src_stride_u;
|
||||||
src_v = src_v + (height - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(height - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
@ -866,8 +868,8 @@ int NV12ToI420Rotate(const uint8_t* src_y,
|
|||||||
enum RotationMode mode) {
|
enum RotationMode mode) {
|
||||||
int halfwidth = (width + 1) >> 1;
|
int halfwidth = (width + 1) >> 1;
|
||||||
int halfheight = (height + 1) >> 1;
|
int halfheight = (height + 1) >> 1;
|
||||||
if (!src_y || !src_uv || width <= 0 || height == 0 || !dst_y || !dst_u ||
|
if (!src_y || !src_uv || width <= 0 || height == 0 || height == INT_MIN ||
|
||||||
!dst_v) {
|
!dst_y || !dst_u || !dst_v) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -875,8 +877,8 @@ int NV12ToI420Rotate(const uint8_t* src_y,
|
|||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
halfheight = (height + 1) >> 1;
|
halfheight = (height + 1) >> 1;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_uv = src_uv + (halfheight - 1) * src_stride_uv;
|
src_uv = src_uv + (ptrdiff_t)(halfheight - 1) * src_stride_uv;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_uv = -src_stride_uv;
|
src_stride_uv = -src_stride_uv;
|
||||||
}
|
}
|
||||||
@ -943,16 +945,16 @@ int Android420ToI420Rotate(const uint8_t* src_y,
|
|||||||
int halfwidth = (width + 1) >> 1;
|
int halfwidth = (width + 1) >> 1;
|
||||||
int halfheight = (height + 1) >> 1;
|
int halfheight = (height + 1) >> 1;
|
||||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
||||||
height == 0) {
|
height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
halfheight = (height + 1) >> 1;
|
halfheight = (height + 1) >> 1;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (halfheight - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(halfheight - 1) * src_stride_u;
|
||||||
src_v = src_v + (halfheight - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(halfheight - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
@ -1018,16 +1020,16 @@ int I010Rotate(const uint16_t* src_y,
|
|||||||
enum RotationMode mode) {
|
enum RotationMode mode) {
|
||||||
int halfwidth = (width + 1) >> 1;
|
int halfwidth = (width + 1) >> 1;
|
||||||
int halfheight = (height + 1) >> 1;
|
int halfheight = (height + 1) >> 1;
|
||||||
if (!src_y || !src_u || !src_v || width <= 0 || height == 0 || !dst_y ||
|
if (!src_y || !src_u || !src_v || width <= 0 || height == 0 ||
|
||||||
!dst_u || !dst_v || dst_stride_y < 0) {
|
height == INT_MIN || !dst_y || !dst_u || !dst_v || dst_stride_y < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (height - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(height - 1) * src_stride_u;
|
||||||
src_v = src_v + (height - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(height - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
@ -1089,16 +1091,16 @@ int I210Rotate(const uint16_t* src_y,
|
|||||||
int halfwidth = (width + 1) >> 1;
|
int halfwidth = (width + 1) >> 1;
|
||||||
int halfheight = (height + 1) >> 1;
|
int halfheight = (height + 1) >> 1;
|
||||||
int r;
|
int r;
|
||||||
if (!src_y || !src_u || !src_v || width <= 0 || height == 0 || !dst_y ||
|
if (!src_y || !src_u || !src_v || width <= 0 || height == 0 ||
|
||||||
!dst_u || !dst_v) {
|
height == INT_MIN || !dst_y || !dst_u || !dst_v) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (height - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(height - 1) * src_stride_u;
|
||||||
src_v = src_v + (height - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(height - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
@ -1186,16 +1188,16 @@ int I410Rotate(const uint16_t* src_y,
|
|||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
enum RotationMode mode) {
|
enum RotationMode mode) {
|
||||||
if (!src_y || !src_u || !src_v || width <= 0 || height == 0 || !dst_y ||
|
if (!src_y || !src_u || !src_v || width <= 0 || height == 0 ||
|
||||||
!dst_u || !dst_v || dst_stride_y < 0) {
|
height == INT_MIN || !dst_y || !dst_u || !dst_v || dst_stride_y < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_y = src_y + (height - 1) * src_stride_y;
|
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||||
src_u = src_u + (height - 1) * src_stride_u;
|
src_u = src_u + (ptrdiff_t)(height - 1) * src_stride_u;
|
||||||
src_v = src_v + (height - 1) * src_stride_v;
|
src_v = src_v + (ptrdiff_t)(height - 1) * src_stride_v;
|
||||||
src_stride_y = -src_stride_y;
|
src_stride_y = -src_stride_y;
|
||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
|
|||||||
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#include "libyuv/rotate_argb.h"
|
#include "libyuv/rotate_argb.h"
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#include "libyuv/convert.h"
|
#include "libyuv/convert.h"
|
||||||
#include "libyuv/cpu_id.h"
|
#include "libyuv/cpu_id.h"
|
||||||
#include "libyuv/planar_functions.h"
|
#include "libyuv/planar_functions.h"
|
||||||
@ -222,14 +224,15 @@ int ARGBRotate(const uint8_t* src_argb,
|
|||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
enum RotationMode mode) {
|
enum RotationMode mode) {
|
||||||
if (!src_argb || width <= 0 || height == 0 || !dst_argb) {
|
if (!src_argb || width <= 0 || height == 0 || height == INT_MIN ||
|
||||||
|
!dst_argb) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
height = -height;
|
height = -height;
|
||||||
src_argb = src_argb + (height - 1) * src_stride_argb;
|
src_argb = src_argb + (ptrdiff_t)(height - 1) * src_stride_argb;
|
||||||
src_stride_argb = -src_stride_argb;
|
src_stride_argb = -src_stride_argb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
#include "libyuv/scale.h"
|
#include "libyuv/scale.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "libyuv/cpu_id.h"
|
#include "libyuv/cpu_id.h"
|
||||||
@ -2230,8 +2231,8 @@ int I420Scale(const uint8_t* src_y,
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
|
if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
|
||||||
src_width > 32768 || src_height > 32768 || !dst_y || !dst_u || !dst_v ||
|
src_height == INT_MIN || src_width > 32768 || src_height > 32768 ||
|
||||||
dst_width <= 0 || dst_height <= 0) {
|
!dst_y || !dst_u || !dst_v || dst_width <= 0 || dst_height <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2275,8 +2276,8 @@ int I420Scale_16(const uint16_t* src_y,
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
|
if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
|
||||||
src_width > 32768 || src_height > 32768 || !dst_y || !dst_u || !dst_v ||
|
src_height == INT_MIN || src_width > 32768 || src_height > 32768 ||
|
||||||
dst_width <= 0 || dst_height <= 0) {
|
!dst_y || !dst_u || !dst_v || dst_width <= 0 || dst_height <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2320,8 +2321,8 @@ int I420Scale_12(const uint16_t* src_y,
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
|
if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
|
||||||
src_width > 32768 || src_height > 32768 || !dst_y || !dst_u || !dst_v ||
|
src_height == INT_MIN || src_width > 32768 || src_height > 32768 ||
|
||||||
dst_width <= 0 || dst_height <= 0) {
|
!dst_y || !dst_u || !dst_v || dst_width <= 0 || dst_height <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2364,8 +2365,8 @@ int I444Scale(const uint8_t* src_y,
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
|
if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
|
||||||
src_width > 32768 || src_height > 32768 || !dst_y || !dst_u || !dst_v ||
|
src_height == INT_MIN || src_width > 32768 || src_height > 32768 ||
|
||||||
dst_width <= 0 || dst_height <= 0) {
|
!dst_y || !dst_u || !dst_v || dst_width <= 0 || dst_height <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2405,8 +2406,8 @@ int I444Scale_16(const uint16_t* src_y,
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
|
if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
|
||||||
src_width > 32768 || src_height > 32768 || !dst_y || !dst_u || !dst_v ||
|
src_height == INT_MIN || src_width > 32768 || src_height > 32768 ||
|
||||||
dst_width <= 0 || dst_height <= 0) {
|
!dst_y || !dst_u || !dst_v || dst_width <= 0 || dst_height <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2446,8 +2447,8 @@ int I444Scale_12(const uint16_t* src_y,
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
|
if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
|
||||||
src_width > 32768 || src_height > 32768 || !dst_y || !dst_u || !dst_v ||
|
src_height == INT_MIN || src_width > 32768 || src_height > 32768 ||
|
||||||
dst_width <= 0 || dst_height <= 0) {
|
!dst_y || !dst_u || !dst_v || dst_width <= 0 || dst_height <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2492,8 +2493,8 @@ int I422Scale(const uint8_t* src_y,
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
|
if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
|
||||||
src_width > 32768 || src_height > 32768 || !dst_y || !dst_u || !dst_v ||
|
src_height == INT_MIN || src_width > 32768 || src_height > 32768 ||
|
||||||
dst_width <= 0 || dst_height <= 0) {
|
!dst_y || !dst_u || !dst_v || dst_width <= 0 || dst_height <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2535,8 +2536,8 @@ int I422Scale_16(const uint16_t* src_y,
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
|
if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
|
||||||
src_width > 32768 || src_height > 32768 || !dst_y || !dst_u || !dst_v ||
|
src_height == INT_MIN || src_width > 32768 || src_height > 32768 ||
|
||||||
dst_width <= 0 || dst_height <= 0) {
|
!dst_y || !dst_u || !dst_v || dst_width <= 0 || dst_height <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2578,8 +2579,8 @@ int I422Scale_12(const uint16_t* src_y,
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
|
if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
|
||||||
src_width > 32768 || src_height > 32768 || !dst_y || !dst_u || !dst_v ||
|
src_height == INT_MIN || src_width > 32768 || src_height > 32768 ||
|
||||||
dst_width <= 0 || dst_height <= 0) {
|
!dst_y || !dst_u || !dst_v || dst_width <= 0 || dst_height <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2622,8 +2623,8 @@ int NV12Scale(const uint8_t* src_y,
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!src_y || !src_uv || src_width <= 0 || src_height == 0 ||
|
if (!src_y || !src_uv || src_width <= 0 || src_height == 0 ||
|
||||||
src_width > 32768 || src_height > 32768 || !dst_y || !dst_uv ||
|
src_height == INT_MIN || src_width > 32768 || src_height > 32768 ||
|
||||||
dst_width <= 0 || dst_height <= 0) {
|
!dst_y || !dst_uv || dst_width <= 0 || dst_height <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2654,8 +2655,8 @@ int NV24Scale(const uint8_t* src_y,
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!src_y || !src_uv || src_width <= 0 || src_height == 0 ||
|
if (!src_y || !src_uv || src_width <= 0 || src_height == 0 ||
|
||||||
src_width > 32768 || src_height > 32768 || !dst_y || !dst_uv ||
|
src_height == INT_MIN || src_width > 32768 || src_height > 32768 ||
|
||||||
dst_width <= 0 || dst_height <= 0) {
|
!dst_y || !dst_uv || dst_width <= 0 || dst_height <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -779,9 +779,9 @@ int ARGBScaleClip(const uint8_t* src_argb,
|
|||||||
int clip_width,
|
int clip_width,
|
||||||
int clip_height,
|
int clip_height,
|
||||||
enum FilterMode filtering) {
|
enum FilterMode filtering) {
|
||||||
if (!src_argb || src_width == 0 || src_height == 0 || !dst_argb ||
|
if (!src_argb || src_width == 0 || src_height == 0 || src_height == INT_MIN ||
|
||||||
dst_width <= 0 || dst_height <= 0 || clip_x < 0 || clip_y < 0 ||
|
!dst_argb || dst_width <= 0 || dst_height <= 0 || clip_x < 0 ||
|
||||||
clip_width > 32768 || clip_height > 32768 ||
|
clip_y < 0 || clip_width > 32768 || clip_height > 32768 ||
|
||||||
(clip_x + clip_width) > dst_width ||
|
(clip_x + clip_width) > dst_width ||
|
||||||
(clip_y + clip_height) > dst_height) {
|
(clip_y + clip_height) > dst_height) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -802,8 +802,9 @@ int ARGBScale(const uint8_t* src_argb,
|
|||||||
int dst_width,
|
int dst_width,
|
||||||
int dst_height,
|
int dst_height,
|
||||||
enum FilterMode filtering) {
|
enum FilterMode filtering) {
|
||||||
if (!src_argb || src_width == 0 || src_height == 0 || src_width > 32768 ||
|
if (!src_argb || src_width == 0 || src_height == 0 || src_height == INT_MIN ||
|
||||||
src_height > 32768 || !dst_argb || dst_width <= 0 || dst_height <= 0) {
|
src_width > 32768 || src_height > 32768 || !dst_argb || dst_width <= 0 ||
|
||||||
|
dst_height <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return ScaleARGB(src_argb, src_stride_argb, src_width, src_height, dst_argb,
|
return ScaleARGB(src_argb, src_stride_argb, src_width, src_height, dst_argb,
|
||||||
@ -835,12 +836,13 @@ int YUVToARGBScaleClip(const uint8_t* src_y,
|
|||||||
int r;
|
int r;
|
||||||
(void)src_fourcc; // TODO(fbarchard): implement and/or assert.
|
(void)src_fourcc; // TODO(fbarchard): implement and/or assert.
|
||||||
(void)dst_fourcc;
|
(void)dst_fourcc;
|
||||||
const int abs_src_height = (src_height < 0) ? -src_height : src_height;
|
|
||||||
if (!src_y || !src_u || !src_v || !dst_argb || src_width <= 0 ||
|
if (!src_y || !src_u || !src_v || !dst_argb || src_width <= 0 ||
|
||||||
src_width > INT_MAX / 4 || src_height == 0 || dst_width <= 0 ||
|
src_width > INT_MAX / 4 || src_height == 0 || src_height == INT_MIN ||
|
||||||
dst_height <= 0 || clip_width <= 0 || clip_height <= 0) {
|
dst_width <= 0 || dst_height <= 0 || clip_width <= 0 ||
|
||||||
|
clip_height <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
const int abs_src_height = (src_height < 0) ? -src_height : src_height;
|
||||||
const uint64_t argb_buffer_size = (uint64_t)src_width * abs_src_height * 4;
|
const uint64_t argb_buffer_size = (uint64_t)src_width * abs_src_height * 4;
|
||||||
if (argb_buffer_size > SIZE_MAX) {
|
if (argb_buffer_size > SIZE_MAX) {
|
||||||
return -1; // Invalid size.
|
return -1; // Invalid size.
|
||||||
|
|||||||
@ -42,8 +42,8 @@ int RGBScale(const uint8_t* src_rgb,
|
|||||||
enum FilterMode filtering) {
|
enum FilterMode filtering) {
|
||||||
int r;
|
int r;
|
||||||
if (!src_rgb || !dst_rgb || src_width <= 0 || src_width > INT_MAX / 4 ||
|
if (!src_rgb || !dst_rgb || src_width <= 0 || src_width > INT_MAX / 4 ||
|
||||||
src_height == 0 || dst_width <= 0 || dst_width > INT_MAX / 4 ||
|
src_height == 0 || src_height == INT_MIN || dst_width <= 0 ||
|
||||||
dst_height <= 0) {
|
dst_width > INT_MAX / 4 || dst_height <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
const int abs_src_height = (src_height < 0) ? -src_height : src_height;
|
const int abs_src_height = (src_height < 0) ? -src_height : src_height;
|
||||||
|
|||||||
@ -885,7 +885,7 @@ static int UVCopy(const uint8_t* src_uv,
|
|||||||
int dst_stride_uv,
|
int dst_stride_uv,
|
||||||
int width,
|
int width,
|
||||||
int height) {
|
int height) {
|
||||||
if (!src_uv || !dst_uv || width <= 0 || height == 0) {
|
if (!src_uv || !dst_uv || width <= 0 || height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
@ -905,7 +905,7 @@ static int UVCopy_16(const uint16_t* src_uv,
|
|||||||
int dst_stride_uv,
|
int dst_stride_uv,
|
||||||
int width,
|
int width,
|
||||||
int height) {
|
int height) {
|
||||||
if (!src_uv || !dst_uv || width <= 0 || height == 0) {
|
if (!src_uv || !dst_uv || width <= 0 || height == 0 || height == INT_MIN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
@ -1061,8 +1061,9 @@ int UVScale(const uint8_t* src_uv,
|
|||||||
int dst_width,
|
int dst_width,
|
||||||
int dst_height,
|
int dst_height,
|
||||||
enum FilterMode filtering) {
|
enum FilterMode filtering) {
|
||||||
if (!src_uv || src_width <= 0 || src_height == 0 || src_width > 32768 ||
|
if (!src_uv || src_width <= 0 || src_height == 0 || src_height == INT_MIN ||
|
||||||
src_height > 32768 || !dst_uv || dst_width <= 0 || dst_height <= 0) {
|
src_width > 32768 || src_height > 32768 || !dst_uv || dst_width <= 0 ||
|
||||||
|
dst_height <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return ScaleUV(src_uv, src_stride_uv, src_width, src_height, dst_uv,
|
return ScaleUV(src_uv, src_stride_uv, src_width, src_height, dst_uv,
|
||||||
@ -1084,8 +1085,9 @@ int UVScale_16(const uint16_t* src_uv,
|
|||||||
enum FilterMode filtering) {
|
enum FilterMode filtering) {
|
||||||
int dy = 0;
|
int dy = 0;
|
||||||
|
|
||||||
if (!src_uv || src_width <= 0 || src_height == 0 || src_width > 32768 ||
|
if (!src_uv || src_width <= 0 || src_height == 0 || src_height == INT_MIN ||
|
||||||
src_height > 32768 || !dst_uv || dst_width <= 0 || dst_height <= 0) {
|
src_width > 32768 || src_height > 32768 || !dst_uv || dst_width <= 0 ||
|
||||||
|
dst_height <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user