add acb&awb support

This commit is contained in:
1605296300@qq.com
2022-09-07 01:22:44 +08:00
parent d55c0ecd4d
commit 7607c8b4d2
57 changed files with 5676 additions and 34 deletions
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assets.Scripts.Audio.CriWareFormats.Common
{
public class BinaryPrimitives
{
internal static ushort ReverseEndianness(ushort le)
{
byte[] tmp = BitConverter.GetBytes(le);
Array.Reverse(tmp);
return BitConverter.ToUInt16(tmp,0);
}
internal static int ReverseEndianness(int le)
{
byte[] tmp = BitConverter.GetBytes(le);
Array.Reverse(tmp);
return BitConverter.ToInt32(tmp, 0);
}
internal static uint ReverseEndianness(uint le)
{
byte[] tmp = BitConverter.GetBytes(le);
Array.Reverse(tmp);
return BitConverter.ToUInt32(tmp, 0);
}
internal static long ReverseEndianness(long le)
{
byte[] tmp = BitConverter.GetBytes(le);
Array.Reverse(tmp);
return BitConverter.ToInt64(tmp, 0);
}
internal static ulong ReverseEndianness(ulong le)
{
byte[] tmp = BitConverter.GetBytes(le);
Array.Reverse(tmp);
return BitConverter.ToUInt64(tmp, 0);
}
public static float Int32BitsToSingle(int m)
{
return BitConverter.ToSingle(BitConverter.GetBytes(m), 0);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 35c4bac6c1dd0664b975a22cf7ea445a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime;
using Assets.Scripts.Audio.CriWareFormats.Common;
namespace CriWareFormats.Common
{
public class BinaryReaderEndian : BinaryReader
{
public BinaryReaderEndian(Stream input) : base(input)
{
}
public short ReadInt16BE()
{
ushort le = base.ReadUInt16();
return (short)BinaryPrimitives.ReverseEndianness(le);
}
public ushort ReadUInt16BE()
{
ushort le = base.ReadUInt16();
return BinaryPrimitives.ReverseEndianness(le);
}
public int ReadInt32BE()
{
uint le = base.ReadUInt32();
return (int)BinaryPrimitives.ReverseEndianness(le);
}
public uint ReadUInt32BE()
{
uint le = base.ReadUInt32();
return BinaryPrimitives.ReverseEndianness(le);
}
public long ReadInt64BE()
{
ulong le = base.ReadUInt64();
return (long)BinaryPrimitives.ReverseEndianness(le);
}
public ulong ReadUInt64BE()
{
ulong le = base.ReadUInt64();
return BinaryPrimitives.ReverseEndianness(le);
}
public float ReadSingleBE()
{
float le = base.ReadSingle();
byte[] floatBytes = BitConverter.GetBytes(le);
byte[] reversed = new byte[4];
for (int i = 0; i < 4; i++)
{
reversed[i] = floatBytes[3 - i];
}
return BitConverter.ToSingle(reversed, 0);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f17047d6b7698144588e1d5181473cf9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace CriWareFormats.Common
{
public static class Endian
{
public static ushort Reverse(ushort value)
{
return (ushort)(value << 8 | value >> 8);
}
public static uint Reverse(uint value)
{
value = (value & 0x00FF00FFu) << 8 | (value & 0xFF00FF00u) >> 8;
return (value & 0x0000FFFFu) << 16 | (value & 0xFFFF0000u) >> 16;
}
public static ulong Reverse(ulong value)
{
value = (value & 0x00FF00FF00FF00FFu) << 8 | (value & 0xFF00FF00FF00FF00u) >> 8;
value = (value & 0x0000FFFF0000FFFFu) << 16 | (value & 0xFFFF0000FFFF0000u) >> 16;
return value << 32 | value >> 32;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dfc4d0df7cc8c294ead855ed1ccc762d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: