162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
262306a36Sopenharmony_ci.. c:namespace:: V4L
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci.. _VIDIOC_G_ENC_INDEX:
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci************************
762306a36Sopenharmony_ciioctl VIDIOC_G_ENC_INDEX
862306a36Sopenharmony_ci************************
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciName
1162306a36Sopenharmony_ci====
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciVIDIOC_G_ENC_INDEX - Get meta data about a compressed video stream
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ciSynopsis
1662306a36Sopenharmony_ci========
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci.. c:macro:: VIDIOC_G_ENC_INDEX
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_G_ENC_INDEX, struct v4l2_enc_idx *argp)``
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciArguments
2362306a36Sopenharmony_ci=========
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci``fd``
2662306a36Sopenharmony_ci    File descriptor returned by :c:func:`open()`.
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci``argp``
2962306a36Sopenharmony_ci    Pointer to struct :c:type:`v4l2_enc_idx`.
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ciDescription
3262306a36Sopenharmony_ci===========
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ciThe :ref:`VIDIOC_G_ENC_INDEX <VIDIOC_G_ENC_INDEX>` ioctl provides meta data about a compressed
3562306a36Sopenharmony_civideo stream the same or another application currently reads from the
3662306a36Sopenharmony_cidriver, which is useful for random access into the stream without
3762306a36Sopenharmony_cidecoding it.
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ciTo read the data applications must call :ref:`VIDIOC_G_ENC_INDEX <VIDIOC_G_ENC_INDEX>` with a
4062306a36Sopenharmony_cipointer to a struct :c:type:`v4l2_enc_idx`. On success
4162306a36Sopenharmony_cithe driver fills the ``entry`` array, stores the number of elements
4262306a36Sopenharmony_ciwritten in the ``entries`` field, and initializes the ``entries_cap``
4362306a36Sopenharmony_cifield.
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ciEach element of the ``entry`` array contains meta data about one
4662306a36Sopenharmony_cipicture. A :ref:`VIDIOC_G_ENC_INDEX <VIDIOC_G_ENC_INDEX>` call reads up to
4762306a36Sopenharmony_ci``V4L2_ENC_IDX_ENTRIES`` entries from a driver buffer, which can hold up
4862306a36Sopenharmony_cito ``entries_cap`` entries. This number can be lower or higher than
4962306a36Sopenharmony_ci``V4L2_ENC_IDX_ENTRIES``, but not zero. When the application fails to
5062306a36Sopenharmony_ciread the meta data in time the oldest entries will be lost. When the
5162306a36Sopenharmony_cibuffer is empty or no capturing/encoding is in progress, ``entries``
5262306a36Sopenharmony_ciwill be zero.
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ciCurrently this ioctl is only defined for MPEG-2 program streams and
5562306a36Sopenharmony_civideo elementary streams.
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci.. tabularcolumns:: |p{4.2cm}|p{6.2cm}|p{6.9cm}|
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci.. c:type:: v4l2_enc_idx
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci.. flat-table:: struct v4l2_enc_idx
6262306a36Sopenharmony_ci    :header-rows:  0
6362306a36Sopenharmony_ci    :stub-columns: 0
6462306a36Sopenharmony_ci    :widths:       1 3 8
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci    * - __u32
6762306a36Sopenharmony_ci      - ``entries``
6862306a36Sopenharmony_ci      - The number of entries the driver stored in the ``entry`` array.
6962306a36Sopenharmony_ci    * - __u32
7062306a36Sopenharmony_ci      - ``entries_cap``
7162306a36Sopenharmony_ci      - The number of entries the driver can buffer. Must be greater than
7262306a36Sopenharmony_ci	zero.
7362306a36Sopenharmony_ci    * - __u32
7462306a36Sopenharmony_ci      - ``reserved``\ [4]
7562306a36Sopenharmony_ci      - Reserved for future extensions. Drivers must set the
7662306a36Sopenharmony_ci	array to zero.
7762306a36Sopenharmony_ci    * - struct :c:type:`v4l2_enc_idx_entry`
7862306a36Sopenharmony_ci      - ``entry``\ [``V4L2_ENC_IDX_ENTRIES``]
7962306a36Sopenharmony_ci      - Meta data about a compressed video stream. Each element of the
8062306a36Sopenharmony_ci	array corresponds to one picture, sorted in ascending order by
8162306a36Sopenharmony_ci	their ``offset``.
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ci.. c:type:: v4l2_enc_idx_entry
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci.. flat-table:: struct v4l2_enc_idx_entry
8962306a36Sopenharmony_ci    :header-rows:  0
9062306a36Sopenharmony_ci    :stub-columns: 0
9162306a36Sopenharmony_ci    :widths:       1 1 2
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci    * - __u64
9462306a36Sopenharmony_ci      - ``offset``
9562306a36Sopenharmony_ci      - The offset in bytes from the beginning of the compressed video
9662306a36Sopenharmony_ci	stream to the beginning of this picture, that is a *PES packet
9762306a36Sopenharmony_ci	header* as defined in :ref:`mpeg2part1` or a *picture header* as
9862306a36Sopenharmony_ci	defined in :ref:`mpeg2part2`. When the encoder is stopped, the
9962306a36Sopenharmony_ci	driver resets the offset to zero.
10062306a36Sopenharmony_ci    * - __u64
10162306a36Sopenharmony_ci      - ``pts``
10262306a36Sopenharmony_ci      - The 33 bit *Presentation Time Stamp* of this picture as defined in
10362306a36Sopenharmony_ci	:ref:`mpeg2part1`.
10462306a36Sopenharmony_ci    * - __u32
10562306a36Sopenharmony_ci      - ``length``
10662306a36Sopenharmony_ci      - The length of this picture in bytes.
10762306a36Sopenharmony_ci    * - __u32
10862306a36Sopenharmony_ci      - ``flags``
10962306a36Sopenharmony_ci      - Flags containing the coding type of this picture, see
11062306a36Sopenharmony_ci	:ref:`enc-idx-flags`.
11162306a36Sopenharmony_ci    * - __u32
11262306a36Sopenharmony_ci      - ``reserved``\ [2]
11362306a36Sopenharmony_ci      - Reserved for future extensions. Drivers must set the array to
11462306a36Sopenharmony_ci	zero.
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_ci.. _enc-idx-flags:
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci.. flat-table:: Index Entry Flags
12162306a36Sopenharmony_ci    :header-rows:  0
12262306a36Sopenharmony_ci    :stub-columns: 0
12362306a36Sopenharmony_ci    :widths:       3 1 4
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ci    * - ``V4L2_ENC_IDX_FRAME_I``
12662306a36Sopenharmony_ci      - 0x00
12762306a36Sopenharmony_ci      - This is an Intra-coded picture.
12862306a36Sopenharmony_ci    * - ``V4L2_ENC_IDX_FRAME_P``
12962306a36Sopenharmony_ci      - 0x01
13062306a36Sopenharmony_ci      - This is a Predictive-coded picture.
13162306a36Sopenharmony_ci    * - ``V4L2_ENC_IDX_FRAME_B``
13262306a36Sopenharmony_ci      - 0x02
13362306a36Sopenharmony_ci      - This is a Bidirectionally predictive-coded picture.
13462306a36Sopenharmony_ci    * - ``V4L2_ENC_IDX_FRAME_MASK``
13562306a36Sopenharmony_ci      - 0x0F
13662306a36Sopenharmony_ci      - *AND* the flags field with this mask to obtain the picture coding
13762306a36Sopenharmony_ci	type.
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ciReturn Value
14062306a36Sopenharmony_ci============
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set
14362306a36Sopenharmony_ciappropriately. The generic error codes are described at the
14462306a36Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter.
145