mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-07 17:26:49 +08:00
I422Rotate update to remove name space for ios build warning
- Remove libyuv:: from within libyuv to resolve a build warning on IOS. - Check src_y parameter is not NULL if there is a dst_y parameter - Apply clang-format - Bump version Performance on Intel Skylake Xeon ARGBRotate90_Opt (795 ms) I420Rotate90_Opt (283 ms) I422Rotate90_Opt (867 ms) <-- scales and rotates I444Rotate90_Opt (565 ms) NV12Rotate90_Opt (289 ms) Performance on Pixel 4 (Cortex A76) ARGBRotate90_Opt (4208 ms) I420Rotate90_Opt (273 ms) I422Rotate90_Opt (1207 ms) I444Rotate90_Opt (718 ms) NV12Rotate90_Opt (282 ms) Bug: libyuv:926 Change-Id: I42e1b93a9595f6ed075918e91bed977dd3d23f6f Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/3576778 Reviewed-by: Mirko Bonadei <mbonadei@chromium.org> Commit-Queue: Frank Barchard <fbarchard@chromium.org>
This commit is contained in:
parent
a77d615e10
commit
2ad73733d9
@ -1,6 +1,6 @@
|
||||
Name: libyuv
|
||||
URL: http://code.google.com/p/libyuv/
|
||||
Version: 1816
|
||||
Version: 1818
|
||||
License: BSD
|
||||
License File: LICENSE
|
||||
|
||||
|
||||
@ -353,7 +353,7 @@ int I444Copy(const uint8_t* src_y,
|
||||
int height);
|
||||
|
||||
// Copy I210 to I210.
|
||||
#define I210ToI210 I210opy
|
||||
#define I210ToI210 I210Copy
|
||||
LIBYUV_API
|
||||
int I210Copy(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
|
||||
@ -65,7 +65,7 @@ int I422Rotate(const uint8_t* src_y,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height,
|
||||
enum libyuv::RotationMode mode);
|
||||
enum RotationMode mode);
|
||||
|
||||
// Rotate I444 frame.
|
||||
LIBYUV_API
|
||||
|
||||
@ -221,7 +221,7 @@ int I422Scale(const uint8_t* src_y,
|
||||
int dst_stride_v,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum libyuv::FilterMode filtering);
|
||||
enum FilterMode filtering);
|
||||
|
||||
LIBYUV_API
|
||||
int I422Scale_16(const uint16_t* src_y,
|
||||
@ -240,7 +240,7 @@ int I422Scale_16(const uint16_t* src_y,
|
||||
int dst_stride_v,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum libyuv::FilterMode filtering);
|
||||
enum FilterMode filtering);
|
||||
|
||||
LIBYUV_API
|
||||
int I422Scale_12(const uint16_t* src_y,
|
||||
@ -259,7 +259,7 @@ int I422Scale_12(const uint16_t* src_y,
|
||||
int dst_stride_v,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum libyuv::FilterMode filtering);
|
||||
enum FilterMode filtering);
|
||||
|
||||
// Scales an NV12 image from the src width and height to the
|
||||
// dst width and height.
|
||||
|
||||
@ -11,6 +11,6 @@
|
||||
#ifndef INCLUDE_LIBYUV_VERSION_H_
|
||||
#define INCLUDE_LIBYUV_VERSION_H_
|
||||
|
||||
#define LIBYUV_VERSION 1817
|
||||
#define LIBYUV_VERSION 1818
|
||||
|
||||
#endif // INCLUDE_LIBYUV_VERSION_H_
|
||||
|
||||
@ -83,7 +83,7 @@ int I420Copy(const uint8_t* src_y,
|
||||
int height) {
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
int halfheight = (height + 1) >> 1;
|
||||
if (!src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
// Negative height means invert the image.
|
||||
@ -125,7 +125,7 @@ int I010Copy(const uint16_t* src_y,
|
||||
int height) {
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
int halfheight = (height + 1) >> 1;
|
||||
if (!src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
// Negative height means invert the image.
|
||||
@ -169,7 +169,7 @@ static int Planar16bitTo8bit(const uint16_t* src_y,
|
||||
int uv_width = SUBSAMPLE(width, subsample_x, subsample_x);
|
||||
int uv_height = SUBSAMPLE(height, subsample_y, subsample_y);
|
||||
int scale = 1 << (24 - depth);
|
||||
if (!src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
// Negative height means invert the image.
|
||||
@ -539,7 +539,7 @@ int I422ToI210(const uint8_t* src_y,
|
||||
int width,
|
||||
int height) {
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
if (!src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
// Negative height means invert the image.
|
||||
@ -554,13 +554,13 @@ int I422ToI210(const uint8_t* src_y,
|
||||
}
|
||||
|
||||
// Convert Y plane.
|
||||
libyuv::Convert8To16Plane(src_y, src_stride_y, dst_y, dst_stride_y, 1024,
|
||||
width, height);
|
||||
Convert8To16Plane(src_y, src_stride_y, dst_y, dst_stride_y, 1024, width,
|
||||
height);
|
||||
// Convert UV planes.
|
||||
libyuv::Convert8To16Plane(src_u, src_stride_u, dst_u, dst_stride_u, 1024,
|
||||
halfwidth, height);
|
||||
libyuv::Convert8To16Plane(src_v, src_stride_v, dst_v, dst_stride_v, 1024,
|
||||
halfwidth, height);
|
||||
Convert8To16Plane(src_u, src_stride_u, dst_u, dst_stride_u, 1024, halfwidth,
|
||||
height);
|
||||
Convert8To16Plane(src_v, src_stride_v, dst_v, dst_stride_v, 1024, halfwidth,
|
||||
height);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -85,7 +85,7 @@ int I420ToI010(const uint8_t* src_y,
|
||||
int height) {
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
int halfheight = (height + 1) >> 1;
|
||||
if (!src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
// Negative height means invert the image.
|
||||
@ -129,7 +129,7 @@ int I420ToI012(const uint8_t* src_y,
|
||||
int height) {
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
int halfheight = (height + 1) >> 1;
|
||||
if (!src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
// Negative height means invert the image.
|
||||
|
||||
@ -239,9 +239,11 @@ int I422Copy(const uint8_t* src_y,
|
||||
int width,
|
||||
int height) {
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
if (!src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
|
||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Negative height means invert the image.
|
||||
if (height < 0) {
|
||||
height = -height;
|
||||
@ -277,7 +279,7 @@ int I444Copy(const uint8_t* src_y,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height) {
|
||||
if (!src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
// Negative height means invert the image.
|
||||
@ -316,9 +318,11 @@ int I210Copy(const uint16_t* src_y,
|
||||
int width,
|
||||
int height) {
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
if (!src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
|
||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Negative height means invert the image.
|
||||
if (height < 0) {
|
||||
height = -height;
|
||||
@ -331,14 +335,11 @@ int I210Copy(const uint16_t* src_y,
|
||||
}
|
||||
|
||||
if (dst_y) {
|
||||
libyuv::CopyPlane_16(src_y, src_stride_y, dst_y, dst_stride_y, width,
|
||||
height);
|
||||
CopyPlane_16(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
}
|
||||
// Copy UV planes.
|
||||
libyuv::CopyPlane_16(src_u, src_stride_u, dst_u, dst_stride_u, halfwidth,
|
||||
height);
|
||||
libyuv::CopyPlane_16(src_v, src_stride_v, dst_v, dst_stride_v, halfwidth,
|
||||
height);
|
||||
CopyPlane_16(src_u, src_stride_u, dst_u, dst_stride_u, halfwidth, height);
|
||||
CopyPlane_16(src_v, src_stride_v, dst_v, dst_stride_v, halfwidth, height);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -404,12 +405,13 @@ int NV12Copy(const uint8_t* src_y,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height) {
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
int halfheight = (height + 1) >> 1;
|
||||
|
||||
if (!src_y || !dst_y || !src_uv || !dst_uv || width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
int halfheight = (height + 1) >> 1;
|
||||
// Negative height means invert the image.
|
||||
if (height < 0) {
|
||||
height = -height;
|
||||
@ -876,9 +878,11 @@ int NV21ToNV12(const uint8_t* src_y,
|
||||
int height) {
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
int halfheight = (height + 1) >> 1;
|
||||
|
||||
if (!src_vu || !dst_uv || width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (dst_y) {
|
||||
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
}
|
||||
@ -2218,10 +2222,12 @@ int I420Mirror(const uint8_t* src_y,
|
||||
int height) {
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
int halfheight = (height + 1) >> 1;
|
||||
|
||||
if (!src_y || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
||||
height == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Negative height means invert the image.
|
||||
if (height < 0) {
|
||||
height = -height;
|
||||
@ -2256,9 +2262,11 @@ int NV12Mirror(const uint8_t* src_y,
|
||||
int height) {
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
int halfheight = (height + 1) >> 1;
|
||||
|
||||
if (!src_y || !src_uv || !dst_uv || width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Negative height means invert the image.
|
||||
if (height < 0) {
|
||||
height = -height;
|
||||
@ -2557,6 +2565,7 @@ int I420Blend(const uint8_t* src_y0,
|
||||
BlendPlaneRow_C;
|
||||
void (*ScaleRowDown2)(const uint8_t* src_ptr, ptrdiff_t src_stride,
|
||||
uint8_t* dst_ptr, int dst_width) = ScaleRowDown2Box_C;
|
||||
|
||||
if (!src_y0 || !src_u0 || !src_v0 || !src_y1 || !src_u1 || !src_v1 ||
|
||||
!alpha || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
return -1;
|
||||
@ -3042,6 +3051,7 @@ int I420Rect(uint8_t* dst_y,
|
||||
uint8_t* start_y = dst_y + y * dst_stride_y + x;
|
||||
uint8_t* start_u = dst_u + (y / 2) * dst_stride_u + (x / 2);
|
||||
uint8_t* start_v = dst_v + (y / 2) * dst_stride_v + (x / 2);
|
||||
|
||||
if (!dst_y || !dst_u || !dst_v || width <= 0 || height == 0 || x < 0 ||
|
||||
y < 0 || value_y < 0 || value_y > 255 || value_u < 0 || value_u > 255 ||
|
||||
value_v < 0 || value_v > 255) {
|
||||
@ -3955,10 +3965,12 @@ int I420Interpolate(const uint8_t* src0_y,
|
||||
int interpolation) {
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
int halfheight = (height + 1) >> 1;
|
||||
|
||||
if (!src0_y || !src0_u || !src0_v || !src1_y || !src1_u || !src1_v ||
|
||||
!dst_y || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
InterpolatePlane(src0_y, src0_stride_y, src1_y, src1_stride_y, dst_y,
|
||||
dst_stride_y, width, height, interpolation);
|
||||
InterpolatePlane(src0_u, src0_stride_u, src1_u, src1_stride_u, dst_u,
|
||||
@ -4860,9 +4872,11 @@ int YUY2ToNV12(const uint8_t* src_yuy2,
|
||||
void (*InterpolateRow)(uint8_t * dst_ptr, const uint8_t* src_ptr,
|
||||
ptrdiff_t src_stride, int dst_width,
|
||||
int source_y_fraction) = InterpolateRow_C;
|
||||
|
||||
if (!src_yuy2 || !dst_y || !dst_uv || width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Negative height means invert the image.
|
||||
if (height < 0) {
|
||||
height = -height;
|
||||
@ -4992,9 +5006,11 @@ int UYVYToNV12(const uint8_t* src_uyvy,
|
||||
void (*InterpolateRow)(uint8_t * dst_ptr, const uint8_t* src_ptr,
|
||||
ptrdiff_t src_stride, int dst_width,
|
||||
int source_y_fraction) = InterpolateRow_C;
|
||||
|
||||
if (!src_uyvy || !dst_y || !dst_uv || width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Negative height means invert the image.
|
||||
if (height < 0) {
|
||||
height = -height;
|
||||
|
||||
@ -494,8 +494,8 @@ int I420Rotate(const uint8_t* src_y,
|
||||
enum RotationMode mode) {
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
int halfheight = (height + 1) >> 1;
|
||||
if (!src_y || !src_u || !src_v || width <= 0 || height == 0 || !dst_y ||
|
||||
!dst_u || !dst_v) {
|
||||
if ((!src_y && dst_y) || !src_u || !src_v || width <= 0 || height == 0 ||
|
||||
!dst_y || !dst_u || !dst_v) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -559,7 +559,7 @@ int I422Rotate(const uint8_t* src_y,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height,
|
||||
enum libyuv::RotationMode mode) {
|
||||
enum RotationMode mode) {
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
int halfheight = (height + 1) >> 1;
|
||||
if (!src_y || !src_u || !src_v || width <= 0 || height == 0 || !dst_y ||
|
||||
@ -578,49 +578,39 @@ int I422Rotate(const uint8_t* src_y,
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case libyuv::kRotate0:
|
||||
case kRotate0:
|
||||
// copy frame
|
||||
libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width,
|
||||
height);
|
||||
libyuv::CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, halfwidth,
|
||||
height);
|
||||
libyuv::CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, halfwidth,
|
||||
height);
|
||||
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, halfwidth, height);
|
||||
CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, halfwidth, height);
|
||||
return 0;
|
||||
case libyuv::kRotate90:
|
||||
case kRotate90:
|
||||
// We need to rotate and rescale, we use plane Y as temporal storage.
|
||||
libyuv::RotatePlane90(src_u, src_stride_u, dst_y, height, halfwidth,
|
||||
height);
|
||||
libyuv::ScalePlane(dst_y, height, height, halfwidth, dst_u, halfheight,
|
||||
halfheight, width, libyuv::kFilterBilinear);
|
||||
libyuv::RotatePlane90(src_v, src_stride_v, dst_y, height, halfwidth,
|
||||
height);
|
||||
libyuv::ScalePlane(dst_y, height, height, halfwidth, dst_v, halfheight,
|
||||
halfheight, width, libyuv::kFilterLinear);
|
||||
libyuv::RotatePlane90(src_y, src_stride_y, dst_y, dst_stride_y, width,
|
||||
height);
|
||||
RotatePlane90(src_u, src_stride_u, dst_y, height, halfwidth, height);
|
||||
ScalePlane(dst_y, height, height, halfwidth, dst_u, halfheight,
|
||||
halfheight, width, kFilterBilinear);
|
||||
RotatePlane90(src_v, src_stride_v, dst_y, height, halfwidth, height);
|
||||
ScalePlane(dst_y, height, height, halfwidth, dst_v, halfheight,
|
||||
halfheight, width, kFilterLinear);
|
||||
RotatePlane90(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
return 0;
|
||||
case libyuv::kRotate270:
|
||||
case kRotate270:
|
||||
// We need to rotate and rescale, we use plane Y as temporal storage.
|
||||
libyuv::RotatePlane270(src_u, src_stride_u, dst_y, height, halfwidth,
|
||||
height);
|
||||
libyuv::ScalePlane(dst_y, height, height, halfwidth, dst_u, halfheight,
|
||||
halfheight, width, libyuv::kFilterBilinear);
|
||||
libyuv::RotatePlane270(src_v, src_stride_v, dst_y, height, halfwidth,
|
||||
height);
|
||||
libyuv::ScalePlane(dst_y, height, height, halfwidth, dst_v, halfheight,
|
||||
halfheight, width, libyuv::kFilterLinear);
|
||||
libyuv::RotatePlane270(src_y, src_stride_y, dst_y, dst_stride_y, width,
|
||||
height);
|
||||
RotatePlane270(src_u, src_stride_u, dst_y, height, halfwidth, height);
|
||||
ScalePlane(dst_y, height, height, halfwidth, dst_u, halfheight,
|
||||
halfheight, width, kFilterBilinear);
|
||||
RotatePlane270(src_v, src_stride_v, dst_y, height, halfwidth, height);
|
||||
ScalePlane(dst_y, height, height, halfwidth, dst_v, halfheight,
|
||||
halfheight, width, kFilterLinear);
|
||||
RotatePlane270(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
|
||||
return 0;
|
||||
case libyuv::kRotate180:
|
||||
libyuv::RotatePlane180(src_y, src_stride_y, dst_y, dst_stride_y, width,
|
||||
height);
|
||||
libyuv::RotatePlane180(src_u, src_stride_u, dst_u, dst_stride_u,
|
||||
halfwidth, height);
|
||||
libyuv::RotatePlane180(src_v, src_stride_v, dst_v, dst_stride_v,
|
||||
halfwidth, height);
|
||||
case kRotate180:
|
||||
RotatePlane180(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
RotatePlane180(src_u, src_stride_u, dst_u, dst_stride_u, halfwidth,
|
||||
height);
|
||||
RotatePlane180(src_v, src_stride_v, dst_v, dst_stride_v, halfwidth,
|
||||
height);
|
||||
return 0;
|
||||
default:
|
||||
break;
|
||||
@ -643,7 +633,7 @@ int I444Rotate(const uint8_t* src_y,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height,
|
||||
enum libyuv::RotationMode mode) {
|
||||
enum RotationMode mode) {
|
||||
if (!src_y || !src_u || !src_v || width <= 0 || height == 0 || !dst_y ||
|
||||
!dst_u || !dst_v) {
|
||||
return -1;
|
||||
@ -661,23 +651,23 @@ int I444Rotate(const uint8_t* src_y,
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case libyuv::kRotate0:
|
||||
case kRotate0:
|
||||
// copy frame
|
||||
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width, height);
|
||||
CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width, height);
|
||||
return 0;
|
||||
case libyuv::kRotate90:
|
||||
case kRotate90:
|
||||
RotatePlane90(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
RotatePlane90(src_u, src_stride_u, dst_u, dst_stride_u, width, height);
|
||||
RotatePlane90(src_v, src_stride_v, dst_v, dst_stride_v, width, height);
|
||||
return 0;
|
||||
case libyuv::kRotate270:
|
||||
case kRotate270:
|
||||
RotatePlane270(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
RotatePlane270(src_u, src_stride_u, dst_u, dst_stride_u, width, height);
|
||||
RotatePlane270(src_v, src_stride_v, dst_v, dst_stride_v, width, height);
|
||||
return 0;
|
||||
case libyuv::kRotate180:
|
||||
case kRotate180:
|
||||
RotatePlane180(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
RotatePlane180(src_u, src_stride_u, dst_u, dst_stride_u, width, height);
|
||||
RotatePlane180(src_v, src_stride_v, dst_v, dst_stride_v, width, height);
|
||||
@ -780,7 +770,8 @@ int Android420ToI420Rotate(const uint8_t* src_y,
|
||||
const ptrdiff_t vu_off = src_v - src_u;
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
int halfheight = (height + 1) >> 1;
|
||||
if (!src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) {
|
||||
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
|
||||
height == 0) {
|
||||
return -1;
|
||||
}
|
||||
// Negative height means invert the image.
|
||||
|
||||
@ -22,10 +22,15 @@ namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// This macro control YUV to RGB using unsigned math to extend range of
|
||||
// This macro controls YUV to RGB using unsigned math to extend range of
|
||||
// YUV to RGB coefficients to 0 to 4 instead of 0 to 2 for more accuracy on B:
|
||||
// LIBYUV_UNLIMITED_DATA
|
||||
|
||||
// Macros to enable unlimited data for each colorspace
|
||||
// LIBYUV_UNLIMITED_BT601
|
||||
// LIBYUV_UNLIMITED_BT709
|
||||
// LIBYUV_UNLIMITED_BT2020
|
||||
|
||||
// The following macro from row_win makes the C code match the row_win code,
|
||||
// which is 7 bit fixed point for ARGBToI420:
|
||||
#if !defined(LIBYUV_BIT_EXACT) && !defined(LIBYUV_DISABLE_X86) && \
|
||||
@ -1463,7 +1468,7 @@ void J400ToARGBRow_C(const uint8_t* src_y, uint8_t* dst_argb, int width) {
|
||||
// KR = 0.299; KB = 0.114
|
||||
|
||||
// U and V contributions to R,G,B.
|
||||
#ifdef LIBYUV_UNLIMITED_DATA
|
||||
#if defined(LIBYUV_UNLIMITED_DATA) || defined(LIBYUV_UNLIMITED_BT601)
|
||||
#define UB 129 /* round(2.018 * 64) */
|
||||
#else
|
||||
#define UB 128 /* max(128, round(2.018 * 64)) */
|
||||
@ -1517,7 +1522,7 @@ MAKEYUVCONSTANTS(JPEG, YG, YB, UB, UG, VG, VR)
|
||||
// KR = 0.2126, KB = 0.0722
|
||||
|
||||
// U and V contributions to R,G,B.
|
||||
#ifdef LIBYUV_UNLIMITED_DATA
|
||||
#if defined(LIBYUV_UNLIMITED_DATA) || defined(LIBYUV_UNLIMITED_BT709)
|
||||
#define UB 135 /* round(2.112 * 64) */
|
||||
#else
|
||||
#define UB 128 /* max(128, round(2.112 * 64)) */
|
||||
@ -1571,7 +1576,7 @@ MAKEYUVCONSTANTS(F709, YG, YB, UB, UG, VG, VR)
|
||||
// KR = 0.2627; KB = 0.0593
|
||||
|
||||
// U and V contributions to R,G,B.
|
||||
#ifdef LIBYUV_UNLIMITED_DATA
|
||||
#if defined(LIBYUV_UNLIMITED_DATA) || defined(LIBYUV_UNLIMITED_BT2020)
|
||||
#define UB 137 /* round(2.142 * 64) */
|
||||
#else
|
||||
#define UB 128 /* max(128, round(2.142 * 64)) */
|
||||
|
||||
@ -2137,6 +2137,7 @@ int I420Scale(const uint8_t* src_y,
|
||||
int src_halfheight = SUBSAMPLE(src_height, 1, 1);
|
||||
int dst_halfwidth = SUBSAMPLE(dst_width, 1, 1);
|
||||
int dst_halfheight = SUBSAMPLE(dst_height, 1, 1);
|
||||
|
||||
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 ||
|
||||
dst_width <= 0 || dst_height <= 0) {
|
||||
@ -2174,6 +2175,7 @@ int I420Scale_16(const uint16_t* src_y,
|
||||
int src_halfheight = SUBSAMPLE(src_height, 1, 1);
|
||||
int dst_halfwidth = SUBSAMPLE(dst_width, 1, 1);
|
||||
int dst_halfheight = SUBSAMPLE(dst_height, 1, 1);
|
||||
|
||||
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 ||
|
||||
dst_width <= 0 || dst_height <= 0) {
|
||||
@ -2211,6 +2213,7 @@ int I420Scale_12(const uint16_t* src_y,
|
||||
int src_halfheight = SUBSAMPLE(src_height, 1, 1);
|
||||
int dst_halfwidth = SUBSAMPLE(dst_width, 1, 1);
|
||||
int dst_halfheight = SUBSAMPLE(dst_height, 1, 1);
|
||||
|
||||
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 ||
|
||||
dst_width <= 0 || dst_height <= 0) {
|
||||
@ -2348,21 +2351,22 @@ int I422Scale(const uint8_t* src_y,
|
||||
int dst_stride_v,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum libyuv::FilterMode filtering) {
|
||||
enum FilterMode filtering) {
|
||||
int src_halfwidth = SUBSAMPLE(src_width, 1, 1);
|
||||
int dst_halfwidth = SUBSAMPLE(dst_width, 1, 1);
|
||||
|
||||
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 ||
|
||||
dst_width <= 0 || dst_height <= 0) {
|
||||
return -1;
|
||||
}
|
||||
int src_halfwidth = SUBSAMPLE(src_width, 1, 1);
|
||||
int dst_halfwidth = SUBSAMPLE(dst_width, 1, 1);
|
||||
|
||||
libyuv::ScalePlane(src_y, src_stride_y, src_width, src_height, dst_y,
|
||||
dst_stride_y, dst_width, dst_height, filtering);
|
||||
libyuv::ScalePlane(src_u, src_stride_u, src_halfwidth, src_height, dst_u,
|
||||
dst_stride_u, dst_halfwidth, dst_height, filtering);
|
||||
libyuv::ScalePlane(src_v, src_stride_v, src_halfwidth, src_height, dst_v,
|
||||
dst_stride_v, dst_halfwidth, dst_height, filtering);
|
||||
ScalePlane(src_y, src_stride_y, src_width, src_height, dst_y, dst_stride_y,
|
||||
dst_width, dst_height, filtering);
|
||||
ScalePlane(src_u, src_stride_u, src_halfwidth, src_height, dst_u,
|
||||
dst_stride_u, dst_halfwidth, dst_height, filtering);
|
||||
ScalePlane(src_v, src_stride_v, src_halfwidth, src_height, dst_v,
|
||||
dst_stride_v, dst_halfwidth, dst_height, filtering);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2383,22 +2387,22 @@ int I422Scale_16(const uint16_t* src_y,
|
||||
int dst_stride_v,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum libyuv::FilterMode filtering) {
|
||||
enum FilterMode filtering) {
|
||||
int src_halfwidth = SUBSAMPLE(src_width, 1, 1);
|
||||
int dst_halfwidth = SUBSAMPLE(dst_width, 1, 1);
|
||||
|
||||
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 ||
|
||||
dst_width <= 0 || dst_height <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int src_halfwidth = SUBSAMPLE(src_width, 1, 1);
|
||||
int dst_halfwidth = SUBSAMPLE(dst_width, 1, 1);
|
||||
|
||||
libyuv::ScalePlane_16(src_y, src_stride_y, src_width, src_height, dst_y,
|
||||
dst_stride_y, dst_width, dst_height, filtering);
|
||||
libyuv::ScalePlane_16(src_u, src_stride_u, src_halfwidth, src_height, dst_u,
|
||||
dst_stride_u, dst_halfwidth, dst_height, filtering);
|
||||
libyuv::ScalePlane_16(src_v, src_stride_v, src_halfwidth, src_height, dst_v,
|
||||
dst_stride_v, dst_halfwidth, dst_height, filtering);
|
||||
ScalePlane_16(src_y, src_stride_y, src_width, src_height, dst_y, dst_stride_y,
|
||||
dst_width, dst_height, filtering);
|
||||
ScalePlane_16(src_u, src_stride_u, src_halfwidth, src_height, dst_u,
|
||||
dst_stride_u, dst_halfwidth, dst_height, filtering);
|
||||
ScalePlane_16(src_v, src_stride_v, src_halfwidth, src_height, dst_v,
|
||||
dst_stride_v, dst_halfwidth, dst_height, filtering);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2419,22 +2423,22 @@ int I422Scale_12(const uint16_t* src_y,
|
||||
int dst_stride_v,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum libyuv::FilterMode filtering) {
|
||||
enum FilterMode filtering) {
|
||||
int src_halfwidth = SUBSAMPLE(src_width, 1, 1);
|
||||
int dst_halfwidth = SUBSAMPLE(dst_width, 1, 1);
|
||||
|
||||
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 ||
|
||||
dst_width <= 0 || dst_height <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int src_halfwidth = SUBSAMPLE(src_width, 1, 1);
|
||||
int dst_halfwidth = SUBSAMPLE(dst_width, 1, 1);
|
||||
|
||||
libyuv::ScalePlane_12(src_y, src_stride_y, src_width, src_height, dst_y,
|
||||
dst_stride_y, dst_width, dst_height, filtering);
|
||||
libyuv::ScalePlane_12(src_u, src_stride_u, src_halfwidth, src_height, dst_u,
|
||||
dst_stride_u, dst_halfwidth, dst_height, filtering);
|
||||
libyuv::ScalePlane_12(src_v, src_stride_v, src_halfwidth, src_height, dst_v,
|
||||
dst_stride_v, dst_halfwidth, dst_height, filtering);
|
||||
ScalePlane_12(src_y, src_stride_y, src_width, src_height, dst_y, dst_stride_y,
|
||||
dst_width, dst_height, filtering);
|
||||
ScalePlane_12(src_u, src_stride_u, src_halfwidth, src_height, dst_u,
|
||||
dst_stride_u, dst_halfwidth, dst_height, filtering);
|
||||
ScalePlane_12(src_v, src_stride_v, src_halfwidth, src_height, dst_v,
|
||||
dst_stride_v, dst_halfwidth, dst_height, filtering);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2459,6 +2463,7 @@ int NV12Scale(const uint8_t* src_y,
|
||||
int src_halfheight = SUBSAMPLE(src_height, 1, 1);
|
||||
int dst_halfwidth = SUBSAMPLE(dst_width, 1, 1);
|
||||
int dst_halfheight = SUBSAMPLE(dst_height, 1, 1);
|
||||
|
||||
if (!src_y || !src_uv || src_width <= 0 || src_height == 0 ||
|
||||
src_width > 32768 || src_height > 32768 || !dst_y || !dst_uv ||
|
||||
dst_width <= 0 || dst_height <= 0) {
|
||||
|
||||
@ -580,28 +580,28 @@ TEST_F(LibYUVColorTest, TestGreyYUV) {
|
||||
|
||||
static void PrintHistogram(int rh[256], int gh[256], int bh[256]) {
|
||||
int i;
|
||||
printf("hist");
|
||||
printf("hist ");
|
||||
for (i = 0; i < 256; ++i) {
|
||||
if (rh[i] || gh[i] || bh[i]) {
|
||||
printf("\t%8d", i - 128);
|
||||
printf(" %8d", i - 128);
|
||||
}
|
||||
}
|
||||
printf("\nred");
|
||||
printf("\nred ");
|
||||
for (i = 0; i < 256; ++i) {
|
||||
if (rh[i] || gh[i] || bh[i]) {
|
||||
printf("\t%8d", rh[i]);
|
||||
printf(" %8d", rh[i]);
|
||||
}
|
||||
}
|
||||
printf("\ngreen");
|
||||
for (i = 0; i < 256; ++i) {
|
||||
if (rh[i] || gh[i] || bh[i]) {
|
||||
printf("\t%8d", gh[i]);
|
||||
printf(" %8d", gh[i]);
|
||||
}
|
||||
}
|
||||
printf("\nblue");
|
||||
printf("\nblue ");
|
||||
for (i = 0; i < 256; ++i) {
|
||||
if (rh[i] || gh[i] || bh[i]) {
|
||||
printf("\t%8d", bh[i]);
|
||||
printf(" %8d", bh[i]);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
@ -28,13 +28,13 @@ namespace libyuv {
|
||||
|
||||
// Test scaling with C vs Opt and return maximum pixel difference. 0 = exact.
|
||||
static int RGBTestFilter(int src_width,
|
||||
int src_height,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
FilterMode f,
|
||||
int benchmark_iterations,
|
||||
int disable_cpu_flags,
|
||||
int benchmark_cpu_info) {
|
||||
int src_height,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
FilterMode f,
|
||||
int benchmark_iterations,
|
||||
int disable_cpu_flags,
|
||||
int benchmark_cpu_info) {
|
||||
if (!SizeValid(src_width, src_height, dst_width, dst_height)) {
|
||||
return 0;
|
||||
}
|
||||
@ -67,18 +67,18 @@ static int RGBTestFilter(int src_width,
|
||||
// Warm up both versions for consistent benchmarks.
|
||||
MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
|
||||
RGBScale(src_rgb + (src_stride_rgb * b) + b * 3, src_stride_rgb, src_width,
|
||||
src_height, dst_rgb_c + (dst_stride_rgb * b) + b * 3, dst_stride_rgb,
|
||||
dst_width, dst_height, f);
|
||||
src_height, dst_rgb_c + (dst_stride_rgb * b) + b * 3, dst_stride_rgb,
|
||||
dst_width, dst_height, f);
|
||||
MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
|
||||
RGBScale(src_rgb + (src_stride_rgb * b) + b * 3, src_stride_rgb, src_width,
|
||||
src_height, dst_rgb_opt + (dst_stride_rgb * b) + b * 3, dst_stride_rgb,
|
||||
dst_width, dst_height, f);
|
||||
src_height, dst_rgb_opt + (dst_stride_rgb * b) + b * 3,
|
||||
dst_stride_rgb, dst_width, dst_height, f);
|
||||
|
||||
MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
|
||||
double c_time = get_time();
|
||||
RGBScale(src_rgb + (src_stride_rgb * b) + b * 3, src_stride_rgb, src_width,
|
||||
src_height, dst_rgb_c + (dst_stride_rgb * b) + b * 3, dst_stride_rgb,
|
||||
dst_width, dst_height, f);
|
||||
src_height, dst_rgb_c + (dst_stride_rgb * b) + b * 3, dst_stride_rgb,
|
||||
dst_width, dst_height, f);
|
||||
|
||||
c_time = (get_time() - c_time);
|
||||
|
||||
@ -86,8 +86,8 @@ static int RGBTestFilter(int src_width,
|
||||
double opt_time = get_time();
|
||||
for (i = 0; i < benchmark_iterations; ++i) {
|
||||
RGBScale(src_rgb + (src_stride_rgb * b) + b * 3, src_stride_rgb, src_width,
|
||||
src_height, dst_rgb_opt + (dst_stride_rgb * b) + b * 3, dst_stride_rgb,
|
||||
dst_width, dst_height, f);
|
||||
src_height, dst_rgb_opt + (dst_stride_rgb * b) + b * 3,
|
||||
dst_stride_rgb, dst_width, dst_height, f);
|
||||
}
|
||||
opt_time = (get_time() - opt_time) / benchmark_iterations;
|
||||
|
||||
@ -122,8 +122,8 @@ static int RGBTestFilter(int src_width,
|
||||
#define SX(x, nom, denom) static_cast<int>((x / nom) * denom)
|
||||
|
||||
#define TEST_FACTOR1(name, filter, nom, denom, max_diff) \
|
||||
TEST_F(LibYUVScaleTest, RGBScaleDownBy##name##_##filter) { \
|
||||
int diff = RGBTestFilter( \
|
||||
TEST_F(LibYUVScaleTest, RGBScaleDownBy##name##_##filter) { \
|
||||
int diff = RGBTestFilter( \
|
||||
SX(benchmark_width_, nom, denom), SX(benchmark_height_, nom, denom), \
|
||||
DX(benchmark_width_, nom, denom), DX(benchmark_height_, nom, denom), \
|
||||
kFilter##filter, benchmark_iterations_, disable_cpu_flags_, \
|
||||
@ -156,19 +156,19 @@ TEST_FACTOR(3, 1, 3)
|
||||
#undef SX
|
||||
#undef DX
|
||||
|
||||
#define TEST_SCALETO1(name, width, height, filter, max_diff) \
|
||||
TEST_F(LibYUVScaleTest, name##To##width##x##height##_##filter) { \
|
||||
#define TEST_SCALETO1(name, width, height, filter, max_diff) \
|
||||
TEST_F(LibYUVScaleTest, name##To##width##x##height##_##filter) { \
|
||||
int diff = RGBTestFilter(benchmark_width_, benchmark_height_, width, \
|
||||
height, kFilter##filter, benchmark_iterations_, \
|
||||
disable_cpu_flags_, benchmark_cpu_info_); \
|
||||
EXPECT_LE(diff, max_diff); \
|
||||
} \
|
||||
TEST_F(LibYUVScaleTest, name##From##width##x##height##_##filter) { \
|
||||
height, kFilter##filter, benchmark_iterations_, \
|
||||
disable_cpu_flags_, benchmark_cpu_info_); \
|
||||
EXPECT_LE(diff, max_diff); \
|
||||
} \
|
||||
TEST_F(LibYUVScaleTest, name##From##width##x##height##_##filter) { \
|
||||
int diff = RGBTestFilter(width, height, Abs(benchmark_width_), \
|
||||
Abs(benchmark_height_), kFilter##filter, \
|
||||
benchmark_iterations_, disable_cpu_flags_, \
|
||||
benchmark_cpu_info_); \
|
||||
EXPECT_LE(diff, max_diff); \
|
||||
Abs(benchmark_height_), kFilter##filter, \
|
||||
benchmark_iterations_, disable_cpu_flags_, \
|
||||
benchmark_cpu_info_); \
|
||||
EXPECT_LE(diff, max_diff); \
|
||||
}
|
||||
|
||||
#if defined(ENABLE_FULL_TESTS)
|
||||
@ -194,13 +194,13 @@ TEST_SCALETO(RGBScale, 1920, 1080)
|
||||
#undef TEST_SCALETO1
|
||||
#undef TEST_SCALETO
|
||||
|
||||
#define TEST_SCALESWAPXY1(name, filter, max_diff) \
|
||||
TEST_F(LibYUVScaleTest, name##SwapXY_##filter) { \
|
||||
int diff = \
|
||||
RGBTestFilter(benchmark_width_, benchmark_height_, benchmark_height_, \
|
||||
benchmark_width_, kFilter##filter, benchmark_iterations_, \
|
||||
disable_cpu_flags_, benchmark_cpu_info_); \
|
||||
EXPECT_LE(diff, max_diff); \
|
||||
#define TEST_SCALESWAPXY1(name, filter, max_diff) \
|
||||
TEST_F(LibYUVScaleTest, name##SwapXY_##filter) { \
|
||||
int diff = RGBTestFilter(benchmark_width_, benchmark_height_, \
|
||||
benchmark_height_, benchmark_width_, \
|
||||
kFilter##filter, benchmark_iterations_, \
|
||||
disable_cpu_flags_, benchmark_cpu_info_); \
|
||||
EXPECT_LE(diff, max_diff); \
|
||||
}
|
||||
|
||||
#if defined(ENABLE_FULL_TESTS)
|
||||
@ -228,14 +228,14 @@ TEST_F(LibYUVScaleTest, RGBTest3x) {
|
||||
benchmark_iterations_;
|
||||
for (int i = 0; i < iterations160; ++i) {
|
||||
RGBScale(orig_pixels, kSrcStride, 480, 3, dest_pixels, kDstStride, 160, 1,
|
||||
kFilterBilinear);
|
||||
kFilterBilinear);
|
||||
}
|
||||
|
||||
EXPECT_EQ(225, dest_pixels[0]);
|
||||
EXPECT_EQ(255 - 225, dest_pixels[1]);
|
||||
|
||||
RGBScale(orig_pixels, kSrcStride, 480, 3, dest_pixels, kDstStride, 160, 1,
|
||||
kFilterNone);
|
||||
kFilterNone);
|
||||
|
||||
EXPECT_EQ(225, dest_pixels[0]);
|
||||
EXPECT_EQ(255 - 225, dest_pixels[1]);
|
||||
@ -259,14 +259,14 @@ TEST_F(LibYUVScaleTest, RGBTest4x) {
|
||||
benchmark_iterations_;
|
||||
for (int i = 0; i < iterations160; ++i) {
|
||||
RGBScale(orig_pixels, kSrcStride, 640, 4, dest_pixels, kDstStride, 160, 1,
|
||||
kFilterBilinear);
|
||||
kFilterBilinear);
|
||||
}
|
||||
|
||||
EXPECT_EQ(66, dest_pixels[0]);
|
||||
EXPECT_EQ(190, dest_pixels[1]);
|
||||
|
||||
RGBScale(orig_pixels, kSrcStride, 64, 4, dest_pixels, kDstStride, 16, 1,
|
||||
kFilterNone);
|
||||
kFilterNone);
|
||||
|
||||
EXPECT_EQ(2, dest_pixels[0]); // expect the 3rd pixel of the 3rd row
|
||||
EXPECT_EQ(255 - 2, dest_pixels[1]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user