[Ffmpeg-devel] #include dsputil.h needed in opt.c

Diego Biurrun diego
Mon Sep 19 19:19:50 CEST 2005


On Mon, Sep 19, 2005 at 11:03:41AM +0200, Michael Niedermayer wrote:
> 
> On Mon, Sep 19, 2005 at 08:12:39AM +0200, Xavier Rodriguez (INEXBEE) wrote:
> > 
> > I have seen that lrintf function was pre-processed in the dsputil.h file and
> > used by several c files in order to manage the fact that some systems like
> > the solaris ones do not have this function in its libraries. The problem is
> > that libavcodec/opt.c file uses the lrintf function but does not include
> > dsputil.h file.
> 
> maybe dsputil.h is not the best place for the lrintf() mess, maybe common.h
> would be better ...

Would something like the attached patch do?

I have a question about how to best handle #indclude: There are several
places that include both avcodec.h and common.h.  Now avcodec.h
#includes avutil.h, which in turn #includes common.h.  Is it better to
#include common.h explicitly or implicitly?

Diego
-------------- next part --------------
Index: libavcodec/dsputil.h
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/dsputil.h,v
retrieving revision 1.119
diff -u -r1.119 dsputil.h
--- libavcodec/dsputil.h	28 Jun 2005 22:46:36 -0000	1.119
+++ libavcodec/dsputil.h	19 Sep 2005 17:11:59 -0000
@@ -28,7 +28,6 @@
 #ifndef DSPUTIL_H
 #define DSPUTIL_H
 
-#include "common.h"
 #include "avcodec.h"
 
 
@@ -594,33 +593,4 @@
     return score;\
 }
 
-#ifndef HAVE_LRINTF
-/* XXX: add ISOC specific test to avoid specific BSD testing. */
-/* better than nothing implementation. */
-/* btw, rintf() is existing on fbsd too -- alex */
-static always_inline long int lrintf(float x)
-{
-#ifdef CONFIG_WIN32
-#  ifdef ARCH_X86
-    int32_t i;
-    asm volatile(
-        "fistpl %0\n\t"
-        : "=m" (i) : "t" (x) : "st"
-    );
-    return i;
-#  else
-    /* XXX: incorrect, but make it compile */
-    return (int)(x + (x < 0 ? -0.5 : 0.5));
-#  endif
-#else
-    return (int)(rint(x));
-#endif
-}
-#else
-#ifndef _ISOC9X_SOURCE
-#define _ISOC9X_SOURCE
-#endif
-#include <math.h>
-#endif
-
 #endif
Index: libavutil/common.h
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavutil/common.h,v
retrieving revision 1.152
diff -u -r1.152 common.h
--- libavutil/common.h	6 Sep 2005 15:06:16 -0000	1.152
+++ libavutil/common.h	19 Sep 2005 17:11:59 -0000
@@ -543,6 +543,35 @@
     }\
 }
 
+#ifndef HAVE_LRINTF
+/* XXX: add ISOC specific test to avoid specific BSD testing. */
+/* better than nothing implementation. */
+/* btw, rintf() is existing on fbsd too -- alex */
+static always_inline long int lrintf(float x)
+{
+#ifdef CONFIG_WIN32
+#  ifdef ARCH_X86
+    int32_t i;
+    asm volatile(
+        "fistpl %0\n\t"
+        : "=m" (i) : "t" (x) : "st"
+    );
+    return i;
+#  else
+    /* XXX: incorrect, but make it compile */
+    return (int)(x + (x < 0 ? -0.5 : 0.5));
+#  endif /* ARCH_X86 */
+#else
+    return (int)(rint(x));
+#endif /* CONFIG_WIN32 */
+}
+#else
+#ifndef _ISOC9X_SOURCE
+#define _ISOC9X_SOURCE
+#endif
+#include <math.h>
+#endif /* HAVE_LRINTF */
+
 #endif /* HAVE_AV_CONFIG_H */
 
 #endif /* COMMON_H */
Index: libavcodec/mpegaudiodec.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/mpegaudiodec.c,v
retrieving revision 1.59
diff -u -r1.59 mpegaudiodec.c
--- libavcodec/mpegaudiodec.c	1 Jun 2005 21:19:00 -0000	1.59
+++ libavcodec/mpegaudiodec.c	19 Sep 2005 17:11:59 -0000
@@ -26,7 +26,6 @@
 #include "avcodec.h"
 #include "bitstream.h"
 #include "mpegaudio.h"
-#include "dsputil.h"
 
 /*
  * TODO:
Index: libavcodec/mpegvideo.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/mpegvideo.c,v
retrieving revision 1.488
diff -u -r1.488 mpegvideo.c
--- libavcodec/mpegvideo.c	14 Aug 2005 15:42:40 -0000	1.488
+++ libavcodec/mpegvideo.c	19 Sep 2005 17:11:59 -0000
@@ -26,7 +26,6 @@
  */ 
  
 #include "avcodec.h"
-#include "dsputil.h"
 #include "mpegvideo.h"
 #include "faandct.h"
 #include <limits.h>



More information about the ffmpeg-devel mailing list