diff options
author | Teravus Ovares | 2009-03-28 20:50:08 +0000 |
---|---|---|
committer | Teravus Ovares | 2009-03-28 20:50:08 +0000 |
commit | b857635712c2c19c2698850d3844f44f28e998a0 (patch) | |
tree | b64356cec4f3f0aad8f0527c4588cd0f6df7388f /OpenSim | |
parent | Add mute list request event and dummy response (diff) | |
download | opensim-SC_OLD-b857635712c2c19c2698850d3844f44f28e998a0.zip opensim-SC_OLD-b857635712c2c19c2698850d3844f44f28e998a0.tar.gz opensim-SC_OLD-b857635712c2c19c2698850d3844f44f28e998a0.tar.bz2 opensim-SC_OLD-b857635712c2c19c2698850d3844f44f28e998a0.tar.xz |
* Adding some heuristic error correction to the j2k decoder module to combat some of the situations that we see in mantis 3049 .
* This may help people on certain 64 bit systems where the end byte position of each layer data packet is incorrect but the start positions are correct.
* The console will still be extremely chatty with 'Inconsistent packet data in JPEG2000 stream:' messages, however.. if OpenSimulator was able to recover the data, it will say HURISTICS SUCCEEDED
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs | 84 |
1 files changed, 83 insertions, 1 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index 3a1d9a3..3343204 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs | |||
@@ -211,7 +211,89 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
211 | 211 | ||
212 | else | 212 | else |
213 | { | 213 | { |
214 | m_log.WarnFormat("[J2KDecoderModule]: JPEG2000 texture decoding failed for {0}", AssetId); | 214 | /* |
215 | Random rnd = new Random(); | ||
216 | // scramble ends for test | ||
217 | for (int i = 0; i < texture.LayerInfo.Length; i++) | ||
218 | { | ||
219 | texture.LayerInfo[i].End = rnd.Next(999999); | ||
220 | } | ||
221 | */ | ||
222 | |||
223 | // Try to do some heuristics error correction! Yeah. | ||
224 | bool sane2Heuristics = true; | ||
225 | |||
226 | if (texture.LayerInfo.Length == 0) | ||
227 | sane2Heuristics = false; | ||
228 | |||
229 | if (sane2Heuristics) | ||
230 | { | ||
231 | // Last layer start is less then the end of the file and last layer start is greater then 0 | ||
232 | if (texture.LayerInfo[texture.LayerInfo.Length - 1].Start < texture.AssetData.Length && texture.LayerInfo[texture.LayerInfo.Length - 1].Start > 0) | ||
233 | { | ||
234 | } | ||
235 | else | ||
236 | { | ||
237 | sane2Heuristics = false; | ||
238 | } | ||
239 | |||
240 | } | ||
241 | |||
242 | if (sane2Heuristics) | ||
243 | { | ||
244 | int start = 0; | ||
245 | |||
246 | // try to fix it by using consistant data in the start field | ||
247 | for (int i = 0; i < texture.LayerInfo.Length; i++) | ||
248 | { | ||
249 | if (i == 0) | ||
250 | start = 0; | ||
251 | |||
252 | if (i == texture.LayerInfo.Length - 1) | ||
253 | texture.LayerInfo[i].End = texture.AssetData.Length; | ||
254 | else | ||
255 | texture.LayerInfo[i].End = texture.LayerInfo[i + 1].Start - 1; | ||
256 | |||
257 | // in this case, the end of the next packet is less then the start of the last packet | ||
258 | // after we've attempted to fix it which means the start of the last packet is borked | ||
259 | // there's no recovery from this | ||
260 | if (texture.LayerInfo[i].End < start) | ||
261 | { | ||
262 | sane2Heuristics = false; | ||
263 | break; | ||
264 | } | ||
265 | |||
266 | if (texture.LayerInfo[i].End < 0 || texture.LayerInfo[i].End > texture.AssetData.Length) | ||
267 | { | ||
268 | sane2Heuristics = false; | ||
269 | break; | ||
270 | } | ||
271 | |||
272 | if (texture.LayerInfo[i].Start < 0 || texture.LayerInfo[i].Start > texture.AssetData.Length) | ||
273 | { | ||
274 | sane2Heuristics = false; | ||
275 | break; | ||
276 | } | ||
277 | |||
278 | start = texture.LayerInfo[i].Start; | ||
279 | } | ||
280 | } | ||
281 | |||
282 | if (sane2Heuristics) | ||
283 | { | ||
284 | layers = texture.LayerInfo; | ||
285 | fCache.SaveFileCacheForAsset(AssetId, layers); | ||
286 | |||
287 | |||
288 | // Write out decode time | ||
289 | m_log.InfoFormat("[J2KDecoderModule]: HEURISTICS SUCCEEDED {0} Decode Time: {1}", Environment.TickCount - DecodeTime, | ||
290 | AssetId); | ||
291 | |||
292 | } | ||
293 | else | ||
294 | { | ||
295 | m_log.WarnFormat("[J2KDecoderModule]: JPEG2000 texture decoding failed for {0}", AssetId); | ||
296 | } | ||
215 | } | 297 | } |
216 | texture = null; // dereference and dispose of ManagedImage | 298 | texture = null; // dereference and dispose of ManagedImage |
217 | } | 299 | } |