Esempio n. 1
0
ErrVal MbCoder::xWriteIntraPredModes( MbDataAccess& rcMbDataAccess )
{
  ROFRS( rcMbDataAccess.getMbData().isIntra(), Err::m_nOK );

  if( rcMbDataAccess.getMbData().isIntra4x4() )
  {
    if( rcMbDataAccess.getSH().getPPS().getTransform8x8ModeFlag() )
    {
      RNOK( m_pcMbSymbolWriteIf->transformSize8x8Flag( rcMbDataAccess ) );
    }

    if( rcMbDataAccess.getMbData().isTransformSize8x8() )
    {
      for( B8x8Idx cIdx; cIdx.isLegal(); cIdx++ )
      {
        RNOK( m_pcMbSymbolWriteIf->intraPredModeLuma( rcMbDataAccess, cIdx ) );
      }
    }
    else
    {
      for( S4x4Idx cIdx; cIdx.isLegal(); cIdx++ )
      {
        RNOK( m_pcMbSymbolWriteIf->intraPredModeLuma( rcMbDataAccess, cIdx ) );
      }
    }
  }

  if( rcMbDataAccess.getMbData().isIntra4x4() || rcMbDataAccess.getMbData().isIntra16x16() )
  {
    RNOK( m_pcMbSymbolWriteIf->intraPredModeChroma( rcMbDataAccess ) );
  }

  return Err::m_nOK;
}
Esempio n. 2
0
ErrVal MbDecoder::xDecodeMbIntraBL( MbDataAccess&     rcMbDataAccess,
                                    IntYuvPicBuffer*  pcRecYuvBuffer,
                                    IntYuvMbBuffer&   rcPredBuffer,
                                    IntYuvPicBuffer*  pcBaseYuvBuffer )
{
  IntYuvMbBuffer      cYuvMbBuffer;
  MbTransformCoeffs&  rcCoeffs = m_cTCoeffs;

  cYuvMbBuffer.loadBuffer ( pcBaseYuvBuffer );
  rcPredBuffer.loadLuma   ( cYuvMbBuffer );
  rcPredBuffer.loadChroma ( cYuvMbBuffer );

  if( rcMbDataAccess.getMbData().isTransformSize8x8() )
  {
    for( B8x8Idx cIdx; cIdx.isLegal(); cIdx++ )
    {
      if( rcMbDataAccess.getMbData().is4x4BlkCoded( cIdx ) )
      {
        RNOK( m_pcTransform->invTransform8x8Blk( cYuvMbBuffer.getYBlk( cIdx ),
                                                 cYuvMbBuffer.getLStride(),
                                                 rcCoeffs.get8x8(cIdx) ) );
      }
    }
  }
  else
  {
    for( B4x4Idx cIdx; cIdx.isLegal(); cIdx++ )
    {
      if( rcMbDataAccess.getMbData().is4x4BlkCoded( cIdx ) )
      {
        RNOK( m_pcTransform->invTransform4x4Blk( cYuvMbBuffer.getYBlk( cIdx ),
                                                 cYuvMbBuffer.getLStride(),
                                                 rcCoeffs.get(cIdx) ) );
      }
    }
  }

  UInt uiChromaCbp = rcMbDataAccess.getMbData().getCbpChroma4x4();
  RNOK( xDecodeChroma( rcMbDataAccess, cYuvMbBuffer, rcPredBuffer, uiChromaCbp, false ) );

  pcRecYuvBuffer->loadBuffer( &cYuvMbBuffer );

  return Err::m_nOK;
}
Esempio n. 3
0
ErrVal
MbParser::xReadIntraPredModes( MbDataAccess& rcMbDataAccess )
{
  ROFRS( rcMbDataAccess.getMbData().isIntra(), Err::m_nOK );

  if( rcMbDataAccess.getMbData().isIntra4x4() )
  {
    if( rcMbDataAccess.getSH().getPPS().getTransform8x8ModeFlag() )
    {
      DECRNOK( m_pcMbSymbolReadIf->transformSize8x8Flag( rcMbDataAccess ) );
    }

    if( rcMbDataAccess.getMbData().isTransformSize8x8() )
    {
      for( B8x8Idx cIdx; cIdx.isLegal(); cIdx++ )
      {
        DECRNOK( m_pcMbSymbolReadIf->intraPredModeLuma8x8( rcMbDataAccess, cIdx ) );
      }
    }
    else
    {
      for( S4x4Idx cIdx; cIdx.isLegal(); cIdx++ )
      {
        DECRNOK( m_pcMbSymbolReadIf->intraPredModeLuma( rcMbDataAccess, cIdx ) );
      }
    }
  }

  if( rcMbDataAccess.getMbData().isIntra4x4() || rcMbDataAccess.getMbData().isIntra16x16() )
  {
    if( rcMbDataAccess.getSH().getSPS().getChromaFormatIdc() )
    {
      DECRNOK( m_pcMbSymbolReadIf->intraPredModeChroma( rcMbDataAccess ) );
    }
    else
    {
      rcMbDataAccess.getMbData().setChromaPredMode( 0 ); // DC prediction
    }
  }

  return Err::m_nOK;
}
Esempio n. 4
0
ErrVal MbDecoder::xDecodeMbIntra8x8( MbDataAccess&   rcMbDataAccess,
                                     IntYuvMbBuffer& cYuvMbBuffer,
                                     IntYuvMbBuffer& rcPredBuffer )
{
  Int  iStride = cYuvMbBuffer.getLStride();

  MbTransformCoeffs& rcCoeffs = m_cTCoeffs;

  for( B8x8Idx cIdx; cIdx.isLegal(); cIdx++ )
  {
    {
      Int iPredMode = rcMbDataAccess.decodeIntraPredMode( cIdx );
      for( S4x4Idx cIdx4x4( cIdx ); cIdx4x4.isLegal( cIdx ); cIdx4x4++ )
      {
        rcMbDataAccess.getMbData().intraPredMode( cIdx4x4 ) = iPredMode;
      }
    }

    XPel* puc = cYuvMbBuffer.getYBlk( cIdx );

    const UInt uiPredMode = rcMbDataAccess.getMbData().intraPredMode( cIdx );

    RNOK( m_pcIntraPrediction->predictLuma8x8Block( puc, iStride, uiPredMode, cIdx ) );

    rcPredBuffer.loadLuma( cYuvMbBuffer, cIdx );

    if( rcMbDataAccess.getMbData().is4x4BlkCoded( cIdx ) )
    {
      RNOK( m_pcTransform->invTransform8x8Blk( puc, iStride, rcCoeffs.get8x8( cIdx ) ) );
    }

  }

  UInt uiChromaCbp = rcMbDataAccess.getMbData().getCbpChroma4x4();
  RNOK( xDecodeChroma( rcMbDataAccess, cYuvMbBuffer, rcPredBuffer, uiChromaCbp, true ) );

  return Err::m_nOK;
}
Esempio n. 5
0
ErrVal MbDecoder::xDecodeMbInter( MbDataAccess&     rcMbDataAccess,
                                  MbDataAccess*     pcMbDataAccessBase,
                                  IntYuvMbBuffer&   rcPredBuffer,
                                  IntYuvPicBuffer*  pcRecYuvBuffer,
                                  IntFrame*         pcResidual,
                                  IntFrame*         pcBaseResidual,
                                  RefFrameList&     rcRefFrameList0,
                                  RefFrameList&     rcRefFrameList1,
                                  Bool              bReconstruct )
{
  IntYuvMbBuffer      cYuvMbBuffer;         cYuvMbBuffer        .setAllSamplesToZero();
  IntYuvMbBuffer      cYuvMbBufferResidual; cYuvMbBufferResidual.setAllSamplesToZero();
  MbTransformCoeffs&  rcCoeffs        = m_cTCoeffs;
  Bool                bCalcMv         = false;
  Bool                bFaultTolerant  = true;

  //===== derive motion vectors =====
  calcMv( rcMbDataAccess, pcMbDataAccessBase );

  //===== get prediction signal when full reconstruction is requested =====
  if( bReconstruct )
  {
    if( rcMbDataAccess.getMbData().getMbMode() == MODE_8x8 || rcMbDataAccess.getMbData().getMbMode() == MODE_8x8ref0 )
    {
      for( B8x8Idx c8x8Idx; c8x8Idx.isLegal(); c8x8Idx++ )
      {
        //----- motion compensated prediction -----
        RNOK( m_pcMotionCompensation->compensateSubMb ( c8x8Idx,
                                                        rcMbDataAccess, rcRefFrameList0, rcRefFrameList1,
                                                        &cYuvMbBuffer, bCalcMv, bFaultTolerant ) );
      }
    }
    else
    {
      //----- motion compensated prediction -----
      RNOK(   m_pcMotionCompensation->compensateMb    ( rcMbDataAccess, 
                                                        rcRefFrameList0, 
                                                        rcRefFrameList1,
                                                        &cYuvMbBuffer, 
                                                        bCalcMv ) );
    }

    rcPredBuffer.loadLuma   ( cYuvMbBuffer );
    rcPredBuffer.loadChroma ( cYuvMbBuffer );
  }


  //===== reconstruct residual signal by using transform coefficients ======
  m_pcTransform->setClipMode( false );
  if( rcMbDataAccess.getMbData().isTransformSize8x8() )
  {
    for( B8x8Idx cIdx; cIdx.isLegal(); cIdx++ )
    {
      if( rcMbDataAccess.getMbData().is4x4BlkCoded( cIdx ) )
      {
        RNOK( m_pcTransform->invTransform8x8Blk( cYuvMbBufferResidual.getYBlk( cIdx ),
                                                 cYuvMbBufferResidual.getLStride(),
                                                 rcCoeffs.get8x8(cIdx) ) );
      }
    }
  }
  else
  {
    for( B4x4Idx cIdx; cIdx.isLegal(); cIdx++ )
    {
      if( rcMbDataAccess.getMbData().is4x4BlkCoded( cIdx ) )
      {
        RNOK( m_pcTransform->invTransform4x4Blk( cYuvMbBufferResidual.getYBlk( cIdx ),
                                                 cYuvMbBufferResidual.getLStride(),
                                                 rcCoeffs.get(cIdx) ) );
      }
    }
  }

  UInt uiChromaCbp = rcMbDataAccess.getMbData().getCbpChroma4x4();
  RNOK( xDecodeChroma( rcMbDataAccess, cYuvMbBufferResidual, rcPredBuffer, uiChromaCbp, false ) );
  m_pcTransform->setClipMode( true );


  //===== add base layer residual =====
  if( rcMbDataAccess.getMbData().getResidualPredFlag( PART_16x16 ) )
  {
    IntYuvMbBuffer cBaseLayerBuffer;
    cBaseLayerBuffer.loadBuffer( pcBaseResidual->getFullPelYuvBuffer() );

		//-- JVT-R091
		if ( bReconstruct && rcMbDataAccess.getMbData().getSmoothedRefFlag() )
		{
			IntYuvMbBuffer cMbBuffer;

			// obtain P
			cMbBuffer.loadLuma	( cYuvMbBuffer );
			cMbBuffer.loadChroma( cYuvMbBuffer );
			
			// P+Rb
			cMbBuffer.add( cBaseLayerBuffer );

			// S(P+Rb)
			pcRecYuvBuffer->loadBuffer( &cMbBuffer );
			pcRecYuvBuffer->smoothMbInside();
			if ( rcMbDataAccess.isAboveMbExisting() )
			{
				pcRecYuvBuffer->smoothMbTop();
			}
			if ( rcMbDataAccess.isLeftMbExisting() )
			{
				pcRecYuvBuffer->smoothMbLeft();
			}

			// store new prediction
			cYuvMbBuffer.loadBuffer	( pcRecYuvBuffer		);
			cYuvMbBuffer.subtract		( cBaseLayerBuffer	);

			// update rcPredBuffer
			rcPredBuffer.loadLuma   ( cYuvMbBuffer			);
			rcPredBuffer.loadChroma ( cYuvMbBuffer			);
		}
		//--

    cYuvMbBufferResidual.add( cBaseLayerBuffer );
    //--- set CBP ---
    rcMbDataAccess.getMbData().setMbExtCbp( rcMbDataAccess.getMbData().getMbExtCbp() | pcMbDataAccessBase->getMbData().getMbExtCbp() );
  }


  //===== reconstruct signal =====
  if( bReconstruct )
  {
    cYuvMbBuffer.add( cYuvMbBufferResidual );
    cYuvMbBuffer.clip();
  }


  //===== store reconstructed residual =====
  if( pcResidual )
  {
    RNOK( pcResidual->getFullPelYuvBuffer()->loadBuffer( &cYuvMbBufferResidual ) );
  }

  //===== store reconstructed signal =====
  if( pcRecYuvBuffer )
  {
    RNOK( pcRecYuvBuffer->loadBuffer( &cYuvMbBuffer ) );
  }

  return Err::m_nOK;
}
Esempio n. 6
0
ErrVal
ReconstructionBypass::xPadRecMb( YuvMbBufferExtension* pcBuffer, UInt uiMask )
{
  Bool bAboveIntra      = 0 != (uiMask & 0x01);
  Bool bBelowIntra      = 0 != (uiMask & 0x10);
  Bool bLeftIntra       = 0 != (uiMask & 0x40);
  Bool bRightIntra      = 0 != (uiMask & 0x04);
  Bool bLeftAboveIntra  = 0 != (uiMask & 0x80);
  Bool bRightAboveIntra = 0 != (uiMask & 0x02);
  Bool bLeftBelowIntra  = 0 != (uiMask & 0x20);
  Bool bRightBelowIntra = 0 != (uiMask & 0x08);

  for( B8x8Idx cIdx; cIdx.isLegal(); cIdx++ )
  {
    switch( cIdx.b8x8Index() )
    {
    case 0:
      {
        if( bAboveIntra )
        {
          if( bLeftIntra )
          {
            pcBuffer->mergeFromLeftAbove( cIdx, bLeftAboveIntra );
          }
          else
          {
            pcBuffer->copyFromAbove( cIdx );
          }
        }
        else
        {
          if( bLeftIntra )
          {
            pcBuffer->copyFromLeft( cIdx );
          }
          else if( bLeftAboveIntra )
          {
            pcBuffer->copyFromLeftAbove( cIdx );
          }
        }
      }
      break;
    case 1:
      {
        if( bAboveIntra )
        {
          if( bRightIntra )
          {
            pcBuffer->mergeFromRightAbove( cIdx, bRightAboveIntra );
          }
          else
          {
            pcBuffer->copyFromAbove( cIdx );
          }
        }
        else
        {
          if( bRightIntra )
          {
            pcBuffer->copyFromRight( cIdx );
          }
          else if( bRightAboveIntra )
          {
            pcBuffer->copyFromRightAbove( cIdx );
          }
        }
      }
      break;
    case 2:
      {
        if( bBelowIntra )
        {
          if( bLeftIntra )
          {
            pcBuffer->mergeFromLeftBelow( cIdx, bLeftBelowIntra );
          }
          else
          {
            pcBuffer->copyFromBelow( cIdx );
          }
        }
        else
        {
          if( bLeftIntra )
          {
            pcBuffer->copyFromLeft( cIdx );
          }
          else if( bLeftBelowIntra )
          {
            pcBuffer->copyFromLeftBelow( cIdx );
          }
        }
      }
      break;
    case 3:
      {
        if( bBelowIntra )
        {
          if( bRightIntra )
          {
            pcBuffer->mergeFromRightBelow( cIdx, bRightBelowIntra );
          }
          else
          {
            pcBuffer->copyFromBelow( cIdx );
          }
        }
        else
        {
          if( bRightIntra )
          {
            pcBuffer->copyFromRight( cIdx );
          }
          else if( bRightBelowIntra )
          {
            pcBuffer->copyFromRightBelow( cIdx );
          }
        }
      }
      break;
    default:
      break;
    }
  }

  return Err::m_nOK;
}