NalUnit.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace MatrixIO.IO.MpegTs
  6. {
  7. public enum NalUnitTypeCode
  8. {
  9. Unspecified = 0,
  10. SliceLayerWithoutPartitioningNonIDR = 1,
  11. SliceDataPartitionLayerA = 2,
  12. SliceDataPartitionLayerB = 3,
  13. SliceDataPartitionLayerC = 4,
  14. SliceLayerWithoutPartitioningIDR = 5,
  15. SupplementalEnahancementInformation = 6,
  16. SequanceParameterSet = 7,
  17. PictureParameterSet = 8,
  18. AccessUnitDelimiter = 9,
  19. EndOfSequence = 10,
  20. EndOfStream = 11,
  21. FillerData = 12,
  22. // 13..23 Reserved
  23. // 24..31 Unspecified
  24. }
  25. public class NalUnit
  26. {
  27. // 00 00 00 01
  28. private byte _header = 0x80;
  29. // 1 bit forbidden_zero_bit
  30. // 2 bit nal_ref_idc
  31. // 5 bit nal_unit_type
  32. public NalUnit(byte[] buffer, int offset, int length)
  33. {
  34. int position = offset;
  35. if (buffer[position++] != 0 || buffer[position++] != 0 || buffer[position++] != 1 ||
  36. (buffer[position] & 0x80) != 0x80)
  37. throw new ArgumentException("NAL Unit does not start with 0x000001 Start Code Prefix.");
  38. _header = buffer[position++];
  39. // TODO: Deserialize NAL Unit.
  40. }
  41. }
  42. }