28 Commits

Author SHA1 Message Date
Frank Barchard
e0040eb318 Apply clang format
Bug: None
Change-Id: I0d9db4b384144523e61ae32b6ab3f72e93a0c265
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/6138934
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
Reviewed-by: Wan-Teh Chang <wtc@google.com>
2025-01-02 13:31:20 -08:00
Frank Barchard
7633328b5f Make functions that malloc check for ubsan math overflow
- add support for negative heights
- sanity check null pointers and invalid width/height

Bug: b/371615496
Change-Id: Icbefcb1ccc5cdf90e417c73440c6fad3b63ed7df
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/5917072
Reviewed-by: Wan-Teh Chang <wtc@google.com>
2024-10-08 21:08:34 +00:00
Frank Barchard
ffd791f749 Check malloc allocation sizes are less than SIZE_MAX
Bug: b/371615496
Change-Id: I75a94b08469d6d6b6fd55a8659031cbcb3d48eed
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/5912039
Reviewed-by: Wan-Teh Chang <wtc@google.com>
2024-10-07 21:34:15 +00:00
Frank Barchard
94af5319f4 Remove M420 and refactor NV12ToI420
M420 is a row biplanar variation of NV12 supported on Microsoft webcams.
The code was hardcoded to bt.601 and should be jpeg, but the format is
very old and rare.  Is a variation on NV12, so if someone needs it, it
can be re-implemented easily.

Bug: libyuv:858
Change-Id: I246167dba3c190cc76af741b8e91e58e68fde28f
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/2212608
Reviewed-by: richard winterton <rrwinterton@gmail.com>
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
2020-05-26 18:48:00 +00:00
Frank Barchard
1f12946068 Add U444ToABGR, J444ToABGR, H444ToABGR, H444ToARGB and ConvertToARGB support
BUG=960620, libyuv:845, b/129864744

Change-Id: I9f80cda3be8e13298c596fac514f65a23a38d3d0
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/1900310
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
2019-11-05 22:11:20 +00:00
Frank Barchard
53e014c99d BT.2020 pull in tests and upstream fixes; expose a few more methods.
This adds some missing prototypes from the BT.2020 CL as well as expands
the H444 and J444 results.

BUG=960620, libyuv:845, b/129864744

Change-Id: I8ea3959379f1bb2edb857d4eb90fb9a1f6aa4e03
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/1899093
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
2019-11-05 20:01:59 +00:00
Frank Barchard
4d67b3e851 Add H420 and H422 to ConvertToARGB()
H420/H422 are bt.720 variants

TBR=braveyao@chromium.org
BUG=libyuv:799
TESTED=try bots tested build on all platforms

Change-Id: I007d8981d91ca0748c59403759109bbcd88f286c
Reviewed-on: https://chromium-review.googlesource.com/1115719
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
Reviewed-by: Frank Barchard <fbarchard@chromium.org>
2018-06-26 22:52:42 +00:00
Frank Barchard
083aa718b9 Add AR30 and AB30 to ConvertToARGB() and fix negative NV12 height
BUG=libyuv:799
TESTED=try bots build

Change-Id: Ib4ce8d928069445a710c1e30ea85d9dccc820b6c
Reviewed-on: https://chromium-review.googlesource.com/1097561
Reviewed-by: Miguel Casas <mcasas@chromium.org>
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
2018-06-12 19:04:40 +00:00
Frank Barchard
196e2e72a3 Revert "Allow negative height when ConvertToI420/ARGB is called with NV12/NV21"
This reverts commit a8aa921c4614f9d6a0e8f3459648ca1ae75cdbe6.

Reason for revert: breaks a webrtc unittest on Windows.

https://bugs.chromium.org/p/webrtc/issues/detail?id=9263&can=2&start=0&num=100&q=&colspec=ID%20Pri%20M%20ReleaseBlock%20Component%20Status%20Owner%20Summary&groupby=&sort=

Original change's description:
> Allow negative height when ConvertToI420/ARGB is called with NV12/NV21
> 
> ConvertToI420 and ConvertToARGB support the use of a negative height
> parameter to flip the image vertically. When converting from NV12 or
> NV21 this parameter was misinterpreted, resulting in invalid output.
> This CL introduces the use of abs_src_height to correctly calculate
> the location of the source UV plane.
> 
> The sign of crop_height is not used, to reduce confusion ConvertToI420
> and ConvertToARGB no longer accept negative crop height.
> 
> Unit tests for Android420ToI420 are updated to fix miscalculation of
> src_stride_uv, fix incorrect pixel strides, and to test inversion.
> New unit tests are included to test inversion for ConvertToARGB,
> ConvertToI420, Android420ToARGB, and Android420ToABGR.
> For consistency the test NV12Crop is renamed ConvertToI420_NV12_Crop.
> 
> Bug: libyuv:446
> Test: out/Release/libyuv_unittest --gtest_filter=*.ConvertTo*:*.Android420To*
> Change-Id: Idc98e62671cb30272cfa7e24fafbc8b73712f7c6
> Reviewed-on: https://chromium-review.googlesource.com/994074
> Commit-Queue: Frank Barchard <fbarchard@chromium.org>
> Reviewed-by: Frank Barchard <fbarchard@chromium.org>

