datacompression.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <HTML>
  2. <HEAD>
  3. <TITLE>Data Compression</TITLE>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. </HEAD>
  6. <link href="RaknetManual.css" rel="stylesheet" type="text/css">
  7. <meta name="title" content="RakNet - Advanced multiplayer game networking API">
  8. </HEAD><BODY BGCOLOR="#ffffff" LINK="#003399" vlink="#003399" alink="#003399" LEFTMARGIN="0" TOPMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0"">
  9. <span style="background-color: rgb(255, 255, 255);"><img src="RakNet_Icon_Final-copy.jpg" alt="Oculus VR, Inc." width="150" height="150"></span><BR>
  10. <BR>
  11. <table width="100%" border="0">
  12. <tr>
  13. <td bgcolor="#2c5d92" class="RakNetWhiteHeader"><img src="spacer.gif" width="8" height="1">Data Compression Overview</td>
  14. </tr>
  15. </table>
  16. <TABLE BORDER="0" CELLPADDING="10" CELLSPACING="0" WIDTH="100%">
  17. <TR>
  18. <TD><span class="RakNetBlueHeader">Description </span><BR>
  19. <BR>
  20. RakNet can automatically compress all your outgoing data and decompress your incoming data. To do this, it needs a 'sample' frequency table for your average game so it can pre-compute how to encode the data to get maximum savings. Here is the general process of how to go about this:
  21. <OL>
  22. <LI>Run a sample 'average' game. Get the frequency table for the server and for one of the clients (or average all the clients if you want).
  23. <LI>Generate the decompression layer for the server from the client's frequency table
  24. <LI>Generate the compression layer for the server from the server's frequency table
  25. <LI>Generate the decompression layer for the client from the server's frequency table
  26. <LI>Generate the compression layer for the client from the client's frequency table.
  27. </OL>
  28. After that everything is handled automatically.<BR>
  29. <BR>
  30. The functions are described below. See Samples\Compression for a full example. </TD>
  31. </TR>
  32. </TABLE>
  33. <table width="100%" border="0">
  34. <tr>
  35. <td bgcolor="#2c5d92" class="RakNetWhiteHeader"><img src="spacer.gif" width="8" height="1">Data Compression Functions</td>
  36. </tr>
  37. </table>
  38. <TABLE BORDER="0" CELLPADDING="10" CELLSPACING="0" WIDTH="100%">
  39. <TR>
  40. <TD><span class="RakNetCode">SetCompileFrequencyTable( bool doCompile )</span><BR>
  41. <BR>
  42. Enables or disables frequency table tracking. This is required to get a frequency table, which is used in GenerateCompressionLayer()
  43. This value persists between connect calls and defaults to false (no frequency tracking)
  44. You can call this at any time - however you SHOULD only call it when disconnected. Otherwise you will only trackpart of the values sent over the network.
  45. <BR><BR>
  46. <span class="RakNetCode">GenerateCompressionLayer(unsigned long inputFrequencyTable[256], bool inputLayer)</span><BR>
  47. <BR>
  48. This is an optional function to generate the compression layer based on the input frequency table, which you get with GetOutgoingFrequencyTable.You should call this twice - once with inputLayer as true and once as false.
  49. The frequency table passed here with inputLayer=true should match the frequency table on the recipient with inputLayer=false.
  50. Likewise, the frequency table passed here with inputLayer=false should match the frequency table on the recipient with inputLayer=true.
  51. Calling this function when there is an existing layer will overwrite the old layer.
  52. <BR>
  53. <BR>
  54. <span class="RakNetCode">DeleteCompressionLayer(bool inputLayer) <BR>
  55. </span><BR>
  56. Delete the output or input layer as specified. This is not necessary to call and is only valuable for freeing memory.
  57. You should only call this when disconnected<BR>
  58. <BR>
  59. <span class="RakNetCode">GetOutgoingFrequencyTable(unsigned long outputFrequencyTable[256]) </span><BR>
  60. <BR>
  61. Returns the frequency of outgoing bytes into output frequency table
  62. The purpose is to save to file as either a master frequency table from a sample game session for passing to GenerateCompressionLayer() .
  63. You should only call this when disconnected. Requires that you first enable data frequency tracking by calling SetCompileFrequencyTable(true)
  64. <BR>
  65. <BR>
  66. <span class="RakNetCode">float GetCompressionRatio </span><BR>
  67. <BR>
  68. This returns a number n > 0.0f where lower numbers are better. n == 1.0f means your data is no smaller or greater than the original. This shows how effective your compression rates are.<BR>
  69. <BR>
  70. <span class="RakNetCode">float GetDecompressionRatio </span><BR>
  71. <BR>
  72. This returns a number n > 0.0f where higher numbers are better. n == 1.0f means the incoming data was decompressed to be just as large as it was when it came in. This shows how effective your compression rates are.<BR>
  73. <BR>
  74. <table width="100%" border="0">
  75. <tr>
  76. <td bgcolor="#2c5d92" class="RakNetWhiteHeader"><img src="spacer.gif" width="8" height="1">See Also</td>
  77. </tr>
  78. </table>
  79. <TABLE BORDER="0" CELLPADDING="10" CELLSPACING="0" WIDTH="100%">
  80. <TR>
  81. <TD> <A HREF="index.html">Index</A><BR> </TD>
  82. </TR>
  83. </TABLE></TD>
  84. </TR></TABLE>
  85. </BODY>
  86. </HTML>
粤ICP备19079148号