Skip to content

Commit

Permalink
media: docs: dev-decoder: add restrictions about CAPTURE buffers
Browse files Browse the repository at this point in the history
CAPTURE buffers might be read by the hardware after they are dequeued,
which goes against the general idea that userspace has full control over
dequeued buffers. Explain why and document the restrictions that this
implies for userspace.

Signed-off-by: Alexandre Courbot <[email protected]>
Acked-by: Tomasz Figa <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
Gnurou authored and mchehab committed Nov 30, 2021
1 parent ef054e3 commit 4cfe98e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Documentation/userspace-api/media/v4l/dev-decoder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,23 @@ available to dequeue. Specifically:
buffers are out-of-order compared to the ``OUTPUT`` buffers): ``CAPTURE``
timestamps will not retain the order of ``OUTPUT`` timestamps.

.. note::

The backing memory of ``CAPTURE`` buffers that are used as reference frames
by the stream may be read by the hardware even after they are dequeued.
Consequently, the client should avoid writing into this memory while the
``CAPTURE`` queue is streaming. Failure to observe this may result in
corruption of decoded frames.

Similarly, when using a memory type other than ``V4L2_MEMORY_MMAP``, the
client should make sure that each ``CAPTURE`` buffer is always queued with
the same backing memory for as long as the ``CAPTURE`` queue is streaming.
The reason for this is that V4L2 buffer indices can be used by drivers to
identify frames. Thus, if the backing memory of a reference frame is
submitted under a different buffer ID, the driver may misidentify it and
decode a new frame into it while it is still in use, resulting in corruption
of the following frames.

During the decoding, the decoder may initiate one of the special sequences, as
listed below. The sequences will result in the decoder returning all the
``CAPTURE`` buffers that originated from all the ``OUTPUT`` buffers processed
Expand Down

0 comments on commit 4cfe98e

Please sign in to comment.