[cvs] / xvidcore / src / image / x86_asm / colorspace_mmx.inc Repository:
ViewVC logotype

Diff of /xvidcore/src/image/x86_asm/colorspace_mmx.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.2.1, Sun Nov 3 04:51:33 2002 UTC revision 1.9, Wed Feb 18 15:10:19 2009 UTC
# Line 1  Line 1 
1    ;/*****************************************************************************
2    ; *
3    ; *  XVID MPEG-4 VIDEO CODEC
4    ; *  - colorspace conversions -
5    ; *
6    ; *  Copyright(C) 2002-2003 Peter Ross <pross@xvid.org>
7    ; *               2008      Michael Militzer <michael@xvid.org>
8    ; *
9    ; *  This program is free software ; you can redistribute it and/or modify
10    ; *  it under the terms of the GNU General Public License as published by
11    ; *  the Free Software Foundation ; either version 2 of the License, or
12    ; *  (at your option) any later version.
13    ; *
14    ; *  This program 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
17    ; *  GNU General Public License for more details.
18    ; *
19    ; *  You should have received a copy of the GNU General Public License
20    ; *  along with this program ; if not, write to the Free Software
21    ; *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22    ; *
23    ; ****************************************************************************/
24    
25  ;------------------------------------------------------------------------------  ;------------------------------------------------------------------------------
26  ;  ;
# Line 13  Line 36 
36  ; ARG1          argument passed to FUNC  ; ARG1          argument passed to FUNC
37  ;  ;
38  ; throughout the FUNC the registers mean:  ; throughout the FUNC the registers mean:
 ; eax           y_stride  
 ; ebx           u_ptr  
 ; ecx           v_ptr  
 ; edx           x_stride  
 ; esi           y_ptr  
 ; edi           x_ptr  
 ; ebp           width  
 ;  
39  ;------------------------------------------------------------------------------  ;------------------------------------------------------------------------------
40    
41    %define y_stride       _EAX
42    %define u_ptr          _EBX
43    %define v_ptr          _ECX
44    %define x_stride       _EDX
45    %define x_stride_d      edx
46    %define y_ptr          _ESI
47    %define x_ptr          _EDI
48    %define width          _EBP
49    
50  %macro          MAKE_COLORSPACE                 8  %macro          MAKE_COLORSPACE                 8
51  %define NAME            %1  %define NAME            %1
52  %define STACK           %2  %define STACK           %2
# Line 32  Line 57 
57  %define ARG1            %7  %define ARG1            %7
58  %define ARG2            %8  %define ARG2            %8
59          ; --- define function global/symbol          ; --- define function global/symbol
60  align 16  ALIGN SECTION_ALIGN
61  cglobal NAME  cglobal NAME
62  NAME  NAME:
63          ; --- init stack ---          ; --- init stack ---
64    
65  %define pushsize        16    push _EBX    ;   esp + localsize + 16
 %define localsize       20 + STACK  
66    
67  %define vflip               esp + localsize + pushsize + 40  %ifdef ARCH_IS_X86_64
 %define height              esp + localsize + pushsize + 36  
 %define width               esp + localsize + pushsize + 32  
 %define uv_stride               esp + localsize + pushsize + 28  
 %define y_stride                esp + localsize + pushsize + 24  
 %define v_ptr                   esp + localsize + pushsize + 20  
 %define u_ptr                   esp + localsize + pushsize + 16  
 %define y_ptr                   esp     + localsize + pushsize + 12  
 %define x_stride                esp + localsize + pushsize + 8  
 %define x_ptr               esp + localsize + pushsize + 4  
 %define _ip                             esp + localsize + pushsize + 0  
   
                 push ebx        ;       esp + localsize + 16  
                 push esi        ;       esp + localsize + 8  
                 push edi        ;       esp + localsize + 4  
                 push ebp        ;       esp + localsize + 0  
   
 %define x_dif                   esp + localsize - 4  
 %define y_dif                   esp + localsize - 8  
 %define uv_dif                  esp + localsize - 12  
 %define fixed_width             esp + localsize - 16  
 %define tmp_height              esp + localsize - 20  
