mirror of
https://github.com/aler9/gortsplib
synced 2025-10-04 06:46:42 +08:00
52 lines
1.0 KiB
Go
52 lines
1.0 KiB
Go
package h265
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/bluenviron/gortsplib/v3/pkg/bits"
|
|
"github.com/bluenviron/gortsplib/v3/pkg/codecs/h264"
|
|
)
|
|
|
|
// PPS is a H265 picture parameter set.
|
|
type PPS struct {
|
|
ID uint32
|
|
SPSID uint32
|
|
DependentSliceSegmentsEnabledFlag bool
|
|
OutputFlagPresentFlag bool
|
|
NumExtraSliceHeaderBits uint8
|
|
}
|
|
|
|
// Unmarshal decodes a PPS.
|
|
func (p *PPS) Unmarshal(buf []byte) error {
|
|
if len(buf) < 2 {
|
|
return fmt.Errorf("not enough bits")
|
|
}
|
|
|
|
buf = h264.EmulationPreventionRemove(buf)
|
|
|
|
buf = buf[2:]
|
|
pos := 0
|
|
|
|
var err error
|
|
p.ID, err = bits.ReadGolombUnsigned(buf, &pos)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
p.SPSID, err = bits.ReadGolombUnsigned(buf, &pos)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = bits.HasSpace(buf, pos, 5)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
p.DependentSliceSegmentsEnabledFlag = bits.ReadFlagUnsafe(buf, &pos)
|
|
p.OutputFlagPresentFlag = bits.ReadFlagUnsafe(buf, &pos)
|
|
p.NumExtraSliceHeaderBits = uint8(bits.ReadBitsUnsafe(buf, &pos, 3))
|
|
|
|
return nil
|
|
}
|