From b86e7715a8d8f081fa9452d92a9d8f6d52867a12 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Jan 2012 22:54:33 +0000 Subject: Improve "j2k decode" command to tell us how many layers and components were decoded, instead of just success/failure --- .../Agent/TextureSender/J2KDecoderModule.cs | 21 ++++++++++++++++----- OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs | 10 ++++++++++ .../Agent/TextureSender/J2KDecoderCommandModule.cs | 16 +++++++++++++--- 3 files changed, 39 insertions(+), 8 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index 349d3ac..a1a2501 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 0964276..46d03b3 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 b224132..439096a 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 -- cgit v1.1