Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1713436imu; Thu, 24 Jan 2019 00:08:08 -0800 (PST) X-Google-Smtp-Source: ALg8bN5cEc1lrDCLoB8qZe+Z6vul63kAlTpvC+vq22hWJf7E+cMTTsFmycAR/MbeGx9O+oSx/SQE X-Received: by 2002:a62:870e:: with SMTP id i14mr5607805pfe.41.1548317288016; Thu, 24 Jan 2019 00:08:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548317287; cv=none; d=google.com; s=arc-20160816; b=IMDPsZ04r+Nyqvy8GNn3wOVjD1F3hXHN0o9uUYRHWV07/65HSQa2xp97YMm3WU83Lx OLgi3Hrk2n8zfjNbU3rm4D24JUyUodNMLEESQHI3uLf99Qvka75q1HAvvdYCX63cl9ba +ZEgmbKgcBBEsxb4/SHTEPWAqP6x/w34rezFIKTW7PM4qsMSm0bp5IVTPdvf9JKoCzG1 g081D0bLshM4MXu5N4KBaZ9yUh0+yGf5eoGZKti6i+lNE4HfKyIKGEV5S2gl8aii1w+4 YUi/SAQZz3pZeP6wbmMh4pKeVaeItYMtjkVH3wU3a77v2+cCSSye5vfUq/X/YXxHJkop mePQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=upjwkUlLSlOg1yEbM64EKv2x0NREMtcXypyfUS73NsE=; b=sNITCYW6gVhX3JIqyM9cBg0McoxKyzpY2DTMjvuGORgByXu9je62og0Q/79J1JEs9M qUNvIJMRglTKSn6vRCluvzagdd0bEV7IWJHuIedT3Sq7gDIhoGHKrXIp2KPvkcapa2xy cHnlGClepzmV65a/xTedN7CZJe22roZbCu3QqI7CxmZYGRVwnuglxBKM80H8Y36Dupnl w82Eo83gJq9uaDPYunBO2TZuWg5r+cV9SFxhCTaOfrI5PyEI4AxkDga/I/gLIPQVKPiL 1DJU2+3XPd3ImLPPFnCp7u6KNtpxdvBJoE+ECN5uNGs/K6ZLxwTBvbE+8hGWKXlQpjC4 Q2eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=IrfGOP86; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g31si18839287pld.358.2019.01.24.00.07.52; Thu, 24 Jan 2019 00:08:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=IrfGOP86; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726212AbfAXIHr (ORCPT + 99 others); Thu, 24 Jan 2019 03:07:47 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:40446 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726045AbfAXIHr (ORCPT ); Thu, 24 Jan 2019 03:07:47 -0500 Received: by mail-ot1-f65.google.com with SMTP id s5so4471029oth.7 for ; Thu, 24 Jan 2019 00:07:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=upjwkUlLSlOg1yEbM64EKv2x0NREMtcXypyfUS73NsE=; b=IrfGOP86HeJ1eDk9qKM3mqgTTEjKl/bcVktZ3Ij5cTafSnxGyWyfHMqa9u+TbQiWTI a46fGKrLCUhFx93F2P0nhjM9/Vv8fDO+ZjQydfBCA0dgaUuaX8vF4aEPCkC2/o46bOM0 nKyy7bEJ6x32azUf6d22BeB1iYQWDduokaJ/o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=upjwkUlLSlOg1yEbM64EKv2x0NREMtcXypyfUS73NsE=; b=TlXHOVfol7dsZG9sycqKYaFuGsaiTAUAvCqw4QKQbqll+1Wq4PrxbeT5HR+x4IXdug G+oZjygDup8zS8yWcM9n7YPhIMsPpZssvOhdIuZiCX7gRqXI5pYGSHFGO/FG+viuc0lQ gnGArLG3mkZcRuo/uaq/jOq8uSHYDgK/RGXq8hsQvn46RDcVOVh+BUiN+TuaKOcUOQVo 401zcBYwTLsYwP80mKpazfQEnUgIIz0KLqM+ZqDLStmHqEO8/YzTaTa+ICO7v6oZTV27 j9fKGi4jcMbpxJv1mz+BrXer30T3F6Vu/IlYiuZDrz++NEILipMbLeFvttvTrejelJNR yUSQ== X-Gm-Message-State: AJcUukf75jgcRX3yFMwgNbTm0q+CWLLIrifUL+yXpSuYK3KL3aQZy5cd PKXmWmhPrQU5YBIDg3ijRUCzEsAidJA= X-Received: by 2002:a9d:7059:: with SMTP id x25mr3877921otj.35.1548317265016; Thu, 24 Jan 2019 00:07:45 -0800 (PST) Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com. [209.85.167.181]) by smtp.gmail.com with ESMTPSA id f76sm11371360oih.58.2019.01.24.00.07.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 00:07:43 -0800 (PST) Received: by mail-oi1-f181.google.com with SMTP id j21so4129037oii.8 for ; Thu, 24 Jan 2019 00:07:43 -0800 (PST) X-Received: by 2002:aca:ea57:: with SMTP id i84mr496281oih.346.1548317263191; Thu, 24 Jan 2019 00:07:43 -0800 (PST) MIME-Version: 1.0 References: <20181205100121.181765-1-acourbot@chromium.org> <42a24867b3b4506cdb7e738eec5b2b8316f8ca19.camel@bootlin.com> In-Reply-To: <42a24867b3b4506cdb7e738eec5b2b8316f8ca19.camel@bootlin.com> From: Tomasz Figa Date: Thu, 24 Jan 2019 17:07:32 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] media: docs-rst: Document m2m stateless video decoder interface To: Paul Kocialkowski Cc: Alexandre Courbot , Mauro Carvalho Chehab , Hans Verkuil , Pawel Osciak , Linux Media Mailing List , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 23, 2019 at 7:42 PM Paul Kocialkowski wrote: > > Hi Alex, > > On Wed, 2019-01-23 at 18:43 +0900, Alexandre Courbot wrote: > > On Tue, Jan 22, 2019 at 7:10 PM Paul Kocialkowski > > wrote: > > > Hi, > > > > > > On Tue, 2019-01-22 at 17:19 +0900, Tomasz Figa wrote: > > > > Hi Paul, > > > > > > > > On Fri, Dec 7, 2018 at 5:30 PM Paul Kocialkowski > > > > wrote: > > > > > Hi, > > > > > > > > > > Thanks for this new version! I only have one comment left, see below. > > > > > > > > > > On Wed, 2018-12-05 at 19:01 +0900, Alexandre Courbot wrote: > > > > > > Documents the protocol that user-space should follow when > > > > > > communicating with stateless video decoders. > > > > > > > > > > > > The stateless video decoding API makes use of the new request and tags > > > > > > APIs. While it has been implemented with the Cedrus driver so far, it > > > > > > should probably still be considered staging for a short while. > > > > > > > > > > > > Signed-off-by: Alexandre Courbot > > > > > > --- > > > > > > Removing the RFC flag this time. Changes since RFCv3: > > > > > > > > > > > > * Included Tomasz and Hans feedback, > > > > > > * Expanded the decoding section to better describe the use of requests, > > > > > > * Use the tags API. > > > > > > > > > > > > Documentation/media/uapi/v4l/dev-codec.rst | 5 + > > > > > > .../media/uapi/v4l/dev-stateless-decoder.rst | 399 ++++++++++++++++++ > > > > > > 2 files changed, 404 insertions(+) > > > > > > create mode 100644 Documentation/media/uapi/v4l/dev-stateless-decoder.rst > > > > > > > > > > > > diff --git a/Documentation/media/uapi/v4l/dev-codec.rst b/Documentation/media/uapi/v4l/dev-codec.rst > > > > > > index c61e938bd8dc..3e6a3e883f11 100644 > > > > > > --- a/Documentation/media/uapi/v4l/dev-codec.rst > > > > > > +++ b/Documentation/media/uapi/v4l/dev-codec.rst > > > > > > @@ -6,6 +6,11 @@ > > > > > > Codec Interface > > > > > > *************** > > > > > > > > > > > > +.. toctree:: > > > > > > + :maxdepth: 1 > > > > > > + > > > > > > + dev-stateless-decoder > > > > > > + > > > > > > A V4L2 codec can compress, decompress, transform, or otherwise convert > > > > > > video data from one format into another format, in memory. Typically > > > > > > such devices are memory-to-memory devices (i.e. devices with the > > > > > > diff --git a/Documentation/media/uapi/v4l/dev-stateless-decoder.rst b/Documentation/media/uapi/v4l/dev-stateless-decoder.rst > > > > > > new file mode 100644 > > > > > > index 000000000000..7a781c89bd59 > > > > > > --- /dev/null > > > > > > +++ b/Documentation/media/uapi/v4l/dev-stateless-decoder.rst > > > > > > @@ -0,0 +1,399 @@ > > > > > > +.. -*- coding: utf-8; mode: rst -*- > > > > > > + > > > > > > +.. _stateless_decoder: > > > > > > + > > > > > > +************************************************** > > > > > > +Memory-to-memory Stateless Video Decoder Interface > > > > > > +************************************************** > > > > > > + > > > > > > +A stateless decoder is a decoder that works without retaining any kind of state > > > > > > +between processing frames. This means that each frame is decoded independently > > > > > > +of any previous and future frames, and that the client is responsible for > > > > > > +maintaining the decoding state and providing it to the decoder with each > > > > > > +decoding request. This is in contrast to the stateful video decoder interface, > > > > > > +where the hardware and driver maintain the decoding state and all the client > > > > > > +has to do is to provide the raw encoded stream. > > > > > > + > > > > > > +This section describes how user-space ("the client") is expected to communicate > > > > > > +with such decoders in order to successfully decode an encoded stream. Compared > > > > > > +to stateful codecs, the decoder/client sequence is simpler, but the cost of > > > > > > +this simplicity is extra complexity in the client which must maintain a > > > > > > +consistent decoding state. > > > > > > + > > > > > > +Stateless decoders make use of the request API and buffer tags. A stateless > > > > > > +decoder must thus expose the following capabilities on its queues when > > > > > > +:c:func:`VIDIOC_REQBUFS` or :c:func:`VIDIOC_CREATE_BUFS` are invoked: > > > > > > + > > > > > > +* The ``V4L2_BUF_CAP_SUPPORTS_REQUESTS`` capability must be set on the > > > > > > + ``OUTPUT`` queue, > > > > > > + > > > > > > +* The ``V4L2_BUF_CAP_SUPPORTS_TAGS`` capability must be set on the ``OUTPUT`` > > > > > > + and ``CAPTURE`` queues, > > > > > > + > > > > > > > > > > [...] > > > > > > > > > > > +Decoding > > > > > > +======== > > > > > > + > > > > > > +For each frame, the client is responsible for submitting a request to which the > > > > > > +following is attached: > > > > > > + > > > > > > +* Exactly one frame worth of encoded data in a buffer submitted to the > > > > > > + ``OUTPUT`` queue, > > > > > > > > > > Although this is still the case in the cedrus driver (but will be fixed > > > > > eventually), this requirement should be dropped because metadata is > > > > > per-slice and not per-picture in the formats we're currently aiming to > > > > > support. > > > > > > > > > > I think it would be safer to mention something like filling the output > > > > > buffer with the minimum unit size for the selected output format, to > > > > > which the associated metadata applies. > > > > > > > > I'm not sure it's a good idea. Some of the reasons why I think so: > > > > 1) There are streams that can have even 32 slices. With that, you > > > > instantly run out of V4L2 buffers even just for 1 frame. > > > > 2) The Rockchip hardware which seems to just pick all the slices one > > > > after another and which was the reason to actually put the slice data > > > > in the buffer like that. > > > > 3) Not all the metadata is per-slice. Actually most of the metadata > > > > is per frame and only what is located inside v4l2_h264_slice_param is > > > > per-slice. The corresponding control is an array, which has an entry > > > > for each slice in the buffer. Each entry includes an offset field, > > > > which points to the place in the buffer where the slice is located. > > > > > > Sorry, I realize that my email wasn't very clear. What I meant to say > > > is that the spec should specify that "at least the minimum unit size > > > for decoding should be passed in a buffer" (that's maybe not the > > > clearest wording), instead of "one frame worth of". > > > > > > I certainly don't mean to say that each slice should be held in a > > > separate buffer and totally agree with all the points you're making :) > > > > Thanks for clarifying. I will update the document and post v3 accordingly. > > > > > I just think we should still allow userspace to pass slices with a > > > finer granularity than "all the slices required for one frame". > > > > I'm afraid that doing so could open the door to some ambiguities. If > > you allow that, then are you also allowed to send more than one frame > > if the decode parameters do not change? How do drivers that only > > support full frames react when handled only parts of a frame? > > IIRC the ability to pass individual slices was brought up regarding a > potential latency benefit, but I doubt it would really be that > significant. > > Thinking about it with the points you mentionned in mind, I guess the > downsides are much more significant than the potential gain. > > So let's stick with requiring all the slices for a frame then! Ack. My view is that we can still loosen this requirement in the future, possibly behind some driver capability flag, but starting with a simpler API, with less freedom to the applications and less constraints on hardware support sounds like a better practice in general. > > Cheers, > > Paul > > > > However, it looks like supporting this might be a problem for the > > > rockchip decoder though. Note that our Allwinner VPU can also process > > > all slices one after the other, but can be configured for slice-level > > > granularity while decoding (at least it looks that way). > > > > > > Side point: After some discussions with Thierry Reading, who's looking > > > into the the Tegra VPU (also stateless), it seems that using the annex- > > > b format for h.264 would be best for everyone. So that means including > > > the start code, NAL header and "raw" slice data. I guess the same > > > should apply to other codecs too. But that should be in the associated > > > pixfmt spec, not in this general document. > > > > > > What do yout think? Hmm, wouldn't that effectively make it the same as V4L2_PIX_FMT_H264? By the way, I proposed it once, some time ago, but it was rejected because VAAPI didn't get the full annex B stream and a V4L2 stateless VAAPI backend would have to reconstruct the stream. Best regards, Tomasz