TBR=fbarchard@chromium.org,robert@bares.me

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: libyuv:446, chromium:9263, libyuv:801
Change-Id: I7c55b3fcb477f9754c249b9c2c54b24da2c29283
Reviewed-on: https://chromium-review.googlesource.com/1081267
Reviewed-by: Frank Barchard <fbarchard@chromium.org>
Reviewed-by: Weiyong Yao <braveyao@chromium.org>
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
2018-06-01 00:19:40 +00:00
Robert Bares
a8aa921c46 Allow negative height when ConvertToI420/ARGB is called with NV12/NV21
ConvertToI420 and ConvertToARGB support the use of a negative height
parameter to flip the image vertically. When converting from NV12 or
NV21 this parameter was misinterpreted, resulting in invalid output.
This CL introduces the use of abs_src_height to correctly calculate
the location of the source UV plane.

The sign of crop_height is not used, to reduce confusion ConvertToI420
and ConvertToARGB no longer accept negative crop height.

Unit tests for Android420ToI420 are updated to fix miscalculation of
src_stride_uv, fix incorrect pixel strides, and to test inversion.
New unit tests are included to test inversion for ConvertToARGB,
ConvertToI420, Android420ToARGB, and Android420ToABGR.
For consistency the test NV12Crop is renamed ConvertToI420_NV12_Crop.

Bug: libyuv:446
Test: out/Release/libyuv_unittest --gtest_filter=*.ConvertTo*:*.Android420To*
Change-Id: Idc98e62671cb30272cfa7e24fafbc8b73712f7c6
Reviewed-on: https://chromium-review.googlesource.com/994074
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
Reviewed-by: Frank Barchard <fbarchard@chromium.org>
2018-04-19 02:41:27 +00:00
Frank Barchard
e1f6c1c0b5 tidy applied with readability-inconsistent-declaration-parameter-name
Bug: libyuv:750
Test: builds and runs and passes more tidy tests
Change-Id: I023699a7aa61ea3f5e4a21647112691ea5739281
Reviewed-on: https://chromium-review.googlesource.com/902170
Reviewed-by: Weiyong Yao <braveyao@chromium.org>
2018-02-07 00:24:25 +00:00
Frank Barchard
7e389884a1 Switch to C99 types
Append _t to all sized types.
uint64 becomes uint64_t etc

Bug: libyuv:774
Test: try bots build on all platforms
Change-Id: Ide273d7f8012313d6610415d514a956d6f3a8cac
Reviewed-on: https://chromium-review.googlesource.com/879922
Reviewed-by: Miguel Casas <mcasas@chromium.org>
2018-01-23 19:16:05 +00:00
Frank Barchard
a7c87e19f0 add Intel Code Analyst markers
add macros to enable/disable code analyst around blocks of code.

Normally these macros should not be used, but if performance
details are wanted for intel code, enable them around the code
and then run via the iaca tool, available on the intel website.

BUG=libyuv:670
TEST=~/iaca-lin64/bin/iaca.sh -64 out/Release/libyuv_unittest
R=wangcheng@google.com

Review-Url: https://codereview.chromium.org/2626193002 .
2017-01-13 15:50:24 -08:00
Frank Barchard
cb11559408 ConvertToARGB: Allows rotation on ARGB input
BUG=libyuv:668
TEST=run unit tests
R=fbarchard@google.com

Review-Url: https://codereview.chromium.org/2620183002 .
2017-01-11 14:38:25 -08:00
Frank Barchard
e62309f259 clang-format libyuv
BUG=libyuv:654
R=kjellander@chromium.org

Review URL: https://codereview.chromium.org/2469353005 .
2016-11-07 17:37:23 -08:00
Frank Barchard
d363ea6527 Remove I411 support.
YUV 411 is very uncommon format.  Remove support.

Update documentation to reflect that 411 is deprecated.

Simplify tests for YUV to only test with the new side by side YUV but keep old 3 plane test around with a macro for now.

BUG=libyuv:645
R=kjellander@chromium.org

Review URL: https://codereview.chromium.org/2406123002 .
2016-10-11 11:14:16 -07:00
Niels Möller
365ed3851c Treat YU12 as an alias for I420. Simplify setting of inv_crop_height.
BUG=
R=fbarchard@google.com

