aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/x86/vf_eq.asm
blob: a30a287029425f38aaa30bc9ca0e6868ce956aa2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
;*****************************************************************************
;* x86-optimized functions for eq filter
;*
;* Original MPlayer filters by Richard Felker.
;*
;* This file is part of FFmpeg.
;*
;* FFmpeg is free software; you can redistribute it and/or modify
;* it under the terms of the GNU General Public License as published by
;* the Free Software Foundation; either version 2 of the License, or
;* (at your option) any later version.
;*
;* FFmpeg is distributed in the hope that it will be useful,
;* but WITHOUT ANY WARRANTY; without even the implied warranty of
;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;* GNU General Public License for more details.
;*
;* You should have received a copy of the GNU General Public License along
;* with FFmpeg; if not, write to the Free Software Foundation, Inc.,
;* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
;*****************************************************************************

%include "libavutil/x86/x86util.asm"

SECTION .text

%macro PROCESS_ONE_LINE 1
cglobal process_one_line, 5, 7, 5, src, dst, contrast, brightness, w
    movd m3, contrastd
    movd m4, brightnessd
    movsx r5d, contrastw
    movsx r6d, brightnessw
    SPLATW m3, m3, 0
    SPLATW m4, m4, 0

    DEFINE_ARGS src, dst, tmp, scalar, w
    xor tmpd, tmpd
    pxor m0, m0
    pxor m1, m1
    mov scalard, wd
    and scalard, mmsize-1
    sar wd, %1
    cmp wd, 1
    jl .loop1

    .loop0:
        movu m1, [srcq]
        mova m2, m1
        punpcklbw m1, m0
        punpckhbw m2, m0
        psllw m1, 4
        psllw m2, 4
        pmulhw m1, m3
        pmulhw m2, m3
        paddw m1, m4
        paddw m2, m4
        packuswb m1, m2
        movu [dstq], m1
        add srcq, mmsize
        add dstq, mmsize
        sub wd, 1
        cmp wd, 0
        jne .loop0

    .loop1:
        cmp scalard, 0
        je .end
        movzx tmpd, byte [srcq]
        imul tmpd, r5d
        sar tmpd, 12
        add tmpd, r6d
        movd m1, tmpd
        packuswb m1, m0
        movd tmpd, m1
        mov [dstq], tmpb
        inc srcq
        inc dstq
        dec scalard
        jmp .loop1

    .end:
        RET

%endmacro

INIT_MMX mmxext
PROCESS_ONE_LINE 3

INIT_XMM sse2
PROCESS_ONE_LINE 4