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 Libav.
7;*
8;* Libav 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;* Libav 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 Libav; if not, write to the Free Software
20;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21;******************************************************************************
22
23%include "x86inc.asm"
24%include "x86util.asm"
25
26SECTION_RODATA
27
28cextern pw_4
29
30SECTION .text
31
32%macro DEINTERLACE 1
33%ifidn %1, inplace
34;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)
35cglobal deinterlace_line_inplace_mmx, 6,6,7,      lum_m4, lum_m3, lum_m2, lum_m1, lum, size
36%else
37;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)
38cglobal deinterlace_line_mmx,         7,7,7, dst, lum_m4, lum_m3, lum_m2, lum_m1, lum, size
39%endif
40    pxor  mm7, mm7
41    movq  mm6, [pw_4]
42.nextrow
43    movd  mm0, [lum_m4q]
44    movd  mm1, [lum_m3q]
45    movd  mm2, [lum_m2q]
46%ifidn %1, inplace
47    movd [lum_m4q], mm2
48%endif
49    movd  mm3, [lum_m1q]
50    movd  mm4, [lumq]
51    punpcklbw mm0, mm7
52    punpcklbw mm1, mm7
53    punpcklbw mm2, mm7
54    punpcklbw mm3, mm7
55    punpcklbw mm4, mm7
56    paddw     mm1, mm3
57    psllw     mm2, 1
58    paddw     mm0, mm4
59    psllw     mm1, 2
60    paddw     mm2, mm6
61    paddw     mm1, mm2
62    psubusw   mm1, mm0
63    psrlw     mm1, 3
64    packuswb  mm1, mm7
65%ifidn %1, inplace
66    movd [lum_m2q], mm1
67%else
68    movd   [dstq], mm1
69    add       dstq, 4
70%endif
71    add    lum_m4q, 4
72    add    lum_m3q, 4
73    add    lum_m2q, 4
74    add    lum_m1q, 4
75    add       lumq, 4
76    sub      sized, 4
77    jg .nextrow
78    REP_RET
79%endmacro
80
81DEINTERLACE ""
82
83DEINTERLACE inplace
84