From bb56377fedf3058d2051764ab16b2b57419cca60 Mon Sep 17 00:00:00 2001 From: Constantin Kaplinsky Date: Tue, 25 Dec 2007 11:25:07 +0000 Subject: [PATCH] Making sure that both height and width of the video area are always multiples of 32. This is important for hardware JPEG encoders. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2378 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- unix/x0vncserver/PollingManager.cxx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/unix/x0vncserver/PollingManager.cxx b/unix/x0vncserver/PollingManager.cxx index b506bb4f..5cd611bd 100644 --- a/unix/x0vncserver/PollingManager.cxx +++ b/unix/x0vncserver/PollingManager.cxx @@ -280,10 +280,22 @@ PollingManager::detectVideo() const int VIDEO_THRESHOLD_0 = 3; const int VIDEO_THRESHOLD_1 = 5; + // In m_rateMatrix, clear counters corresponding to non-32x32 tiles. + // This will guarantee that the size of the video area is always a + // multiple of 32 pixels. This is important for hardware JPEG encoders. + int numTiles = m_heightTiles * m_widthTiles; + if (m_width % 32 != 0) { + for (int n = m_widthTiles - 1; n < numTiles; n += m_widthTiles) + m_rateMatrix[n] = 0; + } + if (m_height % 32 != 0) { + for (int n = numTiles - m_widthTiles; n < numTiles; n++) + m_rateMatrix[n] = 0; + } + // First, detect candidate region that looks like video. In other // words, find a region that consists of continuously changing // pixels. Save the result in m_videoFlags[]. - int numTiles = m_heightTiles * m_widthTiles; for (int i = 0; i < numTiles; i++) { if (m_rateMatrix[i] <= VIDEO_THRESHOLD_0) { m_videoFlags[i] = 0; -- 2.39.5