mirror of https://github.com/FFmpeg/FFmpeg.git
parent
02b6d1dd63
commit
dcae5ba322
5 changed files with 185 additions and 10 deletions
@ -0,0 +1,40 @@ |
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019 Paul B Mahol |
||||||
|
* |
||||||
|
* 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 |
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef AVFILTER_ANLMDNDSP_H |
||||||
|
#define AVFILTER_ANLMDNDSP_H |
||||||
|
|
||||||
|
#include "libavutil/common.h" |
||||||
|
|
||||||
|
#include "audio.h" |
||||||
|
#include "avfilter.h" |
||||||
|
#include "formats.h" |
||||||
|
#include "internal.h" |
||||||
|
|
||||||
|
typedef struct AudioNLMDNDSPContext { |
||||||
|
float (*compute_distance_ssd)(const float *f1, const float *f2, ptrdiff_t K); |
||||||
|
void (*compute_cache)(float *cache, const float *f, ptrdiff_t S, ptrdiff_t K, |
||||||
|
ptrdiff_t i, ptrdiff_t jj); |
||||||
|
} AudioNLMDNDSPContext; |
||||||
|
|
||||||
|
void ff_anlmdn_init(AudioNLMDNDSPContext *s); |
||||||
|
void ff_anlmdn_init_x86(AudioNLMDNDSPContext *s); |
||||||
|
|
||||||
|
#endif /* AVFILTER_ANLMDNDSP_H */ |
@ -0,0 +1,80 @@ |
|||||||
|
;***************************************************************************** |
||||||
|
;* x86-optimized functions for anlmdn filter |
||||||
|
;* Copyright (c) 2017 Paul B Mahol |
||||||
|
;* |
||||||
|
;* 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 |
||||||
|
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||||
|
;****************************************************************************** |
||||||
|
|
||||||
|
%include "libavutil/x86/x86util.asm" |
||||||
|
|
||||||
|
SECTION .text |
||||||
|
|
||||||
|
;------------------------------------------------------------------------------ |
||||||
|
; float ff_compute_distance_ssd(float *f1, const float *f2, ptrdiff_t len) |
||||||
|
;------------------------------------------------------------------------------ |
||||||
|
|
||||||
|
INIT_XMM sse |
||||||
|
cglobal compute_distance_ssd, 3,5,3, f1, f2, len, r, x |
||||||
|
mov xq, lenq |
||||||
|
shl xq, 2 |
||||||
|
neg xq |
||||||
|
add f1q, xq |
||||||
|
add f2q, xq |
||||||
|
xor xq, xq |
||||||
|
shl lenq, 1 |
||||||
|
add lenq, 1 |
||||||
|
shl lenq, 2 |
||||||
|
mov rq, lenq |
||||||
|
and rq, mmsize - 1 |
||||||
|
xorps m0, m0 |
||||||
|
cmp lenq, mmsize |
||||||
|
jl .loop1 |
||||||
|
sub lenq, rq |
||||||
|
ALIGN 16 |
||||||
|
.loop0: |
||||||
|
movups m1, [f1q + xq] |
||||||
|
movups m2, [f2q + xq] |
||||||
|
subps m1, m2 |
||||||
|
mulps m1, m1 |
||||||
|
addps m0, m1 |
||||||
|
add xq, mmsize |
||||||
|
cmp xq, lenq |
||||||
|
jl .loop0 |
||||||
|
|
||||||
|
movhlps xmm1, xmm0 |
||||||
|
addps xmm0, xmm1 |
||||||
|
movss xmm1, xmm0 |
||||||
|
shufps xmm0, xmm0, 1 |
||||||
|
addss xmm0, xmm1 |
||||||
|
|
||||||
|
cmp rq, 0 |
||||||
|
je .end |
||||||
|
add lenq, rq |
||||||
|
.loop1: |
||||||
|
movss xm1, [f1q + xq] |
||||||
|
subss xm1, [f2q + xq] |
||||||
|
mulss xm1, xm1 |
||||||
|
addss xm0, xm1 |
||||||
|
add xq, 4 |
||||||
|
cmp xq, lenq |
||||||
|
jl .loop1 |
||||||
|
.end: |
||||||
|
%if ARCH_X86_64 == 0 |
||||||
|
movss r0m, xm0 |
||||||
|
fld dword r0m |
||||||
|
%endif |
||||||
|
RET |
@ -0,0 +1,35 @@ |
|||||||
|
/*
|
||||||
|
* 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 |
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "config.h" |
||||||
|
#include "libavutil/attributes.h" |
||||||
|
#include "libavutil/cpu.h" |
||||||
|
#include "libavutil/x86/cpu.h" |
||||||
|
#include "libavfilter/af_anlmdndsp.h" |
||||||
|
|
||||||
|
float ff_compute_distance_ssd_sse(const float *f1, const float *f2, |
||||||
|
ptrdiff_t len); |
||||||
|
|
||||||
|
av_cold void ff_anlmdn_init_x86(AudioNLMDNDSPContext *s) |
||||||
|
{ |
||||||
|
int cpu_flags = av_get_cpu_flags(); |
||||||
|
|
||||||
|
if (EXTERNAL_SSE(cpu_flags)) { |
||||||
|
s->compute_distance_ssd = ff_compute_distance_ssd_sse; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue