2008-08-14 07:00:25 +02:00
|
|
|
;******************************************************************************
|
2014-02-13 17:57:05 +01:00
|
|
|
;* optimized bswap buffer functions
|
2008-08-14 07:00:25 +02:00
|
|
|
;* Copyright (c) 2008 Loren Merritt
|
2013-02-07 15:00:29 +01:00
|
|
|
;* Copyright (c) 2003-2013 Michael Niedermayer
|
|
|
|
;* Copyright (c) 2013 Daniel Kang
|
2008-08-14 07:00:25 +02:00
|
|
|
;*
|
|
|
|
;* This file is part of FFmpeg.
|
|
|
|
;*
|
|
|
|
;* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
;* 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.
|
|
|
|
;*
|
|
|
|
;* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
;* 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
|
|
|
|
;* License along with FFmpeg; if not, write to the Free Software
|
2011-05-14 21:32:31 +02:00
|
|
|
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2008-08-14 07:00:25 +02:00
|
|
|
;******************************************************************************
|
|
|
|
|
2012-10-31 13:30:03 +01:00
|
|
|
%include "libavutil/x86/x86util.asm"
|
2008-08-14 07:00:25 +02:00
|
|
|
|
2009-10-18 22:10:10 +02:00
|
|
|
SECTION_RODATA
|
2012-01-19 21:48:39 +01:00
|
|
|
pb_bswap32: db 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12
|
2009-10-18 22:10:10 +02:00
|
|
|
|
2014-05-21 23:02:39 +02:00
|
|
|
cextern pb_80
|
|
|
|
|
2011-05-20 17:33:38 +02:00
|
|
|
SECTION_TEXT
|
2008-08-14 07:00:25 +02:00
|
|
|
|
2012-01-19 21:48:39 +01:00
|
|
|
; %1 = aligned/unaligned
|
2012-07-15 15:45:11 +02:00
|
|
|
%macro BSWAP_LOOPS 1
|
2015-07-16 00:10:27 +02:00
|
|
|
mov r3d, r2d
|
|
|
|
sar r2d, 3
|
2012-01-19 21:48:39 +01:00
|
|
|
jz .left4_%1
|
|
|
|
.loop8_%1:
|
|
|
|
mov%1 m0, [r1 + 0]
|
|
|
|
mov%1 m1, [r1 + 16]
|
2012-07-15 15:45:11 +02:00
|
|
|
%if cpuflag(ssse3)
|
|
|
|
pshufb m0, m2
|
|
|
|
pshufb m1, m2
|
2013-03-24 19:44:23 +01:00
|
|
|
mov%1 [r0 + 0], m0
|
|
|
|
mov%1 [r0 + 16], m1
|
2012-07-15 15:45:11 +02:00
|
|
|
%else
|
2012-01-19 21:48:39 +01:00
|
|
|
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
|
2013-03-24 19:44:23 +01:00
|
|
|
mov%1 [r0 + 0], m2
|
|
|
|
mov%1 [r0 + 16], m3
|
2012-07-15 15:45:11 +02:00
|
|
|
%endif
|
2012-01-19 21:48:39 +01:00
|
|
|
add r0, 32
|
2012-07-15 15:45:11 +02:00
|
|
|
add r1, 32
|
2015-07-16 00:10:27 +02:00
|
|
|
dec r2d
|
2012-01-19 21:48:39 +01:00
|
|
|
jnz .loop8_%1
|
|
|
|
.left4_%1:
|
2015-07-16 00:10:27 +02:00
|
|
|
mov r2d, r3d
|
|
|
|
test r3d, 4
|
2012-01-19 21:48:39 +01:00
|
|
|
jz .left
|
|
|
|
mov%1 m0, [r1]
|
2012-07-15 15:45:11 +02:00
|
|
|
%if cpuflag(ssse3)
|
|
|
|
pshufb m0, m2
|
2013-03-24 19:44:23 +01:00
|
|
|
mov%1 [r0], m0
|
2012-07-15 15:45:11 +02:00
|
|
|
%else
|
2012-01-19 21:48:39 +01:00
|
|
|
pshuflw m0, m0, 10110001b
|
|
|
|
pshufhw m0, m0, 10110001b
|
|
|
|
mova m2, m0
|
|
|
|
psllw m0, 8
|
|
|
|
psrlw m2, 8
|
|
|
|
por m2, m0
|
2013-03-24 19:44:23 +01:00
|
|
|
mov%1 [r0], m2
|
2012-07-15 15:45:11 +02:00
|
|
|
%endif
|
2012-01-19 21:48:39 +01:00
|
|
|
add r1, 16
|
|
|
|
add r0, 16
|
|
|
|
%endmacro
|
|
|
|
|
2014-01-28 20:35:58 +01:00
|
|
|
; void ff_bswap_buf(uint32_t *dst, const uint32_t *src, int w);
|
2012-07-15 15:45:11 +02:00
|
|
|
%macro BSWAP32_BUF 0
|
|
|
|
%if cpuflag(ssse3)
|
|
|
|
cglobal bswap32_buf, 3,4,3
|
|
|
|
mov r3, r1
|
|
|
|
mova m2, [pb_bswap32]
|
|
|
|
%else
|
2012-01-19 21:48:39 +01:00
|
|
|
cglobal bswap32_buf, 3,4,5
|
|
|
|
mov r3, r1
|
2012-07-15 15:45:11 +02:00
|
|
|
%endif
|
2013-03-26 13:02:37 +01:00
|
|
|
or r3, r0
|
2015-07-17 23:20:14 +02:00
|
|
|
test r3, 15
|
2012-01-19 21:48:39 +01:00
|
|
|
jz .start_align
|
2012-07-15 15:45:11 +02:00
|
|
|
BSWAP_LOOPS u
|
2012-01-19 21:48:39 +01:00
|
|
|
jmp .left
|
|
|
|
.start_align:
|
2012-07-15 15:45:11 +02:00
|
|
|
BSWAP_LOOPS a
|
2012-01-19 21:48:39 +01:00
|
|
|
.left:
|
2012-07-15 15:45:11 +02:00
|
|
|
%if cpuflag(ssse3)
|
2015-07-16 00:10:27 +02:00
|
|
|
test r2d, 2
|
2012-01-19 21:48:39 +01:00
|
|
|
jz .left1
|
|
|
|
movq m0, [r1]
|
|
|
|
pshufb m0, m2
|
|
|
|
movq [r0], m0
|
|
|
|
add r1, 8
|
|
|
|
add r0, 8
|
|
|
|
.left1:
|
2015-07-16 00:10:27 +02:00
|
|
|
test r2d, 1
|
2012-01-19 21:48:39 +01:00
|
|
|
jz .end
|
|
|
|
mov r2d, [r1]
|
|
|
|
bswap r2d
|
|
|
|
mov [r0], r2d
|
2012-07-15 15:45:11 +02:00
|
|
|
%else
|
2015-07-16 00:10:27 +02:00
|
|
|
and r2d, 3
|
2012-07-15 15:45:11 +02:00
|
|
|
jz .end
|
|
|
|
.loop2:
|
|
|
|
mov r3d, [r1]
|
|
|
|
bswap r3d
|
|
|
|
mov [r0], r3d
|
|
|
|
add r1, 4
|
|
|
|
add r0, 4
|
2015-07-16 00:10:27 +02:00
|
|
|
dec r2d
|
2012-07-15 15:45:11 +02:00
|
|
|
jnz .loop2
|
|
|
|
%endif
|
2012-01-19 21:48:39 +01:00
|
|
|
.end:
|
|
|
|
RET
|
2012-07-15 15:45:11 +02:00
|
|
|
%endmacro
|
|
|
|
|
|
|
|
INIT_XMM sse2
|
|
|
|
BSWAP32_BUF
|
2012-01-31 01:14:58 +01:00
|
|
|
|
2012-07-15 15:45:11 +02:00
|
|
|
INIT_XMM ssse3
|
|
|
|
BSWAP32_BUF
|