scene_sad.asm 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ;*****************************************************************************
  2. ;* x86-optimized functions for scene SAD
  3. ;*
  4. ;* Copyright (C) 2018 Marton Balint
  5. ;*
  6. ;* Based on vf_blend.asm, Copyright (C) 2015 Paul B Mahol
  7. ;*
  8. ;* This file is part of FFmpeg.
  9. ;*
  10. ;* FFmpeg is free software; you can redistribute it and/or
  11. ;* modify it under the terms of the GNU Lesser General Public
  12. ;* License as published by the Free Software Foundation; either
  13. ;* version 2.1 of the License, or (at your option) any later version.
  14. ;*
  15. ;* FFmpeg is distributed in the hope that it will be useful,
  16. ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. ;* Lesser General Public License for more details.
  19. ;*
  20. ;* You should have received a copy of the GNU Lesser General Public
  21. ;* License along with FFmpeg; if not, write to the Free Software
  22. ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. ;******************************************************************************
  24. %include "libavutil/x86/x86util.asm"
  25. SECTION .text
  26. %macro SAD_INIT 0
  27. cglobal scene_sad, 6, 7, 2, src1, stride1, src2, stride2, width, end, x
  28. add src1q, widthq
  29. add src2q, widthq
  30. neg widthq
  31. pxor m1, m1
  32. %endmacro
  33. %macro SAD_LOOP 0
  34. .nextrow:
  35. mov xq, widthq
  36. .loop:
  37. movu m0, [src1q + xq]
  38. psadbw m0, [src2q + xq]
  39. paddq m1, m0
  40. add xq, mmsize
  41. jl .loop
  42. add src1q, stride1q
  43. add src2q, stride2q
  44. sub endd, 1
  45. jg .nextrow
  46. mov r0q, r6mp
  47. movu [r0q], m1 ; sum
  48. REP_RET
  49. %endmacro
  50. %macro SAD_FRAMES 0
  51. SAD_INIT
  52. SAD_LOOP
  53. %endmacro
  54. INIT_XMM sse2
  55. SAD_FRAMES
  56. %if HAVE_AVX2_EXTERNAL
  57. INIT_YMM avx2
  58. SAD_FRAMES
  59. %endif