Added gst-plugins-base-subtitles0.10-0.10.34 for Meego Harmattan 1.2
[mafwsubrenderer] / gst-plugins-base-subtitles0.10 / gst-libs / gst / floatcast / floatcast.h
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  * Library       <2002> Steve Baker <stevebaker_org@yahoo.co.uk>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 /**
22  * SECTION:gstfloatcast
23  * @short_description: Floating point platform independence macros
24  *
25  * The floatcast.h header file contains a couple of convenience macros for
26  * floating point numbers.
27  *
28  * If you include this header, your application or library must link against
29  * libm (for maths.h support).
30  *
31  * For optimal results, your application&apos;s or library&apos;s build
32  * system should check whether the C99 functions lrint and lrintf are supported
33  * and define the preprocessor symbols HAVE_LRINT and HAVE_LRINTF if so.  If
34  * you are using autoconf, you can do this by using the AC_C99_FUNC_LRINT and
35  * AC_C99_FUNC_LRINTF checks in your configure.ac or configure.in file and
36  * including your application's config.h header before you include floatcast.h.
37  */
38
39 #ifndef __FLOATCAST_H__
40 #define __FLOATCAST_H__
41
42 #include <string.h>
43 #include <glib.h>
44
45 #if defined (_MSC_VER) && !defined (inline)
46 #define inline __inline
47 #endif
48
49 G_BEGIN_DECLS
50
51 /* FIXME 0.11: these gst_cast_*() functions are not used anywhere, so we could
52  * just as well get rid of them and move the float/double swap macros into
53  * gstutils.h in core */
54
55 /**
56  * gst_cast_float:
57  * @x: input value
58  *
59  * Casts a 32-bit floating point value (float) to an integer without bias.
60  */
61 /**
62  * gst_cast_double:
63  * @x: input value
64  *
65  * Casts a 64-bit floating point value (double) to an integer without bias.
66  */
67
68 /* FIXME: HAVE_LRINT && HAVE_LRINTF are defined by config.h - they should
69  * not be used in an installed header. */
70 #if defined(HAVE_LRINT) && defined(HAVE_LRINTF)
71
72         /*      These defines enable functionality introduced with the 1999 ISO C
73         **      standard. They must be defined before the inclusion of math.h to
74         **      engage them. If optimisation is enabled, these functions will be 
75         **      inlined. With optimisation switched off, you have to link in the
76         **      maths library using -lm.
77         */
78
79         #define _ISOC9X_SOURCE  1
80         #define _ISOC99_SOURCE  1
81
82         #define __USE_ISOC9X    1
83         #define __USE_ISOC99    1
84
85         #include        <math.h>
86
87         #define gst_cast_float(x)       ((gint)lrintf(x))
88         #define gst_cast_double(x)      ((gint)lrint(x))
89
90 #else
91         #include <math.h>
92
93         /* use a standard c cast, but do rounding correctly */
94         #define gst_cast_float(x)       ((gint)floor((x)+0.5))
95         #define gst_cast_double(x)      ((gint)floor((x)+0.5))
96
97 #endif
98
99 G_END_DECLS
100
101 #endif /* __FLOATCAST_H__ */
102