H.264 video decoder: wraps TinyH264Decoder (https://github.com/pschatzmann/TinyH264) as a VideoOutput, so it can be plugged directly into e.g. DemuxerAVI::setOutputVideo()/ DemuxerMP4::setOutputVideo(). 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 <CodecH264.h>
|
| static void | onFrame (tinyh264::TinyH264Decoder< tinyh264::PSRAMAllocatorESP32< uint8_t > > &decoder, void *userData) |
| |
H.264 video decoder: wraps TinyH264Decoder (https://github.com/pschatzmann/TinyH264) as a VideoOutput, so it can be plugged directly into e.g. DemuxerAVI::setOutputVideo()/ DemuxerMP4::setOutputVideo(). 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 decoder immediately (Annex-B start codes are self-delimiting, so no internal buffering is needed here; a picture may complete partway through any write() call, not just at flush()). flush() is a no-op, kept only because some producers (e.g. DemuxerAVI/DemuxerMP4) call it unconditionally after each frame.
Uses H264_DEFAULT_ALLOCATOR for the decoded picture buffers - see that macro's own comment above for the PSRAM-on-ESP32/heap- elsewhere default it picks, and how to override it.
- Author
- Phil Schatzmann
- Copyright
- GPLv3
◆ H264Decoder() [1/3]
◆ H264Decoder() [2/3]
◆ H264Decoder() [3/3]
◆ begin()
Reserves the decoder's picture buffers up front - see TinyH264Decoder::begin().
Implements VideoDecoder.
◆ driver()
| tinyh264::TinyH264Decoder< tinyh264::PSRAMAllocatorESP32< uint8_t > > & driver |
( |
| ) |
|
|
inline |
Direct access to the wrapped TinyH264Decoder, e.g. for its width()/ height()/y()/u()/v()/getY()/getU()/getV() accessors.
◆ end()
Releases the decoder's picture buffers - see TinyH264Decoder::end().
Implements VideoDecoder.
◆ flush()
No-op - kept to satisfy the VideoOutput/Print contract; decoding already happens synchronously in write() (see class comment).
Reimplemented from VideoOutput.
◆ hasError()
True if the most recent write() call ended in a bitstream error or hit an unsupported stream feature.
◆ onFrame()
| static void onFrame |
( |
tinyh264::TinyH264Decoder< tinyh264::PSRAMAllocatorESP32< uint8_t > > & |
decoder, |
|
|
void * |
userData |
|
) |
| |
|
inlinestaticprotected |
◆ setMaxRefFrames()
| void setMaxRefFrames |
( |
int |
n | ) |
|
|
inline |
Runtime-active maximum stored reference pictures - see TinyH264Decoder::setMaxRefFrames().
◆ setOutput() [1/2]
| void setOutput |
( |
Print & |
out | ) |
|
|
inlinevirtual |
Defines the target the decoded picture is written to, one write() call per decoded picture, in the format selected via setVideoFormat() (RGB565 by default).
Implements VideoDecoder.
◆ setOutput() [2/2]
◆ setVideoFormat()
Selects the pixel format written to setOutput()'s target - RGB565 (the default) is what most TFT display libraries expect; RGB666/ RGB888 for higher color depth displays; I420 to pass the decoded planes through unconverted (tightly packed: Y bytes, then U bytes, then V bytes, no row padding - see TinyH264Decoder::toYUV420()). Any other VideoFormat is logged and ignored (previous format kept).
Implements VideoDecoder.
◆ videoInfo()
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()
| 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 (e.g. from a demuxer that hands over payload in pieces). Decodes immediately, invoking setOutput()'s Print once per completed picture from within this call (not deferred to flush()).
Implements VideoOutput.
◆ writeToOutput() [1/2]
◆ writeToOutput() [2/2]
| size_t writeToOutput |
( |
uint8_t * |
data, |
|
|
size_t |
len |
|
) |
| |
|
inlineprotected |
◆ decoder_
| tinyh264::TinyH264Decoder< tinyh264::PSRAMAllocatorESP32<uint8_t> > decoder_ |
|
protected |
◆ frame_buffer
◆ p_out
◆ p_out_video
◆ pixel_format
The documentation for this class was generated from the following file: