⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 erc_api.c

📁 本源码是H.26L标准的Visual C++源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
 *      Variables for error concealment
 * \param value
 *      New value
 ************************************************************************
 */
void ercSetErrorConcealment( ercVariables_t *errorVar, int value )
{
  if ( errorVar != NULL )
    errorVar->concealment = value;
}

/*!
 ************************************************************************
 * \brief
 *      Creates a new segment in the segment-list, and marks the start MB and bit position.
 *      If the end of the previous segment was not explicitly marked by "ercStopSegment",
 *      also marks the end of the previous segment.
 *      If needed, it reallocates the segment-list for a larger storage place.
 * \param currMBNum
 *      The MB number where the new slice/segment starts
 * \param segment
 *      Segment/Slice No. counted by the caller
 * \param bitPos
 *      Bitstream pointer: number of bits read from the buffer.
 * \param errorVar
 *      Variables for error detector
 ************************************************************************
 */
void ercStartSegment( int currMBNum, int segment, u_int32 bitPos, ercVariables_t *errorVar )
{
  if ( errorVar && errorVar->concealment ) 
  {
    errorVar->currSegmentCorrupted = 0;
    if ( segment < 0 )
      segment = errorVar->currSegment;
    
    if ( segment >= errorVar->nOfSegments ) 
    {
      errorVar->segments = (ercSegment_t *) realloc(errorVar->segments,2*errorVar->nOfSegments*sizeof(ercSegment_t));
      errorVar->nOfSegments *= 2;
    }
    
    errorVar->segments[ segment ].fCorrupted = 0;
    errorVar->segments[ segment ].startBitPos = bitPos;
    errorVar->segments[ segment ].startMBPos = currMBNum;
    
    if ( segment > 0 ) 
    {
      if ( errorVar->segments[ segment-1 ].endBitPos == 0 ) 
      {
        errorVar->segments[ segment-1 ].endBitPos = bitPos;
        errorVar->segments[ segment-1 ].endMBPos = currMBNum - 1;
      }
    }//if ( segment > 0 ) 
  }   
}

/*!
 ************************************************************************
 * \brief
 *      Marks the end position of a segment.
 * \param currMBNum
 *      The last MB number of the previous segment
 * \param segment
 *      Segment/Slice No. counted by the caller
 *      If (segment<0) the internal segment counter is used.
 * \param bitPos
 *      Bitstream pointer: number of bits read from the buffer.
 * \param errorVar
 *      Variables for error detector
 ************************************************************************
 */
void ercStopSegment( int currMBNum, int segment, u_int32 bitPos, ercVariables_t *errorVar )
{
  if ( errorVar && errorVar->concealment ) 
  {
    if ( segment < 0 )
      segment = errorVar->currSegment;
    
    if ( segment > errorVar->nOfSegments ) 
    {
      return;
    }
    
    errorVar->segments[ segment ].endBitPos = bitPos;
    errorVar->segments[ segment ].endMBPos = currMBNum; //! Changed TO 12.11.2001
    errorVar->currSegment++;
  }
}

/*!
 ************************************************************************
 * \brief
 *      Marks the current segment (the one which has the "currMBNum" MB in it)
 *      as lost: all the blocks of the MBs in the segment as corrupted.
 * \param currMBNum
 *      Selects the segment where this MB number is in.
 * \param picSizeX
 *      Width of the frame in pixels.
 * \param errorVar
 *      Variables for error detector
 ************************************************************************
 */
void ercMarkCurrSegmentLost( int currMBNum, int32 picSizeX, ercVariables_t *errorVar )
{
  int i = 0, j = 0;
  
  if ( errorVar && errorVar->concealment ) 
  {
    if (errorVar->currSegmentCorrupted == 0) 
    {
      errorVar->nOfCorruptedSegments++;
      errorVar->currSegmentCorrupted = 1;
    }
     
    for ( i = 0; i < errorVar->nOfSegments; i++ ) 
    {
      if ( currMBNum >= errorVar->segments[i].startMBPos && ( currMBNum <= errorVar->segments[i].endMBPos || errorVar->segments[i].endMBPos == 0 ) ) 
      {
        /* mark all the Blocks belonging to the lost segment as corrupted */
        for ( j = errorVar->segments[i].startMBPos; j <= errorVar->segments[i].endMBPos; j++ ) 
        {
          errorVar->yCondition[MBNum2YBlock (j, 0, picSizeX)] = ERC_BLOCK_CORRUPTED;
          errorVar->yCondition[MBNum2YBlock (j, 1, picSizeX)] = ERC_BLOCK_CORRUPTED;
          errorVar->yCondition[MBNum2YBlock (j, 2, picSizeX)] = ERC_BLOCK_CORRUPTED;
          errorVar->yCondition[MBNum2YBlock (j, 3, picSizeX)] = ERC_BLOCK_CORRUPTED;
          errorVar->uCondition[j] = ERC_BLOCK_CORRUPTED;
          errorVar->vCondition[j] = ERC_BLOCK_CORRUPTED;
        }
        errorVar->segments[i].fCorrupted = 1;
        break;
      }
    }
  }
}

