# HG changeset patch # User Shinji KONO # Date 1581083801 -32400 # Node ID c7527f24e3446c151e1af9b92861e68fa1df2228 # Parent 5bc128c8e6aacb32a871042fb3893f5b95d4bdd5 fix deflatr diff -r 5bc128c8e6aa -r c7527f24e344 src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEDecoder.java --- a/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEDecoder.java Fri Feb 07 19:22:30 2020 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEDecoder.java Fri Feb 07 22:56:41 2020 +0900 @@ -157,25 +157,26 @@ int span = offset - prevoffset; deflater.setInput(bytes, prevoffset, span); do { - deflater.deflate(c1, Deflater.SYNC_FLUSH); - long bytesRead = deflater.getBytesRead(); + deflater.deflate(c1, Deflater. SYNC_FLUSH); + int bytesRead = (int)deflater.getBytesRead(); if (!deflater.needsInput()) { // compression failed - flushDeflator(bytes); - prevoffset = flushOffset+(int)bytesRead; + flushDeflator(); + prevoffset = flushOffset+(int)deflater.getBytesRead(); flushRectangle(rect); flushMuticast(rfb, bytes); if (last && bytesRead == span) { return; } else { newMulticastPacket(rfb, rect); + deflater.setInput(bytes,prevoffset,offset - prevoffset); deflater.deflate(c1, Deflater.NO_FLUSH); } } } while (! deflater.needsInput()); prevoffset = offset; if (last) { - flushDeflator(bytes); + flushDeflator(); flushRectangle(rect); flushMuticast(rfb, bytes); } @@ -196,10 +197,8 @@ } } - private void flushDeflator(byte[] bytes) { - byte [] n = {}; + private void flushDeflator() { c1.limit(c1.limit() + MARGIN); - deflater.setInput(n); deflater.deflate(c1, Deflater.FULL_FLUSH); if (c1.remaining()==0) { System.out.println("Multicast packet overrun."); diff -r 5bc128c8e6aa -r c7527f24e344 src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java --- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Fri Feb 07 19:22:30 2020 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Fri Feb 07 22:56:41 2020 +0900 @@ -414,7 +414,7 @@ if (buf.remaining() == span) { }else { - System.out.println("Bytes is not equal length "+buf.remaining()+" != "+span); + System.out.println("Bytes is not equal length "+buf.remaining()+" != "+span + " " + (buf.remaining() - span)); } }