1
0

errorconcealment.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*!
  2. ***********************************************************************
  3. * \file errorconcealment.c
  4. *
  5. * \brief
  6. * Implements error concealment scheme for H.264 decoder
  7. *
  8. * \date
  9. * 6.10.2000
  10. *
  11. * \version
  12. * 1.0
  13. *
  14. * \note
  15. * This simple error concealment implemented in this decoder uses
  16. * the existing dependencies of syntax elements.
  17. * In case that an element is detected as false this elements and all
  18. * dependend elements are marked as elements to conceal in the p_Vid->ec_flag[]
  19. * array. If the decoder requests a new element by the function
  20. * readSyntaxElement_xxxx() this array is checked first if an error concealment has
  21. * to be applied on this element.
  22. * In case that an error occured a concealed element is given to the
  23. * decoding function in macroblock().
  24. *
  25. * \author
  26. * Main contributors (see contributors.h for copyright, address and affiliation details)
  27. * - Sebastian Purreiter <[email protected]>
  28. ***********************************************************************
  29. */
  30. #include "contributors.h"
  31. #include "global.h"
  32. #include "elements.h"
  33. /*!
  34. ***********************************************************************
  35. * \brief
  36. * set concealment for all elements in same partition
  37. * and dependend syntax elements
  38. * \param p_Vid
  39. * image encoding parameters for current picture
  40. * \param se
  41. * type of syntax element to conceal
  42. * \return
  43. * EC_REQ, elements of same type or depending type need error concealment. \n
  44. * EX_SYNC sync on next header
  45. ***********************************************************************
  46. */
  47. int set_ec_flag(VideoParameters *p_Vid, int se)
  48. {
  49. /*
  50. if (p_Vid->ec_flag[se] == NO_EC)
  51. printf("Error concealment on element %s\n",SEtypes[se]);
  52. */
  53. switch (se)
  54. {
  55. case SE_HEADER :
  56. p_Vid->ec_flag[SE_HEADER] = EC_REQ;
  57. case SE_PTYPE :
  58. p_Vid->ec_flag[SE_PTYPE] = EC_REQ;
  59. case SE_MBTYPE :
  60. p_Vid->ec_flag[SE_MBTYPE] = EC_REQ;
  61. case SE_REFFRAME :
  62. p_Vid->ec_flag[SE_REFFRAME] = EC_REQ;
  63. p_Vid->ec_flag[SE_MVD] = EC_REQ; // set all motion vectors to zero length
  64. se = SE_CBP_INTER; // conceal also Inter texture elements
  65. break;
  66. case SE_INTRAPREDMODE :
  67. p_Vid->ec_flag[SE_INTRAPREDMODE] = EC_REQ;
  68. se = SE_CBP_INTRA; // conceal also Intra texture elements
  69. break;
  70. case SE_MVD :
  71. p_Vid->ec_flag[SE_MVD] = EC_REQ;
  72. se = SE_CBP_INTER; // conceal also Inter texture elements
  73. break;
  74. default:
  75. break;
  76. }
  77. switch (se)
  78. {
  79. case SE_CBP_INTRA :
  80. p_Vid->ec_flag[SE_CBP_INTRA] = EC_REQ;
  81. case SE_LUM_DC_INTRA :
  82. p_Vid->ec_flag[SE_LUM_DC_INTRA] = EC_REQ;
  83. case SE_CHR_DC_INTRA :
  84. p_Vid->ec_flag[SE_CHR_DC_INTRA] = EC_REQ;
  85. case SE_LUM_AC_INTRA :
  86. p_Vid->ec_flag[SE_LUM_AC_INTRA] = EC_REQ;
  87. case SE_CHR_AC_INTRA :
  88. p_Vid->ec_flag[SE_CHR_AC_INTRA] = EC_REQ;
  89. break;
  90. case SE_CBP_INTER :
  91. p_Vid->ec_flag[SE_CBP_INTER] = EC_REQ;
  92. case SE_LUM_DC_INTER :
  93. p_Vid->ec_flag[SE_LUM_DC_INTER] = EC_REQ;
  94. case SE_CHR_DC_INTER :
  95. p_Vid->ec_flag[SE_CHR_DC_INTER] = EC_REQ;
  96. case SE_LUM_AC_INTER :
  97. p_Vid->ec_flag[SE_LUM_AC_INTER] = EC_REQ;
  98. case SE_CHR_AC_INTER :
  99. p_Vid->ec_flag[SE_CHR_AC_INTER] = EC_REQ;
  100. break;
  101. case SE_DELTA_QUANT_INTER :
  102. p_Vid->ec_flag[SE_DELTA_QUANT_INTER] = EC_REQ;
  103. break;
  104. case SE_DELTA_QUANT_INTRA :
  105. p_Vid->ec_flag[SE_DELTA_QUANT_INTRA] = EC_REQ;
  106. break;
  107. default:
  108. break;
  109. }
  110. return EC_REQ;
  111. }
  112. /*!
  113. ***********************************************************************
  114. * \brief
  115. * resets EC_Flags called at the start of each slice
  116. *
  117. ***********************************************************************
  118. */
  119. void reset_ec_flags(VideoParameters *p_Vid)
  120. {
  121. int i;
  122. for (i=0; i<SE_MAX_ELEMENTS; i++)
  123. p_Vid->ec_flag[i] = NO_EC;
  124. }