Improve "j2k decode" command to tell us how many layers and components were decoded, instead of just success/failure

iar_mods
Justin Clark-Casey (justincc) 2012-01-05 22:54:33 +00:00
parent 5ea9740f1b
commit b86e7715a8
3 changed files with 39 additions and 8 deletions

View File

@ -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
/// </summary>
/// <param name="assetID">UUID of Asset</param>
/// <param name="j2kData">JPEG2000 data</param>
private bool DoJ2KDecode(UUID assetID, byte[] j2kData)
/// <param name="layers">layer data</param>
/// <param name="components">number of components</param>
/// <returns>true if decode was successful. false otherwise.</returns>
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);

View File

@ -43,5 +43,15 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="j2kData"></param>
/// <returns>true if decode was successful. false otherwise.</returns>
bool Decode(UUID assetID, byte[] j2kData);
/// <summary>
/// Provides a synchronous decode so that caller can be assured that this executes before the next line
/// </summary>
/// <param name="assetID"></param>
/// <param name="j2kData"></param>
/// <param name="layers">layer data</param>
/// <param name="components">number of components</param>
/// <returns>true if decode was successful. false otherwise.</returns>
bool Decode(UUID assetID, byte[] j2kData, out OpenJPEG.J2KLayerInfo[] layers, out int components);
}
}

View File

@ -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);
}
}
}
}