[PATCH RFC 03/11] media: h264: Write the stateless encode SPS and PPS with nal_ref_idc 3
From: Arun Iyengar via B4 Relay
Date: Tue Nov 10 2026 - 05:27:30 EST
From: Arun Iyengar <aiyengar1990@xxxxxxxxx>
The sequence and picture parameter set NAL units are written with
nal_ref_idc 0, which ITU-T H.264 section 7.4.1 forbids: "nal_ref_idc
shall not be equal to 0 for sequence parameter set or sequence parameter
set extension or subset sequence parameter set or picture parameter set
NAL units". FFmpeg's H.264 probe rejects such streams (an Annex B file
from the encoder is "detected only with low score of 1"), and stricter
decoders may drop the parameter sets.
Write them with nal_ref_idc 3, as other encoders do. Access unit
delimiters keep 0, which the specification requires for them.
Signed-off-by: Arun Iyengar <aiyengar1990@xxxxxxxxx>
---
drivers/media/v4l2-core/v4l2-h264-enc-rbsp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-h264-enc-rbsp.c b/drivers/media/v4l2-core/v4l2-h264-enc-rbsp.c
index 2d751855195b..fa5857b77d76 100644
--- a/drivers/media/v4l2-core/v4l2-h264-enc-rbsp.c
+++ b/drivers/media/v4l2-core/v4l2-h264-enc-rbsp.c
@@ -654,7 +654,7 @@ int v4l2_h264_enc_rbsp_sps(struct v4l2_h264_enc_rbsp *rbsp,
unsigned int i;
int ret;
- ret = v4l2_h264_enc_rbsp_nalu_begin(rbsp, 0, V4L2_H264_NALU_TYPE_SPS);
+ ret = v4l2_h264_enc_rbsp_nalu_begin(rbsp, 3, V4L2_H264_NALU_TYPE_SPS);
if (ret)
return ret;
@@ -845,7 +845,7 @@ int v4l2_h264_enc_rbsp_pps(struct v4l2_h264_enc_rbsp *rbsp,
u8 pic_scaling_matrix_present_flag = 0;
int ret;
- ret = v4l2_h264_enc_rbsp_nalu_begin(rbsp, 0, V4L2_H264_NALU_TYPE_PPS);
+ ret = v4l2_h264_enc_rbsp_nalu_begin(rbsp, 3, V4L2_H264_NALU_TYPE_PPS);
if (ret)
return ret;
--
2.55.0