forked from KolibriOS/kolibrios
ffmpeg-2.1.1: move directory
git-svn-id: svn://kolibrios.org@6148 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
OBJS += x86/audio_convert_init.o \
|
||||
x86/audio_mix_init.o \
|
||||
x86/dither_init.o \
|
||||
|
||||
YASM-OBJS += x86/audio_convert.o \
|
||||
x86/audio_mix.o \
|
||||
x86/dither.o \
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,263 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
|
||||
*
|
||||
* 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/cpu.h"
|
||||
#include "libavutil/x86/cpu.h"
|
||||
#include "libavresample/audio_convert.h"
|
||||
|
||||
/* flat conversions */
|
||||
|
||||
void ff_conv_s16_to_s32_sse2(int16_t *dst, const int32_t *src, int len);
|
||||
|
||||
void ff_conv_s16_to_flt_sse2(float *dst, const int16_t *src, int len);
|
||||
void ff_conv_s16_to_flt_sse4(float *dst, const int16_t *src, int len);
|
||||
|
||||
void ff_conv_s32_to_s16_mmx (int16_t *dst, const int32_t *src, int len);
|
||||
void ff_conv_s32_to_s16_sse2(int16_t *dst, const int32_t *src, int len);
|
||||
|
||||
void ff_conv_s32_to_flt_sse2(float *dst, const int32_t *src, int len);
|
||||
void ff_conv_s32_to_flt_avx (float *dst, const int32_t *src, int len);
|
||||
|
||||
void ff_conv_flt_to_s16_sse2(int16_t *dst, const float *src, int len);
|
||||
|
||||
void ff_conv_flt_to_s32_sse2(int32_t *dst, const float *src, int len);
|
||||
void ff_conv_flt_to_s32_avx (int32_t *dst, const float *src, int len);
|
||||
|
||||
/* interleave conversions */
|
||||
|
||||
void ff_conv_s16p_to_s16_2ch_sse2(int16_t *dst, int16_t *const *src,
|
||||
int len, int channels);
|
||||
void ff_conv_s16p_to_s16_2ch_avx (int16_t *dst, int16_t *const *src,
|
||||
int len, int channels);
|
||||
|
||||
void ff_conv_s16p_to_s16_6ch_sse2(int16_t *dst, int16_t *const *src,
|
||||
int len, int channels);
|
||||
void ff_conv_s16p_to_s16_6ch_sse2slow(int16_t *dst, int16_t *const *src,
|
||||
int len, int channels);
|
||||
void ff_conv_s16p_to_s16_6ch_avx (int16_t *dst, int16_t *const *src,
|
||||
int len, int channels);
|
||||
|
||||
void ff_conv_s16p_to_flt_2ch_sse2(float *dst, int16_t *const *src,
|
||||
int len, int channels);
|
||||
void ff_conv_s16p_to_flt_2ch_avx (float *dst, int16_t *const *src,
|
||||
int len, int channels);
|
||||
|
||||
void ff_conv_s16p_to_flt_6ch_sse2 (float *dst, int16_t *const *src,
|
||||
int len, int channels);
|
||||
void ff_conv_s16p_to_flt_6ch_ssse3(float *dst, int16_t *const *src,
|
||||
int len, int channels);
|
||||
void ff_conv_s16p_to_flt_6ch_avx (float *dst, int16_t *const *src,
|
||||
int len, int channels);
|
||||
|
||||
void ff_conv_fltp_to_s16_2ch_sse2 (int16_t *dst, float *const *src,
|
||||
int len, int channels);
|
||||
void ff_conv_fltp_to_s16_2ch_ssse3(int16_t *dst, float *const *src,
|
||||
int len, int channels);
|
||||
|
||||
void ff_conv_fltp_to_s16_6ch_sse (int16_t *dst, float *const *src,
|
||||
int len, int channels);
|
||||
void ff_conv_fltp_to_s16_6ch_sse2(int16_t *dst, float *const *src,
|
||||
int len, int channels);
|
||||
void ff_conv_fltp_to_s16_6ch_avx (int16_t *dst, float *const *src,
|
||||
int len, int channels);
|
||||
|
||||
void ff_conv_fltp_to_flt_2ch_sse(float *dst, float *const *src, int len,
|
||||
int channels);
|
||||
void ff_conv_fltp_to_flt_2ch_avx(float *dst, float *const *src, int len,
|
||||
int channels);
|
||||
|
||||
void ff_conv_fltp_to_flt_6ch_mmx (float *dst, float *const *src, int len,
|
||||
int channels);
|
||||
void ff_conv_fltp_to_flt_6ch_sse4(float *dst, float *const *src, int len,
|
||||
int channels);
|
||||
void ff_conv_fltp_to_flt_6ch_avx (float *dst, float *const *src, int len,
|
||||
int channels);
|
||||
|
||||
/* deinterleave conversions */
|
||||
|
||||
void ff_conv_s16_to_s16p_2ch_sse2(int16_t *const *dst, int16_t *src,
|
||||
int len, int channels);
|
||||
void ff_conv_s16_to_s16p_2ch_ssse3(int16_t *const *dst, int16_t *src,
|
||||
int len, int channels);
|
||||
void ff_conv_s16_to_s16p_2ch_avx (int16_t *const *dst, int16_t *src,
|
||||
int len, int channels);
|
||||
|
||||
void ff_conv_s16_to_s16p_6ch_sse2 (int16_t *const *dst, int16_t *src,
|
||||
int len, int channels);
|
||||
void ff_conv_s16_to_s16p_6ch_ssse3(int16_t *const *dst, int16_t *src,
|
||||
int len, int channels);
|
||||
void ff_conv_s16_to_s16p_6ch_avx (int16_t *const *dst, int16_t *src,
|
||||
int len, int channels);
|
||||
|
||||
void ff_conv_s16_to_fltp_2ch_sse2(float *const *dst, int16_t *src,
|
||||
int len, int channels);
|
||||
void ff_conv_s16_to_fltp_2ch_avx (float *const *dst, int16_t *src,
|
||||
int len, int channels);
|
||||
|
||||
void ff_conv_s16_to_fltp_6ch_sse2 (float *const *dst, int16_t *src,
|
||||
int len, int channels);
|
||||
void ff_conv_s16_to_fltp_6ch_ssse3(float *const *dst, int16_t *src,
|
||||
int len, int channels);
|
||||
void ff_conv_s16_to_fltp_6ch_sse4 (float *const *dst, int16_t *src,
|
||||
int len, int channels);
|
||||
void ff_conv_s16_to_fltp_6ch_avx (float *const *dst, int16_t *src,
|
||||
int len, int channels);
|
||||
|
||||
void ff_conv_flt_to_s16p_2ch_sse2(int16_t *const *dst, float *src,
|
||||
int len, int channels);
|
||||
void ff_conv_flt_to_s16p_2ch_avx (int16_t *const *dst, float *src,
|
||||
int len, int channels);
|
||||
|
||||
void ff_conv_flt_to_s16p_6ch_sse2 (int16_t *const *dst, float *src,
|
||||
int len, int channels);
|
||||
void ff_conv_flt_to_s16p_6ch_ssse3(int16_t *const *dst, float *src,
|
||||
int len, int channels);
|
||||
void ff_conv_flt_to_s16p_6ch_avx (int16_t *const *dst, float *src,
|
||||
int len, int channels);
|
||||
|
||||
void ff_conv_flt_to_fltp_2ch_sse(float *const *dst, float *src, int len,
|
||||
int channels);
|
||||
void ff_conv_flt_to_fltp_2ch_avx(float *const *dst, float *src, int len,
|
||||
int channels);
|
||||
|
||||
void ff_conv_flt_to_fltp_6ch_sse2(float *const *dst, float *src, int len,
|
||||
int channels);
|
||||
void ff_conv_flt_to_fltp_6ch_avx (float *const *dst, float *src, int len,
|
||||
int channels);
|
||||
|
||||
av_cold void ff_audio_convert_init_x86(AudioConvert *ac)
|
||||
{
|
||||
int cpu_flags = av_get_cpu_flags();
|
||||
|
||||
if (EXTERNAL_MMX(cpu_flags)) {
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32,
|
||||
0, 1, 8, "MMX", ff_conv_s32_to_s16_mmx);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
|
||||
6, 1, 4, "MMX", ff_conv_fltp_to_flt_6ch_mmx);
|
||||
}
|
||||
if (EXTERNAL_SSE(cpu_flags)) {
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
|
||||
6, 1, 2, "SSE", ff_conv_fltp_to_s16_6ch_sse);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
|
||||
2, 16, 8, "SSE", ff_conv_fltp_to_flt_2ch_sse);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT,
|
||||
2, 16, 4, "SSE", ff_conv_flt_to_fltp_2ch_sse);
|
||||
}
|
||||
if (EXTERNAL_SSE2(cpu_flags)) {
|
||||
if (!(cpu_flags & AV_CPU_FLAG_SSE2SLOW)) {
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32,
|
||||
0, 16, 16, "SSE2", ff_conv_s32_to_s16_sse2);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
|
||||
6, 16, 8, "SSE2", ff_conv_s16p_to_s16_6ch_sse2);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
|
||||
6, 16, 4, "SSE2", ff_conv_fltp_to_s16_6ch_sse2);
|
||||
} else {
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
|
||||
6, 1, 4, "SSE2SLOW", ff_conv_s16p_to_s16_6ch_sse2slow);
|
||||
}
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16,
|
||||
0, 16, 8, "SSE2", ff_conv_s16_to_s32_sse2);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16,
|
||||
0, 16, 8, "SSE2", ff_conv_s16_to_flt_sse2);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32,
|
||||
0, 16, 8, "SSE2", ff_conv_s32_to_flt_sse2);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT,
|
||||
0, 16, 16, "SSE2", ff_conv_flt_to_s16_sse2);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT,
|
||||
0, 16, 16, "SSE2", ff_conv_flt_to_s32_sse2);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
|
||||
2, 16, 16, "SSE2", ff_conv_s16p_to_s16_2ch_sse2);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P,
|
||||
2, 16, 8, "SSE2", ff_conv_s16p_to_flt_2ch_sse2);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P,
|
||||
6, 16, 4, "SSE2", ff_conv_s16p_to_flt_6ch_sse2);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
|
||||
2, 16, 4, "SSE2", ff_conv_fltp_to_s16_2ch_sse2);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16,
|
||||
2, 16, 8, "SSE2", ff_conv_s16_to_s16p_2ch_sse2);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16,
|
||||
6, 16, 4, "SSE2", ff_conv_s16_to_s16p_6ch_sse2);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16,
|
||||
2, 16, 8, "SSE2", ff_conv_s16_to_fltp_2ch_sse2);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16,
|
||||
6, 16, 4, "SSE2", ff_conv_s16_to_fltp_6ch_sse2);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT,
|
||||
2, 16, 8, "SSE2", ff_conv_flt_to_s16p_2ch_sse2);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT,
|
||||
6, 16, 4, "SSE2", ff_conv_flt_to_s16p_6ch_sse2);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT,
|
||||
6, 16, 4, "SSE2", ff_conv_flt_to_fltp_6ch_sse2);
|
||||
}
|
||||
if (EXTERNAL_SSSE3(cpu_flags)) {
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P,
|
||||
6, 16, 4, "SSSE3", ff_conv_s16p_to_flt_6ch_ssse3);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
|
||||
2, 16, 4, "SSSE3", ff_conv_fltp_to_s16_2ch_ssse3);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16,
|
||||
2, 16, 8, "SSSE3", ff_conv_s16_to_s16p_2ch_ssse3);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16,
|
||||
6, 16, 4, "SSSE3", ff_conv_s16_to_s16p_6ch_ssse3);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16,
|
||||
6, 16, 4, "SSSE3", ff_conv_s16_to_fltp_6ch_ssse3);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT,
|
||||
6, 16, 4, "SSSE3", ff_conv_flt_to_s16p_6ch_ssse3);
|
||||
}
|
||||
if (EXTERNAL_SSE4(cpu_flags)) {
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16,
|
||||
0, 16, 8, "SSE4", ff_conv_s16_to_flt_sse4);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
|
||||
6, 16, 4, "SSE4", ff_conv_fltp_to_flt_6ch_sse4);
|
||||
}
|
||||
if (EXTERNAL_AVX(cpu_flags)) {
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32,
|
||||
0, 32, 16, "AVX", ff_conv_s32_to_flt_avx);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT,
|
||||
0, 32, 32, "AVX", ff_conv_flt_to_s32_avx);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
|
||||
2, 16, 16, "AVX", ff_conv_s16p_to_s16_2ch_avx);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
|
||||
6, 16, 8, "AVX", ff_conv_s16p_to_s16_6ch_avx);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P,
|
||||
2, 16, 8, "AVX", ff_conv_s16p_to_flt_2ch_avx);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P,
|
||||
6, 16, 4, "AVX", ff_conv_s16p_to_flt_6ch_avx);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
|
||||
6, 16, 4, "AVX", ff_conv_fltp_to_s16_6ch_avx);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
|
||||
6, 16, 4, "AVX", ff_conv_fltp_to_flt_6ch_avx);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16,
|
||||
2, 16, 8, "AVX", ff_conv_s16_to_s16p_2ch_avx);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16,
|
||||
6, 16, 4, "AVX", ff_conv_s16_to_s16p_6ch_avx);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16,
|
||||
2, 16, 8, "AVX", ff_conv_s16_to_fltp_2ch_avx);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16,
|
||||
6, 16, 4, "AVX", ff_conv_s16_to_fltp_6ch_avx);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT,
|
||||
2, 16, 8, "AVX", ff_conv_flt_to_s16p_2ch_avx);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT,
|
||||
6, 16, 4, "AVX", ff_conv_flt_to_s16p_6ch_avx);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT,
|
||||
2, 16, 4, "AVX", ff_conv_flt_to_fltp_2ch_avx);
|
||||
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT,
|
||||
6, 16, 4, "AVX", ff_conv_flt_to_fltp_6ch_avx);
|
||||
}
|
||||
}
|
@@ -0,0 +1,511 @@
|
||||
;******************************************************************************
|
||||
;* x86 optimized channel mixing
|
||||
;* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
|
||||
;*
|
||||
;* 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"
|
||||
%include "util.asm"
|
||||
|
||||
SECTION_TEXT
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
; void ff_mix_2_to_1_fltp_flt(float **src, float **matrix, int len,
|
||||
; int out_ch, int in_ch);
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
%macro MIX_2_TO_1_FLTP_FLT 0
|
||||
cglobal mix_2_to_1_fltp_flt, 3,4,6, src, matrix, len, src1
|
||||
mov src1q, [srcq+gprsize]
|
||||
mov srcq, [srcq ]
|
||||
sub src1q, srcq
|
||||
mov matrixq, [matrixq ]
|
||||
VBROADCASTSS m4, [matrixq ]
|
||||
VBROADCASTSS m5, [matrixq+4]
|
||||
ALIGN 16
|
||||
.loop:
|
||||
mulps m0, m4, [srcq ]
|
||||
mulps m1, m5, [srcq+src1q ]
|
||||
mulps m2, m4, [srcq+ mmsize]
|
||||
mulps m3, m5, [srcq+src1q+mmsize]
|
||||
addps m0, m0, m1
|
||||
addps m2, m2, m3
|
||||
mova [srcq ], m0
|
||||
mova [srcq+mmsize], m2
|
||||
add srcq, mmsize*2
|
||||
sub lend, mmsize*2/4
|
||||
jg .loop
|
||||
REP_RET
|
||||
%endmacro
|
||||
|
||||
INIT_XMM sse
|
||||
MIX_2_TO_1_FLTP_FLT
|
||||
%if HAVE_AVX_EXTERNAL
|
||||
INIT_YMM avx
|
||||
MIX_2_TO_1_FLTP_FLT
|
||||
%endif
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
; void ff_mix_2_to_1_s16p_flt(int16_t **src, float **matrix, int len,
|
||||
; int out_ch, int in_ch);
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
%macro MIX_2_TO_1_S16P_FLT 0
|
||||
cglobal mix_2_to_1_s16p_flt, 3,4,6, src, matrix, len, src1
|
||||
mov src1q, [srcq+gprsize]
|
||||
mov srcq, [srcq]
|
||||
sub src1q, srcq
|
||||
mov matrixq, [matrixq ]
|
||||
VBROADCASTSS m4, [matrixq ]
|
||||
VBROADCASTSS m5, [matrixq+4]
|
||||
ALIGN 16
|
||||
.loop:
|
||||
mova m0, [srcq ]
|
||||
mova m2, [srcq+src1q]
|
||||
S16_TO_S32_SX 0, 1
|
||||
S16_TO_S32_SX 2, 3
|
||||
cvtdq2ps m0, m0
|
||||
cvtdq2ps m1, m1
|
||||
cvtdq2ps m2, m2
|
||||
cvtdq2ps m3, m3
|
||||
mulps m0, m4
|
||||
mulps m1, m4
|
||||
mulps m2, m5
|
||||
mulps m3, m5
|
||||
addps m0, m2
|
||||
addps m1, m3
|
||||
cvtps2dq m0, m0
|
||||
cvtps2dq m1, m1
|
||||
packssdw m0, m1
|
||||
mova [srcq], m0
|
||||
add srcq, mmsize
|
||||
sub lend, mmsize/2
|
||||
jg .loop
|
||||
REP_RET
|
||||
%endmacro
|
||||
|
||||
INIT_XMM sse2
|
||||
MIX_2_TO_1_S16P_FLT
|
||||
INIT_XMM sse4
|
||||
MIX_2_TO_1_S16P_FLT
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
; void ff_mix_2_to_1_s16p_q8(int16_t **src, int16_t **matrix, int len,
|
||||
; int out_ch, int in_ch);
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
INIT_XMM sse2
|
||||
cglobal mix_2_to_1_s16p_q8, 3,4,6, src, matrix, len, src1
|
||||
mov src1q, [srcq+gprsize]
|
||||
mov srcq, [srcq]
|
||||
sub src1q, srcq
|
||||
mov matrixq, [matrixq]
|
||||
movd m4, [matrixq]
|
||||
movd m5, [matrixq]
|
||||
SPLATW m4, m4, 0
|
||||
SPLATW m5, m5, 1
|
||||
pxor m0, m0
|
||||
punpcklwd m4, m0
|
||||
punpcklwd m5, m0
|
||||
ALIGN 16
|
||||
.loop:
|
||||
mova m0, [srcq ]
|
||||
mova m2, [srcq+src1q]
|
||||
punpckhwd m1, m0, m0
|
||||
punpcklwd m0, m0
|
||||
punpckhwd m3, m2, m2
|
||||
punpcklwd m2, m2
|
||||
pmaddwd m0, m4
|
||||
pmaddwd m1, m4
|
||||
pmaddwd m2, m5
|
||||
pmaddwd m3, m5
|
||||
paddd m0, m2
|
||||
paddd m1, m3
|
||||
psrad m0, 8
|
||||
psrad m1, 8
|
||||
packssdw m0, m1
|
||||
mova [srcq], m0
|
||||
add srcq, mmsize
|
||||
sub lend, mmsize/2
|
||||
jg .loop
|
||||
REP_RET
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
; void ff_mix_1_to_2_fltp_flt(float **src, float **matrix, int len,
|
||||
; int out_ch, int in_ch);
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
%macro MIX_1_TO_2_FLTP_FLT 0
|
||||
cglobal mix_1_to_2_fltp_flt, 3,5,4, src0, matrix0, len, src1, matrix1
|
||||
mov src1q, [src0q+gprsize]
|
||||
mov src0q, [src0q]
|
||||
sub src1q, src0q
|
||||
mov matrix1q, [matrix0q+gprsize]
|
||||
mov matrix0q, [matrix0q]
|
||||
VBROADCASTSS m2, [matrix0q]
|
||||
VBROADCASTSS m3, [matrix1q]
|
||||
ALIGN 16
|
||||
.loop:
|
||||
mova m0, [src0q]
|
||||
mulps m1, m0, m3
|
||||
mulps m0, m0, m2
|
||||
mova [src0q ], m0
|
||||
mova [src0q+src1q], m1
|
||||
add src0q, mmsize
|
||||
sub lend, mmsize/4
|
||||
jg .loop
|
||||
REP_RET
|
||||
%endmacro
|
||||
|
||||
INIT_XMM sse
|
||||
MIX_1_TO_2_FLTP_FLT
|
||||
%if HAVE_AVX_EXTERNAL
|
||||
INIT_YMM avx
|
||||
MIX_1_TO_2_FLTP_FLT
|
||||
%endif
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
; void ff_mix_1_to_2_s16p_flt(int16_t **src, float **matrix, int len,
|
||||
; int out_ch, int in_ch);
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
%macro MIX_1_TO_2_S16P_FLT 0
|
||||
cglobal mix_1_to_2_s16p_flt, 3,5,6, src0, matrix0, len, src1, matrix1
|
||||
mov src1q, [src0q+gprsize]
|
||||
mov src0q, [src0q]
|
||||
sub src1q, src0q
|
||||
mov matrix1q, [matrix0q+gprsize]
|
||||
mov matrix0q, [matrix0q]
|
||||
VBROADCASTSS m4, [matrix0q]
|
||||
VBROADCASTSS m5, [matrix1q]
|
||||
ALIGN 16
|
||||
.loop:
|
||||
mova m0, [src0q]
|
||||
S16_TO_S32_SX 0, 2
|
||||
cvtdq2ps m0, m0
|
||||
cvtdq2ps m2, m2
|
||||
mulps m1, m0, m5
|
||||
mulps m0, m0, m4
|
||||
mulps m3, m2, m5
|
||||
mulps m2, m2, m4
|
||||
cvtps2dq m0, m0
|
||||
cvtps2dq m1, m1
|
||||
cvtps2dq m2, m2
|
||||
cvtps2dq m3, m3
|
||||
packssdw m0, m2
|
||||
packssdw m1, m3
|
||||
mova [src0q ], m0
|
||||
mova [src0q+src1q], m1
|
||||
add src0q, mmsize
|
||||
sub lend, mmsize/2
|
||||
jg .loop
|
||||
REP_RET
|
||||
%endmacro
|
||||
|
||||
INIT_XMM sse2
|
||||
MIX_1_TO_2_S16P_FLT
|
||||
INIT_XMM sse4
|
||||
MIX_1_TO_2_S16P_FLT
|
||||
%if HAVE_AVX_EXTERNAL
|
||||
INIT_XMM avx
|
||||
MIX_1_TO_2_S16P_FLT
|
||||
%endif
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
; void ff_mix_3_8_to_1_2_fltp/s16p_flt(float/int16_t **src, float **matrix,
|
||||
; int len, int out_ch, int in_ch);
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
%macro MIX_3_8_TO_1_2_FLT 3 ; %1 = in channels, %2 = out channels, %3 = s16p or fltp
|
||||
; define some names to make the code clearer
|
||||
%assign in_channels %1
|
||||
%assign out_channels %2
|
||||
%assign stereo out_channels - 1
|
||||
%ifidn %3, s16p
|
||||
%assign is_s16 1
|
||||
%else
|
||||
%assign is_s16 0
|
||||
%endif
|
||||
|
||||
; determine how many matrix elements must go on the stack vs. mmregs
|
||||
%assign matrix_elements in_channels * out_channels
|
||||
%if is_s16
|
||||
%if stereo
|
||||
%assign needed_mmregs 7
|
||||
%else
|
||||
%assign needed_mmregs 5
|
||||
%endif
|
||||
%else
|
||||
%if stereo
|
||||
%assign needed_mmregs 4
|
||||
%else
|
||||
%assign needed_mmregs 3
|
||||
%endif
|
||||
%endif
|
||||
%assign matrix_elements_mm num_mmregs - needed_mmregs
|
||||
%if matrix_elements < matrix_elements_mm
|
||||
%assign matrix_elements_mm matrix_elements
|
||||
%endif
|
||||
%if matrix_elements_mm < matrix_elements
|
||||
%assign matrix_elements_stack matrix_elements - matrix_elements_mm
|
||||
%else
|
||||
%assign matrix_elements_stack 0
|
||||
%endif
|
||||
%assign matrix_stack_size matrix_elements_stack * mmsize
|
||||
|
||||
%assign needed_stack_size -1 * matrix_stack_size
|
||||
%if ARCH_X86_32 && in_channels >= 7
|
||||
%assign needed_stack_size needed_stack_size - 16
|
||||
%endif
|
||||
|
||||
cglobal mix_%1_to_%2_%3_flt, 3,in_channels+2,needed_mmregs+matrix_elements_mm, needed_stack_size, src0, src1, len, src2, src3, src4, src5, src6, src7
|
||||
|
||||
; define src pointers on stack if needed
|
||||
%if matrix_elements_stack > 0 && ARCH_X86_32 && in_channels >= 7
|
||||
%define src5m [rsp+matrix_stack_size+0]
|
||||
%define src6m [rsp+matrix_stack_size+4]
|
||||
%define src7m [rsp+matrix_stack_size+8]
|
||||
%endif
|
||||
|
||||
; load matrix pointers
|
||||
%define matrix0q r1q
|
||||
%define matrix1q r3q
|
||||
%if stereo
|
||||
mov matrix1q, [matrix0q+gprsize]
|
||||
%endif
|
||||
mov matrix0q, [matrix0q]
|
||||
|
||||
; define matrix coeff names
|
||||
%assign %%i 0
|
||||
%assign %%j needed_mmregs
|
||||
%rep in_channels
|
||||
%if %%i >= matrix_elements_mm
|
||||
CAT_XDEFINE mx_stack_0_, %%i, 1
|
||||
CAT_XDEFINE mx_0_, %%i, [rsp+(%%i-matrix_elements_mm)*mmsize]
|
||||
%else
|
||||
CAT_XDEFINE mx_stack_0_, %%i, 0
|
||||
CAT_XDEFINE mx_0_, %%i, m %+ %%j
|
||||
%assign %%j %%j+1
|
||||
%endif
|
||||
%assign %%i %%i+1
|
||||
%endrep
|
||||
%if stereo
|
||||
%assign %%i 0
|
||||
%rep in_channels
|
||||
%if in_channels + %%i >= matrix_elements_mm
|
||||
CAT_XDEFINE mx_stack_1_, %%i, 1
|
||||
CAT_XDEFINE mx_1_, %%i, [rsp+(in_channels+%%i-matrix_elements_mm)*mmsize]
|
||||
%else
|
||||
CAT_XDEFINE mx_stack_1_, %%i, 0
|
||||
CAT_XDEFINE mx_1_, %%i, m %+ %%j
|
||||
%assign %%j %%j+1
|
||||
%endif
|
||||
%assign %%i %%i+1
|
||||
%endrep
|
||||
%endif
|
||||
|
||||
; load/splat matrix coeffs
|
||||
%assign %%i 0
|
||||
%rep in_channels
|
||||
%if mx_stack_0_ %+ %%i
|
||||
VBROADCASTSS m0, [matrix0q+4*%%i]
|
||||
mova mx_0_ %+ %%i, m0
|
||||
%else
|
||||
VBROADCASTSS mx_0_ %+ %%i, [matrix0q+4*%%i]
|
||||
%endif
|
||||
%if stereo
|
||||
%if mx_stack_1_ %+ %%i
|
||||
VBROADCASTSS m0, [matrix1q+4*%%i]
|
||||
mova mx_1_ %+ %%i, m0
|
||||
%else
|
||||
VBROADCASTSS mx_1_ %+ %%i, [matrix1q+4*%%i]
|
||||
%endif
|
||||
%endif
|
||||
%assign %%i %%i+1
|
||||
%endrep
|
||||
|
||||
; load channel pointers to registers as offsets from the first channel pointer
|
||||
%if ARCH_X86_64
|
||||
movsxd lenq, r2d
|
||||
%endif
|
||||
shl lenq, 2-is_s16
|
||||
%assign %%i 1
|
||||
%rep (in_channels - 1)
|
||||
%if ARCH_X86_32 && in_channels >= 7 && %%i >= 5
|
||||
mov src5q, [src0q+%%i*gprsize]
|
||||
add src5q, lenq
|
||||
mov src %+ %%i %+ m, src5q
|
||||
%else
|
||||
mov src %+ %%i %+ q, [src0q+%%i*gprsize]
|
||||
add src %+ %%i %+ q, lenq
|
||||
%endif
|
||||
%assign %%i %%i+1
|
||||
%endrep
|
||||
mov src0q, [src0q]
|
||||
add src0q, lenq
|
||||
neg lenq
|
||||
.loop:
|
||||
; for x86-32 with 7-8 channels we do not have enough gp registers for all src
|
||||
; pointers, so we have to load some of them from the stack each time
|
||||
%define copy_src_from_stack ARCH_X86_32 && in_channels >= 7 && %%i >= 5
|
||||
%if is_s16
|
||||
; mix with s16p input
|
||||
mova m0, [src0q+lenq]
|
||||
S16_TO_S32_SX 0, 1
|
||||
cvtdq2ps m0, m0
|
||||
cvtdq2ps m1, m1
|
||||
%if stereo
|
||||
mulps m2, m0, mx_1_0
|
||||
mulps m3, m1, mx_1_0
|
||||
%endif
|
||||
mulps m0, m0, mx_0_0
|
||||
mulps m1, m1, mx_0_0
|
||||
%assign %%i 1
|
||||
%rep (in_channels - 1)
|
||||
%if copy_src_from_stack
|
||||
%define src_ptr src5q
|
||||
%else
|
||||
%define src_ptr src %+ %%i %+ q
|
||||
%endif
|
||||
%if stereo
|
||||
%if copy_src_from_stack
|
||||
mov src_ptr, src %+ %%i %+ m
|
||||
%endif
|
||||
mova m4, [src_ptr+lenq]
|
||||
S16_TO_S32_SX 4, 5
|
||||
cvtdq2ps m4, m4
|
||||
cvtdq2ps m5, m5
|
||||
FMULADD_PS m2, m4, mx_1_ %+ %%i, m2, m6
|
||||
FMULADD_PS m3, m5, mx_1_ %+ %%i, m3, m6
|
||||
FMULADD_PS m0, m4, mx_0_ %+ %%i, m0, m4
|
||||
FMULADD_PS m1, m5, mx_0_ %+ %%i, m1, m5
|
||||
%else
|
||||
%if copy_src_from_stack
|
||||
mov src_ptr, src %+ %%i %+ m
|
||||
%endif
|
||||
mova m2, [src_ptr+lenq]
|
||||
S16_TO_S32_SX 2, 3
|
||||
cvtdq2ps m2, m2
|
||||
cvtdq2ps m3, m3
|
||||
FMULADD_PS m0, m2, mx_0_ %+ %%i, m0, m4
|
||||
FMULADD_PS m1, m3, mx_0_ %+ %%i, m1, m4
|
||||
%endif
|
||||
%assign %%i %%i+1
|
||||
%endrep
|
||||
%if stereo
|
||||
cvtps2dq m2, m2
|
||||
cvtps2dq m3, m3
|
||||
packssdw m2, m3
|
||||
mova [src1q+lenq], m2
|
||||
%endif
|
||||
cvtps2dq m0, m0
|
||||
cvtps2dq m1, m1
|
||||
packssdw m0, m1
|
||||
mova [src0q+lenq], m0
|
||||
%else
|
||||
; mix with fltp input
|
||||
%if stereo || mx_stack_0_0
|
||||
mova m0, [src0q+lenq]
|
||||
%endif
|
||||
%if stereo
|
||||
mulps m1, m0, mx_1_0
|
||||
%endif
|
||||
%if stereo || mx_stack_0_0
|
||||
mulps m0, m0, mx_0_0
|
||||
%else
|
||||
mulps m0, mx_0_0, [src0q+lenq]
|
||||
%endif
|
||||
%assign %%i 1
|
||||
%rep (in_channels - 1)
|
||||
%if copy_src_from_stack
|
||||
%define src_ptr src5q
|
||||
mov src_ptr, src %+ %%i %+ m
|
||||
%else
|
||||
%define src_ptr src %+ %%i %+ q
|
||||
%endif
|
||||
; avoid extra load for mono if matrix is in a mm register
|
||||
%if stereo || mx_stack_0_ %+ %%i
|
||||
mova m2, [src_ptr+lenq]
|
||||
%endif
|
||||
%if stereo
|
||||
FMULADD_PS m1, m2, mx_1_ %+ %%i, m1, m3
|
||||
%endif
|
||||
%if stereo || mx_stack_0_ %+ %%i
|
||||
FMULADD_PS m0, m2, mx_0_ %+ %%i, m0, m2
|
||||
%else
|
||||
FMULADD_PS m0, mx_0_ %+ %%i, [src_ptr+lenq], m0, m1
|
||||
%endif
|
||||
%assign %%i %%i+1
|
||||
%endrep
|
||||
mova [src0q+lenq], m0
|
||||
%if stereo
|
||||
mova [src1q+lenq], m1
|
||||
%endif
|
||||
%endif
|
||||
|
||||
add lenq, mmsize
|
||||
jl .loop
|
||||
; zero ymm high halves
|
||||
%if mmsize == 32
|
||||
vzeroupper
|
||||
%endif
|
||||
RET
|
||||
%endmacro
|
||||
|
||||
%macro MIX_3_8_TO_1_2_FLT_FUNCS 0
|
||||
%assign %%i 3
|
||||
%rep 6
|
||||
INIT_XMM sse
|
||||
MIX_3_8_TO_1_2_FLT %%i, 1, fltp
|
||||
MIX_3_8_TO_1_2_FLT %%i, 2, fltp
|
||||
INIT_XMM sse2
|
||||
MIX_3_8_TO_1_2_FLT %%i, 1, s16p
|
||||
MIX_3_8_TO_1_2_FLT %%i, 2, s16p
|
||||
INIT_XMM sse4
|
||||
MIX_3_8_TO_1_2_FLT %%i, 1, s16p
|
||||
MIX_3_8_TO_1_2_FLT %%i, 2, s16p
|
||||
; do not use ymm AVX or FMA4 in x86-32 for 6 or more channels due to stack alignment issues
|
||||
%if HAVE_AVX_EXTERNAL
|
||||
%if ARCH_X86_64 || %%i < 6
|
||||
INIT_YMM avx
|
||||
%else
|
||||
INIT_XMM avx
|
||||
%endif
|
||||
MIX_3_8_TO_1_2_FLT %%i, 1, fltp
|
||||
MIX_3_8_TO_1_2_FLT %%i, 2, fltp
|
||||
INIT_XMM avx
|
||||
MIX_3_8_TO_1_2_FLT %%i, 1, s16p
|
||||
MIX_3_8_TO_1_2_FLT %%i, 2, s16p
|
||||
%endif
|
||||
%if HAVE_FMA4_EXTERNAL
|
||||
%if ARCH_X86_64 || %%i < 6
|
||||
INIT_YMM fma4
|
||||
%else
|
||||
INIT_XMM fma4
|
||||
%endif
|
||||
MIX_3_8_TO_1_2_FLT %%i, 1, fltp
|
||||
MIX_3_8_TO_1_2_FLT %%i, 2, fltp
|
||||
INIT_XMM fma4
|
||||
MIX_3_8_TO_1_2_FLT %%i, 1, s16p
|
||||
MIX_3_8_TO_1_2_FLT %%i, 2, s16p
|
||||
%endif
|
||||
%assign %%i %%i+1
|
||||
%endrep
|
||||
%endmacro
|
||||
|
||||
MIX_3_8_TO_1_2_FLT_FUNCS
|
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
|
||||
*
|
||||
* 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/cpu.h"
|
||||
#include "libavutil/x86/cpu.h"
|
||||
#include "libavresample/audio_mix.h"
|
||||
|
||||
void ff_mix_2_to_1_fltp_flt_sse(float **src, float **matrix, int len,
|
||||
int out_ch, int in_ch);
|
||||
void ff_mix_2_to_1_fltp_flt_avx(float **src, float **matrix, int len,
|
||||
int out_ch, int in_ch);
|
||||
|
||||
void ff_mix_2_to_1_s16p_flt_sse2(int16_t **src, float **matrix, int len,
|
||||
int out_ch, int in_ch);
|
||||
void ff_mix_2_to_1_s16p_flt_sse4(int16_t **src, float **matrix, int len,
|
||||
int out_ch, int in_ch);
|
||||
|
||||
void ff_mix_2_to_1_s16p_q8_sse2(int16_t **src, int16_t **matrix,
|
||||
int len, int out_ch, int in_ch);
|
||||
|
||||
void ff_mix_1_to_2_fltp_flt_sse(float **src, float **matrix, int len,
|
||||
int out_ch, int in_ch);
|
||||
void ff_mix_1_to_2_fltp_flt_avx(float **src, float **matrix, int len,
|
||||
int out_ch, int in_ch);
|
||||
|
||||
void ff_mix_1_to_2_s16p_flt_sse2(int16_t **src, float **matrix, int len,
|
||||
int out_ch, int in_ch);
|
||||
void ff_mix_1_to_2_s16p_flt_sse4(int16_t **src, float **matrix, int len,
|
||||
int out_ch, int in_ch);
|
||||
void ff_mix_1_to_2_s16p_flt_avx (int16_t **src, float **matrix, int len,
|
||||
int out_ch, int in_ch);
|
||||
|
||||
#define DEFINE_MIX_3_8_TO_1_2(chan) \
|
||||
void ff_mix_ ## chan ## _to_1_fltp_flt_sse(float **src, \
|
||||
float **matrix, int len, \
|
||||
int out_ch, int in_ch); \
|
||||
void ff_mix_ ## chan ## _to_2_fltp_flt_sse(float **src, \
|
||||
float **matrix, int len, \
|
||||
int out_ch, int in_ch); \
|
||||
\
|
||||
void ff_mix_ ## chan ## _to_1_s16p_flt_sse2(int16_t **src, \
|
||||
float **matrix, int len, \
|
||||
int out_ch, int in_ch); \
|
||||
void ff_mix_ ## chan ## _to_2_s16p_flt_sse2(int16_t **src, \
|
||||
float **matrix, int len, \
|
||||
int out_ch, int in_ch); \
|
||||
\
|
||||
void ff_mix_ ## chan ## _to_1_s16p_flt_sse4(int16_t **src, \
|
||||
float **matrix, int len, \
|
||||
int out_ch, int in_ch); \
|
||||
void ff_mix_ ## chan ## _to_2_s16p_flt_sse4(int16_t **src, \
|
||||
float **matrix, int len, \
|
||||
int out_ch, int in_ch); \
|
||||
\
|
||||
void ff_mix_ ## chan ## _to_1_fltp_flt_avx(float **src, \
|
||||
float **matrix, int len, \
|
||||
int out_ch, int in_ch); \
|
||||
void ff_mix_ ## chan ## _to_2_fltp_flt_avx(float **src, \
|
||||
float **matrix, int len, \
|
||||
int out_ch, int in_ch); \
|
||||
\
|
||||
void ff_mix_ ## chan ## _to_1_s16p_flt_avx(int16_t **src, \
|
||||
float **matrix, int len, \
|
||||
int out_ch, int in_ch); \
|
||||
void ff_mix_ ## chan ## _to_2_s16p_flt_avx(int16_t **src, \
|
||||
float **matrix, int len, \
|
||||
int out_ch, int in_ch); \
|
||||
\
|
||||
void ff_mix_ ## chan ## _to_1_fltp_flt_fma4(float **src, \
|
||||
float **matrix, int len, \
|
||||
int out_ch, int in_ch); \
|
||||
void ff_mix_ ## chan ## _to_2_fltp_flt_fma4(float **src, \
|
||||
float **matrix, int len, \
|
||||
int out_ch, int in_ch); \
|
||||
\
|
||||
void ff_mix_ ## chan ## _to_1_s16p_flt_fma4(int16_t **src, \
|
||||
float **matrix, int len, \
|
||||
int out_ch, int in_ch); \
|
||||
void ff_mix_ ## chan ## _to_2_s16p_flt_fma4(int16_t **src, \
|
||||
float **matrix, int len, \
|
||||
int out_ch, int in_ch);
|
||||
|
||||
DEFINE_MIX_3_8_TO_1_2(3)
|
||||
DEFINE_MIX_3_8_TO_1_2(4)
|
||||
DEFINE_MIX_3_8_TO_1_2(5)
|
||||
DEFINE_MIX_3_8_TO_1_2(6)
|
||||
DEFINE_MIX_3_8_TO_1_2(7)
|
||||
DEFINE_MIX_3_8_TO_1_2(8)
|
||||
|
||||
#define SET_MIX_3_8_TO_1_2(chan) \
|
||||
if (EXTERNAL_SSE(cpu_flags)) { \
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,\
|
||||
chan, 1, 16, 4, "SSE", \
|
||||
ff_mix_ ## chan ## _to_1_fltp_flt_sse); \
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,\
|
||||
chan, 2, 16, 4, "SSE", \
|
||||
ff_mix_## chan ##_to_2_fltp_flt_sse); \
|
||||
} \
|
||||
if (EXTERNAL_SSE2(cpu_flags)) { \
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
|
||||
chan, 1, 16, 8, "SSE2", \
|
||||
ff_mix_ ## chan ## _to_1_s16p_flt_sse2); \
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
|
||||
chan, 2, 16, 8, "SSE2", \
|
||||
ff_mix_ ## chan ## _to_2_s16p_flt_sse2); \
|
||||
} \
|
||||
if (EXTERNAL_SSE4(cpu_flags)) { \
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
|
||||
chan, 1, 16, 8, "SSE4", \
|
||||
ff_mix_ ## chan ## _to_1_s16p_flt_sse4); \
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
|
||||
chan, 2, 16, 8, "SSE4", \
|
||||
ff_mix_ ## chan ## _to_2_s16p_flt_sse4); \
|
||||
} \
|
||||
if (EXTERNAL_AVX(cpu_flags)) { \
|
||||
int ptr_align = 32; \
|
||||
int smp_align = 8; \
|
||||
if (ARCH_X86_32 || chan >= 6) { \
|
||||
ptr_align = 16; \
|
||||
smp_align = 4; \
|
||||
} \
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,\
|
||||
chan, 1, ptr_align, smp_align, "AVX", \
|
||||
ff_mix_ ## chan ## _to_1_fltp_flt_avx); \
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,\
|
||||
chan, 2, ptr_align, smp_align, "AVX", \
|
||||
ff_mix_ ## chan ## _to_2_fltp_flt_avx); \
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
|
||||
chan, 1, 16, 8, "AVX", \
|
||||
ff_mix_ ## chan ## _to_1_s16p_flt_avx); \
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
|
||||
chan, 2, 16, 8, "AVX", \
|
||||
ff_mix_ ## chan ## _to_2_s16p_flt_avx); \
|
||||
} \
|
||||
if (EXTERNAL_FMA4(cpu_flags)) { \
|
||||
int ptr_align = 32; \
|
||||
int smp_align = 8; \
|
||||
if (ARCH_X86_32 || chan >= 6) { \
|
||||
ptr_align = 16; \
|
||||
smp_align = 4; \
|
||||
} \
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,\
|
||||
chan, 1, ptr_align, smp_align, "FMA4", \
|
||||
ff_mix_ ## chan ## _to_1_fltp_flt_fma4); \
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,\
|
||||
chan, 2, ptr_align, smp_align, "FMA4", \
|
||||
ff_mix_ ## chan ## _to_2_fltp_flt_fma4); \
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
|
||||
chan, 1, 16, 8, "FMA4", \
|
||||
ff_mix_ ## chan ## _to_1_s16p_flt_fma4); \
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
|
||||
chan, 2, 16, 8, "FMA4", \
|
||||
ff_mix_ ## chan ## _to_2_s16p_flt_fma4); \
|
||||
}
|
||||
|
||||
av_cold void ff_audio_mix_init_x86(AudioMix *am)
|
||||
{
|
||||
#if HAVE_YASM
|
||||
int cpu_flags = av_get_cpu_flags();
|
||||
|
||||
if (EXTERNAL_SSE(cpu_flags)) {
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
|
||||
2, 1, 16, 8, "SSE", ff_mix_2_to_1_fltp_flt_sse);
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
|
||||
1, 2, 16, 4, "SSE", ff_mix_1_to_2_fltp_flt_sse);
|
||||
}
|
||||
if (EXTERNAL_SSE2(cpu_flags)) {
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,
|
||||
2, 1, 16, 8, "SSE2", ff_mix_2_to_1_s16p_flt_sse2);
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_Q8,
|
||||
2, 1, 16, 8, "SSE2", ff_mix_2_to_1_s16p_q8_sse2);
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,
|
||||
1, 2, 16, 8, "SSE2", ff_mix_1_to_2_s16p_flt_sse2);
|
||||
}
|
||||
if (EXTERNAL_SSE4(cpu_flags)) {
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,
|
||||
2, 1, 16, 8, "SSE4", ff_mix_2_to_1_s16p_flt_sse4);
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,
|
||||
1, 2, 16, 8, "SSE4", ff_mix_1_to_2_s16p_flt_sse4);
|
||||
}
|
||||
if (EXTERNAL_AVX(cpu_flags)) {
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
|
||||
2, 1, 32, 16, "AVX", ff_mix_2_to_1_fltp_flt_avx);
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
|
||||
1, 2, 32, 8, "AVX", ff_mix_1_to_2_fltp_flt_avx);
|
||||
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,
|
||||
1, 2, 16, 8, "AVX", ff_mix_1_to_2_s16p_flt_avx);
|
||||
}
|
||||
|
||||
SET_MIX_3_8_TO_1_2(3)
|
||||
SET_MIX_3_8_TO_1_2(4)
|
||||
SET_MIX_3_8_TO_1_2(5)
|
||||
SET_MIX_3_8_TO_1_2(6)
|
||||
SET_MIX_3_8_TO_1_2(7)
|
||||
SET_MIX_3_8_TO_1_2(8)
|
||||
#endif /* HAVE_YASM */
|
||||
}
|
@@ -0,0 +1,117 @@
|
||||
;******************************************************************************
|
||||
;* x86 optimized dithering format conversion
|
||||
;* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
|
||||
;*
|
||||
;* 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_RODATA 32
|
||||
|
||||
; 1.0f / (2.0f * INT32_MAX)
|
||||
pf_dither_scale: times 8 dd 2.32830643762e-10
|
||||
|
||||
pf_s16_scale: times 4 dd 32753.0
|
||||
|
||||
SECTION_TEXT
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; void ff_quantize(int16_t *dst, float *src, float *dither, int len);
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
INIT_XMM sse2
|
||||
cglobal quantize, 4,4,3, dst, src, dither, len
|
||||
lea lenq, [2*lend]
|
||||
add dstq, lenq
|
||||
lea srcq, [srcq+2*lenq]
|
||||
lea ditherq, [ditherq+2*lenq]
|
||||
neg lenq
|
||||
mova m2, [pf_s16_scale]
|
||||
.loop:
|
||||
mulps m0, m2, [srcq+2*lenq]
|
||||
mulps m1, m2, [srcq+2*lenq+mmsize]
|
||||
addps m0, [ditherq+2*lenq]
|
||||
addps m1, [ditherq+2*lenq+mmsize]
|
||||
cvtps2dq m0, m0
|
||||
cvtps2dq m1, m1
|
||||
packssdw m0, m1
|
||||
mova [dstq+lenq], m0
|
||||
add lenq, mmsize
|
||||
jl .loop
|
||||
REP_RET
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; void ff_dither_int_to_float_rectangular(float *dst, int *src, int len)
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
%macro DITHER_INT_TO_FLOAT_RECTANGULAR 0
|
||||
cglobal dither_int_to_float_rectangular, 3,3,3, dst, src, len
|
||||
lea lenq, [4*lend]
|
||||
add srcq, lenq
|
||||
add dstq, lenq
|
||||
neg lenq
|
||||
mova m0, [pf_dither_scale]
|
||||
.loop:
|
||||
cvtdq2ps m1, [srcq+lenq]
|
||||
cvtdq2ps m2, [srcq+lenq+mmsize]
|
||||
mulps m1, m1, m0
|
||||
mulps m2, m2, m0
|
||||
mova [dstq+lenq], m1
|
||||
mova [dstq+lenq+mmsize], m2
|
||||
add lenq, 2*mmsize
|
||||
jl .loop
|
||||
REP_RET
|
||||
%endmacro
|
||||
|
||||
INIT_XMM sse2
|
||||
DITHER_INT_TO_FLOAT_RECTANGULAR
|
||||
INIT_YMM avx
|
||||
DITHER_INT_TO_FLOAT_RECTANGULAR
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; void ff_dither_int_to_float_triangular(float *dst, int *src0, int len)
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
%macro DITHER_INT_TO_FLOAT_TRIANGULAR 0
|
||||
cglobal dither_int_to_float_triangular, 3,4,5, dst, src0, len, src1
|
||||
lea lenq, [4*lend]
|
||||
lea src1q, [src0q+2*lenq]
|
||||
add src0q, lenq
|
||||
add dstq, lenq
|
||||
neg lenq
|
||||
mova m0, [pf_dither_scale]
|
||||
.loop:
|
||||
cvtdq2ps m1, [src0q+lenq]
|
||||
cvtdq2ps m2, [src0q+lenq+mmsize]
|
||||
cvtdq2ps m3, [src1q+lenq]
|
||||
cvtdq2ps m4, [src1q+lenq+mmsize]
|
||||
addps m1, m1, m3
|
||||
addps m2, m2, m4
|
||||
mulps m1, m1, m0
|
||||
mulps m2, m2, m0
|
||||
mova [dstq+lenq], m1
|
||||
mova [dstq+lenq+mmsize], m2
|
||||
add lenq, 2*mmsize
|
||||
jl .loop
|
||||
REP_RET
|
||||
%endmacro
|
||||
|
||||
INIT_XMM sse2
|
||||
DITHER_INT_TO_FLOAT_TRIANGULAR
|
||||
INIT_YMM avx
|
||||
DITHER_INT_TO_FLOAT_TRIANGULAR
|
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
|
||||
*
|
||||
* 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/cpu.h"
|
||||
#include "libavutil/x86/cpu.h"
|
||||
#include "libavresample/dither.h"
|
||||
|
||||
void ff_quantize_sse2(int16_t *dst, const float *src, float *dither, int len);
|
||||
|
||||
void ff_dither_int_to_float_rectangular_sse2(float *dst, int *src, int len);
|
||||
void ff_dither_int_to_float_rectangular_avx(float *dst, int *src, int len);
|
||||
|
||||
void ff_dither_int_to_float_triangular_sse2(float *dst, int *src0, int len);
|
||||
void ff_dither_int_to_float_triangular_avx(float *dst, int *src0, int len);
|
||||
|
||||
av_cold void ff_dither_init_x86(DitherDSPContext *ddsp,
|
||||
enum AVResampleDitherMethod method)
|
||||
{
|
||||
int cpu_flags = av_get_cpu_flags();
|
||||
|
||||
if (EXTERNAL_SSE2(cpu_flags)) {
|
||||
ddsp->quantize = ff_quantize_sse2;
|
||||
ddsp->ptr_align = 16;
|
||||
ddsp->samples_align = 8;
|
||||
}
|
||||
|
||||
if (method == AV_RESAMPLE_DITHER_RECTANGULAR) {
|
||||
if (EXTERNAL_SSE2(cpu_flags)) {
|
||||
ddsp->dither_int_to_float = ff_dither_int_to_float_rectangular_sse2;
|
||||
}
|
||||
if (EXTERNAL_AVX(cpu_flags)) {
|
||||
ddsp->dither_int_to_float = ff_dither_int_to_float_rectangular_avx;
|
||||
}
|
||||
} else {
|
||||
if (EXTERNAL_SSE2(cpu_flags)) {
|
||||
ddsp->dither_int_to_float = ff_dither_int_to_float_triangular_sse2;
|
||||
}
|
||||
if (EXTERNAL_AVX(cpu_flags)) {
|
||||
ddsp->dither_int_to_float = ff_dither_int_to_float_triangular_avx;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
;******************************************************************************
|
||||
;* x86 utility macros for libavresample
|
||||
;* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
|
||||
;*
|
||||
;* 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
|
||||
;******************************************************************************
|
||||
|
||||
%macro S16_TO_S32_SX 2 ; src/low dst, high dst
|
||||
%if cpuflag(sse4)
|
||||
pmovsxwd m%2, m%1
|
||||
psrldq m%1, 8
|
||||
pmovsxwd m%1, m%1
|
||||
SWAP %1, %2
|
||||
%else
|
||||
mova m%2, m%1
|
||||
punpckhwd m%2, m%2
|
||||
punpcklwd m%1, m%1
|
||||
psrad m%2, 16
|
||||
psrad m%1, 16
|
||||
%endif
|
||||
%endmacro
|
||||
|
||||
%macro DEINT2_PS 3 ; src0/even dst, src1/odd dst, temp
|
||||
shufps m%3, m%1, m%2, q3131
|
||||
shufps m%1, m%2, q2020
|
||||
SWAP %2,%3
|
||||
%endmacro
|
Reference in New Issue
Block a user