diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index 349d3ac4ba..a1a250176d 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs @@ -133,13 +133,20 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender // Do Decode! if (decode) - DoJ2KDecode(assetID, j2kData); + Decode(assetID, j2kData); } } public bool Decode(UUID assetID, byte[] j2kData) { - return DoJ2KDecode(assetID, j2kData); + OpenJPEG.J2KLayerInfo[] layers; + int components; + return Decode(assetID, j2kData, out layers, out components); + } + + public bool Decode(UUID assetID, byte[] j2kData, out OpenJPEG.J2KLayerInfo[] layers, out int components) + { + return DoJ2KDecode(assetID, j2kData, out layers, out components); } #endregion IJ2KDecoder @@ -149,7 +156,10 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender /// /// UUID of Asset /// JPEG2000 data - private bool DoJ2KDecode(UUID assetID, byte[] j2kData) + /// layer data + /// number of components + /// true if decode was successful. false otherwise. + private bool DoJ2KDecode(UUID assetID, byte[] j2kData, out OpenJPEG.J2KLayerInfo[] layers, out int components) { // m_log.DebugFormat( // "[J2KDecoderModule]: Doing J2K decoding of {0} bytes for asset {1}", j2kData.Length, assetID); @@ -158,7 +168,9 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender //int DecodeTime = 0; //DecodeTime = Environment.TickCount; - OpenJPEG.J2KLayerInfo[] layers; + + // We don't get this from CSJ2K. Is it relevant? + components = 0; if (!TryLoadCacheForAsset(assetID, out layers)) { @@ -198,7 +210,6 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender } else { - int components; if (!OpenJPEG.DecodeLayerBoundaries(j2kData, out layers, out components)) { m_log.Warn("[J2KDecoderModule]: OpenJPEG failed to decode texture " + assetID); diff --git a/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs b/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs index 0964276077..46d03b3742 100644 --- a/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs +++ b/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs @@ -43,5 +43,15 @@ namespace OpenSim.Region.Framework.Interfaces /// /// true if decode was successful. false otherwise. bool Decode(UUID assetID, byte[] j2kData); + + /// + /// Provides a synchronous decode so that caller can be assured that this executes before the next line + /// + /// + /// + /// layer data + /// number of components + /// true if decode was successful. false otherwise. + bool Decode(UUID assetID, byte[] j2kData, out OpenJPEG.J2KLayerInfo[] layers, out int components); } } diff --git a/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs b/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs index b224132fc6..439096a09f 100644 --- a/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs @@ -34,6 +34,7 @@ using log4net; using Mono.Addins; using Nini.Config; using OpenMetaverse; +using OpenMetaverse.Imaging; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Region.Framework.Interfaces; @@ -137,9 +138,18 @@ namespace OpenSim.Region.OptionalModules.Agent.TextureSender return; } - if (decoder.Decode(assetId, asset.Data)) - MainConsole.Instance.OutputFormat("Successfully decoded asset {0}", assetId); + OpenJPEG.J2KLayerInfo[] layers; + int components; + if (decoder.Decode(assetId, asset.Data, out layers, out components)) + { + MainConsole.Instance.OutputFormat( + "Successfully decoded asset {0} with {1} layers and {2} components", + assetId, layers.Length, components); + } else - MainConsole.Instance.OutputFormat("Decode of asset {0} failed", assetId); } + { + MainConsole.Instance.OutputFormat("Decode of asset {0} failed", assetId); + } + } } } \ No newline at end of file