rgb2yuv_neon_32.S 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (C) 2013 Xiaolei Yu <dreifachstein@gmail.com>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include "config.h"
  21. #if HAVE_AS_DN_DIRECTIVE
  22. #include "rgb2yuv_neon_common.S"
  23. /* downsampled R16G16B16 x8 */
  24. alias_qw r16x8, q7
  25. alias_qw g16x8, q8
  26. alias_qw b16x8, q9
  27. alias n16x16_o, q11
  28. alias n16x16_ol, q11_l
  29. alias n16x16_oh, q11_h
  30. alias y32x16_el, q12
  31. alias y32x16_eh, q13
  32. alias y32x16_ol, q14
  33. alias y32x16_oh, q15
  34. alias y16x16_e, q12
  35. alias y16x16_el, q12_l
  36. alias y16x16_eh, q12_h
  37. alias y16x16_o, q13
  38. alias y16x16_ol, q13_l
  39. alias y16x16_oh, q13_h
  40. alias y8x16, y16x16_e
  41. .macro init src
  42. // load s32x3x3, narrow to s16x3x3
  43. vld3.i32 {q13_l, q14_l, q15_l}, [\src]!
  44. vld3.i32 {q13_h[0], q14_h[0], q15_h[0]}, [\src]
  45. vmovn.i32 CO_R, q13
  46. vmovn.i32 CO_G, q14
  47. vmovn.i32 CO_B, q15
  48. vmov.u8 BIAS_Y, #16
  49. vmov.u8 BIAS_U, #128
  50. .endm
  51. .macro compute_y_16x1_step action, s8x16, coeff
  52. vmov.u8 n16x16_o, #0
  53. vtrn.u8 \s8x16, n16x16_o
  54. \action y32x16_el, \s8x16\()_l, \coeff
  55. \action y32x16_eh, \s8x16\()_h, \coeff
  56. \action y32x16_ol, n16x16_ol, \coeff
  57. \action y32x16_oh, n16x16_oh, \coeff
  58. .endm
  59. /*
  60. * in: r8x16, g8x16, b8x16
  61. * out: y8x16
  62. * clobber: q11-q15, r8x16, g8x16, b8x16
  63. */
  64. .macro compute_y_16x1
  65. compute_y_16x1_step vmull, r8x16, CO_RY
  66. compute_y_16x1_step vmlal, g8x16, CO_GY
  67. compute_y_16x1_step vmlal, b8x16, CO_BY
  68. vrshrn.i32 y16x16_el, y32x16_el, #15
  69. vrshrn.i32 y16x16_eh, y32x16_eh, #15
  70. vrshrn.i32 y16x16_ol, y32x16_ol, #15
  71. vrshrn.i32 y16x16_oh, y32x16_oh, #15
  72. vtrn.8 y16x16_e, y16x16_o
  73. vadd.u8 y8x16, y8x16, BIAS_Y
  74. .endm
  75. alias c32x8_l, q14
  76. alias c32x8_h, q15
  77. alias_qw c16x8, q13
  78. alias_qw c8x8x2, q10
  79. .macro compute_chroma_8x1_step action, s16x8, coeff
  80. \action c32x8_l, \s16x8\()_l, \coeff
  81. \action c32x8_h, \s16x8\()_h, \coeff
  82. .endm
  83. /*
  84. * in: r16x8, g16x8, b16x8
  85. * out: c8x8
  86. * clobber: q14-q15
  87. */
  88. .macro compute_chroma_8x1 c, C
  89. compute_chroma_8x1_step vmull, r16x8, CO_R\C
  90. compute_chroma_8x1_step vmlal, g16x8, CO_G\C
  91. compute_chroma_8x1_step vmlal, b16x8, CO_B\C
  92. vrshrn.i32 c16x8_l, c32x8_l, #15
  93. vrshrn.i32 c16x8_h, c32x8_h, #15
  94. vmovn.i16 \c\()8x8, c16x8
  95. vadd.u8 \c\()8x8, \c\()8x8, BIAS_\C
  96. .endm
  97. loop_420sp rgbx, nv12, init, kernel_420_16x2, 32
  98. #endif