From: Hans Verkuil <hverkuil@xs4all.nl>
To: Philipp Zabel <p.zabel@pengutronix.de>,
Tomasz Figa <tfiga@chromium.org>,
linux-media@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Pawel Osciak" <posciak@chromium.org>,
"Alexandre Courbot" <acourbot@chromium.org>,
"Kamil Debski" <kamil@wypas.org>,
"Andrzej Hajda" <a.hajda@samsung.com>,
"Kyungmin Park" <kyungmin.park@samsung.com>,
"Jeongtae Park" <jtp.park@samsung.com>,
"Tiffany Lin (林慧珊)" <tiffany.lin@mediatek.com>,
"Andrew-CT Chen (陳智迪)" <andrew-ct.chen@mediatek.com>,
"Stanimir Varbanov" <stanimir.varbanov@linaro.org>,
"Todor Tomov" <todor.tomov@linaro.org>,
"Nicolas Dufresne" <nicolas@ndufresne.ca>,
"Paul Kocialkowski" <paul.kocialkowski@bootlin.com>,
"Laurent Pinchart" <laurent.pinchart@ideasonboard.com>,
dave.stevenson@raspberrypi.org,
"Ezequiel Garcia" <ezequiel@collabora.com>,
"Maxime Jourdan" <maxi.jourdan@wanadoo.fr>
Subject: Re: [PATCH v3 1/2] media: docs-rst: Document memory-to-memory video decoder interface
Date: Thu, 31 Jan 2019 14:19:20 +0100 [thread overview]
Message-ID: <6aa88094-068a-089d-2d52-3f9ade5a396c@xs4all.nl> (raw)
In-Reply-To: <1548938648.4585.3.camel@pengutronix.de>
On 1/31/19 1:44 PM, Philipp Zabel wrote:
> On Thu, 2019-01-31 at 13:30 +0100, Hans Verkuil wrote:
>> On 1/31/19 11:45 AM, Hans Verkuil wrote:
>>> On 1/24/19 11:04 AM, Tomasz Figa wrote:
>>>> Due to complexity of the video decoding process, the V4L2 drivers of
>>>> stateful decoder hardware require specific sequences of V4L2 API calls
>>>> to be followed. These include capability enumeration, initialization,
>>>> decoding, seek, pause, dynamic resolution change, drain and end of
>>>> stream.
>>>>
>>>> Specifics of the above have been discussed during Media Workshops at
>>>> LinuxCon Europe 2012 in Barcelona and then later Embedded Linux
>>>> Conference Europe 2014 in Düsseldorf. The de facto Codec API that
>>>> originated at those events was later implemented by the drivers we already
>>>> have merged in mainline, such as s5p-mfc or coda.
>>>>
>>>> The only thing missing was the real specification included as a part of
>>>> Linux Media documentation. Fix it now and document the decoder part of
>>>> the Codec API.
>>>>
>>>> Signed-off-by: Tomasz Figa <tfiga@chromium.org>
>>>> ---
>>>> Documentation/media/uapi/v4l/dev-decoder.rst | 1076 +++++++++++++++++
>>>> Documentation/media/uapi/v4l/dev-mem2mem.rst | 5 +
>>>> Documentation/media/uapi/v4l/pixfmt-v4l2.rst | 5 +
>>>> Documentation/media/uapi/v4l/v4l2.rst | 10 +-
>>>> .../media/uapi/v4l/vidioc-decoder-cmd.rst | 40 +-
>>>> Documentation/media/uapi/v4l/vidioc-g-fmt.rst | 14 +
>>>> 6 files changed, 1135 insertions(+), 15 deletions(-)
>>>> create mode 100644 Documentation/media/uapi/v4l/dev-decoder.rst
>>>>
>>>
>>> <snip>
>>>
>>>> +4. **This step only applies to coded formats that contain resolution information
>>>> + in the stream.** Continue queuing/dequeuing bitstream buffers to/from the
>>>> + ``OUTPUT`` queue via :c:func:`VIDIOC_QBUF` and :c:func:`VIDIOC_DQBUF`. The
>>>> + buffers will be processed and returned to the client in order, until
>>>> + required metadata to configure the ``CAPTURE`` queue are found. This is
>>>> + indicated by the decoder sending a ``V4L2_EVENT_SOURCE_CHANGE`` event with
>>>> + ``V4L2_EVENT_SRC_CH_RESOLUTION`` source change type.
>>>> +
>>>> + * It is not an error if the first buffer does not contain enough data for
>>>> + this to occur. Processing of the buffers will continue as long as more
>>>> + data is needed.
>>>> +
>>>> + * If data in a buffer that triggers the event is required to decode the
>>>> + first frame, it will not be returned to the client, until the
>>>> + initialization sequence completes and the frame is decoded.
>>>> +
>>>> + * If the client sets width and height of the ``OUTPUT`` format to 0,
>>>> + calling :c:func:`VIDIOC_G_FMT`, :c:func:`VIDIOC_S_FMT`,
>>>> + :c:func:`VIDIOC_TRY_FMT` or :c:func:`VIDIOC_REQBUFS` on the ``CAPTURE``
>>>> + queue will return the ``-EACCES`` error code, until the decoder
>>>> + configures ``CAPTURE`` format according to stream metadata.
>>>
>>> I think this should also include the G/S_SELECTION ioctls, right?
>>
>> I've started work on adding compliance tests for codecs to v4l2-compliance and
>> I quickly discovered that this 'EACCES' error code is not nice at all.
>>
>> The problem is that it is really inconsistent with V4L2 behavior: the basic
>> rule is that there always is a format defined, i.e. G_FMT will always return
>> a format.
>>
>> Suddenly returning an error is actually quite painful to handle because it is
>> a weird exception just for the capture queue of a stateful decoder if no
>> output resolution is known.
>>
>> Just writing that sentence is painful.
>>
>> Why not just return some default driver defined format? It will automatically
>> be updated once the decoder parsed the bitstream and knows the new resolution.
>>
>> It really is just the same behavior as with a resolution change.
>>
>> It is also perfectly fine to request buffers for the capture queue for that
>> default format. It's pointless, but not a bug.
>>
>> Unless I am missing something I strongly recommend changing this behavior.
>
> I just wrote the same in my reply to Nicolas, the CODA driver currently
> sets the capture queue width/height to the output queue's crop rectangle
> (rounded to macroblock size) without ever having seen the SPS.
And thinking about the initial 0x0 width/height for the output queue:
that too is an exception, although less of a problem than the EACCES behavior.
It should be fine for an application to set width/height to 0 when calling
S_FMT for the output queue of the decoder, but I would also prefer that it is
just replaced by the driver with some default resolution. It really doesn't
matter in practice, since you will wait for the SOURCE_CHANGE event regardless.
Only then do you start to configure the CAPTURE queue.
Using 0x0 and EACCES looks good on paper, but in the code it is a hassle and
I'm not convinced there is any benefit.
I like generic APIs and no where else do we ever return a 0 value for width
or height, except in this corner case. It's just awkward.
Regards,
Hans
next prev parent reply other threads:[~2019-01-31 13:19 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-24 10:04 [PATCH v3 0/2] Document memory-to-memory video codec interfaces Tomasz Figa
2019-01-24 10:04 ` [PATCH v3 1/2] media: docs-rst: Document memory-to-memory video decoder interface Tomasz Figa
2019-01-29 13:11 ` Hans Verkuil
2019-01-31 10:45 ` Hans Verkuil
2019-01-31 12:30 ` Hans Verkuil
2019-01-31 12:38 ` Hans Verkuil
2019-01-31 12:44 ` Philipp Zabel
2019-01-31 13:19 ` Hans Verkuil [this message]
2019-02-07 8:51 ` Tomasz Figa
2019-04-05 10:59 ` Philipp Zabel
2019-04-05 11:21 ` Hans Verkuil
2019-04-09 10:28 ` Tomasz Figa
2019-04-09 16:57 ` Philipp Zabel
2019-04-10 9:29 ` Hans Verkuil
2019-01-24 10:04 ` [PATCH v3 2/2] media: docs-rst: Document memory-to-memory video encoder interface Tomasz Figa
2019-01-29 13:52 ` Hans Verkuil
2019-03-14 13:57 ` Hans Verkuil
2019-04-05 8:12 ` Tomasz Figa
2019-04-05 10:03 ` Hans Verkuil
2019-04-08 9:23 ` Tomasz Figa
2019-04-08 11:11 ` Hans Verkuil
2019-04-09 9:35 ` Tomasz Figa
2019-04-10 8:50 ` Hans Verkuil
2019-04-10 16:05 ` Nicolas Dufresne
2019-04-15 8:56 ` Tomasz Figa
2019-04-15 12:30 ` Nicolas Dufresne
2019-04-05 5:53 ` Tomasz Figa
2019-04-05 7:09 ` Hans Verkuil
2019-03-21 10:10 ` Hans Verkuil
2019-04-08 6:59 ` Tomasz Figa
2019-04-08 7:43 ` Hans Verkuil
2019-04-08 9:35 ` Tomasz Figa
2019-03-25 13:12 ` Hans Verkuil
2019-03-25 16:33 ` Hans Verkuil
2019-04-08 8:40 ` Tomasz Figa
2019-04-08 8:36 ` Tomasz Figa
2019-04-08 8:43 ` Hans Verkuil
2019-04-09 7:11 ` Tomasz Figa
2019-04-09 9:37 ` Hans Verkuil
2019-04-09 9:43 ` Tomasz Figa
2019-05-22 8:43 ` Tomasz Figa
2019-05-22 8:51 ` Hans Verkuil
2019-05-22 14:16 ` Michael Tretter
2019-04-30 17:34 ` Michael Tretter
2019-05-14 8:12 ` Tomasz Figa
2019-05-16 8:37 ` Michael Tretter
2019-05-16 8:48 ` Tomasz Figa
2019-01-24 10:38 ` [PATCH v3 0/2] Document memory-to-memory video codec interfaces Hans Verkuil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6aa88094-068a-089d-2d52-3f9ade5a396c@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=a.hajda@samsung.com \
--cc=acourbot@chromium.org \
--cc=andrew-ct.chen@mediatek.com \
--cc=dave.stevenson@raspberrypi.org \
--cc=ezequiel@collabora.com \
--cc=jtp.park@samsung.com \
--cc=kamil@wypas.org \
--cc=kyungmin.park@samsung.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=maxi.jourdan@wanadoo.fr \
--cc=mchehab@kernel.org \
--cc=nicolas@ndufresne.ca \
--cc=p.zabel@pengutronix.de \
--cc=paul.kocialkowski@bootlin.com \
--cc=posciak@chromium.org \
--cc=stanimir.varbanov@linaro.org \
--cc=tfiga@chromium.org \
--cc=tiffany.lin@mediatek.com \
--cc=todor.tomov@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).