aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Agent
diff options
context:
space:
mode:
authorMelanie2010-03-09 22:46:17 +0000
committerMelanie2010-03-09 22:46:17 +0000
commit40873504dcde19a3738cf4d3a4928a59b811e8f0 (patch)
tree605d2c2575e21496b05eeabd0a5755b8fa788efd /OpenSim/Region/CoreModules/Agent
parent- parcel blocking, region crossing blocking, teleport blocking (diff)
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC-40873504dcde19a3738cf4d3a4928a59b811e8f0.zip
opensim-SC-40873504dcde19a3738cf4d3a4928a59b811e8f0.tar.gz
opensim-SC-40873504dcde19a3738cf4d3a4928a59b811e8f0.tar.bz2
opensim-SC-40873504dcde19a3738cf4d3a4928a59b811e8f0.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/CoreModules/Agent')
-rw-r--r--OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs59
1 files changed, 39 insertions, 20 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
index 50c83b5..1386e86 100644
--- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
@@ -60,6 +60,8 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
60 60
61 #region IRegionModule 61 #region IRegionModule
62 62
63 private bool m_useCSJ2K = true;
64
63 public string Name { get { return "J2KDecoderModule"; } } 65 public string Name { get { return "J2KDecoderModule"; } }
64 public bool IsSharedModule { get { return true; } } 66 public bool IsSharedModule { get { return true; } }
65 67
@@ -73,6 +75,12 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
73 m_scene = scene; 75 m_scene = scene;
74 76
75 scene.RegisterModuleInterface<IJ2KDecoder>(this); 77 scene.RegisterModuleInterface<IJ2KDecoder>(this);
78
79 IConfig startupConfig = source.Configs["Startup"];
80 if (startupConfig != null)
81 {
82 m_useCSJ2K = startupConfig.GetBoolean("UseCSJ2K", m_useCSJ2K);
83 }
76 } 84 }
77 85
78 public void PostInitialise() 86 public void PostInitialise()
@@ -144,41 +152,52 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
144 /// <param name="j2kData">JPEG2000 data</param> 152 /// <param name="j2kData">JPEG2000 data</param>
145 private void DoJ2KDecode(UUID assetID, byte[] j2kData) 153 private void DoJ2KDecode(UUID assetID, byte[] j2kData)
146 { 154 {
147// int DecodeTime = 0; 155 //int DecodeTime = 0;
148// DecodeTime = Environment.TickCount; 156 //DecodeTime = Environment.TickCount;
149 OpenJPEG.J2KLayerInfo[] layers; 157 OpenJPEG.J2KLayerInfo[] layers;
150 158
151 if (!TryLoadCacheForAsset(assetID, out layers)) 159 if (!TryLoadCacheForAsset(assetID, out layers))
152 { 160 {
153 try 161 if (m_useCSJ2K)
154 { 162 {
155 List<int> layerStarts = CSJ2K.J2kImage.GetLayerBoundaries(new MemoryStream(j2kData)); 163 try
156
157 if (layerStarts != null && layerStarts.Count > 0)
158 { 164 {
159 layers = new OpenJPEG.J2KLayerInfo[layerStarts.Count]; 165 List<int> layerStarts = CSJ2K.J2kImage.GetLayerBoundaries(new MemoryStream(j2kData));
160 166
161 for (int i = 0; i < layerStarts.Count; i++) 167 if (layerStarts != null && layerStarts.Count > 0)
162 { 168 {
163 OpenJPEG.J2KLayerInfo layer = new OpenJPEG.J2KLayerInfo(); 169 layers = new OpenJPEG.J2KLayerInfo[layerStarts.Count];
170
171 for (int i = 0; i < layerStarts.Count; i++)
172 {
173 OpenJPEG.J2KLayerInfo layer = new OpenJPEG.J2KLayerInfo();
164 174
165 if (i == 0) 175 if (i == 0)
166 layer.Start = 0; 176 layer.Start = 0;
167 else 177 else
168 layer.Start = layerStarts[i]; 178 layer.Start = layerStarts[i];
169 179
170 if (i == layerStarts.Count - 1) 180 if (i == layerStarts.Count - 1)
171 layer.End = j2kData.Length; 181 layer.End = j2kData.Length;
172 else 182 else
173 layer.End = layerStarts[i + 1] - 1; 183 layer.End = layerStarts[i + 1] - 1;
174 184
175 layers[i] = layer; 185 layers[i] = layer;
186 }
176 } 187 }
177 } 188 }
189 catch (Exception ex)
190 {
191 m_log.Warn("[J2KDecoderModule]: CSJ2K threw an exception decoding texture " + assetID + ": " + ex.Message);
192 }
178 } 193 }
179 catch (Exception ex) 194 else
180 { 195 {
181 m_log.Warn("[J2KDecoderModule]: CSJ2K threw an exception decoding texture " + assetID + ": " + ex.Message); 196 int components;
197 if (!OpenJPEG.DecodeLayerBoundaries(j2kData, out layers, out components))
198 {
199 m_log.Warn("[J2KDecoderModule]: OpenJPEG failed to decode texture " + assetID);
200 }
182 } 201 }
183 202
184 if (layers == null || layers.Length == 0) 203 if (layers == null || layers.Length == 0)