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 "hxcolor.h"
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* component GUID support */
  42. HX_RESULT HXEXPORT ENTRYPOINT(GetHXColorGUID) (UCHAR* guid)
  43. {
  44.     if (!guid)
  45.     {
  46.     return HXR_FAIL;
  47.     }
  48.     return HXR_OK;
  49. }
  50. /* low-level color converters: */
  51. #include "colorlib.h"
  52. void HXEXPORT ENTRYPOINT(InitColorConverter) ()
  53. {
  54.     /* generate default (CCIR 601-2) conversion tables: */
  55.     SetSrcI420Colors (0, 0, 0, 0);
  56.     SetDestI420Colors (0, 0, 0, 0);
  57.     SetI420ChromaResamplingMode (0);
  58. }
  59. void HXEXPORT ENTRYPOINT(SetColorAdjustments) (float Brightness, float Contrast, float Saturation, float Hue)
  60. {
  61.     /* this will only affect "from I420" converters: */
  62.     SetSrcI420Colors (Brightness, Contrast, Saturation, Hue);
  63. }
  64. void HXEXPORT ENTRYPOINT(GetColorAdjustments) (float* Brightness, float* Contrast, float* Saturation, float* Hue)
  65. {
  66.     /* this will only affect "from I420" converters: */
  67.     GetSrcI420Colors (Brightness, Contrast, Saturation, Hue);
  68. }
  69. #ifdef _FAT_HXCOLOR
  70. int HXEXPORT ENTRYPOINT(SetChromaResamplingMode) (int nNewMode)
  71. {
  72.     return SetI420ChromaResamplingMode (nNewMode);
  73. }
  74. int HXEXPORT ENTRYPOINT(SuggestRGB8Palette) (int nColors, UINT32 *lpRGBVals)
  75. {
  76.     return SuggestDestRGB8Palette (nColors, (unsigned int*) lpRGBVals);
  77. }
  78. int HXEXPORT ENTRYPOINT(SetRGB8Palette) (int nColors, UINT32 *lpRGBVals, int *lpIndices)
  79. {
  80.     SetSrcRGB8Palette (nColors, (unsigned int*) lpRGBVals, lpIndices);
  81.     return SetDestRGB8Palette (nColors, (unsigned int*) lpRGBVals, lpIndices);
  82. }
  83. #endif
  84. /*
  85.  * Currently implemented color Converters (groupped by common input format):
  86.  */
  87. typedef struct {
  88.     int cidOut;                 /* output color format  */
  89.     LPHXCOLORCONVERTER pfnCC;   /* color converter to use */
  90. } CCLINK, *PCCLINK;
  91. typedef struct {
  92.     int cidOut;                 /* output color format  */
  93.     LPHXCOLORCONVERTER2 pfnCC;  /* color converter to use */
  94. } CCLINK2, *PCCLINK2;
  95. /* "I420 to *" converters: */
  96. static CCLINK pcclI420   [] = { {CID_I420,   I420toI420},   
  97.                                 {CID_YV12,   I420toYV12},
  98.                                 {CID_YUY2,   I420toYUY2},   
  99.                                 {CID_UYVY,   I420toUYVY},
  100.                                 {CID_RGB32,  I420toRGB32},  
  101.                                 {CID_RGB24,  I420toRGB24},
  102.                                 {CID_RGB565, I420toRGB565}, 
  103.                                 {CID_RGB555, I420toRGB555},
  104. #ifdef _8_BIT_SUPPORT
  105.                                 {CID_RGB8,   I420toRGB8},   
  106. #endif
  107. #ifdef _FAT_HXCOLOR
  108.                                 {CID_BGR32,  I420toBGR32},
  109. #endif
  110.                                 {CID_ARGB32, I420toRGB32},
  111.                                 {CID_UNKNOWN,0} };
  112. /* "I420 to *x" converters: */
  113. static CCLINK2 pcclI420x   [] = {
  114.                 {CID_I420,   I420toI420x},
  115.                 {CID_YV12,   I420toYV12x},
  116.                 {CID_YUY2,   I420toYUY2x},
  117.                 {CID_UYVY,   I420toUYVYx},
  118.                 {CID_RGB32,  I420toRGB32x},
  119.                 {CID_RGB24,  I420toRGB24x},
  120.                 {CID_RGB565, I420toRGB565x},
  121.                 {CID_RGB555, I420toRGB555x},
  122. #ifdef _8_BIT_SUPPORT
  123.                 {CID_RGB8,   I420toRGB8x},
  124. #endif
  125. #ifdef _FAT_HXCOLOR                
  126.                 {CID_BGR32,  I420toBGR32x},
  127. #endif
  128.                 {CID_ARGB32, I420toRGB32x},
  129.                 {CID_UNKNOWN,0} /* end of list */
  130.                 };
  131. /* "YUV* to *" converters: */
  132. static CCLINK pcclYV12   [] = { {CID_I420,   YV12toI420},   
  133.                                 {CID_YV12,   YV12toYV12},
  134.                                 {CID_YUY2,   YV12toYUY2},   
  135.                                 {CID_UYVY,   YV12toUYVY},
  136.                                 {CID_RGB32,  YV12toRGB32},
  137.                                 {CID_RGB24,  YV12toRGB24},
  138.                                 {CID_RGB565, YV12toRGB565},
  139.                                 {CID_RGB555, YV12toRGB555},
  140. #ifdef _8_BIT_SUPPORT
  141.                                 {CID_RGB8,   YV12toRGB8},
  142. #endif
  143. #ifdef _FAT_HXCOLOR                
  144.                                 {CID_BGR32,  YV12toBGR32},
  145. #endif
  146.                                 {CID_ARGB32, YV12toRGB32},
  147.                                 {CID_UNKNOWN,0} /* end of list */
  148.                                 };
  149. static CCLINK pcclYVU9   [] = { {CID_I420,   YVU9toI420},
  150.                                 {CID_UNKNOWN, 0}};
  151. static CCLINK pcclYUY2 [] = { {CID_YUY2,    YUY2toYUY2},
  152.                               {CID_I420,    YUY2toI420},
  153.                               {CID_UYVY,    YUY2toUYVY},
  154.                               {CID_YV12,    YUY2toYV12},
  155.                               {CID_UNKNOWN, 0}
  156.                             };
  157. static CCLINK pcclYUVU [] = { {CID_I420,    YUVUtoI420},
  158.                               {CID_UNKNOWN, 0}
  159.                             };
  160. static CCLINK pcclUYVY   [] = { {CID_I420,   UYVYtoI420},
  161.                                 {CID_YV12,   UYVYtoYV12},
  162.                                 {CID_YUY2,   UYVYtoYUY2},
  163.                                 {CID_UYVY,   UYVYtoUYVY},
  164.                                 {CID_UNKNOWN, 0}};
  165. /* "YUV* to *x" converters: */
  166. static CCLINK2 pcclYV12x [] = { {CID_I420,   YV12toI420x},   
  167.                                 {CID_YV12,   YV12toYV12x},
  168.                                 {CID_YUY2,   YV12toYUY2x},   
  169.                                 {CID_UYVY,   YV12toUYVYx},
  170.                                 {CID_RGB32,  YV12toRGB32x},
  171.                                 {CID_RGB24,  YV12toRGB24x},
  172.                                 {CID_RGB565, YV12toRGB565x},
  173.                                 {CID_RGB555, YV12toRGB555x},
  174. #ifdef _8_BIT_SUPPORT
  175.                                 {CID_RGB8,   YV12toRGB8x},
  176. #endif
  177. #ifdef _FAT_HXCOLOR                
  178.                                 {CID_BGR32,  YV12toBGR32x},
  179. #endif
  180.                                 {CID_ARGB32, YV12toRGB32x},
  181.                                 {CID_UNKNOWN,0} /* end of list */
  182.                                 };
  183. static CCLINK2 pcclYUY2x [] = { {CID_I420,   YUY2toI420x},
  184.                                 {CID_YV12,   YUY2toYV12x},
  185.                                 {CID_UNKNOWN, 0}};
  186. static CCLINK2 pcclUYVYx [] = { {CID_I420,   UYVYtoI420x},
  187.                                 {CID_YV12,   UYVYtoYV12x},
  188.                                 {CID_UNKNOWN, 0}};
  189. /* "RGB* to *" converters: */
  190. static CCLINK pcclRGB32  [] = { {CID_I420,    RGB32toI420},
  191.                                 {CID_RGB32,   RGB32toRGB32}, 
  192.                                 {CID_RGB24,   RGB32toRGB24},
  193.                                 {CID_RGB565,  RGB32toRGB565}, 
  194.                                 {CID_RGB555,  RGB32toRGB555},
  195. #ifdef _8_BIT_SUPPORT
  196.                                 {CID_RGB8,    RGB32toRGB8},  
  197. #endif
  198. #ifdef _FAT_HXCOLOR
  199.                                 {CID_BGR32,   RGB32toBGR32},
  200. #endif
  201.                                 {CID_ARGB32,  RGB32toRGB32},
  202.                                 {CID_YUVA,    ARGBtoYUVA},
  203.                                 {CID_UNKNOWN, 0} };
  204. static CCLINK pcclARGB32  [] = { {CID_I420,    RGB32toI420},
  205.                                  {CID_RGB32,   RGB32toRGB32},
  206.                                  {CID_ARGB32,  RGB32toRGB32},
  207.                                  {CID_RGB24,   RGB32toRGB24},
  208.                                  {CID_RGB565,  RGB32toRGB565},
  209.                                  {CID_RGB555,  RGB32toRGB555},
  210. #ifdef _8_BIT_SUPPORT
  211.                                  {CID_RGB8,    RGB32toRGB8},
  212. #endif
  213.                                  {CID_BGR32,   RGB32toBGR32},
  214.                                  {CID_RGB32,   RGB32toRGB32},
  215.                                  {CID_YUVA,    ARGBtoYUVA},
  216.                                  {CID_UNKNOWN, 0} };
  217. static CCLINK pcclYUVA  [] = { {CID_UNKNOWN, 0} };
  218. #ifdef _FAT_HXCOLOR
  219. static CCLINK pcclRGB24  [] = { {CID_I420,   RGB24toI420},
  220.                                 {CID_RGB32,  RGB24toRGB32}, 
  221.                                 {CID_RGB24,  RGB24toRGB24},
  222.                                 {CID_RGB565, RGB24toRGB565},
  223.                                 {CID_RGB555, RGB24toRGB555},
  224. #ifdef _8_BIT_SUPPORT
  225.                                 {CID_RGB8,   RGB24toRGB8},  
  226. #endif
  227.                                 {CID_BGR32,  RGB24toBGR32},
  228.                                 {CID_ARGB32,  RGB24toRGB32}, 
  229.                                 {CID_UNKNOWN,0}};
  230. #else
  231. static CCLINK pcclRGB24  [] = { {CID_UNKNOWN,0} };
  232. #endif
  233. #ifdef _FAT_HXCOLOR
  234. static CCLINK pcclRGB565 [] = { {CID_I420,   RGB565toI420},
  235.                                 {CID_RGB32,  RGB565toRGB32},
  236.                                 {CID_RGB24,  RGB565toRGB24},
  237.                                 {CID_RGB565, RGB565toRGB565},
  238.                                 {CID_RGB555,RGB565toRGB555},
  239. #ifdef _8_BIT_SUPPORT
  240.                                 {CID_RGB8,   RGB565toRGB8}, 
  241. #endif
  242.                                 {CID_BGR32,  RGB565toBGR32},
  243.                                 {CID_ARGB32,  RGB565toRGB32},
  244.                                 {CID_UNKNOWN,0}};
  245. #else
  246. static CCLINK pcclRGB565 [] = { {CID_UNKNOWN,0} };
  247. #endif
  248. #ifdef _FAT_HXCOLOR
  249. static CCLINK pcclRGB555 [] = { {CID_I420,   RGB555toI420},
  250.                                 {CID_RGB32,  RGB555toRGB32},
  251.                                 {CID_RGB24,  RGB555toRGB24},
  252.                                 {CID_RGB565, RGB555toRGB565},
  253.                                 {CID_RGB555,RGB555toRGB555},
  254. #ifdef _8_BIT_SUPPORT
  255.                                 {CID_RGB8,   RGB555toRGB8}, 
  256. #endif
  257.                                 {CID_BGR32,  RGB555toBGR32},
  258.                                 {CID_ARGB32,  RGB555toRGB32},
  259.                                 {CID_UNKNOWN,0}};
  260. #else
  261. static CCLINK pcclRGB555 [] = { {CID_UNKNOWN,0} };
  262. #endif
  263. #ifdef _8_BIT_SUPPORT
  264. static CCLINK pcclRGB8   [] = { {CID_I420,   RGB8toI420},
  265.                                 {CID_RGB32,  RGB8toRGB32},  
  266.                                 {CID_RGB24,  RGB8toRGB24},
  267.                                 {CID_RGB565, RGB8toRGB565}, 
  268.                                 {CID_RGB555, RGB8toRGB555},
  269.                                 {CID_RGB8,   RGB8toRGB8},   
  270.                                 {CID_BGR32,  RGB8toBGR32},
  271.                                 {CID_ARGB32,  RGB8toRGB32},
  272.                                 {CID_UNKNOWN,0}};
  273. #else
  274. static CCLINK pcclRGB8   [] = { {CID_UNKNOWN, 0} };
  275. #endif
  276. /* "XING to *" converters: */
  277. static CCLINK pcclXing   [] = { {CID_YV12,   XINGtoYV12}, 
  278.                                 {CID_YUY2,   XINGtoYUY2},
  279.                                 {CID_UYVY,   XINGtoUYVY},
  280.                                 {CID_RGB32, XINGtoRGB32}, 
  281.                                 {CID_RGB24, XINGtoRGB24},
  282.                                 {CID_RGB565, XINGtoRGB565}, 
  283. #ifdef _8_BIT_SUPPORT
  284.                                 {CID_RGB8, XINGtoRGB8},
  285. #endif
  286.                                 {CID_ARGB32, XINGtoRGB32}, 
  287.                                 {CID_UNKNOWN,0} 
  288. };
  289. /* "BGR* to *" converters: */
  290. static CCLINK pcclBGR32  [] = { {CID_I420,    BGR_32toI420},
  291.                                 {CID_UNKNOWN,0} 
  292. };
  293. static CCLINK pcclBGR24  [] = { {CID_I420,    BGR24toI420},
  294.                                 {CID_UNKNOWN,0} 
  295. };
  296. /* unsupported input formats: */
  297. static CCLINK pcclUNKNOWN [] = {{CID_UNKNOWN, 0}};
  298. /*
  299.  * Color formats/Converters map:
  300.  */
  301. static PCCLINK ppcclColorMap[] =
  302. {
  303.     pcclI420, 
  304.     pcclYV12, 
  305.     pcclYVU9, 
  306.     pcclYUY2, 
  307.     pcclUYVY,
  308.     pcclRGB32, 
  309.     pcclRGB24, 
  310.     pcclRGB565, 
  311.     pcclRGB555, 
  312.     pcclRGB8, 
  313.     pcclXing,
  314.     pcclARGB32, 
  315.     pcclYUVA,
  316. pcclYUVU,
  317.     pcclUNKNOWN,
  318.     pcclBGR32,
  319.     pcclBGR24
  320. };
  321. /*
  322.  * Retrieve the list of color formats that can be converted to, given an input
  323.  * format
  324.  * Use:
  325.  *  HX_RESULT GetCompatibleColorFormats (INT32 cidIn, INT32* pcidOut, UINT32* pnSize);
  326.  * Input:
  327.  *  cidIn - input color format ID (!CID_UNKNOWN)
  328.  *  pcidOut - in - empty array, out - filled array of supported output formats
  329.  *  pnSize - in - size of array, out - number of elements in array
  330.  * Returns:
  331.  *  result
  332.  */HX_RESULT HXEXPORT ENTRYPOINT(GetCompatibleColorFormats)(
  333.     INT32 cidIn /* in */, 
  334.     INT32* pcidOut /* in/out */, 
  335.     UINT32* pnSize /* in/out */)
  336. {
  337.     HX_RESULT res = HXR_FAIL;
  338.         /* check parameters: */
  339.     int nConversions = sizeof(ppcclColorMap)/sizeof(PCCLINK);
  340.     if(cidIn >= 0 && cidIn < nConversions && pcidOut && pnSize) 
  341.     {
  342. UINT32 nFormats = 0;
  343.         /* scan color map: */
  344.         PCCLINK pccl = ppcclColorMap [cidIn];
  345.         while(pccl && pccl->cidOut != CID_UNKNOWN && nFormats < *pnSize) 
  346. {
  347.     pcidOut[nFormats] = pccl->cidOut;
  348.             /* try next element in the list: */
  349.             pccl++;
  350.     nFormats++;
  351.         }
  352. res = HXR_OK;
  353. *pnSize = nFormats;
  354.     }
  355.     return res;
  356. }
  357. /*
  358.  * Find Converter to trasform data in format X to format Y.
  359.  * Use:
  360.  *  LPHXCOLORCONVERTER GetColorConverter (INT32 cidIn, INT32 cidOut);
  361.  * Input:
  362.  *  cidIn - input color format ID (!CID_UNKNOWN)
  363.  *  cidOut - desirable output color format ID (!CID_UNKNOWN)
  364.  * Returns:
  365.  *  pointer to an appropriate color conversion routine, if success;
  366.  *  NULL - conversion is not supported.
  367.  */
  368. LPHXCOLORCONVERTER HXEXPORT ENTRYPOINT(GetColorConverter) (INT32 cidIn, INT32 cidOut)
  369. {
  370.     /* check parameters: */
  371.     int nConversions = sizeof(ppcclColorMap)/sizeof(PCCLINK);
  372.     if (cidIn >= 0 && cidIn < nConversions &&
  373.         cidOut >= 0 && cidOut <= NFORMATS) {
  374.         /* scan color map: */
  375.         PCCLINK pccl = ppcclColorMap [cidIn];
  376.         while (pccl &&
  377.                pccl->cidOut != CID_UNKNOWN) {
  378.             /* check output format:  */
  379.             if (pccl->cidOut == cidOut)
  380.                 return pccl->pfnCC;
  381.             /* try next element in the list: */
  382.             pccl ++;
  383.         }
  384.     }
  385.     return NULL;
  386. }
  387. LPHXCOLORCONVERTER2 HXEXPORT ENTRYPOINT(GetColorConverter2) (INT32 cidIn, INT32 cidOut)
  388. {
  389.     CCLINK2 *pTemp = NULL;
  390.     /* check parameters: */
  391.     if (cidIn == CID_I420)
  392.     {
  393.         pTemp = pcclI420x;
  394.     }
  395.     else if (cidIn == CID_YV12)
  396.     {
  397.         pTemp = pcclYV12x;
  398.     }
  399.     else if (cidIn == CID_YUY2)
  400.     {
  401.         pTemp = pcclYUY2x;
  402.     }
  403.     else if (cidIn == CID_UYVY)
  404.     {
  405.         pTemp = pcclUYVYx;
  406.     }
  407.     if (pTemp)
  408.     {
  409.         /* scan color map: */
  410.         for (int i=0; pTemp[i].cidOut != CID_UNKNOWN; i++)
  411.         {
  412.             /* check output format:  */
  413.             if (pTemp[i].cidOut == cidOut)
  414.                 return pTemp[i].pfnCC;
  415.         }
  416.     }
  417.     return NULL;
  418. }
  419. /*
  420.  * Try selected compatible color formats.
  421.  * Use:
  422.  *  BOOL ScanCompatibleColorFormats (INT32 cidIn, INT32 cidOutMask, void *pParam,
  423.  *      BOOL (*pfnTryIt) (void *pParam, INT32 cidOut, LPHXCOLORCONVERTER pfnCC));
  424.  * Input:
  425.  *  cidIn - input color format ID (!CID_UNKNOWN)
  426.  *  cidOutMask - masks output formats to try (use ~0 to scan all formats)
  427.  *  pParam - pointer to a parameter block to pass to fpTryIt ()
  428.  *  pfnTryIt - pointer to a function, which will be called for each
  429.  *          compatible output format;
  430.  * Returns:
  431.  *  TRUE, if fpTryIt() has exited with TRUE status;
  432.  *  FALSE, if non of the compatible formats has been accepted by fpTryIt().
  433.  */
  434. BOOL HXEXPORT ENTRYPOINT(ScanCompatibleColorFormats) (INT32 cidIn, INT32 cidOutMask, void *pParam,
  435.     BOOL (*pfnTryIt) (void *pParam, INT32 cidOut, LPHXCOLORCONVERTER pfnCC), INT32)
  436. {
  437.     /* check parameters: */
  438.     int nConversions = sizeof(ppcclColorMap)/sizeof(PCCLINK);
  439.     if (cidIn >= 0 && cidIn < nConversions && pfnTryIt != NULL) {
  440.         /* scan color map: */
  441.         PCCLINK pccl = ppcclColorMap [cidIn];
  442.         while (pccl->cidOut != CID_UNKNOWN) {
  443.             /* try this format: */
  444.             if ((cidOutMask & (1U << pccl->cidOut)) &&
  445.                 (* pfnTryIt) (pParam, pccl->cidOut, pccl->pfnCC))
  446.                 return TRUE;
  447.             /* try next element in the list: */
  448.             pccl ++;
  449.         }
  450.     }
  451.     return FALSE;
  452. }
  453. /*
  454.  * Try all compatible color formats.
  455.  */
  456. BOOL HXEXPORT ENTRYPOINT(ScanAllCompatibleColorFormats) (INT32 cidIn,void *pParam,
  457.     BOOL (*pfnTryIt) (void *pParam, INT32 cidOut, LPHXCOLORCONVERTER pfnCC), INT32)
  458. {
  459.     return ENTRYPOINT(ScanCompatibleColorFormats) (cidIn, (INT32)~0, pParam, pfnTryIt);
  460. }
  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
  523. #ifdef __cplusplus
  524. }
  525. #endif