2012-09-23 18:49:26 +00:00
|
|
|
/*
|
2012-12-06 14:43:34 +00:00
|
|
|
* This file is part of FFmpeg.
|
2012-09-23 18:49:26 +00:00
|
|
|
*
|
2012-12-06 14:43:34 +00:00
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2012-09-23 18:49:26 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2012-12-06 14:43:34 +00:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2012-09-23 18:49:26 +00:00
|
|
|
* 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
|
2012-12-06 14:43:34 +00:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2012-09-23 18:49:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "libavutil/cpu.h"
|
|
|
|
#include "libavutil/samplefmt.h"
|
|
|
|
#include "libavutil/x86/cpu.h"
|
|
|
|
#include "libavfilter/af_volume.h"
|
|
|
|
|
|
|
|
void ff_scale_samples_s16_sse2(uint8_t *dst, const uint8_t *src, int len,
|
|
|
|
int volume);
|
|
|
|
|
2012-09-25 12:41:39 +00:00
|
|
|
void ff_scale_samples_s32_sse2(uint8_t *dst, const uint8_t *src, int len,
|
|
|
|
int volume);
|
|
|
|
void ff_scale_samples_s32_ssse3_atom(uint8_t *dst, const uint8_t *src, int len,
|
|
|
|
int volume);
|
|
|
|
void ff_scale_samples_s32_avx(uint8_t *dst, const uint8_t *src, int len,
|
|
|
|
int volume);
|
|
|
|
|
2012-09-23 18:49:26 +00:00
|
|
|
void ff_volume_init_x86(VolumeContext *vol)
|
|
|
|
{
|
|
|
|
int mm_flags = av_get_cpu_flags();
|
|
|
|
enum AVSampleFormat sample_fmt = av_get_packed_sample_fmt(vol->sample_fmt);
|
|
|
|
|
|
|
|
if (sample_fmt == AV_SAMPLE_FMT_S16) {
|
|
|
|
if (EXTERNAL_SSE2(mm_flags) && vol->volume_i < 32768) {
|
|
|
|
vol->scale_samples = ff_scale_samples_s16_sse2;
|
|
|
|
vol->samples_align = 8;
|
|
|
|
}
|
2012-09-25 12:41:39 +00:00
|
|
|
} else if (sample_fmt == AV_SAMPLE_FMT_S32) {
|
|
|
|
if (EXTERNAL_SSE2(mm_flags)) {
|
|
|
|
vol->scale_samples = ff_scale_samples_s32_sse2;
|
|
|
|
vol->samples_align = 4;
|
|
|
|
}
|
|
|
|
if (EXTERNAL_SSSE3(mm_flags) && mm_flags & AV_CPU_FLAG_ATOM) {
|
|
|
|
vol->scale_samples = ff_scale_samples_s32_ssse3_atom;
|
|
|
|
vol->samples_align = 4;
|
|
|
|
}
|
|
|
|
if (EXTERNAL_AVX(mm_flags)) {
|
|
|
|
vol->scale_samples = ff_scale_samples_s32_avx;
|
|
|
|
vol->samples_align = 8;
|
|
|
|
}
|
2012-09-23 18:49:26 +00:00
|
|
|
}
|
|
|
|
}
|