mpeg2

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mpeg2 decodes MPEG-2 video (ISO/IEC 13818-2, Main Profile: 4:2:0, frame and field pictures, every prediction mode) in Go: a fallback where no GPU decodes a Blu-ray's or DVD's MPEG-2.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Accel

type Accel interface {
	// NewSurface gives a surface for frames of the size (the coded size:
	// whole macroblocks). The surfaces of another size have all been
	// released before.
	NewSurface(width, height int) (int, error)
	// Release gives a surface back.
	Release(surface int)
	// DecodePicture decodes a picture (a frame, or one field of one) from
	// its slices, in order.
	DecodePicture(p *AccelPicture, slices []AccelSlice) error
	// Output fills the planes of p, a frame given out in display order,
	// from the surface.
	Output(surface int, p *Picture) error
}

Accel decodes pictures for the decoder.

type AccelPicture

type AccelPicture struct {
	Surface int
	// Forward and Backward are the reference frames' surfaces (-1: none).
	Forward, Backward int
	Width, Height     int // the sequence's
	CodingType        int // 1 I, 2 P, 3 B
	FCode             [2][2]int
	DCPrecision       int
	Structure         int // 1 top field, 2 bottom field, 3 frame
	TopFieldFirst     bool
	FramePredFrameDCT bool
	Concealment       bool
	QScaleType        bool
	IntraVLC          bool
	AlternateScan     bool
	RepeatFirstField  bool
	ProgressiveFrame  bool
	// FirstField is set for a frame picture, and the first field of a
	// frame.
	FirstField bool
	// The quantiser matrices in zigzag scan order.
	IntraQ, NonIntraQ [64]uint8
}

AccelPicture is a picture's parameters, the standard's syntax elements.

type AccelSlice

type AccelSlice struct {
	Data []byte
	// MacroblockOffset is where the first macroblock starts, in bits from
	// the start code.
	MacroblockOffset   int
	MBX, MBY           int // the first macroblock's (MBY in the picture: a field's rows)
	QuantiserScaleCode int
	IntraSlice         bool
}

AccelSlice is a slice: its data, from its start code, and its header.

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder decodes an MPEG-2 video elementary stream, access unit by access unit.

func New

func New() *Decoder

New makes a decoder.

func (*Decoder) Decode

func (d *Decoder) Decode(au []byte, pts int64, out func(*Picture) error) error

Decode decodes an access unit (one or more start code units) given at pts, giving out the pictures that are complete in display order.

func (*Decoder) Errors

func (d *Decoder) Errors() int

Errors is how many slices could not be decoded (and were concealed by what was there).

func (*Decoder) Flush

func (d *Decoder) Flush(out func(*Picture) error) error

Flush gives out the last picture.

func (*Decoder) SetAccel

func (d *Decoder) SetAccel(a Accel)

SetAccel makes the decoder decode through a, from the next sequence.

type Picture

type Picture struct {
	Width, Height    int
	Y, Cb, Cr        []byte
	StrideY, StrideC int
	PTS              int64
	// Progressive is progressive_frame: the two fields are of one moment.
	// TopFieldFirst says which field comes first when not.
	Progressive, TopFieldFirst bool
	// FrameRateNum and FrameRateDen are the sequence's frame rate.
	FrameRateNum, FrameRateDen int
	// Primaries, Transfer and Matrix are the sequence display extension's
	// colour description (H.273 code points; 2, unspecified, when there is
	// none).
	Primaries, Transfer, Matrix int
}

Picture is a decoded frame, in display order: 8-bit 4:2:0 planes, the displayed size of a larger buffer.

Jump to

Keyboard shortcuts

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