github.com/cnotch/ipchub@v1.1.0/av/codec/h264/shortcut.go (about)

     1  // Copyright (c) 2019,CAOHONGJU All rights reserved.
     2  // Use of this source code is governed by a MIT-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package h264
     6  
     7  import "github.com/cnotch/ipchub/av/codec"
     8  
     9  // MetadataIsReady .
    10  func MetadataIsReady(vm *codec.VideoMeta) bool {
    11  	sps := vm.Sps //ParameterSet(ParameterSetSps)
    12  	pps := vm.Pps //ParameterSet(ParameterSetPps)
    13  	if len(sps) == 0 || len(pps) == 0 {
    14  		return false
    15  	}
    16  
    17  	if vm.Width == 0 {
    18  		// decode
    19  		var rawsps RawSPS
    20  		if err := rawsps.Decode(sps); err != nil {
    21  			return false
    22  		}
    23  		vm.Width = rawsps.Width()
    24  		vm.Height = rawsps.Height()
    25  		vm.FixedFrameRate = rawsps.IsFixedFrameRate()
    26  		vm.FrameRate = rawsps.FrameRate()
    27  	}
    28  	return true
    29  }
    30  
    31  // NulType .
    32  func NulType(nt byte) byte {
    33  	return nt & NalTypeBitmask
    34  }
    35  
    36  // IsSps .
    37  func IsSps(nt byte) bool {
    38  	return nt&NalTypeBitmask == NalSps
    39  }
    40  
    41  // IsPps .
    42  func IsPps(nt byte) bool {
    43  	return nt&NalTypeBitmask == NalPps
    44  }
    45  
    46  // IsIdrSlice .
    47  func IsIdrSlice(nt byte) bool {
    48  	return nt&NalTypeBitmask == NalIdrSlice
    49  }
    50  
    51  // IsFillerData .
    52  func IsFillerData(nt byte) bool {
    53  	return nt&NalTypeBitmask == NalFillerData
    54  }