arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members

MPEG-1 part 2 video encoder wrapper around TinyMPGEncoder. More...

#include <CodecMPG.h>

Inheritance diagram for MPGEncoder:
VideoEncoder

Public Member Functions

 MPGEncoder (int width=0, int height=0)
 
 MPGEncoder (Print &out)
 
 MPGEncoder (VideoOutput &out)
 
bool begin () override
 Initializes the encoder (allocates its picture buffers, etc).
 
tinympg::TinyMPGEncoder< tinympg::PSRAMAllocatorESP32< uint8_t > > & driver ()
 
void end () override
 Releases the encoder's resources.
 
void setBitstreamBufferSize (size_t bytes)
 
void setFrameRate (int fps)
 
void setOutput (Print &out) override
 Defines the target the encoded bitstream is written to.
 
void setOutput (VideoOutput &out)
 
void setQp (int qscale)
 
void setSize (int width, int height)
 
void setVideoFormat (VideoFormat format) override
 
VideoInfo videoInfo () override
 
size_t write (const uint8_t *data, size_t len) override
 

Protected Member Functions

bool ensureBitstreamBuffer ()
 
template<typename Fn >
size_t writeOut (Fn encodeInto)
 

Protected Attributes

Vector< uint8_t > bitstream_buffer
 
tinympg::TinyMPGEncoder< tinympg::PSRAMAllocatorESP32< uint8_t > > encoder_
 
int height_ = 0
 
VideoFormat input_format = VideoFormat::I420
 
Printp_out = nullptr
 
VideoOutputp_out_video = nullptr
 
int width_ = 0
 

Static Protected Attributes

static constexpr int kMaxGrowRetries = 4
 

Detailed Description

MPEG-1 part 2 video encoder wrapper around TinyMPGEncoder.

This mirrors the API shape of H264Encoder in CodecH264.h.

Note: Requires TinyMPG (TinyMPGEncoder.h) to be installed and reachable by the compiler include path: https://github.com/pschatzmann/TinyMPG

Constructor & Destructor Documentation

◆ MPGEncoder() [1/3]

MPGEncoder ( int  width = 0,
int  height = 0 
)
inline

◆ MPGEncoder() [2/3]

MPGEncoder ( Print out)
inline

◆ MPGEncoder() [3/3]

MPGEncoder ( VideoOutput out)
inline

Member Function Documentation

◆ begin()

bool begin ( )
inlineoverridevirtual

Initializes the encoder (allocates its picture buffers, etc).

Implements VideoEncoder.

◆ driver()

tinympg::TinyMPGEncoder< tinympg::PSRAMAllocatorESP32< uint8_t > > & driver ( )
inline

◆ end()

void end ( )
inlineoverridevirtual

Releases the encoder's resources.

Implements VideoEncoder.

◆ ensureBitstreamBuffer()

bool ensureBitstreamBuffer ( )
inlineprotected

◆ setBitstreamBufferSize()

void setBitstreamBufferSize ( size_t  bytes)
inline

◆ setFrameRate()

void setFrameRate ( int  fps)
inline

◆ setOutput() [1/2]

void setOutput ( Print out)
inlineoverridevirtual

Defines the target the encoded bitstream is written to.

Implements VideoEncoder.

◆ setOutput() [2/2]

void setOutput ( VideoOutput out)
inline

◆ setQp()

void setQp ( int  qscale)
inline

◆ setSize()

void setSize ( int  width,
int  height 
)
inline

◆ setVideoFormat()

void setVideoFormat ( VideoFormat  format)
inlineoverridevirtual

Selects the raw picture format write() expects - e.g. VideoFormat::I420 (planar Y/U/V, concatenated in one buffer), YUV422 (packed YUYV), RGB565/RGB666/RGB888 (packed). Not every encoder backend supports every value - unsupported values are logged and ignored (the previously selected format stays in effect); see the concrete class for exactly which ones it supports. Call before the first write().

Implements VideoEncoder.

◆ videoInfo()

VideoInfo videoInfo ( )
inlineoverridevirtual

Reports the format/dimensions of the bitstream written to setOutput()'s target - VideoInfo::format is the actual encoded codec (e.g. VideoFormat::H264), NOT setVideoFormat()'s raw input format, the reliable way to determine it (rather than assuming); width/height match the encoder's configured picture size (e.g. setSize()), 0 if that was never called.

Implements VideoEncoder.

◆ write()

size_t write ( const uint8_t *  data,
size_t  len 
)
inlineoverridevirtual

Encodes one raw picture (in setVideoFormat()'s format, sized for the encoder's configured width/height) and writes the result to setOutput()'s target, returning the number of bytes written (0 if nothing was, e.g. setOutput()/size wasn't configured, or the format is unsupported).

Implements VideoEncoder.

◆ writeOut()

template<typename Fn >
size_t writeOut ( Fn  encodeInto)
inlineprotected

Member Data Documentation

◆ bitstream_buffer

Vector<uint8_t> bitstream_buffer
protected

◆ encoder_

tinympg::TinyMPGEncoder< tinympg::PSRAMAllocatorESP32<uint8_t> > encoder_
protected

◆ height_

int height_ = 0
protected

◆ input_format

VideoFormat input_format = VideoFormat::I420
protected

◆ kMaxGrowRetries

constexpr int kMaxGrowRetries = 4
staticconstexprprotected

◆ p_out

Print* p_out = nullptr
protected

◆ p_out_video

VideoOutput* p_out_video = nullptr
protected

◆ width_

int width_ = 0
protected

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