/**
    \fn getNextFrame
*/
bool Telecide::getNextFrame(uint32_t *frameNumber,ADMImage *output_image)
{
uint32_t pframe,nframe;

ADMImage *fc=NULL;
ADMImage *fp=NULL;
ADMImage *fn=NULL;
ADMImage *dst=NULL;
uint8_t *dstp;

ADMImage *final=NULL;
uint8_t *finalp;

unsigned int lowest;
unsigned int predicted;
unsigned int predicted_metric;
teleCide *_param=&configuration;


        *frameNumber=nextFrame;
        bool lastFrame=false;
        aprintf("telecide : frame %d\n",(int)nextFrame);
        // Get the current frame.
        uint32_t frame=nextFrame;
        if (frame < 0) frame = 0;
        
        GETFRAME(frame, fc);
        if(!fc)
        {
            ADM_warning("Telecide:Cannot get frame\n");
            vidCache->unlockAll();
            return false;
        }
        nextFrame++;
        output_image->copyInfo(fc); // copy timing information...

        // Get the previous frame.
        pframe = frame == 0 ? 0 : frame - 1;
        GETFRAME(pframe, fp);

        // Get the next frame metrics, we might need them.        
        nframe = frame + 1;
        GETFRAME(nframe, fn);
        if(!fn)
        {
            nframe=frame;
            GETFRAME(nframe, fn);
            ADM_assert(fn);
            lastFrame=true;
        }

        int pitch = fc->GetPitch(PLANAR_Y);
        
        
        int w = info.width;
        int h = info.height; 
        int hover2 = h >>1;
        int wover2 = w >>1;

        dst=output_image;
        int dpitch = dst->GetPitch(PLANAR_Y);

        // Ensure that the metrics for the frames
        // after the current frame are in the cache. They will be used for
        // pattern guidance.
        if (guide != GUIDE_NONE)
        {
                aprintf("Loop starting at %d +1, cycle=%d\n",frame,cycle);
                for (int y = frame + 1; y <= frame + cycle + 1; y++)
                {
                        if (lastFrame==true ) break;
                        if (CacheQuery(y, &p, &pblock, &c, &cblock) == false)
                        {
                                ADMImage *lc,*lp;

                                GETFRAME(y, lc);
                                GETFRAME(y == 0 ? 1 : y - 1, lp);
                                if(lc && lp)
                                    CalculateMetrics(y, lc,lp); //crp, crpU, crpV, prp, prpU, prpV);
                        }
                }
        }

        /* Check for manual overrides of the field matching. */
        
        found = false;
        film = true;
        
        inpattern = false;
        vthresh = vthresh_saved;
        back = back_saved;
        // Get the metrics for the current-previous (p), current-current (c), and current-next (n) match candidates.
        if (CacheQuery(frame, &p, &pblock, &c, &cblock) == false)
        {
                CalculateMetrics(frame, fc, fp); //fcrp, fcrpU, fcrpV, fprp, fprpU, fprpV);
                CacheQuery(frame, &p, &pblock, &c, &cblock);
        }
        if (CacheQuery(nframe, &np, &npblock, &nc, &ncblock) == false)
        {
                CalculateMetrics(nframe, fn,fc); //fnrp, fnrpU, fnrpV, fcrp, fcrpU, fcrpV);
                CacheQuery(nframe, &np, &npblock, &nc, &ncblock);
        }

        // Determine the best candidate match.
        if (found != true)
        {
                lowest = c;
                chosen = C;
                if (back == ALWAYS_BACK && p < lowest)
                {
                        lowest = p;
                        chosen = P;
                }
                if (np < lowest)
                {
                        lowest = np;
                        chosen = N;
                }
        }
        if ((frame == 0 && chosen == P) || (lastFrame==true && chosen == N))
        {
                chosen = C;
                lowest = c;
        }

        // See if we can apply pattern guidance.
        mismatch = 100.0;
        if (guide != GUIDE_NONE)
        {
                bool hard = false;
                if (frame >= cycle && PredictHardYUY2(frame, &predicted, &predicted_metric) == true)
                {
                        inpattern = true;
                        mismatch = 0.0;
                        hard = true;
                        if (chosen != predicted)
                        {
                                // The chosen frame doesn't match the prediction.
                                if (predicted_metric == 0) mismatch = 0.0;
                                else mismatch = (100.0*abs((int)predicted_metric - (int)lowest))/predicted_metric;
                                if (mismatch < gthresh)
                                {
                                        // It's close enough, so use the predicted one.
                                        if (found != true)
                                        {
                                                chosen = predicted;
                                                override = true;
                                        }
                                }
예제 #2
0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Function Header
void CStaticCounter::OnPaint() 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
{
	GetClientRect(&m_recClient);
	CPaintDC dc(this);
	CStaticDC memDC(&dc, m_recClient);
	CStaticDC* pDC = &memDC;

	pDC->FillSolidRect(&m_recClient, m_crBackground);

	if (!m_bGotMetrics)		CalculateMetrics();

	int nColPos = 0;

	CString strFormatted = m_strDisplay;

	/////////////////////////////////////////////////////////////////////////////////////////////
	// BLANK PADDING
		if ( (m_nBlankPadding>0) && (m_strDisplay.GetLength()<m_nBlankPadding) )
		{
			int nCurLength = m_strDisplay.GetLength();
			int nDiff = m_nBlankPadding-nCurLength;
			CString strBlank("                                        ");
			strFormatted = strBlank.Left(nDiff) + m_strDisplay;
		}
	// END BLANK PADDING
	/////////////////////////////////////////////////////////////////////////////////////////////


	for (int nCount = 0; nCount<strFormatted.GetLength(); nCount++)
	{
		// Calculate the position of the next character:

		if ( nCount > 0 )
		{
			if (strFormatted[nCount] == ':')	
				nColPos+= m_nNotchLength+m_nMargin;
			else if (strFormatted[nCount-1] == ':' )	
				nColPos+= m_nNotchLength+1;
			else
				nColPos += m_nNotchLength + (m_nMargin*4);
		}

		// First 'lay down' the faded notches:
		if (m_bDrawFadedNotches && strFormatted[nCount] != ':' )	
			Draw( pDC, STCOUNTERALL, nColPos );

		if		  ( strFormatted[nCount] == '0' ) Draw( pDC, STCOUNTER0, nColPos );
		else if ( strFormatted[nCount] == '1' )	Draw( pDC, STCOUNTER1, nColPos );
		else if ( strFormatted[nCount] == '2' )	Draw( pDC, STCOUNTER2, nColPos );
		else if ( strFormatted[nCount] == '3' )	Draw( pDC, STCOUNTER3, nColPos );
		else if ( strFormatted[nCount] == '4' )	Draw( pDC, STCOUNTER4, nColPos );
		else if ( strFormatted[nCount] == '5' )	Draw( pDC, STCOUNTER5, nColPos );
		else if ( strFormatted[nCount] == '6' )	Draw( pDC, STCOUNTER6, nColPos );
		else if ( strFormatted[nCount] == '7' )	Draw( pDC, STCOUNTER7, nColPos );
		else if ( strFormatted[nCount] == '8' )	Draw( pDC, STCOUNTER8, nColPos );
		else if ( strFormatted[nCount] == '9' )	Draw( pDC, STCOUNTER9, nColPos );
		else if ( strFormatted[nCount] == '-' )	Draw( pDC, STCOUNTER10, nColPos );
		else if ( strFormatted[nCount] == '.' )	Draw( pDC, STCOUNTER11, nColPos );
		else if ( strFormatted[nCount] == ':' )	Draw( pDC, STCOUNTER12, nColPos );
	}

	if (m_bDraw3DBar)		
	{
		// the reason I multiply by a hundred is to improve the visuals of ranges between 0 and 1
		float fRange = (float)abs( (int)( (m_fMax*100) - (m_fMin*100) ) );
		float fWidth = ((float)m_recClient.right/fRange) * // Split the width up into fRange number of 'portions' ...
							( (m_fPos*100)-(m_fMin*100) ); // .. and multiply by current value

		CRect BarBgRect( CPoint(m_recClient.left, m_recClient.bottom-m_nBarHeight), CSize((int)m_recClient.right, m_nBarHeight) );
		CBrush brBG(::GetSysColor(COLOR_BTNFACE));
		pDC->FillRect(BarBgRect, &brBG);
		pDC->Draw3dRect(	&BarBgRect, ::GetSysColor(COLOR_BTNSHADOW), ::GetSysColor(COLOR_BTNHILIGHT) );

		CRect BarRect(  CPoint(m_recClient.left, m_recClient.bottom-m_nBarHeight), CSize((int)fWidth, m_nBarHeight) );
		m_3DBar.DrawHorizontal( pDC, BarRect );
	}
}
예제 #3
0
// Format a line using the information from a format context.
void CTmLine::FormatL(CTmFormatContext& aContext)
	{
	// Reset arrays and parameters.
	iChunk.Reset();
	iText.Reset();
	iTextWithoutChunkOverlaps.Reset();
	iRunInfo.Reset();
	iCountedEndChar = iHangingEndChar = iEndChar = iNextLineStartChar = 0;
	iAtParEnd = FALSE;
	iHeight = iAscent = 0;
	iInnerBounds.SetRect(0,0,0,0);
	iEllipsis = 0xFFFF;

	// Determine the line break.
	int start_x_coord = aContext.iLineInPar == 0 ? aContext.iFirstLineLeftMargin : aContext.iLeftMargin;
	int align_x_coord = aContext.iParam.iWrapWidth -
						(aContext.iLineInPar == 0 ? aContext.iFirstLineRightMargin : aContext.iRightMargin);
	int wrap_x_coord = KMaxTInt;
	if (aContext.iParam.IsWrapping() && !(aContext.iParFormat.iFlags & RTmParFormat::ENoWrap))
		wrap_x_coord = align_x_coord;
	BreakL(aContext,start_x_coord,wrap_x_coord);

	// Calculate the ascent, descent and width.
	TInt width;
	TInt descent;
	CalculateMetrics(aContext,width,iAscent,descent);

	// Determine if the line has any border rules.
	iBordered = aContext.iLeftBorder || aContext.iRightBorder ||
				(aContext.iTopBorder && aContext.iLineInPar == 0) ||
				(aContext.iBottomBorder && iAtParEnd);
	
	// Determine the next bidirectional category and next strong bidirectional category
	aContext.iBdEndOfLine.Set(aContext.iTextCache, iNextLineStartChar);

	/*
	Calculate the bounds of the line. The outer bounds of the lines in a band completely tile
	the band, and are a series of full-width horizontal slices; these are defined completely by their heights,
	so iHeight represents the outer bounds. The inner bounds surround the actual text, not including margins,
	indents and space above and below lines and paragraphs.
	*/
	iInnerBounds.SetRect(start_x_coord,0,start_x_coord + width,KMaxTInt);
	if (aContext.iLineInPar == 0)
		{
		iInnerBounds.iTl.iY += aContext.iSpaceBefore;
		if (iBordered && aContext.iTopBorder)
			iInnerBounds.iTl.iY += aContext.iVBorderMargin + aContext.iTopBorder;
		}
	iHeight = iInnerBounds.iBr.iY = iInnerBounds.iTl.iY + iAscent + descent;
	if (iAtParEnd)
		{
		iHeight += aContext.iSpaceAfter;
		if (iBordered && aContext.iBottomBorder)
			iHeight += aContext.iVBorderMargin + aContext.iBottomBorder;
		}

	// Perform right alignment, centring or full justification.
	int measure = align_x_coord - start_x_coord;
	switch (aContext.iParFormat.iAlignment)
		{
		case RTmParFormat::EAlignNormalBidirectional:
			if (aContext.iParFormat.RightToLeft())
				{
				if(measure - width < 0)
					{
					iInnerBounds.Move(0, 0);	
					}
					else
					{
					iInnerBounds.Move(measure - width, 0);		
					}
				}
			break;
		case RTmParFormat::EAlignReverseBidirectional:
			if (!aContext.iParFormat.RightToLeft())
				iInnerBounds.Move(measure - width, 0);
			break;
		case RTmParFormat::EAlignCenter:
			iInnerBounds.Move((measure - width) / 2,0);
			break;
		case RTmParFormat::EAlignJustify:
			if (iAtParEnd || measure <= width)
				{
				// Default to normal bidirectional for the last line of
				// a paragraph or if the margins are broken.
				if (aContext.iParFormat.RightToLeft())
					iInnerBounds.Move(measure - width, 0);
				}
			else
				Justify(measure - width);
			break;
		case RTmParFormat::EAlignAbsoluteLeft:
			// default is left
			break;
		case RTmParFormat::EAlignAbsoluteRight:
			iInnerBounds.Move(measure - width, 0);
			break;
		default:
			break;
		}
	}