MHEG  17.9.0
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Pages
mg_ctxt.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2009 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 _MG_CTXT_H
26 #define _MG_CTXT_H
27 
28 #include "mheg5_control.h" /* for colour format defs */
29 
30 #ifdef OSD_8_BIT
31  #if defined(OSD_16_BIT) || defined(OSD_31_BIT) || defined(OSD_32_BIT)
32  #define MULTIPLE_COLOUR_FORMATS
33  #endif
34 #elif defined(OSD_16_BIT)
35  #if defined(OSD_31_BIT) || defined(OSD_32_BIT)
36  #define MULTIPLE_COLOUR_FORMATS
37  #endif
38 #elif defined(OSD_31_BIT) && defined(OSD_32_BIT)
39  #define MULTIPLE_COLOUR_FORMATS
40 #endif
41 
42 #if defined(OSD_31_BIT) /*ST colour*/
43  #if defined(OSD_32_BIT)
44  #define MAX_ALPHA mg_ctxt.max_alpha
45  #else
46  #define MAX_ALPHA 0x80
47  #endif
48  #define CalcAlpha(a) (((a) * MAX_ALPHA) / 255)
49  #define AlphaCalc(a) (((a) * 255) / MAX_ALPHA)
50  #define ConvertAlpha(oc, nc) nc = CalcAlpha(oc >> 24); nc <<= 24; nc |= oc & 0x00ffffff;
51  #define AlphaPlatform(oc) (oc == 0) ? 0 : (CalcAlpha(oc >> 24) << 24) | (oc & 0x00ffffff)
52  #define AlphaStandard(oc) (oc == 0) ? 0 : (AlphaCalc(oc >> 24) << 24) | (oc & 0x00ffffff)
53 #elif defined(OSD_32_BIT)
54  #define MAX_ALPHA 0xff
55  #define CalcAlpha(a) a
56  #define ConvertAlpha(oc, nc) nc = oc;
57  #define AlphaPlatform(oc) oc
58  #define AlphaStandard(oc) oc
59 #endif
60 
61 #ifdef MULTIPLE_COLOUR_FORMATS
62  #define IF_COL_DEPTH(cd) if (mg_ctxt.colour_format == cd)
63  #define ELSE else
64 #else
65  #define IF_COL_DEPTH(cd)
66  #define ELSE
67 #endif
68 
69 #define BytesPerPixel(cf) ((cf + 7) >> 3)
70 
71 typedef struct s_ratio
72 {
73  U16BIT mlt;
74  U16BIT div;
75 } S_RATIO;
76 
77 typedef struct _MGContext
78 {
79  U16BIT out_video_width; /* video screen width */
80  U16BIT out_video_height; /* video screen height */
81  U16BIT out_osd_width; /* OSD output screen width */
82  U16BIT out_osd_height; /* OSD output screen height */
83  U16BIT input_width; /* input width (mheg normally 720 or 360, hbbtv 1280) */
84  U16BIT input_height; /* input height (mheg normally 576 or 288, hbbtv 720) */
85  S_RATIO osd_x;
86  S_RATIO osd_y;
87  S_RATIO vid_x;
88  S_RATIO vid_y;
89  S_RATIO line_w;
90  void *hw_handle;
91  void *screen_buff;
92  U32BIT screen_stride;
93  U16BIT offset_left; /* non-zero where need to scale from 16:9 to 4:3 - value of out_osd_width/8 */
94  U8BIT colour_format; /* Colour depth in bits per pixel - 8,16,31,32 */
95 #if defined(OSD_31_BIT) && defined(OSD_32_BIT)
96  U8BIT max_alpha;
97 #endif
98 } S_MGContext;
99 
100 extern S_MGContext mg_ctxt;
101 
102 #define HD_W_SCALEUP(w) (((S32BIT)(w) * mg_ctxt.line_w.mlt) / mg_ctxt.line_w.div)
103 
104 #define HD_X_SCALEUP(x) (((S32BIT)(x) * mg_ctxt.osd_x.mlt) / mg_ctxt.osd_x.div)
105 
106 #define HD_Y_SCALEUP(y) (((S32BIT)(y) * mg_ctxt.osd_y.mlt) / mg_ctxt.osd_y.div)
107 
108 #endif /*_MG_CTXT_H*/
Definition: mg_ctxt.h:71
This file provides the control interface for MHEG5 engine. The use of this component MUST comply with...
Definition: mg_ctxt.h:77