1
0

erc_api.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*!
  2. ************************************************************************
  3. * \file erc_api.h
  4. *
  5. * \brief
  6. * External (still inside video decoder) interface for error concealment module
  7. *
  8. * \author
  9. * - Ari Hourunranta <[email protected]>
  10. * - Ye-Kui Wang <[email protected]>
  11. * - Jill Boyce <[email protected]>
  12. * - Saurav K Bandyopadhyay <[email protected]>
  13. * - Zhenyu Wu <[email protected]
  14. * - Purvin Pandit <[email protected]>
  15. *
  16. * ************************************************************************
  17. */
  18. #ifndef _ERC_API_H_
  19. #define _ERC_API_H_
  20. #include "erc_globals.h"
  21. /*
  22. * Defines
  23. */
  24. /* If the average motion vector of the correctly received macroblocks is less than the
  25. threshold, concealByCopy is used, otherwise concealByTrial is used. */
  26. #define MVPERMB_THR 8
  27. /* used to determine the size of the allocated memory for a temporal Region (MB) */
  28. #define DEF_REGION_SIZE 384 /* 8*8*6 */
  29. #define ERC_BLOCK_OK 3
  30. #define ERC_BLOCK_CONCEALED 2
  31. #define ERC_BLOCK_CORRUPTED 1
  32. #define ERC_BLOCK_EMPTY 0
  33. /*
  34. * Functions to convert MBNum representation to blockNum
  35. */
  36. #define xPosYBlock(currYBlockNum,picSizeX) \
  37. ((currYBlockNum)%((picSizeX)>>3))
  38. #define yPosYBlock(currYBlockNum,picSizeX) \
  39. ((currYBlockNum)/((picSizeX)>>3))
  40. #define xPosMB(currMBNum,picSizeX) \
  41. ((currMBNum)%((picSizeX)>>4))
  42. #define yPosMB(currMBNum,picSizeX) \
  43. ((currMBNum)/((picSizeX)>>4))
  44. #define MBxy2YBlock(currXPos,currYPos,comp,picSizeX) \
  45. ((((currYPos)<<1)+((comp)>>1))*((picSizeX)>>3)+((currXPos)<<1)+((comp)&1))
  46. #define MBNum2YBlock(currMBNum,comp,picSizeX) \
  47. MBxy2YBlock(xPosMB((currMBNum),(picSizeX)),yPosMB((currMBNum),(picSizeX)),(comp),(picSizeX))
  48. /*
  49. * typedefs
  50. */
  51. /* segment data structure */
  52. typedef struct ercSegment_s
  53. {
  54. int startMBPos;
  55. int endMBPos;
  56. int fCorrupted;
  57. } ercSegment_t;
  58. /* Error detector & concealment instance data structure */
  59. typedef struct ercVariables_s
  60. {
  61. /* Number of macroblocks (size or size/4 of the arrays) */
  62. int nOfMBs;
  63. /* Number of segments (slices) in frame */
  64. int nOfSegments;
  65. /* Array for conditions of Y blocks */
  66. int *yCondition;
  67. /* Array for conditions of U blocks */
  68. int *uCondition;
  69. /* Array for conditions of V blocks */
  70. int *vCondition;
  71. /* Array for Slice level information */
  72. ercSegment_t *segments;
  73. int currSegment;
  74. /* Conditions of the MBs of the previous frame */
  75. int *prevFrameYCondition;
  76. /* Flag telling if the current segment was found to be corrupted */
  77. int currSegmentCorrupted;
  78. /* Counter for corrupted segments per picture */
  79. int nOfCorruptedSegments;
  80. /* State variables for error detector and concealer */
  81. int concealment;
  82. } ercVariables_t;
  83. /*
  84. * External function interface
  85. */
  86. void ercInit(VideoParameters *p_Vid, int pic_sizex, int pic_sizey, int flag);
  87. ercVariables_t *ercOpen( void );
  88. void ercReset( ercVariables_t *errorVar, int nOfMBs, int numOfSegments, int picSizeX );
  89. void ercClose( VideoParameters *p_Vid, ercVariables_t *errorVar );
  90. void ercSetErrorConcealment( ercVariables_t *errorVar, int value );
  91. void ercStartSegment( int currMBNum, int segment, unsigned int bitPos, ercVariables_t *errorVar );
  92. void ercStopSegment( int currMBNum, int segment, unsigned int bitPos, ercVariables_t *errorVar );
  93. void ercMarkCurrSegmentLost(int picSizeX, ercVariables_t *errorVar );
  94. void ercMarkCurrSegmentOK(int picSizeX, ercVariables_t *errorVar );
  95. void ercMarkCurrMBConcealed( int currMBNum, int comp, int picSizeX, ercVariables_t *errorVar );
  96. int ercConcealIntraFrame( VideoParameters *p_Vid, frame *recfr, int picSizeX, int picSizeY, ercVariables_t *errorVar );
  97. int ercConcealInterFrame( frame *recfr, objectBuffer_t *object_list,
  98. int picSizeX, int picSizeY, ercVariables_t *errorVar, int chroma_format_idc );
  99. /* Thomson APIs for concealing entire frame loss */
  100. #include "mbuffer.h"
  101. #include "output.h"
  102. struct concealment_node {
  103. StorablePicture* picture;
  104. int missingpocs;
  105. struct concealment_node *next;
  106. };
  107. extern struct concealment_node * init_node(StorablePicture* , int );
  108. extern void print_node( struct concealment_node * );
  109. extern void print_list( struct concealment_node * );
  110. extern void init_lists_for_non_reference_loss(VideoParameters *p_Vid, int , PictureStructure );
  111. extern void conceal_non_ref_pics(VideoParameters *p_Vid, int diff);
  112. extern void conceal_lost_frames(VideoParameters *p_Vid);
  113. extern void sliding_window_poc_management(DecodedPictureBuffer *p_Dpb, StorablePicture *p);
  114. extern void write_lost_non_ref_pic(VideoParameters *p_Vid, int poc);
  115. extern void write_lost_ref_after_idr(VideoParameters *p_Vid, int pos);
  116. extern int comp(const void *, const void *);
  117. #endif