1 /*
2  * tvtypes.h
3  *
4  * Basic types used in the TV app.
5  *
6  * (C) 1997 Randall Hopper
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met: 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer. 2.
12  * Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions and the following disclaimer in the documentation
14  * and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
20  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  */
29 
30 #ifndef __TVTYPES_H
31 #define __TVTYPES_H
32 
33 #include <sys/param.h>
34 #include <math.h>
35 #include <string.h>
36 
37 typedef unsigned char  TV_UINT8;
38 typedef signed   char  TV_INT8;
39 typedef unsigned short TV_UINT16;
40 typedef short          TV_INT16;
41 typedef unsigned long  TV_UINT32;
42 typedef long           TV_INT32;
43 
44 typedef TV_INT32       TV_BOOL;
45 
46 typedef struct {
47             TV_INT32 x,y,w,h;
48         } TV_GEOM;
49 
50 typedef enum {
51     TV_TRANSFER_STD_IMAGE    = 0x1,
52     TV_TRANSFER_SHMEM_IMAGE  = 0x2,
53     TV_TRANSFER_SHMEM_PIXMAP = 0x4,
54     TV_TRANSFER_DIRECT       = 0x8
55 } TV_TRANSFER_MODE;
56 
57 #define DOUBLE_EPS 1e-7
58 #define FLOAT_EPS  1e-4
59 
60 #define APPROX(x,y,e)    (fabs( (x)-(y) ) < (e))
61 #define INRANGE(x,a,b,e) ( ((x) >= (a)-(e)) && ((x) <= (b)+(e)) )
62 
63 #define SHIFT_AND_MASK(val,lshf,msk)                     \
64            (((lshf) >= 0) ? (((val) <<  (lshf)) & (msk)) \
65                           : (((val) >> -(lshf)) & (msk)))
66 
67 #ifndef MIN
68 #  define MIN(a,b) ((a) < (b) ? (a) : (b))
69 #endif
70 #ifndef MAX
71 #  define MAX(a,b) ((a) > (b) ? (a) : (b))
72 #endif
73 
74 #define STREQ(a,b) (strcmp((a),(b)) == 0)
75 
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79 
80 #ifdef __cplusplus
81 }  /* Close 'extern "C"' */
82 #endif
83 
84 #endif
85