StormByte C++ Library: Multimedia module 0.0.9999
StormByte-Multimedia is a StormByte library module for parsing configuration files
Loading...
Searching...
No Matches
Friends | List of all members
StormByte::Multimedia::Pipeline::Encoder Class Referencefinal

Encodes frames of one output track into packets. More...

#include <StormByte/multimedia/pipeline/encoder.hxx>

Inheritance diagram for StormByte::Multimedia::Pipeline::Encoder:
Inheritance graph
[legend]
Collaboration diagram for StormByte::Multimedia::Pipeline::Encoder:
Collaboration graph
[legend]

Public Member Functions

Lifecycle
 Encoder (std::shared_ptr< StormByte::Logger::Log > log, int output_index, const Codec &codec) noexcept
 Encoder for output track output_index and destination codec.
 
 Encoder (const Encoder &other)=delete
 Copy constructor.
 
 Encoder (Encoder &&other) noexcept=delete
 Move constructor.
 
 ~Encoder () noexcept override
 Destructor.
 
Encoderoperator= (const Encoder &other)=delete
 Copy assignment.
 
Encoderoperator= (Encoder &&other) noexcept=delete
 Move assignment.
 
State
 operator bool () const noexcept
 true if the backend is open and not failed.
 
int Index () const noexcept
 Mux destination order key.
 
std::size_t InputCeiling () const noexcept override
 Ceiling of the encoder input hopper.
 
const CodecDestination () const noexcept
 Destination codec.
 
bool Opened () const noexcept
 Whether the backend finished Open().
 
std::optional< int > AudioChannels () const noexcept
 Encoder channel count after Open(), audio only.
 
std::optional< int > AudioSampleRate () const noexcept
 Encoder sample rate after Open(), audio only.
 
std::optional< int > AudioFrameSize () const noexcept
 Encoder frame_size after Open(), audio only.
 
std::optional< int > AudioSampleFormat () const noexcept
 Encoder sample format after Open(), audio only.
 
Encoder tag
const std::string & EncoderTag () const noexcept
 Writing-application tag stamped on every encoded stream.
 
Implementation
const std::optional< std::string > & Implementation () const noexcept
 Pinned FFmpeg encoder name, if any.
 
void Implementation (std::string name) noexcept
 Pins an FFmpeg encoder name.
 
const FeaturesRequire () const noexcept
 Extra features the caller demands besides Frame HDR.
 
void Require (Features features) noexcept
 Replaces the extra feature mask (before open).
 
const FeaturesCapabilities () const noexcept
 Features of the row selected at open.
 
Rate and style
void CRF (int value) noexcept
 Constant quality (CRF/CQ).
 
const std::optional< int > & CRF () const noexcept
 CRF/CQ, if set.
 
void BitRate (std::int64_t bits_per_second) noexcept
 Target bitrate in bits per second.
 
const std::optional< std::int64_t > & BitRate () const noexcept
 Target bitrate, if set.
 
void MaxBitRate (std::int64_t bits_per_second) noexcept
 VBV ceiling in bits per second.
 
const std::optional< std::int64_t > & MaxBitRate () const noexcept
 VBV ceiling, if set.
 
void Preset (std::string name) noexcept
 Encoder preset.
 
const std::optional< std::string > & Preset () const noexcept
 Preset, if set.
 
void Tune (std::string name) noexcept
 Content tune.
 
const std::optional< std::string > & Tune () const noexcept
 Content tune, if set.
 
FineTune
const std::map< std::string, std::string > & FineTune () const noexcept
 Vendor leftovers.
 
void FineTune (std::map< std::string, std::string > options) noexcept
 Replaces the vendor dict (before open).
 
- Public Member Functions inherited from StormByte::Multimedia::Pipeline::Step
 Step (const Step &other)=delete
 
 Step (Step &&other) noexcept=delete
 
virtual ~Step () noexcept
 Destructor.
 
Stepoperator= (const Step &other)=delete
 
Stepoperator= (Step &&other) noexcept=delete
 
std::condition_variable & Wake () noexcept
 Consumer condition variable.
 
const std::shared_ptr< class Plan > & Plan () const noexcept
 Bound job intention, if any.
 
const KindsReceives () const noexcept
 Kinds this step consumes.
 
const KindsProduces () const noexcept
 Kinds this step emits.
 
State Status () const noexcept
 Current lifecycle value.
 
virtual bool Ready () const noexcept
 Whether this step can take work.
 
void Stop () noexcept
 Asks the worker to leave and closes all hoppers.
 
bool Failed () const noexcept
 Whether this step has failed.
 
const std::optional< std::string > & Error () const noexcept
 Failure text.
 
void Fail (std::string reason) noexcept
 Marks Failed, closes all hoppers and wakes the worker.
 

Friends

class Backend::Pipeline::Encoder
 
class Backend::Pipeline::Detail::Worker::Encode
 
class Muxer
 

Additional Inherited Members

- Protected Member Functions inherited from StormByte::Multimedia::Pipeline::Step
Backend::Pipeline::Pipe & pipe () noexcept
 In / out hoppers of this stage.
 
