^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) .. c:namespace:: V4L
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) .. _VIDIOC_G_ENC_INDEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) ************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) ioctl VIDIOC_G_ENC_INDEX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) ************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) ====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) VIDIOC_G_ENC_INDEX - Get meta data about a compressed video stream
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) Synopsis
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) .. c:macro:: VIDIOC_G_ENC_INDEX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) ``int ioctl(int fd, VIDIOC_G_ENC_INDEX, struct v4l2_enc_idx *argp)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) Arguments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) =========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) ``fd``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) File descriptor returned by :c:func:`open()`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) ``argp``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) Pointer to struct :c:type:`v4l2_enc_idx`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) The :ref:`VIDIOC_G_ENC_INDEX <VIDIOC_G_ENC_INDEX>` ioctl provides meta data about a compressed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) video stream the same or another application currently reads from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) driver, which is useful for random access into the stream without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) decoding it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) To read the data applications must call :ref:`VIDIOC_G_ENC_INDEX <VIDIOC_G_ENC_INDEX>` with a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) pointer to a struct :c:type:`v4l2_enc_idx`. On success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) the driver fills the ``entry`` array, stores the number of elements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) written in the ``entries`` field, and initializes the ``entries_cap``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) Each element of the ``entry`` array contains meta data about one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) picture. A :ref:`VIDIOC_G_ENC_INDEX <VIDIOC_G_ENC_INDEX>` call reads up to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) ``V4L2_ENC_IDX_ENTRIES`` entries from a driver buffer, which can hold up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) to ``entries_cap`` entries. This number can be lower or higher than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) ``V4L2_ENC_IDX_ENTRIES``, but not zero. When the application fails to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) read the meta data in time the oldest entries will be lost. When the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) buffer is empty or no capturing/encoding is in progress, ``entries``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) will be zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) Currently this ioctl is only defined for MPEG-2 program streams and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) video elementary streams.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) .. tabularcolumns:: |p{3.8cm}|p{5.6cm}|p{8.1cm}|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) .. c:type:: v4l2_enc_idx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) .. flat-table:: struct v4l2_enc_idx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) :header-rows: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) :stub-columns: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) :widths: 1 3 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) - ``entries``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) - The number of entries the driver stored in the ``entry`` array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) - ``entries_cap``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) - The number of entries the driver can buffer. Must be greater than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) - ``reserved``\ [4]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) - Reserved for future extensions. Drivers must set the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) array to zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * - struct :c:type:`v4l2_enc_idx_entry`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) - ``entry``\ [``V4L2_ENC_IDX_ENTRIES``]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) - Meta data about a compressed video stream. Each element of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) array corresponds to one picture, sorted in ascending order by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) their ``offset``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) .. c:type:: v4l2_enc_idx_entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) .. flat-table:: struct v4l2_enc_idx_entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) :header-rows: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) :stub-columns: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) :widths: 1 1 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * - __u64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) - ``offset``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) - The offset in bytes from the beginning of the compressed video
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) stream to the beginning of this picture, that is a *PES packet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) header* as defined in :ref:`mpeg2part1` or a *picture header* as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) defined in :ref:`mpeg2part2`. When the encoder is stopped, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) driver resets the offset to zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * - __u64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) - ``pts``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) - The 33 bit *Presentation Time Stamp* of this picture as defined in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) :ref:`mpeg2part1`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) - ``length``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) - The length of this picture in bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) - ``flags``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) - Flags containing the coding type of this picture, see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) :ref:`enc-idx-flags`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) - ``reserved``\ [2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) - Reserved for future extensions. Drivers must set the array to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) .. _enc-idx-flags:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) .. flat-table:: Index Entry Flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) :header-rows: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) :stub-columns: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) :widths: 3 1 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) * - ``V4L2_ENC_IDX_FRAME_I``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) - 0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) - This is an Intra-coded picture.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * - ``V4L2_ENC_IDX_FRAME_P``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) - 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) - This is a Predictive-coded picture.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * - ``V4L2_ENC_IDX_FRAME_B``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) - 0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) - This is a Bidirectionally predictive-coded picture.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * - ``V4L2_ENC_IDX_FRAME_MASK``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) - 0x0F
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) - *AND* the flags field with this mask to obtain the picture coding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) Return Value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) On success 0 is returned, on error -1 and the ``errno`` variable is set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) appropriately. The generic error codes are described at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) :ref:`Generic Error Codes <gen-errors>` chapter.