Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5426661imu; Tue, 29 Jan 2019 19:43:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Z3pelKySvJZ6WX0BrwP4Ot0i6iHFTHH1mh8kdxntiJ/56yO3OmhB5UuA8M8xQwh3kn9Zt X-Received: by 2002:a17:902:9a07:: with SMTP id v7mr23010516plp.247.1548819823359; Tue, 29 Jan 2019 19:43:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548819823; cv=none; d=google.com; s=arc-20160816; b=SVeXLol9oyF2y1KLPKJwAw3eu6bx7YcMQDH76pi4gsgKDriw/U0fkSLLn+fLQ+zTA7 SBHRB5yhpr9Wj5ZqwpgEIXpnMYg/RiNeBDgPTsk6h5pJu0/mvzVCiF87ZbBKe8d5tlB0 bYDGOPWjyphaVLMbJgv5iEEAHhzOdfyY2EFEz7LWpR+/eEAVxObSe+D5g6EKgtw0/VL1 fSmV+85nUpuDJF7du/Qg1KhJjnWXXty69GuSKl4oMBMIaikKXC5q5WlRcJaIu6Cmt/um B/Gj/g1+xD43/UD94MHld3q4VUhnVsehvrfps0Vqwb2ZyYifOEn+k7u0069G1Q62Qgtp 9UzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=TcsyA1n6pBTmF1Y5oeefdi7XPYD4WXUfVM4aanxIPf4=; b=cYK5h6J6e/nQDLSZxXUYem6xOEHKUfkjUfBmDu/eYoHVZzjAHAiLz8rZOReV0Y9fAc 0Dveh0pTfOspBZMollc6UoZo+PdQcb4Yq3q2BrGbYsx7EZDdq9PoHDIhzGehMp5YaJi/ 9ZE3MManxR04ClrpMRhu1nGkew8FGywlIm5pUUAymmKk5y9s9kOK5tBTMs91IKrxhIwi XHEasATGeuSA0FPwZVGGJ86zjSO7DeUpF26x43j8YDOybDIoYi3cUZNDHPmR1feeTVkI M1N6WBJUoXVUn/t7LPkIQWuWCYY1MjIziy66E/LL6A283mBcLMgTIvpptcNpbH4wYZRq X46Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=SpBSH8Mf; 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 o10si303367pgg.373.2019.01.29.19.43.27; Tue, 29 Jan 2019 19:43:43 -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=SpBSH8Mf; 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 S1729794AbfA3DnS (ORCPT + 99 others); Tue, 29 Jan 2019 22:43:18 -0500 Received: from mail-ot1-f67.google.com ([209.85.210.67]:39978 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727527AbfA3DnS (ORCPT ); Tue, 29 Jan 2019 22:43:18 -0500 Received: by mail-ot1-f67.google.com with SMTP id s5so19951627oth.7 for ; Tue, 29 Jan 2019 19:43:17 -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:content-transfer-encoding; bh=TcsyA1n6pBTmF1Y5oeefdi7XPYD4WXUfVM4aanxIPf4=; b=SpBSH8Mf4zPTp2y0b78sCsIPoZBvwdDBA7enAu5Y10R1062+fXZpzl+r8No+CW5FRC KSHqM8Af97BnqRFj7t07VBqY6SQJVWsR4NLhxw/Vjw9WCagOoiXtYm4RT+DK8dT4QnPJ IHkujlBB3kEBFc1/BOweHMC6JdstIC2rm2gQw= 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:content-transfer-encoding; bh=TcsyA1n6pBTmF1Y5oeefdi7XPYD4WXUfVM4aanxIPf4=; b=HYH7NylP5q2RX6UamJHmpIOl7Z+8wvnmT8aVRVL2jO6sOJS/1X/r5wtCLt65oYflE2 JjtZ0XhEmsW4qGWpDWfbSBQkT2qLhK19bwl4hs/SocprHlmS/HIiAy7HpEF135yusQ17 bcvabv7dVLSvzJuuSDYhksTmoeE0Ko5YebN7UlwjgCsvN5RNo7tTdSGELxQvPhQQ7B60 27Mn76AeTxxJPvhvxPP7jjdYsWb7zEKeLjLpvNpwUwpu6rjwMk9w9rFtIM2dWbr1sG6m X0CYV/59cxhphszxG3C7UhNvT0mDm9WrvqR/MarX8ZdIEfx4wmTDefxGXFt8edHn6pPW GfwQ== X-Gm-Message-State: AJcUukeK1URXjU+AuSPxghAcEEcNhkb+RE4+28Sc3/e3qIyvROSyRwox lx7rjg2VeGENTDTCHRL3yGK4DeYRcRc= X-Received: by 2002:a9d:7c1:: with SMTP id 59mr23227275oto.191.1548819796585; Tue, 29 Jan 2019 19:43:16 -0800 (PST) Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com. [209.85.167.177]) by smtp.gmail.com with ESMTPSA id a12sm149538otl.39.2019.01.29.19.43.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 19:43:16 -0800 (PST) Received: by mail-oi1-f177.google.com with SMTP id a77so18115678oii.5 for ; Tue, 29 Jan 2019 19:43:16 -0800 (PST) X-Received: by 2002:aca:ea57:: with SMTP id i84mr11319499oih.346.1548819353475; Tue, 29 Jan 2019 19:35:53 -0800 (PST) MIME-Version: 1.0 References: <20181123130209.11696-1-paul.kocialkowski@bootlin.com> <20181123130209.11696-2-paul.kocialkowski@bootlin.com> <5515174.7lFZcYkk85@jernej-laptop> <776e63c9-d4a5-342a-e0f7-200ef144ffc4@rock-chips.com> <64c793e08d61181b78125b3956ec38623fa5d261.camel@bootlin.com> <82FA0C3F-BC54-4D89-AECB-90D81B89B1CE@soulik.info> <42520087-4EAE-4F7F-BCA0-42E422170E91@soulik.info> <2442b23d3b0a00c1bd441298a712888e016acf92.camel@ndufresne.ca> In-Reply-To: From: Tomasz Figa Date: Wed, 30 Jan 2019 12:35:41 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [linux-sunxi] [PATCH v2 1/2] media: v4l: Add definitions for the HEVC slice format and controls To: Alexandre Courbot Cc: Nicolas Dufresne , Paul Kocialkowski , Ayaka , Randy Li , =?UTF-8?Q?Jernej_=C5=A0krabec?= , Linux Media Mailing List , LKML , devel@driverdev.osuosl.org, "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , Mauro Carvalho Chehab , Maxime Ripard , Hans Verkuil , Ezequiel Garcia , Thomas Petazzoni , "open list:ARM/Rockchip SoC..." Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 30, 2019 at 11:29 AM Alexandre Courbot wrote: > > On Wed, Jan 30, 2019 at 6:41 AM Nicolas Dufresne w= rote: > > > > Le mardi 29 janvier 2019 =C3=A0 16:44 +0900, Alexandre Courbot a =C3=A9= crit : > > > On Fri, Jan 25, 2019 at 10:04 PM Paul Kocialkowski > > > wrote: > > > > Hi, > > > > > > > > On Thu, 2019-01-24 at 20:23 +0800, Ayaka wrote: > > > > > Sent from my iPad > > > > > > > > > > > On Jan 24, 2019, at 6:27 PM, Paul Kocialkowski wrote: > > > > > > > > > > > > Hi, > > > > > > > > > > > > > On Thu, 2019-01-10 at 21:32 +0800, ayaka wrote: > > > > > > > I forget a important thing, for the rkvdec and rk hevc decode= r, it would > > > > > > > requests cabac table, scaling list, picture parameter set and= reference > > > > > > > picture storing in one or various of DMA buffers. I am not ta= lking about > > > > > > > the data been parsed, the decoder would requests a raw data. > > > > > > > > > > > > > > For the pps and rps, it is possible to reuse the slice header= , just let > > > > > > > the decoder know the offset from the bitstream bufer, I would= suggest to > > > > > > > add three properties(with sps) for them. But I think we need = a method to > > > > > > > mark a OUTPUT side buffer for those aux data. > > > > > > > > > > > > I'm quite confused about the hardware implementation then. From= what > > > > > > you're saying, it seems that it takes the raw bitstream element= s rather > > > > > > than parsed elements. Is it really a stateless implementation? > > > > > > > > > > > > The stateless implementation was designed with the idea that on= ly the > > > > > > raw slice data should be passed in bitstream form to the decode= r. For > > > > > > H.264, it seems that some decoders also need the slice header i= n raw > > > > > > bitstream form (because they take the full slice NAL unit), see= the > > > > > > discussions in this thread: > > > > > > media: docs-rst: Document m2m stateless video decoder interface > > > > > > > > > > Stateless just mean it won=E2=80=99t track the previous result, b= ut I don=E2=80=99t > > > > > think you can define what a date the hardware would need. Even yo= u > > > > > just build a dpb for the decoder, it is still stateless, but pars= ing > > > > > less or more data from the bitstream doesn=E2=80=99t stop a decod= er become a > > > > > stateless decoder. > > > > > > > > Yes fair enough, the format in which the hardware decoder takes the > > > > bitstream parameters does not make it stateless or stateful per-se. > > > > It's just that stateless decoders should have no particular reason = for > > > > parsing the bitstream on their own since the hardware can be design= ed > > > > with registers for each relevant bitstream element to configure the > > > > decoding pipeline. That's how GPU-based decoder implementations are > > > > implemented (VAAPI/VDPAU/NVDEC, etc). > > > > > > > > So the format we have agreed on so far for the stateless interface = is > > > > to pass parsed elements via v4l2 control structures. > > > > > > > > If the hardware can only work by parsing the bitstream itself, I'm = not > > > > sure what the best solution would be. Reconstructing the bitstream = in > > > > the kernel is a pretty bad option, but so is parsing in the kernel = or > > > > having the data both in parsed and raw forms. Do you see another > > > > possibility? > > > > > > Is reconstructing the bitstream so bad? The v4l2 controls provide a > > > generic interface to an encoded format which the driver needs to > > > convert into a sequence that the hardware can understand. Typically > > > this is done by populating hardware-specific structures. Can't we > > > consider that in this specific instance, the hardware-specific > > > structure just happens to be identical to the original bitstream > > > format? > > > > At maximum allowed bitrate for let's say HEVC (940MB/s iirc), yes, it > > would be really really bad. In GStreamer project we have discussed for > > a while (but have never done anything about) adding the ability through > > a bitmask to select which part of the stream need to be parsed, as > > parsing itself was causing some overhead. Maybe similar thing applies, > > though as per our new design, it's the fourcc that dictate the driver > > behaviour, we'd need yet another fourcc for drivers that wants the full > > bitstream (which seems odd if you have already parsed everything, I > > think this need some clarification). > > Note that I am not proposing to rebuild the *entire* bitstream > in-kernel. What I am saying is that if the hardware interprets some > structures (like SPS/PPS) in their raw format, this raw format could > be reconstructed from the structures passed by userspace at negligible > cost. Such manipulation would only happen on a small amount of data. > > Exposing finer-grained driver requirements through a bitmask may > deserve more exploring. Maybe we could end with a spectrum of > capabilities that would allow us to cover the range from fully > stateless to fully stateful IPs more smoothly. Right now we have two > specifications that only consider the extremes of that range. I gave it a bit more thought and if we combine what Nicolas suggested about the bitmask control with the userspace providing the full bitstream in the OUTPUT buffers, split into some logical units and "tagged" with their type (e.g. SPS, PPS, slice, etc.), we could potentially get an interface that would work for any kind of decoder I can think of, actually eliminating the boundary between stateful and stateless decoders. For example, a fully stateful decoder would have the bitmask control set to 0 and accept data from all the OUTPUT buffers as they come. A decoder that doesn't do any parsing on its own would have all the valid bits in the bitmask set and ignore the data in OUTPUT buffers tagged as any kind of metadata. And then, we could have any cases in between, including stateful decoders which just can't parse the stream on their own, but still manage anything else themselves, or stateless ones which can parse parts of the stream, like the rk3399 vdec can parse the H.264 slice headers on its own. That could potentially let us completely eliminate the distinction between the stateful and stateless interfaces and just have one that covers both. Thoughts? Best regards, Tomasz