Documentation
¶
Index ¶
- Variables
- func EncodeFrame(samples [][]int64, sampleRate, bitsPerSample int, frameNumber uint64, ...) ([]byte, error)
- func EncodeResidual(w *bits.Writer, residual []int64, coding riceCoding) error
- func EncodeSubframeCandidate(w *bits.Writer, samples []int64, bitsPerSample int, best subframeCandidate) error
- type Encoder
- func (e *Encoder) Close() error
- func (e *Encoder) Flush() error
- func (e *Encoder) MD5() [16]byte
- func (e *Encoder) OutputReady() <-chan struct{}
- func (e *Encoder) Prepare(resources registry.ResourceGrant) error
- func (e *Encoder) ReceivePacket() (*media.Packet, error)
- func (e *Encoder) SendFrame(frame *media.Frame) error
- type FormatSupport
Constants ¶
This section is empty.
Variables ¶
var SupportedFormats = []FormatSupport{ {Format: media.SampleFormatS8, MinBits: 4, MaxBits: 8}, {Format: media.SampleFormatS16, MinBits: 4, MaxBits: 16}, {Format: media.SampleFormatS24, MinBits: 17, MaxBits: 24}, {Format: media.SampleFormatS32, MinBits: 17, MaxBits: 32}, }
Functions ¶
func EncodeFrame ¶
func EncodeResidual ¶
Types ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
func NewEncoder ¶
func NewEncoder(stream media.StreamInfo, cfg config.EncoderConfig, workers *registry.WorkerPool) *Encoder
NewEncoder builds an encoder. workers may be nil, in which case blocks are encoded synchronously; otherwise it must be a pool this encoder is allowed to submit work to for its entire lifetime (the caller retains ownership and is responsible for closing it once every stage sharing it has finished).
func (*Encoder) Close ¶
Close stops accepting further work without emitting a final packet or MD5 summary. It exists so the pipeline wrapper (pkg/engine) can guarantee in-flight state is released on error/cancellation exits, which never reach Flush's io.EOF-only call site. It does not close the pool: that is shared with other stages and owned by whoever constructed this encoder. Safe whether or not Flush ran first, and safe to call more than once.
func (*Encoder) OutputReady ¶
func (e *Encoder) OutputReady() <-chan struct{}
func (*Encoder) ReceivePacket ¶
ReceivePacket drains pendingQueue in submission order. Entries produced by the parallel path may still be in flight (entry.ready == false), in which case waitForEntry blocks on that specific entry until a worker finishes it.
It deliberately never returns ErrEAGAIN just because the head isn't ready yet: callers may wire this encoder into a pipeline with fan-out (e.g. a tee feeding both this encoder and a comparison against its own output), where upstream progress depends on the encoder actually producing a packet rather than the caller pulling more input first. Any policy that withholds a dispatched-but-pending packet in favor of "let more work queue up" can deadlock such a graph — see the regression that motivated this comment. This does mean input chunked smaller than BlockSize (one job dispatched per full block) gets pipelined roughly one job deep rather than the configured parallelism; blocks dispatched together (e.g. a decoder frame larger than BlockSize) still encode in parallel within a single emitFullBlocks call.
type FormatSupport ¶
type FormatSupport struct {
Format media.SampleFormat
MinBits, MaxBits int
}
FormatSupport describes one FLAC-supported input container: MinBits is one more than the next-smaller container's MaxBits (so 12-bit audio must be declared S16, never S24), and MaxBits is the container's own full width. register.go's capability declaration is derived from SupportedFormats so the two can never drift apart.
Source Files
¶
- autocorr.go
- autocorr_dispatch_scalar.go
- block.go
- blocksplit.go
- encoder.go
- frame.go
- frame_channel.go
- lpc.go
- lpc_window.go
- lpc_window_dispatch_scalar.go
- midside.go
- parallel.go
- parallel_job.go
- residual.go
- residual_pred.go
- residual_pred_dispatch_scalar.go
- rice.go
- rice_cost.go
- rice_stats.go
- rice_stats_dispatch_scalar.go
- stream.go
- subframe.go
- subframe_util.go
- window.go