diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Agent/TextureSender')
-rw-r--r-- | OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index 7dd9087..349d3ac 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs | |||
@@ -103,6 +103,10 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
103 | // If it's cached, return the cached results | 103 | // If it's cached, return the cached results |
104 | if (m_decodedCache.TryGetValue(assetID, out result)) | 104 | if (m_decodedCache.TryGetValue(assetID, out result)) |
105 | { | 105 | { |
106 | // m_log.DebugFormat( | ||
107 | // "[J2KDecoderModule]: Returning existing cached {0} layers j2k decode for {1}", | ||
108 | // result.Length, assetID); | ||
109 | |||
106 | callback(assetID, result); | 110 | callback(assetID, result); |
107 | } | 111 | } |
108 | else | 112 | else |
@@ -133,14 +137,9 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
133 | } | 137 | } |
134 | } | 138 | } |
135 | 139 | ||
136 | /// <summary> | 140 | public bool Decode(UUID assetID, byte[] j2kData) |
137 | /// Provides a synchronous decode so that caller can be assured that this executes before the next line | ||
138 | /// </summary> | ||
139 | /// <param name="assetID"></param> | ||
140 | /// <param name="j2kData"></param> | ||
141 | public void Decode(UUID assetID, byte[] j2kData) | ||
142 | { | 141 | { |
143 | DoJ2KDecode(assetID, j2kData); | 142 | return DoJ2KDecode(assetID, j2kData); |
144 | } | 143 | } |
145 | 144 | ||
146 | #endregion IJ2KDecoder | 145 | #endregion IJ2KDecoder |
@@ -150,11 +149,13 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
150 | /// </summary> | 149 | /// </summary> |
151 | /// <param name="assetID">UUID of Asset</param> | 150 | /// <param name="assetID">UUID of Asset</param> |
152 | /// <param name="j2kData">JPEG2000 data</param> | 151 | /// <param name="j2kData">JPEG2000 data</param> |
153 | private void DoJ2KDecode(UUID assetID, byte[] j2kData) | 152 | private bool DoJ2KDecode(UUID assetID, byte[] j2kData) |
154 | { | 153 | { |
155 | // m_log.DebugFormat( | 154 | // m_log.DebugFormat( |
156 | // "[J2KDecoderModule]: Doing J2K decoding of {0} bytes for asset {1}", j2kData.Length, assetID); | 155 | // "[J2KDecoderModule]: Doing J2K decoding of {0} bytes for asset {1}", j2kData.Length, assetID); |
157 | 156 | ||
157 | bool decodedSuccessfully = true; | ||
158 | |||
158 | //int DecodeTime = 0; | 159 | //int DecodeTime = 0; |
159 | //DecodeTime = Environment.TickCount; | 160 | //DecodeTime = Environment.TickCount; |
160 | OpenJPEG.J2KLayerInfo[] layers; | 161 | OpenJPEG.J2KLayerInfo[] layers; |
@@ -192,6 +193,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
192 | catch (Exception ex) | 193 | catch (Exception ex) |
193 | { | 194 | { |
194 | m_log.Warn("[J2KDecoderModule]: CSJ2K threw an exception decoding texture " + assetID + ": " + ex.Message); | 195 | m_log.Warn("[J2KDecoderModule]: CSJ2K threw an exception decoding texture " + assetID + ": " + ex.Message); |
196 | decodedSuccessfully = false; | ||
195 | } | 197 | } |
196 | } | 198 | } |
197 | else | 199 | else |
@@ -200,6 +202,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
200 | if (!OpenJPEG.DecodeLayerBoundaries(j2kData, out layers, out components)) | 202 | if (!OpenJPEG.DecodeLayerBoundaries(j2kData, out layers, out components)) |
201 | { | 203 | { |
202 | m_log.Warn("[J2KDecoderModule]: OpenJPEG failed to decode texture " + assetID); | 204 | m_log.Warn("[J2KDecoderModule]: OpenJPEG failed to decode texture " + assetID); |
205 | decodedSuccessfully = false; | ||
203 | } | 206 | } |
204 | } | 207 | } |
205 | 208 | ||
@@ -208,6 +211,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
208 | m_log.Warn("[J2KDecoderModule]: Failed to decode layer data for texture " + assetID + ", guessing sane defaults"); | 211 | m_log.Warn("[J2KDecoderModule]: Failed to decode layer data for texture " + assetID + ", guessing sane defaults"); |
209 | // Layer decoding completely failed. Guess at sane defaults for the layer boundaries | 212 | // Layer decoding completely failed. Guess at sane defaults for the layer boundaries |
210 | layers = CreateDefaultLayers(j2kData.Length); | 213 | layers = CreateDefaultLayers(j2kData.Length); |
214 | decodedSuccessfully = false; | ||
211 | } | 215 | } |
212 | 216 | ||
213 | // Cache Decoded layers | 217 | // Cache Decoded layers |
@@ -227,6 +231,8 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
227 | m_notifyList.Remove(assetID); | 231 | m_notifyList.Remove(assetID); |
228 | } | 232 | } |
229 | } | 233 | } |
234 | |||
235 | return decodedSuccessfully; | ||
230 | } | 236 | } |
231 | 237 | ||
232 | private OpenJPEG.J2KLayerInfo[] CreateDefaultLayers(int j2kLength) | 238 | private OpenJPEG.J2KLayerInfo[] CreateDefaultLayers(int j2kLength) |