frame

package
v0.0.0-...-fede9f9 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatisticsKeyFramesIn     = "frames_in"
	StatisticsKeyFramesOut    = "frames_out"
	StatisticsKeyLastFrameOut = "last_frame_out"
)
View Source
const (
	FrameStatisticsKeyNumber       = "number"
	FrameStatisticsKeyPts          = "pts"
	FrameStatisticsKeyQuantizer    = "quantizer"
	FrameStatisticsKeySize         = "size"
	FrameStatisticsKeyIsKeyFrame   = "is_key"
	FrameStatisticsKeyIsIntraFrame = "is_intra"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AllowedFrameTypes

type AllowedFrameTypes interface {
	uint8 | uint16
}

type Frame

type Frame interface {
	Properties() Properties
	// PTS usually frame number, but can differ on VFR
	PTS() int64
	// NextPTS Next PTS
	NextPTS() int64

	// Get16 get a pixel sample in 16-bit depth
	Get16(x, y int) (Y uint16, Cb uint16, Cr uint16)

	// Get8 get a pixel sample in 8-bit depth
	Get8(x, y int) (Y uint8, Cb uint8, Cr uint8)

	GetLuma() []byte
	GetCb() []byte
	GetCr() []byte
	// GetJoint Gets Luma+Cb+Cr slice. Do not keep references to this slice, copy instead.
	// This is unsafe
	GetJoint() []byte

	// Return Finishes using this frame and marks it for reuse
	Return()
}

type FrameStatistics

type FrameStatistics map[string]any

func (FrameStatistics) IsIntraFrame

func (s FrameStatistics) IsIntraFrame() bool

func (FrameStatistics) IsKeyFrame

func (s FrameStatistics) IsKeyFrame() bool

func (FrameStatistics) Number

func (s FrameStatistics) Number() int

func (FrameStatistics) PTS

func (s FrameStatistics) PTS() int64

func (FrameStatistics) Quantizer

func (s FrameStatistics) Quantizer() float64

func (FrameStatistics) Size

func (s FrameStatistics) Size() int

type Pool

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

func NewPool

func NewPool(properties Properties) (*Pool, error)

func (*Pool) Get

func (p *Pool) Get(pts, nextPts int64) Frame

func (*Pool) Properties

func (p *Pool) Properties() Properties

func (*Pool) Put

func (p *Pool) Put(f Frame)

type Properties

type Properties struct {
	//TODO: HDR
	Width            int
	Height           int
	PixelAspectRatio utilities.Ratio
	ColorSpace       color.Space
	FullColorRange   bool
}

type Statistics

type Statistics map[string]any

func (Statistics) FramesIn

func (s Statistics) FramesIn() int

func (Statistics) FramesOut

func (s Statistics) FramesOut() int

func (Statistics) LastFrameOut

func (s Statistics) LastFrameOut() *FrameStatistics

type Stream

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

func NewStream

func NewStream(properties StreamProperties) (*Stream, chan<- Frame)

func (*Stream) Channel

func (s *Stream) Channel() <-chan Frame

Channel gets the Frame channel, and locks the input

func (*Stream) Copy

func (s *Stream) Copy(n int) []*Stream

Copy copies the stream n times

func (*Stream) Lock

func (s *Stream) Lock() bool

Lock locks the input, and returns success

func (*Stream) Monochrome

func (s *Stream) Monochrome() *Stream

Monochrome makes stream luma-only

func (*Stream) Properties

func (s *Stream) Properties() StreamProperties

func (*Stream) Sample

func (s *Stream) Sample(each int) *Stream

Sample samples frames every each Frame, and locks the input

func (*Stream) Slice

func (s *Stream) Slice(start, end int) *Stream

Slice produces a slice of the stream, and locks the input

func (*Stream) Split

func (s *Stream) Split(splits ...int) []*Stream

Split produces several Stream across each split point, and locks the input. For example, splits = [2, 5, 20] will produce 4 Stream, [0-1], [2-4], [5-19], [20-...]

func (*Stream) Unlock

func (s *Stream) Unlock() bool

Unlock unlocks the input, and returns the old value

type StreamProperties

type StreamProperties struct {
	// Width could be not populated until the first frame is read. Frame can contain different settings.
	Width int `json:"width" yaml:"width"`
	// Height could be not populated until the first frame is read. Frame can contain different settings.
	Height int `json:"height" yaml:"height"`
	// PixelAspectRatio could be not populated until the first frame is read. Frame can contain different settings.
	PixelAspectRatio utilities.Ratio `json:"par" yaml:"par"`
	// ColorSpace could be not populated until the first frame is read. Frame can contain different settings.
	ColorSpace     color.Space     `json:"colorspace" yaml:"colorspace"`
	FrameRate      utilities.Ratio `json:"framerate" yaml:"framerate"`
	FullColorRange bool            `json:"fullrange" yaml:"fullrange"`
	VFR            bool            `json:"vfr" yaml:"vfr"`
}

func (StreamProperties) FrameProperties

func (p StreamProperties) FrameProperties() Properties

func (StreamProperties) TimeBase

func (p StreamProperties) TimeBase() utilities.Ratio

type TypedFrame

type TypedFrame[T AllowedFrameTypes] interface {
	Frame

	// GetNative get a pixel sample in native bit depth
	GetNative(x, y int) (Y T, Cb T, Cr T)

	// GetNativeLuma also known as Y. Do not keep references to this slice, copy instead.
	GetNativeLuma() []T
	// GetNativeCb also known as U. Do not keep references to this slice, copy instead.
	GetNativeCb() []T
	// GetNativeCr also known as V. Do not keep references to this slice, copy instead.
	GetNativeCr() []T
	// GetNativeJoint Gets Luma+Cb+Cr slice. Do not keep references to this slice, copy instead.
	GetNativeJoint() []T

	FillNativeLuma([]T)
	FillNativeCb([]T)
	FillNativeCr([]T)
}

Jump to

Keyboard shortcuts

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