Mercurial > hg > Members > you > TreeVNC
changeset 47:65b798ba8145
datasplit
author | Yu Taninari <you@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 03 May 2012 14:49:53 +0900 |
parents | f5690aa77f69 |
children | e6d5ec9ec15e |
files | src/treeVnc/MyRfbProtoProxy.java |
diffstat | 1 files changed, 55 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/src/treeVnc/MyRfbProtoProxy.java Thu May 03 14:23:45 2012 +0900 +++ b/src/treeVnc/MyRfbProtoProxy.java Thu May 03 14:49:53 2012 +0900 @@ -1103,19 +1103,22 @@ }; } - private LinkedList<ByteBuffer> splitBuffer(LinkedList<ByteBuffer> input) { + private LinkedList<ByteBuffer> splitBuffer(LinkedList<ByteBuffer> input,ByteBuffer header) throws IOException { LinkedList<ByteBuffer> output = new LinkedList<ByteBuffer>(); // int high = rectH / 4; // System.out.println(INFLATE_BUFSIZE * (input.size() - 1)+ // input.getLast().limit()); - int dataLen = rectW * 64 * 3 * 2; - int temp = 0; - int count = rectH / 128; + int width = header.getShort(8); + int height = header.getShort(10); + int y = header.getShort(6); + int dataLen = width * 64 * 3 * 2; + int temp = 0,preserv=0; + int count = height / 128; - if (rectW % 64 == 0) - dataLen += (rectW / 64) * 2; + if (width % 64 == 0) + dataLen += (width / 64) * 2; else - dataLen += (((rectW / 64) + 1) * 2); + dataLen += (((width / 64) + 1) * 2); for (int i = 0; i < count; i++) { int tempDataLen = dataLen - temp; @@ -1126,7 +1129,9 @@ } if (tempDataLen == INFLATE_BUFSIZE) { output.addLast(input.poll()); - output.addLast(null); + createHeader(header, i, height, y); + zipSplitData(header, output); + output.clear(); temp = INFLATE_BUFSIZE; } else { // System.out.println("THROWIO"); @@ -1134,24 +1139,29 @@ // System.out.println(tempBuf.remaining()); ByteBuffer buf1 = ByteBuffer.allocate(INFLATE_BUFSIZE); - ByteBuffer buf2 = ByteBuffer.allocate(INFLATE_BUFSIZE); tempBuf.get(buf1.array(), 0, tempDataLen); - tempBuf.get(buf2.array(), 0, tempBuf.remaining()); buf1.limit(tempDataLen); + output.addLast(buf1); + createHeader(header, i, height, y); + zipSplitData(header, output); + output.clear(); // insert into createHeader // insert into this area zipcode and buf1 clear + ByteBuffer buf2 = ByteBuffer.allocate(INFLATE_BUFSIZE); + tempBuf.get(buf2.array(), 0, tempBuf.remaining()); buf2.limit(INFLATE_BUFSIZE - tempDataLen); - buf2.position(0); - output.addLast(buf1); - output.addLast(null); output.addLast(buf2); temp = INFLATE_BUFSIZE - tempDataLen; } + preserv = i; } while (input.size() != 0) { output.addLast(input.poll()); } + createHeader(header, preserv+1, height, y); + zipSplitData(header, output); + output.clear(); return output; } @@ -1159,46 +1169,41 @@ private void splitData(LinkedList<ByteBuffer> input, ByteBuffer header) throws IOException, DataFormatException { - int sum2 = 0; - LinkedList<ByteBuffer> buf = splitBuffer(input); - for (int i = 0; i < (rectH / 128) + 1; i++) { - int sum = 0; - LinkedList<ByteBuffer> tempBuf = new LinkedList<ByteBuffer>(); - while (buf.peek() != null) { - tempBuf.addLast(buf.poll()); - sum2 += tempBuf.getLast().limit(); - } - // Deflater nDeflater = deflater; - Deflater nDeflater = new Deflater(); - LinkedList<ByteBuffer> bufs = new LinkedList<ByteBuffer>(); - for (ByteBuffer b : tempBuf) { - sum += b.limit(); - } - - int len2 = zip(nDeflater, tempBuf, 0, bufs); - ByteBuffer blen = ByteBuffer.allocate(4); - blen.putInt(len2); - blen.flip(); - bufs.addFirst(blen); - createHeader(header, i); - - System.out.println(sum - (header.getShort(10) * header.getShort(8)) - * 3); - System.out.println("sum2=" + sum2); - - bufs.addFirst(header); - // broadcastqueue.put(bufs); - multicastqueue.put(bufs); - // System.out.println("pass"); - if (buf.size() != 0) - buf.remove(); - } + splitBuffer(input,header); +// for (int i = 0; i < (rectH / 128) + 1; i++) { +// LinkedList<ByteBuffer> tempBuf = new LinkedList<ByteBuffer>(); +// while (buf.peek() != null) { +// tempBuf.addLast(buf.poll()); +// } +// // Deflater nDeflater = deflater; +// zipSplitData(header, tempBuf); +// // System.out.println("pass"); +// if (buf.size() != 0) +// buf.remove(); +// } // System.out.println("throw"); } - private void createHeader(ByteBuffer header, int count) { - int rH = Math.min(128, rectH - (128 * count)); - int rY = rectY + (128 * count); + private void zipSplitData(ByteBuffer header, LinkedList<ByteBuffer> tempBuf) + throws IOException { + Deflater nDeflater = new Deflater(); + LinkedList<ByteBuffer> bufs = new LinkedList<ByteBuffer>(); + + int len2 = zip(nDeflater, tempBuf, 0, bufs); + ByteBuffer blen = ByteBuffer.allocate(4); + blen.putInt(len2); + blen.flip(); + bufs.addFirst(blen); +// createHeader(header, i); + + bufs.addFirst(header); + // broadcastqueue.put(bufs); + multicastqueue.put(bufs); + } + + private void createHeader(ByteBuffer header, int count,int h,int y) { + int rH = Math.min(128, h - (128 * count)); + int rY = y + (128 * count); header.putShort(10, (short) rH); header.putShort(6, (short) rY); }