comparison i386/dsputil_mmx.c @ 7286:e267f2519248 libavcodec

float_to_int16_interleave: change src to an array of pointers instead of assuming it's contiguous. this has no immediate effect, but will allow it to be used in more codecs.
author lorenm
date Wed, 16 Jul 2008 00:50:12 +0000
parents 6c140c15ee8c
children 2ced44037814
comparison
equal deleted inserted replaced
7285:1fe3ae6a9491 7286:e267f2519248
2154 ); 2154 );
2155 } 2155 }
2156 2156
2157 #define FLOAT_TO_INT16_INTERLEAVE(cpu, body) \ 2157 #define FLOAT_TO_INT16_INTERLEAVE(cpu, body) \
2158 /* gcc pessimizes register allocation if this is in the same function as float_to_int16_interleave_sse2*/\ 2158 /* gcc pessimizes register allocation if this is in the same function as float_to_int16_interleave_sse2*/\
2159 static av_noinline void float_to_int16_interleave2_##cpu(int16_t *dst, const float *src, long len, int channels){\ 2159 static av_noinline void float_to_int16_interleave2_##cpu(int16_t *dst, const float **src, long len, int channels){\
2160 DECLARE_ALIGNED_16(int16_t, tmp[len*channels]);\ 2160 DECLARE_ALIGNED_16(int16_t, tmp[len]);\
2161 int i,j,c;\ 2161 int i,j,c;\
2162 float_to_int16_##cpu(tmp, src, len*channels);\
2163 for(c=0; c<channels; c++){\ 2162 for(c=0; c<channels; c++){\
2164 int16_t *ptmp = tmp+c*len;\ 2163 float_to_int16_##cpu(tmp, src[c], len);\
2165 for(i=0, j=c; i<len; i++, j+=channels)\ 2164 for(i=0, j=c; i<len; i++, j+=channels)\
2166 dst[j] = ptmp[i];\ 2165 dst[j] = tmp[i];\
2167 }\ 2166 }\
2168 }\ 2167 }\
2169 \ 2168 \
2170 static void float_to_int16_interleave_##cpu(int16_t *dst, const float *src, long len, int channels){\ 2169 static void float_to_int16_interleave_##cpu(int16_t *dst, const float **src, long len, int channels){\
2171 if(channels==1)\ 2170 if(channels==1)\
2172 float_to_int16_##cpu(dst, src, len);\ 2171 float_to_int16_##cpu(dst, src[0], len);\
2173 else if(channels>2)\ 2172 else if(channels>2)\
2174 float_to_int16_interleave2_##cpu(dst, src, len, channels);\ 2173 float_to_int16_interleave2_##cpu(dst, src, len, channels);\
2175 else{\ 2174 else{\
2176 float *src1;\ 2175 const float *src0 = src[0];\
2176 const float *src1 = src[1];\
2177 asm volatile(\ 2177 asm volatile(\
2178 "shl $2, %0 \n"\ 2178 "shl $2, %0 \n"\
2179 "add %0, %1 \n"\ 2179 "add %0, %1 \n"\
2180 "add %0, %2 \n"\ 2180 "add %0, %2 \n"\
2181 "lea (%2,%0), %3 \n"\ 2181 "add %0, %3 \n"\
2182 "neg %0 \n"\ 2182 "neg %0 \n"\
2183 body\ 2183 body\
2184 :"+r"(len), "+r"(dst), "+r"(src), "=r"(src1)\ 2184 :"+r"(len), "+r"(dst), "+r"(src0), "+r"(src1)\
2185 );\ 2185 );\
2186 }\ 2186 }\
2187 } 2187 }
2188 2188
2189 FLOAT_TO_INT16_INTERLEAVE(3dnow, 2189 FLOAT_TO_INT16_INTERLEAVE(3dnow,