summaryrefslogtreecommitdiffstats
path: root/libavfilter/x86/af_volume_init.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-09-23 14:49:26 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2012-12-05 11:23:37 -0500
commitf96f1e06a47ebd124dd0b1369f3fdd0f8f25d773 (patch)
tree409a426308dbda9188acbdaabd446b11aedf3204 /libavfilter/x86/af_volume_init.c
parentb384e031daeb1ac612620985e3e5377bc587559c (diff)
downloadffmpeg-streaming-f96f1e06a47ebd124dd0b1369f3fdd0f8f25d773.zip
ffmpeg-streaming-f96f1e06a47ebd124dd0b1369f3fdd0f8f25d773.tar.gz
x86: af_volume: add SSE2-optimized s16 volume scaling
Diffstat (limited to 'libavfilter/x86/af_volume_init.c')
-rw-r--r--libavfilter/x86/af_volume_init.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/libavfilter/x86/af_volume_init.c b/libavfilter/x86/af_volume_init.c
new file mode 100644
index 0000000..00103df
--- /dev/null
+++ b/libavfilter/x86/af_volume_init.c
@@ -0,0 +1,39 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; 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/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);
+
+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;
+ }
+ }
+}
OpenPOWER on IntegriCloud