aboutsummaryrefslogtreecommitdiff
path: root/BDInfo/TSCodecVC1.cs
diff options
context:
space:
mode:
authorLukePulverenti <luke.pulverenti@gmail.com>2013-02-20 20:33:05 -0500
committerLukePulverenti <luke.pulverenti@gmail.com>2013-02-20 20:33:05 -0500
commit767cdc1f6f6a63ce997fc9476911e2c361f9d402 (patch)
tree49add55976f895441167c66cfa95e5c7688d18ce /BDInfo/TSCodecVC1.cs
parent845554722efaed872948a9e0f7202e3ef52f1b6e (diff)
Pushing missing changes
Diffstat (limited to 'BDInfo/TSCodecVC1.cs')
-rw-r--r--BDInfo/TSCodecVC1.cs134
1 files changed, 134 insertions, 0 deletions
diff --git a/BDInfo/TSCodecVC1.cs b/BDInfo/TSCodecVC1.cs
new file mode 100644
index 000000000..3cfd50cba
--- /dev/null
+++ b/BDInfo/TSCodecVC1.cs
@@ -0,0 +1,134 @@
+//============================================================================
+// 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
+//=============================================================================
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+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;
+ }
+ }
+ }
+ }
+}