comparison ppc/float_altivec.c @ 7675:ad4bf45b9b63 libavcodec

Introduce float_to_int16_interleave_altivec, tested with vorbis
author lu_zero
date Sat, 23 Aug 2008 21:09:46 +0000
parents e1876d3200ee
children d1ec9f6c0be1
comparison
equal deleted inserted replaced
7674:e1876d3200ee 7675:ad4bf45b9b63
184 d = float_to_int16_one_altivec(src+i); 184 d = float_to_int16_one_altivec(src+i);
185 vec_st(d, 0, dst+i); 185 vec_st(d, 0, dst+i);
186 } 186 }
187 } 187 }
188 188
189 static void
190 float_to_int16_interleave_altivec(int16_t *dst, const float **src,
191 long len, int channels)
192 {
193 int i;
194 vector signed short d0, d1, d2, c0, c1, t0, t1;
195 vector unsigned char align;
196 if(channels == 1)
197 float_to_int16_altivec(dst, src[0], len);
198 else
199 if (channels == 2) {
200 if(((long)dst)&15)
201 for(i=0; i<len-7; i+=8) {
202 d0 = vec_ld(0, dst + i);
203 t0 = float_to_int16_one_altivec(src[0] + i);
204 d1 = vec_ld(31, dst + i);
205 t1 = float_to_int16_one_altivec(src[1] + i);
206 c0 = vec_mergeh(t0, t1);
207 c1 = vec_mergel(t0, t1);
208 d2 = vec_perm(d1, d0, vec_lvsl(0, dst + i));
209 align = vec_lvsr(0, dst + i);
210 d0 = vec_perm(d2, c0, align);
211 d1 = vec_perm(c0, c1, align);
212 vec_st(d0, 0, dst + i);
213 d0 = vec_perm(c1, d2, align);
214 vec_st(d1, 15, dst + i);
215 vec_st(d0, 31, dst + i);
216 dst+=8;
217 }
218 else
219 for(i=0; i<len-7; i+=8) {
220 t0 = float_to_int16_one_altivec(src[0] + i);
221 t1 = float_to_int16_one_altivec(src[1] + i);
222 d0 = vec_mergeh(t0, t1);
223 d1 = vec_mergel(t0, t1);
224 vec_st(d0, 0, dst + i);
225 vec_st(d1, 16, dst + i);
226 dst+=8;
227 }
228 } else {
229 DECLARE_ALIGNED(16, int16_t, tmp[len]);
230 int c, j;
231 for (c = 0; c < channels; c++) {
232 float_to_int16_altivec(tmp, src[c], len);
233 for (i = 0, j = c; i < len; i++, j+=channels) {
234 dst[j] = tmp[i];
235 }
236 }
237 }
238 }
239
189 void float_init_altivec(DSPContext* c, AVCodecContext *avctx) 240 void float_init_altivec(DSPContext* c, AVCodecContext *avctx)
190 { 241 {
191 c->vector_fmul = vector_fmul_altivec; 242 c->vector_fmul = vector_fmul_altivec;
192 c->vector_fmul_reverse = vector_fmul_reverse_altivec; 243 c->vector_fmul_reverse = vector_fmul_reverse_altivec;
193 c->vector_fmul_add_add = vector_fmul_add_add_altivec; 244 c->vector_fmul_add_add = vector_fmul_add_add_altivec;
194 if(!(avctx->flags & CODEC_FLAG_BITEXACT)) 245 if(!(avctx->flags & CODEC_FLAG_BITEXACT)) {
195 c->float_to_int16 = float_to_int16_altivec; 246 c->float_to_int16 = float_to_int16_altivec;
196 } 247 c->float_to_int16_interleave = float_to_int16_interleave_altivec;
248 }
249 }