mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
IAudioTitleSet
This commit is contained in:
@@ -6,7 +6,7 @@ using static CUETools.Codecs.AudioPCMConfig;
|
||||
|
||||
namespace CUETools.Codecs.MPEG.ATSI
|
||||
{
|
||||
public class AudioDecoder : IAudioSource, IAudioContainer
|
||||
public class AudioDecoder : IAudioSource, IAudioTitleSet
|
||||
{
|
||||
public unsafe AudioDecoder(DecoderSettings settings, string path, Stream IO)
|
||||
{
|
||||
@@ -331,7 +331,7 @@ namespace CUETools.Codecs.MPEG.ATSI
|
||||
public ushort codec;
|
||||
public uint format;
|
||||
|
||||
public byte StreamId
|
||||
public int StreamId
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -342,64 +342,6 @@ namespace CUETools.Codecs.MPEG.ATSI
|
||||
}
|
||||
}
|
||||
|
||||
public string CodecString
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (StreamId)
|
||||
{
|
||||
case DVDA.PCM_STREAM_ID: return "RAW/PCM";
|
||||
case DVDA.MLP_STREAM_ID: return "MLP";
|
||||
default: return StreamId.ToString();
|
||||
}
|
||||
//switch (codec)
|
||||
//{
|
||||
// case 0x000: return "RAW/PCM";
|
||||
// case 0x100: return "MLP";
|
||||
// default: return codec.ToString();
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
public AudioPCMConfig PCM
|
||||
{
|
||||
get
|
||||
{
|
||||
if (track_sector.Count < 1) return null;
|
||||
if (track_sector[0].dvdaBlock == null) return null;
|
||||
return new AudioPCMConfig(
|
||||
track_sector[0].dvdaBlock.gr1_bits,
|
||||
track_sector[0].dvdaBlock.channels,
|
||||
track_sector[0].dvdaBlock.gr1_frequency);
|
||||
}
|
||||
}
|
||||
|
||||
public string RateString
|
||||
{
|
||||
get
|
||||
{
|
||||
var sr = PCM.SampleRate;
|
||||
if (sr % 1000 == 0) return $"{sr / 1000}KHz";
|
||||
if (sr % 100 == 0) return $"{sr / 100}.{(sr / 100) % 10}KHz";
|
||||
return $"{sr}Hz";
|
||||
}
|
||||
}
|
||||
|
||||
public string FormatString
|
||||
{
|
||||
get
|
||||
{
|
||||
if (track_sector.Count < 1) return "?";
|
||||
if (track_sector[0].dvdaBlock == null) return "?";
|
||||
switch (track_sector[0].dvdaBlock.ch_assignment)
|
||||
{
|
||||
case 0: return "mono";
|
||||
case 1: return "stereo";
|
||||
default: return "multi-channel";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<TimeSpan> Chapters
|
||||
{
|
||||
get
|
||||
@@ -436,6 +378,40 @@ namespace CUETools.Codecs.MPEG.ATSI
|
||||
}
|
||||
}
|
||||
|
||||
public AudioPCMConfig PCM
|
||||
{
|
||||
get
|
||||
{
|
||||
if (track_sector.Count < 1) return null;
|
||||
if (track_sector[0].dvdaBlock == null) return null;
|
||||
return new AudioPCMConfig(
|
||||
track_sector[0].dvdaBlock.gr1_bits,
|
||||
track_sector[0].dvdaBlock.channels,
|
||||
track_sector[0].dvdaBlock.gr1_frequency);
|
||||
}
|
||||
}
|
||||
|
||||
public string Codec
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (StreamId)
|
||||
{
|
||||
case DVDA.PCM_STREAM_ID: return "RAW/PCM";
|
||||
case DVDA.MLP_STREAM_ID: return "MLP";
|
||||
default: return StreamId.ToString();
|
||||
}
|
||||
//switch (codec)
|
||||
//{
|
||||
// case 0x000: return "RAW/PCM";
|
||||
// case 0x100: return "MLP";
|
||||
// default: return codec.ToString();
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
public string Language => "";
|
||||
|
||||
public List<ATSITrackTimestamp> track_timestamp;
|
||||
public List<ATSITrackSector> track_sector;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.IO;
|
||||
|
||||
namespace CUETools.Codecs.MPEG.MPLS
|
||||
{
|
||||
public class AudioDecoder : IAudioSource, IAudioContainer
|
||||
public class AudioDecoder : IAudioSource, IAudioTitleSet
|
||||
{
|
||||
public unsafe AudioDecoder(DecoderSettings settings, string path, Stream IO)
|
||||
{
|
||||
@@ -392,7 +392,7 @@ namespace CUETools.Codecs.MPEG.MPLS
|
||||
foreach (var item in hdr_m.play_item)
|
||||
foreach (var audio in item.audio)
|
||||
{
|
||||
if (audio.coding_type != 0x80 /* LPCM */) continue;
|
||||
//if (audio.coding_type != 0x80 /* LPCM */) continue;
|
||||
titles.Add(new AudioTitle(this, audio.pid));
|
||||
}
|
||||
return titles;
|
||||
@@ -461,6 +461,44 @@ namespace CUETools.Codecs.MPEG.MPLS
|
||||
}
|
||||
|
||||
public List<TimeSpan> Chapters => source.Chapters;
|
||||
public AudioPCMConfig PCM
|
||||
{
|
||||
get
|
||||
{
|
||||
var s = FirstStream;
|
||||
int channelCount = s.format == 1 ? 1 : s.format == 3 ? 2 : s.format == 6 ? 5 : 0;
|
||||
int sampleRate = s.rate == 1 ? 48000 : s.rate == 4 ? 96000 : s.rate == 5 ? 192000 : s.rate == 12 ? 192000 : s.rate == 14 ? 96000 : 0;
|
||||
int bitsPerSample = 0;
|
||||
return new AudioPCMConfig(bitsPerSample, channelCount, sampleRate);
|
||||
}
|
||||
}
|
||||
public string Codec
|
||||
{
|
||||
get
|
||||
{
|
||||
var s = FirstStream;
|
||||
return s != null ? s.CodecString : "?";
|
||||
}
|
||||
}
|
||||
public string Language
|
||||
{
|
||||
get
|
||||
{
|
||||
var s = FirstStream;
|
||||
return s != null ? s.LanguageString : "?";
|
||||
}
|
||||
}
|
||||
public int StreamId => pid;
|
||||
|
||||
MPLSStream FirstStream
|
||||
{
|
||||
get
|
||||
{
|
||||
MPLSStream result = null;
|
||||
source.MPLSHeader.play_item.ForEach(i => i.audio.FindAll(a => a.pid == pid).ForEach(x => result = x));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
AudioDecoder source;
|
||||
int pid;
|
||||
@@ -476,7 +514,7 @@ namespace CUETools.Codecs.MPEG.MPLS
|
||||
public uint duration;
|
||||
}
|
||||
|
||||
public struct MPLSStream
|
||||
public class MPLSStream
|
||||
{
|
||||
public byte stream_type;
|
||||
public byte coding_type;
|
||||
|
||||
@@ -56,13 +56,4 @@ namespace CUETools.Codecs.MPEG
|
||||
savedBufferSize = 0;
|
||||
}
|
||||
};
|
||||
|
||||
public class AudioDescription
|
||||
{
|
||||
public int StreamId;
|
||||
public string CodecString;
|
||||
public string LanguageString;
|
||||
public string FormatString;
|
||||
public string RateString;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user