History

media: uapi: move H264 stateless controls out of staging

The H.264 stateless 'uAPI' was staging and marked explicitly in the V4L2 specification that it will change and is unstable. Note that these control IDs were never exported as a public API, they were only defined in kernel-local headers (h264-ctrls.h). Now, the H264 stateless controls is ready to be part of the stable uAPI. While not too late, let's rename them and re-number their control IDs, moving them to the newly created stateless control class, and updating all the drivers accordingly.

Ezequiel Garcia committed 5 years ago

Commit 46a309d1 parent afc532911 files · +457 −475Browse files

Showing the changes to include/uapi/linux (2 of 11 files). Show all

Unified · Split

2 files
  1. include/uapi/linux/v4l2-controls.h +381 −0
  2. include/uapi/linux/videodev2.h +6 −0
include/uapi/linux/v4l2-controls.h+381−0
@@ -1183,6 +1183,387 @@ enum v4l2_detect_md_mode { · 1182 unmodified lines
1183#define V4L2_CID_CODEC_STATELESS_BASE (V4L2_CTRL_CLASS_CODEC_STATELESS | 0x900)1183#define V4L2_CID_CODEC_STATELESS_BASE (V4L2_CTRL_CLASS_CODEC_STATELESS | 0x900)
1184#define V4L2_CID_CODEC_STATELESS_CLASS (V4L2_CTRL_CLASS_CODEC_STATELESS | 1)1184#define V4L2_CID_CODEC_STATELESS_CLASS (V4L2_CTRL_CLASS_CODEC_STATELESS | 1)
1185 1185
1186#define V4L2_CID_STATELESS_H264_DECODE_MODE (V4L2_CID_CODEC_STATELESS_BASE + 0)
1187/**
1188 * enum v4l2_stateless_h264_decode_mode - Decoding mode
1189 *
1190 * @V4L2_STATELESS_H264_DECODE_MODE_SLICE_BASED: indicates that decoding
1191 * is performed one slice at a time. In this mode,
1192 * V4L2_CID_STATELESS_H264_SLICE_PARAMS must contain the parsed slice
1193 * parameters and the OUTPUT buffer must contain a single slice.
1194 * V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF feature is used
1195 * in order to support multislice frames.
1196 * @V4L2_STATELESS_H264_DECODE_MODE_FRAME_BASED: indicates that
1197 * decoding is performed per frame. The OUTPUT buffer must contain
1198 * all slices and also both fields. This mode is typically supported
1199 * by device drivers that are able to parse the slice(s) header(s)
1200 * in hardware. When this mode is selected,
1201 * V4L2_CID_STATELESS_H264_SLICE_PARAMS is not used.
1202 */
1203enum v4l2_stateless_h264_decode_mode {
1204 V4L2_STATELESS_H264_DECODE_MODE_SLICE_BASED,
1205 V4L2_STATELESS_H264_DECODE_MODE_FRAME_BASED,
1206};
1207
1208#define V4L2_CID_STATELESS_H264_START_CODE (V4L2_CID_CODEC_STATELESS_BASE + 1)
1209/**
1210 * enum v4l2_stateless_h264_start_code - Start code
1211 *
1212 * @V4L2_STATELESS_H264_START_CODE_NONE: slices are passed
1213 * to the driver without any start code.
1214 * @V4L2_STATELESS_H264_START_CODE_ANNEX_B: slices are passed
1215 * to the driver with an Annex B start code prefix
1216 * (legal start codes can be 3-bytes 0x000001 or 4-bytes 0x00000001).
1217 * This mode is typically supported by device drivers that parse
1218 * the start code in hardware.
1219 */
1220enum v4l2_stateless_h264_start_code {
1221 V4L2_STATELESS_H264_START_CODE_NONE,
1222 V4L2_STATELESS_H264_START_CODE_ANNEX_B,
1223};
1224
1225#define V4L2_H264_SPS_CONSTRAINT_SET0_FLAG 0x01
1226#define V4L2_H264_SPS_CONSTRAINT_SET1_FLAG 0x02
1227#define V4L2_H264_SPS_CONSTRAINT_SET2_FLAG 0x04
1228#define V4L2_H264_SPS_CONSTRAINT_SET3_FLAG 0x08
1229#define V4L2_H264_SPS_CONSTRAINT_SET4_FLAG 0x10
1230#define V4L2_H264_SPS_CONSTRAINT_SET5_FLAG 0x20
1231
1232#define V4L2_H264_SPS_FLAG_SEPARATE_COLOUR_PLANE 0x01
1233#define V4L2_H264_SPS_FLAG_QPPRIME_Y_ZERO_TRANSFORM_BYPASS 0x02
1234#define V4L2_H264_SPS_FLAG_DELTA_PIC_ORDER_ALWAYS_ZERO 0x04
1235#define V4L2_H264_SPS_FLAG_GAPS_IN_FRAME_NUM_VALUE_ALLOWED 0x08
1236#define V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY 0x10
1237#define V4L2_H264_SPS_FLAG_MB_ADAPTIVE_FRAME_FIELD 0x20
1238#define V4L2_H264_SPS_FLAG_DIRECT_8X8_INFERENCE 0x40
1239
1240#define V4L2_H264_SPS_HAS_CHROMA_FORMAT(sps) \
1241 ((sps)->profile_idc == 100 || (sps)->profile_idc == 110 || \
1242 (sps)->profile_idc == 122 || (sps)->profile_idc == 244 || \
1243 (sps)->profile_idc == 44 || (sps)->profile_idc == 83 || \
1244 (sps)->profile_idc == 86 || (sps)->profile_idc == 118 || \
1245 (sps)->profile_idc == 128 || (sps)->profile_idc == 138 || \
1246 (sps)->profile_idc == 139 || (sps)->profile_idc == 134 || \
1247 (sps)->profile_idc == 135)
1248
1249#define V4L2_CID_STATELESS_H264_SPS (V4L2_CID_CODEC_STATELESS_BASE + 2)
1250/**
1251 * struct v4l2_ctrl_h264_sps - H264 sequence parameter set
1252 *
1253 * All the members on this sequence parameter set structure match the
1254 * sequence parameter set syntax as specified by the H264 specification.
1255 *
1256 * @profile_idc: see H264 specification.
1257 * @constraint_set_flags: see H264 specification.
1258 * @level_idc: see H264 specification.
1259 * @seq_parameter_set_id: see H264 specification.
1260 * @chroma_format_idc: see H264 specification.
1261 * @bit_depth_luma_minus8: see H264 specification.
1262 * @bit_depth_chroma_minus8: see H264 specification.
1263 * @log2_max_frame_num_minus4: see H264 specification.
1264 * @pic_order_cnt_type: see H264 specification.
1265 * @log2_max_pic_order_cnt_lsb_minus4: see H264 specification.
1266 * @max_num_ref_frames: see H264 specification.
1267 * @num_ref_frames_in_pic_order_cnt_cycle: see H264 specification.
1268 * @offset_for_ref_frame: see H264 specification.
1269 * @offset_for_non_ref_pic: see H264 specification.
1270 * @offset_for_top_to_bottom_field: see H264 specification.
1271 * @pic_width_in_mbs_minus1: see H264 specification.
1272 * @pic_height_in_map_units_minus1: see H264 specification.
1273 * @flags: see V4L2_H264_SPS_FLAG_{}.
1274 */
1275struct v4l2_ctrl_h264_sps {
1276 __u8 profile_idc;
1277 __u8 constraint_set_flags;
1278 __u8 level_idc;
1279 __u8 seq_parameter_set_id;
1280 __u8 chroma_format_idc;
1281 __u8 bit_depth_luma_minus8;
1282 __u8 bit_depth_chroma_minus8;
1283 __u8 log2_max_frame_num_minus4;
1284 __u8 pic_order_cnt_type;
1285 __u8 log2_max_pic_order_cnt_lsb_minus4;
1286 __u8 max_num_ref_frames;
1287 __u8 num_ref_frames_in_pic_order_cnt_cycle;
1288 __s32 offset_for_ref_frame[255];
1289 __s32 offset_for_non_ref_pic;
1290 __s32 offset_for_top_to_bottom_field;
1291 __u16 pic_width_in_mbs_minus1;
1292 __u16 pic_height_in_map_units_minus1;
1293 __u32 flags;
1294};
1295
1296#define V4L2_H264_PPS_FLAG_ENTROPY_CODING_MODE 0x0001
1297#define V4L2_H264_PPS_FLAG_BOTTOM_FIELD_PIC_ORDER_IN_FRAME_PRESENT 0x0002
1298#define V4L2_H264_PPS_FLAG_WEIGHTED_PRED 0x0004
1299#define V4L2_H264_PPS_FLAG_DEBLOCKING_FILTER_CONTROL_PRESENT 0x0008
1300#define V4L2_H264_PPS_FLAG_CONSTRAINED_INTRA_PRED 0x0010
1301#define V4L2_H264_PPS_FLAG_REDUNDANT_PIC_CNT_PRESENT 0x0020
1302#define V4L2_H264_PPS_FLAG_TRANSFORM_8X8_MODE 0x0040
1303#define V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT 0x0080
1304
1305#define V4L2_CID_STATELESS_H264_PPS (V4L2_CID_CODEC_STATELESS_BASE + 3)
1306/**
1307 * struct v4l2_ctrl_h264_pps - H264 picture parameter set
1308 *
1309 * Except where noted, all the members on this picture parameter set
1310 * structure match the sequence parameter set syntax as specified
1311 * by the H264 specification.
1312 *
1313 * In particular, V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT flag
1314 * has a specific meaning. This flag should be set if a non-flat
1315 * scaling matrix applies to the picture. In this case, applications
1316 * are expected to use V4L2_CID_STATELESS_H264_SCALING_MATRIX,
1317 * to pass the values of the non-flat matrices.
1318 *
1319 * @pic_parameter_set_id: see H264 specification.
1320 * @seq_parameter_set_id: see H264 specification.
1321 * @num_slice_groups_minus1: see H264 specification.
1322 * @num_ref_idx_l0_default_active_minus1: see H264 specification.
1323 * @num_ref_idx_l1_default_active_minus1: see H264 specification.
1324 * @weighted_bipred_idc: see H264 specification.
1325 * @pic_init_qp_minus26: see H264 specification.
1326 * @pic_init_qs_minus26: see H264 specification.
1327 * @chroma_qp_index_offset: see H264 specification.
1328 * @second_chroma_qp_index_offset: see H264 specification.
1329 * @flags: see V4L2_H264_PPS_FLAG_{}.
1330 */
1331struct v4l2_ctrl_h264_pps {
1332 __u8 pic_parameter_set_id;
1333 __u8 seq_parameter_set_id;
1334 __u8 num_slice_groups_minus1;
1335 __u8 num_ref_idx_l0_default_active_minus1;
1336 __u8 num_ref_idx_l1_default_active_minus1;
1337 __u8 weighted_bipred_idc;
1338 __s8 pic_init_qp_minus26;
1339 __s8 pic_init_qs_minus26;
1340 __s8 chroma_qp_index_offset;
1341 __s8 second_chroma_qp_index_offset;
1342 __u16 flags;
1343};
1344
1345#define V4L2_CID_STATELESS_H264_SCALING_MATRIX (V4L2_CID_CODEC_STATELESS_BASE + 4)
1346/**
1347 * struct v4l2_ctrl_h264_scaling_matrix - H264 scaling matrices
1348 *
1349 * @scaling_list_4x4: scaling matrix after applying the inverse
1350 * scanning process. Expected list order is Intra Y, Intra Cb,
1351 * Intra Cr, Inter Y, Inter Cb, Inter Cr. The values on each
1352 * scaling list are expected in raster scan order.
1353 * @scaling_list_8x8: scaling matrix after applying the inverse
1354 * scanning process. Expected list order is Intra Y, Inter Y,
1355 * Intra Cb, Inter Cb, Intra Cr, Inter Cr. The values on each
1356 * scaling list are expected in raster scan order.
1357 *
1358 * Note that the list order is different for the 4x4 and 8x8
1359 * matrices as per the H264 specification, see table 7-2 "Assignment
1360 * of mnemonic names to scaling list indices and specification of
1361 * fall-back rule".
1362 */
1363struct v4l2_ctrl_h264_scaling_matrix {
1364 __u8 scaling_list_4x4[6][16];
1365 __u8 scaling_list_8x8[6][64];
1366};
1367
1368struct v4l2_h264_weight_factors {
1369 __s16 luma_weight[32];
1370 __s16 luma_offset[32];
1371 __s16 chroma_weight[32][2];
1372 __s16 chroma_offset[32][2];
1373};
1374
1375#define V4L2_H264_CTRL_PRED_WEIGHTS_REQUIRED(pps, slice) \
1376 ((((pps)->flags & V4L2_H264_PPS_FLAG_WEIGHTED_PRED) && \
1377 ((slice)->slice_type == V4L2_H264_SLICE_TYPE_P || \
1378 (slice)->slice_type == V4L2_H264_SLICE_TYPE_SP)) || \
1379 ((pps)->weighted_bipred_idc == 1 && \
1380 (slice)->slice_type == V4L2_H264_SLICE_TYPE_B))
1381
1382#define V4L2_CID_STATELESS_H264_PRED_WEIGHTS (V4L2_CID_CODEC_STATELESS_BASE + 5)
1383/**
1384 * struct v4l2_ctrl_h264_pred_weights - Prediction weight table
1385 *
1386 * Prediction weight table, which matches the syntax specified
1387 * by the H264 specification.
1388 *
1389 * @luma_log2_weight_denom: see H264 specification.
1390 * @chroma_log2_weight_denom: see H264 specification.
1391 * @weight_factors: luma and chroma weight factors.
1392 */
1393struct v4l2_ctrl_h264_pred_weights {
1394 __u16 luma_log2_weight_denom;
1395 __u16 chroma_log2_weight_denom;
1396 struct v4l2_h264_weight_factors weight_factors[2];
1397};
1398
1399#define V4L2_H264_SLICE_TYPE_P 0
1400#define V4L2_H264_SLICE_TYPE_B 1
1401#define V4L2_H264_SLICE_TYPE_I 2
1402#define V4L2_H264_SLICE_TYPE_SP 3
1403#define V4L2_H264_SLICE_TYPE_SI 4
1404
1405#define V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED 0x01
1406#define V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH 0x02
1407
1408#define V4L2_H264_TOP_FIELD_REF 0x1
1409#define V4L2_H264_BOTTOM_FIELD_REF 0x2
1410#define V4L2_H264_FRAME_REF 0x3
1411
1412/**
1413 * struct v4l2_h264_reference - H264 picture reference
1414 *
1415 * @fields: indicates how the picture is referenced.
1416 * Valid values are V4L2_H264_{}_REF.
1417 * @index: index into v4l2_ctrl_h264_decode_params.dpb[].
1418 */
1419struct v4l2_h264_reference {
1420 __u8 fields;
1421 __u8 index;
1422};
1423
1424/*
1425 * Maximum DPB size, as specified by section 'A.3.1 Level limits
1426 * common to the Baseline, Main, and Extended profiles'.
1427 */
1428#define V4L2_H264_NUM_DPB_ENTRIES 16
1429#define V4L2_H264_REF_LIST_LEN (2 * V4L2_H264_NUM_DPB_ENTRIES)
1430
1431#define V4L2_CID_STATELESS_H264_SLICE_PARAMS (V4L2_CID_CODEC_STATELESS_BASE + 6)
1432/**
1433 * struct v4l2_ctrl_h264_slice_params - H264 slice parameters
1434 *
1435 * This structure holds the H264 syntax elements that are specified
1436 * as non-invariant for the slices in a given frame.
1437 *
1438 * Slice invariant syntax elements are contained in struct
1439 * v4l2_ctrl_h264_decode_params. This is done to reduce the API surface
1440 * on frame-based decoders, where slice header parsing is done by the
1441 * hardware.
1442 *
1443 * Slice invariant syntax elements are specified in specification section
1444 * "7.4.3 Slice header semantics".
1445 *
1446 * Except where noted, the members on this struct match the slice header syntax.
1447 *
1448 * @header_bit_size: offset in bits to slice_data() from the beginning of this slice.
1449 * @first_mb_in_slice: see H264 specification.
1450 * @slice_type: see H264 specification.
1451 * @colour_plane_id: see H264 specification.
1452 * @redundant_pic_cnt: see H264 specification.
1453 * @cabac_init_idc: see H264 specification.
1454 * @slice_qp_delta: see H264 specification.
1455 * @slice_qs_delta: see H264 specification.
1456 * @disable_deblocking_filter_idc: see H264 specification.
1457 * @slice_alpha_c0_offset_div2: see H264 specification.
1458 * @slice_beta_offset_div2: see H264 specification.
1459 * @num_ref_idx_l0_active_minus1: see H264 specification.
1460 * @num_ref_idx_l1_active_minus1: see H264 specification.
1461 * @reserved: padding field. Should be zeroed by applications.
1462 * @ref_pic_list0: reference picture list 0 after applying the per-slice modifications.
1463 * @ref_pic_list1: reference picture list 1 after applying the per-slice modifications.
1464 * @flags: see V4L2_H264_SLICE_FLAG_{}.
1465 */
1466struct v4l2_ctrl_h264_slice_params {
1467 __u32 header_bit_size;
1468 __u32 first_mb_in_slice;
1469 __u8 slice_type;
1470 __u8 colour_plane_id;
1471 __u8 redundant_pic_cnt;
1472 __u8 cabac_init_idc;
1473 __s8 slice_qp_delta;
1474 __s8 slice_qs_delta;
1475 __u8 disable_deblocking_filter_idc;
1476 __s8 slice_alpha_c0_offset_div2;
1477 __s8 slice_beta_offset_div2;
1478 __u8 num_ref_idx_l0_active_minus1;
1479 __u8 num_ref_idx_l1_active_minus1;
1480
1481 __u8 reserved;
1482
1483 struct v4l2_h264_reference ref_pic_list0[V4L2_H264_REF_LIST_LEN];
1484 struct v4l2_h264_reference ref_pic_list1[V4L2_H264_REF_LIST_LEN];
1485
1486 __u32 flags;
1487};
1488
1489#define V4L2_H264_DPB_ENTRY_FLAG_VALID 0x01
1490#define V4L2_H264_DPB_ENTRY_FLAG_ACTIVE 0x02
1491#define V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM 0x04
1492#define V4L2_H264_DPB_ENTRY_FLAG_FIELD 0x08
1493
1494/**
1495 * struct v4l2_h264_dpb_entry - H264 decoded picture buffer entry
1496 *
1497 * @reference_ts: timestamp of the V4L2 capture buffer to use as reference.
1498 * The timestamp refers to the timestamp field in struct v4l2_buffer.
1499 * Use v4l2_timeval_to_ns() to convert the struct timeval to a __u64.
1500 * @pic_num: matches PicNum variable assigned during the reference
1501 * picture lists construction process.
1502 * @frame_num: frame identifier which matches frame_num syntax element.
1503 * @fields: indicates how the DPB entry is referenced. Valid values are
1504 * V4L2_H264_{}_REF.
1505 * @reserved: padding field. Should be zeroed by applications.
1506 * @top_field_order_cnt: matches TopFieldOrderCnt picture value.
1507 * @bottom_field_order_cnt: matches BottomFieldOrderCnt picture value.
1508 * Note that picture field is indicated by v4l2_buffer.field.
1509 * @flags: see V4L2_H264_DPB_ENTRY_FLAG_{}.
1510 */
1511struct v4l2_h264_dpb_entry {
1512 __u64 reference_ts;
1513 __u32 pic_num;
1514 __u16 frame_num;
1515 __u8 fields;
1516 __u8 reserved[5];
1517 __s32 top_field_order_cnt;
1518 __s32 bottom_field_order_cnt;
1519 __u32 flags;
1520};
1521
1522#define V4L2_H264_DECODE_PARAM_FLAG_IDR_PIC 0x01
1523#define V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC 0x02
1524#define V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD 0x04
1525
1526#define V4L2_CID_STATELESS_H264_DECODE_PARAMS (V4L2_CID_CODEC_STATELESS_BASE + 7)
1527/**
1528 * struct v4l2_ctrl_h264_decode_params - H264 decoding parameters
1529 *
1530 * @dpb: decoded picture buffer.
1531 * @nal_ref_idc: slice header syntax element.
1532 * @frame_num: slice header syntax element.
1533 * @top_field_order_cnt: matches TopFieldOrderCnt picture value.
1534 * @bottom_field_order_cnt: matches BottomFieldOrderCnt picture value.
1535 * Note that picture field is indicated by v4l2_buffer.field.
1536 * @idr_pic_id: slice header syntax element.
1537 * @pic_order_cnt_lsb: slice header syntax element.
1538 * @delta_pic_order_cnt_bottom: slice header syntax element.
1539 * @delta_pic_order_cnt0: slice header syntax element.
1540 * @delta_pic_order_cnt1: slice header syntax element.
1541 * @dec_ref_pic_marking_bit_size: size in bits of dec_ref_pic_marking()
1542 * syntax element.
1543 * @pic_order_cnt_bit_size: size in bits of pic order count syntax.
1544 * @slice_group_change_cycle: slice header syntax element.
1545 * @reserved: padding field. Should be zeroed by applications.
1546 * @flags: see V4L2_H264_DECODE_PARAM_FLAG_{}.
1547 */
1548struct v4l2_ctrl_h264_decode_params {
1549 struct v4l2_h264_dpb_entry dpb[V4L2_H264_NUM_DPB_ENTRIES];
1550 __u16 nal_ref_idc;
1551 __u16 frame_num;
1552 __s32 top_field_order_cnt;
1553 __s32 bottom_field_order_cnt;
1554 __u16 idr_pic_id;
1555 __u16 pic_order_cnt_lsb;
1556 __s32 delta_pic_order_cnt_bottom;
1557 __s32 delta_pic_order_cnt0;
1558 __s32 delta_pic_order_cnt1;
1559 __u32 dec_ref_pic_marking_bit_size;
1560 __u32 pic_order_cnt_bit_size;
1561 __u32 slice_group_change_cycle;
1562
1563 __u32 reserved;
1564 __u32 flags;
1565};
1566
1186 1567
1187/* MPEG-compression definitions kept for backwards compatibility */1568/* MPEG-compression definitions kept for backwards compatibility */
1188#ifndef __KERNEL__1569#ifndef __KERNEL__
include/uapi/linux/videodev2.h+6−0
@@ -1734,6 +1734,12 @@ struct v4l2_ext_control { · 1733 unmodified lines
1734 __u16 __user *p_u16;1734 __u16 __user *p_u16;
1735 __u32 __user *p_u32;1735 __u32 __user *p_u32;
1736 struct v4l2_area __user *p_area;1736 struct v4l2_area __user *p_area;
1737 struct v4l2_ctrl_h264_sps __user *p_h264_sps;
1738 struct v4l2_ctrl_h264_pps *p_h264_pps;
1739 struct v4l2_ctrl_h264_scaling_matrix __user *p_h264_scaling_matrix;
1740 struct v4l2_ctrl_h264_pred_weights __user *p_h264_pred_weights;
1741 struct v4l2_ctrl_h264_slice_params __user *p_h264_slice_params;
1742 struct v4l2_ctrl_h264_decode_params __user *p_h264_decode_params;
1737 void __user *ptr;1743 void __user *ptr;
1738 };1744 };
1739} __attribute__ ((packed));1745} __attribute__ ((packed));