mirror of https://github.com/FFmpeg/FFmpeg.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
136 lines
3.1 KiB
136 lines
3.1 KiB
16 years ago
|
;******************************************************************************
|
||
11 years ago
|
;* optimized bswap buffer functions
|
||
16 years ago
|
;* Copyright (c) 2008 Loren Merritt
|
||
|
;*
|
||
14 years ago
|
;* This file is part of Libav.
|
||
16 years ago
|
;*
|
||
14 years ago
|
;* Libav is free software; you can redistribute it and/or
|
||
16 years ago
|
;* modify it under the terms of the GNU Lesser General Public
|
||
|
;* License as published by the Free Software Foundation; either
|
||
|
;* version 2.1 of the License, or (at your option) any later version.
|
||
|
;*
|
||
14 years ago
|
;* Libav is distributed in the hope that it will be useful,
|
||
16 years ago
|
;* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
;* Lesser General Public License for more details.
|
||
|
;*
|
||
|
;* You should have received a copy of the GNU Lesser General Public
|
||
14 years ago
|
;* License along with Libav; if not, write to the Free Software
|
||
14 years ago
|
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||
16 years ago
|
;******************************************************************************
|
||
|
|
||
13 years ago
|
%include "libavutil/x86/x86util.asm"
|
||
16 years ago
|
|
||
15 years ago
|
SECTION_RODATA
|
||
13 years ago
|
pb_bswap32: db 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12
|
||
15 years ago
|
|
||
14 years ago
|
SECTION_TEXT
|
||
16 years ago
|
|
||
13 years ago
|
; %1 = aligned/unaligned
|
||
13 years ago
|
%macro BSWAP_LOOPS 1
|
||
13 years ago
|
mov r3, r2
|
||
|
sar r2, 3
|
||
|
jz .left4_%1
|
||
|
.loop8_%1:
|
||
|
mov%1 m0, [r1 + 0]
|
||
|
mov%1 m1, [r1 + 16]
|
||
13 years ago
|
%if cpuflag(ssse3)
|
||
|
pshufb m0, m2
|
||
|
pshufb m1, m2
|
||
12 years ago
|
mov%1 [r0 + 0], m0
|
||
|
mov%1 [r0 + 16], m1
|
||
13 years ago
|
%else
|
||
13 years ago
|
pshuflw m0, m0, 10110001b
|
||
|
pshuflw m1, m1, 10110001b
|
||
|
pshufhw m0, m0, 10110001b
|
||
|
pshufhw m1, m1, 10110001b
|
||
|
mova m2, m0
|
||
|
mova m3, m1
|
||
|
psllw m0, 8
|
||
|
psllw m1, 8
|
||
|
psrlw m2, 8
|
||
|
psrlw m3, 8
|
||
|
por m2, m0
|
||
|
por m3, m1
|
||
12 years ago
|
mov%1 [r0 + 0], m2
|
||
|
mov%1 [r0 + 16], m3
|
||
13 years ago
|
%endif
|
||
13 years ago
|
add r0, 32
|
||
13 years ago
|
add r1, 32
|
||
13 years ago
|
dec r2
|
||
|
jnz .loop8_%1
|
||
|
.left4_%1:
|
||
|
mov r2, r3
|
||
|
and r3, 4
|
||
|
jz .left
|
||
|
mov%1 m0, [r1]
|
||
13 years ago
|
%if cpuflag(ssse3)
|
||
|
pshufb m0, m2
|
||
12 years ago
|
mov%1 [r0], m0
|
||
13 years ago
|
%else
|
||
13 years ago
|
pshuflw m0, m0, 10110001b
|
||
|
pshufhw m0, m0, 10110001b
|
||
|
mova m2, m0
|
||
|
psllw m0, 8
|
||
|
psrlw m2, 8
|
||
|
por m2, m0
|
||
12 years ago
|
mov%1 [r0], m2
|
||
13 years ago
|
%endif
|
||
13 years ago
|
add r1, 16
|
||
|
add r0, 16
|
||
|
%endmacro
|
||
|
|
||
11 years ago
|
; void ff_bswap_buf(uint32_t *dst, const uint32_t *src, int w);
|
||
13 years ago
|
%macro BSWAP32_BUF 0
|
||
|
%if cpuflag(ssse3)
|
||
|
cglobal bswap32_buf, 3,4,3
|
||
|
mov r3, r1
|
||
|
mova m2, [pb_bswap32]
|
||
|
%else
|
||
13 years ago
|
cglobal bswap32_buf, 3,4,5
|
||
|
mov r3, r1
|
||
13 years ago
|
%endif
|
||
13 years ago
|
and r3, 15
|
||
|
jz .start_align
|
||
13 years ago
|
BSWAP_LOOPS u
|
||
13 years ago
|
jmp .left
|
||
|
.start_align:
|
||
13 years ago
|
BSWAP_LOOPS a
|
||
13 years ago
|
.left:
|
||
13 years ago
|
%if cpuflag(ssse3)
|
||
13 years ago
|
mov r3, r2
|
||
|
and r2, 2
|
||
|
jz .left1
|
||
|
movq m0, [r1]
|
||
|
pshufb m0, m2
|
||
|
movq [r0], m0
|
||
|
add r1, 8
|
||
|
add r0, 8
|
||
|
.left1:
|
||
|
and r3, 1
|
||
|
jz .end
|
||
|
mov r2d, [r1]
|
||
|
bswap r2d
|
||
|
mov [r0], r2d
|
||
13 years ago
|
%else
|
||
|
and r2, 3
|
||
|
jz .end
|
||
|
.loop2:
|
||
|
mov r3d, [r1]
|
||
|
bswap r3d
|
||
|
mov [r0], r3d
|
||
|
add r1, 4
|
||
|
add r0, 4
|
||
|
dec r2
|
||
|
jnz .loop2
|
||
|
%endif
|
||
13 years ago
|
.end:
|
||
|
RET
|
||
13 years ago
|
%endmacro
|
||
|
|
||
|
INIT_XMM sse2
|
||
|
BSWAP32_BUF
|
||
|
|
||
|
INIT_XMM ssse3
|
||
|
BSWAP32_BUF
|