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

Symbian

开发平台:

Visual C++

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