Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1116 lines
36 KiB

  1. /* *************************************************************************
  2. ** INTEL Corporation Proprietary Information
  3. **
  4. ** This listing is supplied under the terms of a license
  5. ** agreement with INTEL Corporation and may not be copied
  6. ** nor disclosed except in accordance with the terms of
  7. ** that agreement.
  8. **
  9. ** Copyright (c) 1996 Intel Corporation.
  10. ** All Rights Reserved.
  11. **
  12. ** *************************************************************************
  13. */
  14. //
  15. ////////////////////////////////////////////////////////////////////////////
  16. //
  17. // $Author: mbodart $
  18. // $Date: 17 Mar 1997 08:22:08 $
  19. // $Archive: S:\h26x\src\enc\exbase.cpv $
  20. // $Header: S:\h26x\src\enc\exbase.cpv 1.73 17 Mar 1997 08:22:08 mbodart $
  21. // $Log: S:\h26x\src\enc\exbase.cpv $
  22. //
  23. // Rev 1.73 17 Mar 1997 08:22:08 mbodart
  24. // Minor fixes.
  25. //
  26. // Rev 1.72 11 Mar 1997 13:46:46 JMCVEIGH
  27. // Allow input = 320x240 and output = 320x240 for YUV12. This is
  28. // for snapshot mode.
  29. //
  30. // Rev 1.71 10 Mar 1997 17:34:34 MDUDA
  31. // Put in a check for 9-bit YUV12 and adjusted the internal compress
  32. // structure instead of the input bitmap header info.
  33. //
  34. // Rev 1.70 10 Mar 1997 10:41:20 MDUDA
  35. // Treating inconsistent format/bitwidth as a debug warning. Changing
  36. // bit count to match format.
  37. //
  38. // Rev 1.69 07 Mar 1997 16:00:32 JMCVEIGH
  39. // Added checks for non-NULL lpInst before getting H263PlusState.
  40. // Two separate "suggestions" for image sizes if input size is not
  41. // supported in GetFormat.
  42. //
  43. // Rev 1.68 07 Mar 1997 11:55:44 JMCVEIGH
  44. // Moved query in GetFormat to after we have filled out the output
  45. // format. This is because some apps. will ask for the format and
  46. // then use the returned data, regardless if there was an error.
  47. // Silly apps!
  48. //
  49. // Rev 1.67 07 Mar 1997 09:53:08 mbodart
  50. // Added a call to _clearfp() in the Compress exception handler, so that
  51. // the exception will not reoccur in the caller's code.
  52. //
  53. // Rev 1.66 06 Mar 1997 15:39:26 KLILLEVO
  54. //
  55. // CompressQuery now checks for input/output formats regardless
  56. // of configuration status. Also put in trace support for lparam1 and lparam2.
  57. //
  58. // Rev 1.65 22 Jan 1997 12:17:14 MDUDA
  59. //
  60. // Put in more checking for H263+ option in CompressQuery
  61. // and CompressBegin.
  62. //
  63. // Rev 1.64 22 Jan 1997 08:11:22 JMCVEIGH
  64. // Backward compatibility with crop/stretch for 160x120 and 240x180
  65. // in CompressGetFormat(). Do old way unless we have received the
  66. // H263Plus custom message.
  67. //
  68. // Rev 1.63 13 Jan 1997 10:52:14 JMCVEIGH
  69. //
  70. // Added NULL pointer checks in all functions that interface with
  71. // application.
  72. //
  73. // Rev 1.62 09 Jan 1997 13:50:50 MDUDA
  74. // Removed some _CODEC_STATS stuff.
  75. //
  76. // Rev 1.61 06 Jan 1997 17:42:30 JMCVEIGH
  77. // If H263Plus message is not sent, encoder only supports standard
  78. // frame sizes (sub-QCIF, QCIF, or CIF along with special cases),
  79. // as before.
  80. //
  81. // Rev 1.60 30 Dec 1996 19:57:04 MDUDA
  82. // Making sure that input formats agree with the bit count field.
  83. //
  84. // Rev 1.59 20 Dec 1996 15:25:28 MDUDA
  85. // Fixed problem where YUV12 was enabled for crop and stretch.
  86. // This feature is only allowed for RGB, YVU9 and YUY2.
  87. //
  88. // Rev 1.58 16 Dec 1996 13:36:08 MDUDA
  89. //
  90. // Modified Compress Instance info for input color convertors.
  91. //
  92. // Rev 1.57 11 Dec 1996 16:01:20 MBODART
  93. // In Compress, catch any exceptions and return an error code. This gives
  94. // upstream active movie filters a chance to recover gracefully.
  95. //
  96. // Rev 1.56 09 Dec 1996 17:59:36 JMCVEIGH
  97. // Added support for arbitrary frame size support.
  98. // 4 <= width <= 352, 4 <= height <= 288, both multiples of 4.
  99. // Normally, application will pass identical (arbitrary) frame
  100. // sizes in lParam1 and lParam2 of CompressBegin(). If
  101. // cropping/stretching desired to convert to standard frame sizes,
  102. // application should pass the desired output size in lParam2 and
  103. // the input size in lParam1.
  104. //
  105. // Rev 1.55 09 Dec 1996 09:50:12 MDUDA
  106. //
  107. // Allowing 240x180 and 160x120 (crop and stretch) for YUY2.
  108. // Modified _CODEC_STATS stuff.
  109. //
  110. // Rev 1.54 07 Nov 1996 14:45:16 RHAZRA
  111. // Added buffer size adjustment to H.261 CompressGetSize() function
  112. //
  113. // Rev 1.53 31 Oct 1996 22:33:32 BECHOLS
  114. // Decided buffer arbitration must be done in cxq_main.cpp for RTP.
  115. //
  116. // Rev 1.52 31 Oct 1996 21:55:50 BECHOLS
  117. // Added fudge factor for RTP waiting for Raj to decide what he wants to do.
  118. //
  119. // Rev 1.51 31 Oct 1996 10:05:46 KLILLEVO
  120. // changed from DBOUT to DbgLog
  121. //
  122. // Rev 1.50 18 Oct 1996 14:35:46 MDUDA
  123. //
  124. // Separated CompressGetSize and CompressQuery for H261 and H263 cases.
  125. //
  126. // Rev 1.49 11 Oct 1996 16:05:16 MDUDA
  127. //
  128. // Added initial _CODEC_STATS stuff.
  129. //
  130. // Rev 1.48 16 Sep 1996 16:50:52 CZHU
  131. // Return larger size for GetCompressedSize when RTP is enabled.
  132. //
  133. // Rev 1.47 13 Aug 1996 10:36:46 MDUDA
  134. //
  135. // Now allowing RGB4 input format.
  136. //
  137. // Rev 1.46 09 Aug 1996 09:43:30 MDUDA
  138. // Now allowing RGB16 format on input. This is generated by the color Quick Ca
  139. //
  140. // Rev 1.45 02 Aug 1996 13:45:58 MDUDA
  141. //
  142. // Went back to previous version that allows RGB8 and RGB24 in
  143. // 240x180 and 160x120 frames.
  144. //
  145. // Rev 1.44 01 Aug 1996 11:54:58 BECHOLS
  146. // Cut & Paste Error.
  147. //
  148. // Rev 1.43 01 Aug 1996 11:20:28 BECHOLS
  149. // Fixed handling of RGB 24 bit stuff so that it doesn't allow sizes other
  150. // than QCIF, SQCIF, or CIF. I broke this earlier when I added the RGB 8
  151. // bit support. ...
  152. //
  153. // Rev 1.42 22 Jul 1996 13:31:16 BECHOLS
  154. //
  155. // Added code to allow a CLUT8 input providing that the input resolutions
  156. // are either 240x180 or 160x120.
  157. //
  158. // Rev 1.41 11 Jul 1996 15:43:58 MDUDA
  159. // Added support for YVU9 240 x 180 and 160 x 120 for H263 only.
  160. // We now produce subQCIF for 160x120 and QCIF for 240x180.
  161. //
  162. // Rev 1.40 05 Jun 1996 10:57:54 AKASAI
  163. // Added #ifndef H261 in CompressQuery to make sure that H.261 will
  164. // only support FCIF and QCIF input image sizes. All other input sizes
  165. // should return ICERR_BADFORMAT.
  166. //
  167. // Rev 1.39 30 May 1996 17:02:34 RHAZRA
  168. // Added SQCIF support for H.263 in CompressGetSize()
  169. //
  170. // Rev 1.38 06 May 1996 12:47:40 BECHOLS
  171. // Changed the structure element to unBytesPerSecond.
  172. //
  173. // Rev 1.37 06 May 1996 00:09:44 BECHOLS
  174. // Changed the handling of the CompressFramesInfo message to get DataRate
  175. // from the configuration data if the configuration has the data, and
  176. // we haven't received a CompressBegin message yet.
  177. //
  178. // Rev 1.36 23 Apr 1996 16:51:20 KLILLEVO
  179. // moved paranthesis to fix format check in CompressQuery()
  180. //
  181. // Rev 1.35 18 Apr 1996 16:07:10 RHAZRA
  182. // Fixed CompressQuery to keep compiler happy for the non-MICROSOFT version
  183. //
  184. // Rev 1.34 18 Apr 1996 15:57:46 BECHOLS
  185. // RAJ- Changed the query logic to correctly filter the allowable resolutions
  186. // for compression.
  187. //
  188. // Rev 1.33 12 Apr 1996 14:15:40 RHAZRA
  189. // Added paranthesis in CompressGetSize() to make the ifdef case work
  190. //
  191. // Rev 1.32 12 Apr 1996 13:31:02 RHAZRA
  192. // Added SQCIF support in CompressGetSize() with #ifdef SUPPORT_SQCIF;
  193. // changed CompressGetSize() to return 0 if the input format is not
  194. // supported.
  195. //
  196. // Rev 1.31 10 Apr 1996 16:53:08 RHAZRA
  197. // Added a error return in CompressGetSize() to keep complier smiling...
  198. //
  199. // Rev 1.30 10 Apr 1996 16:39:56 RHAZRA
  200. // Added a check for the 320x240 size in CompressGetSize() function;
  201. // added a ifndef to disable certain sizes and compression formats.
  202. //
  203. // Rev 1.29 04 Apr 1996 13:35:00 RHAZRA
  204. // Changed CompressGetSize() to return spec-compliant buffer sizes.
  205. //
  206. // Rev 1.28 03 Apr 1996 08:39:52 SCDAY
  207. // Added H261 specific code to CompressGetSize to limit buffer size
  208. // as defined in H261 spec
  209. //
  210. // Rev 1.27 21 Feb 1996 11:43:12 SCDAY
  211. // cleaned up compiler build warning by changing conversion frlDataRate to (U3
  212. //
  213. // Rev 1.26 15 Feb 1996 16:03:36 RHAZRA
  214. //
  215. // Added a check for NULL lpInst pointer in CompressGetFormat()
  216. //
  217. // Rev 1.25 02 Feb 1996 18:53:46 TRGARDOS
  218. // Changed code to read frame rate from Compressor Instance
  219. // instead of the hack from Quality field.
  220. //
  221. // Rev 1.24 26 Jan 1996 09:35:32 TRGARDOS
  222. // Added #ifndef H261 for 160x120,320x240 support.
  223. //
  224. // Rev 1.23 04 Jan 1996 18:36:54 TRGARDOS
  225. // Added code to permit 320x240 input and then set a boolean
  226. // bIs320x240.
  227. //
  228. // Rev 1.22 27 Dec 1995 15:32:50 RMCKENZX
  229. // Added copyright notice
  230. //
  231. ///////////////////////////////////////////////////////////////////////////
  232. #include "precomp.h"
  233. #ifdef YUV9FROMFILE
  234. PAVIFILE paviFile;
  235. PAVISTREAM paviStream;
  236. U8 huge * glpTmp;
  237. HGLOBAL hgMem;
  238. #endif
  239. ;////////////////////////////////////////////////////////////////////////////
  240. ;// Function: DWORD PASCAL CompressGetFormat(LPCODINST, LPBITMAPINFOHEADER, LPBITMAPINFOHEADER);
  241. ;//
  242. ;// Description: Added header. This function returns a format that
  243. ;// we can deliver back to the caller.
  244. ;//
  245. ;// History: 05/11/94 -BEN-
  246. ;////////////////////////////////////////////////////////////////////////////
  247. #ifdef USE_BILINEAR_MSH26X
  248. DWORD PASCAL CompressGetFormat(LPINST pi, LPBITMAPINFOHEADER lParam1, LPBITMAPINFOHEADER lParam2)
  249. #else
  250. DWORD PASCAL CompressGetFormat(LPCODINST lpInst, LPBITMAPINFOHEADER lParam1, LPBITMAPINFOHEADER lParam2)
  251. #endif
  252. {
  253. DWORD dwQuery;
  254. #ifdef USE_BILINEAR_MSH26X
  255. LPCODINST lpInst = (LPCODINST)pi->CompPtr;
  256. #endif
  257. FX_ENTRY("CompressGetFormat")
  258. // lpInst == NULL is OK
  259. // this is what you get on ICOpen(...,ICMODE_QUERY)
  260. #if 0
  261. if (lpInst == NULL) {
  262. ERRORMESSAGE(("%s: got a NULL lpInst pointer\r\n", _fx_));
  263. return ((DWORD) ICERR_ERROR);
  264. }
  265. #endif
  266. #ifdef USE_BILINEAR_MSH26X
  267. if(dwQuery = CompressQuery(pi, lParam1, NULL)) {
  268. #else
  269. if(dwQuery = CompressQuery(lpInst, lParam1, NULL)) {
  270. #endif
  271. ERRORMESSAGE(("%s: ICERR_BADFORMAT\r\n", _fx_));
  272. return(dwQuery);
  273. }
  274. if(lParam2 == NULL) {
  275. // he just want me to return the output buffer size.
  276. return ((DWORD)sizeof(BITMAPINFOHEADER));
  277. }
  278. // Check pointer
  279. if (!lParam1)
  280. return ICERR_ERROR;
  281. // give him back what he passed with our stuff in it
  282. #ifndef WIN32
  283. (void)_fmemcpy(lParam2, lParam1,sizeof(BITMAPINFOHEADER));
  284. #else
  285. (void)memcpy(lParam2, lParam1,sizeof(BITMAPINFOHEADER));
  286. #endif
  287. lParam2->biBitCount = 24;
  288. #ifdef USE_BILINEAR_MSH26X
  289. lParam2->biCompression = pi->fccHandler;
  290. #else
  291. lParam2->biCompression = FOURCC_H263;
  292. #endif
  293. #if defined(H263P)
  294. BOOL bH263PlusState = FALSE;
  295. if (lpInst)
  296. CustomGetH263PlusState(lpInst, (DWORD FAR *)&bH263PlusState);
  297. if (!bH263PlusState) {
  298. // For backward compatibility, make sure the crop and stretch cases are covered.
  299. if ( (lParam1->biCompression == FOURCC_YVU9) ||
  300. (lParam1->biCompression == FOURCC_YUY2) ||
  301. (lParam1->biCompression == FOURCC_UYVY) ||
  302. (lParam1->biCompression == FOURCC_YUV12) ||
  303. (lParam1->biCompression == FOURCC_IYUV) ||
  304. (lParam1->biCompression == BI_RGB) )
  305. {
  306. if ( (lParam1->biWidth == 240) && (lParam1->biHeight == 180) )
  307. {
  308. lParam2->biWidth = 176;
  309. lParam2->biHeight = 144;
  310. }
  311. if ( (lParam1->biWidth == 160) && (lParam1->biHeight == 120) )
  312. {
  313. lParam2->biWidth = 128;
  314. lParam2->biHeight = 96;
  315. }
  316. }
  317. }
  318. #else
  319. if ( (lParam1->biCompression == FOURCC_YVU9) ||
  320. (lParam1->biCompression == FOURCC_YUY2) ||
  321. (lParam1->biCompression == FOURCC_UYVY) ||
  322. (lParam1->biCompression == FOURCC_YUV12) ||
  323. (lParam1->biCompression == FOURCC_IYUV) ||
  324. (lParam1->biCompression == BI_RGB) )
  325. {
  326. if ( (lParam1->biWidth == 240) && (lParam1->biHeight == 180) )
  327. {
  328. lParam2->biWidth = 176;
  329. lParam2->biHeight = 144;
  330. }
  331. if ( (lParam1->biWidth == 160) && (lParam1->biHeight == 120) )
  332. {
  333. lParam2->biWidth = 128;
  334. lParam2->biHeight = 96;
  335. }
  336. }
  337. else
  338. {
  339. lParam2->biWidth = MOD4(lParam1->biWidth);
  340. lParam2->biHeight = MOD4(lParam1->biHeight);
  341. }
  342. #endif
  343. lParam2->biClrUsed = 0;
  344. lParam2->biClrImportant = 0;
  345. lParam2->biPlanes = 1;
  346. #ifdef USE_BILINEAR_MSH26X
  347. lParam2->biSizeImage = CompressGetSize(pi, lParam1, lParam2);
  348. #else
  349. lParam2->biSizeImage = CompressGetSize(lpInst, lParam1, lParam2);
  350. #endif
  351. return(ICERR_OK);
  352. }
  353. ;////////////////////////////////////////////////////////////////////////////
  354. ;// Function: DWORD PASCAL CompressGetSize(LPCODINST, LPBITMAPINFOHEADER, LPBITMAPINFOHEADER);
  355. ;//
  356. ;// Description: Added header. This function returns the maximum
  357. ;// size that a compressed buffer can be. This size is
  358. ;// guaranteed in encoder design.
  359. ;//
  360. ;// History: 05/11/94 -BEN-
  361. ;////////////////////////////////////////////////////////////////////////////
  362. #if defined(H261)
  363. DWORD PASCAL CompressGetSize(LPCODINST lpInst, LPBITMAPINFOHEADER lParam1, LPBITMAPINFOHEADER lParam2)
  364. {
  365. // RH: For QCIF and CIF, the maximum buffer sizes for 261 & 263 are identical.
  366. DWORD dwRet = 0;
  367. DWORD dwExtSize=0;
  368. FX_ENTRY("CompressGetSize")
  369. if ((lParam1->biWidth == 176) && (lParam1->biHeight == 144)) {
  370. dwRet = 8192L;
  371. } else {
  372. if ((lParam1->biWidth == 352) && (lParam1->biHeight == 288)) {
  373. dwRet = 32768L;
  374. }
  375. else // unsupported frame size; should not happen
  376. {
  377. ERRORMESSAGE(("%s: ICERR_BADIMAGESIZE\r\n", _fx_));
  378. dwRet = 0;
  379. }
  380. }
  381. #if 0
  382. // Adjust the buffer size for RTP. Note that this adjustment will be performed
  383. // only if the codec has been told previously to use RTP and the RTP-related
  384. // information has been initialized. Therefore, the current (11/7) AM interface
  385. // will not take advantage of this routine.
  386. if (dwRet && lpInst && lpInst->Configuration.bRTPHeader && lpInst->Configuration.bInitialized)
  387. {
  388. dwRet += H261EstimateRTPOverhead(lpInst, lParam1);
  389. }
  390. #endif
  391. return dwRet;
  392. }
  393. #else
  394. /* H.263 case */
  395. #ifdef USE_BILINEAR_MSH26X
  396. DWORD PASCAL CompressGetSize(LPINST pi, LPBITMAPINFOHEADER lParam1, LPBITMAPINFOHEADER lParam2)
  397. #else
  398. DWORD PASCAL CompressGetSize(LPCODINST lpInst, LPBITMAPINFOHEADER lParam1, LPBITMAPINFOHEADER lParam2)
  399. #endif
  400. {
  401. // RH: For QCIF and CIF, the maximum buffer sizes for 261 & 263 are identical.
  402. #ifdef USE_BILINEAR_MSH26X
  403. LPCODINST lpInst = (LPCODINST)pi->CompPtr;
  404. #endif
  405. DWORD dwRet = 0;
  406. DWORD dwExtSize=0;
  407. FX_ENTRY("CompressGetSize")
  408. if (lParam1 == NULL) {
  409. // We will use a size of zero to indicate an error for CompressGetSize
  410. ERRORMESSAGE(("%s: got a NULL lParam1 pointer\r\n", _fx_));
  411. dwRet = 0;
  412. return dwRet;
  413. }
  414. #ifndef H263P
  415. #ifdef USE_BILINEAR_MSH26X
  416. if (pi->fccHandler == FOURCC_H26X)
  417. {
  418. // H.263+
  419. U32 unPaddedWidth;
  420. U32 unPaddedHeight;
  421. U32 unSourceFormatSize;
  422. // Base buffer size on frame dimensions padded to multiples of 16
  423. if (lParam2 == NULL)
  424. {
  425. // In case an old application passed in a NULL pointer in lParam2,
  426. // we use the input frame dimensions to calculate the format size
  427. unPaddedWidth = (lParam1->biWidth + 0xf) & ~0xf;
  428. unPaddedHeight = (lParam1->biHeight + 0xf) & ~0xf;
  429. }
  430. else
  431. {
  432. unPaddedWidth = (lParam2->biWidth + 0xf) & ~0xf;
  433. unPaddedHeight = (lParam2->biHeight + 0xf) & ~0xf;
  434. }
  435. unSourceFormatSize = unPaddedWidth * unPaddedHeight;
  436. // See Table 1/H.263, document LBC-96-358
  437. if (unSourceFormatSize < 25348)
  438. dwRet = 8192L;
  439. else if (unSourceFormatSize < 101380)
  440. dwRet = 32768L;
  441. else if (unSourceFormatSize < 405508)
  442. dwRet = 65536L;
  443. else
  444. dwRet = 131072L;
  445. }
  446. else
  447. {
  448. #endif
  449. if (((lParam1->biWidth == 128) && (lParam1->biHeight == 96)) ||
  450. #ifdef USE_BILINEAR_MSH26X
  451. ((lParam1->biWidth == 80) && (lParam1->biHeight == 64)) ||
  452. #endif
  453. ((lParam1->biWidth == 176) && (lParam1->biHeight == 144)) ||
  454. ((lParam1->biWidth == 240) && (lParam1->biHeight == 180)) ||
  455. ((lParam1->biWidth == 160) && (lParam1->biHeight == 120)))
  456. {
  457. dwRet = 8192L;
  458. }
  459. else if (((lParam1->biWidth == 352) && (lParam1->biHeight == 288)) ||
  460. ((lParam1->biWidth == 320) && (lParam1->biHeight == 240)))
  461. {
  462. dwRet = 32768L;
  463. }
  464. else // unsupported frame size; should not happen
  465. {
  466. ERRORMESSAGE(("%s: ICERR_BADIMAGESIZE\r\n", _fx_));
  467. dwRet = 0;
  468. }
  469. #ifdef USE_BILINEAR_MSH26X
  470. }
  471. #endif
  472. #else
  473. // H.263+
  474. U32 unPaddedWidth;
  475. U32 unPaddedHeight;
  476. U32 unSourceFormatSize;
  477. // Base buffer size on frame dimensions padded to multiples of 16
  478. if (lParam2 == NULL)
  479. {
  480. // In case an old application passed in a NULL pointer in lParam2,
  481. // we use the input frame dimensions to calculate the format size
  482. unPaddedWidth = (lParam1->biWidth + 0xf) & ~0xf;
  483. unPaddedHeight = (lParam1->biHeight + 0xf) & ~0xf;
  484. }
  485. else
  486. {
  487. unPaddedWidth = (lParam2->biWidth + 0xf) & ~0xf;
  488. unPaddedHeight = (lParam2->biHeight + 0xf) & ~0xf;
  489. }
  490. unSourceFormatSize = unPaddedWidth * unPaddedHeight;
  491. // See Table 1/H.263, document LBC-96-358
  492. if (unSourceFormatSize < 25348)
  493. dwRet = 8192L;
  494. else if (unSourceFormatSize < 101380)
  495. dwRet = 32768L;
  496. else if (unSourceFormatSize < 405508)
  497. dwRet = 65536L;
  498. else
  499. dwRet = 131072L;
  500. #endif
  501. #if 0
  502. //adjust if RTP is enabled, based on information in Configuration
  503. //Size calculated using DataRate, FrameRate in lpInst,
  504. //and lpInst->Configuration.unPacketSize;
  505. //Chad, 9/12/96
  506. if (dwRet && lpInst &&
  507. lpInst->Configuration.bRTPHeader && lpInst->Configuration.bInitialized)
  508. {
  509. dwRet += getRTPBsInfoSize(lpInst);
  510. }
  511. #endif
  512. return dwRet;
  513. }
  514. #endif
  515. ;////////////////////////////////////////////////////////////////////////////
  516. ;// Function: DWORD PASCAL CompressQuery(LPCODINST, LPBITMAPINFOHEADER, LPBITMAPINFOHEADER);
  517. ;//
  518. ;// Description:
  519. ;//
  520. ;// History: 05/11/94 -BEN-
  521. ;////////////////////////////////////////////////////////////////////////////
  522. #if defined(H261)
  523. DWORD PASCAL CompressQuery(LPCODINST lpInst, LPBITMAPINFOHEADER lParam1, LPBITMAPINFOHEADER lParam2)
  524. {
  525. // Check for good input format
  526. FX_ENTRY("CompressQuery")
  527. if(NULL == lParam1)
  528. {
  529. ERRORMESSAGE(("%s: ICERR_BADFORMAT\r\n", _fx_));
  530. return((DWORD)ICERR_BADFORMAT);
  531. }
  532. if( (lParam1->biCompression != BI_RGB) &&
  533. (lParam1->biCompression != FOURCC_YUV12) &&
  534. (lParam1->biCompression != FOURCC_IYUV) )
  535. {
  536. ERRORMESSAGE(("%s: ICERR_BADFORMAT\r\n", _fx_));
  537. return((DWORD)ICERR_BADFORMAT);
  538. }
  539. if( (lParam1->biCompression == BI_RGB) && (lParam1->biBitCount != 24))
  540. {
  541. ERRORMESSAGE(("%s: ICERR_BADFORMAT\r\n", _fx_));
  542. return((DWORD)ICERR_BADFORMAT);
  543. }
  544. if(! ( ((lParam1->biWidth == 176) && (lParam1->biHeight == 144)) ||
  545. ((lParam1->biWidth == 352) && (lParam1->biHeight == 288)) ))
  546. {
  547. ERRORMESSAGE(("%s: ICERR_BADFORMAT\r\n", _fx_));
  548. return((DWORD)ICERR_BADFORMAT);
  549. }
  550. if( lParam1->biPlanes != 1 )
  551. {
  552. ERRORMESSAGE(("%s: ICERR_BADFORMAT\r\n", _fx_));
  553. return((DWORD)ICERR_BADFORMAT);
  554. }
  555. if(0 == lParam2) // Checking input only
  556. return(ICERR_OK);
  557. // TODO: Do we want to check frame dimensions of output?
  558. if( lParam2->biCompression != FOURCC_H263 )
  559. {
  560. ERRORMESSAGE(("%s: ICERR_BADFORMAT\r\n", _fx_));
  561. return ((DWORD)ICERR_BADFORMAT);
  562. }
  563. return(ICERR_OK);
  564. }
  565. #else
  566. /* H.263 case */
  567. #ifdef USE_BILINEAR_MSH26X
  568. DWORD PASCAL CompressQuery(LPINST pi, LPBITMAPINFOHEADER lParam1, LPBITMAPINFOHEADER lParam2)
  569. #else
  570. DWORD PASCAL CompressQuery(LPCODINST lpInst, LPBITMAPINFOHEADER lParam1, LPBITMAPINFOHEADER lParam2)
  571. #endif
  572. {
  573. #ifdef USE_BILINEAR_MSH26X
  574. LPCODINST lpInst = (LPCODINST)pi->CompPtr;
  575. #endif
  576. FX_ENTRY("CompressQuery")
  577. #if defined(H263P)
  578. BOOL bH263PlusState = FALSE;
  579. if (lpInst)
  580. CustomGetH263PlusState(lpInst, (DWORD FAR *)&bH263PlusState);
  581. #endif
  582. // Check for good input format
  583. if(lParam1 == NULL)
  584. {
  585. ERRORMESSAGE(("%s: ICERR_BADFORMAT\r\n", _fx_));
  586. return((DWORD)ICERR_BADFORMAT);
  587. }
  588. if( (lParam1->biCompression != BI_RGB) &&
  589. (lParam1->biCompression != FOURCC_YVU9) &&
  590. (lParam1->biCompression != FOURCC_YUV12) &&
  591. (lParam1->biCompression != FOURCC_IYUV) &&
  592. (lParam1->biCompression != FOURCC_UYVY) &&
  593. (lParam1->biCompression != FOURCC_YUY2) )
  594. {
  595. ERRORMESSAGE(("%s: ICERR_BADFORMAT\r\n", _fx_));
  596. return((DWORD)ICERR_BADFORMAT);
  597. }
  598. if( (lParam1->biCompression == BI_RGB) &&
  599. ( (lParam1->biBitCount != 24) &&
  600. #ifdef H263P
  601. (lParam1->biBitCount != 32) &&
  602. #endif
  603. (lParam1->biBitCount != 16) &&
  604. (lParam1->biBitCount != 8) &&
  605. (lParam1->biBitCount != 4) ) )
  606. {
  607. ERRORMESSAGE(("%s: ICERR_BADFORMAT\r\n", _fx_));
  608. return((DWORD)ICERR_BADFORMAT);
  609. }
  610. #ifndef H263P
  611. #ifdef USE_BILINEAR_MSH26X
  612. if (pi->fccHandler == FOURCC_H26X)
  613. {
  614. if ((lParam1->biWidth & 0x3) || (lParam1->biHeight & 0x3) ||
  615. (lParam1->biWidth < 4) || (lParam1->biWidth > 352) ||
  616. (lParam1->biHeight < 4) || (lParam1->biHeight > 288))
  617. {
  618. ERRORMESSAGE(("%s: ICERR_BADFORMAT\r\n", _fx_));
  619. return((DWORD)ICERR_BADFORMAT);
  620. }
  621. }
  622. else
  623. {
  624. #endif
  625. if(!
  626. ( ((lParam1->biWidth == 128) && (lParam1->biHeight == 96)) ||
  627. ((lParam1->biWidth == 176) && (lParam1->biHeight == 144)) ||
  628. #ifdef USE_BILINEAR_MSH26X
  629. ((lParam1->biWidth == 80) && (lParam1->biHeight == 64)) ||
  630. #endif
  631. ((lParam1->biWidth == 352) && (lParam1->biHeight == 288))
  632. #ifndef MICROSOFT
  633. ||
  634. ( ( (lParam1->biCompression == FOURCC_YVU9) ||
  635. (lParam1->biCompression == FOURCC_YUY2) ||
  636. (lParam1->biCompression == FOURCC_UYVY) ||
  637. (lParam1->biCompression == FOURCC_YUV12) ||
  638. (lParam1->biCompression == FOURCC_IYUV) ||
  639. (lParam1->biCompression == BI_RGB) )
  640. && ((lParam1->biWidth == 160) && (lParam1->biHeight == 120)) )
  641. ||
  642. ( ( (lParam1->biCompression == FOURCC_YVU9) ||
  643. (lParam1->biCompression == FOURCC_YUY2) ||
  644. (lParam1->biCompression == FOURCC_UYVY) ||
  645. (lParam1->biCompression == FOURCC_YUV12) ||
  646. (lParam1->biCompression == FOURCC_IYUV) ||
  647. (lParam1->biCompression == BI_RGB) )
  648. && ((lParam1->biWidth == 240) && (lParam1->biHeight == 180)) )
  649. ||
  650. ( ( (lParam1->biCompression == FOURCC_YUV12) || (lParam1->biCompression == FOURCC_IYUV) )
  651. && ((lParam1->biWidth == 320) && (lParam1->biHeight == 240)) )
  652. #endif
  653. ))
  654. {
  655. ERRORMESSAGE(("%s: ICERR_BADFORMAT\r\n", _fx_));
  656. return((DWORD)ICERR_BADFORMAT);
  657. }
  658. #ifdef USE_BILINEAR_MSH26X
  659. }
  660. #endif
  661. #else
  662. if (((FOURCC_YVU9 == lParam1->biCompression) && (9 != lParam1->biBitCount)) ||
  663. ((FOURCC_YUY2 == lParam1->biCompression) && (16 != lParam1->biBitCount)) ||
  664. ((FOURCC_UYVY == lParam1->biCompression) && (16 != lParam1->biBitCount)) ||
  665. // The following check for 9-bit YUV12 is a hack to work around a VPhone 1.x bug.
  666. ((FOURCC_YUV12 == lParam1->biCompression) &&
  667. !((12 == lParam1->biBitCount) || (9 == lParam1->biBitCount))) ||
  668. ((FOURCC_IYUV == lParam1->biCompression) &&
  669. !((12 == lParam1->biBitCount) || (9 == lParam1->biBitCount)))) {
  670. ERRORMESSAGE(("%s: Incorrect bit width (ICERR_BADFORMAT)\r\n", _fx_));
  671. return((DWORD)ICERR_BADFORMAT);
  672. }
  673. // The H263+ message indicates whether arbitrary frame
  674. // sizes are to be supported. If arbitrary frames are needed,
  675. // the H263+ message must be sent before the first call to
  676. // CompressQuery.
  677. if (bH263PlusState) {
  678. if ((lParam1->biWidth & 0x3) || (lParam1->biHeight & 0x3) ||
  679. (lParam1->biWidth < 4) || (lParam1->biWidth > 352) ||
  680. (lParam1->biHeight < 4) || (lParam1->biHeight > 288)) {
  681. ERRORMESSAGE(("%s: ICERR_BADFORMAT\r\n", _fx_));
  682. return((DWORD)ICERR_BADFORMAT);
  683. }
  684. } else {
  685. if(!
  686. ( ((lParam1->biWidth == 128) && (lParam1->biHeight == 96)) ||
  687. ((lParam1->biWidth == 176) && (lParam1->biHeight == 144)) ||
  688. ((lParam1->biWidth == 352) && (lParam1->biHeight == 288)) ||
  689. ( ( (lParam1->biCompression == FOURCC_YVU9) ||
  690. (lParam1->biCompression == FOURCC_YUY2) ||
  691. (lParam1->biCompression == FOURCC_UYVY) ||
  692. (lParam1->biCompression == FOURCC_YUV12) ||
  693. (lParam1->biCompression == FOURCC_IYUV) ||
  694. (lParam1->biCompression == BI_RGB) )
  695. && ((lParam1->biWidth == 160) && (lParam1->biHeight == 120)) ) ||
  696. ( ( (lParam1->biCompression == FOURCC_YVU9) ||
  697. (lParam1->biCompression == FOURCC_YUY2) ||
  698. (lParam1->biCompression == FOURCC_UYVY) ||
  699. (lParam1->biCompression == FOURCC_YUV12) ||
  700. (lParam1->biCompression == FOURCC_IYUV) ||
  701. (lParam1->biCompression == BI_RGB) )
  702. && ((lParam1->biWidth == 240) && (lParam1->biHeight == 180)) ) ||
  703. ( ( (lParam1->biCompression == FOURCC_YUV12) || (lParam1->biCompression == FOURCC_IYUV) )
  704. && ((lParam1->biWidth == 320) && (lParam1->biHeight == 240)) ) ))
  705. {
  706. ERRORMESSAGE(("%s: ICERR_BADFORMAT\r\n", _fx_));
  707. return((DWORD)ICERR_BADFORMAT);
  708. }
  709. }
  710. #endif
  711. if( lParam1->biPlanes != 1 )
  712. {
  713. ERRORMESSAGE(("%s: ICERR_BADFORMAT\r\n", _fx_));
  714. return((DWORD)ICERR_BADFORMAT);
  715. }
  716. if(lParam2 == 0) // Checking input only
  717. return(ICERR_OK);
  718. // TODO: Do we want to check frame dimensions of output?
  719. #ifdef USE_BILINEAR_MSH26X
  720. if( (lParam2->biCompression != FOURCC_H263) && (lParam2->biCompression != FOURCC_H26X) )
  721. #else
  722. if( lParam2->biCompression != FOURCC_H263 )
  723. #endif
  724. {
  725. ERRORMESSAGE(("%s: ICERR_BADFORMAT\r\n", _fx_));
  726. return ((DWORD)ICERR_BADFORMAT);
  727. }
  728. #if defined(H263P)
  729. if (bH263PlusState) {
  730. if ((lParam1->biWidth != lParam2->biWidth) ||
  731. (lParam1->biHeight != lParam2->biHeight)) {
  732. ERRORMESSAGE(("%s: ICERR_BADFORMAT\r\n", _fx_));
  733. return ((DWORD)ICERR_BADFORMAT);
  734. }
  735. } else {
  736. if(!
  737. (( ( ((lParam1->biWidth == 128) && (lParam1->biHeight == 96)) ||
  738. ((lParam1->biWidth == 176) && (lParam1->biHeight == 144)) ||
  739. ((lParam1->biWidth == 352) && (lParam1->biHeight == 288)) ) &&
  740. (lParam1->biWidth == lParam2->biWidth) && (lParam1->biHeight == lParam2->biHeight) ) ||
  741. (((lParam1->biCompression == FOURCC_YVU9) ||
  742. (lParam1->biCompression == FOURCC_YUY2) ||
  743. (lParam1->biCompression == FOURCC_UYVY) ||
  744. (lParam1->biCompression == FOURCC_YUV12) ||
  745. (lParam1->biCompression == FOURCC_IYUV) ||
  746. (lParam1->biCompression == BI_RGB)) &&
  747. (((lParam1->biWidth == 160) && (lParam1->biHeight == 120)) &&
  748. ((lParam2->biWidth == 128) && (lParam2->biHeight == 96)))) ||
  749. (((lParam1->biCompression == FOURCC_YVU9) ||
  750. (lParam1->biCompression == FOURCC_YUY2) ||
  751. (lParam1->biCompression == FOURCC_UYVY) ||
  752. (lParam1->biCompression == FOURCC_YUV12) ||
  753. (lParam1->biCompression == FOURCC_IYUV) ||
  754. (lParam1->biCompression == BI_RGB)) &&
  755. (((lParam1->biWidth == 240) && (lParam1->biHeight == 180)) &&
  756. ((lParam2->biWidth == 176) && (lParam2->biHeight == 144)))) ||
  757. (((lParam1->biCompression == FOURCC_YUV12) || (lParam1->biCompression == FOURCC_IYUV)) &&
  758. (((lParam1->biWidth == 320) && (lParam1->biHeight == 240)) &&
  759. ((lParam2->biWidth == 320) && (lParam2->biHeight == 240)))) ) )
  760. {
  761. ERRORMESSAGE(("%s: ICERR_BADFORMAT\r\n", _fx_));
  762. return ((DWORD)ICERR_BADFORMAT);
  763. }
  764. }
  765. #endif
  766. return(ICERR_OK);
  767. }
  768. #endif
  769. ;////////////////////////////////////////////////////////////////////////////
  770. ;// Function: DWORD PASCAL CompressQuery(LPCODINST, LPBITMAPINFOHEADER, LPBITMAPINFOHEADER);
  771. ;//
  772. ;// Description:
  773. ;//
  774. ;// History: 05/11/94 -BEN-
  775. ;////////////////////////////////////////////////////////////////////////////
  776. DWORD PASCAL CompressFramesInfo(LPCODINST lpCompInst, ICCOMPRESSFRAMES *lParam1, int lParam2)
  777. {
  778. FX_ENTRY("CompressFramesInfo");
  779. // Check to see if we are given a nonzero pointer.
  780. if (lpCompInst == NULL)
  781. {
  782. ERRORMESSAGE(("%s: CompressFramesInfo called with NULL parameter - returning ICERR_BADFORMAT", _fx_));
  783. return ((DWORD)ICERR_BADFORMAT);
  784. }
  785. // lParam2 should be the size of the structure.
  786. if (lParam2 != sizeof(ICCOMPRESSFRAMES))
  787. {
  788. ERRORMESSAGE(("%s: wrong size of ICOMPRESSFRAMES structure", _fx_));
  789. return ((DWORD)ICERR_BADFORMAT);
  790. }
  791. if (!lParam1 || (lParam1->dwScale == 0))
  792. {
  793. ERRORMESSAGE(("%s: dwScale is zero", _fx_));
  794. return ((DWORD)ICERR_BADFORMAT);
  795. }
  796. lpCompInst->FrameRate = (float)lParam1->dwRate / (float)lParam1->dwScale;
  797. lpCompInst->DataRate = (U32)lParam1->lDataRate;
  798. DEBUGMSG(ZONE_BITRATE_CONTROL, ("%s: Setting frame rate at %ld.%ld fps and bitrate at %ld bps", _fx_, (DWORD)lpCompInst->FrameRate, (DWORD)((lpCompInst->FrameRate - (float)(DWORD)lpCompInst->FrameRate) * 100.0f), lpCompInst->DataRate * 8UL));
  799. return ((DWORD)ICERR_OK);
  800. }
  801. ;////////////////////////////////////////////////////////////////////////////
  802. ;// Function: BOOL bIsOkRes(LPCODINST);
  803. ;//
  804. ;// Description: This function checks whether the desired height and
  805. ;// width are possible.
  806. ;//
  807. ;// History: 05/11/94 -BEN-
  808. ;////////////////////////////////////////////////////////////////////////////
  809. BOOL bIsOkRes(LPCODINST lpCompInst)
  810. {
  811. BOOL bRet;
  812. // Check for NULL pointer
  813. if (lpCompInst == NULL)
  814. return 0;
  815. bRet = lpCompInst->xres <= 352
  816. && lpCompInst->yres <= 288
  817. && lpCompInst->xres >= 4
  818. && lpCompInst->yres >= 4
  819. && (lpCompInst->xres & ~3) == lpCompInst->xres
  820. && (lpCompInst->yres & ~3) == lpCompInst->yres;
  821. return(bRet);
  822. }
  823. ;////////////////////////////////////////////////////////////////////////////
  824. ;// Function: DWORD PASCAL CompressBegin(LPCODINST, LPBITMAPINFOHEADER, LPBITMAPINFOHEADER);
  825. ;//
  826. ;// Description:
  827. ;//
  828. ;// History: 05/11/94 -BEN-
  829. ;////////////////////////////////////////////////////////////////////////////
  830. DWORD PASCAL CompressBegin(
  831. #ifdef USE_BILINEAR_MSH26X
  832. LPINST pi,
  833. #else
  834. LPCODINST lpCompInst,
  835. #endif
  836. LPBITMAPINFOHEADER lParam1,
  837. LPBITMAPINFOHEADER lParam2
  838. )
  839. {
  840. #ifdef USE_BILINEAR_MSH26X
  841. LPCODINST lpCompInst = (LPCODINST)pi->CompPtr;
  842. #endif
  843. DWORD dwQuery;
  844. LRESULT retval;
  845. #if defined(H263P)
  846. BOOL bH263PlusState = FALSE;
  847. if (lpCompInst)
  848. CustomGetH263PlusState(lpCompInst, (DWORD FAR *)&bH263PlusState);
  849. #endif
  850. // Check input and output format.
  851. #ifdef USE_BILINEAR_MSH26X
  852. if( (dwQuery = CompressQuery(pi, lParam1, lParam2)) != ICERR_OK)
  853. #else
  854. if( (dwQuery = CompressQuery(lpCompInst, lParam1, lParam2)) != ICERR_OK)
  855. #endif
  856. return(dwQuery);
  857. // Check instance pointer
  858. if (!lpCompInst || !lParam1)
  859. return ICERR_ERROR;
  860. #if defined(H263P) || defined(USE_BILINEAR_MSH26X)
  861. lpCompInst->InputCompression = lParam1->biCompression;
  862. lpCompInst->InputBitWidth = lParam1->biBitCount;
  863. if (((FOURCC_YUV12 == lParam1->biCompression) || (FOURCC_IYUV == lParam1->biCompression)) && (9 == lParam1->biBitCount)) {
  864. lpCompInst->InputBitWidth = 12;
  865. }
  866. #endif
  867. #if defined(H263P)
  868. if ( lParam2 && bH263PlusState)
  869. {
  870. // This is the "new" style for indicating if the input should
  871. // be cropped/stretched to a standard frame size.
  872. // Old applications may pass in NULL or junk for lparam2.
  873. // New applications should pass a valid lParam2 that indicates
  874. // the desired output frame size. Also, the H263Plus flag must
  875. // be set in the configuration structure before calling CompressBegin()
  876. lpCompInst->xres = (WORD)lParam2->biWidth;
  877. lpCompInst->yres = (WORD)lParam2->biHeight;
  878. } else
  879. #endif // H263P
  880. {
  881. lpCompInst->xres = (WORD)lParam1->biWidth;
  882. lpCompInst->yres = (WORD)lParam1->biHeight;
  883. lpCompInst->Is160x120 = FALSE;
  884. lpCompInst->Is240x180 = FALSE;
  885. lpCompInst->Is320x240 = FALSE;
  886. if ( (lParam1->biWidth == 160) && (lParam1->biHeight == 120) )
  887. {
  888. lpCompInst->xres = 128;
  889. lpCompInst->yres = 96;
  890. lpCompInst->Is160x120 = TRUE;
  891. }
  892. else if ( (lParam1->biWidth == 240) && (lParam1->biHeight == 180) )
  893. {
  894. lpCompInst->xres = 176;
  895. lpCompInst->yres = 144;
  896. lpCompInst->Is240x180 = TRUE;
  897. }
  898. else if ( (lParam1->biWidth == 320) && (lParam1->biHeight == 240) )
  899. {
  900. lpCompInst->xres = 352;
  901. lpCompInst->yres = 288;
  902. lpCompInst->Is320x240 = TRUE;
  903. }
  904. }
  905. if(!bIsOkRes(lpCompInst))
  906. return((DWORD)ICERR_BADIMAGESIZE);
  907. // Set frame size.
  908. if (lpCompInst->xres == 128 && lpCompInst->yres == 96)
  909. lpCompInst->FrameSz = SQCIF;
  910. else if (lpCompInst->xres == 176 && lpCompInst->yres == 144)
  911. lpCompInst->FrameSz = QCIF;
  912. else if (lpCompInst->xres == 352 && lpCompInst->yres == 288)
  913. lpCompInst->FrameSz = CIF;
  914. #ifdef USE_BILINEAR_MSH26X
  915. else if (pi->fccHandler == FOURCC_H26X)
  916. lpCompInst->FrameSz = fCIF;
  917. #endif
  918. #ifdef H263P
  919. else
  920. lpCompInst->FrameSz = CUSTOM;
  921. #else
  922. else // unsupported frame size.
  923. return (DWORD)ICERR_BADIMAGESIZE;
  924. #endif
  925. // Allocate and Initialize tables and memory that are specific to
  926. // this instance.
  927. #if defined(H263P) || defined(USE_BILINEAR_MSH26X)
  928. retval = H263InitEncoderInstance(lParam1,lpCompInst);
  929. #else
  930. retval = H263InitEncoderInstance(lpCompInst);
  931. #endif
  932. return(retval);
  933. }
  934. ;////////////////////////////////////////////////////////////////////////////
  935. ;// Function: DWORD PASCAL CompressEnd(LPCODINST);
  936. ;//
  937. ;// Description:
  938. ;//
  939. ;// History: 05/11/94 -BEN-
  940. ;////////////////////////////////////////////////////////////////////////////
  941. DWORD PASCAL CompressEnd(LPCODINST lpInst)
  942. {
  943. LRESULT retval;
  944. retval = H263TermEncoderInstance(lpInst);
  945. return(retval);
  946. }
  947. ;////////////////////////////////////////////////////////////////////////////
  948. ;// Function: DWORD PASCAL Compress(LPCODINST, ICCOMPRESS FAR *, DWORD);
  949. ;//
  950. ;// Description:
  951. ;//
  952. ;// History: 05/11/94 -BEN-
  953. ;////////////////////////////////////////////////////////////////////////////
  954. DWORD PASCAL Compress(
  955. #ifdef USE_BILINEAR_MSH26X
  956. LPINST pi,
  957. #else
  958. LPCODINST lpInst, // ptr to Compressor instance information.
  959. #endif
  960. ICCOMPRESS FAR * lpCompInfo, // ptr to ICCOMPRESS structure.
  961. DWORD dOutbufSize // size, in bytes, of the ICCOMPRESS structure.
  962. )
  963. {
  964. #ifdef USE_BILINEAR_MSH26X
  965. LPCODINST lpInst = (LPCODINST)pi->CompPtr; // ptr to Compressor instance information.
  966. #endif
  967. DWORD dwRet;
  968. FX_ENTRY("Compress")
  969. // Check to see if we are given a NULL pointer.
  970. if(lpInst == NULL || lpCompInfo == NULL)
  971. {
  972. ERRORMESSAGE(("%s: called with NULL parameter\r\n", _fx_));
  973. return( (DWORD) ICERR_ERROR );
  974. }
  975. try
  976. {
  977. #ifdef USE_BILINEAR_MSH26X
  978. dwRet = H263Compress(pi, lpCompInfo);
  979. #else
  980. dwRet = H263Compress(lpInst, lpCompInfo);
  981. #endif
  982. }
  983. catch (...)
  984. {
  985. // For a DEBUG build, display a message and pass the exception up.
  986. // For a release build, stop the exception here and return an error
  987. // code. This gives upstream code a chance to gracefully recover.
  988. // We also need to clear the floating point control word, otherwise
  989. // the upstream code may incur an exception the next time it tries
  990. // a floating point operation (presuming this exception was due
  991. // to a floating point problem).
  992. #if defined(DEBUG) || defined(_DEBUG)
  993. ERRORMESSAGE(("%s: Exception occured!!!\r\n", _fx_));
  994. throw;
  995. #else
  996. _clearfp();
  997. return (DWORD) ICERR_ERROR;
  998. #endif
  999. }
  1000. if(dwRet != ICERR_OK)
  1001. {
  1002. ERRORMESSAGE(("%s: Failed!!!\r\n", _fx_));
  1003. }
  1004. // now transfer the information.
  1005. lpCompInfo->lpbiOutput->biSize =sizeof(BITMAPINFOHEADER);
  1006. #ifdef USE_BILINEAR_MSH26X
  1007. lpCompInfo->lpbiOutput->biCompression = pi->fccHandler;
  1008. #else
  1009. lpCompInfo->lpbiOutput->biCompression = FOURCC_H263;
  1010. #endif
  1011. lpCompInfo->lpbiOutput->biPlanes = 1;
  1012. lpCompInfo->lpbiOutput->biBitCount = 24;
  1013. lpCompInfo->lpbiOutput->biWidth = lpInst->xres;
  1014. lpCompInfo->lpbiOutput->biHeight = lpInst->yres;
  1015. lpCompInfo->lpbiOutput->biSizeImage = lpInst->CompressedSize;
  1016. lpCompInfo->lpbiOutput->biClrUsed = 0;
  1017. lpCompInfo->lpbiOutput->biClrImportant = 0;
  1018. // lpCompInfo->dwFlags is set inside the compressor.
  1019. // set the chunk idea if requested
  1020. if (lpCompInfo->lpckid)
  1021. {
  1022. *(lpCompInfo->lpckid) = TWOCC_H26X;
  1023. }
  1024. return(dwRet);
  1025. }