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