From fa38cf3ee8caf6efa3004a3c089acb156f677a3e Mon Sep 17 00:00:00 2001
From: John Hurliman
Date: Sun, 7 Mar 2010 17:03:56 -0800
Subject: * Added code to support either CSJ2K or OpenJPEG texture decoding.
Currently hardcoded to CSJ2K (so no functional change) but this could easily
be switched to a config option
---
.../Agent/TextureSender/J2KDecoderModule.cs | 53 ++++++++++++++--------
1 file changed, 33 insertions(+), 20 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
index 50c83b5..5b022ac 100644
--- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
@@ -144,41 +144,54 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
/// JPEG2000 data
private void DoJ2KDecode(UUID assetID, byte[] j2kData)
{
-// int DecodeTime = 0;
-// DecodeTime = Environment.TickCount;
+ bool USE_CSJ2K = true;
+
+ //int DecodeTime = 0;
+ //DecodeTime = Environment.TickCount;
OpenJPEG.J2KLayerInfo[] layers;
if (!TryLoadCacheForAsset(assetID, out layers))
{
- try
+ if (USE_CSJ2K)
{
- List layerStarts = CSJ2K.J2kImage.GetLayerBoundaries(new MemoryStream(j2kData));
-
- if (layerStarts != null && layerStarts.Count > 0)
+ try
{
- layers = new OpenJPEG.J2KLayerInfo[layerStarts.Count];
+ List layerStarts = CSJ2K.J2kImage.GetLayerBoundaries(new MemoryStream(j2kData));
- for (int i = 0; i < layerStarts.Count; i++)
+ if (layerStarts != null && layerStarts.Count > 0)
{
- OpenJPEG.J2KLayerInfo layer = new OpenJPEG.J2KLayerInfo();
+ layers = new OpenJPEG.J2KLayerInfo[layerStarts.Count];
- if (i == 0)
- layer.Start = 0;
- else
- layer.Start = layerStarts[i];
+ for (int i = 0; i < layerStarts.Count; i++)
+ {
+ OpenJPEG.J2KLayerInfo layer = new OpenJPEG.J2KLayerInfo();
- if (i == layerStarts.Count - 1)
- layer.End = j2kData.Length;
- else
- layer.End = layerStarts[i + 1] - 1;
+ if (i == 0)
+ layer.Start = 0;
+ else
+ layer.Start = layerStarts[i];
- layers[i] = layer;
+ if (i == layerStarts.Count - 1)
+ layer.End = j2kData.Length;
+ else
+ layer.End = layerStarts[i + 1] - 1;
+
+ layers[i] = layer;
+ }
}
}
+ catch (Exception ex)
+ {
+ m_log.Warn("[J2KDecoderModule]: CSJ2K threw an exception decoding texture " + assetID + ": " + ex.Message);
+ }
}
- catch (Exception ex)
+ else
{
- m_log.Warn("[J2KDecoderModule]: CSJ2K threw an exception decoding texture " + assetID + ": " + ex.Message);
+ int components;
+ if (!OpenJPEG.DecodeLayerBoundaries(j2kData, out layers, out components))
+ {
+ m_log.Warn("[J2KDecoderModule]: OpenJPEG failed to decode texture " + assetID);
+ }
}
if (layers == null || layers.Length == 0)
--
cgit v1.1