/* SPDX-License-Identifier: BSD-2-Clause */ /* * h264_nal_synth.h — synthesise AnnexB SPS + PPS NAL units from the * v4l2_ctrl_h264_sps / v4l2_ctrl_h264_pps structures the libva driver * sets via V4L2 stateless controls and the daedalus kernel module * forwards over the chardev as struct daedalus_h264_meta. * * libavcodec needs SPS+PPS NAL units BEFORE any slice NAL to bind * the slice's pic_parameter_set_id reference; libva-v4l2-request * passes only the slice in the OUTPUT buffer (per the V4L2 stateless * H.264 contract). The daemon bridges by reconstructing SPS+PPS * NAL bytes from the structured controls and prepending them to the * bitstream the daemon hands libavcodec. * * Output is AnnexB-framed: 0x00 0x00 0x00 0x01 start code + NAL. * Emulation prevention (insert 0x03 after any 0x00 0x00 in the RBSP) * is handled by this module so the consumer can concatenate raw. */ #ifndef DAEDALUS_H264_NAL_SYNTH_H #define DAEDALUS_H264_NAL_SYNTH_H #include #include #include /* * Encode an AnnexB SPS NAL into out[]. Returns the number of bytes * written, or 0 on overflow / malformed input. out_cap must be at * least 256 bytes to handle worst-case SPS with full offset_for_ref_ * frame[] cycle. */ size_t h264_synth_sps(const struct v4l2_ctrl_h264_sps *sps, uint8_t *out, size_t out_cap); /* * Encode an AnnexB PPS NAL into out[]. Returns the number of bytes * written, or 0 on overflow. out_cap should be at least 64 bytes; * PPS NALs are small. */ size_t h264_synth_pps(const struct v4l2_ctrl_h264_pps *pps, uint8_t *out, size_t out_cap); #endif /* DAEDALUS_H264_NAL_SYNTH_H */