re/open mixer window fixes
[goodguy/cinelerra.git] / cinelerra-5.1 / mpeg2enc / predict_mmx.s
1 ;
2 ;  predict.s:  mmX optimized block summing differencing routines
3 ;
4 ;  Believed to be original Copyright (C) 2000 Brent Byeler
5 ;
6 ;  This program is free software; you can reaxstribute it and/or
7 ;  modify it under the terms of the GNU General Public License
8 ;  as published by the Free Software Foundation; either version 2
9 ;  of the License, or (at your option) any later version.
10 ;
11 ;  This program is distributed in the hope that it will be useful,
12 ;  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ;  GNU General Public License for more details.
15 ;
16 ;  You should have received a copy of the GNU General Public License
17 ;  along with this program; if not, write to the Free Software
18 ;  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 ;
20 ;
21 ;
22
23
24 ;void sub_pred_mmx(unsigned char *pred,
25 ;                  unsigned char *cur,
26 ;                  int lx, short *blk)
27
28 SECTION .text
29 align 32
30 global sub_pred_mmx
31 sub_pred_mmx:
32
33                 push ebp                                ; save frame pointer
34                 mov ebp, esp            ; link
35                 push eax
36                 push ebx
37                 push ecx
38                 push esi     
39                 push edi
40
41         mov   eax, [ebp+12] ;cur
42         mov   ebx, [ebp+8]  ;pred
43         mov   ecx, [ebp+20] ;blk
44         mov   edi, [ebp+16] ;lx
45         mov   esi, 8
46         pxor  mm7, mm7
47 sub_top:
48         movq  mm0, [eax]
49         add   eax, edi
50         movq  mm2, [ebx]
51         add   ebx, edi
52         movq  mm1, mm0
53         punpcklbw mm0, mm7
54         punpckhbw mm1, mm7
55         movq  mm3, mm2
56         punpcklbw mm2, mm7
57         punpckhbw mm3, mm7
58
59         psubw  mm0, mm2
60         psubw  mm1, mm3
61
62         movq   [ecx], mm0
63         movq   [ecx+8], mm1
64         add    ecx, 16
65
66         dec    esi
67         jg     sub_top
68         
69                 pop edi
70                 pop esi
71                 pop ecx
72                 pop ebx
73                 pop eax
74                 pop ebp                 ; restore stack pointer
75
76                 emms                    ; clear mmx registers
77                 ret             
78
79 ; add prediction and prediction error, saturate to 0...255
80 ;void add_pred_mmx(unsigned char *pred,
81 ;                  unsigned char *cur,
82 ;                  int lx, short *blk)
83
84 align 32
85 global add_pred_mmx
86 add_pred_mmx:
87
88                 push ebp                                ; save frame pointer
89                 mov ebp, esp            ; link
90                 push eax
91                 push ebx
92                 push ecx
93                 push esi     
94                 push edi
95         
96         mov   eax, [ebp+12] ;cur
97         mov   ebx, [ebp+8]  ;pred
98         mov   ecx, [ebp+20] ;blk
99         mov   edi, [ebp+16] ;lx
100         mov   esi, 8
101         pxor  mm7, mm7
102 add_top:
103         movq  mm0, [ecx]
104         movq  mm1, [ecx+8]
105         add   ecx, 16
106         movq  mm2, [ebx]
107         add   ebx, edi
108         movq  mm3, mm2
109         punpcklbw mm2, mm7
110         punpckhbw mm3, mm7
111
112         paddw  mm0, mm2
113         paddw  mm1, mm3
114         packuswb mm0, mm1
115
116         movq   [eax], mm0
117         add    eax, edi
118
119         dec    esi
120         jg     add_top
121         
122                 pop edi
123                 pop esi
124                 pop ecx
125                 pop ebx
126                 pop eax
127                 pop ebp                 ; restore stack pointer
128
129                 emms                    ; clear mmx registers
130                 ret             
131
132