Message ID | 20230309125651.23911-1-andrzej.p@collabora.com (mailing list archive) |
---|---|
Headers |
Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from <linux-media-owner@vger.kernel.org>) id 1paFrC-00DsUV-Og; Thu, 09 Mar 2023 12:58:55 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230514AbjCIM6w (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Thu, 9 Mar 2023 07:58:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231192AbjCIM63 (ORCPT <rfc822;linux-media@vger.kernel.org>); Thu, 9 Mar 2023 07:58:29 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D27DF1687 for <linux-media@vger.kernel.org>; Thu, 9 Mar 2023 04:57:46 -0800 (PST) Received: from localhost.localdomain (unknown [194.146.248.75]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: andrzej.p) by madras.collabora.co.uk (Postfix) with ESMTPSA id C2E476602FE7; Thu, 9 Mar 2023 12:57:03 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1678366624; bh=Fa+K5mx43H80PRxNz8HGFdjywzLARrxyM7AGivxbkmM=; h=From:To:Cc:Subject:Date:From; b=eop0JHHVRbR2cemyFzYWv12A3q9MNdjNt3rzrRbPizk5Mlcqx+EHcTm6kGLNdXhoz ESfuq8UAz5PUQgibHuCIg96U3xKfeLOPFcHup7aTan1gnc8kVLJhz0C1OT2F8XiQBW hkbC11Qh+pBRM1L7FW5s7SujC5oookzK/xmxtkc/6jnYRZyGowS1Nn2ixd3n5CaPLo rh+4I5woJSfNa+bVPo9knDITeJElECBJpIgPz8u80S44ZrSPAKvzcFKS+toNl0iFpW ExL3klAwlWSv/i1JvvPncxeSzh+NRJqbG9s3HYmTyFKnlxRsA3RYphQ30HHbR0kuLT V2/DwWLTxh75Q== From: Andrzej Pietrasiewicz <andrzej.p@collabora.com> To: linux-media@vger.kernel.org Cc: linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Mauro Carvalho Chehab <mchehab@kernel.org>, Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>, Philipp Zabel <p.zabel@pengutronix.de>, Heiko Stuebner <heiko@sntech.de>, Andrzej Pietrasiewicz <andrzej.p@collabora.com>, kernel@collabora.com Subject: [RFC 0/2] VP8 stateless V4L2 encoding uAPI + driver Date: Thu, 9 Mar 2023 13:56:49 +0100 Message-Id: <20230309125651.23911-1-andrzej.p@collabora.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -2.5 (--) X-LSpam-Report: No, score=-2.5 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1 autolearn=ham autolearn_force=no |
Series |
VP8 stateless V4L2 encoding uAPI + driver
|
|
Message
Andrzej Pietrasiewicz
March 9, 2023, 12:56 p.m. UTC
Dear All, This two-patch series adds uAPI for stateless VP8 encoding and an accompanying driver using it. It has been tested on an rk3399 board and there exists a gstreamer user: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3736 example pipeline: gst-launch-1.0 videotestsrc num-buffers=500 ! video/x-raw,width=640,height=480 \ ! v4l2slvp8enc ! queue ! matroskamux ! filesink location=test_vp8.mkv I kindly ask for comments. Notably, the documentation for the added uAPI is missing, that is to be addressed when sending a patch series proper (not RFC). For the RFC I also did not care to replace a BUG_ON() in the boolean encoder. Rebased onto v6.2. Regards, Andrzej Andrzej Pietrasiewicz (2): media: uapi: Add VP8 stateless encoder controls media: rkvdec: Add VP8 encoder drivers/media/platform/verisilicon/Makefile | 2 + drivers/media/platform/verisilicon/hantro.h | 10 + .../platform/verisilicon/hantro_boolenc.c | 69 + .../platform/verisilicon/hantro_boolenc.h | 21 + .../media/platform/verisilicon/hantro_drv.c | 18 +- .../media/platform/verisilicon/hantro_hw.h | 90 + .../media/platform/verisilicon/hantro_v4l2.c | 5 +- .../media/platform/verisilicon/hantro_vp8.c | 118 ++ .../verisilicon/rockchip_vpu2_hw_vp8_enc.c | 1574 +++++++++++++++++ .../platform/verisilicon/rockchip_vpu2_regs.h | 1 + .../platform/verisilicon/rockchip_vpu_hw.c | 23 +- drivers/media/v4l2-core/v4l2-ctrls-core.c | 16 + drivers/media/v4l2-core/v4l2-ctrls-defs.c | 5 + include/media/v4l2-ctrls.h | 1 + include/uapi/linux/v4l2-controls.h | 91 + include/uapi/linux/videodev2.h | 3 + 16 files changed, 2041 insertions(+), 6 deletions(-) create mode 100644 drivers/media/platform/verisilicon/hantro_boolenc.c create mode 100644 drivers/media/platform/verisilicon/hantro_boolenc.h create mode 100644 drivers/media/platform/verisilicon/rockchip_vpu2_hw_vp8_enc.c base-commit: c9c3395d5e3dcc6daee66c6908354d47bf98cb0c
Comments
On Thursday, 9 March 2023 13:56:49 CET Andrzej Pietrasiewicz wrote: > Dear All, > > This two-patch series adds uAPI for stateless VP8 encoding > and an accompanying driver using it. > > It has been tested on an rk3399 board and there exists > a gstreamer user: > > https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3736 > > example pipeline: > > gst-launch-1.0 videotestsrc num-buffers=500 ! > video/x-raw,width=640,height=480 \ ! v4l2slvp8enc ! queue ! matroskamux ! > filesink location=test_vp8.mkv > > I kindly ask for comments. > > Notably, the documentation for the added uAPI is missing, > that is to be addressed when sending a patch series proper (not RFC). > > For the RFC I also did not care to replace a BUG_ON() in the boolean > encoder. > > Rebased onto v6.2. > > Regards, > > Andrzej Hello, I can't offer much in terms on technical comments on the implementation, but thank you for your work on this. A more general question: Is the rate control done by the userspace component or the kernel or even the hardware? I tried this patchset (and the gstreamer merge request) out last night and ran into quite noticable i-frame pulsing, and am wondering who the culprit of that is. Looking at the vp8 encode params in the uAPI, it looks like it'll be userspace in charge of rate control? On a related side note, since I let this run all night with different parameters I can happily report that it seems to be quite stable, no problems encountered at all. Kind regards, Nicolas Frattaroli
Hi Nicolas, +Cc Benjamin W dniu 18.03.2023 o 10:20, Nicolas Frattaroli pisze: > On Thursday, 9 March 2023 13:56:49 CET Andrzej Pietrasiewicz wrote: >> Dear All, >> >> This two-patch series adds uAPI for stateless VP8 encoding >> and an accompanying driver using it. >> >> It has been tested on an rk3399 board and there exists >> a gstreamer user: >> >> https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3736 >> >> example pipeline: >> >> gst-launch-1.0 videotestsrc num-buffers=500 ! >> video/x-raw,width=640,height=480 \ ! v4l2slvp8enc ! queue ! matroskamux ! >> filesink location=test_vp8.mkv >> >> I kindly ask for comments. >> >> Notably, the documentation for the added uAPI is missing, >> that is to be addressed when sending a patch series proper (not RFC). >> >> For the RFC I also did not care to replace a BUG_ON() in the boolean >> encoder. >> >> Rebased onto v6.2. >> >> Regards, >> >> Andrzej > > Hello, > > I can't offer much in terms on technical comments on the implementation, > but thank you for your work on this. A more general question: Is the > rate control done by the userspace component or the kernel or even the > hardware? > > I tried this patchset (and the gstreamer merge request) out last night > and ran into quite noticable i-frame pulsing, and am wondering who the > culprit of that is. Looking at the vp8 encode params in the uAPI, it > looks like it'll be userspace in charge of rate control? > Yes, rate control is entirely on userspace. Modern codec specs (not just vp8) only mandate what constitutes a valid bitstream and how do decode it. No word about encoding, which means that actually many different strategies can be applied to produce a valid bitstream. As such, these strategies look a lot like policies which do not belong to the kernel and I'd rather provide a tool than a policy. As far as I know the rate control mechanism used in the gst element is nothing sophisticated, not even a (full) PID algorithm. Which, I think, was exactly intended to get the thing running in the first place. I would assume that the expected algorithm would be PID proper in this case. Specifically, PID being PID will not prevent the encoding stack from overrunning the set bandwidth for short periods of time, but exactly because rate control belongs to userspace anyone is welcome to develop a solution which provides hard bandwidth guarantees. > On a related side note, since I let this run all night with different > parameters I can happily report that it seems to be quite stable, no > problems encountered at all. Thank you for reporting. In the (expected) case this turns into a patchset proper I would kindly ask for your Tested-by then. Can you share what you used for the nightly tests, both in terms of testing harness and unencoded video material? Regards, Andrzej
On Monday, 20 March 2023 11:07:19 CET Andrzej Pietrasiewicz wrote: > Hi Nicolas, > > > W dniu 18.03.2023 o 10:20, Nicolas Frattaroli pisze: > > On a related side note, since I let this run all night with different > > parameters I can happily report that it seems to be quite stable, no > > problems encountered at all. > > Thank you for reporting. In the (expected) case this turns into a > patchset proper I would kindly ask for your Tested-by then. Will do, I'll be closely tracking this patchset and might also throw a patch your way to enable it on RK356x at some point, since that has the same Hantro encode IP as well as far as I know. > Can you share what you used for the nightly tests, both in terms of > testing harness and unencoded video material? The source material I used is the "Original" quality of the short film "Wanderers" by Erik Wernquist: https://vimeo.com/108650530 You can click on "Download" and choose "Original" from there, which gives you a 4:2:2 10-bit Apple ProRes .mov file. It's quite high quality and includes some interesting segments, such as the asteroid field shot, as well as plenty of grain, both of which really stress an encoder. My testing harness is a little primitive, the precise gst pipeline I used is in this command I ran: for i in {0..63}; do echo "q $i"; \ gst-launch-1.0 filesrc location=~/Wanderers.mov ! \ qtdemux name=demux demux.video_0 ! decodebin ! videoconvert ! \ v4l2slvp8enc min-quality=$i max-quality=$i ! queue ! matroskamux ! \ filesink location="/mnt/usb/w2/vp8_wanderers_q_$i.mkv"; done I figured I'd try out all the quantiser levels this way. It is worth noting that the resultant mkv files are somewhat odd, I had to remux them with ffmpeg (with -c:v copy to copy the vp8 bitstream over) to get mpv to seek properly in them and show bitrate information in the stats overlay (shift+i by default). There's probably a gstreamer thing I'm unaware of to make it properly generate the matroska container as well. Either way, not a problem with the encoder, just the muxer. I'm pretty sure videoconvert gets rid of the 4:2:2-ness and 10-bit-ness of it, since I don't think this hardware encoder is capable of handling that, which is fine by me. However, since this does nicely transcode to a 10-bit video with a software encoder of your choice, Collabora might also be interested in using this footage for any upcoming 10-bit patches to the video decode side of things. :) > Regards, > > Andrzej Kind regards, Nicolas Frattaroli