mirror of
https://github.com/crskycode/GARbro.git
synced 2025-01-12 04:49:32 +08:00
(PcmAudio): support OGG encoding (#35)
This commit is contained in:
parent
4c3e9fdcbd
commit
83fea34587
@ -39,46 +39,6 @@ namespace GameRes.Formats.Circus
|
|||||||
public override uint Signature { get { return 0x4d435058; } } // 'XPCM'
|
public override uint Signature { get { return 0x4d435058; } } // 'XPCM'
|
||||||
|
|
||||||
public override SoundInput TryOpen (Stream file)
|
public override SoundInput TryOpen (Stream file)
|
||||||
{
|
|
||||||
return new PcmInput (file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class PcmInput : SoundInput
|
|
||||||
{
|
|
||||||
public override string SourceFormat { get { return "raw"; } }
|
|
||||||
|
|
||||||
public override int SourceBitrate
|
|
||||||
{
|
|
||||||
get { return (int)Format.AverageBytesPerSecond * 8; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#region IO.Stream methods
|
|
||||||
public override long Position
|
|
||||||
{
|
|
||||||
get { return Source.Position; }
|
|
||||||
set { Source.Position = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanSeek { get { return Source.CanSeek; } }
|
|
||||||
|
|
||||||
public override long Seek (long offset, SeekOrigin origin)
|
|
||||||
{
|
|
||||||
return Source.Seek (offset, origin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int Read (byte[] buffer, int offset, int count)
|
|
||||||
{
|
|
||||||
return Source.Read (buffer, offset, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int ReadByte ()
|
|
||||||
{
|
|
||||||
return Source.ReadByte();
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public PcmInput (Stream file) : base (null)
|
|
||||||
{
|
{
|
||||||
file.Position = 4;
|
file.Position = 4;
|
||||||
using (var input = new ArcView.Reader (file))
|
using (var input = new ArcView.Reader (file))
|
||||||
@ -89,6 +49,12 @@ namespace GameRes.Formats.Circus
|
|||||||
int mode = input.ReadInt32();
|
int mode = input.ReadInt32();
|
||||||
int extra = (mode >> 8) & 0xff;
|
int extra = (mode >> 8) & 0xff;
|
||||||
mode &= 0xff;
|
mode &= 0xff;
|
||||||
|
if (5 == mode)
|
||||||
|
{
|
||||||
|
uint ogg_size = input.ReadUInt32();
|
||||||
|
var ogg = new StreamRegion (file, 0x10, ogg_size);
|
||||||
|
return new OggInput (ogg);
|
||||||
|
}
|
||||||
var format = new WaveFormat();
|
var format = new WaveFormat();
|
||||||
format.FormatTag = input.ReadUInt16();
|
format.FormatTag = input.ReadUInt16();
|
||||||
format.Channels = input.ReadUInt16();
|
format.Channels = input.ReadUInt16();
|
||||||
@ -96,20 +62,21 @@ namespace GameRes.Formats.Circus
|
|||||||
format.AverageBytesPerSecond = input.ReadUInt32();
|
format.AverageBytesPerSecond = input.ReadUInt32();
|
||||||
format.BlockAlign = input.ReadUInt16();
|
format.BlockAlign = input.ReadUInt16();
|
||||||
format.BitsPerSample = input.ReadUInt16();
|
format.BitsPerSample = input.ReadUInt16();
|
||||||
this.Format = format;
|
Stream pcm;
|
||||||
this.PcmSize = src_size;
|
|
||||||
if (0 == mode)
|
if (0 == mode)
|
||||||
{
|
{
|
||||||
this.Source = new StreamRegion (file, file.Position, src_size);
|
pcm = new StreamRegion (file, file.Position, src_size);
|
||||||
}
|
}
|
||||||
else if (1 == mode || 3 == mode)
|
else if (1 == mode || 3 == mode)
|
||||||
{
|
{
|
||||||
var decoder = new PcmDecoder (input, src_size, extra, (XpcmCompression)mode);
|
var decoder = new PcmDecoder (input, src_size, extra, (XpcmCompression)mode);
|
||||||
this.Source = new MemoryStream (decoder.Unpack(), 0, src_size);
|
pcm = new MemoryStream (decoder.Unpack(), 0, src_size);
|
||||||
file.Dispose();
|
file.Dispose();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw new NotSupportedException ("Not supported Circus PCM audio compression");
|
throw new NotSupportedException ("Not supported Circus PCM audio compression");
|
||||||
|
|
||||||
|
return new RawPcmInput (pcm, format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user