Review URL: https://codereview.chromium.org/2020193002 .
2016-06-16 12:49:17 +02:00
Frank Barchard
9c53ff2c57 Fix temporary stride for ConvertToARGB with rotation.
BUG=libyuv:578
TESTED=local unittests pass
R=harryjin@google.com

Review URL: https://codereview.chromium.org/1879783002 .
2016-04-11 15:21:04 -07:00
fbarchard@google.com
5ab38f9258 Remove Q420 fourcc support.
BUG=396
TESTED=local build of unittest builds and passes
R=harryjin@google.com

Review URL: https://webrtc-codereview.appspot.com/39089004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@1278 16f28f9a-4ce2-e073-06de-1de4eb20be90
2015-02-11 18:20:54 +00:00
fbarchard@google.com
0887315390 Remove bayer format support from libyuv. This format is very rare and used on legacy hardware. Its not well optimized and has bugs related to odd widths. Removing the format will allow tests to pass under more circumstances, run faster and allow focus on higher priority quality and performance issues.
BUG=301
TESTED=local unittests build/pass on windows gyp build.
R=harryjin@google.com

Review URL: https://webrtc-codereview.appspot.com/38059004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@1270 16f28f9a-4ce2-e073-06de-1de4eb20be90
2015-02-09 19:58:19 +00:00
fbarchard@google.com
40e3457574 J420ToARGB jpeg variation of YUV color space to ARGB.
BUG=241
TESTED=J420ToARGB unittest
R=harryjin@google.com

Review URL: https://webrtc-codereview.appspot.com/32929004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@1212 16f28f9a-4ce2-e073-06de-1de4eb20be90
2014-12-29 19:17:53 +00:00
fbarchard@google.com
6d82347dda Conversion functions ported to C89 / Visual C.
BUG=303
TESTED=cl /c /TC /Iinclude source/convert_to_argb.cc
R=tpsiaki@google.com

Review URL: https://webrtc-codereview.appspot.com/6969004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@964 16f28f9a-4ce2-e073-06de-1de4eb20be90
2014-01-13 18:32:37 +00:00
fbarchard@google.com
53a7923b15 cast malloc to uint8*
BUG=303
TESTED=visual c higher warnings
R=tpsiaki@google.com

Review URL: https://webrtc-codereview.appspot.com/6639004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@955 16f28f9a-4ce2-e073-06de-1de4eb20be90
2014-01-07 06:06:01 +00:00
fbarchard@google.com
1f923e3ea6 Declare parameters that are unused, since C does not let you give a type without name.
BUG=303
TEST=compile -x c

Review URL: https://webrtc-codereview.appspot.com/6599006

git-svn-id: http://libyuv.googlecode.com/svn/trunk@954 16f28f9a-4ce2-e073-06de-1de4eb20be90
2014-01-07 05:42:27 +00:00
fbarchard@google.com
db73518b19 use LIBYUV_BOOL instead of bool
BUG=303
TESTED=try
R=tpsiaki@google.com

Review URL: https://webrtc-codereview.appspot.com/6519006

git-svn-id: http://libyuv.googlecode.com/svn/trunk@953 16f28f9a-4ce2-e073-06de-1de4eb20be90
2014-01-07 03:59:31 +00:00
fbarchard@google.com
f2bd31538e Change name of variable for convert to crop_width/height instead of dst_width/height to clarify that it is used to crop the original before rotation and is not the final destination size.
BUG=none
TESTED=local builds still work
R=wjia@google.com, wjia@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/5859004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@915 16f28f9a-4ce2-e073-06de-1de4eb20be90
2013-12-16 18:23:04 +00:00
fbarchard@google.com
2d8824079a Fix ConvertToI420() to properly delete temporary array when rotating result. When rotating an image ConvertToI420() allocates a temporary buffer using new[], but then attempts to delete it using delete instead of delete[].This issue is not the root cause of the referenced bug, but it needs to be addressed in order to fix that bug.
BUG=crbug.com/306876
TESTED=try bots
R=wuwang@google.com

Review URL: https://webrtc-codereview.appspot.com/4129005

git-svn-id: http://libyuv.googlecode.com/svn/trunk@866 16f28f9a-4ce2-e073-06de-1de4eb20be90
2013-11-20 21:18:23 +00:00
fbarchard@google.com
8c8cf8d707 Move convert_to_argb and MJPGToARGB to isolated files. Move ValidateJPeg to its own file. Allows jpeg to be not linked in for more applications.
BUG=212
TESTED=manual test by removing mjpeg_decode.cc from gyp file and built/ran unittests
Review URL: https://webrtc-codereview.appspot.com/1310007

git-svn-id: http://libyuv.googlecode.com/svn/trunk@656 16f28f9a-4ce2-e073-06de-1de4eb20be90
2013-04-11 16:34:24 +00:00