Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1755814imu; Thu, 24 Jan 2019 01:05:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN6hxTTcFOz/gKc8UM0Db0lb7WdKNkUmY9f/Epz/b32ZNqy3gvlCEiTbP3I2wlaC7HL+Eoz1 X-Received: by 2002:aa7:868f:: with SMTP id d15mr5553399pfo.225.1548320722905; Thu, 24 Jan 2019 01:05:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548320722; cv=none; d=google.com; s=arc-20160816; b=LOPwLUtY5fZyS4O/AkVT1ZB6aosmX3K+9CnQnwRFuRW8VWzKXFqstElhznAAgfwph/ g6OPf4gEpyAakfE8fvNav7Y23cUu9g1PvLp7fzyFN4TihY6D+sBlPLWdB1ViYzPl9aQ7 h07X4C9lekSH2lJnSy0aax4Z1vJ8+5kActA0AxcvB3/35dGQXli3O3LnIHDM0pHrZl4L cCVSnU8fmHvTR9U323DKVEVfcmdlLHivg2BeqB+FPbkjYOFNVG7mh1LVydBe+Sd6SL04 Ytnvf8JyXzjRhIelkZ9qIyKeuM8U4swPJDRSvAjrzkX9gq9WcfbUAOWxU7MHcCow0Ael a+dQ== 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=D97CEd8vzeWco95M51ixn8l17qLeRZIIapFdVD8ZETc=; b=rYOBcmGQafzNjvPuaKJRByaGwadv070T4TSLkVTYcHMimeA0baJdFosUosHlSitsg3 j7f6z/KZAAHCqgoVezO7kJG4FPRnu2nndKJ5K9gmdQDVztpgkBPVhdDsenIGS7u7foYd znXwxP7HiHRIpw5OJAij/cq/FuDWhRfRlxed2JU1fo9pwhjbFtt1KghWjeF0lfdmQkE+ q+kitFeMX9FbJaB8NXTm3qsmkcgFUCyxpeyatFdf8GzeLLzOp/fNXDawkELsMH/YPfZO oWDJ3gjqHA3eNO7o2FdtQ7DIyjZSC8E10pe7MFSKqelmjgonSJUbJe9x+V5SJGsrQxjd vcXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dXyrDeS1; 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 q10si20826911pll.221.2019.01.24.01.05.02; Thu, 24 Jan 2019 01:05:22 -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=dXyrDeS1; 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 S1727443AbfAXJE4 (ORCPT + 99 others); Thu, 24 Jan 2019 04:04:56 -0500 Received: from mail-oi1-f195.google.com ([209.85.167.195]:45870 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726997AbfAXJEz (ORCPT ); Thu, 24 Jan 2019 04:04:55 -0500 Received: by mail-oi1-f195.google.com with SMTP id y1so4218052oie.12 for ; Thu, 24 Jan 2019 01:04:54 -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=D97CEd8vzeWco95M51ixn8l17qLeRZIIapFdVD8ZETc=; b=dXyrDeS1V3t0Z8O2evdBHEjsirQM3uv45Xe0roa7R7FvrFeP1bIGOPsU6YeWSU+L8o uo15n/D76wDHaykgi+3j70G0iIlf0Zj2GtDuPD4y6TdKdYDpZSHg0iCW0RgUiwfFVv9h O9kOmN3FpQtdZCuKSn7tO6TQmh+KLubygFcws= 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=D97CEd8vzeWco95M51ixn8l17qLeRZIIapFdVD8ZETc=; b=cd57kesUn+/L4uPa6ADUVmC+NY4WEOg9TuPACQsPxn4JelnQNfzcSXmrSYIyAVcEji 0MHaaxmWT6r8oQHFUbXz2YCeBZhhBtIa/pZuLelNIdOB+Qg0G3jb12TKaDjCPRErnST6 ZhFXNILmzcNFUPY5xBSpzpTzEfHyLpwiablmzuckN+AB7kB6L/83ZDb5diDSqv4Z30+/ HhpstYyczcI/d5kwMwtCqqC3pgx1jI3GA2zfWRUYq35566YDsOLXvxXwwOCKGt8UcW7l wBoMlXdrV3739fZ49cgcbgmf7o2LZycxPzI25zlITtrqBnsQabxxqmUPBXIKRWIpdmam Hnmw== X-Gm-Message-State: AJcUukcOeXKataMMe+ROtFWOyA6/K6RCzfFxbrcuDu5HZZ7asRInyNdw Ik83j7MOeD6bKhO2ANO2zHHkv8i4zsM= X-Received: by 2002:aca:4341:: with SMTP id q62mr621165oia.2.1548320694378; Thu, 24 Jan 2019 01:04:54 -0800 (PST) Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com. [209.85.167.182]) by smtp.gmail.com with ESMTPSA id q128sm10008232oia.4.2019.01.24.01.04.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 01:04:53 -0800 (PST) Received: by mail-oi1-f182.google.com with SMTP id v6so4265480oif.2 for ; Thu, 24 Jan 2019 01:04:53 -0800 (PST) X-Received: by 2002:aca:5e09:: with SMTP id s9mr542047oib.153.1548320693086; Thu, 24 Jan 2019 01:04:53 -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: Alexandre Courbot Date: Thu, 24 Jan 2019 18:04:41 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] media: docs-rst: Document m2m stateless video decoder interface To: Paul Kocialkowski Cc: Tomasz Figa , 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! Grateful for that ; thanks! I will rework the document, so please don't waste your time on this v2. How data should be sliced can probably be implemented using a codec-specific control exposing what the driver supports and that user-space would have to check. To make things future-proof it is probably safer to introduce it now even if it only takes a single value ; I will try to incorporate this in the v3 as well.