mp4dechwd_error_conceal.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /*------------------------------------------------------------------------------
  2. -- --
  3. -- This software is confidential and proprietary and may be used --
  4. -- only as expressly authorized by a licensing agreement from --
  5. -- --
  6. -- Hantro Products Oy. --
  7. -- --
  8. -- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
  9. -- ALL RIGHTS RESERVED --
  10. -- --
  11. -- The entire notice above must be reproduced --
  12. -- on all copies and should not be removed. --
  13. -- --
  14. --------------------------------------------------------------------------------
  15. --
  16. -- Abstract : error concealment
  17. --
  18. --------------------------------------------------------------------------------
  19. --
  20. -- Version control information, please leave untouched.
  21. --
  22. -- $RCSfile: mp4dechwd_error_conceal.c,v $
  23. -- $Date: 2007/11/26 09:57:02 $
  24. -- $Revision: 1.3 $
  25. --
  26. ------------------------------------------------------------------------------*/
  27. /*------------------------------------------------------------------------------
  28. Table of context
  29. 1. Include headers
  30. 2. External identifiers
  31. 3. Module defines
  32. 4. Module identifiers
  33. 5. Fuctions
  34. ------------------------------------------------------------------------------*/
  35. /*------------------------------------------------------------------------------
  36. 1. Include headers
  37. ------------------------------------------------------------------------------*/
  38. #include "mp4dechwd_container.h"
  39. #include "mp4dechwd_error_conceal.h"
  40. #include "mp4dechwd_utils.h"
  41. #include "mp4debug.h"
  42. /*------------------------------------------------------------------------------
  43. 2. External identifiers
  44. ------------------------------------------------------------------------------*/
  45. /*------------------------------------------------------------------------------
  46. 3. Module defines
  47. ------------------------------------------------------------------------------*/
  48. enum
  49. {
  50. MASK_BIT0 = 0x1,
  51. MASK_BIT1 = 0x2
  52. };
  53. enum
  54. {
  55. EC_ABOVE,
  56. EC_ABOVELEFT,
  57. EC_ABOVERIGHT,
  58. EC_NOCANDO
  59. };
  60. /*------------------------------------------------------------------------------
  61. 4. Module indentifiers
  62. ------------------------------------------------------------------------------*/
  63. static void PConcealment(DecContainer * pDecCont, u32 mbNumber);
  64. static void IConcealment(DecContainer * pDecCont, u32 mbNumber);
  65. static void ITextureConcealment(DecContainer * pDecCont, u32 mbNumber);
  66. static void MotionVectorConcealment(DecContainer *, u32);
  67. /*------------------------------------------------------------------------------
  68. 5.1 Function name: StrmDec_ErrorConcealment
  69. Purpose:
  70. Input:
  71. Output:
  72. ------------------------------------------------------------------------------*/
  73. u32 StrmDec_ErrorConcealment(DecContainer * pDecContainer, u32 start,
  74. u32 end)
  75. {
  76. extern const u8 asicPosNoRlc[6];
  77. u32 i, j;
  78. u32 vopCodingType = 0;
  79. u32 controlBits = 0;
  80. u32 *pCtrl;
  81. ASSERT(end <= pDecContainer->VopDesc.totalMbInVop);
  82. ASSERT(start <= end);
  83. MP4DEC_API_DEBUG(("ErrorConcealment # %d end \n", end));
  84. vopCodingType = pDecContainer->VopDesc.vopCodingType;
  85. /* qp to control word */
  86. controlBits = (u32) (31 & 0x1F) << ASICPOS_QP;
  87. /* set block type to inter */
  88. controlBits |= ((u32) 1 << ASICPOS_MBTYPE);
  89. controlBits |= ((u32) 1 << ASICPOS_CONCEAL);
  90. controlBits |= ((u32) 1 << ASICPOS_MBNOTCODED);
  91. for(j = 0; j < 6; j++)
  92. {
  93. controlBits |= (1 << asicPosNoRlc[j]);
  94. }
  95. for(i = start; i <= end; i++)
  96. {
  97. /* pointer to control */
  98. pCtrl = pDecContainer->MbSetDesc.pCtrlDataAddr + i * NBR_OF_WORDS_MB;
  99. /* video package boundary */
  100. if((i == pDecContainer->StrmStorage.vpMbNumber) &&
  101. (pDecContainer->StrmStorage.shortVideo == HANTRO_FALSE))
  102. {
  103. controlBits |= (1 << ASICPOS_VPBI);
  104. }
  105. /* write control bits */
  106. *pCtrl = controlBits;
  107. if( ( (vopCodingType == PVOP) ||
  108. (pDecContainer->StrmStorage.validVopHeader == HANTRO_FALSE) ) &&
  109. pDecContainer->VopDesc.vopNumber)
  110. {
  111. PConcealment(pDecContainer, i);
  112. }
  113. else if(vopCodingType == IVOP)
  114. {
  115. IConcealment(pDecContainer, i);
  116. ITextureConcealment(pDecContainer, i);
  117. }
  118. }
  119. /* update number of concealed blocks */
  120. pDecContainer->StrmStorage.numErrMbs += end - start + 1;
  121. return (EC_OK);
  122. }
  123. /*------------------------------------------------------------------------------
  124. 5.2 Function name:PConcealment
  125. Purpose:
  126. Input:
  127. Output:
  128. ------------------------------------------------------------------------------*/
  129. static void PConcealment(DecContainer * pDecContainer, u32 mbNumber)
  130. {
  131. MotionVectorConcealment(pDecContainer, mbNumber);
  132. pDecContainer->MBDesc[mbNumber].errorStatus |= 0x80;
  133. pDecContainer->MBDesc[mbNumber].typeOfMB = MB_INTER;
  134. }
  135. /*------------------------------------------------------------------------------
  136. 5.4 Function name:IConcealment;
  137. Purpose:
  138. Input:
  139. Output:
  140. ------------------------------------------------------------------------------*/
  141. static void IConcealment(DecContainer * pDecContainer, u32 mbNumber)
  142. {
  143. pDecContainer->MBDesc[mbNumber].errorStatus |= 0x80;
  144. pDecContainer->MBDesc[mbNumber].typeOfMB = MB_INTRA;
  145. }
  146. /*------------------------------------------------------------------------------
  147. 5.5 Function name: ITextureConcealment
  148. Purpose: i-vop texture concealment
  149. Input:
  150. Output:
  151. ------------------------------------------------------------------------------*/
  152. static void ITextureConcealment(DecContainer * pDecContainer, u32 mbNumber)
  153. {
  154. u32 *pCtrl;
  155. u32 tmp = 0;
  156. /* pointer to last word of control bits of first block */
  157. pCtrl = pDecContainer->MbSetDesc.pCtrlDataAddr + mbNumber * NBR_OF_WORDS_MB;
  158. tmp = (((u32) 1 << ASICPOS_ACPREDFLAG) | ((u32) 1 << ASICPOS_MBTYPE));
  159. *pCtrl &= ~(tmp);
  160. pDecContainer->MBDesc[mbNumber].errorStatus |= 0x80;
  161. }
  162. /*------------------------------------------------------------------------------
  163. 5.6 Function name: MotionVectorConcealment
  164. Purpose:
  165. Input:
  166. Output:
  167. ------------------------------------------------------------------------------*/
  168. static void MotionVectorConcealment(DecContainer * pDecContainer,
  169. u32 mbNumber)
  170. {
  171. *(pDecContainer->MbSetDesc.pMvDataAddr + mbNumber*NBR_MV_WORDS_MB) = 0;
  172. *(pDecContainer->MbSetDesc.pMvDataAddr + mbNumber*NBR_MV_WORDS_MB + 1) = 0;
  173. *(pDecContainer->MbSetDesc.pMvDataAddr + mbNumber*NBR_MV_WORDS_MB + 2) = 0;
  174. *(pDecContainer->MbSetDesc.pMvDataAddr + mbNumber*NBR_MV_WORDS_MB + 3) = 0;
  175. }