const Backend::Pipeline::Pipe & pipe () const noexcept
 In / out hoppers of this stage.
 
 Step (std::shared_ptr< StormByte::Logger::Log > log, enum Producer name, Kinds receives, Kinds produces) noexcept
 Step in State::Created.
 
void Emit (Item::PointerType item) noexcept
 Write item to the Pipe (item >> pipe).
 
Item::PointerType CloneItem (const Item &item) const noexcept
 Deep-copies item through Item::Clone.
 
void Wait () noexcept
 Sleeps on Wake until hopper Ready, Failed or Stopping.
 
void Launch () noexcept
 Starts the pumper: Setup, Ready, Pump.
 
void Halt () noexcept
 Stop and join the pumper.
 
bool Stopping () const noexcept
 Worker must return (Stop, Halt or Fail).
 
void RecordWork (std::int64_t microseconds) noexcept
 Adds one Process duration to the step summary.
 
std::int64_t LastWork () const noexcept
 Duration of the last timed Process, or 0.
 
void DumpWork () noexcept
 Writes min/max Process time at Debug.
 
Backend::Pipeline::Host & Face () noexcept
 Owner surface for the Pumper and Worker.
 
void Mount (std::unique_ptr< Backend::Pipeline::Pumper > pumper, std::unique_ptr< Backend::Pipeline::Worker > worker) noexcept
 Takes ownership of pumper and binds worker.
 
- Protected Attributes inherited from StormByte::Multimedia::Pipeline::Step
std::shared_ptr< StormByte::Logger::Log > m_log
 
enum Producer m_name
 UseLog leaf / default Label.
 
Kinds m_receives
 Receives.
 
Kinds m_produces
 Produces.
 

Detailed Description

Encodes frames of one output track into packets.

Notice: destination codec when the backend first opens. LowLevel unit lines are always written; the shared logger throttles. One incoming frame counts once; packets produced in that Work share the sample. Pts/Dts on Wrap are the flattened encoder clock (the line that catches a bad DTS flatten). The Through pumper times each Process.

Label is Encoder(libx265) when an implementation is pinned or selected, otherwise Encoder(<registry name>).

Encode-look is Backend::Pipeline::Pipe::CloneTo on the encode Pipe (Filters dest look). There is no side hopper.

Constructor & Destructor Documentation

◆ Encoder() [1/3]

StormByte::Multimedia::Pipeline::Encoder::Encoder ( std::shared_ptr< StormByte::Logger::Log >  log,
int  output_index,
const Codec codec 
)
noexcept

Encoder for output track output_index and destination codec.

Parameters
logShared logger. Empty pointer means no log.
output_indexMux destination order key.
codecRegistry codec. Must HasAccess(Write) at open.

◆ Encoder() [2/3]

Copy constructor.

Parameters
otherSource encoder.

◆ Encoder() [3/3]

Move constructor.

Parameters
otherEncoder to take.

◆ ~Encoder()

StormByte::Multimedia::Pipeline::Encoder::~Encoder ( )
overridenoexcept

Destructor.

Step::Join Halt s before backends die.

Member Function Documentation

◆ AudioChannels()

std::optional< int > StormByte::Multimedia::Pipeline::Encoder::AudioChannels ( ) const
noexcept

Encoder channel count after Open(), audio only.

Returns
Channels, or empty.

◆ AudioFrameSize()

std::optional< int > StormByte::Multimedia::Pipeline::Encoder::AudioFrameSize ( ) const
noexcept

Encoder frame_size after Open(), audio only.

Returns
Samples per packet, or empty.

◆ AudioSampleFormat()

std::optional< int > StormByte::Multimedia::Pipeline::Encoder::AudioSampleFormat ( ) const
noexcept

Encoder sample format after Open(), audio only.

Returns
AVSampleFormat as int, or empty.

◆ AudioSampleRate()

std::optional< int > StormByte::Multimedia::Pipeline::Encoder::AudioSampleRate ( ) const
noexcept

Encoder sample rate after Open(), audio only.

Returns
Hz, or empty.

◆ BitRate() [1/2]

const std::optional< std::int64_t > & StormByte::Multimedia::Pipeline::Encoder::BitRate ( ) const
inlinenoexcept

Target bitrate, if set.

Returns
Bits per second, or empty.

◆ BitRate() [2/2]

void StormByte::Multimedia::Pipeline::Encoder::BitRate ( std::int64_t  bits_per_second)
inlinenoexcept

Target bitrate in bits per second.

Incompatible with CRF.

Parameters
bits_per_secondBitrate.

◆ Capabilities()

const Features & StormByte::Multimedia::Pipeline::Encoder::Capabilities ( ) const
inlinenoexcept

Features of the row selected at open.

Empty if fallback.

Returns
Mask.

◆ CRF() [1/2]

const std::optional< int > & StormByte::Multimedia::Pipeline::Encoder::CRF ( ) const
inlinenoexcept

CRF/CQ, if set.

Returns
Value, or empty.

◆ CRF() [2/2]

