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>
4 files changed
tree: e16d06b5323d206885397ce189e9c9e0902acbb8
  1. .clang-format
  2. .gitignore
  3. .gn
  4. .vpython
  5. AUTHORS
  6. Android.bp
  7. Android.mk
  8. BUILD.gn
  9. CM_linux_packages.cmake
  10. CMakeLists.txt
  11. DEPS
  12. LICENSE
  13. OWNERS
  14. PATENTS
  15. PRESUBMIT.py
  16. README.chromium
  17. README.md
  18. all.gyp
  19. build_overrides/
  20. cleanup_links.py
  21. codereview.settings
  22. docs/
  23. download_vs_toolchain.py
  24. gyp_libyuv
  25. gyp_libyuv.py
  26. include/
  27. infra/
  28. libyuv.gni
  29. libyuv.gyp
  30. libyuv.gypi
  31. libyuv_nacl.gyp
  32. libyuv_test.gyp
  33. linux.mk
  34. public.mk
  35. pylintrc
  36. source/
  37. tools_libyuv/
  38. unit_test/
  39. util/
  40. winarm.mk
README.md

libyuv is an open source project that includes YUV scaling and conversion functionality.

  • Scale YUV to prepare content for compression, with point, bilinear or box filter.
  • Convert to YUV from webcam formats for compression.
  • Convert to RGB formats for rendering/effects.
  • Rotate by 90/180/270 degrees to adjust for mobile devices in portrait mode.
  • Optimized for SSSE3/AVX2 on x86/x64.
  • Optimized for Neon on Arm.
  • Optimized for MSA on Mips.

Development

See [Getting started] 1 for instructions on how to get started developing.

You can also browse the [docs directory] 2 for more documentation.