erc_api.h
上传用户:hjq518
上传日期:2021-12-09
资源大小:5084k
文件大小:5k
源码类别:

Audio

开发平台:

Visual C++

  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                <ari.hourunranta@nokia.com>
  10.  *      - Ye-Kui Wang                    <wyk@ieee.org>
  11.  *      - Jill Boyce                     <jill.boyce@thomson.net>
  12.  *      - Saurav K Bandyopadhyay         <saurav@ieee.org>
  13.  *      - Zhenyu Wu                      <Zhenyu.Wu@thomson.net
  14.  *      - Purvin Pandit                  <Purvin.Pandit@thomson.net>
  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(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( 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( 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. struct concealment_node * init_node(StorablePicture* , int );
  108. void print_node( struct concealment_node * );
  109. void print_list( struct concealment_node * );
  110. void add_node( struct concealment_node * );
  111. void delete_node( struct concealment_node * );
  112. void init_lists_for_non_reference_loss(int , PictureStructure );
  113. void conceal_non_ref_pics(int diff);
  114. void conceal_lost_frames(ImageParameters *img);
  115. void sliding_window_poc_management(StorablePicture *p);
  116. void write_lost_non_ref_pic(int poc, int p_out);
  117. void write_lost_ref_after_idr(int pos);
  118. FrameStore *last_out_fs;
  119. int pocs_in_dpb[100];
  120. int comp(const void *, const void *);
  121. #endif