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_convert.h"
00025
00026
00027
00028 extern void ff_conv_s16_to_s32_sse2(int16_t *dst, const int32_t *src, int len);
00029
00030 extern void ff_conv_s16_to_flt_sse2(float *dst, const int16_t *src, int len);
00031 extern void ff_conv_s16_to_flt_sse4(float *dst, const int16_t *src, int len);
00032
00033 extern void ff_conv_s32_to_s16_mmx (int16_t *dst, const int32_t *src, int len);
00034 extern void ff_conv_s32_to_s16_sse2(int16_t *dst, const int32_t *src, int len);
00035
00036 extern void ff_conv_s32_to_flt_sse2(float *dst, const int32_t *src, int len);
00037 extern void ff_conv_s32_to_flt_avx (float *dst, const int32_t *src, int len);
00038
00039 extern void ff_conv_flt_to_s16_sse2(int16_t *dst, const float *src, int len);
00040
00041 extern void ff_conv_flt_to_s32_sse2(int32_t *dst, const float *src, int len);
00042 extern void ff_conv_flt_to_s32_avx (int32_t *dst, const float *src, int len);
00043
00044
00045
00046 extern void ff_conv_s16p_to_s16_2ch_sse2(int16_t *dst, int16_t *const *src,
00047 int len, int channels);
00048 extern void ff_conv_s16p_to_s16_2ch_avx (int16_t *dst, int16_t *const *src,
00049 int len, int channels);
00050
00051 extern void ff_conv_s16p_to_s16_6ch_sse2(int16_t *dst, int16_t *const *src,
00052 int len, int channels);
00053 extern void ff_conv_s16p_to_s16_6ch_sse2slow(int16_t *dst, int16_t *const *src,
00054 int len, int channels);
00055 extern void ff_conv_s16p_to_s16_6ch_avx (int16_t *dst, int16_t *const *src,
00056 int len, int channels);
00057
00058 extern void ff_conv_s16p_to_flt_2ch_sse2(float *dst, int16_t *const *src,
00059 int len, int channels);
00060 extern void ff_conv_s16p_to_flt_2ch_avx (float *dst, int16_t *const *src,
00061 int len, int channels);
00062
00063 extern void ff_conv_s16p_to_flt_6ch_sse2 (float *dst, int16_t *const *src,
00064 int len, int channels);
00065 extern void ff_conv_s16p_to_flt_6ch_ssse3(float *dst, int16_t *const *src,
00066 int len, int channels);
00067 extern void ff_conv_s16p_to_flt_6ch_avx (float *dst, int16_t *const *src,
00068 int len, int channels);
00069
00070 extern void ff_conv_fltp_to_s16_2ch_sse2 (int16_t *dst, float *const *src,
00071 int len, int channels);
00072 extern void ff_conv_fltp_to_s16_2ch_ssse3(int16_t *dst, float *const *src,
00073 int len, int channels);
00074
00075 extern void ff_conv_fltp_to_s16_6ch_sse (int16_t *dst, float *const *src,
00076 int len, int channels);
00077 extern void ff_conv_fltp_to_s16_6ch_sse2(int16_t *dst, float *const *src,
00078 int len, int channels);
00079 extern void ff_conv_fltp_to_s16_6ch_avx (int16_t *dst, float *const *src,
00080 int len, int channels);
00081
00082 extern void ff_conv_fltp_to_flt_2ch_sse(float *dst, float *const *src, int len,
00083 int channels);
00084 extern void ff_conv_fltp_to_flt_2ch_avx(float *dst, float *const *src, int len,
00085 int channels);
00086
00087 extern void ff_conv_fltp_to_flt_6ch_mmx (float *dst, float *const *src, int len,
00088 int channels);
00089 extern void ff_conv_fltp_to_flt_6ch_sse4(float *dst, float *const *src, int len,
00090 int channels);
00091 extern void ff_conv_fltp_to_flt_6ch_avx (float *dst, float *const *src, int len,
00092 int channels);
00093
00094
00095
00096 extern void ff_conv_s16_to_s16p_2ch_sse2(int16_t *const *dst, int16_t *src,
00097 int len, int channels);
00098 extern void ff_conv_s16_to_s16p_2ch_ssse3(int16_t *const *dst, int16_t *src,
00099 int len, int channels);
00100 extern void ff_conv_s16_to_s16p_2ch_avx (int16_t *const *dst, int16_t *src,
00101 int len, int channels);
00102
00103 extern void ff_conv_s16_to_s16p_6ch_sse2 (int16_t *const *dst, int16_t *src,
00104 int len, int channels);
00105 extern void ff_conv_s16_to_s16p_6ch_ssse3(int16_t *const *dst, int16_t *src,
00106 int len, int channels);
00107 extern void ff_conv_s16_to_s16p_6ch_avx (int16_t *const *dst, int16_t *src,
00108 int len, int channels);
00109
00110 extern void ff_conv_s16_to_fltp_2ch_sse2(float *const *dst, int16_t *src,
00111 int len, int channels);
00112 extern void ff_conv_s16_to_fltp_2ch_avx (float *const *dst, int16_t *src,
00113 int len, int channels);
00114
00115 extern void ff_conv_s16_to_fltp_6ch_sse2 (float *const *dst, int16_t *src,
00116 int len, int channels);
00117 extern void ff_conv_s16_to_fltp_6ch_ssse3(float *const *dst, int16_t *src,
00118 int len, int channels);
00119 extern void ff_conv_s16_to_fltp_6ch_sse4 (float *const *dst, int16_t *src,
00120 int len, int channels);
00121 extern void ff_conv_s16_to_fltp_6ch_avx (float *const *dst, int16_t *src,
00122 int len, int channels);
00123
00124 extern void ff_conv_flt_to_s16p_2ch_sse2(int16_t *const *dst, float *src,
00125 int len, int channels);
00126 extern void ff_conv_flt_to_s16p_2ch_avx (int16_t *const *dst, float *src,
00127 int len, int channels);
00128
00129 extern void ff_conv_flt_to_s16p_6ch_sse2 (int16_t *const *dst, float *src,
00130 int len, int channels);
00131 extern void ff_conv_flt_to_s16p_6ch_ssse3(int16_t *const *dst, float *src,
00132 int len, int channels);
00133 extern void ff_conv_flt_to_s16p_6ch_avx (int16_t *const *dst, float *src,
00134 int len, int channels);
00135
00136 extern void ff_conv_flt_to_fltp_2ch_sse(float *const *dst, float *src, int len,
00137 int channels);
00138 extern void ff_conv_flt_to_fltp_2ch_avx(float *const *dst, float *src, int len,
00139 int channels);
00140
00141 extern void ff_conv_flt_to_fltp_6ch_sse2(float *const *dst, float *src, int len,
00142 int channels);
00143 extern void ff_conv_flt_to_fltp_6ch_avx (float *const *dst, float *src, int len,
00144 int channels);
00145
00146 av_cold void ff_audio_convert_init_x86(AudioConvert *ac)
00147 {
00148 int mm_flags = av_get_cpu_flags();
00149
00150 if (EXTERNAL_MMX(mm_flags)) {
00151 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32,
00152 0, 1, 8, "MMX", ff_conv_s32_to_s16_mmx);
00153 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
00154 6, 1, 4, "MMX", ff_conv_fltp_to_flt_6ch_mmx);
00155 }
00156 if (EXTERNAL_SSE(mm_flags)) {
00157 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
00158 6, 1, 2, "SSE", ff_conv_fltp_to_s16_6ch_sse);
00159 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
00160 2, 16, 8, "SSE", ff_conv_fltp_to_flt_2ch_sse);
00161 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT,
00162 2, 16, 4, "SSE", ff_conv_flt_to_fltp_2ch_sse);
00163 }
00164 if (EXTERNAL_SSE2(mm_flags)) {
00165 if (!(mm_flags & AV_CPU_FLAG_SSE2SLOW)) {
00166 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32,
00167 0, 16, 16, "SSE2", ff_conv_s32_to_s16_sse2);
00168 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
00169 6, 16, 8, "SSE2", ff_conv_s16p_to_s16_6ch_sse2);
00170 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
00171 6, 16, 4, "SSE2", ff_conv_fltp_to_s16_6ch_sse2);
00172 } else {
00173 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
00174 6, 1, 4, "SSE2SLOW", ff_conv_s16p_to_s16_6ch_sse2slow);
00175 }
00176 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16,
00177 0, 16, 8, "SSE2", ff_conv_s16_to_s32_sse2);
00178 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16,
00179 0, 16, 8, "SSE2", ff_conv_s16_to_flt_sse2);
00180 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32,
00181 0, 16, 8, "SSE2", ff_conv_s32_to_flt_sse2);
00182 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT,
00183 0, 16, 16, "SSE2", ff_conv_flt_to_s16_sse2);
00184 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT,
00185 0, 16, 16, "SSE2", ff_conv_flt_to_s32_sse2);
00186 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
00187 2, 16, 16, "SSE2", ff_conv_s16p_to_s16_2ch_sse2);
00188 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P,
00189 2, 16, 8, "SSE2", ff_conv_s16p_to_flt_2ch_sse2);
00190 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P,
00191 6, 16, 4, "SSE2", ff_conv_s16p_to_flt_6ch_sse2);
00192 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
00193 2, 16, 4, "SSE2", ff_conv_fltp_to_s16_2ch_sse2);
00194 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16,
00195 2, 16, 8, "SSE2", ff_conv_s16_to_s16p_2ch_sse2);
00196 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16,
00197 6, 16, 4, "SSE2", ff_conv_s16_to_s16p_6ch_sse2);
00198 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16,
00199 2, 16, 8, "SSE2", ff_conv_s16_to_fltp_2ch_sse2);
00200 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16,
00201 6, 16, 4, "SSE2", ff_conv_s16_to_fltp_6ch_sse2);
00202 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT,
00203 2, 16, 8, "SSE2", ff_conv_flt_to_s16p_2ch_sse2);
00204 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT,
00205 6, 16, 4, "SSE2", ff_conv_flt_to_s16p_6ch_sse2);
00206 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT,
00207 6, 16, 4, "SSE2", ff_conv_flt_to_fltp_6ch_sse2);
00208 }
00209 if (EXTERNAL_SSSE3(mm_flags)) {
00210 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P,
00211 6, 16, 4, "SSSE3", ff_conv_s16p_to_flt_6ch_ssse3);
00212 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
00213 2, 16, 4, "SSSE3", ff_conv_fltp_to_s16_2ch_ssse3);
00214 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16,
00215 2, 16, 8, "SSSE3", ff_conv_s16_to_s16p_2ch_ssse3);
00216 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16,
00217 6, 16, 4, "SSSE3", ff_conv_s16_to_s16p_6ch_ssse3);
00218 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16,
00219 6, 16, 4, "SSSE3", ff_conv_s16_to_fltp_6ch_ssse3);
00220 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT,
00221 6, 16, 4, "SSSE3", ff_conv_flt_to_s16p_6ch_ssse3);
00222 }
00223 if (EXTERNAL_SSE4(mm_flags)) {
00224 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16,
00225 0, 16, 8, "SSE4", ff_conv_s16_to_flt_sse4);
00226 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
00227 6, 16, 4, "SSE4", ff_conv_fltp_to_flt_6ch_sse4);
00228 }
00229 if (EXTERNAL_AVX(mm_flags)) {
00230 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32,
00231 0, 32, 16, "AVX", ff_conv_s32_to_flt_avx);
00232 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT,
00233 0, 32, 32, "AVX", ff_conv_flt_to_s32_avx);
00234 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
00235 2, 16, 16, "AVX", ff_conv_s16p_to_s16_2ch_avx);
00236 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
00237 6, 16, 8, "AVX", ff_conv_s16p_to_s16_6ch_avx);
00238 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P,
00239 2, 16, 8, "AVX", ff_conv_s16p_to_flt_2ch_avx);
00240 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P,
00241 6, 16, 4, "AVX", ff_conv_s16p_to_flt_6ch_avx);
00242 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
00243 6, 16, 4, "AVX", ff_conv_fltp_to_s16_6ch_avx);
00244 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
00245 6, 16, 4, "AVX", ff_conv_fltp_to_flt_6ch_avx);
00246 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16,
00247 2, 16, 8, "AVX", ff_conv_s16_to_s16p_2ch_avx);
00248 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16,
00249 6, 16, 4, "AVX", ff_conv_s16_to_s16p_6ch_avx);
00250 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16,
00251 2, 16, 8, "AVX", ff_conv_s16_to_fltp_2ch_avx);
00252 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16,
00253 6, 16, 4, "AVX", ff_conv_s16_to_fltp_6ch_avx);
00254 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT,
00255 2, 16, 8, "AVX", ff_conv_flt_to_s16p_2ch_avx);
00256 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT,
00257 6, 16, 4, "AVX", ff_conv_flt_to_s16p_6ch_avx);
00258 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT,
00259 2, 16, 4, "AVX", ff_conv_flt_to_fltp_2ch_avx);
00260 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT,
00261 6, 16, 4, "AVX", ff_conv_flt_to_fltp_6ch_avx);
00262 }
00263 }