mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
Some minor fixes
This commit is contained in:
parent
b0a051fc47
commit
55406553f6
@ -91,9 +91,7 @@ namespace AssetStudio
|
|||||||
|
|
||||||
public void LoadFilesAndFolders(params string[] path)
|
public void LoadFilesAndFolders(params string[] path)
|
||||||
{
|
{
|
||||||
var pathList = new List<string>();
|
LoadFilesAndFolders(out _, path);
|
||||||
pathList.AddRange(path);
|
|
||||||
LoadFilesAndFolders(out _, pathList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadFilesAndFolders(out string parentPath, params string[] path)
|
public void LoadFilesAndFolders(out string parentPath, params string[] path)
|
||||||
@ -106,15 +104,15 @@ namespace AssetStudio
|
|||||||
public void LoadFilesAndFolders(out string parentPath, List<string> pathList)
|
public void LoadFilesAndFolders(out string parentPath, List<string> pathList)
|
||||||
{
|
{
|
||||||
var fileList = new List<string>();
|
var fileList = new List<string>();
|
||||||
bool filesInPath = false;
|
var filesInPath = false;
|
||||||
parentPath = "";
|
parentPath = "";
|
||||||
foreach (var path in pathList)
|
foreach (var path in pathList)
|
||||||
{
|
{
|
||||||
var fullPath = Path.GetFullPath(path);
|
var fullPath = Path.GetFullPath(path);
|
||||||
if (Directory.Exists(fullPath))
|
if (Directory.Exists(fullPath))
|
||||||
{
|
{
|
||||||
var parent = Directory.GetParent(fullPath).FullName;
|
var parent = Directory.GetParent(fullPath)?.FullName;
|
||||||
if (!filesInPath && (parentPath == "" || parentPath.Length > parent.Length))
|
if (!filesInPath && (parentPath == "" || parentPath?.Length > parent?.Length))
|
||||||
{
|
{
|
||||||
parentPath = parent;
|
parentPath = parent;
|
||||||
}
|
}
|
||||||
@ -241,6 +239,7 @@ namespace AssetStudio
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
noexistFiles.Add(sharedFilePath);
|
noexistFiles.Add(sharedFilePath);
|
||||||
|
Logger.Warning($"Dependency wasn't found: {sharedFilePath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -399,6 +399,8 @@ namespace AssetStudio
|
|||||||
|
|
||||||
private void ReadBlocks(FileReader reader, CompressionType customBlockCompression, Stream blocksStream)
|
private void ReadBlocks(FileReader reader, CompressionType customBlockCompression, Stream blocksStream)
|
||||||
{
|
{
|
||||||
|
Logger.Debug($"Block compression: {(CompressionType)m_BlocksInfo.Max(x => x.flags)}");
|
||||||
|
|
||||||
var showCustomTypeWarning = true;
|
var showCustomTypeWarning = true;
|
||||||
foreach (var blockInfo in m_BlocksInfo)
|
foreach (var blockInfo in m_BlocksInfo)
|
||||||
{
|
{
|
||||||
@ -420,7 +422,6 @@ namespace AssetStudio
|
|||||||
showCustomTypeWarning = false;
|
showCustomTypeWarning = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Logger.Debug($"Block compression: {compressionType}");
|
|
||||||
|
|
||||||
long numWrite;
|
long numWrite;
|
||||||
var errorMsg = string.Empty;
|
var errorMsg = string.Empty;
|
||||||
|
@ -68,7 +68,7 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
catch (System.Exception e)
|
catch (System.Exception e)
|
||||||
{
|
{
|
||||||
Logger.Warning($"Error while decompressing gzip file {reader.FullPath}\r\n{e}");
|
Logger.Warning($"Error while decompressing Gzip file {reader.FullPath}\n{e}");
|
||||||
reader.Dispose();
|
reader.Dispose();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -76,15 +76,24 @@ namespace AssetStudio
|
|||||||
|
|
||||||
public static FileReader DecompressBrotli(FileReader reader)
|
public static FileReader DecompressBrotli(FileReader reader)
|
||||||
{
|
{
|
||||||
using (reader)
|
try
|
||||||
{
|
{
|
||||||
var stream = new MemoryStream();
|
using (reader)
|
||||||
using (var brotliStream = new BrotliInputStream(reader.BaseStream))
|
|
||||||
{
|
{
|
||||||
brotliStream.CopyTo(stream);
|
var stream = new MemoryStream();
|
||||||
|
using (var brotliStream = new BrotliInputStream(reader.BaseStream))
|
||||||
|
{
|
||||||
|
brotliStream.CopyTo(stream);
|
||||||
|
}
|
||||||
|
stream.Position = 0;
|
||||||
|
return new FileReader(reader.FullPath, stream);
|
||||||
}
|
}
|
||||||
stream.Position = 0;
|
}
|
||||||
return new FileReader(reader.FullPath, stream);
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
Logger.Warning($"Error while decompressing Brotli file {reader.FullPath}\n{e}");
|
||||||
|
reader.Dispose();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,15 +84,16 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetData(byte[] buff, out int read, int startIndex = 0)
|
public int GetData(byte[] buff, int startIndex = 0)
|
||||||
{
|
{
|
||||||
read = -1;
|
int dataLen;
|
||||||
var binaryReader = GetReader();
|
var binaryReader = GetReader();
|
||||||
lock (binaryReader)
|
lock (binaryReader)
|
||||||
{
|
{
|
||||||
binaryReader.BaseStream.Position = Offset;
|
binaryReader.BaseStream.Position = Offset;
|
||||||
read = binaryReader.Read(buff, startIndex, (int)size);
|
dataLen = binaryReader.Read(buff, startIndex, (int)size);
|
||||||
}
|
}
|
||||||
|
return dataLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WriteData(string path)
|
public void WriteData(string path)
|
||||||
|
@ -29,11 +29,11 @@ namespace AssetStudio
|
|||||||
var m_Nodes = m_Type.m_Nodes;
|
var m_Nodes = m_Type.m_Nodes;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_Nodes.Count; i++)
|
for (var i = 0; i < m_Nodes.Count; i++)
|
||||||
{
|
{
|
||||||
ReadStringValue(sb, m_Nodes, reader, ref i);
|
ReadStringValue(sb, m_Nodes, reader, ref i);
|
||||||
|
readed = reader.Position - reader.byteStart;
|
||||||
}
|
}
|
||||||
readed = reader.Position - reader.byteStart;
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@ -206,8 +206,8 @@ namespace AssetStudio
|
|||||||
var m_Node = m_Nodes[i];
|
var m_Node = m_Nodes[i];
|
||||||
var varNameStr = m_Node.m_Name;
|
var varNameStr = m_Node.m_Name;
|
||||||
obj[varNameStr] = ReadValue(m_Nodes, reader, ref i);
|
obj[varNameStr] = ReadValue(m_Nodes, reader, ref i);
|
||||||
|
readed = reader.Position - reader.byteStart;
|
||||||
}
|
}
|
||||||
readed = reader.Position - reader.byteStart;
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
@ -1007,7 +1007,7 @@ namespace AssetStudioCLI.Options
|
|||||||
switch (value.ToLower())
|
switch (value.ToLower())
|
||||||
{
|
{
|
||||||
case "auto":
|
case "auto":
|
||||||
o_bundleBlockInfoCompression.Value = CompressionType.Zstd;
|
o_bundleBlockInfoCompression.Value = CompressionType.Auto;
|
||||||
break;
|
break;
|
||||||
case "zstd":
|
case "zstd":
|
||||||
o_bundleBlockInfoCompression.Value = CompressionType.Zstd;
|
o_bundleBlockInfoCompression.Value = CompressionType.Zstd;
|
||||||
@ -1032,7 +1032,7 @@ namespace AssetStudioCLI.Options
|
|||||||
switch (value.ToLower())
|
switch (value.ToLower())
|
||||||
{
|
{
|
||||||
case "auto":
|
case "auto":
|
||||||
o_bundleBlockCompression.Value = CompressionType.Zstd;
|
o_bundleBlockCompression.Value = CompressionType.Auto;
|
||||||
break;
|
break;
|
||||||
case "zstd":
|
case "zstd":
|
||||||
o_bundleBlockCompression.Value = CompressionType.Zstd;
|
o_bundleBlockCompression.Value = CompressionType.Zstd;
|
||||||
|
@ -97,13 +97,13 @@ namespace AssetStudioCLI
|
|||||||
public static bool ExportAudioClip(AssetItem item, string exportPath, out string debugLog)
|
public static bool ExportAudioClip(AssetItem item, string exportPath, out string debugLog)
|
||||||
{
|
{
|
||||||
debugLog = string.Empty;
|
debugLog = string.Empty;
|
||||||
string exportFullPath;
|
|
||||||
var m_AudioClip = (AudioClip)item.Asset;
|
var m_AudioClip = (AudioClip)item.Asset;
|
||||||
var m_AudioData = BigArrayPool<byte>.Shared.Rent(m_AudioClip.m_AudioData.Size);
|
var m_AudioData = BigArrayPool<byte>.Shared.Rent(m_AudioClip.m_AudioData.Size);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_AudioClip.m_AudioData.GetData(m_AudioData, out var read);
|
string exportFullPath;
|
||||||
if (read <= 0)
|
var dataLen = m_AudioClip.m_AudioData.GetData(m_AudioData);
|
||||||
|
if (dataLen <= 0)
|
||||||
{
|
{
|
||||||
Logger.Error($"Export error. \"{item.Text}\": AudioData was not found");
|
Logger.Error($"Export error. \"{item.Text}\": AudioData was not found");
|
||||||
return false;
|
return false;
|
||||||
|
@ -738,7 +738,7 @@ namespace AssetStudioCLI
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error($"{asset.SourceFile.originalPath}: [{$"{asset.Type}: {asset.Text}".Color(Ansi.BrightRed)}] : Export error\n{ex}");
|
Logger.Error($"{asset.SourceFile.originalPath ?? asset.SourceFile.fullName}: [{$"{asset.Type}: {asset.Text}".Color(Ansi.BrightRed)}] : Export error\n{ex}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isExported)
|
if (isExported)
|
||||||
@ -763,7 +763,7 @@ namespace AssetStudioCLI
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error($"{asset.SourceFile.originalPath}: [{$"{asset.Type}: {asset.Text}".Color(Ansi.BrightRed)}] : Export error\n{ex}");
|
Logger.Error($"{asset.SourceFile.originalPath ?? asset.SourceFile.fullName}: [{$"{asset.Type}: {asset.Text}".Color(Ansi.BrightRed)}] : Export error\n{ex}");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ParallelExporter.ClearHash();
|
ParallelExporter.ClearHash();
|
||||||
@ -1084,7 +1084,10 @@ namespace AssetStudioCLI
|
|||||||
{
|
{
|
||||||
foreach (var assetKvp in containers)
|
foreach (var assetKvp in containers)
|
||||||
{
|
{
|
||||||
l2dContainers[assetKvp.Key] = Path.GetFileName(assetKvp.Key.assetsFile.originalPath);
|
var container = string.IsNullOrEmpty(assetKvp.Key.assetsFile.originalPath)
|
||||||
|
? assetKvp.Key.assetsFile.fullName
|
||||||
|
: assetKvp.Key.assetsFile.originalPath;
|
||||||
|
l2dContainers[assetKvp.Key] = container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var mocPathDict = GenerateMocPathDict(mocDict, l2dContainers, searchByFilename);
|
var mocPathDict = GenerateMocPathDict(mocDict, l2dContainers, searchByFilename);
|
||||||
@ -1141,16 +1144,19 @@ namespace AssetStudioCLI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var cubismExtractor = new Live2DExtractor(assetGroupKvp);
|
var cubismExtractor = new Live2DExtractor(assetGroupKvp);
|
||||||
|
var filename = string.IsNullOrEmpty(cubismExtractor.MocMono.assetsFile.originalPath)
|
||||||
|
? Path.GetFileNameWithoutExtension(cubismExtractor.MocMono.assetsFile.fileName)
|
||||||
|
: Path.GetFileNameWithoutExtension(cubismExtractor.MocMono.assetsFile.originalPath);
|
||||||
string modelPath;
|
string modelPath;
|
||||||
switch (modelGroupOption)
|
switch (modelGroupOption)
|
||||||
{
|
{
|
||||||
case Live2DModelGroupOption.SourceFileName:
|
case Live2DModelGroupOption.SourceFileName:
|
||||||
modelPath = Path.GetFileNameWithoutExtension(cubismExtractor.MocMono.assetsFile.originalPath);
|
modelPath = filename;
|
||||||
break;
|
break;
|
||||||
case Live2DModelGroupOption.ModelName:
|
case Live2DModelGroupOption.ModelName:
|
||||||
modelPath = !string.IsNullOrEmpty(cubismExtractor.Model?.Name)
|
modelPath = !string.IsNullOrEmpty(cubismExtractor.Model?.Name)
|
||||||
? cubismExtractor.Model.Name
|
? cubismExtractor.Model.Name
|
||||||
: Path.GetFileNameWithoutExtension(cubismExtractor.MocMono.assetsFile.originalPath);
|
: filename;
|
||||||
break;
|
break;
|
||||||
default: //ContainerPath
|
default: //ContainerPath
|
||||||
var container = searchByFilename && cubismExtractor.Model != null
|
var container = searchByFilename && cubismExtractor.Model != null
|
||||||
|
4
AssetStudioGUI/AssetStudioGUIForm.Designer.cs
generated
4
AssetStudioGUI/AssetStudioGUIForm.Designer.cs
generated
@ -298,8 +298,8 @@
|
|||||||
this.useAssetLoadingViaTypetreeToolStripMenuItem.Name = "useAssetLoadingViaTypetreeToolStripMenuItem";
|
this.useAssetLoadingViaTypetreeToolStripMenuItem.Name = "useAssetLoadingViaTypetreeToolStripMenuItem";
|
||||||
this.useAssetLoadingViaTypetreeToolStripMenuItem.Size = new System.Drawing.Size(241, 22);
|
this.useAssetLoadingViaTypetreeToolStripMenuItem.Size = new System.Drawing.Size(241, 22);
|
||||||
this.useAssetLoadingViaTypetreeToolStripMenuItem.Text = "Parse assets using their typetree";
|
this.useAssetLoadingViaTypetreeToolStripMenuItem.Text = "Parse assets using their typetree";
|
||||||
this.useAssetLoadingViaTypetreeToolStripMenuItem.ToolTipText = "(Applies to assets with typetree included). Slower but more correct parsing. Only" +
|
this.useAssetLoadingViaTypetreeToolStripMenuItem.ToolTipText = "(Applies to assets with typetree included). Slower but can parse non-standard ass" +
|
||||||
" for Texture2D and AnimationClip assets for now.";
|
"ets. Only for Texture2D, AnimationClip and Material assets for now.";
|
||||||
this.useAssetLoadingViaTypetreeToolStripMenuItem.CheckedChanged += new System.EventHandler(this.useAssetLoadingViaTypetreeToolStripMenuItem_CheckedChanged);
|
this.useAssetLoadingViaTypetreeToolStripMenuItem.CheckedChanged += new System.EventHandler(this.useAssetLoadingViaTypetreeToolStripMenuItem_CheckedChanged);
|
||||||
//
|
//
|
||||||
// assetLoadingToolStripSeparator
|
// assetLoadingToolStripSeparator
|
||||||
|
@ -1123,8 +1123,8 @@ namespace AssetStudioGUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
soundBuff = BigArrayPool<byte>.Shared.Rent(m_AudioClip.m_AudioData.Size);
|
soundBuff = BigArrayPool<byte>.Shared.Rent(m_AudioClip.m_AudioData.Size);
|
||||||
m_AudioClip.m_AudioData.GetData(soundBuff, out var read);
|
var dataLen = m_AudioClip.m_AudioData.GetData(soundBuff);
|
||||||
if (read <= 0)
|
if (dataLen <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var exinfo = new FMOD.CREATESOUNDEXINFO();
|
var exinfo = new FMOD.CREATESOUNDEXINFO();
|
||||||
@ -1550,6 +1550,9 @@ namespace AssetStudioGUI
|
|||||||
|
|
||||||
private void ResetForm()
|
private void ResetForm()
|
||||||
{
|
{
|
||||||
|
if (Studio.assetsManager.assetsFileList.Count > 0)
|
||||||
|
Logger.Info("Resetting program...");
|
||||||
|
|
||||||
Text = guiTitle;
|
Text = guiTitle;
|
||||||
Studio.assetsManager.Clear();
|
Studio.assetsManager.Clear();
|
||||||
Studio.assemblyLoader.Clear();
|
Studio.assemblyLoader.Clear();
|
||||||
|
@ -95,14 +95,14 @@ namespace AssetStudioGUI
|
|||||||
|
|
||||||
public static bool ExportAudioClip(AssetItem item, string exportPath, out string debugLog)
|
public static bool ExportAudioClip(AssetItem item, string exportPath, out string debugLog)
|
||||||
{
|
{
|
||||||
debugLog = "";
|
debugLog = string.Empty;
|
||||||
string exportFullPath;
|
|
||||||
var m_AudioClip = (AudioClip)item.Asset;
|
var m_AudioClip = (AudioClip)item.Asset;
|
||||||
var m_AudioData = BigArrayPool<byte>.Shared.Rent(m_AudioClip.m_AudioData.Size);
|
var m_AudioData = BigArrayPool<byte>.Shared.Rent(m_AudioClip.m_AudioData.Size);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_AudioClip.m_AudioData.GetData(m_AudioData, out var read);
|
string exportFullPath;
|
||||||
if (read <= 0)
|
var dataLen = m_AudioClip.m_AudioData.GetData(m_AudioData);
|
||||||
|
if (dataLen <= 0)
|
||||||
{
|
{
|
||||||
Logger.Warning($"Failed to export \"{item.Text}\": AudioData was not found");
|
Logger.Warning($"Failed to export \"{item.Text}\": AudioData was not found");
|
||||||
return false;
|
return false;
|
||||||
|
@ -1182,7 +1182,10 @@ namespace AssetStudioGUI
|
|||||||
{
|
{
|
||||||
foreach (var assetKvp in l2dAssetContainers)
|
foreach (var assetKvp in l2dAssetContainers)
|
||||||
{
|
{
|
||||||
l2dContainers[assetKvp.Key] = Path.GetFileName(assetKvp.Key.assetsFile.originalPath);
|
var container = string.IsNullOrEmpty(assetKvp.Key.assetsFile.originalPath)
|
||||||
|
? assetKvp.Key.assetsFile.fullName
|
||||||
|
: assetKvp.Key.assetsFile.originalPath;
|
||||||
|
l2dContainers[assetKvp.Key] = container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var mocPathDict = GenerateMocPathDict(mocDict, l2dContainers, searchByFilename);
|
var mocPathDict = GenerateMocPathDict(mocDict, l2dContainers, searchByFilename);
|
||||||
@ -1243,16 +1246,19 @@ namespace AssetStudioGUI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var cubismExtractor = new Live2DExtractor(assetGroupKvp, selClipMotions, selFadeMotions, selFadeLst);
|
var cubismExtractor = new Live2DExtractor(assetGroupKvp, selClipMotions, selFadeMotions, selFadeLst);
|
||||||
|
var filename = string.IsNullOrEmpty(cubismExtractor.MocMono.assetsFile.originalPath)
|
||||||
|
? Path.GetFileNameWithoutExtension(cubismExtractor.MocMono.assetsFile.fileName)
|
||||||
|
: Path.GetFileNameWithoutExtension(cubismExtractor.MocMono.assetsFile.originalPath);
|
||||||
string modelPath;
|
string modelPath;
|
||||||
switch (modelGroupOption)
|
switch (modelGroupOption)
|
||||||
{
|
{
|
||||||
case Live2DModelGroupOption.SourceFileName:
|
case Live2DModelGroupOption.SourceFileName:
|
||||||
modelPath = Path.GetFileNameWithoutExtension(cubismExtractor.MocMono.assetsFile.originalPath);
|
modelPath = filename;
|
||||||
break;
|
break;
|
||||||
case Live2DModelGroupOption.ModelName:
|
case Live2DModelGroupOption.ModelName:
|
||||||
modelPath = !string.IsNullOrEmpty(cubismExtractor.Model?.Name)
|
modelPath = !string.IsNullOrEmpty(cubismExtractor.Model?.Name)
|
||||||
? cubismExtractor.Model.Name
|
? cubismExtractor.Model.Name
|
||||||
: Path.GetFileNameWithoutExtension(cubismExtractor.MocMono.assetsFile.originalPath);
|
: filename;
|
||||||
break;
|
break;
|
||||||
default: //ContainerPath
|
default: //ContainerPath
|
||||||
var container = searchByFilename && cubismExtractor.Model != null
|
var container = searchByFilename && cubismExtractor.Model != null
|
||||||
|
@ -130,8 +130,8 @@ namespace AssetStudio
|
|||||||
|
|
||||||
debugLog += "[Legacy wav converter] Generating wav header..\n";
|
debugLog += "[Legacy wav converter] Generating wav header..\n";
|
||||||
var buffer = new byte[audioSize + 44];
|
var buffer = new byte[audioSize + 44];
|
||||||
m_AudioClip.m_AudioData.GetData(buffer, out var read, 44);
|
var dataLen = m_AudioClip.m_AudioData.GetData(buffer, 44);
|
||||||
if (read > 0)
|
if (dataLen > 0)
|
||||||
{
|
{
|
||||||
var wavHeader = new WavHeader(audioSize, audioFormat, channels, (uint)sampleRate, bits);
|
var wavHeader = new WavHeader(audioSize, audioFormat, channels, (uint)sampleRate, bits);
|
||||||
wavHeader.WriteToArray(buffer);
|
wavHeader.WriteToArray(buffer);
|
||||||
@ -141,16 +141,16 @@ namespace AssetStudio
|
|||||||
|
|
||||||
private static void ReadAsPcm16(IntPtr srcPtr, byte[] destBuffer, int offset, uint pcmDataLen, ref string debugLog)
|
private static void ReadAsPcm16(IntPtr srcPtr, byte[] destBuffer, int offset, uint pcmDataLen, ref string debugLog)
|
||||||
{
|
{
|
||||||
var pcmFloatSample = new byte[4];
|
var pcmFloatVal = new byte[4];
|
||||||
for (var i = 0; i < pcmDataLen; i += 4)
|
for (var i = 0; i < pcmDataLen; i += 4)
|
||||||
{
|
{
|
||||||
for (var j = 0; j < 4; j++)
|
for (var j = 0; j < 4; j++)
|
||||||
{
|
{
|
||||||
pcmFloatSample[j] = Marshal.ReadByte(srcPtr, i + j);
|
pcmFloatVal[j] = Marshal.ReadByte(srcPtr, i + j);
|
||||||
}
|
}
|
||||||
var pcm16Sample = (short)MathHelper.Clamp(BitConverter.ToSingle(pcmFloatSample, 0) * short.MaxValue, short.MinValue, short.MaxValue);
|
var pcm16Val = (short)MathHelper.Clamp(BitConverter.ToSingle(pcmFloatVal, 0) * short.MaxValue, short.MinValue, short.MaxValue);
|
||||||
destBuffer[offset] = (byte)(pcm16Sample & 255);
|
destBuffer[offset] = (byte)(pcm16Val & 255);
|
||||||
destBuffer[offset + 1] = (byte)(pcm16Sample >> 8);
|
destBuffer[offset + 1] = (byte)(pcm16Val >> 8);
|
||||||
offset += 2;
|
offset += 2;
|
||||||
}
|
}
|
||||||
debugLog += "Finished PCMFLOAT -> PCM16 converting\n";
|
debugLog += "Finished PCMFLOAT -> PCM16 converting\n";
|
||||||
|
@ -89,7 +89,7 @@ namespace AssetStudio
|
|||||||
var buff = BigArrayPool<byte>.Shared.Rent(reader.Size);
|
var buff = BigArrayPool<byte>.Shared.Rent(reader.Size);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
reader.GetData(buff, out _);
|
_ = reader.GetData(buff);
|
||||||
if (switchSwizzled)
|
if (switchSwizzled)
|
||||||
{
|
{
|
||||||
var unswizzledData = BigArrayPool<byte>.Shared.Rent(reader.Size);
|
var unswizzledData = BigArrayPool<byte>.Shared.Rent(reader.Size);
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
using SixLabors.ImageSharp;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using SixLabors.ImageSharp;
|
||||||
using SixLabors.ImageSharp.PixelFormats;
|
using SixLabors.ImageSharp.PixelFormats;
|
||||||
using SixLabors.ImageSharp.Processing;
|
using SixLabors.ImageSharp.Processing;
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace AssetStudio
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
@ -10,8 +11,8 @@ namespace AssetStudio
|
|||||||
public static Image<Bgra32> ConvertToImage(this Texture2D m_Texture2D, bool flip)
|
public static Image<Bgra32> ConvertToImage(this Texture2D m_Texture2D, bool flip)
|
||||||
{
|
{
|
||||||
var converter = new Texture2DConverter(m_Texture2D);
|
var converter = new Texture2DConverter(m_Texture2D);
|
||||||
var uncroppedSize = converter.GetUncroppedSize();
|
|
||||||
var buff = BigArrayPool<byte>.Shared.Rent(converter.OutputDataSize);
|
var buff = BigArrayPool<byte>.Shared.Rent(converter.OutputDataSize);
|
||||||
|
var spanBuff = buff.AsSpan(0, converter.OutputDataSize);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!converter.DecodeTexture2D(buff))
|
if (!converter.DecodeTexture2D(buff))
|
||||||
@ -20,12 +21,13 @@ namespace AssetStudio
|
|||||||
Image<Bgra32> image;
|
Image<Bgra32> image;
|
||||||
if (converter.UsesSwitchSwizzle)
|
if (converter.UsesSwitchSwizzle)
|
||||||
{
|
{
|
||||||
image = Image.LoadPixelData<Bgra32>(buff, uncroppedSize.Width, uncroppedSize.Height);
|
var uncroppedSize = converter.GetUncroppedSize();
|
||||||
|
image = Image.LoadPixelData<Bgra32>(spanBuff, uncroppedSize.Width, uncroppedSize.Height);
|
||||||
image.Mutate(x => x.Crop(m_Texture2D.m_Width, m_Texture2D.m_Height));
|
image.Mutate(x => x.Crop(m_Texture2D.m_Width, m_Texture2D.m_Height));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
image = Image.LoadPixelData<Bgra32>(buff, m_Texture2D.m_Width, m_Texture2D.m_Height);
|
image = Image.LoadPixelData<Bgra32>(spanBuff, m_Texture2D.m_Width, m_Texture2D.m_Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flip)
|
if (flip)
|
||||||
|
@ -43,7 +43,7 @@ namespace AssetStudio
|
|||||||
return (a + b - 1) / b;
|
return (a + b - 1) / b;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void Unswizzle(byte[] data, Size imageSize, Size blockSize, int gobsPerBlock, byte[] newData)
|
internal static void Unswizzle(ReadOnlySpan<byte> data, Size imageSize, Size blockSize, int gobsPerBlock, Span<byte> newData)
|
||||||
{
|
{
|
||||||
int width = imageSize.Width;
|
int width = imageSize.Width;
|
||||||
int height = imageSize.Height;
|
int height = imageSize.Height;
|
||||||
@ -69,7 +69,7 @@ namespace AssetStudio
|
|||||||
int gobDstY = (i * gobsPerBlock + k) * GOB_Y_TEXEL_COUNT + gobY;
|
int gobDstY = (i * gobsPerBlock + k) * GOB_Y_TEXEL_COUNT + gobY;
|
||||||
int gobDstLinPos = gobDstY * blockCountX * TEXEL_BYTE_SIZE + gobDstX * TEXEL_BYTE_SIZE;
|
int gobDstLinPos = gobDstY * blockCountX * TEXEL_BYTE_SIZE + gobDstX * TEXEL_BYTE_SIZE;
|
||||||
|
|
||||||
Buffer.BlockCopy(data, srcPos, newData, gobDstLinPos, TEXEL_BYTE_SIZE);
|
data.Slice(srcPos, TEXEL_BYTE_SIZE).CopyTo(newData.Slice(gobDstLinPos));
|
||||||
|
|
||||||
srcPos += TEXEL_BYTE_SIZE;
|
srcPos += TEXEL_BYTE_SIZE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user