[MPlayer-dev-eng] [PATCH] slightly faster float2int
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Tue Apr 11 11:46:32 CEST 2006
Hi,
please comment and if possible benchmark as well. Not sure if it's worth
changing, but this rots in my tree...
Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libaf/af_format.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af_format.c,v
retrieving revision 1.31
diff -u -r1.31 af_format.c
--- libaf/af_format.c 13 Nov 2005 18:28:44 -0000 1.31
+++ libaf/af_format.c 11 Apr 2006 09:45:18 -0000
@@ -467,23 +467,31 @@
static void float2int(float* in, void* out, int len, int bps)
{
- register int i;
+ register long i = -len;
+ if (len <= 0)
+ return;
+ in = &in[len];
+ out += bps * len;
switch(bps){
case(1):
- for(i=0;i<len;i++)
+ do {
((int8_t*)out)[i] = lrintf(127.0 * in[i]);
+ } while (++i);
break;
case(2):
- for(i=0;i<len;i++)
+ do {
((int16_t*)out)[i] = lrintf(32767.0 * in[i]);
+ } while (++i);
break;
case(3):
- for(i=0;i<len;i++)
+ do {
store24bit(out, i, lrintf(2147483647.0 * in[i]));
+ } while (++i);
break;
case(4):
- for(i=0;i<len;i++)
+ do {
((int32_t*)out)[i] = lrintf(2147483647.0 * in[i]);
+ } while (++i);
break;
}
}
More information about the MPlayer-dev-eng
mailing list