hxcolor.cpp
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:22k
源码类别:

Symbian

开发平台:

Visual C++

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