00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "libswresample/swresample_internal.h"
00022 #include "libswresample/audioconvert.h"
00023
00024 #define PROTO(pre, in, out, cap) void ff ## pre ## _ ##in## _to_ ##out## _a_ ##cap(uint8_t **dst, const uint8_t **src, int len);
00025 #define PROTO2(pre, out, cap) PROTO(pre, int16, out, cap) PROTO(pre, int32, out, cap) PROTO(pre, float, out, cap)
00026 #define PROTO3(pre, cap) PROTO2(pre, int16, cap) PROTO2(pre, int32, cap) PROTO2(pre, float, cap)
00027 #define PROTO4(pre) PROTO3(pre, mmx) PROTO3(pre, sse) PROTO3(pre, sse2) PROTO3(pre, ssse3) PROTO3(pre, sse4) PROTO3(pre, avx)
00028 PROTO4()
00029 PROTO4(_pack_2ch)
00030 PROTO4(_pack_6ch)
00031 PROTO4(_unpack_2ch)
00032
00033 void swri_audio_convert_init_x86(struct AudioConvert *ac,
00034 enum AVSampleFormat out_fmt,
00035 enum AVSampleFormat in_fmt,
00036 int channels){
00037 int mm_flags = av_get_cpu_flags();
00038
00039 ac->simd_f= NULL;
00040
00041
00042
00043 #define MULTI_CAPS_FUNC(flag, cap) \
00044 if (mm_flags & flag) {\
00045 if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16P)\
00046 ac->simd_f = ff_int16_to_int32_a_ ## cap;\
00047 if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S32P)\
00048 ac->simd_f = ff_int32_to_int16_a_ ## cap;\
00049 }
00050
00051 MULTI_CAPS_FUNC(AV_CPU_FLAG_MMX, mmx)
00052 MULTI_CAPS_FUNC(AV_CPU_FLAG_SSE, sse)
00053
00054 if(mm_flags & AV_CPU_FLAG_MMX) {
00055 if(channels == 6) {
00056 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
00057 ac->simd_f = ff_pack_6ch_float_to_float_a_mmx;
00058 }
00059 }
00060
00061 if(mm_flags & AV_CPU_FLAG_SSE) {
00062 if(channels == 2) {
00063 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
00064 ac->simd_f = ff_pack_2ch_int32_to_int32_a_sse;
00065 if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S16P)
00066 ac->simd_f = ff_pack_2ch_int16_to_int16_a_sse;
00067 if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S16P)
00068 ac->simd_f = ff_pack_2ch_int16_to_int32_a_sse;
00069 if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S32P)
00070 ac->simd_f = ff_pack_2ch_int32_to_int16_a_sse;
00071
00072 if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S32)
00073 ac->simd_f = ff_unpack_2ch_int32_to_int32_a_sse;
00074 if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S16)
00075 ac->simd_f = ff_unpack_2ch_int16_to_int16_a_sse;
00076 if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16)
00077 ac->simd_f = ff_unpack_2ch_int16_to_int32_a_sse;
00078 if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S32)
00079 ac->simd_f = ff_unpack_2ch_int32_to_int16_a_sse;
00080 }
00081 }
00082
00083 if(mm_flags & AV_CPU_FLAG_SSE2) {
00084 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
00085 ac->simd_f = ff_int32_to_float_a_sse2;
00086 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16P)
00087 ac->simd_f = ff_int16_to_float_a_sse2;
00088 if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLTP)
00089 ac->simd_f = ff_float_to_int32_a_sse2;
00090 if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLTP)
00091 ac->simd_f = ff_float_to_int16_a_sse2;
00092
00093 if(channels == 2) {
00094 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
00095 ac->simd_f = ff_pack_2ch_int32_to_float_a_sse2;
00096 if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
00097 ac->simd_f = ff_pack_2ch_float_to_int32_a_sse2;
00098 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S16P)
00099 ac->simd_f = ff_pack_2ch_int16_to_float_a_sse2;
00100 if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLTP)
00101 ac->simd_f = ff_pack_2ch_float_to_int16_a_sse2;
00102 if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32)
00103 ac->simd_f = ff_unpack_2ch_int32_to_float_a_sse2;
00104 if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLT)
00105 ac->simd_f = ff_unpack_2ch_float_to_int32_a_sse2;
00106 if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16)
00107 ac->simd_f = ff_unpack_2ch_int16_to_float_a_sse2;
00108 if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLT)
00109 ac->simd_f = ff_unpack_2ch_float_to_int16_a_sse2;
00110 }
00111 }
00112 if(mm_flags & AV_CPU_FLAG_SSSE3) {
00113 if(channels == 2) {
00114 if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S16)
00115 ac->simd_f = ff_unpack_2ch_int16_to_int16_a_ssse3;
00116 if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16)
00117 ac->simd_f = ff_unpack_2ch_int16_to_int32_a_ssse3;
00118 if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16)
00119 ac->simd_f = ff_unpack_2ch_int16_to_float_a_ssse3;
00120 }
00121 }
00122 if(mm_flags & AV_CPU_FLAG_SSE4) {
00123 if(channels == 6) {
00124 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
00125 ac->simd_f = ff_pack_6ch_float_to_float_a_sse4;
00126 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
00127 ac->simd_f = ff_pack_6ch_int32_to_float_a_sse4;
00128 if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
00129 ac->simd_f = ff_pack_6ch_float_to_int32_a_sse4;
00130 }
00131 }
00132 if(HAVE_AVX && mm_flags & AV_CPU_FLAG_AVX) {
00133 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
00134 ac->simd_f = ff_int32_to_float_a_avx;
00135 if(channels == 6) {
00136 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
00137 ac->simd_f = ff_pack_6ch_float_to_float_a_avx;
00138 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
00139 ac->simd_f = ff_pack_6ch_int32_to_float_a_avx;
00140 if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
00141 ac->simd_f = ff_pack_6ch_float_to_int32_a_avx;
00142 }
00143 }
00144 }