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.

204 lines
5.0 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. ** Copyright (c) 1996 Intel Corporation.
  11. ** All Rights Reserved.
  12. **
  13. ** *************************************************************************
  14. // $Header: S:\h26x\src\common\c1rtp.cpv 1.5 02 Dec 1996 16:13:38 RHAZRA $
  15. // $Log: S:\h26x\src\common\c1rtp.cpv $
  16. #
  17. # Rev 1.5 02 Dec 1996 16:13:38 RHAZRA
  18. # More adjustment to the H.261 RTp overhead estimation routine.
  19. #
  20. # Rev 1.4 22 Nov 1996 14:52:22 RHAZRA
  21. # Changed RTP overhead estimation routine slightly.
  22. #
  23. # Rev 1.3 18 Nov 1996 17:10:48 MBODART
  24. # Replaced all debug message invocations with Active Movie's DbgLog.
  25. #
  26. # Rev 1.2 07 Nov 1996 14:46:32 RHAZRA
  27. # Added function to guestimate RTP overhead in bitstream buffer.
  28. #
  29. # Rev 1.1 23 Aug 1996 13:05:54 RHAZRA
  30. # Added #ifdef RING0 .. #endif to avoid wsprintf and GlobalAlloc
  31. # problems in RING0
  32. #
  33. # Rev 1.0 21 Aug 1996 18:29:04 RHAZRA
  34. # Initial revision.
  35. //
  36. // Rev 1.2 02 May 1996 13:27:04 CZHU
  37. // Adjust for merging with main database in the decoder
  38. //
  39. // Rev 1.1 28 Apr 1996 20:34:50 BECHOLS
  40. //
  41. // Removed IFDEF -- RTP_HEADER.
  42. //
  43. // Rev 1.0 22 Apr 1996 17:47:54 BECHOLS
  44. // Initial revision.
  45. //
  46. // Rev 1.3 10 Apr 1996 13:32:08 CZHU
  47. //
  48. // Moved testing packet loss into this module
  49. // for common use by encoder or dec
  50. //
  51. // Rev 1.2 29 Mar 1996 14:45:06 CZHU
  52. //
  53. // Rev 1.1 29 Mar 1996 14:39:34 CZHU
  54. // Some cleaning
  55. //
  56. // Rev 1.0 29 Mar 1996 13:32:42 CZHU
  57. // Initial revision.
  58. //
  59. */
  60. #include "precomp.h"
  61. I32 H26XRTP_VerifyBsInfoStream(
  62. T_H263DecoderCatalog *DC,
  63. U8 *pu8Src,
  64. U32 uSize
  65. )
  66. {
  67. T_H26X_RTP_BSINFO_TRAILER *pBsTrailer;
  68. T_RTP_H261_BSINFO *pBsInfo;
  69. #ifndef RING0
  70. #ifdef _DEBUG
  71. int i;
  72. #endif
  73. #endif
  74. ASSERT(!DC->iVerifiedBsExt);
  75. DC->iVerifiedBsExt=TRUE;
  76. pBsTrailer =(T_H26X_RTP_BSINFO_TRAILER *)(pu8Src + uSize);
  77. pBsTrailer--;
  78. #ifndef RING0
  79. #ifdef _DEBUG
  80. {char msg[120];
  81. int iused;
  82. iused= wsprintf(msg,"StartCode = %ld, CompSize=%ld, No.Pack=%ld, SRC=%d, TR=%d, TRB=%d, DBQ=%d",
  83. pBsTrailer->uUniqueCode, pBsTrailer->uCompressedSize,
  84. pBsTrailer->uNumOfPackets,pBsTrailer->u8Src,
  85. pBsTrailer->u8TR,pBsTrailer->u8TRB,pBsTrailer->u8DBQ );
  86. ASSERT(iused < 120);
  87. DBOUT(msg);
  88. }
  89. #endif
  90. #endif
  91. if (pBsTrailer->uUniqueCode != H261_RTP_BS_START_CODE)
  92. {
  93. //#ifdef LOSS_RECOVERY
  94. #ifndef RING0
  95. #ifdef _DEBUG
  96. DBOUT("No RTP BS Extension found");
  97. #endif
  98. #endif
  99. DC->iValidBsExt = FALSE;
  100. DC->uNumOfPackets = 0;
  101. DC->pBsInfo = NULL;
  102. DC->pBsTrailer = NULL;
  103. //#endif
  104. goto ret;
  105. }
  106. //bitstream is valid, so...
  107. pBsInfo = (T_RTP_H261_BSINFO *)pBsTrailer;
  108. pBsInfo -= pBsTrailer->uNumOfPackets;
  109. //#ifdef LOSS_RECOVERY
  110. DC->pBsTrailer = (void *)pBsTrailer;
  111. DC->uNumOfPackets = pBsTrailer->uNumOfPackets;
  112. DC->iValidBsExt =TRUE;
  113. DC->pBsInfo = (void *)pBsInfo;
  114. //#endif
  115. #ifndef RING0
  116. #ifdef _DEBUG
  117. for (i=0; i< (int)pBsTrailer->uNumOfPackets; i++)
  118. {
  119. char msg[120];
  120. int iused;
  121. iused= wsprintf(msg,
  122. "uFlag =%d,BitOffset=%d, MBA=%d, uQuant=%d,GOBN=%d",
  123. pBsInfo->uFlags,
  124. pBsInfo->uBitOffset,
  125. pBsInfo->u8MBA,
  126. pBsInfo->u8Quant,
  127. pBsInfo->u8GOBN);
  128. ASSERT(iused < 120);
  129. DBOUT(msg);
  130. pBsInfo++;
  131. }
  132. #endif
  133. #endif
  134. ret:
  135. return TRUE;
  136. }
  137. DWORD H261EstimateRTPOverhead(LPCODINST lpInst, LPBITMAPINFOHEADER lParam1)
  138. {
  139. DWORD dExtendedSize;
  140. DWORD dTargetFrameSize;
  141. DWORD dEffectivePacketSize;
  142. BOOL bTargetSizeOK;
  143. DWORD dNumberOfGOBs;
  144. DWORD dNumberOfPacketsPerGOB;
  145. DWORD dGOBSize;
  146. DWORD dNormalBufferSize;
  147. extern U32 getRTPPacketSizeThreshold(U32);
  148. if (lParam1->biHeight == 288 && lParam1->biWidth == 352)
  149. {
  150. dNumberOfGOBs = 12;
  151. dNormalBufferSize = 32*1024;
  152. }
  153. else
  154. {
  155. dNumberOfGOBs = 3;
  156. dNormalBufferSize = 8 * 1024;
  157. }
  158. dEffectivePacketSize = getRTPPacketSizeThreshold(lpInst->Configuration.unPacketSize);
  159. if ( (lpInst->FrameRate > 0 ) && (lpInst->DataRate > 0) )
  160. {
  161. dTargetFrameSize = (DWORD) (lpInst->DataRate / lpInst->FrameRate);
  162. bTargetSizeOK = TRUE;
  163. }
  164. else
  165. {
  166. bTargetSizeOK = FALSE;
  167. }
  168. if (bTargetSizeOK)
  169. {
  170. dGOBSize = dTargetFrameSize/dNumberOfGOBs;
  171. dNumberOfPacketsPerGOB = __max(1, dGOBSize/dEffectivePacketSize);
  172. dExtendedSize = ( dNumberOfPacketsPerGOB * dNumberOfGOBs * sizeof(T_RTP_H261_BSINFO) +
  173. sizeof(T_H26X_RTP_BSINFO_TRAILER) ) * 2;
  174. }
  175. else
  176. dExtendedSize = dNormalBufferSize;
  177. return (dExtendedSize);
  178. }