hxcolor.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:21k
源码类别:

Symbian

开发平台:

C/C++

  1. /* ***** BEGIN LICENSE BLOCK ***** 
  2.  * Version: RCSL 1.0/RPSL 1.0 
  3.  *  
  4.  * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. 
  5.  *      
  6.  * The contents of this file, and the files included with this file, are 
  7.  * subject to the current version of the RealNetworks Public Source License 
  8.  * Version 1.0 (the "RPSL") available at 
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed 
  10.  * the file under the RealNetworks Community Source License Version 1.0 
  11.  * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, 
  12.  * in which case the RCSL will apply. You may also obtain the license terms 
  13.  * directly from RealNetworks.  You may not use this file except in 
  14.  * compliance with the RPSL or, if you have a valid RCSL with RealNetworks 
  15.  * applicable to this file, the RCSL.  Please see the applicable RPSL or 
  16.  * RCSL for the rights, obligations and limitations governing use of the 
  17.  * contents of the file.  
  18.  *  
  19.  * This file is part of the Helix DNA Technology. RealNetworks is the 
  20.  * developer of the Original Code and owns the copyrights in the portions 
  21.  * it created. 
  22.  *  
  23.  * This file, and the files included with this file, is distributed and made 
  24.  * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  25.  * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  26.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 
  27.  * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  28.  * 
  29.  * Technology Compatibility Kit Test Suite(s) Location: 
  30.  *    http://www.helixcommunity.org/content/tck 
  31.  * 
  32.  * Contributor(s): 
  33.  *  
  34.  * ***** END LICENSE BLOCK ***** */ 
  35. #include "hxtypes.h"
  36. #include "hxcom.h"
  37. #include "platform/openwave/hxcolor.h"
  38. /* component GUID support */
  39. HX_RESULT HXEXPORT ENTRYPOINT(GetHXColorGUID) (UCHAR* guid)
  40. {
  41.     if (!guid)
  42.     {
  43.     return HXR_FAIL;
  44.     }
  45.     return HXR_OK;
  46. }
  47. /* low-level color converters: */
  48. #include "colorlib.h"
  49. void HXEXPORT ENTRYPOINT(InitColorConverter) ()
  50. {
  51.     /* generate default (CCIR 601-2) conversion tables: */
  52.     SetSrcI420Colors (0, 0, 0, 0);
  53.     SetDestI420Colors (0, 0, 0, 0);
  54.     SetI420ChromaResamplingMode (0);
  55. }
  56. void HXEXPORT ENTRYPOINT(SetColorAdjustments) (float Brightness, float Contrast, float Saturation, float Hue)
  57. {
  58.     /* this will only affect "from I420" converters: */
  59.     SetSrcI420Colors (Brightness, Contrast, Saturation, Hue);
  60. }
  61. void HXEXPORT ENTRYPOINT(GetColorAdjustments) (float* Brightness, float* Contrast, float* Saturation, float* Hue)
  62. {
  63.     /* this will only affect "from I420" converters: */
  64.     GetSrcI420Colors (Brightness, Contrast, Saturation, Hue);
  65. }
  66. #ifdef _FAT_HXCOLOR
  67. int HXEXPORT ENTRYPOINT(SetChromaResamplingMode) (int nNewMode)
  68. {
  69.     return SetI420ChromaResamplingMode (nNewMode);
  70. }
  71. int HXEXPORT ENTRYPOINT(SuggestRGB8Palette) (int nColors, UINT32 *lpRGBVals)
  72. {
  73.     return SuggestDestRGB8Palette (nColors, (unsigned int*) lpRGBVals);
  74. }
  75. int HXEXPORT ENTRYPOINT(SetRGB8Palette) (int nColors, UINT32 *lpRGBVals, int *lpIndices)
  76. {
  77.     SetSrcRGB8Palette (nColors, (unsigned int*) lpRGBVals, lpIndices);
  78.     return SetDestRGB8Palette (nColors, (unsigned int*) lpRGBVals, lpIndices);
  79. }
  80. #endif
  81. /*
  82.  * Currently implemented color Converters (groupped by common input format):
  83.  */
  84. typedef struct {
  85.     int cidOut;                 /* output color format  */
  86.     LPHXCOLORCONVERTER pfnCC;   /* color converter to use */
  87. } CCLINK, *PCCLINK;
  88. typedef struct {
  89.     int cidOut;                 /* output color format  */
  90.     LPHXCOLORCONVERTER2 pfnCC;  /* color converter to use */
  91. } CCLINK2, *PCCLINK2;
  92. /* "I420 to *" converters: */
  93. static CCLINK pcclI420   [] = { {CID_I420,   I420toI420},   
  94.                                 {CID_YV12,   I420toYV12},
  95.                                 {CID_YUY2,   I420toYUY2},   
  96.                                 {CID_UYVY,   I420toUYVY},
  97.                                 {CID_RGB32,  I420toRGB32},  
  98.                                 {CID_RGB24,  I420toRGB24},
  99.                                 {CID_RGB565, I420toRGB565}, 
  100.                                 {CID_RGB555, I420toRGB555},
  101. #ifdef _8_BIT_SUPPORT
  102.                                 {CID_RGB8,   I420toRGB8},   
  103. #endif
  104. #ifdef _FAT_HXCOLOR
  105.                                 {CID_BGR32,  I420toBGR32},
  106. #endif
  107.                                 {CID_ARGB32, I420toRGB32},
  108.                                 {CID_UNKNOWN,0} };
  109. /* "I420 to *x" converters: */
  110. static CCLINK2 pcclI420x   [] = {
  111.                 {CID_I420,   I420toI420x},
  112.                 {CID_YV12,   I420toYV12x},
  113.                 {CID_YUY2,   I420toYUY2x},
  114.                 {CID_UYVY,   I420toUYVYx},
  115.                 {CID_RGB32,  I420toRGB32x},
  116.                 {CID_RGB24,  I420toRGB24x},
  117.                 {CID_RGB565, I420toRGB565x},
  118.                 {CID_RGB555, I420toRGB555x},
  119. #ifdef _8_BIT_SUPPORT
  120.                 {CID_RGB8,   I420toRGB8x},
  121. #endif
  122. #ifdef _FAT_HXCOLOR                
  123.                 {CID_BGR32,  I420toBGR32x},
  124. #endif
  125.                 {CID_ARGB32, I420toRGB32x},
  126.                 {CID_UNKNOWN,0} /* end of list */
  127.                 };
  128. /* "YUV* to *" converters: */
  129. static CCLINK pcclYV12   [] = { {CID_I420,   YV12toI420},   
  130.                                 {CID_YV12,   YV12toYV12},
  131.                                 {CID_YUY2,   YV12toYUY2},   
  132.                                 {CID_UYVY,   YV12toUYVY},
  133.                                 {CID_RGB32,  YV12toRGB32},
  134.                                 {CID_RGB24,  YV12toRGB24},
  135.                                 {CID_RGB565, YV12toRGB565},
  136.                                 {CID_RGB555, YV12toRGB555},
  137. #ifdef _8_BIT_SUPPORT
  138.                                 {CID_RGB8,   YV12toRGB8},
  139. #endif
  140. #ifdef _FAT_HXCOLOR                
  141.                                 {CID_BGR32,  YV12toBGR32},
  142. #endif
  143.                                 {CID_ARGB32, YV12toRGB32},
  144.                                 {CID_UNKNOWN,0} /* end of list */
  145.                                 };
  146. static CCLINK pcclYVU9   [] = { {CID_I420,   YVU9toI420},
  147.                                 {CID_UNKNOWN, 0}};
  148. static CCLINK pcclYUY2 [] = { {CID_YUY2,    YUY2toYUY2},
  149.                               {CID_I420,    YUY2toI420},
  150.                               {CID_UYVY,    YUY2toUYVY},
  151.                               {CID_YV12,    YUY2toYV12},
  152.                               {CID_UNKNOWN, 0}
  153.                             };
  154. static CCLINK pcclYUVU [] = { {CID_I420,    YUVUtoI420},
  155.                               {CID_UNKNOWN, 0}
  156.                             };
  157. static CCLINK pcclUYVY   [] = { {CID_I420,   UYVYtoI420},
  158.                                 {CID_YV12,   UYVYtoYV12},
  159.                                 {CID_YUY2,   UYVYtoYUY2},
  160.                                 {CID_UYVY,   UYVYtoUYVY},
  161.                                 {CID_UNKNOWN, 0}};
  162. /* "YUV* to *x" converters: */
  163. static CCLINK2 pcclYV12x [] = { {CID_I420,   YV12toI420x},   
  164.                                 {CID_YV12,   YV12toYV12x},
  165.                                 {CID_YUY2,   YV12toYUY2x},   
  166.                                 {CID_UYVY,   YV12toUYVYx},
  167.                                 {CID_RGB32,  YV12toRGB32x},
  168.                                 {CID_RGB24,  YV12toRGB24x},
  169.                                 {CID_RGB565, YV12toRGB565x},
  170.                                 {CID_RGB555, YV12toRGB555x},
  171. #ifdef _8_BIT_SUPPORT
  172.                                 {CID_RGB8,   YV12toRGB8x},
  173. #endif
  174. #ifdef _FAT_HXCOLOR                
  175.                                 {CID_BGR32,  YV12toBGR32x},
  176. #endif
  177.                                 {CID_ARGB32, YV12toRGB32x},
  178.                                 {CID_UNKNOWN,0} /* end of list */
  179.                                 };
  180. static CCLINK2 pcclYUY2x [] = { {CID_I420,   YUY2toI420x},
  181.                                 {CID_YV12,   YUY2toYV12x},
  182.                                 {CID_UNKNOWN, 0}};
  183. static CCLINK2 pcclUYVYx [] = { {CID_I420,   UYVYtoI420x},
  184.                                 {CID_YV12,   UYVYtoYV12x},
  185.                                 {CID_UNKNOWN, 0}};
  186. /* "RGB* to *" converters: */
  187. static CCLINK pcclRGB32  [] = { {CID_I420,    RGB32toI420},
  188.                                 {CID_RGB32,   RGB32toRGB32}, 
  189.                                 {CID_RGB24,   RGB32toRGB24},
  190.                                 {CID_RGB565,  RGB32toRGB565}, 
  191.                                 {CID_RGB555,  RGB32toRGB555},
  192. #ifdef _8_BIT_SUPPORT
  193.                                 {CID_RGB8,    RGB32toRGB8},  
  194. #endif
  195. #ifdef _FAT_HXCOLOR
  196.                                 {CID_BGR32,   RGB32toBGR32},
  197. #endif
  198.                                 {CID_ARGB32,  RGB32toRGB32},
  199.                                 {CID_YUVA,    ARGBtoYUVA},
  200.                                 {CID_UNKNOWN, 0} };
  201. static CCLINK pcclARGB32  [] = { {CID_I420,    RGB32toI420},
  202.                                  {CID_RGB32,   RGB32toRGB32},
  203.                                  {CID_ARGB32,  RGB32toRGB32},
  204.                                  {CID_RGB24,   RGB32toRGB24},
  205.                                  {CID_RGB565,  RGB32toRGB565},
  206.                                  {CID_RGB555,  RGB32toRGB555},
  207. #ifdef _8_BIT_SUPPORT
  208.                                  {CID_RGB8,    RGB32toRGB8},
  209. #endif
  210.                                  {CID_BGR32,   RGB32toBGR32},
  211.                                  {CID_RGB32,   RGB32toRGB32},
  212.                                  {CID_YUVA,    ARGBtoYUVA},
  213.                                  {CID_UNKNOWN, 0} };
  214. static CCLINK pcclYUVA  [] = { {CID_UNKNOWN, 0} };
  215. #ifdef _FAT_HXCOLOR
  216. static CCLINK pcclRGB24  [] = { {CID_I420,   RGB24toI420},
  217.                                 {CID_RGB32,  RGB24toRGB32}, 
  218.                                 {CID_RGB24,  RGB24toRGB24},
  219.                                 {CID_RGB565, RGB24toRGB565},
  220.                                 {CID_RGB555, RGB24toRGB555},
  221. #ifdef _8_BIT_SUPPORT
  222.                                 {CID_RGB8,   RGB24toRGB8},  
  223. #endif
  224.                                 {CID_BGR32,  RGB24toBGR32},
  225.                                 {CID_ARGB32,  RGB24toRGB32}, 
  226.                                 {CID_UNKNOWN,0}};
  227. #else
  228. static CCLINK pcclRGB24  [] = { {CID_UNKNOWN,0} };
  229. #endif
  230. #ifdef _FAT_HXCOLOR
  231. static CCLINK pcclRGB565 [] = { {CID_I420,   RGB565toI420},
  232.                                 {CID_RGB32,  RGB565toRGB32},
  233.                                 {CID_RGB24,  RGB565toRGB24},
  234.                                 {CID_RGB565, RGB565toRGB565},
  235.                                 {CID_RGB555,RGB565toRGB555},
  236. #ifdef _8_BIT_SUPPORT
  237.                                 {CID_RGB8,   RGB565toRGB8}, 
  238. #endif
  239.                                 {CID_BGR32,  RGB565toBGR32},
  240.                                 {CID_ARGB32,  RGB565toRGB32},
  241.                                 {CID_UNKNOWN,0}};
  242. #else
  243. static CCLINK pcclRGB565 [] = { {CID_UNKNOWN,0} };
  244. #endif
  245. #ifdef _FAT_HXCOLOR
  246. static CCLINK pcclRGB555 [] = { {CID_I420,   RGB555toI420},
  247.                                 {CID_RGB32,  RGB555toRGB32},
  248.                                 {CID_RGB24,  RGB555toRGB24},
  249.                                 {CID_RGB565, RGB555toRGB565},
  250.                                 {CID_RGB555,RGB555toRGB555},
  251. #ifdef _8_BIT_SUPPORT
  252.                                 {CID_RGB8,   RGB555toRGB8}, 
  253. #endif
  254.                                 {CID_BGR32,  RGB555toBGR32},
  255.                                 {CID_ARGB32,  RGB555toRGB32},
  256.                                 {CID_UNKNOWN,0}};
  257. #else
  258. static CCLINK pcclRGB555 [] = { {CID_UNKNOWN,0} };
  259. #endif
  260. #ifdef _8_BIT_SUPPORT
  261. static CCLINK pcclRGB8   [] = { {CID_I420,   RGB8toI420},
  262.                                 {CID_RGB32,  RGB8toRGB32},  
  263.                                 {CID_RGB24,  RGB8toRGB24},
  264.                                 {CID_RGB565, RGB8toRGB565}, 
  265.                                 {CID_RGB555, RGB8toRGB555},
  266.                                 {CID_RGB8,   RGB8toRGB8},   
  267.                                 {CID_BGR32,  RGB8toBGR32},
  268.                                 {CID_ARGB32,  RGB8toRGB32},
  269.                                 {CID_UNKNOWN,0}};
  270. #else
  271. static CCLINK pcclRGB8   [] = { {CID_UNKNOWN, 0} };
  272. #endif
  273. /* "XING to *" converters: */
  274. static CCLINK pcclXing   [] = { {CID_YV12,   XINGtoYV12}, 
  275.                                 {CID_YUY2,   XINGtoYUY2},
  276.                                 {CID_UYVY,   XINGtoUYVY},
  277.                                 {CID_RGB32, XINGtoRGB32}, 
  278.                                 {CID_RGB24, XINGtoRGB24},
  279.                                 {CID_RGB565, XINGtoRGB565}, 
  280. #ifdef _8_BIT_SUPPORT
  281.                                 {CID_RGB8, XINGtoRGB8},
  282. #endif
  283.                                 {CID_ARGB32, XINGtoRGB32}, 
  284.                                 {CID_UNKNOWN,0} 
  285. };
  286. /* "BGR* to *" converters: */
  287. static CCLINK pcclBGR32  [] = { {CID_I420,    BGR_32toI420},
  288.                                 {CID_UNKNOWN,0} 
  289. };
  290. static CCLINK pcclBGR24  [] = { {CID_I420,    BGR24toI420},
  291.                                 {CID_UNKNOWN,0} 
  292. };
  293. /* unsupported input formats: */
  294. static CCLINK pcclUNKNOWN [] = {{CID_UNKNOWN, 0}};
  295. /*
  296.  * Color formats/Converters map:
  297.  */
  298. static PCCLINK ppcclColorMap[] =
  299. {
  300.     pcclI420, 
  301.     pcclYV12, 
  302.     pcclYVU9, 
  303.     pcclYUY2, 
  304.     pcclUYVY,
  305.     pcclRGB32, 
  306.     pcclRGB24, 
  307.     pcclRGB565, 
  308.     pcclRGB555, 
  309.     pcclRGB8, 
  310.     pcclXing,
  311.     pcclARGB32, 
  312.     pcclYUVA,
  313. pcclYUVU,
  314.     pcclUNKNOWN,
  315.     pcclBGR32,
  316.     pcclBGR24
  317. };
  318. /*
  319.  * Retrieve the list of color formats that can be converted to, given an input
  320.  * format
  321.  * Use:
  322.  *  HX_RESULT GetCompatibleColorFormats (INT32 cidIn, INT32* pcidOut, UINT32* pnSize);
  323.  * Input:
  324.  *  cidIn - input color format ID (!CID_UNKNOWN)
  325.  *  pcidOut - in - empty array, out - filled array of supported output formats
  326.  *  pnSize - in - size of array, out - number of elements in array
  327.  * Returns:
  328.  *  result
  329.  */HX_RESULT HXEXPORT ENTRYPOINT(GetCompatibleColorFormats)(
  330.     INT32 cidIn /* in */, 
  331.     INT32* pcidOut /* in/out */, 
  332.     UINT32* pnSize /* in/out */)
  333. {
  334.     HX_RESULT res = HXR_FAIL;
  335.         /* check parameters: */
  336.     int nConversions = sizeof(ppcclColorMap)/sizeof(PCCLINK);
  337.     if(cidIn >= 0 && cidIn < nConversions && pcidOut && pnSize) 
  338.     {
  339. UINT32 nFormats = 0;
  340.         /* scan color map: */
  341.         PCCLINK pccl = ppcclColorMap [cidIn];
  342.         while(pccl && pccl->cidOut != CID_UNKNOWN && nFormats < *pnSize) 
  343. {
  344.     pcidOut[nFormats] = pccl->cidOut;
  345.             /* try next element in the list: */
  346.             pccl++;
  347.     nFormats++;
  348.         }
  349. res = HXR_OK;
  350. *pnSize = nFormats;
  351.     }
  352.     return res;
  353. }
  354. /*
  355.  * Find Converter to trasform data in format X to format Y.
  356.  * Use:
  357.  *  LPHXCOLORCONVERTER GetColorConverter (INT32 cidIn, INT32 cidOut);
  358.  * Input:
  359.  *  cidIn - input color format ID (!CID_UNKNOWN)
  360.  *  cidOut - desirable output color format ID (!CID_UNKNOWN)
  361.  * Returns:
  362.  *  pointer to an appropriate color conversion routine, if success;
  363.  *  NULL - conversion is not supported.
  364.  */
  365. LPHXCOLORCONVERTER HXEXPORT ENTRYPOINT(GetColorConverter) (INT32 cidIn, INT32 cidOut)
  366. {
  367.     /* check parameters: */
  368.     int nConversions = sizeof(ppcclColorMap)/sizeof(PCCLINK);
  369.     if (cidIn >= 0 && cidIn < nConversions &&
  370.         cidOut >= 0 && cidOut <= NFORMATS) {
  371.         /* scan color map: */
  372.         PCCLINK pccl = ppcclColorMap [cidIn];
  373.         while (pccl &&
  374.                pccl->cidOut != CID_UNKNOWN) {
  375.             /* check output format:  */
  376.             if (pccl->cidOut == cidOut)
  377.                 return pccl->pfnCC;
  378.             /* try next element in the list: */
  379.             pccl ++;
  380.         }
  381.     }
  382.     return NULL;
  383. }
  384. LPHXCOLORCONVERTER2 HXEXPORT ENTRYPOINT(GetColorConverter2) (INT32 cidIn, INT32 cidOut)
  385. {
  386.     CCLINK2 *pTemp = NULL;
  387.     /* check parameters: */
  388.     if (cidIn == CID_I420)
  389.     {
  390.         pTemp = pcclI420x;
  391.     }
  392.     else if (cidIn == CID_YV12)
  393.     {
  394.         pTemp = pcclYV12x;
  395.     }
  396.     else if (cidIn == CID_YUY2)
  397.     {
  398.         pTemp = pcclYUY2x;
  399.     }
  400.     else if (cidIn == CID_UYVY)
  401.     {
  402.         pTemp = pcclUYVYx;
  403.     }
  404.     if (pTemp)
  405.     {
  406.         /* scan color map: */
  407.         for (int i=0; pTemp[i].cidOut != CID_UNKNOWN; i++)
  408.         {
  409.             /* check output format:  */
  410.             if (pTemp[i].cidOut == cidOut)
  411.                 return pTemp[i].pfnCC;
  412.         }
  413.     }
  414.     return NULL;
  415. }
  416. /// Because ADS1.2 armcpp crash bug, we will not using these function on Openwave platform.
  417. #ifndef ADS12
  418. /*
  419.  * Try selected compatible color formats.
  420.  * Use:
  421.  *  BOOL ScanCompatibleColorFormats (INT32 cidIn, INT32 cidOutMask, void *pParam,
  422.  *      BOOL (*pfnTryIt) (void *pParam, INT32 cidOut, LPHXCOLORCONVERTER pfnCC));
  423.  * Input:
  424.  *  cidIn - input color format ID (!CID_UNKNOWN)
  425.  *  cidOutMask - masks output formats to try (use ~0 to scan all formats)
  426.  *  pParam - pointer to a parameter block to pass to fpTryIt ()
  427.  *  pfnTryIt - pointer to a function, which will be called for each
  428.  *          compatible output format;
  429.  * Returns:
  430.  *  TRUE, if fpTryIt() has exited with TRUE status;
  431.  *  FALSE, if non of the compatible formats has been accepted by fpTryIt().
  432.  */
  433. BOOL HXEXPORT ENTRYPOINT(ScanCompatibleColorFormats) (INT32 cidIn, INT32 cidOutMask, void *pParam,
  434.                                                       BOOL (*pfnTryIt) (void *pParam, INT32 cidOut, LPHXCOLORCONVERTER pfnCC),INT32)
  435. {
  436.     /* check parameters: */
  437.     int nConversions = sizeof(ppcclColorMap)/sizeof(PCCLINK);
  438.     if (cidIn >= 0 && cidIn < nConversions && pfnTryIt != NULL) {
  439.         /* scan color map: */
  440.         PCCLINK pccl = ppcclColorMap [cidIn];
  441.         while (pccl->cidOut != CID_UNKNOWN) {
  442.             /* try this format: */
  443.             if ((cidOutMask & (1U << pccl->cidOut)) &&
  444.                 (* pfnTryIt) (pParam, pccl->cidOut, pccl->pfnCC))
  445.                 return TRUE;
  446.             /* try next element in the list: */
  447.             pccl ++;
  448.         }
  449.     }
  450.     return FALSE;
  451. }
  452. /*
  453.  * Try all compatible color formats.
  454.  */
  455. BOOL HXEXPORT ENTRYPOINT(ScanAllCompatibleColorFormats) (BOOL (*pfnTryIt) (void *pParam, INT32 cidOut, LPHXCOLORCONVERTER pfnCC)
  456.                                                         ,INT32 cidIn,void *pParam)
  457. {
  458.     return ENTRYPOINT(ScanCompatibleColorFormats) (cidIn, (INT32)~0, pParam,pfnTryIt);
  459. }
  460. #endif
  461. /***********************
  462.  * Old HXCOLOR.DLL interface:
  463.  ****************************************************/
  464. #ifdef _FAT_HXCOLOR
  465. /*
  466.  * Converts a YUV buffer into an RGB buffer in the specified format.
  467.  */
  468. void HXEXPORT ENTRYPOINT(ConvertYUVtoRGB) (UCHAR* ySrc, UCHAR* uSrc, UCHAR* vSrc,
  469.                                            INT32  nPitchSrc,
  470.                                            UCHAR* Dst, INT32  nWidth, INT32 nHeight,
  471.                                            INT32  nPitchDst, INT16 nFormat, INT16 nExpand)
  472. {
  473. #if defined(_WINDOWS) || defined(_UNIX)
  474.     static void (*cc []) (unsigned char *, unsigned char *, unsigned char *, int, unsigned char *, int, int, int) =
  475.     {
  476.         oldI420toRGB24,   oldI420toRGB555,   oldI420toRGB565,
  477.         oldI420toRGB24x2, oldI420toRGB555x2, oldI420toRGB565x2
  478.     };
  479.     /* get function index: */
  480.     register int idx = (nFormat - T_RGB888);
  481.     if (idx < 0 || idx > 2) return;         /* bad format */
  482.     if (nExpand) idx += 3;
  483.     /* call color converter/interpolator: */
  484.     (* cc [idx]) (ySrc, uSrc, vSrc, nPitchSrc, Dst, nWidth, nHeight, nPitchDst);
  485. #elif defined (_MACINTOSH)
  486.     /* Mac version uses big endian RGB32 format only.
  487.      * Note, that our *->RGB32 converters will generate correct output
  488.      * on both LE & BE machines: */
  489.     (nExpand? oldI420toRGB32x2: oldI420toRGB32)
  490.         (ySrc, uSrc, vSrc, nPitchSrc, Dst, nWidth, nHeight, nPitchDst);
  491. #endif
  492. }
  493. void HXEXPORT ENTRYPOINT(ConvertYUVtoMacRGB32) (UCHAR* ySrc, UCHAR* uSrc, UCHAR* vSrc, INT32  nPitchSrc,
  494.         UCHAR* Dst, INT32  nWidth, INT32  nHeight, INT32  nPitchDst, INT16  nFormat, INT16  nExpand)
  495. {
  496.     /* Mac version uses big endian RGB32 format only.
  497.      * Note, that our *->RGB32 converters will generate correct output
  498.      * on both LE & BE machines: */
  499.     (nExpand? oldI420toRGB32x2: oldI420toRGB32)
  500.         (ySrc, uSrc, vSrc, nPitchSrc, Dst, nWidth, nHeight, nPitchDst);
  501. }
  502. /*
  503.  * Converts a 24bit RGB Buffer into a 32bit RGB buffer, used mainly on the Macintosh.
  504.  */
  505. void HXEXPORT ENTRYPOINT(ConvertRGB24toXRGB) (UCHAR* pSrc, UCHAR* pDest,
  506.     ULONG32 srcSize, ULONG32 destSize, INT32 nWidth, INT32 nHeight)
  507. {
  508.     /* this shall generate a correct padded RGB32 on both LE & BE machines: */
  509.     RGB24toRGB32 (pDest, nWidth, nHeight, (nWidth*3+3)&~3, 0, 0, nWidth, nHeight,
  510.                  pSrc, nWidth, nHeight, nWidth * 4, 0, 0, nWidth, nHeight);
  511. }
  512. /*
  513.  * Converts a RGB3 buffer into a YUV buffer in Y'CbCr 4:2:0 format.
  514.  */
  515. void HXEXPORT ENTRYPOINT(ConvertRGBtoYUV) (UCHAR* pInput, UCHAR* pOutput,
  516.     INT32 nWidth, INT32 nHeight, BOOL bBGR)
  517. {
  518.     /* ignore bBRG for now: */
  519.     RGB24toI420 (pOutput, nWidth, nHeight, (nWidth*3+3)&~3, 0, 0, nWidth, nHeight,
  520.                 pInput, nWidth, nHeight, nWidth, 0, 0, nWidth, nHeight);
  521. }
  522. #endif