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.

189 lines
4.5 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. * d3gob.cpp
  16. *
  17. * Description:
  18. * This modules contains the GOB header support routines
  19. *
  20. * Routines:
  21. * H263SetGOBHeaderInfo
  22. *
  23. * Data:
  24. */
  25. /* $Header: S:\h26x\src\dec\d1gob.cpv 1.15 10 Sep 1996 15:50:52 RHAZRA $
  26. */
  27. #include "precomp.h"
  28. /* BIT field Constants
  29. */
  30. const int BITS_GOB_STARTCODE = 16;
  31. const int BITS_GROUP_NUMBER = 4;
  32. const int BITS_GFID = 2;
  33. const int BITS_GQUANT = 5;
  34. const int MAX_GBSC_LOOKAHEAD_NUMBER = 7;
  35. const int BITS_GSPARE = 8; // not including the following GEI
  36. /* GBSC_VALUE - 0000 0000 0000 0001 xxxx xxxx xxxx xxxx
  37. */
  38. const U32 GBSC_VALUE = (0x00010000 >> (32-BITS_GOB_STARTCODE));
  39. /*****************************************************************************
  40. *
  41. * H263DecodeGOBHeader
  42. *
  43. * Set the GOB header information in the decoder catalog. GOB numbers 2 thru
  44. * N may have a GOB header. Look for one if it is there read it storing the
  45. * information in the catalog. If a GOB header is not there set the information
  46. * to default values.
  47. *
  48. * Returns an ICERR_STATUS
  49. */
  50. #pragma code_seg("IACODE1")
  51. extern I32 H263DecodeGOBHeader(
  52. T_H263DecoderCatalog FAR * DC,
  53. BITSTREAM_STATE FAR * fpbsState,
  54. U32 uAssumedGroupNumber)
  55. {
  56. U8 FAR * fpu8;
  57. U32 uBitsReady;
  58. U32 uWork;
  59. I32 iReturn;
  60. U32 uResult;
  61. U16 bFoundStartCode = 0;
  62. int iSpareCount;
  63. #ifndef RING0
  64. char buf120[120];
  65. int iLength;
  66. #endif
  67. GET_BITS_RESTORE_STATE(fpu8, uWork, uBitsReady, fpbsState)
  68. /* GNum */
  69. GET_FIXED_BITS((U32) BITS_GROUP_NUMBER, fpu8, uWork, uBitsReady, uResult);
  70. DC->uGroupNumber = uResult;
  71. //#ifndef LOSS_RECOVERY
  72. #if 0
  73. if (DC->uGroupNumber <= 0)
  74. {
  75. DBOUT("Bad GOB number");
  76. iReturn = ICERR_ERROR;
  77. goto done;
  78. /* took out ASSERT so that can try and catch
  79. ** invalid bit streams and return error
  80. */
  81. //ASSERT(DC->uGroupNumber > 0);
  82. }
  83. #else
  84. if (DC->uGroupNumber <= 0)
  85. {
  86. DBOUT("Detected packet fault in GOB number");
  87. DBOUT("Returning PACKET_FAULT_AT_MB_OR_GOB");
  88. iReturn = PACKET_FAULT_AT_MB_OR_GOB;
  89. goto done;
  90. }
  91. #endif
  92. /* GQUANT */
  93. GET_FIXED_BITS((U32) BITS_GQUANT, fpu8, uWork, uBitsReady, uResult);
  94. //#ifndef LOSS_RECOVERY
  95. #if 0
  96. if (uResult < 1)
  97. {
  98. iReturn = ICERR_ERROR;
  99. goto done;
  100. }
  101. DC->uGQuant = uResult;
  102. DC->uMQuant = uResult;
  103. #else
  104. if (uResult < 1)
  105. {
  106. DBOUT("Detected packet fault in GOB quant");
  107. DBOUT("Returning PACKET_FAULT_AT_PSC");
  108. iReturn = PACKET_FAULT_AT_PSC;
  109. GET_BITS_SAVE_STATE(fpu8, uWork, uBitsReady, fpbsState)
  110. goto done;
  111. }
  112. DC->uGQuant = uResult;
  113. DC->uMQuant = uResult;
  114. #endif
  115. /* skip spare bits */
  116. iSpareCount = 0;
  117. GET_ONE_BIT(fpu8, uWork, uBitsReady, uResult);
  118. while(uResult)
  119. {
  120. GET_FIXED_BITS((U32)BITS_GSPARE, fpu8, uWork, uBitsReady, uResult);
  121. GET_ONE_BIT(fpu8, uWork, uBitsReady, uResult);
  122. iSpareCount += BITS_GSPARE;
  123. }
  124. /* Save the modified bitstream state */
  125. GET_BITS_SAVE_STATE(fpu8, uWork, uBitsReady, fpbsState)
  126. #ifndef RING0
  127. iLength = wsprintf(buf120,"GOB: HeaderPresent=%d GN=%ld GQ=%ld",
  128. bFoundStartCode,
  129. DC->uGroupNumber,
  130. DC->uGQuant);
  131. DBOUT(buf120);
  132. ASSERT(iLength < 120);
  133. #endif
  134. iReturn = ICERR_OK;
  135. done:
  136. return iReturn;
  137. } /* end H263DecodeGOBHeader() */
  138. #pragma code_seg()
  139. /* ******************************************** */
  140. #pragma code_seg("IACODE1")
  141. extern I32 H263DecodeGOBStartCode(
  142. T_H263DecoderCatalog FAR * DC,
  143. BITSTREAM_STATE FAR * fpbsState)
  144. {
  145. U8 FAR * fpu8;
  146. U32 uBitsReady;
  147. U32 uWork;
  148. I32 iReturn;
  149. U32 uResult;
  150. /* Look for the GOB header Start Code */
  151. GET_BITS_RESTORE_STATE(fpu8, uWork, uBitsReady, fpbsState)
  152. GET_FIXED_BITS((U32) BITS_GOB_STARTCODE, fpu8, uWork, uBitsReady, uResult);
  153. if (uResult != 1)
  154. {
  155. iReturn = ICERR_ERROR;
  156. goto done;
  157. }
  158. GET_BITS_SAVE_STATE(fpu8, uWork, uBitsReady, fpbsState)
  159. iReturn = ICERR_OK;
  160. done:
  161. return iReturn;
  162. } /* end H263DecodeGOBStartCode() */
  163. #pragma code_seg()