vf_limiter.asm 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. ;*****************************************************************************
  2. ;* x86-optimized functions for limiter filter
  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 "libavutil/x86/x86util.asm"
  21. SECTION .text
  22. INIT_XMM sse2
  23. cglobal limiter_8bit, 6, 7, 3, src, dst, slinesize, dlinesize, w, h, x
  24. movsxdifnidn wq, wd
  25. add srcq, wq
  26. add dstq, wq
  27. neg wq
  28. movd m1, r6m
  29. punpcklbw m1, m1
  30. SPLATW m1, m1
  31. movd m2, r7m
  32. punpcklbw m2, m2
  33. SPLATW m2, m2
  34. .nextrow:
  35. mov xq, wq
  36. .loop:
  37. movu m0, [srcq + xq]
  38. CLIPUB m0, m1, m2
  39. mova [dstq+xq], m0
  40. add xq, mmsize
  41. jl .loop
  42. add srcq, slinesizeq
  43. add dstq, dlinesizeq
  44. sub hd, 1
  45. jg .nextrow
  46. RET
  47. INIT_XMM sse4
  48. cglobal limiter_16bit, 6, 7, 3, src, dst, slinesize, dlinesize, w, h, x
  49. shl wd, 1
  50. add srcq, wq
  51. add dstq, wq
  52. neg wq
  53. movd m1, r6m
  54. SPLATW m1, m1
  55. movd m2, r7m
  56. SPLATW m2, m2
  57. .nextrow:
  58. mov xq, wq
  59. .loop:
  60. movu m0, [srcq + xq]
  61. pmaxuw m0, m1
  62. pminuw m0, m2
  63. mova [dstq+xq], m0
  64. add xq, mmsize
  65. jl .loop
  66. add srcq, slinesizeq
  67. add dstq, dlinesizeq
  68. sub hd, 1
  69. jg .nextrow
  70. RET