1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
3 .. _codec-stateless-controls:
5 *********************************
6 Stateless Codec Control Reference
7 *********************************
9 The Stateless Codec control class is intended to support
10 stateless decoder and encoders (i.e. hardware accelerators).
12 These drivers are typically supported by the :ref:`stateless_decoder`,
13 and deal with parsed pixel formats such as V4L2_PIX_FMT_H264_SLICE.
15 Stateless Codec Control ID
16 ==========================
18 .. _codec-stateless-control-id:
20 ``V4L2_CID_CODEC_STATELESS_CLASS (class)``
21 The Stateless Codec class descriptor.
23 .. _v4l2-codec-stateless-h264:
25 ``V4L2_CID_STATELESS_H264_SPS (struct)``
26 Specifies the sequence parameter set (as extracted from the
27 bitstream) for the associated H264 slice data. This includes the
28 necessary parameters for configuring a stateless hardware decoding
29 pipeline for H264. The bitstream parameters are defined according
30 to :ref:`h264`, section 7.4.2.1.1 "Sequence Parameter Set Data
31 Semantics". For further documentation, refer to the above
32 specification, unless there is an explicit comment stating
35 .. c:type:: v4l2_ctrl_h264_sps
37 .. cssclass:: longtable
39 .. flat-table:: struct v4l2_ctrl_h264_sps
48 - ``constraint_set_flags``
49 - See :ref:`Sequence Parameter Set Constraints Set Flags <h264_sps_constraints_set_flags>`
54 - ``seq_parameter_set_id``
57 - ``chroma_format_idc``
60 - ``bit_depth_luma_minus8``
63 - ``bit_depth_chroma_minus8``
66 - ``log2_max_frame_num_minus4``
69 - ``pic_order_cnt_type``
72 - ``log2_max_pic_order_cnt_lsb_minus4``
75 - ``max_num_ref_frames``
78 - ``num_ref_frames_in_pic_order_cnt_cycle``
81 - ``offset_for_ref_frame[255]``
84 - ``offset_for_non_ref_pic``
87 - ``offset_for_top_to_bottom_field``
90 - ``pic_width_in_mbs_minus1``
93 - ``pic_height_in_map_units_minus1``
97 - See :ref:`Sequence Parameter Set Flags <h264_sps_flags>`
99 .. _h264_sps_constraints_set_flags:
101 ``Sequence Parameter Set Constraints Set Flags``
103 .. cssclass:: longtable
110 * - ``V4L2_H264_SPS_CONSTRAINT_SET0_FLAG``
113 * - ``V4L2_H264_SPS_CONSTRAINT_SET1_FLAG``
116 * - ``V4L2_H264_SPS_CONSTRAINT_SET2_FLAG``
119 * - ``V4L2_H264_SPS_CONSTRAINT_SET3_FLAG``
122 * - ``V4L2_H264_SPS_CONSTRAINT_SET4_FLAG``
125 * - ``V4L2_H264_SPS_CONSTRAINT_SET5_FLAG``
131 ``Sequence Parameter Set Flags``
133 .. cssclass:: longtable
140 * - ``V4L2_H264_SPS_FLAG_SEPARATE_COLOUR_PLANE``
143 * - ``V4L2_H264_SPS_FLAG_QPPRIME_Y_ZERO_TRANSFORM_BYPASS``
146 * - ``V4L2_H264_SPS_FLAG_DELTA_PIC_ORDER_ALWAYS_ZERO``
149 * - ``V4L2_H264_SPS_FLAG_GAPS_IN_FRAME_NUM_VALUE_ALLOWED``
152 * - ``V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY``
155 * - ``V4L2_H264_SPS_FLAG_MB_ADAPTIVE_FRAME_FIELD``
158 * - ``V4L2_H264_SPS_FLAG_DIRECT_8X8_INFERENCE``
162 ``V4L2_CID_STATELESS_H264_PPS (struct)``
163 Specifies the picture parameter set (as extracted from the
164 bitstream) for the associated H264 slice data. This includes the
165 necessary parameters for configuring a stateless hardware decoding
166 pipeline for H264. The bitstream parameters are defined according
167 to :ref:`h264`, section 7.4.2.2 "Picture Parameter Set RBSP
168 Semantics". For further documentation, refer to the above
169 specification, unless there is an explicit comment stating
172 .. c:type:: v4l2_ctrl_h264_pps
174 .. cssclass:: longtable
176 .. flat-table:: struct v4l2_ctrl_h264_pps
182 - ``pic_parameter_set_id``
185 - ``seq_parameter_set_id``
188 - ``num_slice_groups_minus1``
191 - ``num_ref_idx_l0_default_active_minus1``
194 - ``num_ref_idx_l1_default_active_minus1``
197 - ``weighted_bipred_idc``
200 - ``pic_init_qp_minus26``
203 - ``pic_init_qs_minus26``
206 - ``chroma_qp_index_offset``
209 - ``second_chroma_qp_index_offset``
213 - See :ref:`Picture Parameter Set Flags <h264_pps_flags>`
217 ``Picture Parameter Set Flags``
219 .. cssclass:: longtable
226 * - ``V4L2_H264_PPS_FLAG_ENTROPY_CODING_MODE``
229 * - ``V4L2_H264_PPS_FLAG_BOTTOM_FIELD_PIC_ORDER_IN_FRAME_PRESENT``
232 * - ``V4L2_H264_PPS_FLAG_WEIGHTED_PRED``
235 * - ``V4L2_H264_PPS_FLAG_DEBLOCKING_FILTER_CONTROL_PRESENT``
238 * - ``V4L2_H264_PPS_FLAG_CONSTRAINED_INTRA_PRED``
241 * - ``V4L2_H264_PPS_FLAG_REDUNDANT_PIC_CNT_PRESENT``
244 * - ``V4L2_H264_PPS_FLAG_TRANSFORM_8X8_MODE``
247 * - ``V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT``
249 - Indicates that ``V4L2_CID_STATELESS_H264_SCALING_MATRIX``
250 must be used for this picture.
252 ``V4L2_CID_STATELESS_H264_SCALING_MATRIX (struct)``
253 Specifies the scaling matrix (as extracted from the bitstream) for
254 the associated H264 slice data. The bitstream parameters are
255 defined according to :ref:`h264`, section 7.4.2.1.1.1 "Scaling
256 List Semantics". For further documentation, refer to the above
257 specification, unless there is an explicit comment stating
260 .. c:type:: v4l2_ctrl_h264_scaling_matrix
262 .. cssclass:: longtable
264 .. flat-table:: struct v4l2_ctrl_h264_scaling_matrix
270 - ``scaling_list_4x4[6][16]``
271 - Scaling matrix after applying the inverse scanning process.
272 Expected list order is Intra Y, Intra Cb, Intra Cr, Inter Y,
273 Inter Cb, Inter Cr. The values on each scaling list are
274 expected in raster scan order.
276 - ``scaling_list_8x8[6][64]``
277 - Scaling matrix after applying the inverse scanning process.
278 Expected list order is Intra Y, Inter Y, Intra Cb, Inter Cb,
279 Intra Cr, Inter Cr. The values on each scaling list are
280 expected in raster scan order.
282 ``V4L2_CID_STATELESS_H264_SLICE_PARAMS (struct)``
283 Specifies the slice parameters (as extracted from the bitstream)
284 for the associated H264 slice data. This includes the necessary
285 parameters for configuring a stateless hardware decoding pipeline
286 for H264. The bitstream parameters are defined according to
287 :ref:`h264`, section 7.4.3 "Slice Header Semantics". For further
288 documentation, refer to the above specification, unless there is
289 an explicit comment stating otherwise.
291 .. c:type:: v4l2_ctrl_h264_slice_params
293 .. cssclass:: longtable
295 .. flat-table:: struct v4l2_ctrl_h264_slice_params
301 - ``header_bit_size``
302 - Offset in bits to slice_data() from the beginning of this slice.
304 - ``first_mb_in_slice``
310 - ``colour_plane_id``
313 - ``redundant_pic_cnt``
325 - ``disable_deblocking_filter_idc``
328 - ``slice_alpha_c0_offset_div2``
331 - ``slice_beta_offset_div2``
334 - ``num_ref_idx_l0_active_minus1``
335 - If num_ref_idx_active_override_flag is not set, this field must be
336 set to the value of num_ref_idx_l0_default_active_minus1.
338 - ``num_ref_idx_l1_active_minus1``
339 - If num_ref_idx_active_override_flag is not set, this field must be
340 set to the value of num_ref_idx_l1_default_active_minus1.
343 - Applications and drivers must set this to zero.
344 * - struct :c:type:`v4l2_h264_reference`
345 - ``ref_pic_list0[32]``
346 - Reference picture list after applying the per-slice modifications
347 * - struct :c:type:`v4l2_h264_reference`
348 - ``ref_pic_list1[32]``
349 - Reference picture list after applying the per-slice modifications
352 - See :ref:`Slice Parameter Flags <h264_slice_flags>`
354 .. _h264_slice_flags:
356 ``Slice Parameter Set Flags``
358 .. cssclass:: longtable
365 * - ``V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED``
368 * - ``V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH``
372 ``V4L2_CID_STATELESS_H264_PRED_WEIGHTS (struct)``
373 Prediction weight table defined according to :ref:`h264`,
374 section 7.4.3.2 "Prediction Weight Table Semantics".
375 The prediction weight table must be passed by applications
376 under the conditions explained in section 7.3.3 "Slice header
379 .. c:type:: v4l2_ctrl_h264_pred_weights
381 .. cssclass:: longtable
383 .. flat-table:: struct v4l2_ctrl_h264_pred_weights
389 - ``luma_log2_weight_denom``
392 - ``chroma_log2_weight_denom``
394 * - struct :c:type:`v4l2_h264_weight_factors`
395 - ``weight_factors[2]``
396 - The weight factors at index 0 are the weight factors for the reference
397 list 0, the one at index 1 for the reference list 1.
399 .. c:type:: v4l2_h264_weight_factors
401 .. cssclass:: longtable
403 .. flat-table:: struct v4l2_h264_weight_factors
409 - ``luma_weight[32]``
412 - ``luma_offset[32]``
415 - ``chroma_weight[32][2]``
418 - ``chroma_offset[32][2]``
421 ``Picture Reference``
423 .. c:type:: v4l2_h264_reference
425 .. cssclass:: longtable
427 .. flat-table:: struct v4l2_h264_reference
434 - Specifies how the picture is referenced. See :ref:`Reference Fields <h264_ref_fields>`
437 - Index into the :c:type:`v4l2_ctrl_h264_decode_params`.dpb array.
443 .. cssclass:: longtable
450 * - ``V4L2_H264_TOP_FIELD_REF``
452 - The top field in field pair is used for short-term reference.
453 * - ``V4L2_H264_BOTTOM_FIELD_REF``
455 - The bottom field in field pair is used for short-term reference.
456 * - ``V4L2_H264_FRAME_REF``
458 - The frame (or the top/bottom fields, if it's a field pair)
459 is used for short-term reference.
461 ``V4L2_CID_STATELESS_H264_DECODE_PARAMS (struct)``
462 Specifies the decode parameters (as extracted from the bitstream)
463 for the associated H264 slice data. This includes the necessary
464 parameters for configuring a stateless hardware decoding pipeline
465 for H264. The bitstream parameters are defined according to
466 :ref:`h264`. For further documentation, refer to the above
467 specification, unless there is an explicit comment stating
470 .. c:type:: v4l2_ctrl_h264_decode_params
472 .. cssclass:: longtable
474 .. flat-table:: struct v4l2_ctrl_h264_decode_params
479 * - struct :c:type:`v4l2_h264_dpb_entry`
484 - NAL reference ID value coming from the NAL Unit header
489 - ``top_field_order_cnt``
490 - Picture Order Count for the coded top field
492 - ``bottom_field_order_cnt``
493 - Picture Order Count for the coded bottom field
498 - ``pic_order_cnt_lsb``
501 - ``delta_pic_order_cnt_bottom``
504 - ``delta_pic_order_cnt0``
507 - ``delta_pic_order_cnt1``
510 - ``dec_ref_pic_marking_bit_size``
511 - Size in bits of the dec_ref_pic_marking() syntax element.
513 - ``pic_order_cnt_bit_size``
514 - Combined size in bits of the picture order count related syntax
515 elements: pic_order_cnt_lsb, delta_pic_order_cnt_bottom,
516 delta_pic_order_cnt0, and delta_pic_order_cnt1.
518 - ``slice_group_change_cycle``
522 - Applications and drivers must set this to zero.
525 - See :ref:`Decode Parameters Flags <h264_decode_params_flags>`
527 .. _h264_decode_params_flags:
529 ``Decode Parameters Flags``
531 .. cssclass:: longtable
538 * - ``V4L2_H264_DECODE_PARAM_FLAG_IDR_PIC``
540 - That picture is an IDR picture
541 * - ``V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC``
544 * - ``V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD``
548 .. c:type:: v4l2_h264_dpb_entry
550 .. cssclass:: longtable
552 .. flat-table:: struct v4l2_h264_dpb_entry
559 - Timestamp of the V4L2 capture buffer to use as reference, used
560 with B-coded and P-coded frames. The timestamp refers to the
561 ``timestamp`` field in struct :c:type:`v4l2_buffer`. Use the
562 :c:func:`v4l2_timeval_to_ns()` function to convert the struct
563 :c:type:`timeval` in struct :c:type:`v4l2_buffer` to a __u64.
572 - Specifies how the DPB entry is referenced. See :ref:`Reference Fields <h264_ref_fields>`
575 - Applications and drivers must set this to zero.
577 - ``top_field_order_cnt``
580 - ``bottom_field_order_cnt``
584 - See :ref:`DPB Entry Flags <h264_dpb_flags>`
588 ``DPB Entries Flags``
590 .. cssclass:: longtable
597 * - ``V4L2_H264_DPB_ENTRY_FLAG_VALID``
599 - The DPB entry is valid (non-empty) and should be considered.
600 * - ``V4L2_H264_DPB_ENTRY_FLAG_ACTIVE``
602 - The DPB entry is used for reference.
603 * - ``V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM``
605 - The DPB entry is used for long-term reference.
606 * - ``V4L2_H264_DPB_ENTRY_FLAG_FIELD``
608 - The DPB entry is a single field or a complementary field pair.
610 ``V4L2_CID_STATELESS_H264_DECODE_MODE (enum)``
611 Specifies the decoding mode to use. Currently exposes slice-based and
612 frame-based decoding but new modes might be added later on.
613 This control is used as a modifier for V4L2_PIX_FMT_H264_SLICE
614 pixel format. Applications that support V4L2_PIX_FMT_H264_SLICE
615 are required to set this control in order to specify the decoding mode
616 that is expected for the buffer.
617 Drivers may expose a single or multiple decoding modes, depending
618 on what they can support.
620 .. c:type:: v4l2_stateless_h264_decode_mode
622 .. cssclass:: longtable
629 * - ``V4L2_STATELESS_H264_DECODE_MODE_SLICE_BASED``
631 - Decoding is done at the slice granularity.
632 The OUTPUT buffer must contain a single slice.
633 When this mode is selected, the ``V4L2_CID_STATELESS_H264_SLICE_PARAMS``
634 control shall be set. When multiple slices compose a frame,
635 use of ``V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF`` flag
637 * - ``V4L2_STATELESS_H264_DECODE_MODE_FRAME_BASED``
639 - Decoding is done at the frame granularity,
640 The OUTPUT buffer must contain all slices needed to decode the
641 frame. The OUTPUT buffer must also contain both fields.
642 This mode will be supported by devices that
643 parse the slice(s) header(s) in hardware. When this mode is
644 selected, the ``V4L2_CID_STATELESS_H264_SLICE_PARAMS``
645 control shall not be set.
647 ``V4L2_CID_STATELESS_H264_START_CODE (enum)``
648 Specifies the H264 slice start code expected for each slice.
649 This control is used as a modifier for V4L2_PIX_FMT_H264_SLICE
650 pixel format. Applications that support V4L2_PIX_FMT_H264_SLICE
651 are required to set this control in order to specify the start code
652 that is expected for the buffer.
653 Drivers may expose a single or multiple start codes, depending
654 on what they can support.
656 .. c:type:: v4l2_stateless_h264_start_code
658 .. cssclass:: longtable
665 * - ``V4L2_STATELESS_H264_START_CODE_NONE``
667 - Selecting this value specifies that H264 slices are passed
668 to the driver without any start code.
669 * - ``V4L2_STATELESS_H264_START_CODE_ANNEX_B``
671 - Selecting this value specifies that H264 slices are expected
672 to be prefixed by Annex B start codes. According to :ref:`h264`
673 valid start codes can be 3-bytes 0x000001 or 4-bytes 0x00000001.
676 .. _codec-stateless-fwht:
678 ``V4L2_CID_STATELESS_FWHT_PARAMS (struct)``
679 Specifies the FWHT (Fast Walsh Hadamard Transform) parameters (as extracted
680 from the bitstream) for the associated FWHT data. This includes the necessary
681 parameters for configuring a stateless hardware decoding pipeline for FWHT.
682 This codec is specific to the vicodec test driver.
684 .. c:type:: v4l2_ctrl_fwht_params
686 .. cssclass:: longtable
688 .. tabularcolumns:: |p{1.4cm}|p{4.3cm}|p{11.8cm}|
690 .. flat-table:: struct v4l2_ctrl_fwht_params
696 - ``backward_ref_ts``
697 - Timestamp of the V4L2 capture buffer to use as backward reference, used
698 with P-coded frames. The timestamp refers to the
699 ``timestamp`` field in struct :c:type:`v4l2_buffer`. Use the
700 :c:func:`v4l2_timeval_to_ns()` function to convert the struct
701 :c:type:`timeval` in struct :c:type:`v4l2_buffer` to a __u64.
704 - The version of the codec. Set to ``V4L2_FWHT_VERSION``.
707 - The width of the frame.
710 - The height of the frame.
713 - The flags of the frame, see :ref:`fwht-flags`.
716 - The colorspace of the frame, from enum :c:type:`v4l2_colorspace`.
719 - The transfer function, from enum :c:type:`v4l2_xfer_func`.
722 - The Y'CbCr encoding, from enum :c:type:`v4l2_ycbcr_encoding`.
725 - The quantization range, from enum :c:type:`v4l2_quantization`.
734 .. cssclass:: longtable
736 .. tabularcolumns:: |p{6.8cm}|p{2.4cm}|p{8.3cm}|
743 * - ``V4L2_FWHT_FL_IS_INTERLACED``
745 - Set if this is an interlaced format.
746 * - ``V4L2_FWHT_FL_IS_BOTTOM_FIRST``
748 - Set if this is a bottom-first (NTSC) interlaced format.
749 * - ``V4L2_FWHT_FL_IS_ALTERNATE``
751 - Set if each 'frame' contains just one field.
752 * - ``V4L2_FWHT_FL_IS_BOTTOM_FIELD``
754 - If V4L2_FWHT_FL_IS_ALTERNATE was set, then this is set if this 'frame' is the
755 bottom field, else it is the top field.
756 * - ``V4L2_FWHT_FL_LUMA_IS_UNCOMPRESSED``
758 - Set if the Y' (luma) plane is uncompressed.
759 * - ``V4L2_FWHT_FL_CB_IS_UNCOMPRESSED``
761 - Set if the Cb plane is uncompressed.
762 * - ``V4L2_FWHT_FL_CR_IS_UNCOMPRESSED``
764 - Set if the Cr plane is uncompressed.
765 * - ``V4L2_FWHT_FL_CHROMA_FULL_HEIGHT``
767 - Set if the chroma plane has the same height as the luma plane,
768 else the chroma plane is half the height of the luma plane.
769 * - ``V4L2_FWHT_FL_CHROMA_FULL_WIDTH``
771 - Set if the chroma plane has the same width as the luma plane,
772 else the chroma plane is half the width of the luma plane.
773 * - ``V4L2_FWHT_FL_ALPHA_IS_UNCOMPRESSED``
775 - Set if the alpha plane is uncompressed.
776 * - ``V4L2_FWHT_FL_I_FRAME``
778 - Set if this is an I-frame.
779 * - ``V4L2_FWHT_FL_COMPONENTS_NUM_MSK``
781 - The number of color components - 1.
782 * - ``V4L2_FWHT_FL_PIXENC_MSK``
784 - The mask for the pixel encoding.
785 * - ``V4L2_FWHT_FL_PIXENC_YUV``
787 - Set if the pixel encoding is YUV.
788 * - ``V4L2_FWHT_FL_PIXENC_RGB``
790 - Set if the pixel encoding is RGB.
791 * - ``V4L2_FWHT_FL_PIXENC_HSV``
793 - Set if the pixel encoding is HSV.