ARGBToAR30 use vpmulhuw to replicate fields

AR30 is optimized with 3 techniques
1. vpmulhuw is used to replicate 8 bits to 10 bits.
2. Two channels are processed at a time.  R and B, and A and G.
3. vpshufb is used to shift and mask 2 channels of R and B

Red Blue
With the 8 bit value in the upper bits, vpmulhuw by (1024+4) will produce a 10
bit value in the low 10 bits of each 16 bit value. This is whats wanted for the
blue channel. The red needs to be shifted 4 left, so multiply by (1024+4)*16 for
red.

Alpha Green
Alpha and Green are already in the high bits so vpand can zero out the other
bits, keeping just 2 upper bits of alpha and 8 bit green. The same multiplier
could be used for Green - (1024+4) putting the 10 bit green in the lsb.  Alpha
would be a simple multiplier to shift it into position.  It wants a gap of 10
above the green.  Green is 10 bits, so there are 6 bits in the low short.  4
more are needed, so a multiplier of 4 gets the 2 bits into the upper 16 bits,
and then a shift of 4 is a multiply of 16, so (4*16) = 64.  Then shift the
result left 10 to position the A and G channels.

Bug: libyuv:751
Test: ARGBToAR30_Opt
Change-Id: Ie4f20dce18203bae7b75acb1fd5232db8a8a4f11
Reviewed-on: https://chromium-review.googlesource.com/820046
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
Reviewed-by: Cheng Wang <wangcheng@google.com>
2 files changed
tree: ac6a284fe290fe1da81e9d39fde5792cedfcba39
  1. build_overrides/
  2. docs/
  3. include/
  4. infra/
  5. source/
  6. tools_libyuv/
  7. unit_test/
  8. util/
  9. .clang-format
  10. .gitignore
  11. .gn
  12. .vpython
  13. all.gyp
  14. Android.bp
  15. Android.mk
  16. AUTHORS
  17. BUILD.gn
  18. cleanup_links.py
  19. CM_linux_packages.cmake
  20. CMakeLists.txt
  21. codereview.settings
  22. DEPS
  23. download_vs_toolchain.py
  24. gyp_libyuv
  25. gyp_libyuv.py
  26. libyuv.gni
  27. libyuv.gyp
  28. libyuv.gypi
  29. libyuv_nacl.gyp
  30. libyuv_test.gyp
  31. LICENSE
  32. LICENSE_THIRD_PARTY
  33. linux.mk
  34. OWNERS
  35. PATENTS
  36. PRESUBMIT.py
  37. public.mk
  38. pylintrc
  39. README.chromium
  40. README.md
  41. 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.
  • Convert from YUV to formats for rendering/effects.
  • Rotate by 90/180/270 degrees to adjust for mobile devices in portrait mode.
  • Optimized for SSE2/SSSE3/AVX2 on x86/x64.
  • Optimized for Neon on Arm.
  • Optimized for DSP R2 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.