MHEG5  15.3.0
source/graphics/inc/mg_ctxt.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
00003  * Copyright © 2009 Ocean Blue Software Ltd
00004  *
00005  * This file is part of a DTVKit Software Component
00006  * You are permitted to copy, modify or distribute this file subject to the terms
00007  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
00008  * 
00009  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
00010  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
00011  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
00012  * 
00013  * If you or your organisation is not a member of DTVKit then you have access
00014  * to this source code outside of the terms of the licence agreement
00015  * and you are expected to delete this and any associated files immediately.
00016  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
00017  *******************************************************************************/
00025 #ifndef _MG_CTXT_H
00026 #define _MG_CTXT_H
00027 
00028 #include "mheg5_control.h" /* for colour format defs */
00029 
00030 #ifdef OSD_8_BIT
00031  #if defined(OSD_16_BIT) || defined(OSD_31_BIT) || defined(OSD_32_BIT)
00032   #define MULTIPLE_COLOUR_FORMATS
00033  #endif
00034 #elif defined(OSD_16_BIT)
00035  #if defined(OSD_31_BIT) || defined(OSD_32_BIT)
00036   #define MULTIPLE_COLOUR_FORMATS
00037  #endif
00038 #elif defined(OSD_31_BIT) && defined(OSD_32_BIT)
00039   #define MULTIPLE_COLOUR_FORMATS
00040 #endif
00041 
00042 #if defined(OSD_31_BIT) /*ST colour*/
00043  #if defined(OSD_32_BIT)
00044   #define MAX_ALPHA           mg_ctxt.max_alpha
00045  #else
00046   #define MAX_ALPHA           0x80
00047  #endif
00048  #define CalcAlpha(a)         (((a) * MAX_ALPHA) / 255)
00049  #define AlphaCalc(a)         (((a) * 255) / MAX_ALPHA)
00050  #define ConvertAlpha(oc, nc)  nc = CalcAlpha(oc >> 24); nc <<= 24; nc |= oc & 0x00ffffff;
00051  #define AlphaPlatform(oc)    (oc == 0) ? 0 : (CalcAlpha(oc >> 24) << 24) | (oc & 0x00ffffff)
00052  #define AlphaStandard(oc)    (oc == 0) ? 0 : (AlphaCalc(oc >> 24) << 24) | (oc & 0x00ffffff)
00053 #elif defined(OSD_32_BIT)
00054  #define MAX_ALPHA            0xff
00055  #define CalcAlpha(a)         a
00056  #define ConvertAlpha(oc, nc)  nc = oc;
00057  #define AlphaPlatform(oc)    oc
00058  #define AlphaStandard(oc)    oc
00059 #endif
00060 
00061 #ifdef MULTIPLE_COLOUR_FORMATS
00062  #define IF_COL_DEPTH(cd)     if (mg_ctxt.colour_format == cd)
00063  #define ELSE                 else
00064 #else
00065  #define IF_COL_DEPTH(cd)
00066  #define ELSE
00067 #endif
00068 
00069 #define BytesPerPixel(cf)  ((cf + 7) >> 3)
00070 
00071 typedef struct s_ratio
00072 {
00073    U16BIT mlt;
00074    U16BIT div;
00075 } S_RATIO;
00076 
00077 typedef struct _MGContext
00078 {
00079    U16BIT out_video_width;        /* video screen width  */
00080    U16BIT out_video_height;       /* video screen height */
00081    U16BIT out_osd_width;          /* OSD output screen width  */
00082    U16BIT out_osd_height;         /* OSD output screen height */
00083    U16BIT input_width;            /* input width (mheg normally 720 or 360, hbbtv 1280) */
00084    U16BIT input_height;           /* input height (mheg normally 576 or 288, hbbtv 720) */
00085    S_RATIO osd_x;
00086    S_RATIO osd_y;
00087    S_RATIO vid_x;
00088    S_RATIO vid_y;
00089    S_RATIO line_w;
00090    void *hw_handle;
00091    void *screen_buff;
00092    U32BIT screen_stride;
00093    U8BIT colour_format;           /* Colour depth in bits per pixel - 8,16,31,32 */
00094 #if defined(OSD_31_BIT) && defined(OSD_32_BIT)
00095    U8BIT max_alpha;
00096 #endif
00097 } S_MGContext;
00098 
00099 extern S_MGContext mg_ctxt;
00100 
00101 #define HD_W_SCALEUP(w)       (((S32BIT)(w) * mg_ctxt.line_w.mlt) / mg_ctxt.line_w.div)
00102 
00103 #define HD_X_SCALEUP(x)       (((S32BIT)(x) * mg_ctxt.osd_x.mlt) / mg_ctxt.osd_x.div)
00104 
00105 #define HD_Y_SCALEUP(y)       (((S32BIT)(y) * mg_ctxt.osd_y.mlt) / mg_ctxt.osd_y.div)
00106 
00107 #endif /*_MG_CTXT_H*/
 All Data Structures Files Functions Variables Typedefs Defines