void StormByte::Multimedia::Pipeline::Encoder::CRF ( int  value)
inlinenoexcept

Constant quality (CRF/CQ).

Incompatible with BitRate.

Parameters
valueEncoder quality value.

◆ Destination()

const Codec & StormByte::Multimedia::Pipeline::Encoder::Destination ( ) const
inlinenoexcept

Destination codec.

Returns
Registry codec bound at construction.

◆ EncoderTag()

const std::string & StormByte::Multimedia::Pipeline::Encoder::EncoderTag ( ) const
inlinenoexcept

Writing-application tag stamped on every encoded stream.

Returns
StormByte-Multimedia version. Never empty after construction.

◆ FineTune() [1/2]

const std::map< std::string, std::string > & StormByte::Multimedia::Pipeline::Encoder::FineTune ( ) const
inlinenoexcept

Vendor leftovers.

Not CRF/preset/tune/bufsize.

Returns
Key/value map.

◆ FineTune() [2/2]

void StormByte::Multimedia::Pipeline::Encoder::FineTune ( std::map< std::string, std::string >  options)
inlinenoexcept

Replaces the vendor dict (before open).

Parameters
optionsKey/value pairs.

◆ Implementation() [1/2]

const std::optional< std::string > & StormByte::Multimedia::Pipeline::Encoder::Implementation ( ) const
inlinenoexcept

Pinned FFmpeg encoder name, if any.

Returns
Name, or empty.

◆ Implementation() [2/2]

void StormByte::Multimedia::Pipeline::Encoder::Implementation ( std::string  name)
noexcept

Pins an FFmpeg encoder name.

Empty clears the pin.

Parameters
nameavcodec_find_encoder_by_name key.

◆ Index()

int StormByte::Multimedia::Pipeline::Encoder::Index ( ) const
inlinenoexcept

Mux destination order key.

Returns
Index set at construction.

◆ InputCeiling()

std::size_t StormByte::Multimedia::Pipeline::Encoder::InputCeiling ( ) const
inlineoverridevirtualnoexcept

Ceiling of the encoder input hopper.

Returns
Max queued frames. Never 0.

Reimplemented from StormByte::Multimedia::Pipeline::Step.

◆ MaxBitRate() [1/2]

const std::optional< std::int64_t > & StormByte::Multimedia::Pipeline::Encoder::MaxBitRate ( ) const
inlinenoexcept

VBV ceiling, if set.

Returns
Bits per second, or empty.

◆ MaxBitRate() [2/2]

void StormByte::Multimedia::Pipeline::Encoder::MaxBitRate ( std::int64_t  bits_per_second)
inlinenoexcept

VBV ceiling in bits per second.

Parameters
bits_per_secondMax bitrate.

◆ Opened()

bool StormByte::Multimedia::Pipeline::Encoder::Opened ( ) const
noexcept

Whether the backend finished Open().

Returns
false before the first frame or after Fail().

◆ operator bool()

StormByte::Multimedia::Pipeline::Encoder::operator bool ( ) const
explicitnoexcept

true if the backend is open and not failed.

Returns
Open and not Failed.

◆ operator=() [1/2]

Encoder & StormByte::Multimedia::Pipeline::Encoder::operator= ( const Encoder other)
delete

Copy assignment.

Parameters
otherSource encoder.
Returns
*this.

◆ operator=() [2/2]

Encoder & StormByte::Multimedia::Pipeline::Encoder::operator= ( Encoder &&  other)
deletenoexcept

Move assignment.

Parameters
otherEncoder to take.
Returns
*this.

◆ Preset() [1/2]

const std::optional< std::string > & StormByte::Multimedia::Pipeline::Encoder::Preset ( ) const
inlinenoexcept

Preset, if set.

Returns
Name, or empty.

◆ Preset() [2/2]

void StormByte::Multimedia::Pipeline::Encoder::Preset ( std::string  name)
noexcept

Encoder preset.

Parameters
namePreset name.

◆ Require() [1/2]

const Features & StormByte::Multimedia::Pipeline::Encoder::Require ( ) const
inlinenoexcept

Extra features the caller demands besides Frame HDR.

Returns
Mask.

◆ Require() [2/2]

void StormByte::Multimedia::Pipeline::Encoder::Require ( Features  features)
inlinenoexcept

Replaces the extra feature mask (before open).

Parameters
featuresRequired bits.

◆ Tune() [1/2]

const std::optional< std::string > & StormByte::Multimedia::Pipeline::Encoder::Tune ( ) const
inlinenoexcept

Content tune, if set.

Returns
Name, or empty.

◆ Tune() [2/2]

void StormByte::Multimedia::Pipeline::Encoder::Tune ( std::string  name)
noexcept

Content tune.

Parameters
nameTune name.

Friends And Related Symbol Documentation

◆ Backend::Pipeline::Detail::Worker::Encode

friend class Backend::Pipeline::Detail::Worker::Encode
friend

◆ Backend::Pipeline::Encoder

friend class Backend::Pipeline::Encoder
friend

◆ Muxer

friend class Muxer
friend

The documentation for this class was generated from the following file: