MHEG  17.9.0
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Pages
osd_utils.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2006 Ocean Blue Software Ltd
4  *
5  * This file is part of a DTVKit Software Component
6  * You are permitted to copy, modify or distribute this file subject to the terms
7  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
8  *
9  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
10  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
11  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
12  *
13  * If you or your organisation is not a member of DTVKit then you have access
14  * to this source code outside of the terms of the licence agreement
15  * and you are expected to delete this and any associated files immediately.
16  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
17  *******************************************************************************/
25 #ifndef _OSD_UTILS_H
26 #define _OSD_UTILS_H
27 
28 /*---includes for this file--------------------------------------------------*/
29 
30 /* compiler library header files */
31 
32 /* third party header files */
33 
34 /* OBS header files */
35 #include <techtype.h>
36 
37 /*---Constant and macro definitions for public use-----------------------------*/
38 
39 /* Macros to extract red, green, blue, transparent and alpha values from an
40  * OSDColor value
41  */
42 #define GetRValue(osdcolour) (((osdcolour) >> 16) & 0xff)
43 #define GetGValue(osdcolour) (((osdcolour) >> 8) & 0xff)
44 #define GetBValue(osdcolour) ((osdcolour) & 0xff)
45 #define GetTValue(osdcolour) (((osdcolour) >> 24) ^ 0xff)
46 #define GetAValue(osdcolour) ((osdcolour) >> 24)
47 
48 
49 /* Macros to convert from discrete red, green, blue and transparent values to
50  * OSDColor values
51  */
52 #define RGB(r, g, b) (0xff000000 | ((r) << 16) | ((g) << 8) | (b))
53 #define RGBT(r, g, b, t) ((((t) ^ 0xff) << 24) | ((r) << 16) | ((g) << 8) | (b))
54 #define RGBA(r, g, b, a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
55 
56 #define MakeHD2Color(osdcol) (((osdcol >> 16) & 0xf000) | ((osdcol >> 12) & 0x0f00) \
57  | ((osdcol >> 8) & 0x00f0) | ((osdcol >> 4) & 0x000f))
58 
59 /*
60  * HD2Colour is two byte colour, again in the ARGB format:
61  * Alpha bits 15..12
62  * Red bits 11..8
63  * Green bits 7.. 4
64  * Blue bits 3.. 0
65  *
66  * Note:
67  * For bits 15..12, the value of 0xf represents completely opaque,
68  * and the value of 0x0 represents completely transparent.
69  */
70 typedef U16BIT HD2Color;
71 
72 
73 #ifdef OSD_8_BIT
74 
75  #ifndef PALETTE_OFFSET
76  #define PALETTE_OFFSET 0
77  #endif
78  #define OFFSET_TRANS (PALETTE_OFFSET + 0)
79  #define OFFSET_OPAQUE (PALETTE_OFFSET + 49)
80 extern OSDColor *mg_palette;
81 
82 
83 /*---Enumerations for public use-----------------------------------------------*/
84 
85 /*---Global type defs for public use-------------------------------------------*/
86 
87 /*---Global Function prototypes for public use---------------------------------*/
88 
89 /*!**************************************************************************
90  * @fn OSD_FindNearestColourIndex
91  * @brief Return nearest colour index.
92  * @param U8BIT r Red component of colour
93  * U8BIT g Green component of colour
94  * U8BIT b Blue component of colour
95  * U8BIT a Alpha component of colour
96  * @return U8BIT Index of nearest colour in the
97  * MHEG palette
98  * @warning This function depends on the order of the MHEG palette.
99  * @bug
100  ****************************************************************************/
101 extern U8BIT OSD_FindNearestColourIndex(OSDColor target);
102 
103 /*!**************************************************************************
104  * @fn OSD_BlendPixels
105  * @brief Plots pixels into a buffer, comparing the new and old values to
106  * ensure that pixels with transparent components are correctly
107  * blended together.
108  * @param U8BIT* pixel Destination pointer for the pixel
109  * This contains the old pixel
110  * U8BIT colour Colour index of the new pixel
111  * @return None
112  * @warning None
113  * @bug None
114  ****************************************************************************/
115 void OSD_BlendPixels(U8BIT *pixel, U8BIT colour);
116 
117 /*!**************************************************************************
118  * @fn OSD_IsColourOpaque
119  * @brief Tell whether a colour is opaque or not
120  * @param U8BIT colour The colour
121  * @return TRUE if the colour is opaque, FALSE otherwise
122  * @warning This function depends on the order of the MHEG palette.
123  * @bug None.
124  ****************************************************************************/
125 /* BOOLEAN OSD_IsColourOpaque(U8BIT colour); */
126  #define OSD_IsColourOpaque(colour) (colour >= OFFSET_OPAQUE)
127 
128 #endif /*OSD_8_BIT*/
129 
130 #endif /* _OSD_UTILS_H */
131 
System Wide Global Technical Data Type Definitions.