00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "libavutil/cpu.h"
00026 #include "libavutil/x86/asm.h"
00027 #include "libavutil/x86/cpu.h"
00028 #include "libavcodec/fmtconvert.h"
00029 #include "libavcodec/dsputil.h"
00030
00031 #if HAVE_YASM
00032
00033 void ff_int32_to_float_fmul_scalar_sse (float *dst, const int *src, float mul, int len);
00034 void ff_int32_to_float_fmul_scalar_sse2(float *dst, const int *src, float mul, int len);
00035
00036 void ff_float_to_int16_3dnow(int16_t *dst, const float *src, long len);
00037 void ff_float_to_int16_sse (int16_t *dst, const float *src, long len);
00038 void ff_float_to_int16_sse2 (int16_t *dst, const float *src, long len);
00039
00040 void ff_float_to_int16_step_3dnow(int16_t *dst, const float *src, long len, long step);
00041 void ff_float_to_int16_step_sse (int16_t *dst, const float *src, long len, long step);
00042 void ff_float_to_int16_step_sse2 (int16_t *dst, const float *src, long len, long step);
00043
00044 void ff_float_to_int16_interleave2_3dnow(int16_t *dst, const float **src, long len);
00045 void ff_float_to_int16_interleave2_sse (int16_t *dst, const float **src, long len);
00046 void ff_float_to_int16_interleave2_sse2 (int16_t *dst, const float **src, long len);
00047
00048 void ff_float_to_int16_interleave6_sse(int16_t *dst, const float **src, int len);
00049 void ff_float_to_int16_interleave6_3dnow(int16_t *dst, const float **src, int len);
00050 void ff_float_to_int16_interleave6_3dnowext(int16_t *dst, const float **src, int len);
00051
00052 #define ff_float_to_int16_interleave6_sse2 ff_float_to_int16_interleave6_sse
00053
00054 #define FLOAT_TO_INT16_INTERLEAVE(cpu) \
00055 \
00056 static av_noinline void float_to_int16_interleave_misc_##cpu(int16_t *dst, const float **src, long len, int channels){\
00057 int c;\
00058 for(c=0; c<channels; c++){\
00059 ff_float_to_int16_step_##cpu(dst+c, src[c], len, channels);\
00060 }\
00061 }\
00062 \
00063 static void float_to_int16_interleave_##cpu(int16_t *dst, const float **src, long len, int channels){\
00064 if(channels==1)\
00065 ff_float_to_int16_##cpu(dst, src[0], len);\
00066 else if(channels==2){\
00067 ff_float_to_int16_interleave2_##cpu(dst, src, len);\
00068 }else if(channels==6){\
00069 ff_float_to_int16_interleave6_##cpu(dst, src, len);\
00070 }else\
00071 float_to_int16_interleave_misc_##cpu(dst, src, len, channels);\
00072 }
00073
00074 FLOAT_TO_INT16_INTERLEAVE(3dnow)
00075 FLOAT_TO_INT16_INTERLEAVE(sse)
00076 FLOAT_TO_INT16_INTERLEAVE(sse2)
00077
00078 static void float_to_int16_interleave_3dnowext(int16_t *dst, const float **src,
00079 long len, int channels)
00080 {
00081 if(channels==6)
00082 ff_float_to_int16_interleave6_3dnowext(dst, src, len);
00083 else
00084 float_to_int16_interleave_3dnow(dst, src, len, channels);
00085 }
00086
00087 void ff_float_interleave2_mmx(float *dst, const float **src, unsigned int len);
00088 void ff_float_interleave2_sse(float *dst, const float **src, unsigned int len);
00089
00090 void ff_float_interleave6_mmx(float *dst, const float **src, unsigned int len);
00091 void ff_float_interleave6_sse(float *dst, const float **src, unsigned int len);
00092
00093 static void float_interleave_mmx(float *dst, const float **src,
00094 unsigned int len, int channels)
00095 {
00096 if (channels == 2) {
00097 ff_float_interleave2_mmx(dst, src, len);
00098 } else if (channels == 6)
00099 ff_float_interleave6_mmx(dst, src, len);
00100 else
00101 ff_float_interleave_c(dst, src, len, channels);
00102 }
00103
00104 static void float_interleave_sse(float *dst, const float **src,
00105 unsigned int len, int channels)
00106 {
00107 if (channels == 2) {
00108 ff_float_interleave2_sse(dst, src, len);
00109 } else if (channels == 6)
00110 ff_float_interleave6_sse(dst, src, len);
00111 else
00112 ff_float_interleave_c(dst, src, len, channels);
00113 }
00114 #endif
00115
00116 void ff_fmt_convert_init_x86(FmtConvertContext *c, AVCodecContext *avctx)
00117 {
00118 #if HAVE_YASM
00119 int mm_flags = av_get_cpu_flags();
00120
00121 if (EXTERNAL_MMX(mm_flags)) {
00122 c->float_interleave = float_interleave_mmx;
00123
00124 if (EXTERNAL_AMD3DNOW(mm_flags)) {
00125 if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
00126 c->float_to_int16 = ff_float_to_int16_3dnow;
00127 c->float_to_int16_interleave = float_to_int16_interleave_3dnow;
00128 }
00129 }
00130 if (EXTERNAL_AMD3DNOWEXT(mm_flags)) {
00131 if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
00132 c->float_to_int16_interleave = float_to_int16_interleave_3dnowext;
00133 }
00134 }
00135 if (EXTERNAL_SSE(mm_flags)) {
00136 c->int32_to_float_fmul_scalar = ff_int32_to_float_fmul_scalar_sse;
00137 c->float_to_int16 = ff_float_to_int16_sse;
00138 c->float_to_int16_interleave = float_to_int16_interleave_sse;
00139 c->float_interleave = float_interleave_sse;
00140 }
00141 if (EXTERNAL_SSE2(mm_flags)) {
00142 c->int32_to_float_fmul_scalar = ff_int32_to_float_fmul_scalar_sse2;
00143 c->float_to_int16 = ff_float_to_int16_sse2;
00144 c->float_to_int16_interleave = float_to_int16_interleave_sse2;
00145 }
00146 }
00147 #endif
00148 }