1 |
;/****************************************************************************** |
;/************************************************************************** |
2 |
; * * |
; * |
3 |
; * This file is part of XviD, a free MPEG-4 video encoder/decoder * |
; * XVID MPEG-4 VIDEO CODEC |
4 |
; * * |
; * - 3dne Quantization/Dequantization - |
5 |
; * XviD is an implementation of a part of one or more MPEG-4 Video tools * |
; * |
6 |
; * as specified in ISO/IEC 14496-2 standard. Those intending to use this * |
; * Copyright (C) 2002-2003 Peter Ross <pross@xvid.org> |
7 |
; * software module in hardware or software products are advised that its * |
; * 2002-2003 Michael Militzer <isibaar@xvid.org> |
8 |
; * use may infringe existing patents or copyrights, and any such use * |
; * 2002-2003 Pascal Massimino <skal@planet-d.net> |
9 |
; * would be at such party's own risk. The original developer of this * |
; * |
10 |
; * software module and his/her company, and subsequent editors and their * |
; * This program is free software ; you can redistribute it and/or modify |
11 |
; * companies, will have no liability for use of this software or * |
; * it under the terms of the GNU General Public License as published by |
12 |
; * modifications or derivatives thereof. * |
; * the Free Software Foundation ; either version 2 of the License, or |
13 |
; * * |
; * (at your option) any later version. |
14 |
; * XviD is free software; you can redistribute it and/or modify it * |
; * |
15 |
; * under the terms of the GNU General Public License as published by * |
; * This program is distributed in the hope that it will be useful, |
16 |
; * the Free Software Foundation; either version 2 of the License, or * |
; * but WITHOUT ANY WARRANTY ; without even the implied warranty of |
17 |
; * (at your option) any later version. * |
; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 |
; * * |
; * GNU General Public License for more details. |
19 |
; * XviD is distributed in the hope that it will be useful, but * |
; * |
20 |
; * WITHOUT ANY WARRANTY; without even the implied warranty of * |
; * You should have received a copy of the GNU General Public License |
21 |
; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
; * along with this program ; if not, write to the Free Software |
22 |
; * GNU General Public License for more details. * |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 |
; * * |
; * |
24 |
; * You should have received a copy of the GNU General Public License * |
; * $Id$ |
25 |
; * along with this program; if not, write to the Free Software * |
; * |
26 |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
; *************************************************************************/ |
|
; * * |
|
|
; ******************************************************************************/ |
|
|
; |
|
|
;/****************************************************************************** |
|
|
; * * |
|
|
; * quantize4.asm, MMX optimized MPEG quantization/dequantization * |
|
|
; * * |
|
|
; * Copyright (C) 2002 - Peter Ross <pross@cs.rmit.edu.au> * |
|
|
; * Copyright (C) 2002 - Michael Militzer <isibaar@xvid.org> * |
|
|
; * * |
|
|
; * For more information visit the XviD homepage: http://www.xvid.org * |
|
|
; * * |
|
|
; ******************************************************************************/ |
|
|
; |
|
|
;/****************************************************************************** |
|
|
; * * |
|
|
; * Revision history: * |
|
|
; * * |
|
|
; * 14.06.2002 mmx dequant4_* funcs revamped -Skal- * |
|
|
; * 22.01.2002 initial version * |
|
|
; * * |
|
|
; ******************************************************************************/ |
|
27 |
|
|
28 |
; data/text alignment |
; data/text alignment |
29 |
%define ALIGN 8 |
%define ALIGN 8 |
32 |
|
|
33 |
bits 32 |
bits 32 |
34 |
|
|
|
%ifdef FORMAT_COFF |
|
|
SECTION .data data |
|
|
%else |
|
|
SECTION .data data align=8 |
|
|
%endif |
|
|
|
|
|
|
|
35 |
%macro cglobal 1 |
%macro cglobal 1 |
36 |
%ifdef PREFIX |
%ifdef PREFIX |
37 |
global _%1 |
global _%1 |
50 |
%endif |
%endif |
51 |
%endmacro |
%endmacro |
52 |
|
|
53 |
mmx_one times 4 dw 1 |
;*************************************************************************** |
54 |
|
; Local data |
55 |
|
;*************************************************************************** |
56 |
|
|
57 |
|
%ifdef FORMAT_COFF |
58 |
|
SECTION .data data |
59 |
|
%else |
60 |
|
SECTION .data data align=8 |
61 |
|
%endif |
62 |
|
|
63 |
|
mmx_one: |
64 |
|
times 4 dw 1 |
65 |
|
|
66 |
;=========================================================================== |
;=========================================================================== |
67 |
; |
; |
69 |
; |
; |
70 |
;=========================================================================== |
;=========================================================================== |
71 |
|
|
72 |
%macro MMX_DIV 1 |
align 16 |
73 |
times 4 dw (1 << 17) / (%1 * 2) + 1 |
mmx_div: |
74 |
%endmacro |
%assign quant 1 |
75 |
|
%rep 31 |
76 |
align ALIGN |
times 4 dw (1<<17) / (quant*2) + 1 |
77 |
mmx_div |
%assign quant quant+1 |
78 |
MMX_DIV 1 |
%endrep |
|
MMX_DIV 2 |
|
|
MMX_DIV 3 |
|
|
MMX_DIV 4 |
|
|
MMX_DIV 5 |
|
|
MMX_DIV 6 |
|
|
MMX_DIV 7 |
|
|
MMX_DIV 8 |
|
|
MMX_DIV 9 |
|
|
MMX_DIV 10 |
|
|
MMX_DIV 11 |
|
|
MMX_DIV 12 |
|
|
MMX_DIV 13 |
|
|
MMX_DIV 14 |
|
|
MMX_DIV 15 |
|
|
MMX_DIV 16 |
|
|
MMX_DIV 17 |
|
|
MMX_DIV 18 |
|
|
MMX_DIV 19 |
|
|
MMX_DIV 20 |
|
|
MMX_DIV 21 |
|
|
MMX_DIV 22 |
|
|
MMX_DIV 23 |
|
|
MMX_DIV 24 |
|
|
MMX_DIV 25 |
|
|
MMX_DIV 26 |
|
|
MMX_DIV 27 |
|
|
MMX_DIV 28 |
|
|
MMX_DIV 29 |
|
|
MMX_DIV 30 |
|
|
MMX_DIV 31 |
|
|
|
|
79 |
|
|
80 |
;=========================================================================== |
;=========================================================================== |
81 |
; |
; |
106 |
; |
; |
107 |
;=========================================================================== |
;=========================================================================== |
108 |
|
|
109 |
%macro MMX_QUANTD 1 |
quantd: |
110 |
times 4 dw ((VM18P*%1) + (VM18Q/2)) / VM18Q |
%assign quant 1 |
111 |
%endmacro |
%rep 31 |
112 |
|
times 4 dw ((VM18P*quant) + (VM18Q/2)) / VM18Q |
113 |
quantd |
%assign quant quant+1 |
114 |
MMX_QUANTD 1 |
%endrep |
|
MMX_QUANTD 2 |
|
|
MMX_QUANTD 3 |
|
|
MMX_QUANTD 4 |
|
|
MMX_QUANTD 5 |
|
|
MMX_QUANTD 6 |
|
|
MMX_QUANTD 7 |
|
|
MMX_QUANTD 8 |
|
|
MMX_QUANTD 9 |
|
|
MMX_QUANTD 10 |
|
|
MMX_QUANTD 11 |
|
|
MMX_QUANTD 12 |
|
|
MMX_QUANTD 13 |
|
|
MMX_QUANTD 14 |
|
|
MMX_QUANTD 15 |
|
|
MMX_QUANTD 16 |
|
|
MMX_QUANTD 17 |
|
|
MMX_QUANTD 18 |
|
|
MMX_QUANTD 19 |
|
|
MMX_QUANTD 20 |
|
|
MMX_QUANTD 21 |
|
|
MMX_QUANTD 22 |
|
|
MMX_QUANTD 23 |
|
|
MMX_QUANTD 24 |
|
|
MMX_QUANTD 25 |
|
|
MMX_QUANTD 26 |
|
|
MMX_QUANTD 27 |
|
|
MMX_QUANTD 28 |
|
|
MMX_QUANTD 29 |
|
|
MMX_QUANTD 30 |
|
|
MMX_QUANTD 31 |
|
|
|
|
115 |
|
|
116 |
;=========================================================================== |
;=========================================================================== |
117 |
; |
; |
119 |
; |
; |
120 |
;=========================================================================== |
;=========================================================================== |
121 |
|
|
122 |
%macro MMX_MUL_QUANT 1 |
mmx_mul_quant: |
123 |
times 4 dw %1 |
%assign quant 1 |
124 |
%endmacro |
%rep 31 |
125 |
|
times 4 dw quant |
126 |
mmx_mul_quant |
%assign quant quant+1 |
127 |
MMX_MUL_QUANT 1 |
%endrep |
|
MMX_MUL_QUANT 2 |
|
|
MMX_MUL_QUANT 3 |
|
|
MMX_MUL_QUANT 4 |
|
|
MMX_MUL_QUANT 5 |
|
|
MMX_MUL_QUANT 6 |
|
|
MMX_MUL_QUANT 7 |
|
|
MMX_MUL_QUANT 8 |
|
|
MMX_MUL_QUANT 9 |
|
|
MMX_MUL_QUANT 10 |
|
|
MMX_MUL_QUANT 11 |
|
|
MMX_MUL_QUANT 12 |
|
|
MMX_MUL_QUANT 13 |
|
|
MMX_MUL_QUANT 14 |
|
|
MMX_MUL_QUANT 15 |
|
|
MMX_MUL_QUANT 16 |
|
|
MMX_MUL_QUANT 17 |
|
|
MMX_MUL_QUANT 18 |
|
|
MMX_MUL_QUANT 19 |
|
|
MMX_MUL_QUANT 20 |
|
|
MMX_MUL_QUANT 21 |
|
|
MMX_MUL_QUANT 22 |
|
|
MMX_MUL_QUANT 23 |
|
|
MMX_MUL_QUANT 24 |
|
|
MMX_MUL_QUANT 25 |
|
|
MMX_MUL_QUANT 26 |
|
|
MMX_MUL_QUANT 27 |
|
|
MMX_MUL_QUANT 28 |
|
|
MMX_MUL_QUANT 29 |
|
|
MMX_MUL_QUANT 30 |
|
|
MMX_MUL_QUANT 31 |
|
128 |
|
|
129 |
;=========================================================================== |
;=========================================================================== |
130 |
; |
; |
134 |
|
|
135 |
align 16 |
align 16 |
136 |
|
|
137 |
mmx_32767_minus_2047 times 4 dw (32767-2047) |
mmx_32767_minus_2047: |
138 |
mmx_32768_minus_2048 times 4 dw (32768-2048) |
times 4 dw (32767-2047) |
139 |
mmx_2047 times 4 dw 2047 |
mmx_32768_minus_2048: |
140 |
mmx_minus_2048 times 4 dw (-2048) |
times 4 dw (32768-2048) |
141 |
zero times 4 dw 0 |
mmx_2047: |
142 |
|
times 4 dw 2047 |
143 |
|
mmx_minus_2048: |
144 |
|
times 4 dw (-2048) |
145 |
|
zero: |
146 |
|
times 4 dw 0 |
147 |
|
|
148 |
|
;*************************************************************************** |
149 |
|
; Local data |
150 |
|
;*************************************************************************** |
151 |
|
|
152 |
section .text |
section .text |
153 |
|
|
154 |
;=========================================================================== |
;=========================================================================== |
155 |
; |
; |
156 |
; void quant_intra4_mmx(int16_t * coeff, |
; uint32_t quant_mpeg_intra_mmx(int16_t * coeff, |
157 |
; const int16_t const * data, |
; const int16_t const * data, |
158 |
; const uint32_t quant, |
; const uint32_t quant, |
159 |
; const uint32_t dcscalar); |
; const uint32_t dcscalar); |
218 |
|
|
219 |
paddw mm0, mm5 ; + quantd |
paddw mm0, mm5 ; + quantd |
220 |
paddw mm3, mm5 |
paddw mm3, mm5 |
|
|
|
221 |
pmulhw mm0, mm7 ; mm0 = (mm0 / 2Q) >> 16 |
pmulhw mm0, mm7 ; mm0 = (mm0 / 2Q) >> 16 |
222 |
pmulhw mm3, mm7 ; |
pmulhw mm3, mm7 ; |
223 |
psrlw mm0, 1 ; additional shift by 1 => 16 + 1 = 17 |
psrlw mm0, 1 ; additional shift by 1 => 16 + 1 = 17 |
259 |
pop esi |
pop esi |
260 |
pop ecx |
pop ecx |
261 |
|
|
262 |
|
xor eax, eax ; return(0); |
263 |
ret |
ret |
264 |
|
|
265 |
align ALIGN |
align ALIGN |
370 |
|
|
371 |
;=========================================================================== |
;=========================================================================== |
372 |
; |
; |
373 |
; uint32_t quant4_inter_mmx(int16_t * coeff, |
; uint32_t quant_mpeg_inter_mmx(int16_t * coeff, |
374 |
; const int16_t const * data, |
; const int16_t const * data, |
375 |
; const uint32_t quant); |
; const uint32_t quant); |
376 |
; |
; |
569 |
|
|
570 |
;=========================================================================== |
;=========================================================================== |
571 |
; |
; |
572 |
; void dequant4_intra_mmx(int16_t *data, |
; uint32_t dequant_mpeg_intra_mmx(int16_t *data, |
573 |
; const int16_t const *coeff, |
; const int16_t const *coeff, |
574 |
; const uint32_t quant, |
; const uint32_t quant, |
575 |
; const uint32_t dcscalar); |
; const uint32_t dcscalar); |
697 |
movd eax, mm0 |
movd eax, mm0 |
698 |
mov [edx], ax |
mov [edx], ax |
699 |
|
|
700 |
|
xor eax, eax |
701 |
ret |
ret |
702 |
|
|
703 |
;=========================================================================== |
;=========================================================================== |
704 |
; |
; |
705 |
; void dequant4_inter_mmx(int16_t * data, |
; uint32_t dequant_mpeg_inter_mmx(int16_t * data, |
706 |
; const int16_t * const coeff, |
; const int16_t * const coeff, |
707 |
; const uint32_t quant); |
; const uint32_t quant); |
708 |
; |
; |
803 |
xor eax, 1 |
xor eax, 1 |
804 |
xor word [edx + 2*63], ax |
xor word [edx + 2*63], ax |
805 |
|
|
806 |
|
xor eax, eax |
807 |
ret |
ret |
|
|
|