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>
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
- Copyright
- GPLv3
◆ H264DecoderESP32S3() [1/3]
template<typename Alloc = H264_DEFAULT_ALLOCATOR>
◆ H264DecoderESP32S3() [2/3]
template<typename Alloc = H264_DEFAULT_ALLOCATOR>
◆ H264DecoderESP32S3() [3/3]
template<typename Alloc = H264_DEFAULT_ALLOCATOR>
◆ begin()
template<typename Alloc = H264_DEFAULT_ALLOCATOR>
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>
Releases the decoder's resources - see esp_h264::H264Decoder::end().
Implements VideoDecoder.
◆ flush()
template<typename Alloc = H264_DEFAULT_ALLOCATOR>
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 |
◆ setOutput() [2/2]
template<typename Alloc = H264_DEFAULT_ALLOCATOR>
◆ 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>
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>
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.
◆ 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>
◆ p_out_video
template<typename Alloc = H264_DEFAULT_ALLOCATOR>
The documentation for this class was generated from the following file: