github.com/bluenviron/mediacommon@v1.9.3/pkg/codecs/h264/nalu_type.go (about)

     1  package h264
     2  
     3  import (
     4  	"fmt"
     5  )
     6  
     7  // NALUType is the type of a NALU.
     8  // Specification: ITU-T Rec. H.264, Table 7-1
     9  type NALUType uint8
    10  
    11  // NALU types.
    12  const (
    13  	NALUTypeNonIDR                        NALUType = 1
    14  	NALUTypeDataPartitionA                NALUType = 2
    15  	NALUTypeDataPartitionB                NALUType = 3
    16  	NALUTypeDataPartitionC                NALUType = 4
    17  	NALUTypeIDR                           NALUType = 5
    18  	NALUTypeSEI                           NALUType = 6
    19  	NALUTypeSPS                           NALUType = 7
    20  	NALUTypePPS                           NALUType = 8
    21  	NALUTypeAccessUnitDelimiter           NALUType = 9
    22  	NALUTypeEndOfSequence                 NALUType = 10
    23  	NALUTypeEndOfStream                   NALUType = 11
    24  	NALUTypeFillerData                    NALUType = 12
    25  	NALUTypeSPSExtension                  NALUType = 13
    26  	NALUTypePrefix                        NALUType = 14
    27  	NALUTypeSubsetSPS                     NALUType = 15
    28  	NALUTypeReserved16                    NALUType = 16
    29  	NALUTypeReserved17                    NALUType = 17
    30  	NALUTypeReserved18                    NALUType = 18
    31  	NALUTypeSliceLayerWithoutPartitioning NALUType = 19
    32  	NALUTypeSliceExtension                NALUType = 20
    33  	NALUTypeSliceExtensionDepth           NALUType = 21
    34  	NALUTypeReserved22                    NALUType = 22
    35  	NALUTypeReserved23                    NALUType = 23
    36  
    37  	// additional NALU types for RTP/H264
    38  	NALUTypeSTAPA  NALUType = 24
    39  	NALUTypeSTAPB  NALUType = 25
    40  	NALUTypeMTAP16 NALUType = 26
    41  	NALUTypeMTAP24 NALUType = 27
    42  	NALUTypeFUA    NALUType = 28
    43  	NALUTypeFUB    NALUType = 29
    44  )
    45  
    46  var naluTypeLabels = map[NALUType]string{
    47  	NALUTypeNonIDR:                        "NonIDR",
    48  	NALUTypeDataPartitionA:                "DataPartitionA",
    49  	NALUTypeDataPartitionB:                "DataPartitionB",
    50  	NALUTypeDataPartitionC:                "DataPartitionC",
    51  	NALUTypeIDR:                           "IDR",
    52  	NALUTypeSEI:                           "SEI",
    53  	NALUTypeSPS:                           "SPS",
    54  	NALUTypePPS:                           "PPS",
    55  	NALUTypeAccessUnitDelimiter:           "AccessUnitDelimiter",
    56  	NALUTypeEndOfSequence:                 "EndOfSequence",
    57  	NALUTypeEndOfStream:                   "EndOfStream",
    58  	NALUTypeFillerData:                    "FillerData",
    59  	NALUTypeSPSExtension:                  "SPSExtension",
    60  	NALUTypePrefix:                        "Prefix",
    61  	NALUTypeSubsetSPS:                     "SubsetSPS",
    62  	NALUTypeReserved16:                    "Reserved16",
    63  	NALUTypeReserved17:                    "Reserved17",
    64  	NALUTypeReserved18:                    "Reserved18",
    65  	NALUTypeSliceLayerWithoutPartitioning: "SliceLayerWithoutPartitioning",
    66  	NALUTypeSliceExtension:                "SliceExtension",
    67  	NALUTypeSliceExtensionDepth:           "SliceExtensionDepth",
    68  	NALUTypeReserved22:                    "Reserved22",
    69  	NALUTypeReserved23:                    "Reserved23",
    70  	NALUTypeSTAPA:                         "STAP-A",
    71  	NALUTypeSTAPB:                         "STAP-B",
    72  	NALUTypeMTAP16:                        "MTAP-16",
    73  	NALUTypeMTAP24:                        "MTAP-24",
    74  	NALUTypeFUA:                           "FU-A",
    75  	NALUTypeFUB:                           "FU-B",
    76  }
    77  
    78  // String implements fmt.Stringer.
    79  func (nt NALUType) String() string {
    80  	if l, ok := naluTypeLabels[nt]; ok {
    81  		return l
    82  	}
    83  	return fmt.Sprintf("unknown (%d)", nt)
    84  }