threadprogress: reorder instructions to fix race.
[ffmpeg.git] / libavcodec / x86 / vp6dsp.asm
blob01065417343135c283a0c29739ccbde38c57a82e
1 ;******************************************************************************
2 ;* MMX/SSE2-optimized functions for the VP6 decoder
3 ;* Copyright (C) 2009 Sebastien Lucas <sebastien.lucas@gmail.com>
4 ;* Copyright (C) 2009 Zuxy Meng <zuxy.meng@gmail.com>
5 ;*
6 ;* This file is part of FFmpeg.
7 ;*
8 ;* FFmpeg is free software; you can redistribute it and/or
9 ;* modify it under the terms of the GNU Lesser General Public
10 ;* License as published by the Free Software Foundation; either
11 ;* version 2.1 of the License, or (at your option) any later version.
13 ;* FFmpeg is distributed in the hope that it will be useful,
14 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ;* Lesser General Public License for more details.
18 ;* You should have received a copy of the GNU Lesser General Public
19 ;* License along with FFmpeg; if not, write to the Free Software
20 ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 ;******************************************************************************
23 %include "libavutil/x86/x86util.asm"
25 cextern pw_64
27 SECTION .text
29 %macro DIAG4 6
30 movq m0, [%1+%2]
31 movq m1, [%1+%3]
32 punpcklbw m0, m7
33 punpcklbw m1, m7
34 pmullw m0, m4 ; src[x-8 ] * biweight [0]
35 pmullw m1, m5 ; src[x ] * biweight [1]
36 paddw m0, m1
37 movq m1, [%1+%4]
38 movq m2, [%1+%5]
39 punpcklbw m1, m7
40 punpcklbw m2, m7
41 pmullw m1, m6 ; src[x+8 ] * biweight [2]
42 pmullw m2, m3 ; src[x+16] * biweight [3]
43 paddw m1, m2
44 paddsw m0, m1
45 paddsw m0, [pw_64] ; Add 64
46 psraw m0, 7
47 packuswb m0, m0
48 movq [%6], m0
49 %endmacro
51 %macro SPLAT4REGS 0
52 pshuflw m4, m3, 0x0
53 pshuflw m5, m3, 0x55
54 pshuflw m6, m3, 0xAA
55 pshuflw m3, m3, 0xFF
56 punpcklqdq m4, m4
57 punpcklqdq m5, m5
58 punpcklqdq m6, m6
59 punpcklqdq m3, m3
60 %endmacro
62 ; void ff_vp6_filter_diag4_<opt>(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
63 ; const int16_t h_weight[4], const int16_t v_weights[4])
64 INIT_XMM sse2
65 cglobal vp6_filter_diag4, 5, 7, 8
66 mov r5, rsp ; backup stack pointer
67 and rsp, ~(mmsize-1) ; align stack
68 sub rsp, 8*11
70 sub r1, r2
72 pxor m7, m7
73 movq m3, [r3]
74 SPLAT4REGS
76 mov r3, rsp
77 mov r6, 11
78 .nextrow:
79 DIAG4 r1, -1, 0, 1, 2, r3
80 add r3, 8
81 add r1, r2
82 dec r6
83 jnz .nextrow
85 movq m3, [r4]
86 SPLAT4REGS
88 lea r3, [rsp+8]
89 mov r6, 8
90 .nextcol:
91 DIAG4 r3, -8, 0, 8, 16, r0
92 add r3, 8
93 add r0, r2
94 dec r6
95 jnz .nextcol
97 mov rsp, r5 ; restore stack pointer
98 RET