125 lines
4.2 KiB
Diff
125 lines
4.2 KiB
Diff
From 205b58f87337b9cfba33b63224ec968f0ac7d6a2 Mon Sep 17 00:00:00 2001
|
|
From: Michael Grzeschik <m.grzeschik@pengutronix.de>
|
|
Date: Tue, 21 Feb 2023 01:57:50 +0100
|
|
Subject: [PATCH 45/68] v4l2codecs: Add V4L2 H264 stateless encode uAPI
|
|
|
|
Upstream-Status: Pending
|
|
---
|
|
sys/v4l2codecs/linux/v4l2-controls.h | 85 ++++++++++++++++++++++++++++
|
|
sys/v4l2codecs/linux/videodev2.h | 3 +
|
|
2 files changed, 88 insertions(+)
|
|
|
|
diff --git a/sys/v4l2codecs/linux/v4l2-controls.h b/sys/v4l2codecs/linux/v4l2-controls.h
|
|
index 8838a5d..9c83596 100644
|
|
--- a/sys/v4l2codecs/linux/v4l2-controls.h
|
|
+++ b/sys/v4l2codecs/linux/v4l2-controls.h
|
|
@@ -1615,6 +1615,91 @@ struct v4l2_ctrl_h264_decode_params {
|
|
__u32 flags;
|
|
};
|
|
|
|
+#define V4L2_H264_NAL_CODED_SLICE_NON_IDR_PIC 1
|
|
+#define V4L2_H264_NAL_CODED_SLICE_IDR_PIC 5
|
|
+
|
|
+#define V4L2_CID_STATELESS_H264_ENCODE_PARAMS (V4L2_CID_CODEC_STATELESS_BASE + 8)
|
|
+
|
|
+/**
|
|
+ * struct v4l2_ctrl_h264_encode_params
|
|
+ * @slice_type: selects slice type. Set to one of V4L2_H264_SLICE_TYPE_{}
|
|
+ * @pic_parameter_set_id: identifies the picture parameter set that is referred to
|
|
+ * in the slice header. The value shall be in the range of 0 to 255, inclusive.
|
|
+ * @frame_num: an identifier for pictures.
|
|
+ * @idr_pic_id: identifies an IDR picture.
|
|
+ * @cabac_init_idc: index for determining the initialization table used in the
|
|
+ * initialization process for context variables. The value of cabac_init_idc
|
|
+ * shall be in the range of 0 to 2, inclusive.
|
|
+ * @disable_deblocking_filter_idc: specifies whether the operation of the
|
|
+ * deblocking filter shall be disabled across some block edges of the slice and
|
|
+ * specifies for which edges the filtering is disabled.
|
|
+ * @slice_alpha_c0_offset_div2: offset used in accessing the alpha and tC0
|
|
+ * deblocking filter tables for filtering operations controlled by the macroblocks
|
|
+ * within the slice.
|
|
+ * @slice_beta_offset_div2: offset used in accessing the beta deblocking filter
|
|
+ * table for filtering operations controlled by the macroblocks within the slice.
|
|
+ * @slice_size_mb_rows: number of macroblock rows in a slice.
|
|
+ * @pic_init_qp_minus26: initial value minus 26 of luma qp for each slice.
|
|
+ * @chroma_qp_index_offset: offset that shall be added to qp luma for addressing the
|
|
+ * table of qp chroma values for the Cb chroma component.
|
|
+ * @flags: combination of V4L2_H264_SLICE_FLAG_{} flags.
|
|
+ */
|
|
+struct v4l2_ctrl_h264_encode_params {
|
|
+ /* Slice parameters */
|
|
+
|
|
+ __u8 slice_type;
|
|
+ __u8 pic_parameter_set_id;
|
|
+ __u16 frame_num;
|
|
+ __u16 idr_pic_id;
|
|
+ __u8 cabac_init_idc;
|
|
+ __u8 disable_deblocking_filter_idc;
|
|
+ __s8 slice_alpha_c0_offset_div2;
|
|
+ __s8 slice_beta_offset_div2;
|
|
+
|
|
+ __s32 slice_size_mb_rows;
|
|
+
|
|
+ /* PPS parameters */
|
|
+
|
|
+ __s8 pic_init_qp_minus26;
|
|
+ __s8 chroma_qp_index_offset;
|
|
+
|
|
+ __u32 flags; /* V4L2_H264_ENCODE_FLAG_ */
|
|
+
|
|
+ /* Nal parameters */
|
|
+ __u8 nal_reference_idc; // 2 bit
|
|
+ __u8 nalu_type; // 5 bit
|
|
+
|
|
+ /* Reference */
|
|
+
|
|
+ __u64 reference_ts;
|
|
+};
|
|
+
|
|
+#define V4L2_H264_ENCODE_FLAG_ENTROPY_CABAC 0x01
|
|
+#define V4L2_H264_ENCODE_FLAG_TRANSFORM_8X8_MODE 0x02
|
|
+#define V4L2_H264_ENCODE_FLAG_CONSTRAINED_INTRA_PRED 0x04
|
|
+#define V4L2_H264_ENCODE_FLAG_MARK_LONGTERM 0x08
|
|
+
|
|
+#define V4L2_CID_STATELESS_H264_ENCODE_RC (V4L2_CID_CODEC_STATELESS_BASE + 9)
|
|
+
|
|
+/**
|
|
+ * struct v4l2_ctrl_h264_encode_rc
|
|
+ *
|
|
+ * @qp: quantization parameter for the currently encoded slice
|
|
+ *
|
|
+ * TODO: other fields likely not needed
|
|
+ */
|
|
+struct v4l2_ctrl_h264_encode_rc {
|
|
+ __u32 qp;
|
|
+ __u32 qp_min;
|
|
+ __u32 qp_max;
|
|
+ __s32 mad_qp_delta;
|
|
+ __u32 mad_threshold;
|
|
+
|
|
+ __u32 cp_distance_mbs;
|
|
+ __u32 cp_target[10];
|
|
+ __s32 cp_target_error[6];
|
|
+ __s32 cp_qp_delta[7];
|
|
+};
|
|
|
|
/* Stateless FWHT control, used by the vicodec driver */
|
|
|
|
diff --git a/sys/v4l2codecs/linux/videodev2.h b/sys/v4l2codecs/linux/videodev2.h
|
|
index 687ac85..efaa797 100644
|
|
--- a/sys/v4l2codecs/linux/videodev2.h
|
|
+++ b/sys/v4l2codecs/linux/videodev2.h
|
|
@@ -1794,6 +1794,9 @@ enum v4l2_ctrl_type {
|
|
V4L2_CTRL_TYPE_H264_SLICE_PARAMS = 0x0203,
|
|
V4L2_CTRL_TYPE_H264_DECODE_PARAMS = 0x0204,
|
|
V4L2_CTRL_TYPE_H264_PRED_WEIGHTS = 0x0205,
|
|
+ V4L2_CTRL_TYPE_H264_ENCODE_PARAMS = 0x0206,
|
|
+ V4L2_CTRL_TYPE_H264_ENCODE_RC = 0x0207,
|
|
+ V4L2_CTRL_TYPE_H264_ENCODE_FEEDBACK = 0x0208,
|
|
|
|
V4L2_CTRL_TYPE_FWHT_PARAMS = 0x0220,
|
|
|
|
--
|
|
2.25.1
|
|
|