[MPlayer-dev-eng] [PATCH] ao_plugin.c bugfixes and speed improvement
kisg at lme.linux.hu
Sun Apr 7 12:10:58 CEST 2002
While analyzing the problems I have encountered in ao_plugin.c I found this
It talks about performance penalties when using plain C float (double) to
Brief description: The ISO C standard says, that the float to int cast is a
truncation operation. This causes the new pipeline based FPUs (P3, P4, Athlon)
to flush their whole pipeline. In many cases we could actually round the
value to the nearest integer, which is much faster.
The ISO C99 standard introduced the functions lrint and lrintf which do
exactly this. In GNU C they are defined in math.h as inline functions.
One has to define the _ISO9X_SOURCE and _ISO99_SOURCE flags to use these
functions. The only drawback is that when optimizations are turned of the
binary needs to be linked against the math library.
I think, that in ao_plugin.c get_space() we actually want to round the
value, and not truncate.
The attached patch solves both the ao_plugin_local_data.len problem and the
Please review and commit if you like.
Thanks for your time,
-------------- next part --------------
--- ao_plugin.c.orig Fri Apr 5 10:16:13 2002
+++ ao_plugin.c Sun Apr 7 11:36:25 2002
@@ -1,6 +1,10 @@
+#define _ISOC9X_SOURCE 1
+#define _ISOC99_SOURCE 1
@@ -172,6 +176,7 @@
if(!ao_plugin_local_data.buf) return 0;
@@ -190,6 +195,7 @@
// stop playing and empty buffers (for seeking/pause)
@@ -218,7 +224,7 @@
- return (int)(sz);
+ return (int)lrint(sz);
// plays 'len' bytes of 'data'
More information about the MPlayer-dev-eng