aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs32
1 files changed, 26 insertions, 6 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
index 276dfbe..a93a3e5 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
@@ -48,6 +48,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
48 48
49 public class J2KImage 49 public class J2KImage
50 { 50 {
51
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 public double m_designatedPriorityKey; 53 public double m_designatedPriorityKey;
53 public double m_requestedPriority = 0.0d; 54 public double m_requestedPriority = 0.0d;
@@ -61,7 +62,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
61 public AssetBase m_MissingSubstitute = null; 62 public AssetBase m_MissingSubstitute = null;
62 public bool m_decoded = false; 63 public bool m_decoded = false;
63 public bool m_completedSendAtCurrentDiscardLevel; 64 public bool m_completedSendAtCurrentDiscardLevel;
64 65
65 private sbyte m_discardLevel=-1; 66 private sbyte m_discardLevel=-1;
66 private uint m_packetNumber; 67 private uint m_packetNumber;
67 private bool m_decoderequested = false; 68 private bool m_decoderequested = false;
@@ -72,7 +73,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
72 private const int cImagePacketSize = 1000; 73 private const int cImagePacketSize = 1000;
73 private const int cFirstPacketSize = 600; 74 private const int cFirstPacketSize = 600;
74 private AssetBase m_asset = null; 75 private AssetBase m_asset = null;
75 76 private LLImageManager m_image;
77 public J2KImage(LLImageManager image)
78 {
79 m_image = image;
80 }
76 81
77 public uint m_pPacketNumber 82 public uint m_pPacketNumber
78 { 83 {
@@ -103,6 +108,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
103 108
104 public void J2KDecodedCallback(UUID AssetId, OpenJPEG.J2KLayerInfo[] layers) 109 public void J2KDecodedCallback(UUID AssetId, OpenJPEG.J2KLayerInfo[] layers)
105 { 110 {
111 m_image.m_outstandingtextures++;
106 Layers = layers; 112 Layers = layers;
107 m_decoded = true; 113 m_decoded = true;
108 RunUpdate(); 114 RunUpdate();
@@ -130,8 +136,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
130 { 136 {
131 if (m_packetNumber == 1) 137 if (m_packetNumber == 1)
132 return m_asset.Data.Length; 138 return m_asset.Data.Length;
133 return (m_asset.Data.Length - cFirstPacketSize) % cImagePacketSize; 139 int lastsize = (m_asset.Data.Length - cFirstPacketSize) % cImagePacketSize;
134 } 140 //If the last packet size is zero, it's really cImagePacketSize, it sits on the boundary
141 if (lastsize == 0)
142 {
143 lastsize = cImagePacketSize;
144 }
145 return lastsize;
146 }
147
135 148
136 public int CurrentBytePosition() 149 public int CurrentBytePosition()
137 { 150 {
@@ -247,7 +260,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
247 m_sentinfo = true; 260 m_sentinfo = true;
248 m_packetNumber++; 261 m_packetNumber++;
249 } 262 }
250 263 bool ignoreStop = false;
251 if (m_packetNumber < 2) 264 if (m_packetNumber < 2)
252 { 265 {
253 m_packetNumber = 2; 266 m_packetNumber = 2;
@@ -260,6 +273,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
260 SendMore = SendPacket(client); 273 SendMore = SendPacket(client);
261 m_packetNumber++; 274 m_packetNumber++;
262 } 275 }
276
263 if (m_packetNumber > m_stopPacket) 277 if (m_packetNumber > m_stopPacket)
264 { 278 {
265 279
@@ -339,11 +353,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
339 { 353 {
340 m_discardLevel = m_requestedDiscardLevel; 354 m_discardLevel = m_requestedDiscardLevel;
341 } 355 }
342 356
343 //Calculate the m_stopPacket 357 //Calculate the m_stopPacket
344 if (Layers.Length > 0) 358 if (Layers.Length > 0)
345 { 359 {
346 m_stopPacket = (uint)GetPacketForBytePosition(Layers[(Layers.Length - 1) - m_discardLevel].End); 360 m_stopPacket = (uint)GetPacketForBytePosition(Layers[(Layers.Length - 1) - m_discardLevel].End);
361 //I don't know why, but the viewer seems to expect the final packet if the file
362 //is just one packet bigger.
363 if (TexturePacketCount() == m_stopPacket + 1)
364 {
365 m_stopPacket = TexturePacketCount();
366 }
347 } 367 }
348 else 368 else
349 { 369 {