예제 #1
0
void UpRegulateDataStream (CP_INSTANCE *cpi, ogg_uint32_t RegulationQ,
                           ogg_int32_t RecoveryBlocks ) {
  ogg_uint32_t LastPassMBPos = 0;
  ogg_uint32_t StdLastMBPos = 0;

  ogg_uint32_t MaxSB = cpi->pb.YSBRows *
    cpi->pb.YSBCols;    /* Tot super blocks in image */

  ogg_uint32_t SB=0;    /* Super-Block index */
  ogg_uint32_t MB;      /* Macro-Block index */

  /* Decduct the number of blocks in an MB / 2 from the recover block count.
     This will compensate for the fact that once we start checking an MB
     we test every block in that macro block */
  if ( RecoveryBlocks > 3 )
    RecoveryBlocks -= 3;

  /* Up regulate blocks last coded at higher Q */
  UpRegulateBlocks( cpi, RegulationQ, RecoveryBlocks,
                    &cpi->LastEndSB, &StdLastMBPos );

  /* If we have still not used up the minimum number of blocks and are
     at the minimum Q then run through a final pass of the data to
     insure that each block gets a final refresh. */
  if ( (RegulationQ == VERY_BEST_Q) &&
       (cpi->MotionScore < RecoveryBlocks) ) {
    if ( cpi->FinalPassLastPos < MaxSB ) {
      for ( SB = cpi->FinalPassLastPos; SB < MaxSB; SB++ ) {
        /* Check its four Macro-Blocks */
        for ( MB=LastPassMBPos; MB<4; MB++ ) {
          /* Mark relevant blocks for update */
          UpRegulateMB( cpi, RegulationQ, SB, MB, 1 );

          /* Keep track of the last refresh MB. */
          LastPassMBPos += 1;
          if ( LastPassMBPos == 4 ) {
            LastPassMBPos = 0;

            /* Increment SB index */
            cpi->FinalPassLastPos += 1;
          }

          /* Termination clause */
          if (cpi->MotionScore >= RecoveryBlocks)
            break;
        }

        /* Termination clause */
        if (cpi->MotionScore >= RecoveryBlocks)
          break;

      }
    }
  }
}
예제 #2
0
/****************************************************************************
 * 
 *  ROUTINE       :     UpRegulateDataStream
 *
 *  INPUTS        :     Q at which to up regulate and target number of blocks
 *
 *  OUTPUTS       :     None.
 *
 *  RETURNS       :     None.
 *
 *  FUNCTION      :     This function uses up spare bandwidth when not much is going
 *                      on to refresh quality.
 *
 *  SPECIAL NOTES :     None. 
 *
 *
 *  ERRORS        :     None.
 *
 ****************************************************************************/
void UpRegulateDataStream( CP_INSTANCE *cpi, UINT32 RegulationQ, INT32 RecoveryBlocks ) 
{  
	UINT32 LastPassMBPos = 0;		// MB index used in final pass of refresh.
	UINT32 StdLastMBPos = 0;			// MB index used in std refresh.
    
	UINT32 i =	0;   
    UINT32 LoopTimesRound = 0;

	UINT32 MaxSB = cpi->pb.YSBRows * cpi->pb.YSBCols;       // Tot super blocks in image

	UINT32 SB=0;							// Super-Block index
	UINT32 MB;								// Macro-Block index

	// Decduct the number of blocks in an MB / 2 from the recover block count.
	// This will compensate for the fact that once we start checking an MB
	// we test every block in that macro block
	if ( RecoveryBlocks > 3 )
	{
		RecoveryBlocks -= 3;
	}

	// Up regulate blocks last coded at higher Q
	UpRegulateBlocks( cpi, RegulationQ, RecoveryBlocks, &cpi->LastEndSB, &StdLastMBPos );

    // If we have still not used up the minimum number of blocks
    // and are at the minimum Q then run through a final pass of 
    // the data to insure that each block gets a final refresh.
    if ( (RegulationQ == VERY_BEST_Q) &&
		 (cpi->MotionScore < RecoveryBlocks) )
    {
		if ( cpi->FinalPassLastPos < MaxSB )
		{
			for ( SB = cpi->FinalPassLastPos; SB < MaxSB; SB++ )
			{
				// Check its four Macro-Blocks
				for ( MB=LastPassMBPos; MB<4; MB++ )
				{
					// Mark relevant blocks for update
					UpRegulateMB( cpi, RegulationQ, SB, MB, TRUE );

					// Keep track of the last refresh MB.
					LastPassMBPos += 1;
					if ( LastPassMBPos == 4 )
                    {
						LastPassMBPos = 0;

				        // Increment SB index
				        cpi->FinalPassLastPos += 1;
                    }

					// Termination clause
					if (cpi->MotionScore >= RecoveryBlocks)
						break;
				}

				// Termination clause
				if (cpi->MotionScore >= RecoveryBlocks)
					break;

			}
		}
    }
}