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