mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-07 13:49:53 +00:00
To do so, simply add these init files to X86ASM-OBJS instead of OBJS in the Makefile. The former is already used for the actual assembly files, but using them for the C init files just works, because the build system uses file extensions to derive whether it is a C or a NASM file. This avoids compiling unused function stubs and also reduces our reliance on DCE: We don't add %if checks to the asm files except for AVX, AVX2, FMA3, FMA4, XOP and AVX512, so all the MMX-SSE4 functions will be available. It also allows to remove HAVE_X86ASM checks in these init files. (x86/ops.c has already been put in X86ASM-OBJS.) Reviewed-by: Kacper Michajłow <kasper93@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
83 lines
3 KiB
C
83 lines
3 KiB
C
/*
|
|
* Copyright (C) 2012 Michael Niedermayer (michaelni@gmx.at)
|
|
*
|
|
* This file is part of libswresample
|
|
*
|
|
* libswresample 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.
|
|
*
|
|
* libswresample 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 libswresample; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#include "libavutil/attributes.h"
|
|
#include "libavutil/mem.h"
|
|
#include "libavutil/x86/cpu.h"
|
|
#include "libswresample/swresample_internal.h"
|
|
|
|
#define D(type, simd) \
|
|
mix_1_1_func_type ff_mix_1_1_a_## type ## _ ## simd;\
|
|
mix_2_1_func_type ff_mix_2_1_a_## type ## _ ## simd;
|
|
|
|
D(float, sse)
|
|
D(float, avx)
|
|
D(int16, sse2)
|
|
|
|
av_cold int swri_rematrix_init_x86(struct SwrContext *s){
|
|
int mm_flags = av_get_cpu_flags();
|
|
int nb_in = s->used_ch_layout.nb_channels;
|
|
int nb_out = s->out.ch_count;
|
|
int num = nb_in * nb_out;
|
|
int i,j;
|
|
|
|
s->mix_1_1_simd = NULL;
|
|
s->mix_2_1_simd = NULL;
|
|
|
|
if (s->midbuf.fmt == AV_SAMPLE_FMT_S16P){
|
|
if(EXTERNAL_SSE2(mm_flags)) {
|
|
s->mix_1_1_simd = ff_mix_1_1_a_int16_sse2;
|
|
s->mix_2_1_simd = ff_mix_2_1_a_int16_sse2;
|
|
}
|
|
s->native_simd_matrix = av_calloc(num, 2 * sizeof(int16_t));
|
|
if (!s->native_simd_matrix)
|
|
return AVERROR(ENOMEM);
|
|
|
|
for(i=0; i<nb_out; i++){
|
|
int sh = 0;
|
|
for(j=0; j<nb_in; j++)
|
|
sh = FFMAX(sh, FFABS(((int*)s->native_matrix)[i * nb_in + j]));
|
|
sh = FFMAX(av_log2(sh) - 14, 0);
|
|
for(j=0; j<nb_in; j++) {
|
|
((int16_t*)s->native_simd_matrix)[2*(i * nb_in + j)+1] = 15 - sh;
|
|
((int16_t*)s->native_simd_matrix)[2*(i * nb_in + j)] =
|
|
((((int*)s->native_matrix)[i * nb_in + j]) + (1<<sh>>1)) >> sh;
|
|
}
|
|
}
|
|
s->native_simd_one.i16[1] = 14;
|
|
s->native_simd_one.i16[0] = 16384;
|
|
} else if(s->midbuf.fmt == AV_SAMPLE_FMT_FLTP){
|
|
if(EXTERNAL_SSE(mm_flags)) {
|
|
s->mix_1_1_simd = ff_mix_1_1_a_float_sse;
|
|
s->mix_2_1_simd = ff_mix_2_1_a_float_sse;
|
|
}
|
|
if(EXTERNAL_AVX_FAST(mm_flags)) {
|
|
s->mix_1_1_simd = ff_mix_1_1_a_float_avx;
|
|
s->mix_2_1_simd = ff_mix_2_1_a_float_avx;
|
|
}
|
|
s->native_simd_matrix = av_calloc(num, sizeof(float));
|
|
if (!s->native_simd_matrix)
|
|
return AVERROR(ENOMEM);
|
|
memcpy(s->native_simd_matrix, s->native_matrix, num * sizeof(float));
|
|
s->native_simd_one.f = s->native_one.f;
|
|
}
|
|
|
|
return 0;
|
|
}
|