[FFmpeg-devel] [PATCH 1/2] swresample: Refactor resample asm and port it to yasm

Michael Niedermayer michaelni at gmx.at
Thu Mar 20 01:08:40 CET 2014


On Wed, Mar 19, 2014 at 06:45:03PM -0300, James Almer wrote:
> This reduces code duplication and makes it easier to implement new asm 
> functions in the future
> 
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
>  libswresample/resample.c            | 96 ++++++++++---------------------------
>  libswresample/resample_template.c   | 49 +++++++------------
>  libswresample/swresample_internal.h | 24 ++++++++++
>  libswresample/x86/Makefile          |  1 +
>  libswresample/x86/resample.asm      | 64 +++++++++++++++++++++++++
>  libswresample/x86/resample_mmx.h    | 74 ----------------------------
>  libswresample/x86/swresample_x86.c  | 16 +++++++
>  7 files changed, 148 insertions(+), 176 deletions(-)
>  create mode 100644 libswresample/x86/resample.asm
>  delete mode 100644 libswresample/x86/resample_mmx.h

benchmark:

before: 253482 decicycles in resample, 1024 runs, 0 skips
after   356545 decicycles in resample, 1024 runs, 0 skips

tested using ffplay HAYLEY\ WESTENRA-WHISPERS\ IN\ A\ DREAM.webm -af aformat=s32,aresample=48000,aformat=s32


[...]
> +%macro RESAMPLE_SCALARPRODUCT_INT16 0
> +cglobal resample_scalarproduct_int16, 4,4,2, src, dst, filter, len
> +    shl      lenq, 1
> +    neg      lenq
> +    sub      srcq, lenq
> +    sub      filterq, lenq
> +    mova     m0, [round]
> +.loop
> +    movu     m1, [srcq + lenq]
> +    pmaddwd  m1, [filterq + lenq]
> +    paddd    m0, m1
> +    add      lenq, mmsize
> +    js .loop
> +%if mmsize == 8
> +    pshufw   m1, m0, 0xe
> +    paddd    m0, m1
> +%else
> +    pshufd   m1, m0, 0xe
> +    paddd    m0, m1
> +    pshufd   m1, m0, 1
> +    paddd    m0, m1
> +%endif
> +    psrad    m0, 15
> +    packssdw m0, m0
> +    movd     [dstq], m0

> +%if mmsize == 8
> +    emms
> +%endif

this is not ok
emms is slow and does not belong in the inner loop


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140320/d298e6de/attachment.asc>


More information about the ffmpeg-devel mailing list