68    
69                  sub esp, localsize  %define localsize       2*PTR_SIZE + STACK
70    %ifndef WINDOWS
71    %define pushsize        2*PTR_SIZE
72    %define shadow          0
73    %else
74    %define pushsize        4*PTR_SIZE
75    %define shadow          32 + 2*PTR_SIZE
76    %endif
77    
78    %define prm_vflip           dword [_ESP + localsize + pushsize + shadow + 4*PTR_SIZE]
79    %define prm_height          dword [_ESP + localsize + pushsize + shadow + 3*PTR_SIZE]
80    %define prm_width           dword [_ESP + localsize + pushsize + shadow + 2*PTR_SIZE]
81    %define prm_uv_stride       dword [_ESP + localsize + pushsize + shadow + 1*PTR_SIZE]
82    
83    %ifdef WINDOWS
84    %define prm_y_stride        dword [_ESP + localsize + pushsize + shadow + 0*PTR_SIZE]
85    %define prm_v_ptr           [_ESP + localsize + pushsize + shadow - 1*PTR_SIZE]
86    
87      push _ESI    ;   esp + localsize + 8
88      push _EDI    ;   esp + localsize + 4
89    
90    %else
91    %define prm_y_stride        prm6d
92    %define prm_v_ptr           prm5
93    %endif
94    
95    %define prm_u_ptr           prm4
96    %define prm_y_ptr           prm3
97    %define prm_x_stride        prm2d
98    %define prm_x_ptr           prm1
99    %define _ip                 _ESP + localsize + pushsize + 0
100    
101    %define x_dif               TMP0
102    
103    %else
104    
105    %define localsize       5*PTR_SIZE + STACK
106    %define pushsize        4*PTR_SIZE
107    
108    %define prm_vflip           [_ESP + localsize + pushsize + 10*PTR_SIZE]
109    %define prm_height          [_ESP + localsize + pushsize +  9*PTR_SIZE]
110    %define prm_width           [_ESP + localsize + pushsize +  8*PTR_SIZE]
111    %define prm_uv_stride       [_ESP + localsize + pushsize +  7*PTR_SIZE]
112    %define prm_y_stride        [_ESP + localsize + pushsize +  6*PTR_SIZE]
113    %define prm_v_ptr           [_ESP + localsize + pushsize +  5*PTR_SIZE]
114    %define prm_u_ptr           [_ESP + localsize + pushsize +  4*PTR_SIZE]
115    %define prm_y_ptr           [_ESP + localsize + pushsize +  3*PTR_SIZE]
116    %define prm_x_stride        [_ESP + localsize + pushsize +  2*PTR_SIZE]
117    %define prm_x_ptr           [_ESP + localsize + pushsize +  1*PTR_SIZE]
118    %define _ip                 _ESP + localsize + pushsize + 0
119    
120    %define x_dif               dword [_ESP + localsize -  5*4]
121    
122      push _ESI    ;   esp + localsize + 8
123      push _EDI    ;   esp + localsize + 4
124    
125    %endif
126    
127      push _EBP    ;   esp + localsize + 0
128    
129    %define y_dif           dword [_ESP + localsize -  1*4]
130    %define uv_dif          dword [_ESP + localsize -  2*4]
131    %define fixed_width     dword [_ESP + localsize -  3*4]
132    %define tmp_height      dword [_ESP + localsize -  4*4]
133    
134      sub _ESP, localsize
135    
136          ; --- init varibles ---          ; --- init varibles ---
137    
138                  mov eax, [width]                        ; fixed width    mov eax, prm_width         ; fixed width
139                  add eax, 15                                     ;                  add eax, 15                                     ;
140                  and eax, ~15                            ;                  and eax, ~15                            ;
141                  mov [fixed_width],eax                           ;    mov fixed_width, eax       ;
142    
143                  mov ebx, [x_stride]                     ;    mov ebx, prm_x_stride      ;
144  %rep BYTES  %rep BYTES
145                  sub ebx, eax                            ;    sub _EBX, _EAX             ;
146  %endrep  %endrep
147                  mov [x_dif], ebx                        ; x_dif = x_stride - BYTES*fixed_width    mov x_dif, _EBX            ; x_dif = x_stride - BYTES*fixed_width
148    
149                  mov ebx, [y_stride]                     ;    mov ebx, prm_y_stride      ;
150                  sub ebx, eax                            ;                  sub ebx, eax                            ;
151                  mov [y_dif], ebx                        ; y_dif = y_stride - fixed_width    mov y_dif, ebx             ; y_dif = y_stride - fixed_width
152    
153                  mov ebx, [uv_stride]            ;    mov ebx, prm_uv_stride     ;
154                  mov ecx, eax                            ;    mov TMP1, _EAX             ;
155                  shr ecx, 1                                      ;    shr TMP1, 1                ;
156                  sub ebx, ecx                            ;    sub _EBX, TMP1             ;
157                  mov [uv_dif], ebx                       ; uv_dif = uv_stride - fixed_width/2    mov uv_dif, ebx            ; uv_dif = uv_stride - fixed_width/2
158    
159                  mov esi, [y_ptr]                ; $esi$ = y_ptr  %ifdef ARCH_IS_X86_64
160                  mov edi, [x_ptr]                ; $edi$ = x_ptr  %ifndef WINDOWS
161                  mov edx, [x_stride]             ; $edx$ = x_stride    mov TMP1d, prm_x_stride
162                  mov ebp, [height]               ; $ebp$ = height    mov _ESI, prm_y_ptr
163      mov _EDX, TMP1
164    %else
165      mov _ESI, prm_y_ptr
166      mov _EDI, prm_x_ptr
167    %endif
168    %else
169      mov _ESI, prm_y_ptr        ; $esi$ = y_ptr
170      mov _EDI, prm_x_ptr        ; $edi$ = x_ptr
171      mov  edx, prm_x_stride     ; $edx$ = x_stride
172    %endif
173    
174      mov ebp, prm_height       ; $ebp$ = height
175    
176                  mov ebx, [vflip]    mov ebx, prm_vflip
177                  or ebx, ebx    or _EBX, _EBX
178                  jz .dont_flip                  jz .dont_flip
179    
180          ; --- do flipping ---          ; --- do flipping ---
181    
182                  xor ebx,ebx    xor _EBX,_EBX
183  %rep BYTES  %rep BYTES
184                  sub ebx, eax    sub _EBX, _EAX
185  %endrep  %endrep
186                  sub ebx, edx    sub _EBX, _EDX
187                  mov [x_dif], ebx                ; x_dif = -BYTES*fixed_width - x_stride    mov x_dif, _EBX            ; x_dif = -BYTES*fixed_width - x_stride
188    
189                  mov eax, ebp    lea _EAX, [_EBP-1]
190                  sub eax, 1  
191                  push edx  %ifdef ARCH_IS_X86_64
192      mov TMP1, _EDX
193      mul edx
194      mov _EDX, TMP1
195    %else
196      push _EDX
197                  mul edx                  mul edx
198                  pop edx    pop _EDX
199                  add edi, eax                    ; $edi$ += (height-1) * x_stride  %endif
200      add _EDI, _EAX             ; $edi$ += (height-1) * x_stride
201    
202                  neg edx                                 ; x_stride = -x_stride    neg _EDX                   ; x_stride = -x_stride
203    
204  .dont_flip  .dont_flip:
205    
206          ; --- begin loop ---          ; --- begin loop ---
207    
208                  mov eax, [y_stride]             ; $eax$ = y_stride    mov  eax, prm_y_stride     ; $eax$ = y_stride
209                  mov ebx, [u_ptr]                ; $ebx$ = u_ptr    mov _EBX, prm_u_ptr        ; $ebx$ = u_ptr
210                  mov ecx, [v_ptr]                ; $ecx$ = v_ptr    mov _ECX, prm_v_ptr        ; $ecx$ = v_ptr
211    
212                  FUNC %+ _INIT ARG1, ARG2                ; call FUNC_INIT                  FUNC %+ _INIT ARG1, ARG2                ; call FUNC_INIT
213    
214  .y_loop  .y_loop:
215                  mov [tmp_height], ebp    mov tmp_height, ebp
216                  mov ebp, [fixed_width]    mov ebp, fixed_width
217    
218  .x_loop  .x_loop:
219                  FUNC ARG1, ARG2                 ; call FUNC                  FUNC ARG1, ARG2                 ; call FUNC
220    
221                  add     edi, BYTES*PIXELS               ; x_ptr += BYTES*PIXELS    add _EDI, BYTES*PIXELS     ; x_ptr += BYTES*PIXELS
222                  add     esi, PIXELS                             ; y_ptr += PIXELS    add _ESI, PIXELS           ; y_ptr += PIXELS
223                  add     ebx, PIXELS/2                   ; u_ptr += PIXELS/2    add _EBX, PIXELS/2         ; u_ptr += PIXELS/2
224                  add     ecx, PIXELS/2                   ; v_ptr += PIXELS/2    add _ECX, PIXELS/2         ; v_ptr += PIXELS/2
225    
226                  sub ebp, PIXELS         ; $ebp$ -= PIXELS    sub _EBP, PIXELS           ; $ebp$ -= PIXELS
227                  jg      .x_loop                 ; if ($ebp$ > 0) goto .x_loop                  jg      .x_loop                 ; if ($ebp$ > 0) goto .x_loop
228    
229                  mov ebp, [tmp_height]    mov ebp, tmp_height
230                  add edi, [x_dif]                ; x_ptr += x_dif + (VPIXELS-1)*x_stride    add _EDI, x_dif            ; x_ptr += x_dif + (VPIXELS-1)*x_stride
231                  add esi, [y_dif]                ; y_ptr += y_dif + (VPIXELS-1)*y_stride  %ifdef ARCH_IS_X86_64
232      mov TMP1d, y_dif
233      add _ESI, TMP1             ; y_ptr += y_dif + (VPIXELS-1)*y_stride
234    %else
235      add _ESI, y_dif            ; y_ptr += y_dif + (VPIXELS-1)*y_stride
236    %endif
237    
238  %rep VPIXELS-1  %rep VPIXELS-1
239                  add edi, edx    add _EDI, _EDX
240                  add esi, eax    add _ESI, _EAX
241  %endrep  %endrep
242    
243                  add ebx, [uv_dif]               ; u_ptr += uv_dif + ((VPIXELS/2)-1)*uv_stride  %ifdef ARCH_IS_X86_64
244                  add ecx, [uv_dif]               ; v_ptr += uv_dif + ((VPIXELS/2)-1)*uv_stride    mov TMP1d, uv_dif
245      add _EBX, TMP1             ; u_ptr += uv_dif + ((VPIXELS/2)-1)*uv_stride
246      add _ECX, TMP1             ; v_ptr += uv_dif + ((VPIXELS/2)-1)*uv_stride
247    %else
248      add _EBX, uv_dif           ; u_ptr += uv_dif + ((VPIXELS/2)-1)*uv_stride
249      add _ECX, uv_dif           ; v_ptr += uv_dif + ((VPIXELS/2)-1)*uv_stride
250    %endif
251    
252  %rep (VPIXELS/2)-1  %rep (VPIXELS/2)-1
253                  add ebx, [uv_stride]  %ifdef ARCH_IS_X86_64
254                  add ecx, [uv_stride]    mov TMP1d, prm_uv_stride
255      add _EBX, TMP1
256      add _ECX, TMP1
257    %else
258      add _EBX, prm_uv_stride
259      add _ECX, prm_uv_stride
260    %endif
261  %endrep  %endrep
262    
263                  sub ebp, VPIXELS        ; $ebp$ -= VPIXELS    sub _EBP, VPIXELS          ; $ebp$ -= VPIXELS
264                  jg .y_loop                      ; if ($ebp$ > 0) goto .y_loop                  jg .y_loop                      ; if ($ebp$ > 0) goto .y_loop
265    
266          ; cleanup stack & undef everything          ; cleanup stack & undef everything
267    
268                  add esp, localsize    add _ESP, localsize
269                  pop ebp  
270                  pop edi    pop _EBP
271                  pop esi  %ifndef ARCH_IS_X86_64
272                  pop ebx    pop _EDI
273      pop _ESI
274  %undef vflip  %else
275  %undef height  %ifdef WINDOWS
276  %undef width    pop _EDI
277  %undef uv_stride    pop _ESI
278  %undef y_stride  %endif
279  %undef v_ptr  %endif
280  %undef u_ptr    pop _EBX
281  %undef y_ptr  
282  %undef x_stride  %undef prm_vflip
283  %undef x_ptr  %undef prm_height
284    %undef prm_width
285    %undef prm_uv_stride
286    %undef prm_y_stride
287    %undef prm_v_ptr
288    %undef prm_u_ptr
289    %undef prm_y_ptr
290    %undef prm_x_stride
291    %undef prm_x_ptr
292  %undef _ip  %undef _ip
293  %undef x_dif  %undef x_dif
294  %undef y_dif  %undef y_dif
# Line 184  Line 296 
296  %undef fixed_width  %undef fixed_width
297  %undef tmp_height  %undef tmp_height
298                  ret                  ret
299    ENDFUNC
300  %undef NAME  %undef NAME
301  %undef STACK  %undef STACK
302  %undef BYTES  %undef BYTES

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.9

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4