You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
3.9KB

  1. ;******************************************************************************
  2. ;* V210 SIMD pack
  3. ;* Copyright (c) 2014 Kieran Kunhya <kierank@obe.tv>
  4. ;*
  5. ;* This file is part of Libav.
  6. ;*
  7. ;* Libav is free software; you can redistribute it and/or
  8. ;* modify it under the terms of the GNU Lesser General Public
  9. ;* License as published by the Free Software Foundation; either
  10. ;* version 2.1 of the License, or (at your option) any later version.
  11. ;*
  12. ;* Libav is distributed in the hope that it will be useful,
  13. ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. ;* Lesser General Public License for more details.
  16. ;*
  17. ;* You should have received a copy of the GNU Lesser General Public
  18. ;* License along with Libav; if not, write to the Free Software
  19. ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. ;******************************************************************************
  21. %include "libavutil/x86/x86util.asm"
  22. SECTION_RODATA
  23. v210_enc_min_10: times 8 dw 0x4
  24. v210_enc_max_10: times 8 dw 0x3fb
  25. v210_enc_luma_mult_10: dw 4,1,16,4,1,16,0,0
  26. v210_enc_luma_shuf_10: db -1,0,1,-1,2,3,4,5,-1,6,7,-1,8,9,10,11
  27. v210_enc_chroma_mult_10: dw 1,4,16,0,16,1,4,0
  28. v210_enc_chroma_shuf_10: db 0,1,8,9,-1,2,3,-1,10,11,4,5,-1,12,13,-1
  29. v210_enc_min_8: times 16 db 0x1
  30. v210_enc_max_8: times 16 db 0xfe
  31. v210_enc_luma_shuf_8: db 6,-1,7,-1,8,-1,9,-1,10,-1,11,-1,-1,-1,-1,-1
  32. v210_enc_luma_mult_8: dw 16,4,64,16,4,64,0,0
  33. v210_enc_chroma_shuf1_8: db 0,-1,1,-1,2,-1,3,-1,8,-1,9,-1,10,-1,11,-1
  34. v210_enc_chroma_shuf2_8: db 3,-1,4,-1,5,-1,7,-1,11,-1,12,-1,13,-1,15,-1
  35. v210_enc_chroma_mult_8: dw 4,16,64,0,64,4,16,0
  36. SECTION .text
  37. %macro v210_planar_pack_10 0
  38. ; v210_planar_pack_10(const uint16_t *y, const uint16_t *u, const uint16_t *v, uint8_t *dst, ptrdiff_t width)
  39. cglobal v210_planar_pack_10, 5, 5, 4, y, u, v, dst, width
  40. lea r0, [yq+2*widthq]
  41. add uq, widthq
  42. add vq, widthq
  43. neg widthq
  44. mova m2, [v210_enc_min_10]
  45. mova m3, [v210_enc_max_10]
  46. .loop
  47. movu m0, [yq+2*widthq]
  48. CLIPW m0, m2, m3
  49. movq m1, [uq+widthq]
  50. movhps m1, [vq+widthq]
  51. CLIPW m1, m2, m3
  52. pmullw m0, [v210_enc_luma_mult_10]
  53. pshufb m0, [v210_enc_luma_shuf_10]
  54. pmullw m1, [v210_enc_chroma_mult_10]
  55. pshufb m1, [v210_enc_chroma_shuf_10]
  56. por m0, m1
  57. movu [dstq], m0
  58. add dstq, mmsize
  59. add widthq, 6
  60. jl .loop
  61. RET
  62. %endmacro
  63. INIT_XMM ssse3
  64. v210_planar_pack_10
  65. %macro v210_planar_pack_8 0
  66. ; v210_planar_pack_8(const uint8_t *y, const uint8_t *u, const uint8_t *v, uint8_t *dst, ptrdiff_t width)
  67. cglobal v210_planar_pack_8, 5, 5, 7, y, u, v, dst, width
  68. add yq, widthq
  69. shr widthq, 1
  70. add uq, widthq
  71. add vq, widthq
  72. neg widthq
  73. mova m4, [v210_enc_min_8]
  74. mova m5, [v210_enc_max_8]
  75. pxor m6, m6
  76. .loop
  77. movu m1, [yq+2*widthq]
  78. CLIPUB m1, m4, m5
  79. punpcklbw m0, m1, m6
  80. ; can't unpack high bytes in the same way because we process
  81. ; only six bytes at a time
  82. pshufb m1, [v210_enc_luma_shuf_8]
  83. pmullw m0, [v210_enc_luma_mult_8]
  84. pmullw m1, [v210_enc_luma_mult_8]
  85. pshufb m0, [v210_enc_luma_shuf_10]
  86. pshufb m1, [v210_enc_luma_shuf_10]
  87. movq m3, [uq+widthq]
  88. movhps m3, [vq+widthq]
  89. CLIPUB m3, m4, m5
  90. ; shuffle and multiply to get the same packing as in 10-bit
  91. pshufb m2, m3, [v210_enc_chroma_shuf1_8]
  92. pshufb m3, [v210_enc_chroma_shuf2_8]
  93. pmullw m2, [v210_enc_chroma_mult_8]
  94. pmullw m3, [v210_enc_chroma_mult_8]
  95. pshufb m2, [v210_enc_chroma_shuf_10]
  96. pshufb m3, [v210_enc_chroma_shuf_10]
  97. por m0, m2
  98. por m1, m3
  99. movu [dstq], m0
  100. movu [dstq+mmsize], m1
  101. add dstq, 2*mmsize
  102. add widthq, 6
  103. jl .loop
  104. RET
  105. %endmacro
  106. INIT_XMM ssse3
  107. v210_planar_pack_8
  108. INIT_XMM avx
  109. v210_planar_pack_8