示例#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       :     UpRegulateBlocks
 *
 *  INPUTS        :     UINT32 Q 
 *						(Q at which to up regulate and target number of blocks)
 *
 *                      UINT32 RecoveryBlocks
 *						(Limit on total number of blocks for this frame)
 *
 *                      UINT32 LastSB, LastMB
 *                      (Where we had got up to in SB) and MB
 *
 *  OUTPUTS       :     None.
 *
 *  RETURNS       :     None.
 *
 *  FUNCTION      :     See if we can add some blocks.
 *
 *  SPECIAL NOTES :     None. 
 *
 *
 *  ERRORS        :     None.
 *
 ****************************************************************************/
void UpRegulateBlocks( CP_INSTANCE *cpi, UINT32 RegulationQ, INT32 RecoveryBlocks, 
					   UINT32 * LastSB, UINT32 * LastMB ) 
{
    UINT32 LoopTimesRound = 0;
	UINT32 MaxSB = cpi->pb.YSBRows * cpi->pb.YSBCols;   // Tot super blocks in image
	UINT32 SB, MB;						// Super-Block and macro block indices.

	// First scan for blocks for which a residue update is outstanding.
	while ( (cpi->MotionScore < RecoveryBlocks) && 
		    (LoopTimesRound < MAX_UP_REG_LOOPS) )
	{
		LoopTimesRound++;

		for ( SB = (*LastSB); SB < MaxSB; SB++ )
		{
			// Check its four Macro-Blocks
			for ( MB=(*LastMB); MB<4; MB++ )
			{
				// Mark relevant blocks for update
				UpRegulateMB( cpi, RegulationQ, SB, MB, FALSE );

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

				// Termination clause
				if (cpi->MotionScore >= RecoveryBlocks)
                {
                    // Make sure we don't stall at SB level
                    if ( *LastMB == 0 )
                        SB++;
					break;
                }
			}

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

		// Update super block start index 
		if ( SB >= MaxSB)
		{
		  	(*LastSB) = 0;
		}
		else
		{
		  	(*LastSB) = SB;
		}
	}
}
示例#3
0
static void UpRegulateBlocks (CP_INSTANCE *cpi, ogg_uint32_t RegulationQ,
                       ogg_int32_t RecoveryBlocks,
                       ogg_uint32_t * LastSB, ogg_uint32_t * LastMB ) {

  ogg_uint32_t LoopTimesRound = 0;
  ogg_uint32_t MaxSB = cpi->pb.YSBRows *
    cpi->pb.YSBCols;   /* Tot super blocks in image */
  ogg_uint32_t SB, MB; /* Super-Block and macro block indices. */

  /* First scan for blocks for which a residue update is outstanding. */
  while ( (cpi->MotionScore < RecoveryBlocks) &&
          (LoopTimesRound < MAX_UP_REG_LOOPS) ) {
    LoopTimesRound++;

    for ( SB = (*LastSB); SB < MaxSB; SB++ ) {
      /* Check its four Macro-Blocks */
      for ( MB=(*LastMB); MB<4; MB++ ) {
        /* Mark relevant blocks for update */
        UpRegulateMB( cpi, RegulationQ, SB, MB, 0 );

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

        /* Termination clause */
        if (cpi->MotionScore >= RecoveryBlocks) {
          /* Make sure we don't stall at SB level */
          if ( *LastMB == 0 )
            SB++;
          break;
        }
      }

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

    /* Update super block start index  */
    if ( SB >= MaxSB){
      (*LastSB) = 0;
    }else{
      (*LastSB) = SB;
    }
  }
}
示例#4
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;

			}
		}
    }
}