/*!
 ************************************************************************
 * \brief
 *      Marks the current segment (the one which has the "currMBNum" MB in it)
 *      as OK: all the blocks of the MBs in the segment as OK.
 * \param currMBNum
 *      Selects the segment where this MB number is in.
 * \param picSizeX
 *      Width of the frame in pixels.
 * \param errorVar
 *      Variables for error detector
 ************************************************************************
 */
void ercMarkCurrSegmentOK( int currMBNum, int32 picSizeX, ercVariables_t *errorVar )
{
  int i = 0, j = 0;
  
  if ( errorVar && errorVar->concealment ) 
  {
    for ( i = 0; i < errorVar->nOfSegments; i++ ) 
    {
      if ( currMBNum >= errorVar->segments[i].startMBPos && ( currMBNum <= errorVar->segments[i].endMBPos || errorVar->segments[i].endMBPos == 0 ) ) 
      {
        /* mark all the Blocks belonging to the segment as OK */
        for ( j = errorVar->segments[i].startMBPos; j <= errorVar->segments[i].endMBPos; j++ ) 
        {
          errorVar->yCondition[MBNum2YBlock (j, 0, picSizeX)] = ERC_BLOCK_OK;
          errorVar->yCondition[MBNum2YBlock (j, 1, picSizeX)] = ERC_BLOCK_OK;
          errorVar->yCondition[MBNum2YBlock (j, 2, picSizeX)] = ERC_BLOCK_OK;
          errorVar->yCondition[MBNum2YBlock (j, 3, picSizeX)] = ERC_BLOCK_OK;
          errorVar->uCondition[j] = ERC_BLOCK_OK;
          errorVar->vCondition[j] = ERC_BLOCK_OK;
        }
        errorVar->segments[i].fCorrupted = 0;
        break;
      }
    }
  }
}

/*!
 ************************************************************************
 * \brief
 *      Marks the Blocks of the given component (YUV) of the current MB as concealed.
 * \param currMBNum
 *      Selects the segment where this MB number is in.
 * \param comp
 *      Component to mark (0:Y, 1:U, 2:V, <0:All)
 * \param picSizeX
 *      Width of the frame in pixels.
 * \param errorVar
 *      Variables for error detector
 ************************************************************************
 */
void ercMarkCurrMBConcealed( int currMBNum, int comp, int32 picSizeX, ercVariables_t *errorVar )
{
  int setAll = 0;
  
  if ( errorVar && errorVar->concealment ) 
  {
    if (comp < 0) 
    {
      setAll = 1;
      comp = 0;
    }
    
    switch (comp) 
    {
    case 0:
      errorVar->yCondition[MBNum2YBlock (currMBNum, 0, picSizeX)] = ERC_BLOCK_CONCEALED;
      errorVar->yCondition[MBNum2YBlock (currMBNum, 1, picSizeX)] = ERC_BLOCK_CONCEALED;
      errorVar->yCondition[MBNum2YBlock (currMBNum, 2, picSizeX)] = ERC_BLOCK_CONCEALED;
      errorVar->yCondition[MBNum2YBlock (currMBNum, 3, picSizeX)] = ERC_BLOCK_CONCEALED;
      if (!setAll)
        break;
    case 1:
      errorVar->uCondition[currMBNum] = ERC_BLOCK_CONCEALED;
      if (!setAll)
        break;
    case 2:
      errorVar->vCondition[currMBNum] = ERC_BLOCK_CONCEALED;
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -