本文整理汇总了C#中Variant.Compact方法的典型用法代码示例。如果您正苦于以下问题:C# Variant.Compact方法的具体用法?C# Variant.Compact怎么用?C# Variant.Compact使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Variant
的用法示例。
在下文中一共展示了Variant.Compact方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public bool Init(byte[] pSPS, byte[] pPPS)
{
Clear();
_SPSInfo = Variant.Get();
_PPSInfo = Variant.Get();
if (pSPS.Length == 0 || pSPS.Length > 65535 || pPPS.Length == 0 || pPPS.Length > 65535)
{
Logger.FATAL("Invalid SPS/PPS lengths");
return false;
}
SPS = pSPS;
PPS = pPPS;
Rate = 90000;
var ms = new MemoryStream(SpsLength-1);
for (ushort i = 1; i < pSPS.Length; i++)
{
if (i + 2 < pSPS.Length - 1 && SPS[i] == 0 && SPS[i + 1] == 0 && SPS[i + 2] == 3)
{
ms.WriteByte(0);
ms.WriteByte(0);
i += 2;
}
else
{
ms.WriteByte(SPS[i]);
}
}
ms.Position = 0;
using (var spsReader = new BitReader(ms))
{
if (!ReadSPS(spsReader, _SPSInfo))
{
Logger.WARN("Unable to parse SPS");
}
else
{
_SPSInfo.Compact();
Width = ((uint)_SPSInfo["pic_width_in_mbs_minus1"] + 1) * 16;
Height = ((uint)_SPSInfo["pic_height_in_map_units_minus1"] + 1) * 16;
// FINEST("_width: %u (%u); _height: %u (%u)",
// _width, (uint32_t) _SPSInfo["pic_width_in_mbs_minus1"],
// _height, (uint32_t) _SPSInfo["pic_height_in_map_units_minus1"]);
}
}
ms = new MemoryStream(PpsLength-1);
for (ushort i = 1; i < pPPS.Length; i++)
{
if (i + 2 < pPPS.Length - 1 && PPS[i] == 0 && PPS[i + 1] == 0 && PPS[i + 2] == 3)
{
ms.WriteByte(0);
ms.WriteByte(0);
i += 2;
}
else
{
ms.WriteByte(PPS[i]);
}
}
ms.Position = 0;
using (var ppsReader = new BitReader(ms))
{
if (!ReadPPS(ppsReader, _PPSInfo))
{
Logger.WARN("Unable to read PPS info");
}
}
return true;
}