private static bool IsPotentialFalseHit(IResultNode resultNode) { if (resultNode.Length < 0x200) { return(true); } var firstMacroblockInSlice = resultNode.FindAttributeByName(FirstMacroblockInSliceName); if (firstMacroblockInSlice == null) { return(true); } var pictureParamaterSetId = resultNode.FindAttributeByName(PictureParameterSetIdName); if (pictureParamaterSetId == null) { return(true); } var sliceType = resultNode.FindAttributeByName(SliceTypeName); if (sliceType == null) { return(true); } return(H264Utils.ComputeFalseHitLikelihoodScore((uint)firstMacroblockInSlice.Value, (uint)pictureParamaterSetId.Value, (SliceType)(int)sliceType.Value) >= 1); }
private static IDataPacket ProducePlayableExport(IResultNode result, IDataPacket h264StartCodePrefixDataPacket) { if (result.DataFormat != CodecID.H264) { return(result); } if (result.FindAttributeByName("StartCodePrefix") != null) { return(result); } string nalUnitType = result.FindAttributeByName("NalUnitType").ValueAsString; int lengthPrefixBytes = ((nalUnitType == "7") || (nalUnitType == "8")) ? 2 : 4; return(h264StartCodePrefixDataPacket.Append(result.GetSubPacket(lengthPrefixBytes, (result.Length - lengthPrefixBytes)))); }
private static bool IsIntraSlice(IResultNode resultNode) { if (!IsSlice(resultNode) || (resultNode.Name != IdrPictureSlice.Name)) { return(false); } var sliceTypeAttribute = resultNode.FindAttributeByName(SliceTypeName); if (sliceTypeAttribute == null) { return(false); } if ((int)sliceTypeAttribute.Value == (int)SliceType.I) { return(true); } if ((int)sliceTypeAttribute.Value == (int)SliceType.OnlyI) { return(true); } return(false); }
private static uint?GetFirstMacroblockInSlice(IResultNode resultNode) { var firstMacroblockInSlice = resultNode.FindAttributeByName(FirstMacroblockInSliceName); if (firstMacroblockInSlice == null) { return(null); } return((uint)firstMacroblockInSlice.Value); }
private static bool IsH264NalUnitResultFoThaRealzWhenAlreadyH264(IResultNode result) { if (result.FindAttributeByName("NalUnitLength") != null) { return(true); } foreach (var child in result.Children) { if (IsH264NalUnitResultFoThaRealzWhenAlreadyH264(child)) { return(true); } } return(false); }
private static bool IsH264NalUnitStreamResult(IResultNode resultNode) { if ((resultNode.DataFormat == CodecID.H264) && (resultNode.FindAttributeByName("StartCodePrefix") == null)) { return(true); // NAL unit stream format } foreach (IResultNode childResult in resultNode.Children) { if (IsH264NalUnitStreamResult(childResult)) { return(true); } } return(false); }
public bool IsKeyFrame(IResultNode resultNode) { if (resultNode.Name != PictureHeader.Name) { return(false); } var pictureCodingTypeAttribute = resultNode.FindAttributeByName(Enum.GetName(typeof(PictureHeader.Attribute), PictureHeader.Attribute.PictureCodingType)); if (pictureCodingTypeAttribute == null) { return(false); } return((int)pictureCodingTypeAttribute.Value == (int)PictureCodingType.IType); }
private long TrimResult() { if (_lastHeader == null) { return(0L); } // Trim zero byte stuffing from last header (if any) string zeroByteStuffingName = Enum.GetName(typeof(NalUnitParser.Attribute), NalUnitParser.Attribute.TrailingZeroBytes); var zeroByteStuffingAttribute = _lastHeader.FindAttributeByName(zeroByteStuffingName); if (zeroByteStuffingAttribute == null) { return(0L); } uint byteCount = (uint)zeroByteStuffingAttribute.Value; // Rebuild the last header, omitting the zero byte stuffing attribute var resultNodeBuilder = new ResultNodeBuilder { Name = _lastHeader.Name, Metadata = _lastHeader, DataPacket = _lastHeader.GetSubPacket(0, (_lastHeader.Length - byteCount)) }; foreach (IResultAttribute attribute in _lastHeader.Attributes.Where(a => a.Name != zeroByteStuffingName)) { resultNodeBuilder.AddAttribute(attribute); } // Replace the last header with the new (trimmed) header IResultNode parent = _lastHeader.Parent; parent.RemoveChild(_lastHeader); parent.AddChild(resultNodeBuilder.Build()); // Compensate end offset for zero byte trimming return(-byteCount); }
private static bool IsH264NalUnitResult(IResultNode result) { return((result.DataFormat == Interface.CodecID.H264) && (result.FindAttributeByName(NalUnitLengthName) != null)); }
public IResultAttribute FindAttributeByName(string name) { return(_result.FindAttributeByName(name)); }
public ResultAttributeVerification VerifyAttribute(string attributeName) { return(new ResultAttributeVerification(_resultNode.FindAttributeByName(attributeName), "Attribute (" + attributeName + ") of " + _description)); }
protected override void OnGetCellData(Row row, Column column, CellData cellData) { base.OnGetCellData(row, column, cellData); if (column.Name == null) { return; } IResultNode result = row.Item as IResultNode; if (result == null) { return; } DefaultColumnIndex index; if (DefaultColumnExtensions.TryParse(column.Name, out index)) { switch (index) { case DefaultColumnIndex.Name: cellData.Value = result.Name; if (result.InputFile is IReferenceHeaderFile) { cellData.EvenStyle = new Style(cellData.EvenStyle) { ForeColor = Color.RoyalBlue, Font = new Font(cellData.EvenStyle.Font.FontFamily, cellData.EvenStyle.Font.SizeInPoints, FontStyle.Bold) }; cellData.OddStyle = new Style(cellData.OddStyle) { ForeColor = Color.RoyalBlue, Font = new Font(cellData.OddStyle.Font.FontFamily, cellData.OddStyle.Font.SizeInPoints, FontStyle.Bold) }; } break; case DefaultColumnIndex.Detector: cellData.Value = result.Detectors.First().Name; break; case DefaultColumnIndex.DetectorVersion: cellData.Value = _detectorFormatter.FormatVersion(result.Detectors.First()); break; case DefaultColumnIndex.Offset: cellData.Value = result.StartOffset; if (DisplayMode == DisplayMode.Hex) { cellData.Format = "{0:X}"; } break; case DefaultColumnIndex.Length: cellData.Value = result.Length; if (DisplayMode == DisplayMode.Hex) { cellData.Format = "{0:X}"; } break; case DefaultColumnIndex.EndOffset: cellData.Value = result.EndOffset; if (DisplayMode == DisplayMode.Hex) { cellData.Format = "{0:X}"; } break; case DefaultColumnIndex.File: IInputFile inputFile = result.InputFile; if (inputFile != null) { cellData.Value = (new FileInfo(inputFile.Name)).Name; cellData.ToolTip = inputFile.Name; cellData.AlwaysDisplayToolTip = true; } break; } } else { IResultAttribute attribute = result.FindAttributeByName(column.Name); if (attribute == null) { cellData.Value = string.Empty; } else { cellData.Value = attribute.ValueAsString; // Align the cell content depending its value. if ((attribute.Value.GetType() == typeof(string)) || (attribute.Value.GetType() == typeof(bool))) { cellData.EvenStyle = new Style(cellData.EvenStyle, _horzAlignmentNearStyleDelta); cellData.OddStyle = new Style(cellData.OddStyle, _horzAlignmentNearStyleDelta); } else { cellData.EvenStyle = new Style(cellData.EvenStyle, _horzAlignmentFarStyleDelta); cellData.OddStyle = new Style(cellData.OddStyle, _horzAlignmentFarStyleDelta); } } } }
/// <summary> /// Compares results on the values of an attribute. /// </summary> /// <param name="x">the first result to compare</param> /// <param name="y">the second result to compare</param> /// <param name="attributeName">the name of the attribute to compare</param> private static int CompareResultsByAttributeValue(IResultNode x, IResultNode y, string attributeName) { if (x == y) { return(0); } IResultAttribute attributeX = x.FindAttributeByName(attributeName); IResultAttribute attributeY = y.FindAttributeByName(attributeName); if (attributeX == attributeY) { return(0); } if (attributeX == null || attributeY == null) { return((attributeX == null) ? -1 : 1); } // Compare by object value if appropriate types object valueX = attributeX.Value; object valueY = attributeY.Value; if (valueX is byte && valueY is byte) { return(((byte)valueX).CompareTo((byte)valueY)); } else if (valueX is short && valueY is short) { return(((short)valueX).CompareTo((short)valueY)); } else if (valueX is ushort && valueY is ushort) { return(((ushort)valueX).CompareTo((ushort)valueY)); } else if (valueX is int && valueY is int) { return(((int)valueX).CompareTo((int)valueY)); } else if (valueX is uint && valueY is uint) { return(((uint)valueX).CompareTo((uint)valueY)); } else if (valueX is long && valueY is long) { return(((long)valueX).CompareTo((long)valueY)); } else if (valueX is ulong && valueY is ulong) { return(((ulong)valueX).CompareTo((ulong)valueY)); } else if (valueX is bool && valueY is bool) { return(((bool)valueX).CompareTo((bool)valueY)); } else if (valueX is float && valueY is float) { return(((float)valueX).CompareTo((float)valueY)); } else if (valueX is double && valueY is double) { return(((double)valueX).CompareTo((double)valueY)); } else if (valueX is decimal && valueY is decimal) { return(((decimal)valueX).CompareTo((decimal)valueY)); } // Compare by string value string stringX = attributeX.ValueAsString; string stringY = attributeY.ValueAsString; if (stringX == stringY) { return(0); } else if (stringX == null || stringY == null) { return((stringX == null) ? -1 : 1); } else { return(stringX.CompareTo(stringY)); } }