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.

214 lines
6.2 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, 1996 Intel Corporation.
  10. ** All Rights Reserved.
  11. **
  12. ** *************************************************************************
  13. */
  14. //////////////////////////////////////////////////////////////////////////
  15. // $Author: MBODART $
  16. // $Date: 12 Sep 1996 14:23:16 $
  17. // $Archive: S:\h26x\src\dec\d1picchk.cpv $
  18. // $Header: S:\h26x\src\dec\d1picchk.cpv 1.4 12 Sep 1996 14:23:16 MBODART $
  19. // $Log: S:\h26x\src\dec\d1picchk.cpv $
  20. //
  21. // Rev 1.4 12 Sep 1996 14:23:16 MBODART
  22. // Replaced GlobalAlloc family with HeapAlloc in the H.261 decoder.
  23. //
  24. // Rev 1.3 21 Mar 1996 17:01:42 AKASAI
  25. // Added #ifdef so code is not included in non-checksum build.
  26. //////////////////////////////////////////////////////////////////////////////
  27. #ifdef CHECKSUM_PICTURE
  28. #include "precomp.h"
  29. //*********************************************************************
  30. //H261PictureCheckSumEntry -- This function locks Decoder Instance
  31. // data, calls routine to computes the
  32. // "Picture CheckSum" 3 - 32-bit values are
  33. // computed and returned in structure
  34. // YVUCheckSum and then Decoder Instance
  35. // data is unlocked.
  36. //*********************************************************************
  37. I32 H261PictureCheckSumEntry(
  38. LPDECINST lpInst,
  39. YVUCheckSum * pYVUCheckSum)
  40. {
  41. LRESULT iReturn = ICERR_ERROR;
  42. U8 FAR * P32Inst;
  43. if (lpInst->pDecoderInst == NULL)
  44. {
  45. DBOUT("ERROR :: H261PictureCheckSumEntry :: ICERR_MEMORY");
  46. iReturn = ICERR_MEMORY;
  47. goto done;
  48. }
  49. /* Build the decoder catalog pointer
  50. */
  51. P32Inst = (U8 FAR *) ((((U32) lpInst->pDecoderInst) + 31) & ~0x1F);
  52. /* Call routine to compute checksum
  53. */
  54. iReturn = H261ComputePictureCheckSum( P32Inst, pYVUCheckSum );
  55. done:
  56. return iReturn;
  57. }
  58. //*********************************************************************
  59. //H261ComputePictureCheckSum -- This function computes the "Picture CheckSum"
  60. // 3 - 32-bit values are computed and returned
  61. // in structure YVUCheckSum
  62. //*********************************************************************
  63. I32 H261ComputePictureCheckSum(
  64. U8 FAR * P32Inst,
  65. YVUCheckSum * pYVUCheckSum)
  66. {
  67. I32 iReturn = ICERR_ERROR;
  68. T_H263DecoderCatalog * DC;
  69. /* The following are used for Picture CheckSum */
  70. U32 uYCheckSum=0;
  71. U32 uVCheckSum=0;
  72. U32 uUCheckSum=0;
  73. I32 irow, icolumn;
  74. DWORD * hpdw;
  75. DWORD * hpdwU;
  76. DC = (T_H263DecoderCatalog FAR *) P32Inst;
  77. if (DC->uSrcFormat == SRC_FORMAT_QCIF)
  78. {
  79. hpdw = (DWORD *)((HPBYTE)P32Inst+DC->PrevFrame.X32_YPlane+Y_START);
  80. for (irow=0; irow < 144; irow++)
  81. {
  82. for (icolumn=0; icolumn < (176/16); icolumn++)
  83. {
  84. uYCheckSum += *hpdw++;
  85. uYCheckSum += *hpdw++;
  86. uYCheckSum += *hpdw++;
  87. uYCheckSum += *hpdw++;
  88. }
  89. hpdw += (PITCH/4) - (176/4);
  90. }
  91. pYVUCheckSum->uYCheckSum = uYCheckSum;
  92. hpdw = (DWORD *)((HPBYTE)P32Inst+DC->PrevFrame.X32_VPlane+UV_START);
  93. hpdwU = (DWORD *)((HPBYTE)P32Inst+DC->PrevFrame.X32_UPlane+UV_START);
  94. for (irow=0; irow < (144/2); irow++)
  95. {
  96. for (icolumn=0; icolumn < (176/16); icolumn++)
  97. {
  98. uVCheckSum += *hpdw++;
  99. uVCheckSum += *hpdw++;
  100. uUCheckSum += *hpdwU++;
  101. uUCheckSum += *hpdwU++;
  102. }
  103. hpdw += (PITCH/4) - (176/8);
  104. hpdwU += (PITCH/4) - (176/8);
  105. }
  106. pYVUCheckSum->uVCheckSum = uVCheckSum;
  107. pYVUCheckSum->uUCheckSum = uUCheckSum;
  108. }
  109. else if (DC->uSrcFormat == SRC_FORMAT_CIF)
  110. {
  111. hpdw = (DWORD *)((HPBYTE)P32Inst+DC->PrevFrame.X32_YPlane+Y_START);
  112. for (irow=0; irow < 288; irow++)
  113. {
  114. for (icolumn=0; icolumn < (352/32); icolumn++)
  115. {
  116. uYCheckSum += *hpdw++;
  117. uYCheckSum += *hpdw++;
  118. uYCheckSum += *hpdw++;
  119. uYCheckSum += *hpdw++;
  120. uYCheckSum += *hpdw++;
  121. uYCheckSum += *hpdw++;
  122. uYCheckSum += *hpdw++;
  123. uYCheckSum += *hpdw++;
  124. }
  125. hpdw += (PITCH/4) - (352/4);
  126. }
  127. pYVUCheckSum->uYCheckSum = uYCheckSum;
  128. hpdw = (DWORD *)((HPBYTE)P32Inst+DC->PrevFrame.X32_VPlane+UV_START);
  129. hpdwU = (DWORD *)((HPBYTE)P32Inst+DC->PrevFrame.X32_UPlane+UV_START);
  130. for (irow=0; irow < (288/2); irow++)
  131. {
  132. for (icolumn=0; icolumn < (352/32); icolumn++)
  133. {
  134. uVCheckSum += *hpdw++;
  135. uVCheckSum += *hpdw++;
  136. uVCheckSum += *hpdw++;
  137. uVCheckSum += *hpdw++;
  138. uUCheckSum += *hpdwU++;
  139. uUCheckSum += *hpdwU++;
  140. uUCheckSum += *hpdwU++;
  141. uUCheckSum += *hpdwU++;
  142. }
  143. hpdw += (PITCH/4) - (352/8);
  144. hpdwU += (PITCH/4) - (352/8);
  145. }
  146. pYVUCheckSum->uVCheckSum = uVCheckSum;
  147. pYVUCheckSum->uUCheckSum = uUCheckSum;
  148. }
  149. else {
  150. ASSERT(0); // Should never happen
  151. }
  152. iReturn = ICERR_OK;
  153. return iReturn;
  154. }
  155. //*********************************************************************
  156. //H261ComparePictureCheckSum -- This function compares the "Picture CheckSum"
  157. // 3 - 32-bit values.
  158. //*********************************************************************
  159. I32 H261ComparePictureCheckSum(
  160. YVUCheckSum * pYVUCheckSum1,
  161. YVUCheckSum * pYVUCheckSum2)
  162. {
  163. I32 iReturn = ICERR_ERROR;
  164. I16 iErrorFlag = 0;
  165. if (pYVUCheckSum1->uYCheckSum != pYVUCheckSum2->uYCheckSum)
  166. {
  167. DBOUT("Y CheckSum does not match");
  168. iErrorFlag = 1;
  169. // goto done;
  170. }
  171. if (pYVUCheckSum1->uVCheckSum != pYVUCheckSum2->uVCheckSum)
  172. {
  173. DBOUT("V CheckSum does not match");
  174. iErrorFlag = 1;
  175. // goto done;
  176. }
  177. if (pYVUCheckSum1->uUCheckSum != pYVUCheckSum2->uUCheckSum)
  178. {
  179. DBOUT("U CheckSum does not match");
  180. iErrorFlag = 1;
  181. // goto done;
  182. }
  183. /* if any or all planes had checksum errors, return ICERR_ERROR */
  184. if (iErrorFlag)
  185. iReturn = ICERR_ERROR;
  186. else iReturn = ICERR_OK;
  187. // done:
  188. return iReturn;
  189. }
  190. #endif