[FFmpeg-cvslog] r22399 - in trunk: ffmpeg.c libavutil/internal.h libavutil/libm.h

mru subversion
Tue Mar 9 16:10:23 CET 2010


Author: mru
Date: Tue Mar  9 16:10:23 2010
New Revision: 22399

Log:
Move libm replacements to new header libm.h

ffmpeg.c uses lrintf(), which is missing on some systems.  Previously
it picked up the replacement via libavutil/internal.h due to
HAVE_AV_CONFIG_H being erroneously defined.

Moving these replacements to a separate header enables ffmpeg.c to
use them without being exposed to internal interfaces.

This use of a non-public header is justified by the header in question
not being part of the internal interface either.  It should rather be
considered as part of the build system, which is shared between the
libraries and the applications.

This header cannot be installed since the tested conditions depend on
the compiler.

Added:
   trunk/libavutil/libm.h
Modified:
   trunk/ffmpeg.c
   trunk/libavutil/internal.h

Modified: trunk/ffmpeg.c
==============================================================================
--- trunk/ffmpeg.c	Tue Mar  9 15:59:40 2010	(r22398)
+++ trunk/ffmpeg.c	Tue Mar  9 16:10:23 2010	(r22399)
@@ -40,6 +40,7 @@
 #include "libavutil/fifo.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/avstring.h"
+#include "libavutil/libm.h"
 #include "libavformat/os_support.h"
 
 #if HAVE_SYS_RESOURCE_H

Modified: trunk/libavutil/internal.h
==============================================================================
--- trunk/libavutil/internal.h	Tue Mar  9 15:59:40 2010	(r22398)
+++ trunk/libavutil/internal.h	Tue Mar  9 16:10:23 2010	(r22399)
@@ -192,65 +192,7 @@
     }\
 }
 
-#if !HAVE_EXP2
-#undef exp2
-#define exp2(x) exp((x) * 0.693147180559945)
-#endif /* HAVE_EXP2 */
-
-#if !HAVE_EXP2F
-#undef exp2f
-#define exp2f(x) ((float)exp2(x))
-#endif /* HAVE_EXP2F */
-
-#if !HAVE_LLRINT
-#undef llrint
-#define llrint(x) ((long long)rint(x))
-#endif /* HAVE_LLRINT */
-
-#if !HAVE_LOG2
-#undef log2
-#define log2(x) (log(x) * 1.44269504088896340736)
-#endif /* HAVE_LOG2 */
-
-#if !HAVE_LOG2F
-#undef log2f
-#define log2f(x) ((float)log2(x))
-#endif /* HAVE_LOG2F */
-
-#if !HAVE_LRINT
-static av_always_inline av_const long int lrint(double x)
-{
-    return rint(x);
-}
-#endif /* HAVE_LRINT */
-
-#if !HAVE_LRINTF
-static av_always_inline av_const long int lrintf(float x)
-{
-    return (int)(rint(x));
-}
-#endif /* HAVE_LRINTF */
-
-#if !HAVE_ROUND
-static av_always_inline av_const double round(double x)
-{
-    return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
-}
-#endif /* HAVE_ROUND */
-
-#if !HAVE_ROUNDF
-static av_always_inline av_const float roundf(float x)
-{
-    return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
-}
-#endif /* HAVE_ROUNDF */
-
-#if !HAVE_TRUNCF
-static av_always_inline av_const float truncf(float x)
-{
-    return (x > 0) ? floor(x) : ceil(x);
-}
-#endif /* HAVE_TRUNCF */
+#include "libm.h"
 
 /**
  * Returns NULL if CONFIG_SMALL is true, otherwise the argument

Added: trunk/libavutil/libm.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/libavutil/libm.h	Tue Mar  9 16:10:23 2010	(r22399)
@@ -0,0 +1,90 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file libavutil/libm.h
+ * Replacements for frequently missing libm functions
+ */
+
+#ifndef AVUTIL_LIBM_H
+#define AVUTIL_LIBM_H
+
+#include <math.h>
+#include "config.h"
+
+#if !HAVE_EXP2
+#undef exp2
+#define exp2(x) exp((x) * 0.693147180559945)
+#endif /* HAVE_EXP2 */
+
+#if !HAVE_EXP2F
+#undef exp2f
+#define exp2f(x) ((float)exp2(x))
+#endif /* HAVE_EXP2F */
+
+#if !HAVE_LLRINT
+#undef llrint
+#define llrint(x) ((long long)rint(x))
+#endif /* HAVE_LLRINT */
+
+#if !HAVE_LOG2
+#undef log2
+#define log2(x) (log(x) * 1.44269504088896340736)
+#endif /* HAVE_LOG2 */
+
+#if !HAVE_LOG2F
+#undef log2f
+#define log2f(x) ((float)log2(x))
+#endif /* HAVE_LOG2F */
+
+#if !HAVE_LRINT
+static av_always_inline av_const long int lrint(double x)
+{
+    return rint(x);
+}
+#endif /* HAVE_LRINT */
+
+#if !HAVE_LRINTF
+static av_always_inline av_const long int lrintf(float x)
+{
+    return (int)(rint(x));
+}
+#endif /* HAVE_LRINTF */
+
+#if !HAVE_ROUND
+static av_always_inline av_const double round(double x)
+{
+    return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
+}
+#endif /* HAVE_ROUND */
+
+#if !HAVE_ROUNDF
+static av_always_inline av_const float roundf(float x)
+{
+    return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
+}
+#endif /* HAVE_ROUNDF */
+
+#if !HAVE_TRUNCF
+static av_always_inline av_const float truncf(float x)
+{
+    return (x > 0) ? floor(x) : ceil(x);
+}
+#endif /* HAVE_TRUNCF */
+
+#endif /* AVUTIL_LIBM_H */



More information about the ffmpeg-cvslog mailing list