Code reformat.

This commit is contained in:
2019-11-25 00:54:38 +00:00
parent a5c650440d
commit d864bfab6c
116 changed files with 16544 additions and 19331 deletions

View File

@@ -37,25 +37,13 @@ using DiscImageChef.Console;
namespace DiscImageChef.Decoders.CD
{
/// <summary>
/// Information from the following standards:
/// ANSI X3.304-1997
/// T10/1048-D revision 9.0
/// T10/1048-D revision 10a
/// T10/1228-D revision 7.0c
/// T10/1228-D revision 11a
/// T10/1363-D revision 10g
/// T10/1545-D revision 1d
/// T10/1545-D revision 5
/// T10/1545-D revision 5a
/// T10/1675-D revision 2c
/// T10/1675-D revision 4
/// T10/1836-D revision 2g
/// ISO/IEC 61104: Compact disc video system - 12 cm CD-V
/// ISO/IEC 60908: Audio recording - Compact disc digital audio system
/// Information from the following standards: ANSI X3.304-1997 T10/1048-D revision 9.0 T10/1048-D revision 10a
/// T10/1228-D revision 7.0c T10/1228-D revision 11a T10/1363-D revision 10g T10/1545-D revision 1d T10/1545-D revision
/// 5 T10/1545-D revision 5a T10/1675-D revision 2c T10/1675-D revision 4 T10/1836-D revision 2g ISO/IEC 61104: Compact
/// disc video system - 12 cm CD-V ISO/IEC 60908: Audio recording - Compact disc digital audio system
/// </summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public static class FullTOC
{
const string StereoNoPre = "Stereo audio track with no pre-emphasis";
@@ -65,98 +53,15 @@ namespace DiscImageChef.Decoders.CD
const string DataUnintrp = "Data track, recorded uninterrupted";
const string DataIncrtly = "Data track, recorded incrementally";
public struct CDFullTOC
{
/// <summary>
/// Total size of returned session information minus this field
/// </summary>
public ushort DataLength;
/// <summary>
/// First complete session number in hex
/// </summary>
public byte FirstCompleteSession;
/// <summary>
/// Last complete session number in hex
/// </summary>
public byte LastCompleteSession;
/// <summary>
/// Track descriptors
/// </summary>
public TrackDataDescriptor[] TrackDescriptors;
}
public struct TrackDataDescriptor
{
/// <summary>
/// Byte 0
/// Session number in hex
/// </summary>
public byte SessionNumber;
/// <summary>
/// Byte 1, bits 7 to 4
/// Type of information in Q subchannel of block where this TOC entry was found
/// </summary>
public byte ADR;
/// <summary>
/// Byte 1, bits 3 to 0
/// Track attributes
/// </summary>
public byte CONTROL;
/// <summary>
/// Byte 2
/// </summary>
public byte TNO;
/// <summary>
/// Byte 3
/// </summary>
public byte POINT;
/// <summary>
/// Byte 4
/// </summary>
public byte Min;
/// <summary>
/// Byte 5
/// </summary>
public byte Sec;
/// <summary>
/// Byte 6
/// </summary>
public byte Frame;
/// <summary>
/// Byte 7, CD only
/// </summary>
public byte Zero;
/// <summary>
/// Byte 7, bits 7 to 4, DDCD only
/// </summary>
public byte HOUR;
/// <summary>
/// Byte 7, bits 3 to 0, DDCD only
/// </summary>
public byte PHOUR;
/// <summary>
/// Byte 8
/// </summary>
public byte PMIN;
/// <summary>
/// Byte 9
/// </summary>
public byte PSEC;
/// <summary>
/// Byte 10
/// </summary>
public byte PFRAME;
}
public static CDFullTOC? Decode(byte[] CDFullTOCResponse)
{
if(CDFullTOCResponse == null) return null;
if(CDFullTOCResponse == null)
return null;
CDFullTOC decoded = new CDFullTOC
var decoded = new CDFullTOC
{
DataLength = BigEndianBitConverter.ToUInt16(CDFullTOCResponse, 0),
FirstCompleteSession = CDFullTOCResponse[2],
LastCompleteSession = CDFullTOCResponse[3]
FirstCompleteSession = CDFullTOCResponse[2], LastCompleteSession = CDFullTOCResponse[3]
};
decoded.TrackDescriptors = new TrackDataDescriptor[(decoded.DataLength - 2) / 11];
@@ -166,6 +71,7 @@ namespace DiscImageChef.Decoders.CD
DicConsole.DebugWriteLine("CD full TOC decoder",
"Expected CDFullTOC size ({0} bytes) is not received size ({1} bytes), not decoding",
decoded.DataLength + 2, CDFullTOCResponse.Length);
return null;
}
@@ -192,16 +98,18 @@ namespace DiscImageChef.Decoders.CD
public static string Prettify(CDFullTOC? CDFullTOCResponse)
{
if(CDFullTOCResponse == null) return null;
if(CDFullTOCResponse == null)
return null;
CDFullTOC response = CDFullTOCResponse.Value;
StringBuilder sb = new StringBuilder();
var sb = new StringBuilder();
int lastSession = 0;
sb.AppendFormat("First complete session number: {0}", response.FirstCompleteSession).AppendLine();
sb.AppendFormat("Last complete session number: {0}", response.LastCompleteSession).AppendLine();
foreach(TrackDataDescriptor descriptor in response.TrackDescriptors)
if((descriptor.CONTROL & 0x08) == 0x08 ||
descriptor.ADR != 1 && descriptor.ADR != 5 && descriptor.ADR != 4 && descriptor.ADR != 6 ||
@@ -240,31 +148,40 @@ namespace DiscImageChef.Decoders.CD
case 0xA0 when descriptor.ADR == 4:
{
sb.AppendFormat("First video track number: {0}", descriptor.PMIN).AppendLine();
switch(descriptor.PSEC)
{
case 0x10:
sb.AppendLine("CD-V single in NTSC format with digital stereo sound");
break;
case 0x11:
sb.AppendLine("CD-V single in NTSC format with digital bilingual sound");
break;
case 0x12:
sb.AppendLine("CD-V disc in NTSC format with digital stereo sound");
break;
case 0x13:
sb.AppendLine("CD-V disc in NTSC format with digital bilingual sound");
break;
case 0x20:
sb.AppendLine("CD-V single in PAL format with digital stereo sound");
break;
case 0x21:
sb.AppendLine("CD-V single in PAL format with digital bilingual sound");
break;
case 0x22:
sb.AppendLine("CD-V disc in PAL format with digital stereo sound");
break;
case 0x23:
sb.AppendLine("CD-V disc in PAL format with digital bilingual sound");
break;
}
@@ -274,63 +191,80 @@ namespace DiscImageChef.Decoders.CD
case 0xA0 when descriptor.ADR == 1:
{
sb.AppendFormat("First track number: {0} (", descriptor.PMIN);
switch((TocControl)(descriptor.CONTROL & 0x0D))
{
case TocControl.TwoChanNoPreEmph:
sb.Append(StereoNoPre);
break;
case TocControl.TwoChanPreEmph:
sb.Append(StereoPreEm);
break;
case TocControl.FourChanNoPreEmph:
sb.Append(QuadNoPreEm);
break;
case TocControl.FourChanPreEmph:
sb.Append(QuadPreEmph);
break;
case TocControl.DataTrack:
sb.Append(DataUnintrp);
break;
case TocControl.DataTrackIncremental:
sb.Append(DataIncrtly);
break;
}
sb.AppendLine(")");
sb.AppendFormat("Disc type: {0}", descriptor.PSEC).AppendLine();
//sb.AppendFormat("Absolute time: {3:D2}:{0:D2}:{1:D2}:{2:D2}", descriptor.Min, descriptor.Sec, descriptor.Frame, descriptor.HOUR).AppendLine();
break;
}
case 0xA1 when descriptor.ADR == 4:
sb.AppendFormat("Last video track number: {0}", descriptor.PMIN).AppendLine();
break;
case 0xA1 when descriptor.ADR == 1:
{
sb.AppendFormat("Last track number: {0} (", descriptor.PMIN);
switch((TocControl)(descriptor.CONTROL & 0x0D))
{
case TocControl.TwoChanNoPreEmph:
sb.Append(StereoNoPre);
break;
case TocControl.TwoChanPreEmph:
sb.Append(StereoPreEm);
break;
case TocControl.FourChanNoPreEmph:
sb.Append(QuadNoPreEm);
break;
case TocControl.FourChanPreEmph:
sb.Append(QuadPreEmph);
break;
case TocControl.DataTrack:
sb.Append(DataUnintrp);
break;
case TocControl.DataTrackIncremental:
sb.Append(DataIncrtly);
break;
}
sb.AppendLine(")");
//sb.AppendFormat("Absolute time: {3:D2}:{0:D2}:{1:D2}:{2:D2}", descriptor.Min, descriptor.Sec, descriptor.Frame, descriptor.HOUR).AppendLine();
break;
}
@@ -343,8 +277,9 @@ namespace DiscImageChef.Decoders.CD
descriptor.PHOUR).AppendLine();
else
sb.AppendFormat("Lead-out start position: {0:D2}:{1:D2}:{2:D2}",
descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME)
.AppendLine();
descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME).
AppendLine();
//sb.AppendFormat("Absolute time: {3:D2}:{0:D2}:{1:D2}:{2:D2}", descriptor.Min, descriptor.Sec, descriptor.Frame, descriptor.HOUR).AppendLine();
switch((TocControl)(descriptor.CONTROL & 0x0D))
@@ -354,10 +289,12 @@ namespace DiscImageChef.Decoders.CD
case TocControl.FourChanNoPreEmph:
case TocControl.FourChanPreEmph:
sb.AppendLine("Lead-out is audio type");
break;
case TocControl.DataTrack:
case TocControl.DataTrackIncremental:
sb.AppendLine("Lead-out is data type");
break;
}
@@ -366,21 +303,24 @@ namespace DiscImageChef.Decoders.CD
case 0xF0:
{
sb.AppendFormat("Book type: 0x{0:X2}", descriptor.PMIN);
sb.AppendFormat("Material type: 0x{0:X2}", descriptor.PSEC);
sb.AppendFormat("Book type: 0x{0:X2}", descriptor.PMIN);
sb.AppendFormat("Material type: 0x{0:X2}", descriptor.PSEC);
sb.AppendFormat("Moment of inertia: 0x{0:X2}", descriptor.PFRAME);
if(descriptor.PHOUR > 0)
sb.AppendFormat("Absolute time: {3:D2}:{0:D2}:{1:D2}:{2:D2}", descriptor.Min,
descriptor.Sec, descriptor.Frame, descriptor.HOUR).AppendLine();
else
sb.AppendFormat("Absolute time: {0:D2}:{1:D2}:{2:D2}", descriptor.Min,
descriptor.Sec, descriptor.Frame).AppendLine();
break;
}
default:
{
if(descriptor.POINT >= 0x01 && descriptor.POINT <= 0x63)
if(descriptor.POINT >= 0x01 &&
descriptor.POINT <= 0x63)
if(descriptor.ADR == 4)
sb.AppendFormat("Video track {3} starts at: {0:D2}:{1:D2}:{2:D2}",
descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME,
@@ -391,7 +331,8 @@ namespace DiscImageChef.Decoders.CD
if((TocControl)(descriptor.CONTROL & 0x0D) == TocControl.DataTrack ||
(TocControl)(descriptor.CONTROL & 0x0D) ==
TocControl.DataTrackIncremental) type = "Data";
TocControl.DataTrackIncremental)
type = "Data";
if(descriptor.PHOUR > 0)
sb.AppendFormat("{5} track {3} starts at: {4:D2}:{0:D2}:{1:D2}:{2:D2} (",
@@ -406,21 +347,27 @@ namespace DiscImageChef.Decoders.CD
{
case TocControl.TwoChanNoPreEmph:
sb.Append(StereoNoPre);
break;
case TocControl.TwoChanPreEmph:
sb.Append(StereoPreEm);
break;
case TocControl.FourChanNoPreEmph:
sb.Append(QuadNoPreEm);
break;
case TocControl.FourChanPreEmph:
sb.Append(QuadPreEmph);
break;
case TocControl.DataTrack:
sb.Append(DataUnintrp);
break;
case TocControl.DataTrackIncremental:
sb.Append(DataIncrtly);
break;
}
@@ -457,24 +404,26 @@ namespace DiscImageChef.Decoders.CD
{
if(descriptor.PHOUR > 0)
{
sb
.AppendFormat("Start of next possible program in the recordable area of the disc: {3:D2}:{0:D2}:{1:D2}:{2:D2}",
sb.
AppendFormat("Start of next possible program in the recordable area of the disc: {3:D2}:{0:D2}:{1:D2}:{2:D2}",
descriptor.Min, descriptor.Sec, descriptor.Frame,
descriptor.HOUR).AppendLine();
sb
.AppendFormat("Maximum start of outermost Lead-out in the recordable area of the disc: {3:D2}:{0:D2}:{1:D2}:{2:D2}",
sb.
AppendFormat("Maximum start of outermost Lead-out in the recordable area of the disc: {3:D2}:{0:D2}:{1:D2}:{2:D2}",
descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME,
descriptor.PHOUR).AppendLine();
}
else
{
sb
.AppendFormat("Start of next possible program in the recordable area of the disc: {0:D2}:{1:D2}:{2:D2}",
sb.
AppendFormat("Start of next possible program in the recordable area of the disc: {0:D2}:{1:D2}:{2:D2}",
descriptor.Min, descriptor.Sec, descriptor.Frame).AppendLine();
sb
.AppendFormat("Maximum start of outermost Lead-out in the recordable area of the disc: {0:D2}:{1:D2}:{2:D2}",
descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME)
.AppendLine();
sb.
AppendFormat("Maximum start of outermost Lead-out in the recordable area of the disc: {0:D2}:{1:D2}:{2:D2}",
descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME).
AppendLine();
}
break;
@@ -482,9 +431,11 @@ namespace DiscImageChef.Decoders.CD
case 0xB1:
{
sb.AppendFormat("Number of skip interval pointers: {0}", descriptor.PMIN)
.AppendLine();
sb.AppendFormat("Number of skip interval pointers: {0}", descriptor.PMIN).
AppendLine();
sb.AppendFormat("Number of skip track pointers: {0}", descriptor.PSEC).AppendLine();
break;
}
@@ -499,22 +450,25 @@ namespace DiscImageChef.Decoders.CD
sb.AppendFormat("Skip track {0}", descriptor.PMIN).AppendLine();
sb.AppendFormat("Skip track {0}", descriptor.PSEC).AppendLine();
sb.AppendFormat("Skip track {0}", descriptor.PFRAME).AppendLine();
break;
}
case 0xC0:
{
sb.AppendFormat("Optimum recording power: 0x{0:X2}", descriptor.Min).AppendLine();
if(descriptor.PHOUR > 0)
sb
.AppendFormat("Start time of the first Lead-in area in the disc: {3:D2}:{0:D2}:{1:D2}:{2:D2}",
sb.
AppendFormat("Start time of the first Lead-in area in the disc: {3:D2}:{0:D2}:{1:D2}:{2:D2}",
descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME,
descriptor.PHOUR).AppendLine();
else
sb
.AppendFormat("Start time of the first Lead-in area in the disc: {0:D2}:{1:D2}:{2:D2}",
descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME)
.AppendLine();
sb.
AppendFormat("Start time of the first Lead-in area in the disc: {0:D2}:{1:D2}:{2:D2}",
descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME).
AppendLine();
break;
}
@@ -528,6 +482,7 @@ namespace DiscImageChef.Decoders.CD
sb.AppendFormat("PMIN = {0}", descriptor.PMIN).AppendLine();
sb.AppendFormat("PSEC = {0}", descriptor.PSEC).AppendLine();
sb.AppendFormat("PFRAME = {0}", descriptor.PFRAME).AppendLine();
break;
}
@@ -535,23 +490,25 @@ namespace DiscImageChef.Decoders.CD
{
if(descriptor.PHOUR > 0)
{
sb
.AppendFormat("Start position of outer part lead-in area: {3:D2}:{0:D2}:{1:D2}:{2:D2}",
sb.
AppendFormat("Start position of outer part lead-in area: {3:D2}:{0:D2}:{1:D2}:{2:D2}",
descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME,
descriptor.PHOUR).AppendLine();
sb
.AppendFormat("Stop position of inner part lead-out area: {3:D2}:{0:D2}:{1:D2}:{2:D2}",
sb.
AppendFormat("Stop position of inner part lead-out area: {3:D2}:{0:D2}:{1:D2}:{2:D2}",
descriptor.Min, descriptor.Sec, descriptor.Frame,
descriptor.HOUR).AppendLine();
}
else
{
sb
.AppendFormat("Start position of outer part lead-in area: {0:D2}:{1:D2}:{2:D2}",
descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME)
.AppendLine();
sb
.AppendFormat("Stop position of inner part lead-out area: {0:D2}:{1:D2}:{2:D2}",
sb.
AppendFormat("Start position of outer part lead-in area: {0:D2}:{1:D2}:{2:D2}",
descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME).
AppendLine();
sb.
AppendFormat("Stop position of inner part lead-out area: {0:D2}:{1:D2}:{2:D2}",
descriptor.Min, descriptor.Sec, descriptor.Frame).AppendLine();
}
@@ -560,14 +517,16 @@ namespace DiscImageChef.Decoders.CD
default:
{
if(descriptor.POINT >= 0x01 && descriptor.POINT <= 0x40)
if(descriptor.POINT >= 0x01 &&
descriptor.POINT <= 0x40)
{
sb
.AppendFormat("Start time for interval that should be skipped: {0:D2}:{1:D2}:{2:D2}",
descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME)
.AppendLine();
sb
.AppendFormat("Ending time for interval that should be skipped: {0:D2}:{1:D2}:{2:D2}",
sb.
AppendFormat("Start time for interval that should be skipped: {0:D2}:{1:D2}:{2:D2}",
descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME).
AppendLine();
sb.
AppendFormat("Ending time for interval that should be skipped: {0:D2}:{1:D2}:{2:D2}",
descriptor.Min, descriptor.Sec, descriptor.Frame).AppendLine();
}
else
@@ -597,6 +556,7 @@ namespace DiscImageChef.Decoders.CD
{
uint id = (uint)((descriptor.Min << 16) + (descriptor.Sec << 8) + descriptor.Frame);
sb.AppendFormat("Disc ID: {0:X6}", id & 0x00FFFFFF).AppendLine();
break;
}
}
@@ -608,7 +568,52 @@ namespace DiscImageChef.Decoders.CD
public static string Prettify(byte[] CDFullTOCResponse)
{
CDFullTOC? decoded = Decode(CDFullTOCResponse);
return Prettify(decoded);
}
public struct CDFullTOC
{
/// <summary>Total size of returned session information minus this field</summary>
public ushort DataLength;
/// <summary>First complete session number in hex</summary>
public byte FirstCompleteSession;
/// <summary>Last complete session number in hex</summary>
public byte LastCompleteSession;
/// <summary>Track descriptors</summary>
public TrackDataDescriptor[] TrackDescriptors;
}
public struct TrackDataDescriptor
{
/// <summary>Byte 0 Session number in hex</summary>
public byte SessionNumber;
/// <summary>Byte 1, bits 7 to 4 Type of information in Q subchannel of block where this TOC entry was found</summary>
public byte ADR;
/// <summary>Byte 1, bits 3 to 0 Track attributes</summary>
public byte CONTROL;
/// <summary>Byte 2</summary>
public byte TNO;
/// <summary>Byte 3</summary>
public byte POINT;
/// <summary>Byte 4</summary>
public byte Min;
/// <summary>Byte 5</summary>
public byte Sec;
/// <summary>Byte 6</summary>
public byte Frame;
/// <summary>Byte 7, CD only</summary>
public byte Zero;
/// <summary>Byte 7, bits 7 to 4, DDCD only</summary>
public byte HOUR;
/// <summary>Byte 7, bits 3 to 0, DDCD only</summary>
public byte PHOUR;
/// <summary>Byte 8</summary>
public byte PMIN;
/// <summary>Byte 9</summary>
public byte PSEC;
/// <summary>Byte 10</summary>
public byte PFRAME;
}
}
}