diff options
Diffstat (limited to 'BDInfo')
| -rw-r--r-- | BDInfo/BDInfo.csproj | 2 | ||||
| -rw-r--r-- | BDInfo/BDInfoSettings.cs | 98 | ||||
| -rw-r--r-- | BDInfo/BDROM.cs | 42 | ||||
| -rw-r--r-- | BDInfo/LanguageCodes.cs | 2 | ||||
| -rw-r--r-- | BDInfo/Properties/AssemblyInfo.cs | 4 | ||||
| -rw-r--r-- | BDInfo/ReadMe.txt | 4 | ||||
| -rw-r--r-- | BDInfo/TSCodecAC3.cs | 4 | ||||
| -rw-r--r-- | BDInfo/TSCodecAVC.cs | 2 | ||||
| -rw-r--r-- | BDInfo/TSCodecDTS.cs | 2 | ||||
| -rw-r--r-- | BDInfo/TSCodecDTSHD.cs | 4 | ||||
| -rw-r--r-- | BDInfo/TSCodecLPCM.cs | 2 | ||||
| -rw-r--r-- | BDInfo/TSCodecMPEG2.cs | 2 | ||||
| -rw-r--r-- | BDInfo/TSCodecMVC.cs | 2 | ||||
| -rw-r--r-- | BDInfo/TSCodecTrueHD.cs | 2 | ||||
| -rw-r--r-- | BDInfo/TSCodecVC1.cs | 2 | ||||
| -rw-r--r-- | BDInfo/TSInterleavedFile.cs | 3 | ||||
| -rw-r--r-- | BDInfo/TSPlaylistFile.cs | 81 | ||||
| -rw-r--r-- | BDInfo/TSStream.cs | 45 | ||||
| -rw-r--r-- | BDInfo/TSStreamBuffer.cs | 20 | ||||
| -rw-r--r-- | BDInfo/TSStreamClip.cs | 14 | ||||
| -rw-r--r-- | BDInfo/TSStreamClipFile.cs | 109 | ||||
| -rw-r--r-- | BDInfo/TSStreamFile.cs | 192 |
22 files changed, 263 insertions, 375 deletions
diff --git a/BDInfo/BDInfo.csproj b/BDInfo/BDInfo.csproj index b64f5e7a7..774e5709d 100644 --- a/BDInfo/BDInfo.csproj +++ b/BDInfo/BDInfo.csproj @@ -1,4 +1,4 @@ -<Project Sdk="Microsoft.NET.Sdk"> +<Project Sdk="Microsoft.NET.Sdk"> <ItemGroup> <Compile Include="..\SharedVersion.cs" Link="SharedVersion.cs" /> diff --git a/BDInfo/BDInfoSettings.cs b/BDInfo/BDInfoSettings.cs index 7abb67499..f4cb30016 100644 --- a/BDInfo/BDInfoSettings.cs +++ b/BDInfo/BDInfoSettings.cs @@ -1,105 +1,33 @@ - + namespace BDInfo { class BDInfoSettings { - public static bool GenerateStreamDiagnostics - { - get - { - return true; - } - } + public static bool GenerateStreamDiagnostics => true; - public static bool EnableSSIF - { - get - { - return true; - } - } + public static bool EnableSSIF => true; - public static bool AutosaveReport - { - get - { - return false; - } - } + public static bool AutosaveReport => false; - public static bool GenerateFrameDataFile - { - get - { - return false; - } - } + public static bool GenerateFrameDataFile => false; - public static bool FilterLoopingPlaylists - { - get - { - return true; - } - } + public static bool FilterLoopingPlaylists => true; - public static bool FilterShortPlaylists - { - get - { - return false; - } - } + public static bool FilterShortPlaylists => false; - public static int FilterShortPlaylistsValue - { - get - { - return 0; - } - } + public static int FilterShortPlaylistsValue => 0; - public static bool UseImagePrefix - { - get - { - return false; - } - } + public static bool UseImagePrefix => false; - public static string UseImagePrefixValue - { - get - { - return null; - } - } + public static string UseImagePrefixValue => null; /// <summary> /// Setting this to false throws an IComparer error on some discs. /// </summary> - public static bool KeepStreamOrder - { - get - { - return true; - } - } + public static bool KeepStreamOrder => true; - public static bool GenerateTextSummary - { - get - { - return false; - } - } + public static bool GenerateTextSummary => false; - public static string LastPath - { - get - { - return string.Empty; - } - } + public static string LastPath => string.Empty; } } diff --git a/BDInfo/BDROM.cs b/BDInfo/BDROM.cs index 7d8268222..b747d996f 100644 --- a/BDInfo/BDROM.cs +++ b/BDInfo/BDROM.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // @@ -164,7 +164,7 @@ namespace BDInfo if (DirectoryPLAYLIST != null) { FileSystemMetadata[] files = GetFiles(DirectoryPLAYLIST.FullName, ".mpls").ToArray(); - foreach (FileSystemMetadata file in files) + foreach (var file in files) { PlaylistFiles.Add( file.Name.ToUpper(), new TSPlaylistFile(this, file, _fileSystem, textEncoding)); @@ -174,7 +174,7 @@ namespace BDInfo if (DirectorySTREAM != null) { FileSystemMetadata[] files = GetFiles(DirectorySTREAM.FullName, ".m2ts").ToArray(); - foreach (FileSystemMetadata file in files) + foreach (var file in files) { StreamFiles.Add( file.Name.ToUpper(), new TSStreamFile(file, _fileSystem)); @@ -184,7 +184,7 @@ namespace BDInfo if (DirectoryCLIPINF != null) { FileSystemMetadata[] files = GetFiles(DirectoryCLIPINF.FullName, ".clpi").ToArray(); - foreach (FileSystemMetadata file in files) + foreach (var file in files) { StreamClipFiles.Add( file.Name.ToUpper(), new TSStreamClipFile(file, _fileSystem, textEncoding)); @@ -194,7 +194,7 @@ namespace BDInfo if (DirectorySSIF != null) { FileSystemMetadata[] files = GetFiles(DirectorySSIF.FullName, ".ssif").ToArray(); - foreach (FileSystemMetadata file in files) + foreach (var file in files) { InterleavedFiles.Add( file.Name.ToUpper(), new TSInterleavedFile(file)); @@ -214,8 +214,8 @@ namespace BDInfo public void Scan() { - List<TSStreamClipFile> errorStreamClipFiles = new List<TSStreamClipFile>(); - foreach (TSStreamClipFile streamClipFile in StreamClipFiles.Values) + var errorStreamClipFiles = new List<TSStreamClipFile>(); + foreach (var streamClipFile in StreamClipFiles.Values) { try { @@ -239,7 +239,7 @@ namespace BDInfo } } - foreach (TSStreamFile streamFile in StreamFiles.Values) + foreach (var streamFile in StreamFiles.Values) { string ssifName = Path.GetFileNameWithoutExtension(streamFile.Name) + ".SSIF"; if (InterleavedFiles.ContainsKey(ssifName)) @@ -252,8 +252,8 @@ namespace BDInfo StreamFiles.Values.CopyTo(streamFiles, 0); Array.Sort(streamFiles, CompareStreamFiles); - List<TSPlaylistFile> errorPlaylistFiles = new List<TSPlaylistFile>(); - foreach (TSPlaylistFile playlistFile in PlaylistFiles.Values) + var errorPlaylistFiles = new List<TSPlaylistFile>(); + foreach (var playlistFile in PlaylistFiles.Values) { try { @@ -277,15 +277,15 @@ namespace BDInfo } } - List<TSStreamFile> errorStreamFiles = new List<TSStreamFile>(); - foreach (TSStreamFile streamFile in streamFiles) + var errorStreamFiles = new List<TSStreamFile>(); + foreach (var streamFile in streamFiles) { try { - List<TSPlaylistFile> playlists = new List<TSPlaylistFile>(); - foreach (TSPlaylistFile playlist in PlaylistFiles.Values) + var playlists = new List<TSPlaylistFile>(); + foreach (var playlist in PlaylistFiles.Values) { - foreach (TSStreamClip streamClip in playlist.StreamClips) + foreach (var streamClip in playlist.StreamClips) { if (streamClip.Name == streamFile.Name) { @@ -314,12 +314,12 @@ namespace BDInfo } } - foreach (TSPlaylistFile playlistFile in PlaylistFiles.Values) + foreach (var playlistFile in PlaylistFiles.Values) { playlistFile.Initialize(); if (!Is50Hz) { - foreach (TSVideoStream videoStream in playlistFile.VideoStreams) + foreach (var videoStream in playlistFile.VideoStreams) { if (videoStream.FrameRate == TSFrameRate.FRAMERATE_25 || videoStream.FrameRate == TSFrameRate.FRAMERATE_50) @@ -369,7 +369,7 @@ namespace BDInfo if (dir != null) { FileSystemMetadata[] children = _fileSystem.GetDirectories(dir.FullName).ToArray(); - foreach (FileSystemMetadata child in children) + foreach (var child in children) { if (string.Equals(child.Name, name, StringComparison.OrdinalIgnoreCase)) { @@ -378,7 +378,7 @@ namespace BDInfo } if (searchDepth > 0) { - foreach (FileSystemMetadata child in children) + foreach (var child in children) { GetDirectory( name, child, searchDepth - 1); @@ -395,7 +395,7 @@ namespace BDInfo //if (!ExcludeDirs.Contains(directoryInfo.Name.ToUpper())) // TODO: Keep? { FileSystemMetadata[] pathFiles = _fileSystem.GetFiles(directoryInfo.FullName).ToArray(); - foreach (FileSystemMetadata pathFile in pathFiles) + foreach (var pathFile in pathFiles) { if (pathFile.Extension.ToUpper() == ".SSIF") { @@ -405,7 +405,7 @@ namespace BDInfo } FileSystemMetadata[] pathChildren = _fileSystem.GetDirectories(directoryInfo.FullName).ToArray(); - foreach (FileSystemMetadata pathChild in pathChildren) + foreach (var pathChild in pathChildren) { size += GetDirectorySize(pathChild); } diff --git a/BDInfo/LanguageCodes.cs b/BDInfo/LanguageCodes.cs index 90d0bccc4..ab2693ffb 100644 --- a/BDInfo/LanguageCodes.cs +++ b/BDInfo/LanguageCodes.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // diff --git a/BDInfo/Properties/AssemblyInfo.cs b/BDInfo/Properties/AssemblyInfo.cs index 77bd9df2a..788cf7366 100644 --- a/BDInfo/Properties/AssemblyInfo.cs +++ b/BDInfo/Properties/AssemblyInfo.cs @@ -15,7 +15,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyCulture("")] [assembly: NeutralResourcesLanguage("en")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/BDInfo/ReadMe.txt b/BDInfo/ReadMe.txt index 68326d560..e70b0b66c 100644 --- a/BDInfo/ReadMe.txt +++ b/BDInfo/ReadMe.txt @@ -1,5 +1,5 @@ -The source is taken from the BDRom folder of this project: +The source is taken from the BDRom folder of this project: http://www.cinemasquid.com/blu-ray/tools/bdinfo -BDInfoSettings was taken from the FormSettings class, and changed so that the settings all return defaults.
\ No newline at end of file +BDInfoSettings was taken from the FormSettings class, and changed so that the settings all return defaults. diff --git a/BDInfo/TSCodecAC3.cs b/BDInfo/TSCodecAC3.cs index 144141c30..35d306a19 100644 --- a/BDInfo/TSCodecAC3.cs +++ b/BDInfo/TSCodecAC3.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // @@ -24,7 +24,7 @@ namespace BDInfo { public abstract class TSCodecAC3 { - private static byte[] eac3_blocks = new byte[] { 1, 2, 3, 6 }; + private static byte[] eac3_blocks = new byte[] { 1, 2, 3, 6 }; public static void Scan( TSAudioStream stream, diff --git a/BDInfo/TSCodecAVC.cs b/BDInfo/TSCodecAVC.cs index 43c6d6f85..5833d169f 100644 --- a/BDInfo/TSCodecAVC.cs +++ b/BDInfo/TSCodecAVC.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // diff --git a/BDInfo/TSCodecDTS.cs b/BDInfo/TSCodecDTS.cs index 904dcd986..ff94cb702 100644 --- a/BDInfo/TSCodecDTS.cs +++ b/BDInfo/TSCodecDTS.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // diff --git a/BDInfo/TSCodecDTSHD.cs b/BDInfo/TSCodecDTSHD.cs index 3c5ad85cc..57a136d2d 100644 --- a/BDInfo/TSCodecDTSHD.cs +++ b/BDInfo/TSCodecDTSHD.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // @@ -211,7 +211,7 @@ namespace BDInfo // TODO if (stream.CoreStream != null) { - TSAudioStream coreStream = (TSAudioStream)stream.CoreStream; + var coreStream = (TSAudioStream)stream.CoreStream; if (coreStream.AudioMode == TSAudioMode.Extended && stream.ChannelCount == 5) { diff --git a/BDInfo/TSCodecLPCM.cs b/BDInfo/TSCodecLPCM.cs index d12674f0e..5709d8689 100644 --- a/BDInfo/TSCodecLPCM.cs +++ b/BDInfo/TSCodecLPCM.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // diff --git a/BDInfo/TSCodecMPEG2.cs b/BDInfo/TSCodecMPEG2.cs index 1d523528e..8bcd07d02 100644 --- a/BDInfo/TSCodecMPEG2.cs +++ b/BDInfo/TSCodecMPEG2.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // diff --git a/BDInfo/TSCodecMVC.cs b/BDInfo/TSCodecMVC.cs index 80fed3886..abff0c1b0 100644 --- a/BDInfo/TSCodecMVC.cs +++ b/BDInfo/TSCodecMVC.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // diff --git a/BDInfo/TSCodecTrueHD.cs b/BDInfo/TSCodecTrueHD.cs index 6ea78614c..5e81e162c 100644 --- a/BDInfo/TSCodecTrueHD.cs +++ b/BDInfo/TSCodecTrueHD.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // diff --git a/BDInfo/TSCodecVC1.cs b/BDInfo/TSCodecVC1.cs index ce9eabdb9..e2fbbf692 100644 --- a/BDInfo/TSCodecVC1.cs +++ b/BDInfo/TSCodecVC1.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // diff --git a/BDInfo/TSInterleavedFile.cs b/BDInfo/TSInterleavedFile.cs index 44a16bbaa..0f35cfb2a 100644 --- a/BDInfo/TSInterleavedFile.cs +++ b/BDInfo/TSInterleavedFile.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // @@ -17,7 +17,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //============================================================================= -using System.IO; using MediaBrowser.Model.IO; // TODO: Do more interesting things here... diff --git a/BDInfo/TSPlaylistFile.cs b/BDInfo/TSPlaylistFile.cs index c4e8d62ec..ba0b37f00 100644 --- a/BDInfo/TSPlaylistFile.cs +++ b/BDInfo/TSPlaylistFile.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // @@ -21,7 +21,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Text; using MediaBrowser.Model.IO; using MediaBrowser.Model.Text; @@ -86,9 +85,9 @@ namespace BDInfo _fileSystem = fileSystem; _textEncoding = textEncoding; IsCustom = true; - foreach (TSStreamClip clip in clips) + foreach (var clip in clips) { - TSStreamClip newClip = new TSStreamClip( + var newClip = new TSStreamClip( clip.StreamFile, clip.StreamClipFile); newClip.Name = clip.Name; @@ -124,7 +123,7 @@ namespace BDInfo get { ulong size = 0; - foreach (TSStreamClip clip in StreamClips) + foreach (var clip in StreamClips) { size += clip.InterleavedFileSize; } @@ -136,7 +135,7 @@ namespace BDInfo get { ulong size = 0; - foreach (TSStreamClip clip in StreamClips) + foreach (var clip in StreamClips) { size += clip.FileSize; } @@ -148,7 +147,7 @@ namespace BDInfo get { double length = 0; - foreach (TSStreamClip clip in StreamClips) + foreach (var clip in StreamClips) { if (clip.AngleIndex == 0) { @@ -164,7 +163,7 @@ namespace BDInfo get { double length = 0; - foreach (TSStreamClip clip in StreamClips) + foreach (var clip in StreamClips) { length += clip.Length; } @@ -177,7 +176,7 @@ namespace BDInfo get { ulong size = 0; - foreach (TSStreamClip clip in StreamClips) + foreach (var clip in StreamClips) { if (clip.AngleIndex == 0) { @@ -193,7 +192,7 @@ namespace BDInfo get { ulong size = 0; - foreach (TSStreamClip clip in StreamClips) + foreach (var clip in StreamClips) { size += clip.PacketSize; } @@ -264,7 +263,7 @@ namespace BDInfo int itemCount = ReadInt16(data, ref pos); int subitemCount = ReadInt16(data, ref pos); - List<TSStreamClip> chapterClips = new List<TSStreamClip>(); + var chapterClips = new List<TSStreamClip>(); for (int itemIndex = 0; itemIndex < itemCount; itemIndex++) { int itemStart = pos; @@ -311,7 +310,7 @@ namespace BDInfo if (outTime < 0) outTime &= 0x7FFFFFFF; double timeOut = (double)outTime / 45000; - TSStreamClip streamClip = new TSStreamClip( + var streamClip = new TSStreamClip( streamFile, streamClipFile); streamClip.Name = streamFileName; //TODO @@ -362,7 +361,7 @@ namespace BDInfo FileInfo.Name, angleClipFileName)); } - TSStreamClip angleClip = + var angleClip = new TSStreamClip(angleFile, angleClipFile); angleClip.AngleIndex = angle + 1; angleClip.TimeIn = streamClip.TimeIn; @@ -395,33 +394,33 @@ namespace BDInfo for (int i = 0; i < streamCountVideo; i++) { - TSStream stream = CreatePlaylistStream(data, ref pos); + var stream = CreatePlaylistStream(data, ref pos); if (stream != null) PlaylistStreams[stream.PID] = stream; } for (int i = 0; i < streamCountAudio; i++) { - TSStream stream = CreatePlaylistStream(data, ref pos); + var stream = CreatePlaylistStream(data, ref pos); if (stream != null) PlaylistStreams[stream.PID] = stream; } for (int i = 0; i < streamCountPG; i++) { - TSStream stream = CreatePlaylistStream(data, ref pos); + var stream = CreatePlaylistStream(data, ref pos); if (stream != null) PlaylistStreams[stream.PID] = stream; } for (int i = 0; i < streamCountIG; i++) { - TSStream stream = CreatePlaylistStream(data, ref pos); + var stream = CreatePlaylistStream(data, ref pos); if (stream != null) PlaylistStreams[stream.PID] = stream; } for (int i = 0; i < streamCountSecondaryAudio; i++) { - TSStream stream = CreatePlaylistStream(data, ref pos); + var stream = CreatePlaylistStream(data, ref pos); if (stream != null) PlaylistStreams[stream.PID] = stream; pos += 2; } for (int i = 0; i < streamCountSecondaryVideo; i++) { - TSStream stream = CreatePlaylistStream(data, ref pos); + var stream = CreatePlaylistStream(data, ref pos); if (stream != null) PlaylistStreams[stream.PID] = stream; pos += 6; } @@ -446,7 +445,7 @@ namespace BDInfo chapterIndex < chapterCount; chapterIndex++) { - int chapterType = data[pos+1]; + int chapterType = data[pos + 1]; if (chapterType == 1) { @@ -459,7 +458,7 @@ namespace BDInfo ((long)data[pos + 6] << 8) + ((long)data[pos + 7]); - TSStreamClip streamClip = chapterClips[streamFileIndex]; + var streamClip = chapterClips[streamFileIndex]; double chapterSeconds = (double)chapterTime / 45000; @@ -499,8 +498,8 @@ namespace BDInfo { LoadStreamClips(); - Dictionary<string, List<double>> clipTimes = new Dictionary<string, List<double>>(); - foreach (TSStreamClip clip in StreamClips) + var clipTimes = new Dictionary<string, List<double>>(); + foreach (var clip in StreamClips) { if (clip.AngleIndex == 0) { @@ -568,7 +567,7 @@ namespace BDInfo int streamLength = data[pos++]; int streamPos = pos; - TSStreamType streamType = (TSStreamType)data[pos++]; + var streamType = (TSStreamType)data[pos++]; switch (streamType) { case TSStreamType.MVC_VIDEO: @@ -580,11 +579,11 @@ namespace BDInfo case TSStreamType.MPEG2_VIDEO: case TSStreamType.VC1_VIDEO: - TSVideoFormat videoFormat = (TSVideoFormat) + var videoFormat = (TSVideoFormat) (data[pos] >> 4); - TSFrameRate frameRate = (TSFrameRate) + var frameRate = (TSFrameRate) (data[pos] & 0xF); - TSAspectRatio aspectRatio = (TSAspectRatio) + var aspectRatio = (TSAspectRatio) (data[pos + 1] >> 4); stream = new TSVideoStream(); @@ -618,9 +617,9 @@ namespace BDInfo int audioFormat = ReadByte(data, ref pos); - TSChannelLayout channelLayout = (TSChannelLayout) + var channelLayout = (TSChannelLayout) (audioFormat >> 4); - TSSampleRate sampleRate = (TSSampleRate) + var sampleRate = (TSSampleRate) (audioFormat & 0xF); string audioLanguage = ReadString(data, 3, ref pos); @@ -713,7 +712,7 @@ namespace BDInfo { referenceClip = StreamClips[0]; } - foreach (TSStreamClip clip in StreamClips) + foreach (var clip in StreamClips) { if (clip.StreamClipFile.Streams.Count > referenceClip.StreamClipFile.Streams.Count) { @@ -739,12 +738,12 @@ namespace BDInfo } } - foreach (TSStream clipStream + foreach (var clipStream in referenceClip.StreamClipFile.Streams.Values) { if (!Streams.ContainsKey(clipStream.PID)) { - TSStream stream = clipStream.Clone(); + var stream = clipStream.Clone(); Streams[clipStream.PID] = stream; if (!IsCustom && !PlaylistStreams.ContainsKey(stream.PID)) @@ -780,7 +779,7 @@ namespace BDInfo referenceClip.StreamFile.Streams.ContainsKey(4114) && !Streams.ContainsKey(4114)) { - TSStream stream = referenceClip.StreamFile.Streams[4114].Clone(); + var stream = referenceClip.StreamFile.Streams[4114].Clone(); Streams[4114] = stream; if (stream.IsVideoStream) { @@ -788,12 +787,12 @@ namespace BDInfo } } - foreach (TSStream clipStream + foreach (var clipStream in referenceClip.StreamFile.Streams.Values) { if (Streams.ContainsKey(clipStream.PID)) { - TSStream stream = Streams[clipStream.PID]; + var stream = Streams[clipStream.PID]; if (stream.StreamType != clipStream.StreamType) continue; @@ -812,8 +811,8 @@ namespace BDInfo else if (stream.IsAudioStream && clipStream.IsAudioStream) { - TSAudioStream audioStream = (TSAudioStream)stream; - TSAudioStream clipAudioStream = (TSAudioStream)clipStream; + var audioStream = (TSAudioStream)stream; + var clipAudioStream = (TSAudioStream)clipStream; if (clipAudioStream.ChannelCount > audioStream.ChannelCount) { @@ -864,7 +863,7 @@ namespace BDInfo SortedStreams.Add(stream); for (int i = 0; i < AngleCount; i++) { - TSStream angleStream = stream.Clone(); + var angleStream = stream.Clone(); angleStream.AngleIndex = i + 1; AngleStreams[i][angleStream.PID] = angleStream; SortedStreams.Add(angleStream); @@ -901,7 +900,7 @@ namespace BDInfo public void ClearBitrates() { - foreach (TSStreamClip clip in StreamClips) + foreach (var clip in StreamClips) { clip.PayloadBytes = 0; clip.PacketCount = 0; @@ -909,7 +908,7 @@ namespace BDInfo if (clip.StreamFile != null) { - foreach (TSStream stream in clip.StreamFile.Streams.Values) + foreach (var stream in clip.StreamFile.Streams.Values) { stream.PayloadBytes = 0; stream.PacketCount = 0; @@ -924,7 +923,7 @@ namespace BDInfo } } - foreach (TSStream stream in SortedStreams) + foreach (var stream in SortedStreams) { stream.PayloadBytes = 0; stream.PacketCount = 0; diff --git a/BDInfo/TSStream.cs b/BDInfo/TSStream.cs index 250308b1a..3c30a8597 100644 --- a/BDInfo/TSStream.cs +++ b/BDInfo/TSStream.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // @@ -109,7 +109,7 @@ namespace BDInfo public TSDescriptor Clone() { - TSDescriptor descriptor = + var descriptor = new TSDescriptor(Name, (byte)Value.Length); Value.CopyTo(descriptor.Value, 0); return descriptor; @@ -142,21 +142,12 @@ namespace BDInfo public double PacketSeconds = 0; public int AngleIndex = 0; - public ulong PacketSize - { - get - { - return PacketCount * 192; - } - } + public ulong PacketSize => PacketCount * 192; private string _LanguageCode; public string LanguageCode { - get - { - return _LanguageCode; - } + get => _LanguageCode; set { _LanguageCode = value; @@ -398,13 +389,7 @@ namespace BDInfo } } - public virtual string Description - { - get - { - return ""; - } - } + public virtual string Description => ""; public abstract TSStream Clone(); @@ -419,7 +404,7 @@ namespace BDInfo if (Descriptors != null) { stream.Descriptors = new List<TSDescriptor>(); - foreach (TSDescriptor descriptor in Descriptors) + foreach (var descriptor in Descriptors) { stream.Descriptors.Add(descriptor.Clone()); } @@ -444,10 +429,7 @@ namespace BDInfo private TSVideoFormat _VideoFormat; public TSVideoFormat VideoFormat { - get - { - return _VideoFormat; - } + get => _VideoFormat; set { _VideoFormat = value; @@ -488,10 +470,7 @@ namespace BDInfo private TSFrameRate _FrameRate; public TSFrameRate FrameRate { - get - { - return _FrameRate; - } + get => _FrameRate; set { _FrameRate = value; @@ -574,7 +553,7 @@ namespace BDInfo public override TSStream Clone() { - TSVideoStream stream = new TSVideoStream(); + var stream = new TSVideoStream(); CopyTo(stream); stream.VideoFormat = _VideoFormat; @@ -748,7 +727,7 @@ namespace BDInfo public override TSStream Clone() { - TSAudioStream stream = new TSAudioStream(); + var stream = new TSAudioStream(); CopyTo(stream); stream.SampleRate = SampleRate; @@ -777,7 +756,7 @@ namespace BDInfo public override TSStream Clone() { - TSGraphicsStream stream = new TSGraphicsStream(); + var stream = new TSGraphicsStream(); CopyTo(stream); return stream; } @@ -793,7 +772,7 @@ namespace BDInfo public override TSStream Clone() { - TSTextStream stream = new TSTextStream(); + var stream = new TSTextStream(); CopyTo(stream); return stream; } diff --git a/BDInfo/TSStreamBuffer.cs b/BDInfo/TSStreamBuffer.cs index 2f9094876..30bd1a3f4 100644 --- a/BDInfo/TSStreamBuffer.cs +++ b/BDInfo/TSStreamBuffer.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // @@ -37,21 +37,9 @@ namespace BDInfo Stream = new MemoryStream(Buffer); } - public long Length - { - get - { - return (long)BufferLength; - } - } + public long Length => (long)BufferLength; - public long Position - { - get - { - return Stream.Position; - } - } + public long Position => Stream.Position; public void Add( byte[] buffer, @@ -123,7 +111,7 @@ namespace BDInfo data += (Stream.ReadByte() << shift); shift -= 8; } - BitVector32 vector = new BitVector32(data); + var vector = new BitVector32(data); int value = 0; for (int i = SkipBits; i < SkipBits + bits; i++) diff --git a/BDInfo/TSStreamClip.cs b/BDInfo/TSStreamClip.cs index d7592a71a..295eeb6b1 100644 --- a/BDInfo/TSStreamClip.cs +++ b/BDInfo/TSStreamClip.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // @@ -74,13 +74,7 @@ namespace BDInfo } } - public ulong PacketSize - { - get - { - return PacketCount * 192; - } - } + public ulong PacketSize => PacketCount * 192; public ulong PacketBitRate { @@ -96,11 +90,11 @@ namespace BDInfo public bool IsCompatible(TSStreamClip clip) { - foreach (TSStream stream1 in StreamFile.Streams.Values) + foreach (var stream1 in StreamFile.Streams.Values) { if (clip.StreamFile.Streams.ContainsKey(stream1.PID)) { - TSStream stream2 = clip.StreamFile.Streams[stream1.PID]; + var stream2 = clip.StreamFile.Streams[stream1.PID]; if (stream1.StreamType != stream2.StreamType) { return false; diff --git a/BDInfo/TSStreamClipFile.cs b/BDInfo/TSStreamClipFile.cs index f311dd839..be6299e1a 100644 --- a/BDInfo/TSStreamClipFile.cs +++ b/BDInfo/TSStreamClipFile.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // @@ -21,7 +21,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Text; using MediaBrowser.Model.IO; using MediaBrowser.Model.Text; @@ -37,7 +36,7 @@ namespace BDInfo public string Name = null; public Dictionary<ushort, TSStream> Streams = - new Dictionary<ushort,TSStream>(); + new Dictionary<ushort, TSStream>(); public TSStreamClipFile( FileSystemMetadata fileInfo, IFileSystem fileSystem, ITextEncoding textEncoding) @@ -115,7 +114,7 @@ namespace BDInfo streamOffset += 2; - TSStreamType streamType = (TSStreamType) + var streamType = (TSStreamType) clipData[streamOffset + 1]; switch (streamType) { @@ -127,18 +126,18 @@ namespace BDInfo case TSStreamType.MPEG1_VIDEO: case TSStreamType.MPEG2_VIDEO: case TSStreamType.VC1_VIDEO: - { - TSVideoFormat videoFormat = (TSVideoFormat) - (clipData[streamOffset + 2] >> 4); - TSFrameRate frameRate = (TSFrameRate) - (clipData[streamOffset + 2] & 0xF); - TSAspectRatio aspectRatio = (TSAspectRatio) - (clipData[streamOffset + 3] >> 4); - - stream = new TSVideoStream(); - ((TSVideoStream)stream).VideoFormat = videoFormat; - ((TSVideoStream)stream).AspectRatio = aspectRatio; - ((TSVideoStream)stream).FrameRate = frameRate; + { + var videoFormat = (TSVideoFormat) + (clipData[streamOffset + 2] >> 4); + var frameRate = (TSFrameRate) + (clipData[streamOffset + 2] & 0xF); + var aspectRatio = (TSAspectRatio) + (clipData[streamOffset + 3] >> 4); + + stream = new TSVideoStream(); + ((TSVideoStream)stream).VideoFormat = videoFormat; + ((TSVideoStream)stream).AspectRatio = aspectRatio; + ((TSVideoStream)stream).FrameRate = frameRate; #if DEBUG Debug.WriteLine(string.Format( "\t{0} {1} {2} {3} {4}", @@ -148,8 +147,8 @@ namespace BDInfo frameRate, aspectRatio)); #endif - } - break; + } + break; case TSStreamType.AC3_AUDIO: case TSStreamType.AC3_PLUS_AUDIO: @@ -162,23 +161,23 @@ namespace BDInfo case TSStreamType.LPCM_AUDIO: case TSStreamType.MPEG1_AUDIO: case TSStreamType.MPEG2_AUDIO: - { - byte[] languageBytes = new byte[3]; - Array.Copy(clipData, streamOffset + 3, - languageBytes, 0, languageBytes.Length); - string languageCode = - _textEncoding.GetASCIIEncoding().GetString(languageBytes, 0, languageBytes.Length); - - TSChannelLayout channelLayout = (TSChannelLayout) - (clipData[streamOffset + 2] >> 4); - TSSampleRate sampleRate = (TSSampleRate) - (clipData[streamOffset + 2] & 0xF); - - stream = new TSAudioStream(); - ((TSAudioStream)stream).LanguageCode = languageCode; - ((TSAudioStream)stream).ChannelLayout = channelLayout; - ((TSAudioStream)stream).SampleRate = TSAudioStream.ConvertSampleRate(sampleRate); - ((TSAudioStream)stream).LanguageCode = languageCode; + { + byte[] languageBytes = new byte[3]; + Array.Copy(clipData, streamOffset + 3, + languageBytes, 0, languageBytes.Length); + string languageCode = + _textEncoding.GetASCIIEncoding().GetString(languageBytes, 0, languageBytes.Length); + + var channelLayout = (TSChannelLayout) + (clipData[streamOffset + 2] >> 4); + var sampleRate = (TSSampleRate) + (clipData[streamOffset + 2] & 0xF); + + stream = new TSAudioStream(); + ((TSAudioStream)stream).LanguageCode = languageCode; + ((TSAudioStream)stream).ChannelLayout = channelLayout; + ((TSAudioStream)stream).SampleRate = TSAudioStream.ConvertSampleRate(sampleRate); + ((TSAudioStream)stream).LanguageCode = languageCode; #if DEBUG Debug.WriteLine(string.Format( "\t{0} {1} {2} {3} {4}", @@ -188,20 +187,20 @@ namespace BDInfo channelLayout, sampleRate)); #endif - } - break; + } + break; case TSStreamType.INTERACTIVE_GRAPHICS: case TSStreamType.PRESENTATION_GRAPHICS: - { - byte[] languageBytes = new byte[3]; - Array.Copy(clipData, streamOffset + 2, - languageBytes, 0, languageBytes.Length); - string languageCode = - _textEncoding.GetASCIIEncoding().GetString(languageBytes, 0, languageBytes.Length); + { + byte[] languageBytes = new byte[3]; + Array.Copy(clipData, streamOffset + 2, + languageBytes, 0, languageBytes.Length); + string languageCode = + _textEncoding.GetASCIIEncoding().GetString(languageBytes, 0, languageBytes.Length); stream = new TSGraphicsStream(); - stream.LanguageCode = languageCode; + stream.LanguageCode = languageCode; #if DEBUG Debug.WriteLine(string.Format( "\t{0} {1} {2}", @@ -209,16 +208,16 @@ namespace BDInfo streamType, languageCode)); #endif - } - break; + } + break; case TSStreamType.SUBTITLE: - { - byte[] languageBytes = new byte[3]; - Array.Copy(clipData, streamOffset + 3, - languageBytes, 0, languageBytes.Length); - string languageCode = - _textEncoding.GetASCIIEncoding().GetString(languageBytes, 0, languageBytes.Length); + { + byte[] languageBytes = new byte[3]; + Array.Copy(clipData, streamOffset + 3, + languageBytes, 0, languageBytes.Length); + string languageCode = + _textEncoding.GetASCIIEncoding().GetString(languageBytes, 0, languageBytes.Length); #if DEBUG Debug.WriteLine(string.Format( "\t{0} {1} {2}", @@ -227,9 +226,9 @@ namespace BDInfo languageCode)); #endif stream = new TSTextStream(); - stream.LanguageCode = languageCode; - } - break; + stream.LanguageCode = languageCode; + } + break; } if (stream != null) diff --git a/BDInfo/TSStreamFile.cs b/BDInfo/TSStreamFile.cs index 00e6b338e..ecf6609e2 100644 --- a/BDInfo/TSStreamFile.cs +++ b/BDInfo/TSStreamFile.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // @@ -283,7 +283,7 @@ namespace BDInfo bool isAVC = false; bool isMVC = false; - foreach (TSStream finishedStream in Streams.Values) + foreach (var finishedStream in Streams.Values) { if (!finishedStream.IsInitialized) { @@ -327,10 +327,10 @@ namespace BDInfo UpdateStreamBitrate(PID, PTSPID, PTS, PTSDiff); } - foreach (TSPlaylistFile playlist in Playlists) + foreach (var playlist in Playlists) { double packetSeconds = 0; - foreach (TSStreamClip clip in playlist.StreamClips) + foreach (var clip in playlist.StreamClips) { if (clip.AngleIndex == 0) { @@ -339,7 +339,7 @@ namespace BDInfo } if (packetSeconds > 0) { - foreach (TSStream playlistStream in playlist.SortedStreams) + foreach (var playlistStream in playlist.SortedStreams) { if (playlistStream.IsVBR) { @@ -366,14 +366,14 @@ namespace BDInfo { if (Playlists == null) return; - TSStreamState streamState = StreamStates[PID]; + var streamState = StreamStates[PID]; double streamTime = (double)PTS / 90000; double streamInterval = (double)PTSDiff / 90000; double streamOffset = streamTime + streamInterval; - foreach (TSPlaylistFile playlist in Playlists) + foreach (var playlist in Playlists) { - foreach (TSStreamClip clip in playlist.StreamClips) + foreach (var clip in playlist.StreamClips) { if (clip.Name != this.Name) continue; @@ -390,7 +390,7 @@ namespace BDInfo clip.PacketSeconds = streamOffset - clip.TimeIn; } - Dictionary<ushort, TSStream> playlistStreams = playlist.Streams; + var playlistStreams = playlist.Streams; if (clip.AngleIndex > 0 && clip.AngleIndex < playlist.AngleStreams.Count + 1) { @@ -398,7 +398,7 @@ namespace BDInfo } if (playlistStreams.ContainsKey(PID)) { - TSStream stream = playlistStreams[PID]; + var stream = playlistStreams[PID]; stream.PayloadBytes += streamState.WindowBytes; stream.PacketCount += streamState.WindowPackets; @@ -425,13 +425,13 @@ namespace BDInfo if (Streams.ContainsKey(PID)) { - TSStream stream = Streams[PID]; + var stream = Streams[PID]; stream.PayloadBytes += streamState.WindowBytes; stream.PacketCount += streamState.WindowPackets; if (stream.IsVideoStream) { - TSStreamDiagnostics diag = new TSStreamDiagnostics(); + var diag = new TSStreamDiagnostics(); diag.Marker = (double)PTS / 90000; diag.Interval = (double)PTSDiff / 90000; diag.Bytes = streamState.WindowBytes; @@ -482,7 +482,7 @@ namespace BDInfo StreamStates.Clear(); StreamDiagnostics.Clear(); - TSPacketParser parser = + var parser = new TSPacketParser(); long fileLength = (uint)fileStream.Length; @@ -536,80 +536,80 @@ namespace BDInfo switch (parser.HeaderParse) { case 2: - { - parser.TransportErrorIndicator = - (byte)((buffer[i] >> 7) & 0x1); - parser.PayloadUnitStartIndicator = - (byte)((buffer[i] >> 6) & 0x1); - parser.TransportPriority = - (byte)((buffer[i] >> 5) & 0x1); - parser.PID = - (ushort)((buffer[i] & 0x1f) << 8); - } - break; - - case 1: - { - parser.PID |= (ushort)buffer[i]; - if (Streams.ContainsKey(parser.PID)) - { - parser.Stream = Streams[parser.PID]; - } - else { - parser.Stream = null; + parser.TransportErrorIndicator = + (byte)((buffer[i] >> 7) & 0x1); + parser.PayloadUnitStartIndicator = + (byte)((buffer[i] >> 6) & 0x1); + parser.TransportPriority = + (byte)((buffer[i] >> 5) & 0x1); + parser.PID = + (ushort)((buffer[i] & 0x1f) << 8); } - if (!StreamStates.ContainsKey(parser.PID)) - { - StreamStates[parser.PID] = new TSStreamState(); - } - parser.StreamState = StreamStates[parser.PID]; - parser.StreamState.TotalPackets++; - parser.StreamState.WindowPackets++; - parser.TotalPackets++; - } - break; + break; - case 0: - { - parser.TransportScramblingControl = - (byte)((buffer[i] >> 6) & 0x3); - parser.AdaptionFieldControl = - (byte)((buffer[i] >> 4) & 0x3); - - if ((parser.AdaptionFieldControl & 0x2) == 0x2) - { - parser.AdaptionFieldState = true; - } - if (parser.PayloadUnitStartIndicator == 1) + case 1: { - if (parser.PID == 0) + parser.PID |= (ushort)buffer[i]; + if (Streams.ContainsKey(parser.PID)) { - parser.PATSectionStart = true; + parser.Stream = Streams[parser.PID]; } - else if (parser.PID == parser.PMTPID) + else { - parser.PMTSectionStart = true; + parser.Stream = null; } - else if (parser.StreamState != null && - parser.StreamState.TransferState) + if (!StreamStates.ContainsKey(parser.PID)) { - parser.StreamState.TransferState = false; - parser.StreamState.TransferCount++; + StreamStates[parser.PID] = new TSStreamState(); + } + parser.StreamState = StreamStates[parser.PID]; + parser.StreamState.TotalPackets++; + parser.StreamState.WindowPackets++; + parser.TotalPackets++; + } + break; - bool isFinished = ScanStream( - parser.Stream, - parser.StreamState, - parser.StreamState.StreamBuffer); + case 0: + { + parser.TransportScramblingControl = + (byte)((buffer[i] >> 6) & 0x3); + parser.AdaptionFieldControl = + (byte)((buffer[i] >> 4) & 0x3); - if (!isFullScan && isFinished) + if ((parser.AdaptionFieldControl & 0x2) == 0x2) + { + parser.AdaptionFieldState = true; + } + if (parser.PayloadUnitStartIndicator == 1) + { + if (parser.PID == 0) + { + parser.PATSectionStart = true; + } + else if (parser.PID == parser.PMTPID) + { + parser.PMTSectionStart = true; + } + else if (parser.StreamState != null && + parser.StreamState.TransferState) { - return; + parser.StreamState.TransferState = false; + parser.StreamState.TransferCount++; + + bool isFinished = ScanStream( + parser.Stream, + parser.StreamState, + parser.StreamState.StreamBuffer); + + if (!isFullScan && isFinished) + { + return; + } } } } - } - break; + break; } } else if (parser.AdaptionFieldState) @@ -670,7 +670,8 @@ namespace BDInfo parser.PAT[parser.PATOffset++] = buffer[i++]; parser.PATSectionLength--; parser.PacketLength--; - } --i; + } + --i; if (parser.PATSectionLength == 0) { @@ -801,7 +802,8 @@ namespace BDInfo PMT[parser.PMTOffset++] = buffer[i++]; --parser.PMTSectionLength; --parser.PacketLength; - } --i; + } + --i; if (parser.PMTSectionLength == 0) { @@ -837,7 +839,7 @@ namespace BDInfo if (!Streams.ContainsKey(streamPID)) { - List<TSDescriptor> streamDescriptors = + var streamDescriptors = new List<TSDescriptor>(); /* @@ -994,7 +996,7 @@ namespace BDInfo { --parser.PMTProgramDescriptorLength; - TSDescriptor descriptor = parser.PMTProgramDescriptors[ + var descriptor = parser.PMTProgramDescriptors[ parser.PMTProgramDescriptors.Count - 1]; int valueIndex = @@ -1024,8 +1026,8 @@ namespace BDInfo parser.StreamState != null && parser.TransportScramblingControl == 0) { - TSStream stream = parser.Stream; - TSStreamState streamState = parser.StreamState; + var stream = parser.Stream; + var streamState = parser.StreamState; streamState.Parse = (streamState.Parse << 8) + buffer[i]; @@ -1459,7 +1461,7 @@ namespace BDInfo ulong PTSLast = 0; ulong PTSDiff = 0; - foreach (TSStream stream in Streams.Values) + foreach (var stream in Streams.Values) { if (!stream.IsVideoStream) continue; @@ -1495,10 +1497,10 @@ namespace BDInfo case TSStreamType.MPEG1_VIDEO: case TSStreamType.MPEG2_VIDEO: case TSStreamType.VC1_VIDEO: - { - stream = new TSVideoStream(); - } - break; + { + stream = new TSVideoStream(); + } + break; case TSStreamType.AC3_AUDIO: case TSStreamType.AC3_PLUS_AUDIO: @@ -1511,23 +1513,23 @@ namespace BDInfo case TSStreamType.LPCM_AUDIO: case TSStreamType.MPEG1_AUDIO: case TSStreamType.MPEG2_AUDIO: - { - stream = new TSAudioStream(); - } - break; + { + stream = new TSAudioStream(); + } + break; case TSStreamType.INTERACTIVE_GRAPHICS: case TSStreamType.PRESENTATION_GRAPHICS: - { - stream = new TSGraphicsStream(); - } - break; + { + stream = new TSGraphicsStream(); + } + break; case TSStreamType.SUBTITLE: - { - stream = new TSTextStream(); - } - break; + { + stream = new TSTextStream(); + } + break; default: break; |
