|
arduino-audio-tools
|
H.264 video encoder for ESP32-P4: wraps esp_h264_p4::H264EncoderP4 (https://github.com/pschatzmann/codec-h264-ESP32P4), which drives ESP32-P4's dedicated H.264 hardware encoder block - the ESP32-P4-specific counterpart of H264Encoder (CodecH264.h, the portable TinyH264-based software encoder) and a hardware-backed sibling of H264EncoderESP32S3 (whose wrapped esp_h264::H264Encoder is software-only, since the S3 has no H.264 hardware block). More...
#include <CodecH264ESP32P4.h>
Classes | |
| class | DualOutputPrint |
Public Member Functions | |
| H264EncoderESP32P4 () | |
| H264EncoderESP32P4 (Print &out) | |
| H264EncoderESP32P4 (VideoOutput &out) | |
| bool | begin () override |
| Initializes the encoder - see esp_h264_p4::H264EncoderP4::begin(). | |
| esp_h264_p4::H264EncoderP4< Alloc > & | driver () |
| Direct access to the wrapped esp_h264_p4::H264EncoderP4. | |
| void | end () override |
| esp_h264_frame_type_t | lastFrameType () const |
| void | setBitrate (int bitsPerSecond) |
| void | setFrameRate (int fps) |
| void | setGop (int gop) |
| void | setOutput (Print &out) override |
| void | setOutput (VideoOutput &out) |
| void | setOutputBufferSize (size_t size) |
| void | setQpRange (int qpMin, int qpMax) |
| 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 Attributes | |
| esp_h264_p4::H264EncoderP4< Alloc >::Config | config_ |
| DualOutputPrint | dual_out_ |
| esp_h264_p4::H264EncoderP4< Alloc > | encoder_ |
| VideoFormat | input_format = VideoFormat::I420 |
| Print * | p_out = nullptr |
| VideoOutput * | p_out_video = nullptr |
H.264 video encoder for ESP32-P4: wraps esp_h264_p4::H264EncoderP4 (https://github.com/pschatzmann/codec-h264-ESP32P4), which drives ESP32-P4's dedicated H.264 hardware encoder block - the ESP32-P4-specific counterpart of H264Encoder (CodecH264.h, the portable TinyH264-based software encoder) and a hardware-backed sibling of H264EncoderESP32S3 (whose wrapped esp_h264::H264Encoder is software-only, since the S3 has no H.264 hardware block).
Configure via setSize()/setFrameRate()/setBitrate()/setGop()/ setQpRange()/setVideoFormat() (I420 - the default -, RGB565 or YUV422), then feed raw pictures via write() - it writes the resulting Annex-B bitstream straight to the Print target passed to setOutput().
Unlike RGB565/YUV422 (packed formats the hardware encoder consumes as-is), I420 (planar Y/U/V) is not one of the hardware's accepted raw layouts - write() instead routes it through esp_h264_p4::H264EncoderP4::encodeYUV420Planar(), which repacks it into the hardware's required ESP_H264_RAW_FMT_O_UYY_E_VYY layout internally.
The Alloc template parameter is forwarded to esp_h264_p4::H264EncoderP4
|
inline |
|
inline |
|
inline |
|
inlineoverridevirtual |
Initializes the encoder - see esp_h264_p4::H264EncoderP4::begin().
Implements VideoEncoder.
|
inline |
Direct access to the wrapped esp_h264_p4::H264EncoderP4.
|
inlineoverridevirtual |
Releases the encoder's resources - see esp_h264_p4::H264EncoderP4::end().
Implements VideoEncoder.
|
inline |
Frame type of the most recent successful encode (IDR/I/P) - see esp_h264_p4::H264EncoderP4::lastFrameType().
|
inline |
Target bitrate (bits/sec) - defaults to width*height*fps*30/100 if never called. Call before begin().
|
inline |
|
inline |
Group-of-Pictures size (keyframe interval, in frames) - unlike the software encoder (H264EncoderESP32S3), 0 is invalid here; defaults to setFrameRate()'s fps if never called. Call before begin().
|
inlineoverridevirtual |
Defines the target each write() call writes its encoded bitstream to.
Implements VideoEncoder.
|
inline |
|
inline |
Output buffer size (bytes) the wrapped encoder allocates for the encoded bitstream - defaults to width*height*bytes-per-pixel (for the selected raw format) if never called. Call before begin().
|
inline |
Quantizer parameter range [0, 51] the encoder's rate control stays within - lower is better quality/higher bitrate. Defaults to [25, 30] if never called. Call before begin().
|
inline |
|
inlineoverridevirtual |
Selects the raw picture format write() expects - this backend (esp_h264_p4) supports VideoFormat::I420 (the default: planar Y/U/V, no row padding - repacked internally, see class comment), RGB565 (16-bit, 5-6-5 packed, little-endian) and YUV422 (packed YUYV); any other value is logged and ignored (the previously selected format stays in effect). Call before begin() - it also selects the hardware's raw pixel format (Config::pic_type).
Implements VideoEncoder.
|
inlineoverridevirtual |
Reports the codec/dimensions of the bitstream written to setOutput()'s target - format is always VideoFormat::H264 (NOT setVideoFormat()'s raw input format); width/height match setSize() (640x480 if never called - see Config's defaults).
Implements VideoEncoder.
|
inlineoverridevirtual |
Encodes one raw picture, in setVideoFormat()'s format (I420 by default: Y, then U, then V, no row padding; RGB565 or YUV422 likewise, passed straight through to the hardware), and writes the result to setOutput() - len must be at least width*height*3/2 (I420) or width*height*2 (RGB565/YUV422). Returns 1 on success (see class comment - not an exact byte count, the underlying esp_h264_p4::H264EncoderP4 only reports success/failure), or 0 on failure (e.g. setOutput() wasn't configured, len too small, or the format is unsupported).
Implements VideoEncoder.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |