18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
28c2ecf20Sopenharmony_ci.. c:namespace:: V4L
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci.. _VIDIOC_G_ENC_INDEX:
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci************************
78c2ecf20Sopenharmony_ciioctl VIDIOC_G_ENC_INDEX
88c2ecf20Sopenharmony_ci************************
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciName
118c2ecf20Sopenharmony_ci====
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ciVIDIOC_G_ENC_INDEX - Get meta data about a compressed video stream
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ciSynopsis
168c2ecf20Sopenharmony_ci========
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci.. c:macro:: VIDIOC_G_ENC_INDEX
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci``int ioctl(int fd, VIDIOC_G_ENC_INDEX, struct v4l2_enc_idx *argp)``
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ciArguments
238c2ecf20Sopenharmony_ci=========
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci``fd``
268c2ecf20Sopenharmony_ci    File descriptor returned by :c:func:`open()`.
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci``argp``
298c2ecf20Sopenharmony_ci    Pointer to struct :c:type:`v4l2_enc_idx`.
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ciDescription
328c2ecf20Sopenharmony_ci===========
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ciThe :ref:`VIDIOC_G_ENC_INDEX <VIDIOC_G_ENC_INDEX>` ioctl provides meta data about a compressed
358c2ecf20Sopenharmony_civideo stream the same or another application currently reads from the
368c2ecf20Sopenharmony_cidriver, which is useful for random access into the stream without
378c2ecf20Sopenharmony_cidecoding it.
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ciTo read the data applications must call :ref:`VIDIOC_G_ENC_INDEX <VIDIOC_G_ENC_INDEX>` with a
408c2ecf20Sopenharmony_cipointer to a struct :c:type:`v4l2_enc_idx`. On success
418c2ecf20Sopenharmony_cithe driver fills the ``entry`` array, stores the number of elements
428c2ecf20Sopenharmony_ciwritten in the ``entries`` field, and initializes the ``entries_cap``
438c2ecf20Sopenharmony_cifield.
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ciEach element of the ``entry`` array contains meta data about one
468c2ecf20Sopenharmony_cipicture. A :ref:`VIDIOC_G_ENC_INDEX <VIDIOC_G_ENC_INDEX>` call reads up to
478c2ecf20Sopenharmony_ci``V4L2_ENC_IDX_ENTRIES`` entries from a driver buffer, which can hold up
488c2ecf20Sopenharmony_cito ``entries_cap`` entries. This number can be lower or higher than
498c2ecf20Sopenharmony_ci``V4L2_ENC_IDX_ENTRIES``, but not zero. When the application fails to
508c2ecf20Sopenharmony_ciread the meta data in time the oldest entries will be lost. When the
518c2ecf20Sopenharmony_cibuffer is empty or no capturing/encoding is in progress, ``entries``
528c2ecf20Sopenharmony_ciwill be zero.
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ciCurrently this ioctl is only defined for MPEG-2 program streams and
558c2ecf20Sopenharmony_civideo elementary streams.
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{3.8cm}|p{5.6cm}|p{8.1cm}|
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci.. c:type:: v4l2_enc_idx
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci.. flat-table:: struct v4l2_enc_idx
628c2ecf20Sopenharmony_ci    :header-rows:  0
638c2ecf20Sopenharmony_ci    :stub-columns: 0
648c2ecf20Sopenharmony_ci    :widths:       1 3 8
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci    * - __u32
678c2ecf20Sopenharmony_ci      - ``entries``
688c2ecf20Sopenharmony_ci      - The number of entries the driver stored in the ``entry`` array.
698c2ecf20Sopenharmony_ci    * - __u32
708c2ecf20Sopenharmony_ci      - ``entries_cap``
718c2ecf20Sopenharmony_ci      - The number of entries the driver can buffer. Must be greater than
728c2ecf20Sopenharmony_ci	zero.
738c2ecf20Sopenharmony_ci    * - __u32
748c2ecf20Sopenharmony_ci      - ``reserved``\ [4]
758c2ecf20Sopenharmony_ci      - Reserved for future extensions. Drivers must set the
768c2ecf20Sopenharmony_ci	array to zero.
778c2ecf20Sopenharmony_ci    * - struct :c:type:`v4l2_enc_idx_entry`
788c2ecf20Sopenharmony_ci      - ``entry``\ [``V4L2_ENC_IDX_ENTRIES``]
798c2ecf20Sopenharmony_ci      - Meta data about a compressed video stream. Each element of the
808c2ecf20Sopenharmony_ci	array corresponds to one picture, sorted in ascending order by
818c2ecf20Sopenharmony_ci	their ``offset``.
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci.. c:type:: v4l2_enc_idx_entry
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci.. flat-table:: struct v4l2_enc_idx_entry
898c2ecf20Sopenharmony_ci    :header-rows:  0
908c2ecf20Sopenharmony_ci    :stub-columns: 0
918c2ecf20Sopenharmony_ci    :widths:       1 1 2
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci    * - __u64
948c2ecf20Sopenharmony_ci      - ``offset``
958c2ecf20Sopenharmony_ci      - The offset in bytes from the beginning of the compressed video
968c2ecf20Sopenharmony_ci	stream to the beginning of this picture, that is a *PES packet
978c2ecf20Sopenharmony_ci	header* as defined in :ref:`mpeg2part1` or a *picture header* as
988c2ecf20Sopenharmony_ci	defined in :ref:`mpeg2part2`. When the encoder is stopped, the
998c2ecf20Sopenharmony_ci	driver resets the offset to zero.
1008c2ecf20Sopenharmony_ci    * - __u64
1018c2ecf20Sopenharmony_ci      - ``pts``
1028c2ecf20Sopenharmony_ci      - The 33 bit *Presentation Time Stamp* of this picture as defined in
1038c2ecf20Sopenharmony_ci	:ref:`mpeg2part1`.
1048c2ecf20Sopenharmony_ci    * - __u32
1058c2ecf20Sopenharmony_ci      - ``length``
1068c2ecf20Sopenharmony_ci      - The length of this picture in bytes.
1078c2ecf20Sopenharmony_ci    * - __u32
1088c2ecf20Sopenharmony_ci      - ``flags``
1098c2ecf20Sopenharmony_ci      - Flags containing the coding type of this picture, see
1108c2ecf20Sopenharmony_ci	:ref:`enc-idx-flags`.
1118c2ecf20Sopenharmony_ci    * - __u32
1128c2ecf20Sopenharmony_ci      - ``reserved``\ [2]
1138c2ecf20Sopenharmony_ci      - Reserved for future extensions. Drivers must set the array to
1148c2ecf20Sopenharmony_ci	zero.
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci.. _enc-idx-flags:
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci.. flat-table:: Index Entry Flags
1218c2ecf20Sopenharmony_ci    :header-rows:  0
1228c2ecf20Sopenharmony_ci    :stub-columns: 0
1238c2ecf20Sopenharmony_ci    :widths:       3 1 4
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci    * - ``V4L2_ENC_IDX_FRAME_I``
1268c2ecf20Sopenharmony_ci      - 0x00
1278c2ecf20Sopenharmony_ci      - This is an Intra-coded picture.
1288c2ecf20Sopenharmony_ci    * - ``V4L2_ENC_IDX_FRAME_P``
1298c2ecf20Sopenharmony_ci      - 0x01
1308c2ecf20Sopenharmony_ci      - This is a Predictive-coded picture.
1318c2ecf20Sopenharmony_ci    * - ``V4L2_ENC_IDX_FRAME_B``
1328c2ecf20Sopenharmony_ci      - 0x02
1338c2ecf20Sopenharmony_ci      - This is a Bidirectionally predictive-coded picture.
1348c2ecf20Sopenharmony_ci    * - ``V4L2_ENC_IDX_FRAME_MASK``
1358c2ecf20Sopenharmony_ci      - 0x0F
1368c2ecf20Sopenharmony_ci      - *AND* the flags field with this mask to obtain the picture coding
1378c2ecf20Sopenharmony_ci	type.
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ciReturn Value
1408c2ecf20Sopenharmony_ci============
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set
1438c2ecf20Sopenharmony_ciappropriately. The generic error codes are described at the
1448c2ecf20Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter.
145