changeset 10:d2644d8f7893

add code
author riono <e165729@ie.u-ryukyu.ac.jp>
date Thu, 07 May 2020 18:45:22 +0900
parents e1196cd575bf
children c9d0d3e1a82f
files Paper/riono-sigos.pdf Paper/riono-sigos.tex Paper/src/decode.java
diffstat 3 files changed, 60 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
Binary file Paper/riono-sigos.pdf has changed
--- a/Paper/riono-sigos.tex	Thu May 07 11:15:06 2020 +0900
+++ b/Paper/riono-sigos.tex	Thu May 07 18:45:22 2020 +0900
@@ -15,6 +15,9 @@
 \usepackage[dvipdfmx]{graphicx}
 \usepackage{latexsym}
 \usepackage{url}
+\usepackage{listings}
+\usepackage{caption}
+
 
 \def\Underline{\setbox0\hbox\bgroup\let\\\endUnderline}
 \def\endUnderline{\vphantom{y}\egroup\smash{\underline{\box0}}\\}
@@ -24,11 +27,33 @@
 %\setcounter{巻数}{59}%vol59=2018
 %\setcounter{号数}{10}
 %\setcounter{page}{1}
+\lstset{
+  language=java, 
+  tabsize=2, 
+  numbers=left,
+  frame=single, 
+  basicstyle={\ttfamily\footnotesize}, % 
+  identifierstyle={\footnotesize}, % 
+ commentstyle={\footnotesize\itshape}, % 
+  keywordstyle={\footnotesize\bfseries}, % 
+  ndkeywordstyle={\footnotesize}, % 
+  stringstyle={\footnotesize\ttfamily}, 
+  breaklines=true, 
+  captionpos=t, 
+  columns=[l]{fullflexible}, % 
+  xrightmargin=0zw, % 
+  xleftmargin=1zw, % 
+  aboveskip=1zw, 
+  numberstyle={\scriptsize}, % 
+  stepnumber=1, 
+  numbersep=0.5zw, % 
+  lineskip=-0.5ex, 
+}
 
+\renewcommand{\lstlistingname}{Code}
 
 \begin{document}
 
-
 \title{Multicast Wifi VNCの実装と評価}
 
 \affiliate{KIE}{琉球大学大学院理工学研究科情報工学専攻}
@@ -236,15 +261,11 @@
     \label{tb:rectangleheader}
 \end{table}
 
-次にTileLoopの処理について説明する。以下の図\ref{fig:TileLoopFlow}はTileRoopのフローチャートである。
+次にTileLoopの処理について説明する。
+Code\ref{code:tileloop}はTileLoopの処理を擬似的に抜粋したものである。
 
-\begin{figure}[htp] %PDF
-\begin{center}
-\includegraphics[width=8cm]{fig/TileLoopFlow.pdf}
-\caption{TileLoopのフローチャート}
-\label{fig:TileLoopFlow}
-\end{center}
-\end{figure}
+\lstinputlisting[caption=TileLoopの処理関数, label=code:tileloop]{src/decode.java}
+
 
 図\ref{fig:TileLoopFlow}中1にて、TileLoopの初期化でBlockingと構築するPacketの準備を行う。Loop本体ではZRLEで受け取ったRectangleを1Tile 64x64に分割し、1Tileずつ処理を行う。そして受け取ったZRLEより処理を行うTileのデータを取得し、圧縮段階に入る。
 
@@ -265,12 +286,12 @@
 
 そこで圧縮率は悪くなるが、確実にPacketに書き込まれるSYNC\_FLUSHを利用し、ZRLEEの生成を行う。
 
-図\ref{fig:TileLoopFlow}中3ではPacketの上限までいかなかった場合の分岐である。
+図中3ではPacketの上限までいかなかった場合の分岐である。
 分岐の初めではRectangleの構成を行なっているc1Rectと、ZRLEから送られてきたRectangleなどと比較を行い、Phaseの確認をする。
 
 Phaseの変更がなかった場合はLoopの先頭に戻るが、Phaseの変更があった場合、これまで構成していたRectangleとしてc1RectをそのPhaseのRectangle Headerに書き出す。c1Rectは次のPhaseに向けて初期化される。またこの時、図\ref{fig:Packet}の各Rectangleの行末にあるように、FULL\_HLUSHを行う理由は、次の行に移る際圧縮用のStreamにデータを残さないためである。
 
-図\ref{fig:TileLoopFlow}中4の処理は、Packetが一旦の上限42KBまで達したことで分岐する。
+図中4の処理は、Packetが一旦の上限42KBまで達したことで分岐する。
 
 java.util.zip.deflaterを使用した圧縮では、Packetが一杯になってしまうと、圧縮書き出し中でも中断してしまう。そこでPacketの余剰分を解放し上限を60KBにすることで、確実に書き込みを可能とする。図\ref{fig:Packet}中Last Tileとは、Packetが一杯になった際に読み込まれているTileのことを指す。Last Tileは圧縮前で最大16KBと考えられる。これを圧縮すると3 - 4KB程度であるので、その分のマージンを持っていくことで、読み込んだ最後のTileまできちんとPacketに書き込むことができる。
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Paper/src/decode.java	Thu May 07 18:45:22 2020 +0900
@@ -0,0 +1,28 @@
+public void decode(Renderer renderer, ByteBuffer header, FramebufferUpdateRectangle rect, ByteBuffer buf, int zippedLength, TreeRFBProto rfbProto) throws TransportException {
+  int offset = zippedLength;
+  int maxX = rect.x + rect.width;
+  int maxY = rect.y + rect.height;
+  byte[] bytes = buf.array();
+  WifiMulticast = rfbProto;
+
+  TileLoop tileloop = new TileLoop(rfbProto, zippedLength);
+  if (WifiMulticast) {
+    tileloop.zrleeBlocking(rfbProto, header, rect, bytes);
+  }
+  for (int tileY = rect.y; tileY < maxY; tileY += MAX_TILE_SIZE) {
+    int tileHeight = Math.min(maxY - tileY, MAX_TILE_SIZE);
+    if (tileloop.blocking) {
+      tileloop.c1rect.height += tileHeight;
+    }
+    for (int tileX = rect.x; tileX < maxX; tileX += MAX_TILE_SIZE) {
+      int tileWidth = Math.min(maxX - tileX, MAX_TILE_SIZE);
+      offset += decodePacked(bytes, offset, renderer, paletteSize, tileX, tileY, tileWidth, tileHeight);
+      if (WifiMulticast) {
+	tileloop.multicastPut(rfbProto, false, bytes, offset, tileWidth, tileHeight, tileX, tileY);
+      }
+    }
+  }
+  if (WifiMulticast)
+    tileloop.multicastPut(rfbProto, true, bytes, offset, 0, 0, 0, 0);
+}
+