Convert deinterlacing MMX code to YASM
[libav.git] / libavcodec / x86 / deinterlace.asm
1 ;******************************************************************************
2 ;* MMX optimized deinterlacing functions
3 ;* Copyright (c) 2010 Vitor Sessak
4 ;* Copyright (c) 2002 Michael Niedermayer
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.
12 ;*
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.
17 ;*
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 ;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 ;******************************************************************************
22
23 %include "x86inc.asm"
24 %include "x86util.asm"
25
26 SECTION_RODATA
27
28 cextern pw_4
29
30 %macro DEINTERLACE 1
31 %ifidn %1, inplace
32 ;void ff_deinterlace_line_inplace_mmx(const uint8_t *lum_m4, const uint8_t *lum_m3, const uint8_t *lum_m2, const uint8_t *lum_m1, const uint8_t *lum, int size)
33 cglobal deinterlace_line_inplace_mmx, 6,6,7, lum_m4, lum_m3, lum_m2, lum_m1, lum, size
34 %else
35 ;void ff_deinterlace_line_mmx(uint8_t *dst, const uint8_t *lum_m4, const uint8_t *lum_m3, const uint8_t *lum_m2, const uint8_t *lum_m1, const uint8_t *lum, int size)
36 cglobal deinterlace_line_mmx, 7,7,7, dst, lum_m4, lum_m3, lum_m2, lum_m1, lum, size
37 %endif
38 pxor mm7, mm7
39 movq mm6, [pw_4]
40 .nextrow
41 movd mm0, [lum_m4q]
42 movd mm1, [lum_m3q]
43 movd mm2, [lum_m2q]
44 %ifidn %1, inplace
45 movd [lum_m4q], mm2
46 %endif
47 movd mm3, [lum_m1q]
48 movd mm4, [lumq]
49 punpcklbw mm0, mm7
50 punpcklbw mm1, mm7
51 punpcklbw mm2, mm7
52 punpcklbw mm3, mm7
53 punpcklbw mm4, mm7
54 paddw mm1, mm3
55 psllw mm2, 1
56 paddw mm0, mm4
57 psllw mm1, 2
58 paddw mm2, mm6
59 paddw mm1, mm2
60 psubusw mm1, mm0
61 psrlw mm1, 3
62 packuswb mm1, mm7
63 %ifidn %1, inplace
64 movd [lum_m2q], mm1
65 %else
66 movd [dstq], mm1
67 add dstq, 4
68 %endif
69 add lum_m4q, 4
70 add lum_m3q, 4
71 add lum_m2q, 4
72 add lum_m1q, 4
73 add lumq, 4
74 sub sized, 4
75 jg .nextrow
76 REP_RET
77 %endmacro
78
79 DEINTERLACE ""
80
81 DEINTERLACE inplace