Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2940944yba; Tue, 16 Apr 2019 00:58:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxl4TD2NRpS/Ng2ItSk9dPQwgkbyfkNeAblEFIctZoSVBHEmg4NjWU5zuVbRC9UlRn8+eDz X-Received: by 2002:aa7:9296:: with SMTP id j22mr82346391pfa.140.1555401488989; Tue, 16 Apr 2019 00:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555401488; cv=none; d=google.com; s=arc-20160816; b=okPwsSqF7CuYXSnu1xbKdaGnbzm/cLqOMk6pwh1EBqSdDLLh1zf/WM9ApgMzfKIltz WWXKesTZA13MbRPJJIFfkcgL35dm8Xt73BJQgkuzyLmDFQ0uPz3ENjDATRA/YQtY9oPk UrDM3iFuBYTElRsiZ6o4HosRUkCMaIKru3S8hZonh4uZLccIbI7VfECFna2dBPAuUR6t EoY+d4OdC9GPlEC4JLallT/XJ4iQCfitLyy2DKzVRz3J7hKgLoKMRwHNXIVcIDNodG0d Q4t5gyNLshGAmERfA8VFFipe6ebHFCmnhr4IhcUHSarKZj7YJMus7b+TwVzwqA7Xgdl0 fIYQ== 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:mime-version :user-agent:organization:references:in-reply-to:date:cc:to:from :subject:message-id; bh=ava8UX4trM2NtIzNHfcEg0I6Xjalb3fV9qQLGQrFXSQ=; b=DX26q730C6WsPyuAwLWsVOs8QMxNyMkL2foVprniNF2xD9r9P1iAe+EBcib+Ay+yz9 /3y8qYIN6Y9k6rLMDPw0FlO1Ll3cyYasbiA3C2pcoauWlcIlKGFO94lsuR1ptXJXw1Si wWD2Ja2+EVqX/LNniTBffsp8ybYvqX/XhwaUt/KXc6xEA+nV7Ftw9+XwdLpwU/ST20ml qxbKPjgGsDlrNIEHpkuHuIemHwOqNOUuFWQnOEZ5Eu6CDueP5HxO1m4V/QmF9iCjOXZj QJcPAmcKyk6KG19uK5Jpw9C3fmB+jNzv/D8v0yz+noL0HShjZCasSdpFI2L9OzZZLCTC TtdQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h8si45082677pgp.446.2019.04.16.00.57.52; Tue, 16 Apr 2019 00:58:08 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728692AbfDPHzz (ORCPT + 99 others); Tue, 16 Apr 2019 03:55:55 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:52789 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726837AbfDPHzx (ORCPT ); Tue, 16 Apr 2019 03:55:53 -0400 X-Originating-IP: 90.88.18.121 Received: from aptenodytes (aaubervilliers-681-1-63-121.w90-88.abo.wanadoo.fr [90.88.18.121]) (Authenticated sender: paul.kocialkowski@bootlin.com) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 220631C0011; Tue, 16 Apr 2019 07:55:49 +0000 (UTC) Message-ID: <0f4775b1bb04e136e3a425df0ba6a201594acdbd.camel@bootlin.com> Subject: Re: [PATCH v4] media: docs-rst: Document m2m stateless video decoder interface From: Paul Kocialkowski To: Alexandre Courbot , Nicolas Dufresne Cc: Tomasz Figa , Maxime Ripard , Hans Verkuil , Dafna Hirschfeld , Mauro Carvalho Chehab , Linux Media Mailing List , LKML Date: Tue, 16 Apr 2019 09:55:49 +0200 In-Reply-To: References: <20190306080019.159676-1-acourbot@chromium.org> <371df0e4ec9e38d83d11171cbd98f19954cbf787.camel@ndufresne.ca> <439b7f57aa3ba2b2ed5b043f961ef87cb83912af.camel@ndufresne.ca> <59e23c5ca5bfbadf9441ea06da2e9b9b5898c6d7.camel@bootlin.com> <0b495143bb260cf9f8927ee541e7f001842ac5c3.camel@ndufresne.ca> Organization: Bootlin Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Le mardi 16 avril 2019 à 16:22 +0900, Alexandre Courbot a écrit : [...] > Thanks for this great discussion. Let me try to summarize the status > of this thread + the IRC discussion and add my own thoughts: > > Proper support for multiple decoding units (e.g. H.264 slices) per > frame should not be an afterthought ; compliance to encoded formats > depend on it, and the benefit of lower latency is a significant > consideration for vendors. > > m2m, which we use for all stateless codecs, has a strong assumption > that one OUTPUT buffer consumed results in one CAPTURE buffer being > produced. This assumption can however be overruled: at least the venus > driver does it to implement the stateful specification. > > So we need a way to specify frame boundaries when submitting encoded > content to the driver. One request should contain a single OUTPUT > buffer, containing a single decoding unit, but we need a way to > specify whether the driver should directly produce a CAPTURE buffer > from this request, or keep using the same CAPTURE buffer with > subsequent requests. > > I can think of 2 ways this can be expressed: > 1) We keep the current m2m behavior as the default (a CAPTURE buffer > is produced), and add a flag to ask the driver to change that behavior > and hold on the CAPTURE buffer and reuse it with the next request(s) ; That would kind of break the stateless idea. I think we need requests to be fully independent of eachother and have some entity that coordinates requests for this kind of things. > 2) We specify that no CAPTURE buffer is produced by default, unless a > flag asking so is specified. > > The flag could be specified in one of two ways: > a) As a new v4l2_buffer.flag for the OUTPUT buffer ; > b) As a dedicated control, either format-specific or more common to all codecs. I think we must aim for a generic solution that would be at least common to all codecs, and if possible common to requests regardless of whether they concern video decoding or not. I really like the idea of introducing a requests batch/group/queue, which groups requests together and allows marking them done when the whole group is done being decoded. For that, we explicitly mark one of the requests as the final one, so that we can continue adding requests to the batch even when it's already being processed. When all the requests are done being decoded, we can mark them done. With that, we also need some tweaking in the core to look for an available capture buffer that matches the output buffer's timestamp before trying to dequeue the next available capture buffer. This way, the first request of the batch will get any queued capture buffer, but subsequent requests will find the matchung capture buffer by timestamp. I think that's basically all we need to handle that and the two aspects (picking by timestamp and requests groups) are rather independent and the latter could probably be used in other situations than video decoding. What do you think? Cheers, Paul > I tend to favor 2) and b) for this, for the reason that with H.264 at > least, user-space does not know whether a slice is the last slice of a > frame until it starts parsing the next one, and we don't know when we > will receive it. If we use a control to ask that a CAPTURE buffer be > produced, we can always submit another request with only that control > set once it is clear that the frame is complete (and not delay > decoding meanwhile). In practice I am not that familiar with > latency-sensitive streaming ; maybe a smart streamer would just append > an AUD NAL unit at the end of every frame and we can thus submit the > flag it with the last slice without further delay? > > An extra constraint to enforce would be that each decoding unit > belonging to the same frame must be submitted with the same timestamp, > otherwise the request submission would fail. We really need a > framework to enforce all this at a higher level than individual > drivers, once we reach an agreement I will start working on this. > > Formats that do not support multiple decoding units per frame would > reject any request that does not carry the end-of-frame information. > > Anything missing / any further comment? -- Paul Kocialkowski, Bootlin Embedded Linux and kernel engineering https://bootlin.com