diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-10-26 15:29:56 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-10-26 15:29:56 -0400 |
| commit | 3d7f75eea3465a34b443cf90d0affe5a637faf5d (patch) | |
| tree | 47be26c509373d62c560f65b2721c3185ba0e78d /BDInfo/TSCodecVC1.cs | |
| parent | 0189f4c49dc89654e6aa10c5dd0fc50a0984bfec (diff) | |
more steps to make provider project portable
Diffstat (limited to 'BDInfo/TSCodecVC1.cs')
| -rw-r--r-- | BDInfo/TSCodecVC1.cs | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/BDInfo/TSCodecVC1.cs b/BDInfo/TSCodecVC1.cs new file mode 100644 index 000000000..164ef8c47 --- /dev/null +++ b/BDInfo/TSCodecVC1.cs @@ -0,0 +1,131 @@ +//============================================================================ +// BDInfo - Blu-ray Video and Audio Analysis Tool +// Copyright © 2010 Cinema Squid +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//============================================================================= + + +namespace BDInfo +{ + public abstract class TSCodecVC1 + { + public static void Scan( + TSVideoStream stream, + TSStreamBuffer buffer, + ref string tag) + { + int parse = 0; + byte frameHeaderParse = 0; + byte sequenceHeaderParse = 0; + bool isInterlaced = false; + + for (int i = 0; i < buffer.Length; i++) + { + parse = (parse << 8) + buffer.ReadByte(); + + if (parse == 0x0000010D) + { + frameHeaderParse = 4; + } + else if (frameHeaderParse > 0) + { + --frameHeaderParse; + if (frameHeaderParse == 0) + { + uint pictureType = 0; + if (isInterlaced) + { + if ((parse & 0x80000000) == 0) + { + pictureType = + (uint)((parse & 0x78000000) >> 13); + } + else + { + pictureType = + (uint)((parse & 0x3c000000) >> 12); + } + } + else + { + pictureType = + (uint)((parse & 0xf0000000) >> 14); + } + + if ((pictureType & 0x20000) == 0) + { + tag = "P"; + } + else if ((pictureType & 0x10000) == 0) + { + tag = "B"; + } + else if ((pictureType & 0x8000) == 0) + { + tag = "I"; + } + else if ((pictureType & 0x4000) == 0) + { + tag = "BI"; + } + else + { + tag = null; + } + if (stream.IsInitialized) return; + } + } + else if (parse == 0x0000010F) + { + sequenceHeaderParse = 6; + } + else if (sequenceHeaderParse > 0) + { + --sequenceHeaderParse; + switch (sequenceHeaderParse) + { + case 5: + int profileLevel = ((parse & 0x38) >> 3); + if (((parse & 0xC0) >> 6) == 3) + { + stream.EncodingProfile = string.Format( + "Advanced Profile {0}", profileLevel); + } + else + { + stream.EncodingProfile = string.Format( + "Main Profile {0}", profileLevel); + } + break; + + case 0: + if (((parse & 0x40) >> 6) > 0) + { + isInterlaced = true; + } + else + { + isInterlaced = false; + } + break; + } + stream.IsVBR = true; + stream.IsInitialized = true; + } + } + } + } +} |
