/*************************************************************************** The Disc Image Chef ---------------------------------------------------------------------------- Filename : BD.cs Version : 1.0 Author(s) : Natalia Portillo Component : Decoders. Revision : $Revision$ Last change by : $Author$ Date : $Date$ --[ Description ] ---------------------------------------------------------- Decodes DVD structures. --[ License ] -------------------------------------------------------------- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ---------------------------------------------------------------------------- Copyright (C) 2011-2014 Claunia.com ****************************************************************************/ //$Id$ using System; using System.Text; namespace DiscImageChef.Decoders { /// /// 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 /// ECMA 365 /// public static class DVD { #region Public enumerations public enum DiskCategory : byte { DVDROM = 0x00, DVDRAM = 0x01, DVDR = 0x02, DVDRW = 0x03, HDDVDROM = 0x04, HDDVDRAM = 0x05, HDDVDR = 0x06, Reserved1 = 0x07, UMD = 0x08, DVDPRW = 0x09, DVDPR = 0x0A, Reserved2 = 0x0B, Reserved3 = 0x0C, DVDPRWDL = 0x0D, DVDPRDL = 0x0E, Reserved4 = 0x0F } public enum MaximumRateField : byte { /// /// 2.52 Mbps /// TwoMbps = 0x00, /// /// 5.04 Mbps /// FiveMbps = 0x01, /// /// 10.08 Mbps /// TenMbps = 0x02, /// /// 20.16 Mbps /// TwentyMbps = 0x03, /// /// 30.24 Mbps /// ThirtyMbps = 0x04, Unspecified = 0x0F } public enum LayerTypeFieldMask : byte { Embossed = 0x01, Recordable = 0x02, Rewritable = 0x04, Reserved = 0x08 } public enum LinearDensityField : byte { /// /// 0.267 μm/bit /// TwoSix = 0x00, /// /// 0.293 μm/bit /// TwoNine = 0x01, /// /// 0.409 to 0.435 μm/bit /// FourZero = 0x02, /// /// 0.280 to 0.291 μm/bit /// TwoEight = 0x04, /// /// 0.153 μm/bit /// OneFive = 0x05, /// /// 0.130 to 0.140 μm/bit /// OneThree = 0x06, /// /// 0.353 μm/bit /// ThreeFive = 0x08, } public enum TrackDensityField : byte { /// /// 0.74 μm/track /// Seven = 0x00, /// /// 0.80 μm/track /// Eight = 0x01, /// /// 0.615 μm/track /// Six = 0x02, /// /// 0.40 μm/track /// Four = 0x03, /// /// 0.34 μm/track /// Three = 0x04 } public enum CopyrightType : byte { /// /// There is no copy protection /// NoProtection = 0x00, /// /// Copy protection is CSS/CPPM /// CSS = 0x01, /// /// Copy protection is CPRM /// CPRM = 0x02, /// /// Copy protection is AACS /// AACS = 0x10 } public enum WPDiscTypes : byte { /// /// Should not write without a cartridge /// DoNotWrite = 0x00, /// /// Can write without a cartridge /// CanWrite = 0x01, Reserved1 = 0x02, Reserved2 = 0x03 } #endregion #region Public structures public struct PhysicalFormatInformation { /// /// Bytes 0 to 1 /// Data length /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Byte 4, bits 7 to 4 /// Disk category field /// public byte DiskCategory; /// /// Byte 4, bits 3 to 0 /// Media version /// public byte PartVersion; /// /// Byte 5, bits 7 to 4 /// 120mm if 0, 80mm if 1. If UMD (60mm) 0 also. Reserved rest of values /// public byte DiscSize; /// /// Byte 5, bits 3 to 0 /// Maximum data rate /// public byte MaximumRate; /// /// Byte 6, bit 7 /// Reserved /// public bool Reserved3; /// /// Byte 6, bits 6 to 5 /// Number of layers /// public byte Layers; /// /// Byte 6, bit 4 /// Track path /// public bool TrackPath; /// /// Byte 6, bits 3 to 0 /// Layer type /// public byte LayerType; /// /// Byte 7, bits 7 to 4 /// Linear density field /// public byte LinearDensity; /// /// Byte 7, bits 3 to 0 /// Track density field /// public byte TrackDensity; /// /// Bytes 8 to 11 /// PSN where Data Area starts /// public UInt32 DataAreaStartPSN; /// /// Bytes 12 to 15 /// PSN where Data Area ends /// public UInt32 DataAreaEndPSN; /// /// Bytes 16 to 19 /// PSN where Data Area ends in Layer 0 /// public UInt32 Layer0EndPSN; /// /// Byte 20, bit 7 /// True if BCA exists. GC/Wii discs do not have this bit set, but there is a BCA, making it unreadable in normal DVD drives /// public bool BCA; /// /// Byte 20, bits 6 to 0 /// Reserved /// public byte Reserved4; /// /// Bytes 21 to 22 /// UMD only, media attribute, application-defined, part of media specific in rest of discs /// public UInt16 MediaAttribute; /// /// Bytes 21 to 2051, set to zeroes in UMD (at least according to ECMA). /// Media specific /// public byte[] MediaSpecific; } public struct LeadInCopyright { /// /// Bytes 0 to 1 /// Data length /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Byte 4 /// Copy protection system type /// public byte CopyrightType; /// /// Byte 5 /// Bitmask of regions where this disc is playable /// public byte RegionInformation; /// /// Byte 6 /// Reserved /// public byte Reserved3; /// /// Byte 7 /// Reserved /// public byte Reserved4; } public struct DiscKey { /// /// Bytes 0 to 1 /// Data length /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Bytes 4 to 2052 /// Disc key for CSS, Album Identifier for CPPM /// public byte[] Key; } public struct BurstCuttingArea { /// /// Bytes 0 to 1 /// Data length /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Bytes 4 to end /// Burst cutting area contents, 12 to 188 bytes /// public byte[] BCA; } public struct DiscManufacturingInformation { /// /// Bytes 0 to 1 /// Data length /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Bytes 4 to 2052 /// Disc Manufacturing Information /// public byte[] DMI; } public struct DiscMediaIdentifier { /// /// Bytes 0 to 1 /// Data length /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Bytes 4 to end /// Disc Media Identifier for CPRM /// public byte[] MediaIdentifier; } public struct DiscMediaKeyBlock { /// /// Bytes 0 to 1 /// Data length /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Bytes 4 to end /// Disc Media Key Block for CPRM /// public byte[] MediaKeyBlock; } public struct DiscDefinitionStructure { /// /// Bytes 0 to 1 /// Data length /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Bytes 4 to 2052 /// DVD-RAM / HD DVD-RAM disc definition structure /// public byte[] DDS; } public struct MediumStatus { /// /// Bytes 0 to 1 /// Data length /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Byte 4, bit 7 /// Medium is in a cartridge /// public bool Cartridge; /// /// Byte 4, bit 6 /// Medium has been taken out/inserted in a cartridge /// public bool OUT; /// /// Byte 4, bits 5 to 4 /// Reserved /// public byte Reserved3; /// /// Byte 4, bit 3 /// Media is write protected by reason stablished in RAMSWI /// public bool MSWI; /// /// Byte 4, bit 2 /// Media is write protected by cartridge /// public bool CWP; /// /// Byte 4, bit 1 /// Media is persistently write protected /// public bool PWP; /// /// Byte 4, bit 0 /// Reserved /// public bool Reserved4; /// /// Byte 5 /// Writable status depending on cartridge /// public byte DiscType; /// /// Byte 6 /// Reserved /// public byte Reserved5; /// /// Byte 7 /// Reason of specific write protection, only defined 0x01 as "bare disc wp", and 0xFF as unspecified. Rest reserved. /// public byte RAMSWI; } public struct SpareAreaInformation { /// /// Bytes 0 to 1 /// Data length /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Bytes 4 to 7 /// Data length /// public UInt32 UnusedPrimaryBlocks; /// /// Bytes 8 to 11 /// Data length /// public UInt32 UnusedSupplementaryBlocks; /// /// Bytes 12 to 15 /// Data length /// public UInt32 AllocatedSupplementaryBlocks; } public struct LastBorderOutRMD { /// /// Bytes 0 to 1 /// Data length /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Bytes 4 to end /// RMD in last recorded Border-out /// public byte[] RMD; } public struct PreRecordedInformation { /// /// Bytes 0 to 1 /// Data length /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Bytes 4 to end /// Pre-recorded Information in Lead-in for writable media /// public byte[] PRI; } public struct UniqueDiscIdentifier { /// /// Bytes 0 to 1 /// Data length /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Byte 4 /// Reserved /// public byte Reserved3; /// /// Byte 5 /// Reserved /// public byte Reserved4; /// /// Bytes 6 to 7 /// Random number /// public UInt16 RandomNumber; /// /// Byte 8 to 11 /// Year /// public UInt32 Year; /// /// Byte 12 to 13 /// Month /// public UInt16 Month; /// /// Byte 14 to 15 /// Day /// public UInt16 Day; /// /// Byte 16 to 17 /// Hour /// public UInt16 Hour; /// /// Byte 18 to 19 /// Minute /// public UInt16 Minute; /// /// Byte 20 to 21 /// Second /// public UInt16 Second; } public struct PhysicalFormatInformationForWritables { /// /// Bytes 0 to 1 /// Data length /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Byte 4, bits 7 to 4 /// Disk category field /// public byte DiskCategory; /// /// Byte 4, bits 3 to 0 /// Media version /// public byte PartVersion; /// /// Byte 5, bits 7 to 4 /// 120mm if 0, 80mm if 1 /// public byte DiscSize; /// /// Byte 5, bits 3 to 0 /// Maximum data rate /// public byte MaximumRate; /// /// Byte 6, bit 7 /// Reserved /// public bool Reserved3; /// /// Byte 6, bits 6 to 5 /// Number of layers /// public byte Layers; /// /// Byte 6, bit 4 /// Track path /// public bool TrackPath; /// /// Byte 6, bits 3 to 0 /// Layer type /// public byte LayerType; /// /// Byte 7, bits 7 to 4 /// Linear density field /// public byte LinearDensity; /// /// Byte 7, bits 3 to 0 /// Track density field /// public byte TrackDensity; /// /// Bytes 8 to 11 /// PSN where Data Area starts /// public UInt32 DataAreaStartPSN; /// /// Bytes 12 to 15 /// PSN where Data Area ends /// public UInt32 DataAreaEndPSN; /// /// Bytes 16 to 19 /// PSN where Data Area ends in Layer 0 /// public UInt32 Layer0EndPSN; /// /// Byte 20, bit 7 /// True if BCA exists /// public bool BCA; /// /// Byte 20, bits 6 to 0 /// Reserved /// public byte Reserved4; /// /// Bytes 21 to 2051 /// Media specific, content defined in each specification /// public byte[] MediaSpecific; } public struct ADIPInformation { /// /// Bytes 0 to 1 /// Data length /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Bytes 4 to 259 /// ADIP, defined in DVD standards /// public byte[] ADIP; } public struct HDLeadInCopyright { /// /// Bytes 0 to 1 /// Data length /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Bytes 4 to 2052 /// HD DVD Lead-In Copyright Information /// public byte[] CopyrightInformation; } public struct HDMediumStatus { /// /// Bytes 0 to 1 /// Data length /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Byte 4, bits 7 to 1 /// Reserved /// public byte Reserved3; /// /// Byte 4, bit 0 /// Test Zone has been extended /// public bool ExtendedTestZone; /// /// Byte 5 /// Number of remaining RMDs in RDZ /// public byte RemainingRMDs; /// /// Bytes 6 to 7 /// Number of remaining RMDs in current RMZ /// public UInt16 CurrentRemainingRMDs; } public struct LayerCapacity { /// /// Bytes 0 to 1 /// Data length /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Byte 4, bit 7 /// If set, L0 capacity is immutable /// public bool InitStatus; /// /// Byte 4, bits 6 to 0 /// Reserved /// public byte Reserved3; /// /// Byte 5 /// Reserved /// public byte Reserved4; /// /// Byte 6 /// Reserved /// public byte Reserved5; /// /// Byte 7 /// Reserved /// public byte Reserved6; /// /// Byte 8 to 11 /// L0 Data Area Capacity /// public UInt32 Capacity; } public struct MiddleZoneStartAddress { /// /// Bytes 0 to 1 /// Data length = 10 /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Byte 4, bit 7 /// If set, L0 shifter middle area is immutable /// public bool InitStatus; /// /// Byte 4, bits 6 to 0 /// Reserved /// public byte Reserved3; /// /// Byte 5 /// Reserved /// public byte Reserved4; /// /// Byte 6 /// Reserved /// public byte Reserved5; /// /// Byte 7 /// Reserved /// public byte Reserved6; /// /// Byte 8 to 11 /// Start LBA of Shifted Middle Area on L0 /// public UInt32 ShiftedMiddleAreaStartAddress; } public struct JumpIntervalSize { /// /// Bytes 0 to 1 /// Data length = 10 /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Byte 4 /// Reserved /// public byte Reserved3; /// /// Byte 5 /// Reserved /// public byte Reserved4; /// /// Byte 6 /// Reserved /// public byte Reserved5; /// /// Byte 7 /// Reserved /// public byte Reserved6; /// /// Byte 8 to 11 /// Jump Interval size for the Regular Interval Layer Jump /// public UInt32 Size; } public struct ManualLayerJumpAddress { /// /// Bytes 0 to 1 /// Data length = 10 /// public UInt16 DataLength; /// /// Byte 2 /// Reserved /// public byte Reserved1; /// /// Byte 3 /// Reserved /// public byte Reserved2; /// /// Byte 4 /// Reserved /// public byte Reserved3; /// /// Byte 5 /// Reserved /// public byte Reserved4; /// /// Byte 6 /// Reserved /// public byte Reserved5; /// /// Byte 7 /// Reserved /// public byte Reserved6; /// /// Byte 8 to 11 /// LBA for the manual layer jump /// public UInt32 LBA; } #endregion Public structures } }