00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "config.h"
00022 #include "libavutil/cpu.h"
00023 #include "libavutil/x86/cpu.h"
00024 #include "libavresample/audio_mix.h"
00025
00026 extern void ff_mix_2_to_1_fltp_flt_sse(float **src, float **matrix, int len,
00027 int out_ch, int in_ch);
00028 extern void ff_mix_2_to_1_fltp_flt_avx(float **src, float **matrix, int len,
00029 int out_ch, int in_ch);
00030
00031 extern void ff_mix_2_to_1_s16p_flt_sse2(int16_t **src, float **matrix, int len,
00032 int out_ch, int in_ch);
00033 extern void ff_mix_2_to_1_s16p_flt_sse4(int16_t **src, float **matrix, int len,
00034 int out_ch, int in_ch);
00035
00036 extern void ff_mix_2_to_1_s16p_q8_sse2(int16_t **src, int16_t **matrix,
00037 int len, int out_ch, int in_ch);
00038
00039 extern void ff_mix_1_to_2_fltp_flt_sse(float **src, float **matrix, int len,
00040 int out_ch, int in_ch);
00041 extern void ff_mix_1_to_2_fltp_flt_avx(float **src, float **matrix, int len,
00042 int out_ch, int in_ch);
00043
00044 extern void ff_mix_1_to_2_s16p_flt_sse2(int16_t **src, float **matrix, int len,
00045 int out_ch, int in_ch);
00046 extern void ff_mix_1_to_2_s16p_flt_sse4(int16_t **src, float **matrix, int len,
00047 int out_ch, int in_ch);
00048 extern void ff_mix_1_to_2_s16p_flt_avx (int16_t **src, float **matrix, int len,
00049 int out_ch, int in_ch);
00050
00051 #define DEFINE_MIX_3_8_TO_1_2(chan) \
00052 extern void ff_mix_ ## chan ## _to_1_fltp_flt_sse(float **src, \
00053 float **matrix, int len, \
00054 int out_ch, int in_ch); \
00055 extern void ff_mix_ ## chan ## _to_2_fltp_flt_sse(float **src, \
00056 float **matrix, int len, \
00057 int out_ch, int in_ch); \
00058 \
00059 extern void ff_mix_ ## chan ## _to_1_s16p_flt_sse2(int16_t **src, \
00060 float **matrix, int len, \
00061 int out_ch, int in_ch); \
00062 extern void ff_mix_ ## chan ## _to_2_s16p_flt_sse2(int16_t **src, \
00063 float **matrix, int len, \
00064 int out_ch, int in_ch); \
00065 \
00066 extern void ff_mix_ ## chan ## _to_1_s16p_flt_sse4(int16_t **src, \
00067 float **matrix, int len, \
00068 int out_ch, int in_ch); \
00069 extern void ff_mix_ ## chan ## _to_2_s16p_flt_sse4(int16_t **src, \
00070 float **matrix, int len, \
00071 int out_ch, int in_ch); \
00072 \
00073 extern void ff_mix_ ## chan ## _to_1_fltp_flt_avx(float **src, \
00074 float **matrix, int len, \
00075 int out_ch, int in_ch); \
00076 extern void ff_mix_ ## chan ## _to_2_fltp_flt_avx(float **src, \
00077 float **matrix, int len, \
00078 int out_ch, int in_ch); \
00079 \
00080 extern void ff_mix_ ## chan ## _to_1_s16p_flt_avx(int16_t **src, \
00081 float **matrix, int len, \
00082 int out_ch, int in_ch); \
00083 extern void ff_mix_ ## chan ## _to_2_s16p_flt_avx(int16_t **src, \
00084 float **matrix, int len, \
00085 int out_ch, int in_ch); \
00086 \
00087 extern void ff_mix_ ## chan ## _to_1_fltp_flt_fma4(float **src, \
00088 float **matrix, int len, \
00089 int out_ch, int in_ch); \
00090 extern void ff_mix_ ## chan ## _to_2_fltp_flt_fma4(float **src, \
00091 float **matrix, int len, \
00092 int out_ch, int in_ch); \
00093 \
00094 extern void ff_mix_ ## chan ## _to_1_s16p_flt_fma4(int16_t **src, \
00095 float **matrix, int len, \
00096 int out_ch, int in_ch); \
00097 extern void ff_mix_ ## chan ## _to_2_s16p_flt_fma4(int16_t **src, \
00098 float **matrix, int len, \
00099 int out_ch, int in_ch);
00100
00101 DEFINE_MIX_3_8_TO_1_2(3)
00102 DEFINE_MIX_3_8_TO_1_2(4)
00103 DEFINE_MIX_3_8_TO_1_2(5)
00104 DEFINE_MIX_3_8_TO_1_2(6)
00105 DEFINE_MIX_3_8_TO_1_2(7)
00106 DEFINE_MIX_3_8_TO_1_2(8)
00107
00108 #define SET_MIX_3_8_TO_1_2(chan) \
00109 if (EXTERNAL_SSE(mm_flags)) { \
00110 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,\
00111 chan, 1, 16, 4, "SSE", \
00112 ff_mix_ ## chan ## _to_1_fltp_flt_sse); \
00113 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,\
00114 chan, 2, 16, 4, "SSE", \
00115 ff_mix_## chan ##_to_2_fltp_flt_sse); \
00116 } \
00117 if (EXTERNAL_SSE2(mm_flags)) { \
00118 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
00119 chan, 1, 16, 8, "SSE2", \
00120 ff_mix_ ## chan ## _to_1_s16p_flt_sse2); \
00121 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
00122 chan, 2, 16, 8, "SSE2", \
00123 ff_mix_ ## chan ## _to_2_s16p_flt_sse2); \
00124 } \
00125 if (EXTERNAL_SSE4(mm_flags)) { \
00126 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
00127 chan, 1, 16, 8, "SSE4", \
00128 ff_mix_ ## chan ## _to_1_s16p_flt_sse4); \
00129 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
00130 chan, 2, 16, 8, "SSE4", \
00131 ff_mix_ ## chan ## _to_2_s16p_flt_sse4); \
00132 } \
00133 if (EXTERNAL_AVX(mm_flags)) { \
00134 int ptr_align = 32; \
00135 int smp_align = 8; \
00136 if (ARCH_X86_32 || chan >= 6) { \
00137 ptr_align = 16; \
00138 smp_align = 4; \
00139 } \
00140 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,\
00141 chan, 1, ptr_align, smp_align, "AVX", \
00142 ff_mix_ ## chan ## _to_1_fltp_flt_avx); \
00143 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,\
00144 chan, 2, ptr_align, smp_align, "AVX", \
00145 ff_mix_ ## chan ## _to_2_fltp_flt_avx); \
00146 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
00147 chan, 1, 16, 8, "AVX", \
00148 ff_mix_ ## chan ## _to_1_s16p_flt_avx); \
00149 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
00150 chan, 2, 16, 8, "AVX", \
00151 ff_mix_ ## chan ## _to_2_s16p_flt_avx); \
00152 } \
00153 if (EXTERNAL_FMA4(mm_flags)) { \
00154 int ptr_align = 32; \
00155 int smp_align = 8; \
00156 if (ARCH_X86_32 || chan >= 6) { \
00157 ptr_align = 16; \
00158 smp_align = 4; \
00159 } \
00160 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,\
00161 chan, 1, ptr_align, smp_align, "FMA4", \
00162 ff_mix_ ## chan ## _to_1_fltp_flt_fma4); \
00163 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,\
00164 chan, 2, ptr_align, smp_align, "FMA4", \
00165 ff_mix_ ## chan ## _to_2_fltp_flt_fma4); \
00166 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
00167 chan, 1, 16, 8, "FMA4", \
00168 ff_mix_ ## chan ## _to_1_s16p_flt_fma4); \
00169 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
00170 chan, 2, 16, 8, "FMA4", \
00171 ff_mix_ ## chan ## _to_2_s16p_flt_fma4); \
00172 }
00173
00174 av_cold void ff_audio_mix_init_x86(AudioMix *am)
00175 {
00176 #if HAVE_YASM
00177 int mm_flags = av_get_cpu_flags();
00178
00179 if (EXTERNAL_SSE(mm_flags)) {
00180 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
00181 2, 1, 16, 8, "SSE", ff_mix_2_to_1_fltp_flt_sse);
00182 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
00183 1, 2, 16, 4, "SSE", ff_mix_1_to_2_fltp_flt_sse);
00184 }
00185 if (EXTERNAL_SSE2(mm_flags)) {
00186 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,
00187 2, 1, 16, 8, "SSE2", ff_mix_2_to_1_s16p_flt_sse2);
00188 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_Q8,
00189 2, 1, 16, 8, "SSE2", ff_mix_2_to_1_s16p_q8_sse2);
00190 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,
00191 1, 2, 16, 8, "SSE2", ff_mix_1_to_2_s16p_flt_sse2);
00192 }
00193 if (EXTERNAL_SSE4(mm_flags)) {
00194 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,
00195 2, 1, 16, 8, "SSE4", ff_mix_2_to_1_s16p_flt_sse4);
00196 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,
00197 1, 2, 16, 8, "SSE4", ff_mix_1_to_2_s16p_flt_sse4);
00198 }
00199 if (EXTERNAL_AVX(mm_flags)) {
00200 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
00201 2, 1, 32, 16, "AVX", ff_mix_2_to_1_fltp_flt_avx);
00202 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
00203 1, 2, 32, 8, "AVX", ff_mix_1_to_2_fltp_flt_avx);
00204 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,
00205 1, 2, 16, 8, "AVX", ff_mix_1_to_2_s16p_flt_avx);
00206 }
00207
00208 SET_MIX_3_8_TO_1_2(3)
00209 SET_MIX_3_8_TO_1_2(4)
00210 SET_MIX_3_8_TO_1_2(5)
00211 SET_MIX_3_8_TO_1_2(6)
00212 SET_MIX_3_8_TO_1_2(7)
00213 SET_MIX_3_8_TO_1_2(8)
00214 #endif
00215 }