Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp412470imm; Wed, 22 Aug 2018 06:26:51 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxtRCugmYBI2mORmwBOTy3VT2SoxF1wajySXW2kUKkHM9kT12Fm0TNXpUwITFZB5kNX/7LS X-Received: by 2002:a62:d8c7:: with SMTP id e190-v6mr25337690pfg.88.1534944411441; Wed, 22 Aug 2018 06:26:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534944411; cv=none; d=google.com; s=arc-20160816; b=RA62yk+vusSW9AiL+INocanPdb3WGofbgIh4oPTK825D+4Je/lBVdeUzNP5yJ8m8ER Cd2L2KGw4mgeuVO7STHf8av3kkrgcK76PwWfU9eQA7eEtIdpqaOjC2DB4ExnaF9MlTZN GykBZhaoIIyE+MSMYRNJ7fvKy/6QPgbRuDntbm/s5V0cTolsrGyAGAs5mf4/I14PDRpm EEyc4iBEaxPltg7TV7eYqrTB3++v8z7EGmwEi22GkZkuiOjqiUbcGTbQhud+ek/sp+de aBIBB2gVCAn8COENnPJYPi5A7mTPpO82wNHlAWXgoT5yQKXFeOZ61u+HohDovMYxvVf4 n32g== 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 :arc-authentication-results; bh=tbrx76D5WkhPou4JfAmzZx4FT6d8lT5APKbpJ65zCHI=; b=Fav271NljMub+fRUOrXaw3Lc/PZzX//sKkvHRj5w+vosidSou2aGsxgd0+HF18lvC/ jaVaSFaCtk40CHHocIlY4bYKKBd7zQOl1CCMONPT8XJEdQPbm7/bY05RoTrhFmdZyoRN tZeFmHc8kJTLA5C6xgUAh5X1o/uPt604IHa4RYDnMP/FcMSHFdBWE7oDoZY/zbmRGF8F ShUzUm54lvQF7f/B+9daYDPYXSRoO7DTQgPEnVv8v27DBcCNsbNoO9MsqZMGoWSfom3W 9GJ6b5hbDYPeFy20Ns4rEhUR0oWJT3bdD/RryGd0zt9AGOzzjW9OsPkgC9LXfnZ7Qm1F SZHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=B0rtV+ny; 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 e10-v6si1831395pfc.51.2018.08.22.06.26.35; Wed, 22 Aug 2018 06:26:51 -0700 (PDT) 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=B0rtV+ny; 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 S1729056AbeHVQtf (ORCPT + 99 others); Wed, 22 Aug 2018 12:49:35 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:44444 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728758AbeHVQtf (ORCPT ); Wed, 22 Aug 2018 12:49:35 -0400 Received: by mail-yw1-f67.google.com with SMTP id l9-v6so616445ywc.11 for ; Wed, 22 Aug 2018 06:24:40 -0700 (PDT) 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=tbrx76D5WkhPou4JfAmzZx4FT6d8lT5APKbpJ65zCHI=; b=B0rtV+nyPwhpTE1HkWdZnAZwg1sFSyidPjwkyfxqi2hr3fnE9gjVsQGNatAIqW6MtC tKMgdfd5hM9wKN0WHIpouM5serl46jXL6nXGdVDuJ1Ml+IEafxMBlA+uKI7DClau9Mp7 DXKdIuEAxUDE3KJ4sccquA/zO6kHaEe47LbuI= 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=tbrx76D5WkhPou4JfAmzZx4FT6d8lT5APKbpJ65zCHI=; b=CWmGIq2M1ibRsXr+WFVWJ6xBIsQScYbEp2708Lu7b4xgO7w6j1CghmASaHOLIVy4Li /7Kc7qv0k5Z/1JmgrKjV4qZiDvkXjZQWgMLC9S6C/FeRqoa9evwiAcTX/RQAWIXWmhtR UBadTlO6JqeBrSxNmTAZHmvUHJ8OBGThH8vLygWvxiwAd4Xyw3qqRcBcCp50lkwuB9pd NZiVzZ3LnoH95hbqb+JeSvZXGI2+DdpUK4e4P4CsRG6t0IkJ67nm1J1/cGPwFfdi0izr LkQDa8W5PcMpkqR605yBVnVCD8Zwb49KL95u0ltJ+zWI6Ma3GWeG3fAk9GBHu5iVz/FS bAeg== X-Gm-Message-State: APzg51D0Ko/yPyqSzBioN4Z88wxIS+sDe6WONTj4YDOgyAV9LJLAFJXb iDz+PDJpMl/mKxmmGMNjkwYdl9lpZrLLag== X-Received: by 2002:a0d:dcc1:: with SMTP id f184-v6mr30912ywe.26.1534944279713; Wed, 22 Aug 2018 06:24:39 -0700 (PDT) Received: from mail-yb0-f169.google.com (mail-yb0-f169.google.com. [209.85.213.169]) by smtp.gmail.com with ESMTPSA id v126-v6sm1749382ywe.45.2018.08.22.06.24.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Aug 2018 06:24:38 -0700 (PDT) Received: by mail-yb0-f169.google.com with SMTP id d34-v6so648634yba.3 for ; Wed, 22 Aug 2018 06:24:38 -0700 (PDT) X-Received: by 2002:a25:9347:: with SMTP id g7-v6mr8235831ybo.293.1534944277722; Wed, 22 Aug 2018 06:24:37 -0700 (PDT) MIME-Version: 1.0 References: <20180613140714.1686-1-maxime.ripard@bootlin.com> <20180613140714.1686-2-maxime.ripard@bootlin.com> <80e1d9cb49c6df06843e49332685f2b401023292.camel@collabora.com> <20180822091557.gtnlgoebyv6yttzf@flea> In-Reply-To: From: Tomasz Figa Date: Wed, 22 Aug 2018 22:24:23 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/9] CHROMIUM: v4l: Add H264 low-level decoder API compound controls. To: Paul Kocialkowski Cc: Maxime Ripard , Ezequiel Garcia , Pawel Osciak , Hans Verkuil , Alexandre Courbot , Sakari Ailus , Laurent Pinchart , Chen-Yu Tsai , Linux Kernel Mailing List , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , Linux Media Mailing List , Nicolas Dufresne , jenskuske@gmail.com, linux-sunxi@googlegroups.com, thomas.petazzoni@bootlin.com, groeck@chromium.org 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, Aug 22, 2018 at 10:03 PM Paul Kocialkowski wrote: > > Hi, > > On Wed, 2018-08-22 at 18:54 +0900, Tomasz Figa wrote: > > On Wed, Aug 22, 2018 at 6:16 PM Maxime Ripard wrote: > > > > > > Hi, > > > > > > On Tue, Aug 21, 2018 at 01:58:38PM -0300, Ezequiel Garcia wrote: > > > > On Wed, 2018-06-13 at 16:07 +0200, Maxime Ripard wrote: > > > > > From: Pawel Osciak > > > > > > > > > > Signed-off-by: Pawel Osciak > > > > > Reviewed-by: Wu-cheng Li > > > > > Tested-by: Tomasz Figa > > > > > [rebase44(groeck): include linux/types.h in v4l2-controls.h] > > > > > Signed-off-by: Guenter Roeck > > > > > Signed-off-by: Maxime Ripard > > > > > --- > > > > > > > > > > > > > [..] > > > > > diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h > > > > > index 242a6bfa1440..4b4a1b25a0db 100644 > > > > > --- a/include/uapi/linux/videodev2.h > > > > > +++ b/include/uapi/linux/videodev2.h > > > > > @@ -626,6 +626,7 @@ struct v4l2_pix_format { > > > > > #define V4L2_PIX_FMT_H264 v4l2_fourcc('H', '2', '6', '4') /* H264 with start codes */ > > > > > #define V4L2_PIX_FMT_H264_NO_SC v4l2_fourcc('A', 'V', 'C', '1') /* H264 without start codes */ > > > > > #define V4L2_PIX_FMT_H264_MVC v4l2_fourcc('M', '2', '6', '4') /* H264 MVC */ > > > > > +#define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4') /* H264 parsed slices */ > > > > > > > > As pointed out by Tomasz, the Rockchip VPU driver expects start codes [1], so the userspace > > > > should be aware of it. Perhaps we could document this pixel format better as: > > > > > > > > #define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4') /* H264 parsed slices with start codes */ > > > > > > I'm not sure this is something we want to do at that point. libva > > > doesn't give the start code, so this is only going to make the life of > > > the sane controllers more difficult. And if you need to have the start > > > code and parse it, then you're not so stateless anymore. > > > > I might not remember correctly, but Rockchip decoder does some slice > > parsing on its own (despite not doing any higher level parsing). > > Probably that's why it needs those start codes. > > The VPU found on Allwinner platforms also provides a mechanism to parse > the bitstream data via a dedicated interface through the VPU registers. > It is used in libvdpau-sunxi but not in our driver, because we don't > want to be doing bitstream parsing in the kernel. > > It would be good to know if this is just a feature of the Rockchip VPU > hardware that can be skipped (like on Allwinner) or if it's a hard > requirement in its decoding pipeline. It's a hard requirement for its decoding pipeline, but... > Also, maybe it only concerns the > slice header? It is already part of the slice data (provided by VAAPI) > for H.264/H.265 and an offset is provided to the beginning of the coded > video data. Yes, it seems to be only the slice header. > > > I wonder if libva is the best reference here. It's been designed > > almost entirely by Intel for Intel video hardware. We want something > > that could work with a wide range of devices and avoid something like > > a need to create a semi-stateless API few months later. In fact, > > hardware from another vendor, we're working with, also does parsing of > > slice headers internally. Moreover, we have some weird > > kind-of-stateful decoders, which cannot fully deal with bitstream on > > its own, e.g. cannot parse formats, cannot handle resolution changes, > > need H264 bitstream NALUs split into separate buffers, etc. > > > > As I suggested some time ago, having the full bitstream in the buffer, > > with offsets of particular units included in respective controls, > > would be the most scalable thing. If really needed, we could add flags > > telling the driver that particular units are present, so one's > > implementation of libva could put only raw slice data in the buffers. > > But perhaps it's libva which needs some amendment? > > If the raw bitstream is needed, I think it would make more sense to use > the already-existing formats for stateful VPUs along with the controls > for stateless ones instead of having the full bitstream in the > V4L2_PIX_FMT_*_SLICE formats. It may indeed make sense to separate this based on pixel format. However, how do we tell the client that it needs to provide those controls? Current concept was based entirely on pixel format, so I guess that would mean creating something like V4L2_PIX_FMT_*_NOT_REALLY_SLICE (_PARSED, _STATELESS?). Might be okay, though... > > I would also be tempted to say that reconstructing the needed parts of > the bitstream in-driver for these half-way VPUs would be a better > approach than blurrying the line between how (and what) data should be > passed for stateful and stateless VPUs at the API level. Stateless > should only cover what's in the slice NAL unit RBSP, which excludes the > start code detection bytes. It is no longer parsed data otherwise. I'm not sure where such decision comes from. In particular, Chromium, from which this code originates, includes start codes in V4L2_PIX_FMT_H264_SLICE. As I mentioned earlier, we can't design this API based only on 1 type of hardware semantics. The stateless API should cover any kind of codec that needs user space assistance in processing the stream, which in practice would be almost everything for which stateful API doesn't work. That said, since pixel format essentially specifies the buffer contents, having such cases differentiated based on the pixel format doesn't sound insane. Best regards, Tomasz