]> git.sesse.net Git - ffmpeg/blob - libavfilter/x86/scene_sad.asm
avfilter/vf_gblur: add missing preprocessor check
[ffmpeg] / libavfilter / x86 / scene_sad.asm
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
25 %include "libavutil/x86/x86util.asm"
26
27 SECTION .text
28
29
30 %macro SAD_INIT 0
31 cglobal scene_sad, 6, 7, 2, src1, stride1, src2, stride2, width, end, x
32     add     src1q, widthq
33     add     src2q, widthq
34     neg    widthq
35     pxor       m1, m1
36 %endmacro
37
38
39 %macro SAD_LOOP 0
40 .nextrow:
41     mov        xq, widthq
42
43     .loop:
44         movu            m0, [src1q + xq]
45         psadbw          m0, [src2q + xq]
46         paddq           m1, m0
47         add             xq, mmsize
48     jl .loop
49     add     src1q, stride1q
50     add     src2q, stride2q
51     sub      endd, 1
52     jg .nextrow
53
54     mov         r0q, r6mp
55     movu      [r0q], m1      ; sum
56 REP_RET
57 %endmacro
58
59
60 %macro SAD_FRAMES 0
61     SAD_INIT
62     SAD_LOOP
63 %endmacro
64
65
66 INIT_XMM sse2
67 SAD_FRAMES
68
69 %if HAVE_AVX2_EXTERNAL
70
71 INIT_YMM avx2
72 SAD_FRAMES
73
74 %endif