2014-06-14 20:11:03 +02:00
|
|
|
/*
|
|
|
|
* audio resampling
|
|
|
|
* Copyright (c) 2004-2012 Michael Niedermayer <michaelni@gmx.at>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* audio resampling
|
|
|
|
* @author Michael Niedermayer <michaelni@gmx.at>
|
|
|
|
*/
|
|
|
|
|
2014-07-03 03:16:50 +02:00
|
|
|
#include "libavutil/x86/cpu.h"
|
2014-06-14 20:11:03 +02:00
|
|
|
#include "libswresample/resample.h"
|
|
|
|
|
2014-06-30 18:06:01 +02:00
|
|
|
#define RESAMPLE_FUNCS(type, opt) \
|
2014-07-03 03:16:48 +02:00
|
|
|
int ff_resample_common_##type##_##opt(ResampleContext *c, void *dst, \
|
|
|
|
const void *src, int sz, int upd); \
|
|
|
|
int ff_resample_linear_##type##_##opt(ResampleContext *c, void *dst, \
|
|
|
|
const void *src, int sz, int upd)
|
2014-06-30 01:19:03 +02:00
|
|
|
|
2014-06-30 18:06:01 +02:00
|
|
|
RESAMPLE_FUNCS(int16, mmxext);
|
|
|
|
RESAMPLE_FUNCS(int16, sse2);
|
2014-06-30 18:06:02 +02:00
|
|
|
RESAMPLE_FUNCS(int16, xop);
|
2014-06-30 18:06:01 +02:00
|
|
|
RESAMPLE_FUNCS(float, sse);
|
|
|
|
RESAMPLE_FUNCS(float, avx);
|
|
|
|
RESAMPLE_FUNCS(float, fma3);
|
|
|
|
RESAMPLE_FUNCS(float, fma4);
|
|
|
|
RESAMPLE_FUNCS(double, sse2);
|
2014-06-30 18:06:00 +02:00
|
|
|
|
2015-02-20 23:55:52 +01:00
|
|
|
av_cold void swri_resample_dsp_x86_init(ResampleContext *c)
|
2014-06-14 20:11:03 +02:00
|
|
|
{
|
|
|
|
int av_unused mm_flags = av_get_cpu_flags();
|
|
|
|
|
2014-07-03 03:16:48 +02:00
|
|
|
switch(c->format){
|
|
|
|
case AV_SAMPLE_FMT_S16P:
|
2014-07-03 03:16:50 +02:00
|
|
|
if (ARCH_X86_32 && EXTERNAL_MMXEXT(mm_flags)) {
|
2014-07-03 03:16:48 +02:00
|
|
|
c->dsp.resample = c->linear ? ff_resample_linear_int16_mmxext
|
|
|
|
: ff_resample_common_int16_mmxext;
|
|
|
|
}
|
2014-07-03 03:16:50 +02:00
|
|
|
if (EXTERNAL_SSE2(mm_flags)) {
|
2014-07-03 03:16:48 +02:00
|
|
|
c->dsp.resample = c->linear ? ff_resample_linear_int16_sse2
|
|
|
|
: ff_resample_common_int16_sse2;
|
|
|
|
}
|
2014-07-03 03:16:50 +02:00
|
|
|
if (EXTERNAL_XOP(mm_flags)) {
|
2014-07-03 03:16:48 +02:00
|
|
|
c->dsp.resample = c->linear ? ff_resample_linear_int16_xop
|
|
|
|
: ff_resample_common_int16_xop;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AV_SAMPLE_FMT_FLTP:
|
2014-07-03 03:16:50 +02:00
|
|
|
if (EXTERNAL_SSE(mm_flags)) {
|
2014-07-03 03:16:48 +02:00
|
|
|
c->dsp.resample = c->linear ? ff_resample_linear_float_sse
|
|
|
|
: ff_resample_common_float_sse;
|
|
|
|
}
|
2015-05-31 19:20:29 +02:00
|
|
|
if (EXTERNAL_AVX_FAST(mm_flags)) {
|
2014-07-03 03:16:48 +02:00
|
|
|
c->dsp.resample = c->linear ? ff_resample_linear_float_avx
|
|
|
|
: ff_resample_common_float_avx;
|
|
|
|
}
|
2015-05-31 19:20:29 +02:00
|
|
|
if (EXTERNAL_FMA3(mm_flags) && !(mm_flags & AV_CPU_FLAG_AVXSLOW)) {
|
2014-07-03 03:16:48 +02:00
|
|
|
c->dsp.resample = c->linear ? ff_resample_linear_float_fma3
|
|
|
|
: ff_resample_common_float_fma3;
|
|
|
|
}
|
2014-07-03 03:16:50 +02:00
|
|
|
if (EXTERNAL_FMA4(mm_flags)) {
|
2014-07-03 03:16:48 +02:00
|
|
|
c->dsp.resample = c->linear ? ff_resample_linear_float_fma4
|
|
|
|
: ff_resample_common_float_fma4;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AV_SAMPLE_FMT_DBLP:
|
2014-07-03 03:16:50 +02:00
|
|
|
if (EXTERNAL_SSE2(mm_flags)) {
|
2014-07-03 03:16:48 +02:00
|
|
|
c->dsp.resample = c->linear ? ff_resample_linear_double_sse2
|
|
|
|
: ff_resample_common_double_sse2;
|
|
|
|
}
|
|
|
|
break;
|
2014-06-30 18:06:02 +02:00
|
|
|
}
|
2014-06-14 20:11:03 +02:00
|
|
|
}
|