arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
H264DecoderESP32S3< Alloc > Class Template Reference

H.264 video decoder for ESP32-S3: wraps esp_h264::H264Decoder (https://github.com/pschatzmann/ESP32S3-h264) as a VideoOutput, so it can be plugged directly into e.g. DemuxerAVI::setOutputVideo()/ DemuxerMP4::setOutputVideo() - the same role H264Decoder (CodecH264.h, the portable TinyH264-based decoder) plays, for boards where the ESP32-S3-specific esp_h264 backend is preferred instead. Consumes an Annex-B H.264 bitstream via write() and, once a complete picture has been decoded, writes it - converted to setVideoFormat()'s format (RGB565 by default, the common TFT wire format) - to the Print target configured via setOutput(), one write() call per decoded picture. More...

#include <CodecH264ESP32S3.h>

Inheritance diagram for H264DecoderESP32S3< Alloc >:
VideoDecoder VideoOutput

Public Member Functions

 H264DecoderESP32S3 ()
 
 H264DecoderESP32S3 (Print &out)
 
 H264DecoderESP32S3 (VideoOutput &out)
 
bool begin () override
 Initializes the decoder - see esp_h264::H264Decoder::begin().
 
uint32_t decodeErrors () const
 Number of decode errors since begin().
 
esp_h264::H264Decoder< Alloc > & driver ()
 Direct access to the wrapped esp_h264::H264Decoder.
 
void end () override
 Releases the decoder's resources - see esp_h264::H264Decoder::end().
 
void flush () override
 
uint32_t frameCount () const
 Number of frames successfully decoded since begin().
 
void setInputBufferSize (size_t size)
 
void setOutput (Print &out) override
 
void setOutput (VideoOutput &out)
 
void setOutputBufferSize (size_t size)
 
void setVideoFormat (VideoFormat format) override
 
VideoInfo videoInfo () override
 
size_t write (const uint8_t *data, size_t len) override
 

Protected Attributes

esp_h264::H264Decoder< Alloc >::Config config_
 
esp_h264::H264Decoder< Alloc > decoder_
 
Printp_out = nullptr
 
VideoOutputp_out_video = nullptr
 

Detailed Description

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
class audio_tools::H264DecoderESP32S3< Alloc >

H.264 video decoder for ESP32-S3: wraps esp_h264::H264Decoder (https://github.com/pschatzmann/ESP32S3-h264) as a VideoOutput, so it can be plugged directly into e.g. DemuxerAVI::setOutputVideo()/ DemuxerMP4::setOutputVideo() - the same role H264Decoder (CodecH264.h, the portable TinyH264-based decoder) plays, for boards where the ESP32-S3-specific esp_h264 backend is preferred instead. Consumes an Annex-B H.264 bitstream via write() and, once a complete picture has been decoded, writes it - converted to setVideoFormat()'s format (RGB565 by default, the common TFT wire format) - to the Print target configured via setOutput(), one write() call per decoded picture.

write()/flush() implement the VideoOutput contract (see Video.h): write() may be called one or more times per frame - bytes are forwarded to the wrapped decoder's decode() immediately, which invokes the frame callback synchronously for every completed picture found in that call, not deferred to flush(). flush() is a no-op, kept only because some producers (e.g. DemuxerAVI/DemuxerMP4) call it unconditionally after each frame.

The Alloc template parameter is forwarded to esp_h264::H264Decoder - see that class's own file comment (H264Decoder.h) for the PSRAM- vs. internal-RAM allocator choice (H264DecoderPSRAM/H264DecoderRAM aliases). Defaults to H264_DEFAULT_ALLOCATOR.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ H264DecoderESP32S3() [1/3]

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
H264DecoderESP32S3 ( )
inline

◆ H264DecoderESP32S3() [2/3]

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
H264DecoderESP32S3 ( Print out)
inline

◆ H264DecoderESP32S3() [3/3]

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
H264DecoderESP32S3 ( VideoOutput out)
inline

Member Function Documentation

◆ begin()

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
bool begin ( )
inlineoverridevirtual

Initializes the decoder - see esp_h264::H264Decoder::begin().

Implements VideoDecoder.

◆ decodeErrors()

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
uint32_t decodeErrors ( ) const
inline

Number of decode errors since begin().

◆ driver()

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
esp_h264::H264Decoder< Alloc > & driver ( )
inline

Direct access to the wrapped esp_h264::H264Decoder.

◆ end()

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
void end ( )
inlineoverridevirtual

Releases the decoder's resources - see esp_h264::H264Decoder::end().

Implements VideoDecoder.

◆ flush()

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
void flush ( )
inlineoverridevirtual

No-op - kept to satisfy the VideoOutput/Print contract; decoding already happens synchronously in write() (see class comment).

Reimplemented from VideoOutput.

◆ frameCount()

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
uint32_t frameCount ( ) const
inline

Number of frames successfully decoded since begin().

◆ setInputBufferSize()

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
void setInputBufferSize ( size_t  size)
inline

Input buffer size (bytes) the wrapped decoder allocates for its own copy of write()'s data - see esp_h264::H264Decoder::Config:: input_buffer_size. Call before begin().

◆ setOutput() [1/2]

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
void setOutput ( Print out)
inlineoverridevirtual

Defines the target the decoded picture is written to, one write() call per decoded picture, in the format selected via setVideoFormat() (RGB565 by default). Call before begin().

Implements VideoDecoder.

◆ setOutput() [2/2]

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
void setOutput ( VideoOutput out)
inline

◆ setOutputBufferSize()

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
void setOutputBufferSize ( size_t  size)
inline

Output buffer size (bytes) the wrapped decoder allocates for the decoded/converted picture - must be at least width*height*bytes- per-pixel for setVideoFormat()'s format. Call before begin().

◆ setVideoFormat()

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
void setVideoFormat ( VideoFormat  format)
inlineoverridevirtual

Selects the pixel format written to setOutput()'s target - this backend (esp_h264) only supports VideoFormat::RGB565 (the default) and VideoFormat::I420; any other value is logged and ignored (the previously selected format stays in effect) - use driver() and esp_h264_types.h's other ESP_H264_RAW_FMT_* values directly if you need one of those instead. Call before begin().

Implements VideoDecoder.

◆ videoInfo()

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
VideoInfo videoInfo ( )
inlineoverridevirtual

Reports the format/dimensions of the picture written to setOutput()'s target - format is setVideoFormat()'s most recently selected value (RGB565 if never called); width/height are the most recently decoded picture's (0 before any picture has been decoded).

Implements VideoDecoder.

◆ write()

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
size_t write ( const uint8_t *  data,
size_t  len 
)
inlineoverridevirtual

Feeds one chunk of Annex-B H.264 data - may be called more than once per frame. Decodes immediately, invoking setOutput()'s Print once per completed picture from within this call (not deferred to flush()).

Implements VideoOutput.

Member Data Documentation

◆ config_

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
esp_h264::H264Decoder<Alloc>::Config config_
protected

◆ decoder_

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
esp_h264::H264Decoder<Alloc> decoder_
protected

◆ p_out

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
Print* p_out = nullptr
protected

◆ p_out_video

template<typename Alloc = H264_DEFAULT_ALLOCATOR>
VideoOutput* p_out_video = nullptr
protected

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