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.
138 lines
3.3 KiB
138 lines
3.3 KiB
11 years ago
|
;*****************************************************************************
|
||
|
;* SIMD-optimized MPEG encoding functions
|
||
|
;*****************************************************************************
|
||
|
;* Copyright (c) 2000, 2001 Fabrice Bellard
|
||
|
;* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
|
||
|
;*
|
||
11 years ago
|
;* This file is part of FFmpeg.
|
||
11 years ago
|
;*
|
||
11 years ago
|
;* FFmpeg is free software; you can redistribute it and/or
|
||
11 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.
|
||
|
;*
|
||
11 years ago
|
;* FFmpeg is distributed in the hope that it will be useful,
|
||
11 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
|
||
11 years ago
|
;* License along with FFmpeg; if not, write to the Free Software
|
||
11 years ago
|
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||
|
;*****************************************************************************
|
||
|
|
||
|
%include "libavutil/x86/x86util.asm"
|
||
|
|
||
11 years ago
|
SECTION_RODATA
|
||
11 years ago
|
|
||
11 years ago
|
cextern pw_1
|
||
|
|
||
|
SECTION .text
|
||
11 years ago
|
; int ff_pix_sum16_mmx(uint8_t *pix, int line_size)
|
||
11 years ago
|
; %1 = number of xmm registers used
|
||
|
; %2 = number of loops
|
||
|
; %3 = number of GPRs used
|
||
|
%macro PIX_SUM16 4
|
||
|
cglobal pix_sum16, 2, %3, %1
|
||
11 years ago
|
movsxdifnidn r1, r1d
|
||
11 years ago
|
mov r2, %2
|
||
|
%if cpuflag(xop)
|
||
|
lea r3, [r1*3]
|
||
|
%else
|
||
|
pxor m5, m5
|
||
|
%endif
|
||
|
pxor m4, m4
|
||
11 years ago
|
.loop:
|
||
11 years ago
|
%if cpuflag(xop)
|
||
|
vphaddubq m0, [r0]
|
||
|
vphaddubq m1, [r0+r1]
|
||
|
vphaddubq m2, [r0+r1*2]
|
||
|
vphaddubq m3, [r0+r3]
|
||
|
%else
|
||
|
mova m0, [r0]
|
||
|
%if mmsize == 8
|
||
|
mova m1, [r0+8]
|
||
|
%else
|
||
|
mova m1, [r0+r1]
|
||
|
%endif
|
||
|
punpckhbw m2, m0, m5
|
||
|
punpcklbw m0, m5
|
||
|
punpckhbw m3, m1, m5
|
||
|
punpcklbw m1, m5
|
||
|
%endif ; cpuflag(xop)
|
||
11 years ago
|
paddw m1, m0
|
||
|
paddw m3, m2
|
||
|
paddw m3, m1
|
||
11 years ago
|
paddw m4, m3
|
||
|
%if mmsize == 8
|
||
|
add r0, r1
|
||
|
%else
|
||
|
lea r0, [r0+r1*%4]
|
||
|
%endif
|
||
|
dec r2
|
||
|
jne .loop
|
||
|
%if cpuflag(xop)
|
||
|
pshufd m0, m4, q0032
|
||
|
paddd m4, m0
|
||
|
%else
|
||
|
HADDW m4, m5
|
||
|
%endif
|
||
|
movd eax, m4
|
||
11 years ago
|
RET
|
||
11 years ago
|
%endmacro
|
||
11 years ago
|
|
||
|
INIT_MMX mmx
|
||
11 years ago
|
PIX_SUM16 0, 16, 3, 0
|
||
|
INIT_XMM sse2
|
||
|
PIX_SUM16 6, 8, 3, 2
|
||
|
%if HAVE_XOP_EXTERNAL
|
||
|
INIT_XMM xop
|
||
|
PIX_SUM16 5, 4, 4, 4
|
||
|
%endif
|
||
|
|
||
11 years ago
|
; int ff_pix_norm1_mmx(uint8_t *pix, int line_size)
|
||
11 years ago
|
; %1 = number of xmm registers used
|
||
|
; %2 = number of loops
|
||
|
%macro PIX_NORM1 2
|
||
|
cglobal pix_norm1, 2, 3, %1
|
||
11 years ago
|
movsxdifnidn r1, r1d
|
||
11 years ago
|
mov r2, %2
|
||
11 years ago
|
pxor m0, m0
|
||
11 years ago
|
pxor m5, m5
|
||
11 years ago
|
.loop:
|
||
|
mova m2, [r0+0]
|
||
11 years ago
|
%if mmsize == 8
|
||
11 years ago
|
mova m3, [r0+8]
|
||
11 years ago
|
%else
|
||
|
mova m3, [r0+r1]
|
||
|
%endif
|
||
|
punpckhbw m1, m2, m0
|
||
11 years ago
|
punpcklbw m2, m0
|
||
11 years ago
|
punpckhbw m4, m3, m0
|
||
|
punpcklbw m3, m0
|
||
11 years ago
|
pmaddwd m1, m1
|
||
|
pmaddwd m2, m2
|
||
|
pmaddwd m3, m3
|
||
|
pmaddwd m4, m4
|
||
|
paddd m2, m1
|
||
|
paddd m4, m3
|
||
11 years ago
|
paddd m5, m2
|
||
|
paddd m5, m4
|
||
|
%if mmsize == 8
|
||
11 years ago
|
add r0, r1
|
||
11 years ago
|
%else
|
||
|
lea r0, [r0+r1*2]
|
||
|
%endif
|
||
11 years ago
|
dec r2
|
||
|
jne .loop
|
||
11 years ago
|
HADDD m5, m1
|
||
|
movd eax, m5
|
||
11 years ago
|
RET
|
||
11 years ago
|
%endmacro
|
||
|
|
||
|
INIT_MMX mmx
|
||
|
PIX_NORM1 0, 16
|
||
|
INIT_XMM sse2
|
||
|
PIX_NORM1 6, 8
|
||
11 years ago
|
|