mirror of
https://github.com/crskycode/GARbro.git
synced 2026-07-08 01:30:18 +08:00
IBinaryStream migration - continued.
This commit is contained in:
@@ -37,7 +37,7 @@ namespace GameRes.Formats.Pvns
|
||||
public override string Description { get { return "PVNS engine compressed audio format"; } }
|
||||
public override uint Signature { get { return 0x53564B4D; } } // 'MKVS'
|
||||
|
||||
public override SoundInput TryOpen (Stream file)
|
||||
public override SoundInput TryOpen (IBinaryStream file)
|
||||
{
|
||||
using (var reader = new MvReader (file))
|
||||
{
|
||||
@@ -52,7 +52,7 @@ namespace GameRes.Formats.Pvns
|
||||
|
||||
internal sealed class MvReader : IDisposable
|
||||
{
|
||||
BinaryReader m_input;
|
||||
IBinaryStream m_input;
|
||||
byte[] m_output;
|
||||
WaveFormat m_format;
|
||||
int m_channel_size;
|
||||
@@ -61,7 +61,7 @@ namespace GameRes.Formats.Pvns
|
||||
public byte[] Data { get { return m_output; } }
|
||||
public WaveFormat Format { get { return m_format; } }
|
||||
|
||||
public MvReader (Stream input)
|
||||
public MvReader (IBinaryStream input)
|
||||
{
|
||||
var header = new byte[0x12];
|
||||
input.Read (header, 0, header.Length);
|
||||
@@ -72,14 +72,14 @@ namespace GameRes.Formats.Pvns
|
||||
m_format.SamplesPerSecond = LittleEndian.ToUInt16 (header, 0xA);
|
||||
m_format.BlockAlign = (ushort)(m_format.Channels*m_format.BitsPerSample/8);
|
||||
m_format.AverageBytesPerSecond = m_format.SamplesPerSecond*m_format.BlockAlign;
|
||||
m_input = new ArcView.Reader (input);
|
||||
m_input = input;
|
||||
m_output = new byte[2 * m_format.Channels * m_channel_size];
|
||||
m_samples = LittleEndian.ToInt32 (header, 0xE);
|
||||
}
|
||||
|
||||
public void Unpack ()
|
||||
{
|
||||
m_input.BaseStream.Position = 0x12;
|
||||
m_input.Position = 0x12;
|
||||
var pre_sample1 = new int[0x400];
|
||||
var pre_sample2 = new int[0x400];
|
||||
var pre_sample3 = new int[0x140 * m_format.Channels];
|
||||
@@ -180,14 +180,8 @@ namespace GameRes.Formats.Pvns
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
bool _disposed = false;
|
||||
public void Dispose ()
|
||||
{
|
||||
if (!_disposed)
|
||||
{
|
||||
m_input.Dispose();
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -45,14 +45,11 @@ namespace GameRes.Formats.Pvns
|
||||
public override string Description { get { return "PVNS engine image format"; } }
|
||||
public override uint Signature { get { return 0x50425350; } } // 'PSBP'
|
||||
|
||||
public override ImageMetaData ReadMetaData (Stream stream)
|
||||
public override ImageMetaData ReadMetaData (IBinaryStream stream)
|
||||
{
|
||||
var header = new byte[0x14];
|
||||
if (header.Length != stream.Read (header, 0, header.Length))
|
||||
return null;
|
||||
var header = stream.ReadHeader (0x14);
|
||||
stream.Seek (-0x13, SeekOrigin.End);
|
||||
var tail = new byte[0x13];
|
||||
stream.Read (tail, 0, tail.Length);
|
||||
var tail = stream.ReadBytes (0x13);
|
||||
for (int i = 4; i < 0x14; ++i)
|
||||
{
|
||||
header[i] ^= tail[tail.Length - 3 + (i & 1)];
|
||||
@@ -60,18 +57,18 @@ namespace GameRes.Formats.Pvns
|
||||
}
|
||||
return new PsbMetaData
|
||||
{
|
||||
Width = LittleEndian.ToUInt16 (header, 0x0E),
|
||||
Height = LittleEndian.ToUInt16 (header, 0x10),
|
||||
BPP = LittleEndian.ToUInt16 (header, 0x12),
|
||||
Method = LittleEndian.ToUInt16 (header, 0x0C),
|
||||
TableOffset = LittleEndian.ToInt32 (header, 4),
|
||||
DataOffset = LittleEndian.ToInt32 (header, 8),
|
||||
Width = header.ToUInt16 (0x0E),
|
||||
Height = header.ToUInt16 (0x10),
|
||||
BPP = header.ToUInt16 (0x12),
|
||||
Method = header.ToUInt16 (0x0C),
|
||||
TableOffset = header.ToInt32 (4),
|
||||
DataOffset = header.ToInt32 (8),
|
||||
};
|
||||
}
|
||||
|
||||
public override ImageData Read (Stream stream, ImageMetaData info)
|
||||
public override ImageData Read (IBinaryStream stream, ImageMetaData info)
|
||||
{
|
||||
var reader = new PsbReader (stream, (PsbMetaData)info);
|
||||
var reader = new PsbReader (stream.AsStream, (PsbMetaData)info);
|
||||
reader.Unpack();
|
||||
return ImageData.Create (info, reader.Format, null, reader.Data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user