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.

226 lines
6.6 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) 1995 Intel Corporation.
  10. ** All Rights Reserved.
  11. **
  12. ** *************************************************************************
  13. */
  14. /*
  15. * d1pict.cpp
  16. *
  17. * Description:
  18. * This modules contains the picture header parsing routines
  19. *
  20. * Routines:
  21. * H263ReadPictureHeader
  22. *
  23. * Data:
  24. */
  25. /* $Header: S:\h26x\src\dec\d1pict.cpv 1.13 22 Jan 1997 13:36:12 RHAZRA $
  26. */
  27. #include "precomp.h"
  28. /* BIT field Constants
  29. */
  30. const int BITS_PICTURE_STARTCODE = 20;
  31. const int BITS_TR = 5;
  32. const int BITS_PSPARE = 8; //not including the following PEI
  33. /* PSC_VALUE - 0000 0000 0000 0001 0000 xxxx xxxx xxxx
  34. */
  35. const U32 PSC_VALUE = (0x00010000 >> (32-BITS_PICTURE_STARTCODE));
  36. /* We only want to search so far before it is considered an error
  37. */
  38. const int MAX_LOOKAHEAD_NUMBER = 256; /* number of bits */
  39. /*****************************************************************************
  40. *
  41. * H263DecodePictureHeader
  42. *
  43. * Read and parse the picture header - updating the fpbsState if the read
  44. * succeeds.
  45. *
  46. * Returns an ICERR_STATUS
  47. */
  48. #ifdef CHECKSUM_PICTURE
  49. extern I32
  50. H263DecodePictureHeader(
  51. T_H263DecoderCatalog FAR * DC,
  52. U8 FAR * fpu8,
  53. U32 uBitsReady,
  54. U32 uWork,
  55. BITSTREAM_STATE FAR * fpbsState,
  56. YVUCheckSum * pReadYVUCksum,
  57. U32 * uCheckSumValid)
  58. #else
  59. extern I32
  60. H263DecodePictureHeader(
  61. T_H263DecoderCatalog FAR * DC,
  62. U8 FAR * fpu8,
  63. U32 uBitsReady,
  64. U32 uWork,
  65. BITSTREAM_STATE FAR * fpbsState)
  66. #endif
  67. {
  68. I32 iReturn;
  69. int iLookAhead;
  70. U32 uResult;
  71. U32 uData;
  72. int iSpareCount;
  73. #ifndef RING0
  74. char buf120[120];
  75. int iLength;
  76. #endif
  77. /* PSC
  78. */
  79. GET_FIXED_BITS((U32) BITS_PICTURE_STARTCODE, fpu8, uWork, uBitsReady,
  80. uResult);
  81. iLookAhead = 0;
  82. while (uResult != PSC_VALUE) {
  83. uResult = uResult << 1;
  84. uResult &= GetBitsMask[BITS_PICTURE_STARTCODE];
  85. GET_ONE_BIT(fpu8, uWork, uBitsReady, uData);
  86. uResult |= uData;
  87. iLookAhead++;
  88. if (iLookAhead > MAX_LOOKAHEAD_NUMBER) {
  89. DBOUT("ERROR :: H263ReadPictureHeader :: missing PSC :: ERROR");
  90. iReturn = ICERR_ERROR;
  91. goto done;
  92. }
  93. }
  94. GET_FIXED_BITS((U32) BITS_TR, fpu8, uWork, uBitsReady, uResult);
  95. DC->uTempRef = uResult;
  96. /* PTYPE
  97. */
  98. GET_ONE_BIT(fpu8, uWork, uBitsReady, uResult);
  99. DC->bSplitScreen = (U16) uResult;
  100. GET_ONE_BIT(fpu8, uWork, uBitsReady, uResult);
  101. DC->bCameraOn = (U16) uResult;
  102. GET_ONE_BIT(fpu8, uWork, uBitsReady, uResult);
  103. DC->bFreezeRelease = (U16) uResult;
  104. GET_ONE_BIT(fpu8, uWork, uBitsReady, uResult);
  105. if (uResult > SRC_FORMAT_CIF)
  106. {
  107. DBOUT("ERROR::H263ReadPictureHeader::src format not supported??::ERROR");
  108. iReturn=ICERR_ERROR;
  109. goto done;
  110. }
  111. DC->uPrevSrcFormat = DC->uSrcFormat;
  112. DC->uSrcFormat = (U16) uResult;
  113. if (DC->bReadSrcFormat && DC->uPrevSrcFormat != DC->uSrcFormat)
  114. {
  115. DBOUT("ERROR::H263ReadPictureHeader::src format change is not supported??::ERROR");
  116. iReturn=ICERR_ERROR;
  117. goto done;
  118. }
  119. DC->bReadSrcFormat = 1;
  120. GET_ONE_BIT(fpu8, uWork, uBitsReady, uResult);
  121. DC->bHiResStill = (U16) !uResult;
  122. GET_ONE_BIT(fpu8, uWork, uBitsReady, uResult);
  123. DC->bUnused = (U16) uResult;
  124. /* process Picture layer checksum data */
  125. /* OR */
  126. /* skip spare bits */
  127. #ifdef CHECKSUM_PICTURE
  128. /* get checksum data one bit */
  129. GET_ONE_BIT(fpu8, uWork, uBitsReady, uResult);
  130. if (uResult == 1)
  131. {
  132. /* first check for key field */
  133. GET_FIXED_BITS((U32) BITS_PSPARE, fpu8, uWork, uBitsReady, uResult);
  134. if (uResult == 1)
  135. *uCheckSumValid = 1;
  136. else *uCheckSumValid = 0;
  137. GET_ONE_BIT(fpu8, uWork, uBitsReady, uResult);
  138. GET_FIXED_BITS((U32) BITS_PSPARE, fpu8, uWork, uBitsReady, uResult);
  139. /* get Y checksum */
  140. pReadYVUCksum->uYCheckSum = ((uResult & 0xff) << 24);
  141. GET_FIXED_BITS(9, fpu8, uWork, uBitsReady, uResult);
  142. pReadYVUCksum->uYCheckSum = (pReadYVUCksum->uYCheckSum | ((uResult & 0xff) << 16));
  143. GET_FIXED_BITS(9, fpu8, uWork, uBitsReady, uResult);
  144. pReadYVUCksum->uYCheckSum = (pReadYVUCksum->uYCheckSum | ((uResult & 0xff) << 8));
  145. GET_FIXED_BITS(9, fpu8, uWork, uBitsReady, uResult);
  146. pReadYVUCksum->uYCheckSum = (pReadYVUCksum->uYCheckSum | (uResult & 0xff));
  147. /* get V checksum */
  148. GET_FIXED_BITS(9, fpu8, uWork, uBitsReady, uResult);
  149. pReadYVUCksum->uVCheckSum = ((uResult & 0xff) << 24);
  150. GET_FIXED_BITS(9, fpu8, uWork, uBitsReady, uResult);
  151. pReadYVUCksum->uVCheckSum = (pReadYVUCksum->uVCheckSum | ((uResult & 0xff) << 16));
  152. GET_FIXED_BITS(9, fpu8, uWork, uBitsReady, uResult);
  153. pReadYVUCksum->uVCheckSum = (pReadYVUCksum->uVCheckSum | ((uResult & 0xff) << 8));
  154. GET_FIXED_BITS(9, fpu8, uWork, uBitsReady, uResult);
  155. pReadYVUCksum->uVCheckSum = (pReadYVUCksum->uVCheckSum | (uResult & 0xff));
  156. /* get U checksum */
  157. GET_FIXED_BITS(9, fpu8, uWork, uBitsReady, uResult);
  158. pReadYVUCksum->uUCheckSum = ((uResult & 0xff) << 24);
  159. GET_FIXED_BITS(9, fpu8, uWork, uBitsReady, uResult);
  160. pReadYVUCksum->uUCheckSum = (pReadYVUCksum->uUCheckSum | ((uResult & 0xff) << 16));
  161. GET_FIXED_BITS(9, fpu8, uWork, uBitsReady, uResult);
  162. pReadYVUCksum->uUCheckSum = (pReadYVUCksum->uUCheckSum | ((uResult & 0xff) << 8));
  163. GET_FIXED_BITS(9, fpu8, uWork, uBitsReady, uResult);
  164. pReadYVUCksum->uUCheckSum = (pReadYVUCksum->uUCheckSum | (uResult & 0xff));
  165. GET_ONE_BIT(fpu8, uWork, uBitsReady, uResult);
  166. while (uResult) {
  167. GET_FIXED_BITS((U32) BITS_PSPARE, fpu8, uWork, uBitsReady, uResult);
  168. GET_ONE_BIT(fpu8, uWork, uBitsReady, uResult);
  169. }
  170. }
  171. else
  172. {
  173. DBOUT("ERROR :: H261PictureChecksum :: Invalid Checksum data :: ERROR");
  174. iReturn = ICERR_ERROR;
  175. goto done;
  176. }
  177. #else /* checksum is not enabled */
  178. /* skip spare bits */
  179. iSpareCount = 0;
  180. GET_ONE_BIT(fpu8, uWork, uBitsReady, uResult);
  181. while (uResult) {
  182. GET_FIXED_BITS((U32) BITS_PSPARE, fpu8, uWork, uBitsReady, uResult);
  183. GET_ONE_BIT(fpu8, uWork, uBitsReady, uResult);
  184. iSpareCount += BITS_PSPARE;
  185. }
  186. #endif
  187. #ifndef RING0
  188. iLength = wsprintf(buf120,
  189. "TR=%ld SS=%d CAM=%d FRZ=%d SRC=%d Spare=%d",
  190. DC->uTempRef,
  191. DC->bSplitScreen,
  192. DC->bCameraOn,
  193. DC->bFreezeRelease,
  194. DC->uSrcFormat,
  195. iSpareCount);
  196. DBOUT(buf120);
  197. ASSERT(iLength < 120);
  198. #endif
  199. GET_BITS_SAVE_STATE(fpu8, uWork, uBitsReady, fpbsState);
  200. iReturn = ICERR_OK;
  201. done:
  202. return iReturn;
  203. } /* end H263DecodePictureHeader() */