]> git.sesse.net Git - ffmpeg/blob - libavcodec/x86/mpegvideoencdsp.asm
xsubdec: Convert to the new bitstream reader
[ffmpeg] / libavcodec / x86 / mpegvideoencdsp.asm
1 ;*****************************************************************************
2 ;* SIMD-optimized MPEG encoding functions
3 ;*****************************************************************************
4 ;* Copyright (c) 2000, 2001 Fabrice Bellard
5 ;* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
6 ;*
7 ;* This file is part of Libav.
8 ;*
9 ;* Libav is free software; you can redistribute it and/or
10 ;* modify it under the terms of the GNU Lesser General Public
11 ;* License as published by the Free Software Foundation; either
12 ;* version 2.1 of the License, or (at your option) any later version.
13 ;*
14 ;* Libav is distributed in the hope that it will be useful,
15 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 ;* Lesser General Public License for more details.
18 ;*
19 ;* You should have received a copy of the GNU Lesser General Public
20 ;* License along with Libav; if not, write to the Free Software
21 ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 ;*****************************************************************************
23
24 %include "libavutil/x86/x86util.asm"
25
26 SECTION .text
27
28 INIT_MMX mmx
29 ; int ff_pix_sum16_mmx(uint8_t *pix, int line_size)
30 cglobal pix_sum16, 2, 3
31     movsxdifnidn r1, r1d
32     mov          r2, r1
33     neg          r2
34     shl          r2, 4
35     sub          r0, r2
36     pxor         m7, m7
37     pxor         m6, m6
38 .loop:
39     mova         m0, [r0+r2+0]
40     mova         m1, [r0+r2+0]
41     mova         m2, [r0+r2+8]
42     mova         m3, [r0+r2+8]
43     punpcklbw    m0, m7
44     punpckhbw    m1, m7
45     punpcklbw    m2, m7
46     punpckhbw    m3, m7
47     paddw        m1, m0
48     paddw        m3, m2
49     paddw        m3, m1
50     paddw        m6, m3
51     add          r2, r1
52     js .loop
53     mova         m5, m6
54     psrlq        m6, 32
55     paddw        m6, m5
56     mova         m5, m6
57     psrlq        m6, 16
58     paddw        m6, m5
59     movd        eax, m6
60     and         eax, 0xffff
61     RET
62
63 INIT_MMX mmx
64 ; int ff_pix_norm1_mmx(uint8_t *pix, int line_size)
65 cglobal pix_norm1, 2, 4
66     movsxdifnidn r1, r1d
67     mov          r2, 16
68     pxor         m0, m0
69     pxor         m7, m7
70 .loop:
71     mova         m2, [r0+0]
72     mova         m3, [r0+8]
73     mova         m1, m2
74     punpckhbw    m1, m0
75     punpcklbw    m2, m0
76     mova         m4, m3
77     punpckhbw    m3, m0
78     punpcklbw    m4, m0
79     pmaddwd      m1, m1
80     pmaddwd      m2, m2
81     pmaddwd      m3, m3
82     pmaddwd      m4, m4
83     paddd        m2, m1
84     paddd        m4, m3
85     paddd        m7, m2
86     add          r0, r1
87     paddd        m7, m4
88     dec r2
89     jne .loop
90     mova         m1, m7
91     psrlq        m7, 32
92     paddd        m1, m7
93     movd        eax, m1
94     RET
95