Skip to content

Commit 5c4a5d0

Browse files
committed
Fix compression ratio stats in decoder
We need to count the number of bytes received, not what's been put in the temporary output buffer. The two are not the same for all decoders.
1 parent acd0e8e commit 5c4a5d0

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

common/rfb/DecodeManager.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ bool DecodeManager::decodeRect(const core::Rect& r, int encoding,
149149
partialEntry->server = &conn->server;
150150
partialEntry->pb = pb;
151151
partialEntry->bufferStream = bufferStream;
152+
153+
beforePos = conn->getInStream()->pos();
152154
} else {
153155
assert(partialEntry->rect == r);
154156
assert(partialEntry->encoding == encoding);
@@ -170,7 +172,7 @@ bool DecodeManager::decodeRect(const core::Rect& r, int encoding,
170172
&partialEntry->affectedRegion);
171173

172174
stats[encoding].rects++;
173-
stats[encoding].bytes += 12 + partialEntry->bufferStream->length();
175+
stats[encoding].bytes += 12 + conn->getInStream()->pos() - beforePos;
174176
stats[encoding].pixels += r.area();
175177
equiv = 12 + r.area() * (conn->server.pf().bpp/8);
176178
stats[encoding].equivalent += equiv;

common/rfb/DecodeManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ namespace rfb {
7171
};
7272

7373
DecoderStats stats[encodingMax+1];
74+
size_t beforePos;
7475

7576
struct QueueEntry {
7677
bool active;

0 commit comments

Comments
 (0)