Commit 7205513f authored by Ivan Kalvachev's avatar Ivan Kalvachev Committed by Rostislav Pehlivanov

SIMD opus pvq_search implementation

Explanation on the workings and methods used by the
Pyramid Vector Quantization Search function
could be found in the following Work-In-Progress mail threads:
http://ffmpeg.org/pipermail/ffmpeg-devel/2017-June/212146.html
http://ffmpeg.org/pipermail/ffmpeg-devel/2017-June/212816.html
http://ffmpeg.org/pipermail/ffmpeg-devel/2017-July/213030.html
http://ffmpeg.org/pipermail/ffmpeg-devel/2017-July/213436.htmlSigned-off-by: 's avatarIvan Kalvachev <ikalvachev@gmail.com>
parent 30ae07d7
...@@ -947,6 +947,9 @@ int av_cold ff_celt_pvq_init(CeltPVQ **pvq) ...@@ -947,6 +947,9 @@ int av_cold ff_celt_pvq_init(CeltPVQ **pvq)
s->encode_band = pvq_encode_band; s->encode_band = pvq_encode_band;
s->band_cost = pvq_band_cost; s->band_cost = pvq_band_cost;
if (ARCH_X86)
ff_opus_dsp_init_x86(s);
*pvq = s; *pvq = s;
return 0; return 0;
......
...@@ -33,8 +33,8 @@ ...@@ -33,8 +33,8 @@
float *lowband_scratch, int fill) float *lowband_scratch, int fill)
struct CeltPVQ { struct CeltPVQ {
DECLARE_ALIGNED(32, int, qcoeff )[176]; DECLARE_ALIGNED(32, int, qcoeff )[256];
DECLARE_ALIGNED(32, float, hadamard_tmp)[176]; DECLARE_ALIGNED(32, float, hadamard_tmp)[256];
float (*pvq_search)(float *X, int *y, int K, int N); float (*pvq_search)(float *X, int *y, int K, int N);
...@@ -45,6 +45,7 @@ struct CeltPVQ { ...@@ -45,6 +45,7 @@ struct CeltPVQ {
}; };
int ff_celt_pvq_init (struct CeltPVQ **pvq); int ff_celt_pvq_init (struct CeltPVQ **pvq);
void ff_opus_dsp_init_x86(struct CeltPVQ *s);
void ff_celt_pvq_uninit(struct CeltPVQ **pvq); void ff_celt_pvq_uninit(struct CeltPVQ **pvq);
#endif /* AVCODEC_OPUS_PVQ_H */ #endif /* AVCODEC_OPUS_PVQ_H */
...@@ -52,6 +52,8 @@ OBJS-$(CONFIG_APNG_DECODER) += x86/pngdsp_init.o ...@@ -52,6 +52,8 @@ OBJS-$(CONFIG_APNG_DECODER) += x86/pngdsp_init.o
OBJS-$(CONFIG_CAVS_DECODER) += x86/cavsdsp.o OBJS-$(CONFIG_CAVS_DECODER) += x86/cavsdsp.o
OBJS-$(CONFIG_DCA_DECODER) += x86/dcadsp_init.o x86/synth_filter_init.o OBJS-$(CONFIG_DCA_DECODER) += x86/dcadsp_init.o x86/synth_filter_init.o
OBJS-$(CONFIG_DNXHD_ENCODER) += x86/dnxhdenc_init.o OBJS-$(CONFIG_DNXHD_ENCODER) += x86/dnxhdenc_init.o
OBJS-$(CONFIG_OPUS_DECODER) += x86/opus_dsp_init.o
OBJS-$(CONFIG_OPUS_ENCODER) += x86/opus_dsp_init.o
OBJS-$(CONFIG_HEVC_DECODER) += x86/hevcdsp_init.o OBJS-$(CONFIG_HEVC_DECODER) += x86/hevcdsp_init.o
OBJS-$(CONFIG_JPEG2000_DECODER) += x86/jpeg2000dsp_init.o OBJS-$(CONFIG_JPEG2000_DECODER) += x86/jpeg2000dsp_init.o
OBJS-$(CONFIG_MLP_DECODER) += x86/mlpdsp_init.o OBJS-$(CONFIG_MLP_DECODER) += x86/mlpdsp_init.o
...@@ -123,6 +125,7 @@ X86ASM-OBJS-$(CONFIG_MDCT15) += x86/mdct15.o ...@@ -123,6 +125,7 @@ X86ASM-OBJS-$(CONFIG_MDCT15) += x86/mdct15.o
X86ASM-OBJS-$(CONFIG_ME_CMP) += x86/me_cmp.o X86ASM-OBJS-$(CONFIG_ME_CMP) += x86/me_cmp.o
X86ASM-OBJS-$(CONFIG_MPEGAUDIODSP) += x86/imdct36.o X86ASM-OBJS-$(CONFIG_MPEGAUDIODSP) += x86/imdct36.o
X86ASM-OBJS-$(CONFIG_MPEGVIDEOENC) += x86/mpegvideoencdsp.o X86ASM-OBJS-$(CONFIG_MPEGVIDEOENC) += x86/mpegvideoencdsp.o
X86ASM-OBJS-$(CONFIG_OPUS_ENCODER) += x86/opus_pvq_search.o
X86ASM-OBJS-$(CONFIG_PIXBLOCKDSP) += x86/pixblockdsp.o X86ASM-OBJS-$(CONFIG_PIXBLOCKDSP) += x86/pixblockdsp.o
X86ASM-OBJS-$(CONFIG_QPELDSP) += x86/qpeldsp.o \ X86ASM-OBJS-$(CONFIG_QPELDSP) += x86/qpeldsp.o \
x86/fpel.o \ x86/fpel.o \
......
/*
* Opus encoder assembly optimizations
* Copyright (C) 2017 Ivan Kalvachev <ikalvachev@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/x86/cpu.h"
#include "libavcodec/opus_pvq.h"
extern float ff_pvq_search_sse2(float *X, int *y, int K, int N);
extern float ff_pvq_search_sse4(float *X, int *y, int K, int N);
extern float ff_pvq_search_avx (float *X, int *y, int K, int N);
av_cold void ff_opus_dsp_init_x86(CeltPVQ *s)
{
int cpu_flags = av_get_cpu_flags();
#if CONFIG_OPUS_ENCODER
if (EXTERNAL_SSE2(cpu_flags))
s->pvq_search = ff_pvq_search_sse2;
if (EXTERNAL_SSE4(cpu_flags))
s->pvq_search = ff_pvq_search_sse4;
if (EXTERNAL_AVX(cpu_flags))
s->pvq_search = ff_pvq_search_avx;
#endif
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment