pes

package
v0.0.0-...-3fc9a46 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2024 License: MIT Imports: 6 Imported by: 5

README

mpeg/pes

Package pes implements an MPEG-2 packetized elementary stream parser as defined in ISO/IEC 13818-1.

GoDoc

This package is experimental and is not intended for use in production environments.

Roadmap

  • Basic packet parser
  • Full PES Extension support
  • Packet streamer interface (via <-chan Packet)
  • PayloadReader (implementing io.Reader)

Documentation

Overview

Package pes implements an MPEG-2 packetized elementary stream parser as defined in ISO/IEC 13818-1.

This package is experimental and is not intended for use in production environments.

This package is _not_ optimized for processing video in a production environment, instead is geared towards an educational look at some of the algorithms and processes used to decode compressed video.

Index

Constants

View Source
const StartCodePrefix = 0x000001

StartCodePrefix is the prefix that signals the start a PES packet.

Variables

View Source
var (
	ErrStartCodePrefixNotFound = errors.New("start code prefix not found")
	ErrMarkerNotFound          = errors.New("marker not found")
	ErrInvalidStuffingByte     = errors.New("invalid stuffing byte")
)

Functions

func NewPayloadReader

func NewPayloadReader(source io.Reader) io.Reader

NewPayloadReader creates a new reader that provides only Payload bytes from the source PES stream

Types

type Extension

type Extension struct {
	PrivateDataFlag                  bool
	PackHeaderFieldFlag              bool
	ProgramPacketSequenceCounterFlag bool
	P_STD_BufferFlag                 bool
	ExtensionFlag2                   bool

	PrivateData []byte
	*P_STD_Buffer
}

Extension contains the parsed fields from an optional Header Extension.

type Header struct {
	ScramblingControl      uint32
	Priority               bool
	DataAlignmentIndicator bool
	Copyright              bool
	OrignalOrCopy          bool
	PtsDtsFlags            uint32
	EscrFlag               bool
	EsRateFlag             bool
	DsmTrickModeFlag       bool
	AdditionalCopyInfoFlag bool
	CrcFlag                bool
	ExtensionFlag          bool
	HeaderDataLength       uint32

	PresentationTimeStamp uint32
	DecodingTimeStamp     uint32

	Extension *Extension
}

Header contains the optional header fields parsed from a PES packet.

type P_STD_Buffer

type P_STD_Buffer struct {
	Scale uint32
	Size  uint32
}

type Packet

type Packet struct {
	StreamID     uint32
	PacketLength uint32
	*Header
	Payload []byte
}

Packet is a parsed PES packet from a bitstream. A PES packet consists, at minimum, of a start_code_prefix, stream_id, packet_length, followed by a variable number of bytes of payload. It can optionally, for certain stream types, contain a Header.

┌──────────────────────┬──────┬──────────────┬────────────────────────-
│start_code_prefix     │stream│packet_length │payload                 -
│                  (24)│id (8)│          (16)│                        -
└──────────────────────┴──────┴──────────────┴────────────────────────-
                                             Λ
                                            ╱ ╲
     ╱─────────────(optional)──────────────╱   ╲
    ╱                                           ╲
    ┌───────────────────────────────────────────┐
    │PES Header                                 │
    │                                 (variable)│
    └───────────────────────────────────────────┘

func NewPacket

func NewPacket(br bitreader.BitReader) (packet *Packet, err error)

Creates a new packet and reads it from the bitstream.

func (*Packet) Next

func (packet *Packet) Next(reader bitreader.BitReader) error

Next reads the next packet from the bitstream

type PacketChannel

type PacketChannel <-chan *Packet

PacketChannel is a delivery channel of PES Packets

func (PacketChannel) PayloadOnly

func (input PacketChannel) PayloadOnly() <-chan []byte

PayloadOnly transforms a PacketChannel into a delivery channel of packet payload

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL