FastLED 3.9.15
Loading...
Searching...
No Matches
h264.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/codec/common.h"
5#include "fl/stl/noexcept.h"
6
7namespace fl {
8
9// H.264 metadata parsed from SPS NAL unit via Exp-Golomb decoding.
10struct H264Info {
11 fl::u16 width = 0;
12 fl::u16 height = 0;
13 fl::u8 profile = 0; // Baseline=66, Main=77, High=100, etc.
14 fl::u8 level = 0; // e.g. 30 = level 3.0
16 bool isValid = false;
17
18 H264Info() FL_NOEXCEPT = default;
19 H264Info(fl::u16 w, fl::u16 h, fl::u8 prof, fl::u8 lvl)
20 : width(w), height(h), profile(prof), level(lvl), isValid(true) {}
21};
22
23// H.264 decoder configuration
24struct H264Config {
25 fl::u16 maxWidth = 1920;
26 fl::u16 maxHeight = 1080;
27};
28
29// H.264 decoder factory — follows the same pattern as Mpeg1.
30// On host platforms, createDecoder() returns a NullDecoder (structural validation only).
31// On ESP32-P4, createDecoder() returns a hardware-accelerated decoder.
32class H264 {
33public:
34 // Create an H.264 decoder for the current platform.
35 // Returns NullDecoder on platforms without H.264 HW support.
36 static IDecoderPtr createDecoder(const H264Config& config,
37 fl::string* error_message = nullptr);
38
39 static IDecoderPtr createDecoder(fl::string* error_message = nullptr) {
40 H264Config config;
41 return createDecoder(config, error_message);
42 }
43
44 // Check if H.264 decoding is supported on this platform.
45 // Currently only true on ESP32-P4.
46 static bool isSupported();
47
48 // Parse H.264 metadata from an MP4 container without creating a decoder.
49 // Extracts SPS from avcC box and parses width/height/profile/level.
51 fl::string* error_message = nullptr);
52
53 // Parse H.264 SPS NAL unit directly (without MP4 container).
54 // The spsData should be the raw SPS NAL unit bytes (without start code).
56 fl::string* error_message = nullptr);
57};
58
59} // namespace fl
static H264Info parseSPS(fl::span< const fl::u8 > spsData, fl::string *error_message=nullptr)
Definition h264.cpp.hpp:85
static IDecoderPtr createDecoder(fl::string *error_message=nullptr)
Definition h264.h:39
static IDecoderPtr createDecoder(const H264Config &config, fl::string *error_message=nullptr)
static H264Info parseH264Info(fl::span< const fl::u8 > mp4Data, fl::string *error_message=nullptr)
Definition h264.cpp.hpp:196
static bool isSupported()
unsigned char u8
Definition s16x16x4.h:132
unsigned char u8
Definition stdint.h:131
Base definition for an LED controller.
Definition crgb.hpp:179
fl::u16 maxHeight
Definition h264.h:26
fl::u16 maxWidth
Definition h264.h:25
#define FL_NOEXCEPT
fl::u8 profile
Definition h264.h:13
fl::u8 level
Definition h264.h:14
fl::u8 numRefFrames
Definition h264.h:15
H264Info() FL_NOEXCEPT=default
bool isValid
Definition h264.h:16
fl::u16 height
Definition h264.h:12
fl::u16 width
Definition h264.h:11