you probably don't want the ~2% perf improvement below... but i figured
i'd post it anyhow :)
well... i do suggest the use of fabsf() rather than fabs() -- gcc doesn't
seem smart enough to figure out fabs() when you ask it to compile
"-mfpmath=sse".
but the #else part uses properties of ieee-754 float layout which you may
or may not be interested in (ab)using. basically the left shift lops off
the sign bit, then the rest of the bits can be compared directly as
integers -- this is all possible because the exponent is stored biased.
it's an old trick (and part of the reason for why floats are stored this
way in the first place).
anyhow, i figured i'd post this so i could feel justified in asking about
the double indirection -- the double indirection appears to be required
because _vp_quantize_couple_sort needs to return a permutation which
yields the sorted data, do i understand that right?
thanks
-dean
p.s. 1-3% oggenc perf improvement measured on all of p-m, p4, k8, efficeon
with this patch and compilation options "-march=pentium4
-mfpmath=sse".
Index: psy.c
==================================================================RCS file:
/usr/local/cvsroot/vorbis/lib/psy.c,v
retrieving revision 1.81
diff -u -r1.81 psy.c
--- a/psy.c 21 Oct 2002 07:00:11 -0000 1.81
+++ b/psy.c 23 Mar 2004 03:16:32 -0000
@@ -29,6 +29,8 @@
#include "scales.h"
#include "misc.h"
+#include <stdint.h>
+
#define NEGINF -9999.f
static double stereo_threshholds[]={0.0, .5, 1.0, 1.5, 2.5, 4.5, 8.5, 16.5,
9e10};
@@ -966,9 +968,17 @@
/* this is for per-channel noise normalization */
static int apsort(const void *a, const void *b){
- float f1=fabs(**(float**)a);
- float f2=fabs(**(float**)b);
+#if 0
+ float f1=fabsf(**(float**)a);
+ float f2=fabsf(**(float**)b);
return (f1<f2)-(f1>f2);
+#else
+ uint32_t u1 = **(uint32_t **)a;
+ uint32_t u2 = **(uint32_t **)b;
+ u1 <<= 1;
+ u2 <<= 1;
+ return (u1<u2)-(u1>u2);
+#endif
}
int **_vp_quantize_couple_sort(vorbis_block *vb,
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to
'vorbis-dev-request@xiph.org'
containing only the word 'unsubscribe' in the body. No subject is
needed.
Unsubscribe messages sent to the list will be ignored/filtered.