format ids that require conversion are stored in a static HashSet.

This commit is contained in:
morkt 2015-05-16 00:35:32 +04:00
parent 792b299037
commit 7b131442ad

View File

@ -23,6 +23,7 @@
// IN THE SOFTWARE. // IN THE SOFTWARE.
// //
using System.Collections.Generic;
using System.ComponentModel.Composition; using System.ComponentModel.Composition;
using System.IO; using System.IO;
using System.Text; using System.Text;
@ -49,11 +50,17 @@ namespace GameRes
public override string SourceFormat { get { return "wav"; } } public override string SourceFormat { get { return "wav"; } }
static readonly HashSet<WaveFormatEncoding> ConversionRequired = new HashSet<WaveFormatEncoding> {
WaveFormatEncoding.Adpcm, // 2
WaveFormatEncoding.MuLaw, // 7
WaveFormatEncoding.DviAdpcm, // 0x11
};
public WaveInput (Stream file) : base (file) public WaveInput (Stream file) : base (file)
{ {
m_reader = new WaveFileReader (file); m_reader = new WaveFileReader (file);
var wf = m_reader.WaveFormat; var wf = m_reader.WaveFormat;
if (WaveFormatEncoding.Adpcm == wf.Encoding || WaveFormatEncoding.MuLaw == wf.Encoding) // 2 || 7 if (ConversionRequired.Contains (wf.Encoding))
{ {
var wav = WaveFormatConversionStream.CreatePcmStream (m_reader); var wav = WaveFormatConversionStream.CreatePcmStream (m_reader);
wf = wav.WaveFormat; wf = wav.WaveFormat;