aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJohn Hurliman2010-03-07 17:03:56 -0800
committerJohn Hurliman2010-03-07 17:03:56 -0800
commitfa38cf3ee8caf6efa3004a3c089acb156f677a3e (patch)
tree15f001ae6b2c863e3d58953a7acc2d4ae3aefcad
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-fa38cf3ee8caf6efa3004a3c089acb156f677a3e.zip
opensim-SC_OLD-fa38cf3ee8caf6efa3004a3c089acb156f677a3e.tar.gz
opensim-SC_OLD-fa38cf3ee8caf6efa3004a3c089acb156f677a3e.tar.bz2
opensim-SC_OLD-fa38cf3ee8caf6efa3004a3c089acb156f677a3e.tar.xz
* 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
-rw-r--r--OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs53
1 files 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
144 /// <param name="j2kData">JPEG2000 data</param> 144 /// <param name="j2kData">JPEG2000 data</param>
145 private void DoJ2KDecode(UUID assetID, byte[] j2kData) 145 private void DoJ2KDecode(UUID assetID, byte[] j2kData)
146 { 146 {
147// int DecodeTime = 0; 147 bool USE_CSJ2K = true;
148// DecodeTime = Environment.TickCount; 148
149 //int DecodeTime = 0;
150 //DecodeTime = Environment.TickCount;
149 OpenJPEG.J2KLayerInfo[] layers; 151 OpenJPEG.J2KLayerInfo[] layers;
150 152
151 if (!TryLoadCacheForAsset(assetID, out layers)) 153 if (!TryLoadCacheForAsset(assetID, out layers))
152 { 154 {
153 try 155 if (USE_CSJ2K)
154 { 156 {
155 List<int> layerStarts = CSJ2K.J2kImage.GetLayerBoundaries(new MemoryStream(j2kData)); 157 try
156
157 if (layerStarts != null && layerStarts.Count > 0)
158 { 158 {
159 layers = new OpenJPEG.J2KLayerInfo[layerStarts.Count]; 159 List<int> layerStarts = CSJ2K.J2kImage.GetLayerBoundaries(new MemoryStream(j2kData));
160 160
161 for (int i = 0; i < layerStarts.Count; i++) 161 if (layerStarts != null && layerStarts.Count > 0)
162 { 162 {
163 OpenJPEG.J2KLayerInfo layer = new OpenJPEG.J2KLayerInfo(); 163 layers = new OpenJPEG.J2KLayerInfo[layerStarts.Count];
164 164
165 if (i == 0) 165 for (int i = 0; i < layerStarts.Count; i++)
166 layer.Start = 0; 166 {
167 else 167 OpenJPEG.J2KLayerInfo layer = new OpenJPEG.J2KLayerInfo();
168 layer.Start = layerStarts[i];
169 168
170 if (i == layerStarts.Count - 1) 169 if (i == 0)
171 layer.End = j2kData.Length; 170 layer.Start = 0;
172 else 171 else
173 layer.End = layerStarts[i + 1] - 1; 172 layer.Start = layerStarts[i];
174 173
175 layers[i] = layer; 174 if (i == layerStarts.Count - 1)
175 layer.End = j2kData.Length;
176 else
177 layer.End = layerStarts[i + 1] - 1;
178
179 layers[i] = layer;
180 }
176 } 181 }
177 } 182 }
183 catch (Exception ex)
184 {
185 m_log.Warn("[J2KDecoderModule]: CSJ2K threw an exception decoding texture " + assetID + ": " + ex.Message);
186 }
178 } 187 }
179 catch (Exception ex) 188 else
180 { 189 {
181 m_log.Warn("[J2KDecoderModule]: CSJ2K threw an exception decoding texture " + assetID + ": " + ex.Message); 190 int components;
191 if (!OpenJPEG.DecodeLayerBoundaries(j2kData, out layers, out components))
192 {
193 m_log.Warn("[J2KDecoderModule]: OpenJPEG failed to decode texture " + assetID);
194 }
182 } 195 }
183 196
184 if (layers == null || layers.Length == 0) 197 if (layers == null || layers.Length == 0)