Exemplo n.º 1
0
// Tight
UINT vncEncoder::NumCodedRects(RECT &rect)
{
	rfb::Rect TRect;
	TRect.br.x = rect.right;
	TRect.tl.x = rect.left;
	TRect.tl.y = rect.top;
	TRect.br.y = rect.bottom;
	
	return NumCodedRects(TRect);
}
Exemplo n.º 2
0
UINT vncEncodeCoRRE::RequiredBuffSize(UINT width, UINT height)
{
	rfb::Rect fullscreen = rfb::Rect(0, 0, width, height);
	UINT codedrects;

	// Work out how many rectangles the entire screen would
	// be re-encoded to...
	codedrects = NumCodedRects(fullscreen);

	// The buffer size required is the size of raw data for the whole
	// screen plus enough space for the required number of rectangle
	// headers.
	// This is inherently always greater than the RAW encoded size of
	// the whole screen!
	return (codedrects * sz_rfbFramebufferUpdateRectHeader) +
			(width * height * m_remoteformat.bitsPerPixel)/8;
}
Exemplo n.º 3
0
UINT
vncEncodeCoRRE::NumCodedRects(const rfb::Rect &rect)
{
	// If we have any statistical data handy then adjust the CoRRE sizes
	if (m_statsready)
	{
		m_statsready = FALSE;

		UINT newscore = m_encodedbytes * m_lastrectbytes;
		UINT oldscore = m_lastencodedbytes * m_rectbytes;

		if (newscore <= oldscore)
		{
			// The change was a good one, so adjust the threshold accordingly!
			m_threshold = max(5, min(95, m_threshold + m_maxadjust));

			m_maxwidth = max(8, min(255, m_maxwidth + m_maxadjust));
			m_maxheight = max(8, min(255, m_maxheight + m_maxadjust));
		}
		else
		{
			// The change was a bad one, so adjust the threshold accordingly!
			// m_threshold = Max(5, Min(95, m_threshold - m_maxadjust));
		}

		// Now calculate a new adjustment and apply it
		m_maxadjust = ((rand() % 99)<m_threshold) ? 1 : -1;
		
		// Prepare the stats data for next time...
		m_lastencodedbytes = m_encodedbytes;
		m_lastrectbytes = m_rectbytes;

		m_encodedbytes = 0;
		m_rectbytes = 0;
	}

	// Now return the number of rects that this one would encode to
    if ((rect.br.y-rect.tl.y) > m_maxheight)
	{
		rfb::Rect subrect1, subrect2;

		// Find how many rects the two subrects would take
		subrect1.tl.x = rect.tl.x;
		subrect1.br.x = rect.br.x;
		subrect1.tl.y = rect.tl.y;
		subrect1.br.y = rect.tl.y + m_maxheight;

		subrect2.tl.x = rect.tl.x;
		subrect2.br.x = rect.br.x;
		subrect2.tl.y = rect.tl.y + m_maxheight;
		subrect2.br.y = rect.br.y;

		return NumCodedRects(subrect1) + NumCodedRects(subrect2);
	}

    if ((rect.br.x-rect.tl.x) > m_maxwidth)
	{
		rfb::Rect subrect1, subrect2;

		// Find how many rects the two subrects would take
		subrect1.tl.x = rect.tl.x;
		subrect1.br.x = rect.tl.x + m_maxwidth;
		subrect1.tl.y = rect.tl.y;
		subrect1.br.y = rect.br.y;

		subrect2.tl.x = rect.tl.x + m_maxwidth;
		subrect2.br.x = rect.br.x;
		subrect2.tl.y = rect.tl.y;
		subrect2.br.y = rect.br.y;
		return NumCodedRects(subrect1) + NumCodedRects(subrect2);
	}

	// This rectangle is small enough not to require splitting
	return 1;
}