Message ID | 20231004103720.3540436-2-hugues.fruchet@foss.st.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp34722vqb; Wed, 4 Oct 2023 03:38:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEHBPsMkahiXzNgG8JscaWtyObXi9Gtv849zV8o7H7WBcO6TasSMvhlIay4Jj7O6QLfxHW7 X-Received: by 2002:a05:6808:abb:b0:3a7:1962:d7ff with SMTP id r27-20020a0568080abb00b003a71962d7ffmr1881620oij.57.1696415886895; Wed, 04 Oct 2023 03:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696415886; cv=none; d=google.com; s=arc-20160816; b=X13frYyKhZEaSBaaYXWyRJxVlfihUn25zu3oIHFseuzrEGQeL7Nq/I46p02E/qqU5s VbQLpzAfM+qrX2uZHZSOkIPaVBpsTUGN6kn43xf9//DtllxCIyumk8B+T5STjrXjIyLe T3R0TiJC8BmSaqLdqTTiEF4PSY242aIWOzvBhhZVL89MZ4OtSfyjf2Ux0iHEcrDtGDm6 VKCG1ZEvAPMGnRtdtACdohnXa5kioaL7pECk7GKNm1oZ8SE1lPhWW4HpkUMaI5NMvjue pRw6YX8tYt7tOCcOU7/xltlPeasrpWI/dC3pFjin3EEdCd+EMawRVHFkacHy7WiBhk36 wCdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=z7mZwxfo000nV9RjYsAl7O2aw4iXhCX5I97+YBsYwPk=; fh=ErwLDw9+98Mb4Q3i5RoHr7UOS7Ns3CK5YbB+qheGbUs=; b=CfklWT7JkPhaH/N4P+/A1PIdi1i5UKdSYLf8bahYOyX9tpGsBWEgfVNZdDYLWdf14w 5LKiU7xR2MpsCg4rX+OJZUhR+8qlKvQGnQ/VZbChOglEREnz1ZwP6JK7BmwCVTCMzfH3 FzfqE1O8ANzYOkQLvhhiTNMSeDOEHw4NN/jagRO0ar7dIWRnq4W0Ym3wUpUJaGad0+RV 0UqIuX5E4+hC1wYSzE1eCWaqrwefv/IaG2MHzPaV0RTsH8SOT60Z1Pnvl15+J7wnrA2e l0x6YJUFszMTQV2bZHTyUElp5VLA+lsXNhaat31kGji+5ftjS5TfRjjruwX0Keg5ZkVM HRHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=LbXHaCkr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id q184-20020a632ac1000000b00577646e2b6bsi3302568pgq.206.2023.10.04.03.38.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 03:38:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=LbXHaCkr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4E1D181E9A48; Wed, 4 Oct 2023 03:38:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242128AbjJDKiB (ORCPT <rfc822;pusanteemu@gmail.com> + 18 others); Wed, 4 Oct 2023 06:38:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232982AbjJDKh5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 4 Oct 2023 06:37:57 -0400 Received: from mx08-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3917BA1; Wed, 4 Oct 2023 03:37:53 -0700 (PDT) Received: from pps.filterd (m0369457.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 394A3870022388; Wed, 4 Oct 2023 12:37:30 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= selector1; bh=z7mZwxfo000nV9RjYsAl7O2aw4iXhCX5I97+YBsYwPk=; b=Lb XHaCkrv+OuptTlA+Ed2/zsXTOrN+/DtLmmYC9+H6Dd2FvZymJbRO0bN9vfulyAru O36EwPE5rjPq4D3h0Ih1snITE6Qn42Fs0yDZMEV0iqkPufIwX7sYaxhz3u3ZF/io GBhJlaotuagSrapkia8OZuXRjTnAihouHFVMnAHLdIneMFDFKYrggAoU90l60eA4 N0uCDtvXI+XS8LgJD/jDdQuQdowkXv53yBemMF0cX1XGfgORWNc93rWMgDkjoB69 K+OCmZ+Lbu5tPi/j+rYekeks9wXQIn/N1GqzPg1OQ9GIHM+e1IsGSXw9rl6hw5fg ftQxKQrze7J1w2pQCOew== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3texmj69fe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Oct 2023 12:37:30 +0200 (MEST) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id EFDF9100057; Wed, 4 Oct 2023 12:37:28 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id E36E7231518; Wed, 4 Oct 2023 12:37:28 +0200 (CEST) Received: from localhost (10.201.20.120) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 4 Oct 2023 12:37:28 +0200 From: Hugues Fruchet <hugues.fruchet@foss.st.com> To: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>, Philipp Zabel <p.zabel@pengutronix.de>, Andrzej Pietrasiewicz <andrzej.p@collabora.com>, Nicolas Dufresne <nicolas.dufresne@collabora.com>, Sakari Ailus <sakari.ailus@linux.intel.com>, Benjamin Gaignard <benjamin.gaignard@collabora.com>, Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>, Daniel Almeida <daniel.almeida@collabora.com>, Benjamin Mugnier <benjamin.mugnier@foss.st.com>, Heiko Stuebner <heiko@sntech.de>, Mauro Carvalho Chehab <mchehab@kernel.org>, Hans Verkuil <hverkuil@xs4all.nl>, <linux-media@vger.kernel.org>, Maxime Coquelin <mcoquelin.stm32@gmail.com>, Alexandre Torgue <alexandre.torgue@foss.st.com>, <linux-stm32@st-md-mailman.stormreply.com>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, <devicetree@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org>, <linux-rockchip@lists.infradead.org> CC: Hugues Fruchet <hugues.fruchet@foss.st.com>, Marco Felsch <m.felsch@pengutronix.de>, Adam Ford <aford173@gmail.com> Subject: [RFC 1/6] media: uapi: Add VP8 stateless encoder controls Date: Wed, 4 Oct 2023 12:37:15 +0200 Message-ID: <20231004103720.3540436-2-hugues.fruchet@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231004103720.3540436-1-hugues.fruchet@foss.st.com> References: <20231004103720.3540436-1-hugues.fruchet@foss.st.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.201.20.120] X-ClientProxiedBy: SHFCAS1NODE1.st.com (10.75.129.72) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-04_02,2023-10-02_01,2023-05-22_02 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 04 Oct 2023 03:38:06 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778820985369188778 X-GMAIL-MSGID: 1778820985369188778 |
Series |
VP8 H1 stateless encoding
|
|
Commit Message
Hugues Fruchet
Oct. 4, 2023, 10:37 a.m. UTC
From: Andrzej Pietrasiewicz <andrzej.p@collabora.com> Add uAPI for stateless VP8 encoders. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> --- drivers/media/v4l2-core/v4l2-ctrls-core.c | 13 ++++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 5 ++ include/media/v4l2-ctrls.h | 2 + include/uapi/linux/v4l2-controls.h | 91 +++++++++++++++++++++++ include/uapi/linux/videodev2.h | 3 + 5 files changed, 114 insertions(+)
Comments
Few comments. > + if (p_vp8_encode_params->loop_filter_level > 63) > + return -EINVAL; > + > + if (p_vp8_encode_params->sharpness_level > 7) > + return -EINVAL; Can we define these magic numbers 63, 7? > + case V4L2_CID_STATELESS_VP8_ENCODE_QP: return "VP8 Encode QP"; Can we add more details about this CID? Or let me know if I missed it somewhere in the series. > +#define V4L2_CID_STATELESS_VP8_ENCODE_PARAMS (V4L2_CID_CODEC_STATELESS_BASE + 601) Can we put 2 CIDs in the same place? I think it is more readable that way. I also see that was the case for HEVC. https://git.linuxtv.org/media_tree.git/tree/include/uapi/linux/v4l2-controls.h?h=master&id=c91fd7b7a8ae17ab8be0b6e765e4a38783749330#n2062 > + * @loop_filter_level: sets the strength of the applied loop filter. > + * Set to a value from the rage 0..63. typo s/rage/range/ > + * @copy_buffer_to_alternate: specifies the atlref frame refresh strategy. > + * Set to one of V4L2_VP8_FRAME_FLAG_ALTREF_{}. nit: typo s/atlref/altref/ On Wed, Oct 4, 2023 at 3:37 AM Hugues Fruchet <hugues.fruchet@foss.st.com> wrote: > > From: Andrzej Pietrasiewicz <andrzej.p@collabora.com> > > Add uAPI for stateless VP8 encoders. > > Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> > --- > drivers/media/v4l2-core/v4l2-ctrls-core.c | 13 ++++ > drivers/media/v4l2-core/v4l2-ctrls-defs.c | 5 ++ > include/media/v4l2-ctrls.h | 2 + > include/uapi/linux/v4l2-controls.h | 91 +++++++++++++++++++++++ > include/uapi/linux/videodev2.h | 3 + > 5 files changed, 114 insertions(+) > > diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c > index a662fb60f73f..c7799ceb3d6d 100644 > --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c > +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c > @@ -811,6 +811,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, > struct v4l2_ctrl_hevc_pps *p_hevc_pps; > struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering; > struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params; > + struct v4l2_ctrl_vp8_encode_params *p_vp8_encode_params; > struct v4l2_area *area; > void *p = ptr.p + idx * ctrl->elem_size; > unsigned int i; > @@ -1047,6 +1048,15 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, > zero_padding(p_vp8_frame->coder_state); > break; > > + case V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS: > + p_vp8_encode_params = p; > + if (p_vp8_encode_params->loop_filter_level > 63) > + return -EINVAL; > + > + if (p_vp8_encode_params->sharpness_level > 7) > + return -EINVAL; > + break; > + > case V4L2_CTRL_TYPE_HEVC_SPS: > p_hevc_sps = p; > > @@ -1868,6 +1878,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, > case V4L2_CTRL_TYPE_AREA: > elem_size = sizeof(struct v4l2_area); > break; > + case V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS: > + elem_size = sizeof(struct v4l2_ctrl_vp8_encode_params); > + break; > default: > if (type < V4L2_CTRL_COMPOUND_TYPES) > elem_size = sizeof(s32); > diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c > index 8696eb1cdd61..bd26f1d89bd5 100644 > --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c > +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c > @@ -1236,6 +1236,8 @@ const char *v4l2_ctrl_get_name(u32 id) > case V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY: return "AV1 Tile Group Entry"; > case V4L2_CID_STATELESS_AV1_FRAME: return "AV1 Frame Parameters"; > case V4L2_CID_STATELESS_AV1_FILM_GRAIN: return "AV1 Film Grain"; > + case V4L2_CID_STATELESS_VP8_ENCODE_PARAMS: return "VP8 Encode Parameters"; > + case V4L2_CID_STATELESS_VP8_ENCODE_QP: return "VP8 Encode QP"; > > /* Colorimetry controls */ > /* Keep the order of the 'case's the same as in v4l2-controls.h! */ > @@ -1592,6 +1594,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, > case V4L2_CID_STATELESS_AV1_FILM_GRAIN: > *type = V4L2_CTRL_TYPE_AV1_FILM_GRAIN; > break; > + case V4L2_CID_STATELESS_VP8_ENCODE_PARAMS: > + *type = V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS; > + break; > case V4L2_CID_UNIT_CELL_SIZE: > *type = V4L2_CTRL_TYPE_AREA; > *flags |= V4L2_CTRL_FLAG_READ_ONLY; > diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h > index 59679a42b3e7..a165719e1139 100644 > --- a/include/media/v4l2-ctrls.h > +++ b/include/media/v4l2-ctrls.h > @@ -56,6 +56,7 @@ struct video_device; > * @p_av1_tile_group_entry: Pointer to an AV1 tile group entry structure. > * @p_av1_frame: Pointer to an AV1 frame structure. > * @p_av1_film_grain: Pointer to an AV1 film grain structure. > + * @p_vp8_encode_params: Pointer to a VP8 encode parameter structure. > * @p: Pointer to a compound value. > * @p_const: Pointer to a constant compound value. > */ > @@ -89,6 +90,7 @@ union v4l2_ctrl_ptr { > struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry; > struct v4l2_ctrl_av1_frame *p_av1_frame; > struct v4l2_ctrl_av1_film_grain *p_av1_film_grain; > + struct v4l2_ctrl_vp8_encode_params *p_vp8_encode_params; > void *p; > const void *p_const; > }; > diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h > index c3604a0a3e30..fdec5764e09c 100644 > --- a/include/uapi/linux/v4l2-controls.h > +++ b/include/uapi/linux/v4l2-controls.h > @@ -3479,6 +3479,97 @@ struct v4l2_ctrl_av1_film_grain { > __u8 reserved[4]; > }; > > +#define V4L2_CID_STATELESS_VP8_ENCODE_PARAMS (V4L2_CID_CODEC_STATELESS_BASE + 601) > + > +#define V4L2_VP8_FRAME_FLAG_SHOWFRAME 0x1 > +#define V4L2_VP8_FRAME_FLAG_GOLDEN_REFRESH 0x2 > +#define V4L2_VP8_FRAME_FLAG_ALTREF_REFRESH 0x4 > +#define V4L2_VP8_FRAME_FLAG_SEGMENT_ENABLED 0x8 > +#define V4L2_VP8_FRAME_FLAG_LOOP_FILTER_ADJ_ENABLED 0x10 > +#define V4L2_VP8_FRAME_FLAG_REFRESH_ENTROPY_PROBS 0x20 > + > +#define V4L2_VP8_FRAME_TYPE_KEYFRAME 0 > +#define V4L2_VP8_FRAME_TYPE_INTER 1 > + > +#define V4L2_VP8_FRAME_COLOR_SPACE_YUV 0 > +#define V4L2_VP8_FRAME_COLOR_SPACE_RESERVED 1 > + > +#define V4L2_VP8_FRAME_CLAMPING_REQUIRED 0 > +#define V4L2_VP8_FRAME_CLAMPING_NO 1 > + > +#define V4L2_VP8_FRAME_FILTER_TYPE_NORMAL 0 > +#define V4L2_VP8_FRAME_FILTER_TYPE_SIMPLE 1 > + > +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_1 0 > +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_2 1 > +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_4 2 > +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_8 3 > + > +#define V4L2_VP8_FRAME_GOLDEN_KEEP 0 > +#define V4L2_VP8_FRAME_GOLDEN_LASTFRAME 1 > +#define V4L2_VP8_FRAME_GOLDEN_ALTREF 2 > + > +#define V4L2_VP8_FRAME_ALTREF_KEEP 0 > +#define V4L2_VP8_FRAME_ALTREF_LASTFRAME 1 > +#define V4L2_VP8_FRAME_ALTREF_GOLDEN 2 > + > +#define V4L2_VP8_FRAME_REF_LAST 0 > +#define V4L2_VP8_FRAME_REF_GOLDEN 1 > +#define V4L2_VP8_FRAME_REF_ALT 2 > + > +/** > + * struct v4l2_ctrl_vp8_encode_params - VP8 encode parameters > + * @flags: combination of V4L2_VP8_FRAME_FLAG_{} flags. > + * @frame_type: specifies the frame type (key or inter). > + * Set to one of V4L2_VP8_FRAME_TYPE_{}. > + * @color_space: defines the YUV color space of the sequence. > + * V4L2_VP8_FRAME_TYPE_INTER frames shall set this field to zero. > + * Set to one of V4L2_VP8_FRAME_COLOR_SPACE_{}. > + * @clamping_type: defines pixel value clamping type. > + * V4L2_VP8_FRAME_TYPE_INTER frames shall set this field to zero. > + * Set to one of V4L2_VP8_FRAME_CLAMPING_{}. > + * @loop_filter_type: selects the type of loop filter applied. > + * Set to one of V4L2_VP8_FRAME_FILTER_TYPE_{}. > + * @loop_filter_level: sets the strength of the applied loop filter. > + * Set to a value from the rage 0..63. > + * @sharpness_level: sets the sharpness of the applied loop filter. > + * Set to a value from the range 0..7. > + * @log2_nbr_of_dct_partitions: determines the number of separate partitions > + * containing the DCT coefficients of macroblocks. > + * Set to one of V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_{}. > + * @prob_intra: indicates the probability of an intra macroblock. > + * Set to a value from the range 0..255. > + * @prob_last: indicates the probability that the last reference frame is used for inter-prediction. > + * Set to a value from the range 0..255. > + * @prob_gf: indicates the probability that the golden reference frame is used for inter-prediction. > + * Set to a value from the range 0..255. > + * @copy_buffer_to_golden: specifies the golden frame refresh strategy. > + * Set to one of V4L2_VP8_FRAME_FLAG_GOLDEN_{}. > + * @copy_buffer_to_alternate: specifies the atlref frame refresh strategy. > + * Set to one of V4L2_VP8_FRAME_FLAG_ALTREF_{}. > + * @reference_type: specifies what kind of reference to use for current inter frame. > + * V4L2_VP8_FRAME_TYPE_KEYFRAME shall set this field to zero. > + * Set to one of V4L2_VP8_FRAME_REF_{}. > + */ > +struct v4l2_ctrl_vp8_encode_params { > + __u32 flags; > + __u8 frame_type; > + __u8 color_space; > + __u8 clamping_type; > + __u8 loop_filter_type; > + __u8 loop_filter_level; > + __u8 sharpness_level; > + __u8 log2_nbr_of_dct_partitions; > + __u8 prob_intra; > + __u8 prob_last; > + __u8 prob_gf; > + __u8 copy_buffer_to_golden; > + __u8 copy_buffer_to_alternate; > + __u8 reference_type; > +}; > + > +#define V4L2_CID_STATELESS_VP8_ENCODE_QP (V4L2_CID_CODEC_STATELESS_BASE + 602) > + > /* MPEG-compression definitions kept for backwards compatibility */ > #ifndef __KERNEL__ > #define V4L2_CTRL_CLASS_MPEG V4L2_CTRL_CLASS_CODEC > diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h > index 78260e5d9985..b3cbdc60b82c 100644 > --- a/include/uapi/linux/videodev2.h > +++ b/include/uapi/linux/videodev2.h > @@ -1836,6 +1836,7 @@ struct v4l2_ext_control { > struct v4l2_ctrl_av1_tile_group_entry __user *p_av1_tile_group_entry; > struct v4l2_ctrl_av1_frame __user *p_av1_frame; > struct v4l2_ctrl_av1_film_grain __user *p_av1_film_grain; > + struct v4l2_ctrl_vp8_encode_params __user *p_vp8_encode_params; > void __user *ptr; > }; > } __attribute__ ((packed)); > @@ -1914,6 +1915,8 @@ enum v4l2_ctrl_type { > V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY = 0x281, > V4L2_CTRL_TYPE_AV1_FRAME = 0x282, > V4L2_CTRL_TYPE_AV1_FILM_GRAIN = 0x283, > + > + V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS = 0x0290, > }; > > /* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ > -- > 2.25.1 >
Hi Steve, Thanks for looking into it, W dniu 14.11.2023 o 23:19, Steve Cho pisze: > Few comments. > >> + if (p_vp8_encode_params->loop_filter_level > 63) >> + return -EINVAL; >> + >> + if (p_vp8_encode_params->sharpness_level > 7) >> + return -EINVAL; > > Can we define these magic numbers 63, 7? ok > > >> + case V4L2_CID_STATELESS_VP8_ENCODE_QP: return "VP8 Encode QP"; > > Can we add more details about this CID? Or let me know if I missed it > somewhere in the series. The documenation was missing indeed, which was mentioned in the cover letter. > > >> +#define V4L2_CID_STATELESS_VP8_ENCODE_PARAMS (V4L2_CID_CODEC_STATELESS_BASE + 601) > > Can we put 2 CIDs in the same place? I think it is more readable that > way. I also see that was the case for HEVC. > https://git.linuxtv.org/media_tree.git/tree/include/uapi/linux/v4l2-controls.h?h=master&id=c91fd7b7a8ae17ab8be0b6e765e4a38783749330#n2062 If there's "prior art" for that, I see no objections. > > >> + * @loop_filter_level: sets the strength of the applied loop filter. >> + * Set to a value from the rage 0..63. > > typo s/rage/range/ Thanks for spotting it, this rage should be stopped ;) > > >> + * @copy_buffer_to_alternate: specifies the atlref frame refresh strategy. >> + * Set to one of V4L2_VP8_FRAME_FLAG_ALTREF_{}. > > nit: typo s/atlref/altref/ Thanks! Regards, Andrzej > > On Wed, Oct 4, 2023 at 3:37 AM Hugues Fruchet > <hugues.fruchet@foss.st.com> wrote: >> >> From: Andrzej Pietrasiewicz <andrzej.p@collabora.com> >> >> Add uAPI for stateless VP8 encoders. >> >> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> >> --- >> drivers/media/v4l2-core/v4l2-ctrls-core.c | 13 ++++ >> drivers/media/v4l2-core/v4l2-ctrls-defs.c | 5 ++ >> include/media/v4l2-ctrls.h | 2 + >> include/uapi/linux/v4l2-controls.h | 91 +++++++++++++++++++++++ >> include/uapi/linux/videodev2.h | 3 + >> 5 files changed, 114 insertions(+) >> >> diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c >> index a662fb60f73f..c7799ceb3d6d 100644 >> --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c >> +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c >> @@ -811,6 +811,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, >> struct v4l2_ctrl_hevc_pps *p_hevc_pps; >> struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering; >> struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params; >> + struct v4l2_ctrl_vp8_encode_params *p_vp8_encode_params; >> struct v4l2_area *area; >> void *p = ptr.p + idx * ctrl->elem_size; >> unsigned int i; >> @@ -1047,6 +1048,15 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, >> zero_padding(p_vp8_frame->coder_state); >> break; >> >> + case V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS: >> + p_vp8_encode_params = p; >> + if (p_vp8_encode_params->loop_filter_level > 63) >> + return -EINVAL; >> + >> + if (p_vp8_encode_params->sharpness_level > 7) >> + return -EINVAL; >> + break; >> + >> case V4L2_CTRL_TYPE_HEVC_SPS: >> p_hevc_sps = p; >> >> @@ -1868,6 +1878,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, >> case V4L2_CTRL_TYPE_AREA: >> elem_size = sizeof(struct v4l2_area); >> break; >> + case V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS: >> + elem_size = sizeof(struct v4l2_ctrl_vp8_encode_params); >> + break; >> default: >> if (type < V4L2_CTRL_COMPOUND_TYPES) >> elem_size = sizeof(s32); >> diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c >> index 8696eb1cdd61..bd26f1d89bd5 100644 >> --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c >> +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c >> @@ -1236,6 +1236,8 @@ const char *v4l2_ctrl_get_name(u32 id) >> case V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY: return "AV1 Tile Group Entry"; >> case V4L2_CID_STATELESS_AV1_FRAME: return "AV1 Frame Parameters"; >> case V4L2_CID_STATELESS_AV1_FILM_GRAIN: return "AV1 Film Grain"; >> + case V4L2_CID_STATELESS_VP8_ENCODE_PARAMS: return "VP8 Encode Parameters"; >> + case V4L2_CID_STATELESS_VP8_ENCODE_QP: return "VP8 Encode QP"; >> >> /* Colorimetry controls */ >> /* Keep the order of the 'case's the same as in v4l2-controls.h! */ >> @@ -1592,6 +1594,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, >> case V4L2_CID_STATELESS_AV1_FILM_GRAIN: >> *type = V4L2_CTRL_TYPE_AV1_FILM_GRAIN; >> break; >> + case V4L2_CID_STATELESS_VP8_ENCODE_PARAMS: >> + *type = V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS; >> + break; >> case V4L2_CID_UNIT_CELL_SIZE: >> *type = V4L2_CTRL_TYPE_AREA; >> *flags |= V4L2_CTRL_FLAG_READ_ONLY; >> diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h >> index 59679a42b3e7..a165719e1139 100644 >> --- a/include/media/v4l2-ctrls.h >> +++ b/include/media/v4l2-ctrls.h >> @@ -56,6 +56,7 @@ struct video_device; >> * @p_av1_tile_group_entry: Pointer to an AV1 tile group entry structure. >> * @p_av1_frame: Pointer to an AV1 frame structure. >> * @p_av1_film_grain: Pointer to an AV1 film grain structure. >> + * @p_vp8_encode_params: Pointer to a VP8 encode parameter structure. >> * @p: Pointer to a compound value. >> * @p_const: Pointer to a constant compound value. >> */ >> @@ -89,6 +90,7 @@ union v4l2_ctrl_ptr { >> struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry; >> struct v4l2_ctrl_av1_frame *p_av1_frame; >> struct v4l2_ctrl_av1_film_grain *p_av1_film_grain; >> + struct v4l2_ctrl_vp8_encode_params *p_vp8_encode_params; >> void *p; >> const void *p_const; >> }; >> diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h >> index c3604a0a3e30..fdec5764e09c 100644 >> --- a/include/uapi/linux/v4l2-controls.h >> +++ b/include/uapi/linux/v4l2-controls.h >> @@ -3479,6 +3479,97 @@ struct v4l2_ctrl_av1_film_grain { >> __u8 reserved[4]; >> }; >> >> +#define V4L2_CID_STATELESS_VP8_ENCODE_PARAMS (V4L2_CID_CODEC_STATELESS_BASE + 601) >> + >> +#define V4L2_VP8_FRAME_FLAG_SHOWFRAME 0x1 >> +#define V4L2_VP8_FRAME_FLAG_GOLDEN_REFRESH 0x2 >> +#define V4L2_VP8_FRAME_FLAG_ALTREF_REFRESH 0x4 >> +#define V4L2_VP8_FRAME_FLAG_SEGMENT_ENABLED 0x8 >> +#define V4L2_VP8_FRAME_FLAG_LOOP_FILTER_ADJ_ENABLED 0x10 >> +#define V4L2_VP8_FRAME_FLAG_REFRESH_ENTROPY_PROBS 0x20 >> + >> +#define V4L2_VP8_FRAME_TYPE_KEYFRAME 0 >> +#define V4L2_VP8_FRAME_TYPE_INTER 1 >> + >> +#define V4L2_VP8_FRAME_COLOR_SPACE_YUV 0 >> +#define V4L2_VP8_FRAME_COLOR_SPACE_RESERVED 1 >> + >> +#define V4L2_VP8_FRAME_CLAMPING_REQUIRED 0 >> +#define V4L2_VP8_FRAME_CLAMPING_NO 1 >> + >> +#define V4L2_VP8_FRAME_FILTER_TYPE_NORMAL 0 >> +#define V4L2_VP8_FRAME_FILTER_TYPE_SIMPLE 1 >> + >> +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_1 0 >> +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_2 1 >> +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_4 2 >> +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_8 3 >> + >> +#define V4L2_VP8_FRAME_GOLDEN_KEEP 0 >> +#define V4L2_VP8_FRAME_GOLDEN_LASTFRAME 1 >> +#define V4L2_VP8_FRAME_GOLDEN_ALTREF 2 >> + >> +#define V4L2_VP8_FRAME_ALTREF_KEEP 0 >> +#define V4L2_VP8_FRAME_ALTREF_LASTFRAME 1 >> +#define V4L2_VP8_FRAME_ALTREF_GOLDEN 2 >> + >> +#define V4L2_VP8_FRAME_REF_LAST 0 >> +#define V4L2_VP8_FRAME_REF_GOLDEN 1 >> +#define V4L2_VP8_FRAME_REF_ALT 2 >> + >> +/** >> + * struct v4l2_ctrl_vp8_encode_params - VP8 encode parameters >> + * @flags: combination of V4L2_VP8_FRAME_FLAG_{} flags. >> + * @frame_type: specifies the frame type (key or inter). >> + * Set to one of V4L2_VP8_FRAME_TYPE_{}. >> + * @color_space: defines the YUV color space of the sequence. >> + * V4L2_VP8_FRAME_TYPE_INTER frames shall set this field to zero. >> + * Set to one of V4L2_VP8_FRAME_COLOR_SPACE_{}. >> + * @clamping_type: defines pixel value clamping type. >> + * V4L2_VP8_FRAME_TYPE_INTER frames shall set this field to zero. >> + * Set to one of V4L2_VP8_FRAME_CLAMPING_{}. >> + * @loop_filter_type: selects the type of loop filter applied. >> + * Set to one of V4L2_VP8_FRAME_FILTER_TYPE_{}. >> + * @loop_filter_level: sets the strength of the applied loop filter. >> + * Set to a value from the rage 0..63. >> + * @sharpness_level: sets the sharpness of the applied loop filter. >> + * Set to a value from the range 0..7. >> + * @log2_nbr_of_dct_partitions: determines the number of separate partitions >> + * containing the DCT coefficients of macroblocks. >> + * Set to one of V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_{}. >> + * @prob_intra: indicates the probability of an intra macroblock. >> + * Set to a value from the range 0..255. >> + * @prob_last: indicates the probability that the last reference frame is used for inter-prediction. >> + * Set to a value from the range 0..255. >> + * @prob_gf: indicates the probability that the golden reference frame is used for inter-prediction. >> + * Set to a value from the range 0..255. >> + * @copy_buffer_to_golden: specifies the golden frame refresh strategy. >> + * Set to one of V4L2_VP8_FRAME_FLAG_GOLDEN_{}. >> + * @copy_buffer_to_alternate: specifies the atlref frame refresh strategy. >> + * Set to one of V4L2_VP8_FRAME_FLAG_ALTREF_{}. >> + * @reference_type: specifies what kind of reference to use for current inter frame. >> + * V4L2_VP8_FRAME_TYPE_KEYFRAME shall set this field to zero. >> + * Set to one of V4L2_VP8_FRAME_REF_{}. >> + */ >> +struct v4l2_ctrl_vp8_encode_params { >> + __u32 flags; >> + __u8 frame_type; >> + __u8 color_space; >> + __u8 clamping_type; >> + __u8 loop_filter_type; >> + __u8 loop_filter_level; >> + __u8 sharpness_level; >> + __u8 log2_nbr_of_dct_partitions; >> + __u8 prob_intra; >> + __u8 prob_last; >> + __u8 prob_gf; >> + __u8 copy_buffer_to_golden; >> + __u8 copy_buffer_to_alternate; >> + __u8 reference_type; >> +}; >> + >> +#define V4L2_CID_STATELESS_VP8_ENCODE_QP (V4L2_CID_CODEC_STATELESS_BASE + 602) >> + >> /* MPEG-compression definitions kept for backwards compatibility */ >> #ifndef __KERNEL__ >> #define V4L2_CTRL_CLASS_MPEG V4L2_CTRL_CLASS_CODEC >> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h >> index 78260e5d9985..b3cbdc60b82c 100644 >> --- a/include/uapi/linux/videodev2.h >> +++ b/include/uapi/linux/videodev2.h >> @@ -1836,6 +1836,7 @@ struct v4l2_ext_control { >> struct v4l2_ctrl_av1_tile_group_entry __user *p_av1_tile_group_entry; >> struct v4l2_ctrl_av1_frame __user *p_av1_frame; >> struct v4l2_ctrl_av1_film_grain __user *p_av1_film_grain; >> + struct v4l2_ctrl_vp8_encode_params __user *p_vp8_encode_params; >> void __user *ptr; >> }; >> } __attribute__ ((packed)); >> @@ -1914,6 +1915,8 @@ enum v4l2_ctrl_type { >> V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY = 0x281, >> V4L2_CTRL_TYPE_AV1_FRAME = 0x282, >> V4L2_CTRL_TYPE_AV1_FILM_GRAIN = 0x283, >> + >> + V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS = 0x0290, >> }; >> >> /* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ >> -- >> 2.25.1 >>
Thank you Andrzej for the follow up! On Mon, Nov 20, 2023 at 8:43 AM Andrzej Pietrasiewicz <andrzej.p@collabora.com> wrote: > > Hi Steve, > > Thanks for looking into it, > > W dniu 14.11.2023 o 23:19, Steve Cho pisze: > > Few comments. > > > >> + if (p_vp8_encode_params->loop_filter_level > 63) > >> + return -EINVAL; > >> + > >> + if (p_vp8_encode_params->sharpness_level > 7) > >> + return -EINVAL; > > > > Can we define these magic numbers 63, 7? > > ok > > > > > > >> + case V4L2_CID_STATELESS_VP8_ENCODE_QP: return "VP8 Encode QP"; > > > > Can we add more details about this CID? Or let me know if I missed it > > somewhere in the series. > > The documenation was missing indeed, which was mentioned in the cover letter. > > > > > > >> +#define V4L2_CID_STATELESS_VP8_ENCODE_PARAMS (V4L2_CID_CODEC_STATELESS_BASE + 601) > > > > Can we put 2 CIDs in the same place? I think it is more readable that > > way. I also see that was the case for HEVC. > > https://git.linuxtv.org/media_tree.git/tree/include/uapi/linux/v4l2-controls.h?h=master&id=c91fd7b7a8ae17ab8be0b6e765e4a38783749330#n2062 > > If there's "prior art" for that, I see no objections. > > > > > > >> + * @loop_filter_level: sets the strength of the applied loop filter. > >> + * Set to a value from the rage 0..63. > > > > typo s/rage/range/ > > Thanks for spotting it, this rage should be stopped ;) > > > > > > >> + * @copy_buffer_to_alternate: specifies the atlref frame refresh strategy. > >> + * Set to one of V4L2_VP8_FRAME_FLAG_ALTREF_{}. > > > > nit: typo s/atlref/altref/ > > Thanks! > > Regards, > > Andrzej > > > > > On Wed, Oct 4, 2023 at 3:37 AM Hugues Fruchet > > <hugues.fruchet@foss.st.com> wrote: > >> > >> From: Andrzej Pietrasiewicz <andrzej.p@collabora.com> > >> > >> Add uAPI for stateless VP8 encoders. > >> > >> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> > >> --- > >> drivers/media/v4l2-core/v4l2-ctrls-core.c | 13 ++++ > >> drivers/media/v4l2-core/v4l2-ctrls-defs.c | 5 ++ > >> include/media/v4l2-ctrls.h | 2 + > >> include/uapi/linux/v4l2-controls.h | 91 +++++++++++++++++++++++ > >> include/uapi/linux/videodev2.h | 3 + > >> 5 files changed, 114 insertions(+) > >> > >> diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c > >> index a662fb60f73f..c7799ceb3d6d 100644 > >> --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c > >> +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c > >> @@ -811,6 +811,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, > >> struct v4l2_ctrl_hevc_pps *p_hevc_pps; > >> struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering; > >> struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params; > >> + struct v4l2_ctrl_vp8_encode_params *p_vp8_encode_params; > >> struct v4l2_area *area; > >> void *p = ptr.p + idx * ctrl->elem_size; > >> unsigned int i; > >> @@ -1047,6 +1048,15 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, > >> zero_padding(p_vp8_frame->coder_state); > >> break; > >> > >> + case V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS: > >> + p_vp8_encode_params = p; > >> + if (p_vp8_encode_params->loop_filter_level > 63) > >> + return -EINVAL; > >> + > >> + if (p_vp8_encode_params->sharpness_level > 7) > >> + return -EINVAL; > >> + break; > >> + > >> case V4L2_CTRL_TYPE_HEVC_SPS: > >> p_hevc_sps = p; > >> > >> @@ -1868,6 +1878,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, > >> case V4L2_CTRL_TYPE_AREA: > >> elem_size = sizeof(struct v4l2_area); > >> break; > >> + case V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS: > >> + elem_size = sizeof(struct v4l2_ctrl_vp8_encode_params); > >> + break; > >> default: > >> if (type < V4L2_CTRL_COMPOUND_TYPES) > >> elem_size = sizeof(s32); > >> diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c > >> index 8696eb1cdd61..bd26f1d89bd5 100644 > >> --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c > >> +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c > >> @@ -1236,6 +1236,8 @@ const char *v4l2_ctrl_get_name(u32 id) > >> case V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY: return "AV1 Tile Group Entry"; > >> case V4L2_CID_STATELESS_AV1_FRAME: return "AV1 Frame Parameters"; > >> case V4L2_CID_STATELESS_AV1_FILM_GRAIN: return "AV1 Film Grain"; > >> + case V4L2_CID_STATELESS_VP8_ENCODE_PARAMS: return "VP8 Encode Parameters"; > >> + case V4L2_CID_STATELESS_VP8_ENCODE_QP: return "VP8 Encode QP"; > >> > >> /* Colorimetry controls */ > >> /* Keep the order of the 'case's the same as in v4l2-controls.h! */ > >> @@ -1592,6 +1594,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, > >> case V4L2_CID_STATELESS_AV1_FILM_GRAIN: > >> *type = V4L2_CTRL_TYPE_AV1_FILM_GRAIN; > >> break; > >> + case V4L2_CID_STATELESS_VP8_ENCODE_PARAMS: > >> + *type = V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS; > >> + break; > >> case V4L2_CID_UNIT_CELL_SIZE: > >> *type = V4L2_CTRL_TYPE_AREA; > >> *flags |= V4L2_CTRL_FLAG_READ_ONLY; > >> diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h > >> index 59679a42b3e7..a165719e1139 100644 > >> --- a/include/media/v4l2-ctrls.h > >> +++ b/include/media/v4l2-ctrls.h > >> @@ -56,6 +56,7 @@ struct video_device; > >> * @p_av1_tile_group_entry: Pointer to an AV1 tile group entry structure. > >> * @p_av1_frame: Pointer to an AV1 frame structure. > >> * @p_av1_film_grain: Pointer to an AV1 film grain structure. > >> + * @p_vp8_encode_params: Pointer to a VP8 encode parameter structure. > >> * @p: Pointer to a compound value. > >> * @p_const: Pointer to a constant compound value. > >> */ > >> @@ -89,6 +90,7 @@ union v4l2_ctrl_ptr { > >> struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry; > >> struct v4l2_ctrl_av1_frame *p_av1_frame; > >> struct v4l2_ctrl_av1_film_grain *p_av1_film_grain; > >> + struct v4l2_ctrl_vp8_encode_params *p_vp8_encode_params; > >> void *p; > >> const void *p_const; > >> }; > >> diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h > >> index c3604a0a3e30..fdec5764e09c 100644 > >> --- a/include/uapi/linux/v4l2-controls.h > >> +++ b/include/uapi/linux/v4l2-controls.h > >> @@ -3479,6 +3479,97 @@ struct v4l2_ctrl_av1_film_grain { > >> __u8 reserved[4]; > >> }; > >> > >> +#define V4L2_CID_STATELESS_VP8_ENCODE_PARAMS (V4L2_CID_CODEC_STATELESS_BASE + 601) > >> + > >> +#define V4L2_VP8_FRAME_FLAG_SHOWFRAME 0x1 > >> +#define V4L2_VP8_FRAME_FLAG_GOLDEN_REFRESH 0x2 > >> +#define V4L2_VP8_FRAME_FLAG_ALTREF_REFRESH 0x4 > >> +#define V4L2_VP8_FRAME_FLAG_SEGMENT_ENABLED 0x8 > >> +#define V4L2_VP8_FRAME_FLAG_LOOP_FILTER_ADJ_ENABLED 0x10 > >> +#define V4L2_VP8_FRAME_FLAG_REFRESH_ENTROPY_PROBS 0x20 > >> + > >> +#define V4L2_VP8_FRAME_TYPE_KEYFRAME 0 > >> +#define V4L2_VP8_FRAME_TYPE_INTER 1 > >> + > >> +#define V4L2_VP8_FRAME_COLOR_SPACE_YUV 0 > >> +#define V4L2_VP8_FRAME_COLOR_SPACE_RESERVED 1 > >> + > >> +#define V4L2_VP8_FRAME_CLAMPING_REQUIRED 0 > >> +#define V4L2_VP8_FRAME_CLAMPING_NO 1 > >> + > >> +#define V4L2_VP8_FRAME_FILTER_TYPE_NORMAL 0 > >> +#define V4L2_VP8_FRAME_FILTER_TYPE_SIMPLE 1 > >> + > >> +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_1 0 > >> +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_2 1 > >> +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_4 2 > >> +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_8 3 > >> + > >> +#define V4L2_VP8_FRAME_GOLDEN_KEEP 0 > >> +#define V4L2_VP8_FRAME_GOLDEN_LASTFRAME 1 > >> +#define V4L2_VP8_FRAME_GOLDEN_ALTREF 2 > >> + > >> +#define V4L2_VP8_FRAME_ALTREF_KEEP 0 > >> +#define V4L2_VP8_FRAME_ALTREF_LASTFRAME 1 > >> +#define V4L2_VP8_FRAME_ALTREF_GOLDEN 2 > >> + > >> +#define V4L2_VP8_FRAME_REF_LAST 0 > >> +#define V4L2_VP8_FRAME_REF_GOLDEN 1 > >> +#define V4L2_VP8_FRAME_REF_ALT 2 > >> + > >> +/** > >> + * struct v4l2_ctrl_vp8_encode_params - VP8 encode parameters > >> + * @flags: combination of V4L2_VP8_FRAME_FLAG_{} flags. > >> + * @frame_type: specifies the frame type (key or inter). > >> + * Set to one of V4L2_VP8_FRAME_TYPE_{}. > >> + * @color_space: defines the YUV color space of the sequence. > >> + * V4L2_VP8_FRAME_TYPE_INTER frames shall set this field to zero. > >> + * Set to one of V4L2_VP8_FRAME_COLOR_SPACE_{}. > >> + * @clamping_type: defines pixel value clamping type. > >> + * V4L2_VP8_FRAME_TYPE_INTER frames shall set this field to zero. > >> + * Set to one of V4L2_VP8_FRAME_CLAMPING_{}. > >> + * @loop_filter_type: selects the type of loop filter applied. > >> + * Set to one of V4L2_VP8_FRAME_FILTER_TYPE_{}. > >> + * @loop_filter_level: sets the strength of the applied loop filter. > >> + * Set to a value from the rage 0..63. > >> + * @sharpness_level: sets the sharpness of the applied loop filter. > >> + * Set to a value from the range 0..7. > >> + * @log2_nbr_of_dct_partitions: determines the number of separate partitions > >> + * containing the DCT coefficients of macroblocks. > >> + * Set to one of V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_{}. > >> + * @prob_intra: indicates the probability of an intra macroblock. > >> + * Set to a value from the range 0..255. > >> + * @prob_last: indicates the probability that the last reference frame is used for inter-prediction. > >> + * Set to a value from the range 0..255. > >> + * @prob_gf: indicates the probability that the golden reference frame is used for inter-prediction. > >> + * Set to a value from the range 0..255. > >> + * @copy_buffer_to_golden: specifies the golden frame refresh strategy. > >> + * Set to one of V4L2_VP8_FRAME_FLAG_GOLDEN_{}. > >> + * @copy_buffer_to_alternate: specifies the atlref frame refresh strategy. > >> + * Set to one of V4L2_VP8_FRAME_FLAG_ALTREF_{}. > >> + * @reference_type: specifies what kind of reference to use for current inter frame. > >> + * V4L2_VP8_FRAME_TYPE_KEYFRAME shall set this field to zero. > >> + * Set to one of V4L2_VP8_FRAME_REF_{}. > >> + */ > >> +struct v4l2_ctrl_vp8_encode_params { > >> + __u32 flags; > >> + __u8 frame_type; > >> + __u8 color_space; > >> + __u8 clamping_type; > >> + __u8 loop_filter_type; > >> + __u8 loop_filter_level; > >> + __u8 sharpness_level; > >> + __u8 log2_nbr_of_dct_partitions; > >> + __u8 prob_intra; > >> + __u8 prob_last; > >> + __u8 prob_gf; > >> + __u8 copy_buffer_to_golden; > >> + __u8 copy_buffer_to_alternate; > >> + __u8 reference_type; > >> +}; > >> + > >> +#define V4L2_CID_STATELESS_VP8_ENCODE_QP (V4L2_CID_CODEC_STATELESS_BASE + 602) > >> + > >> /* MPEG-compression definitions kept for backwards compatibility */ > >> #ifndef __KERNEL__ > >> #define V4L2_CTRL_CLASS_MPEG V4L2_CTRL_CLASS_CODEC > >> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h > >> index 78260e5d9985..b3cbdc60b82c 100644 > >> --- a/include/uapi/linux/videodev2.h > >> +++ b/include/uapi/linux/videodev2.h > >> @@ -1836,6 +1836,7 @@ struct v4l2_ext_control { > >> struct v4l2_ctrl_av1_tile_group_entry __user *p_av1_tile_group_entry; > >> struct v4l2_ctrl_av1_frame __user *p_av1_frame; > >> struct v4l2_ctrl_av1_film_grain __user *p_av1_film_grain; > >> + struct v4l2_ctrl_vp8_encode_params __user *p_vp8_encode_params; > >> void __user *ptr; > >> }; > >> } __attribute__ ((packed)); > >> @@ -1914,6 +1915,8 @@ enum v4l2_ctrl_type { > >> V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY = 0x281, > >> V4L2_CTRL_TYPE_AV1_FRAME = 0x282, > >> V4L2_CTRL_TYPE_AV1_FILM_GRAIN = 0x283, > >> + > >> + V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS = 0x0290, > >> }; > >> > >> /* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ > >> -- > >> 2.25.1 > >> >
On Wed, Oct 04, 2023 at 12:37:15PM +0200, Hugues Fruchet wrote: > From: Andrzej Pietrasiewicz <andrzej.p@collabora.com> > > Add uAPI for stateless VP8 encoders. > > Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> > --- > drivers/media/v4l2-core/v4l2-ctrls-core.c | 13 ++++ > drivers/media/v4l2-core/v4l2-ctrls-defs.c | 5 ++ > include/media/v4l2-ctrls.h | 2 + > include/uapi/linux/v4l2-controls.h | 91 +++++++++++++++++++++++ > include/uapi/linux/videodev2.h | 3 + > 5 files changed, 114 insertions(+) > > diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c > index a662fb60f73f..c7799ceb3d6d 100644 > --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c > +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c > @@ -811,6 +811,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, > struct v4l2_ctrl_hevc_pps *p_hevc_pps; > struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering; > struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params; > + struct v4l2_ctrl_vp8_encode_params *p_vp8_encode_params; > struct v4l2_area *area; > void *p = ptr.p + idx * ctrl->elem_size; > unsigned int i; > @@ -1047,6 +1048,15 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, > zero_padding(p_vp8_frame->coder_state); > break; > > + case V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS: > + p_vp8_encode_params = p; > + if (p_vp8_encode_params->loop_filter_level > 63) > + return -EINVAL; > + > + if (p_vp8_encode_params->sharpness_level > 7) > + return -EINVAL; > + break; > + > case V4L2_CTRL_TYPE_HEVC_SPS: > p_hevc_sps = p; > > @@ -1868,6 +1878,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, > case V4L2_CTRL_TYPE_AREA: > elem_size = sizeof(struct v4l2_area); > break; > + case V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS: > + elem_size = sizeof(struct v4l2_ctrl_vp8_encode_params); > + break; > default: > if (type < V4L2_CTRL_COMPOUND_TYPES) > elem_size = sizeof(s32); > diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c > index 8696eb1cdd61..bd26f1d89bd5 100644 > --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c > +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c > @@ -1236,6 +1236,8 @@ const char *v4l2_ctrl_get_name(u32 id) > case V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY: return "AV1 Tile Group Entry"; > case V4L2_CID_STATELESS_AV1_FRAME: return "AV1 Frame Parameters"; > case V4L2_CID_STATELESS_AV1_FILM_GRAIN: return "AV1 Film Grain"; > + case V4L2_CID_STATELESS_VP8_ENCODE_PARAMS: return "VP8 Encode Parameters"; > + case V4L2_CID_STATELESS_VP8_ENCODE_QP: return "VP8 Encode QP"; > > /* Colorimetry controls */ > /* Keep the order of the 'case's the same as in v4l2-controls.h! */ > @@ -1592,6 +1594,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, > case V4L2_CID_STATELESS_AV1_FILM_GRAIN: > *type = V4L2_CTRL_TYPE_AV1_FILM_GRAIN; > break; > + case V4L2_CID_STATELESS_VP8_ENCODE_PARAMS: > + *type = V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS; > + break; > case V4L2_CID_UNIT_CELL_SIZE: > *type = V4L2_CTRL_TYPE_AREA; > *flags |= V4L2_CTRL_FLAG_READ_ONLY; > diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h > index 59679a42b3e7..a165719e1139 100644 > --- a/include/media/v4l2-ctrls.h > +++ b/include/media/v4l2-ctrls.h > @@ -56,6 +56,7 @@ struct video_device; > * @p_av1_tile_group_entry: Pointer to an AV1 tile group entry structure. > * @p_av1_frame: Pointer to an AV1 frame structure. > * @p_av1_film_grain: Pointer to an AV1 film grain structure. > + * @p_vp8_encode_params: Pointer to a VP8 encode parameter structure. > * @p: Pointer to a compound value. > * @p_const: Pointer to a constant compound value. > */ > @@ -89,6 +90,7 @@ union v4l2_ctrl_ptr { > struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry; > struct v4l2_ctrl_av1_frame *p_av1_frame; > struct v4l2_ctrl_av1_film_grain *p_av1_film_grain; > + struct v4l2_ctrl_vp8_encode_params *p_vp8_encode_params; > void *p; > const void *p_const; > }; > diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h > index c3604a0a3e30..fdec5764e09c 100644 > --- a/include/uapi/linux/v4l2-controls.h > +++ b/include/uapi/linux/v4l2-controls.h > @@ -3479,6 +3479,97 @@ struct v4l2_ctrl_av1_film_grain { > __u8 reserved[4]; > }; > > +#define V4L2_CID_STATELESS_VP8_ENCODE_PARAMS (V4L2_CID_CODEC_STATELESS_BASE + 601) > + > +#define V4L2_VP8_FRAME_FLAG_SHOWFRAME 0x1 > +#define V4L2_VP8_FRAME_FLAG_GOLDEN_REFRESH 0x2 > +#define V4L2_VP8_FRAME_FLAG_ALTREF_REFRESH 0x4 > +#define V4L2_VP8_FRAME_FLAG_SEGMENT_ENABLED 0x8 > +#define V4L2_VP8_FRAME_FLAG_LOOP_FILTER_ADJ_ENABLED 0x10 > +#define V4L2_VP8_FRAME_FLAG_REFRESH_ENTROPY_PROBS 0x20 Hi Andrzej, Would you be able to add "ENCODE" to these FLAG names e.g. something like this: V4L2_VP8_FRAME_ENCODE_FLAG_SHOWFRAME Just to disguish these flag names from the ones that are used in the stateless vp8 decoder struct v4l2_ctrl_vp8_frame. If it makes no difference otherwise, it would be helpful for someone who might be trying to parse this future uAPI with a perl script :) thanks, Deborah > + > +#define V4L2_VP8_FRAME_TYPE_KEYFRAME 0 > +#define V4L2_VP8_FRAME_TYPE_INTER 1 > + > +#define V4L2_VP8_FRAME_COLOR_SPACE_YUV 0 > +#define V4L2_VP8_FRAME_COLOR_SPACE_RESERVED 1 > + > +#define V4L2_VP8_FRAME_CLAMPING_REQUIRED 0 > +#define V4L2_VP8_FRAME_CLAMPING_NO 1 > + > +#define V4L2_VP8_FRAME_FILTER_TYPE_NORMAL 0 > +#define V4L2_VP8_FRAME_FILTER_TYPE_SIMPLE 1 > + > +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_1 0 > +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_2 1 > +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_4 2 > +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_8 3 > + > +#define V4L2_VP8_FRAME_GOLDEN_KEEP 0 > +#define V4L2_VP8_FRAME_GOLDEN_LASTFRAME 1 > +#define V4L2_VP8_FRAME_GOLDEN_ALTREF 2 > + > +#define V4L2_VP8_FRAME_ALTREF_KEEP 0 > +#define V4L2_VP8_FRAME_ALTREF_LASTFRAME 1 > +#define V4L2_VP8_FRAME_ALTREF_GOLDEN 2 > + > +#define V4L2_VP8_FRAME_REF_LAST 0 > +#define V4L2_VP8_FRAME_REF_GOLDEN 1 > +#define V4L2_VP8_FRAME_REF_ALT 2 > + > +/** > + * struct v4l2_ctrl_vp8_encode_params - VP8 encode parameters > + * @flags: combination of V4L2_VP8_FRAME_FLAG_{} flags. > + * @frame_type: specifies the frame type (key or inter). > + * Set to one of V4L2_VP8_FRAME_TYPE_{}. > + * @color_space: defines the YUV color space of the sequence. > + * V4L2_VP8_FRAME_TYPE_INTER frames shall set this field to zero. > + * Set to one of V4L2_VP8_FRAME_COLOR_SPACE_{}. > + * @clamping_type: defines pixel value clamping type. > + * V4L2_VP8_FRAME_TYPE_INTER frames shall set this field to zero. > + * Set to one of V4L2_VP8_FRAME_CLAMPING_{}. > + * @loop_filter_type: selects the type of loop filter applied. > + * Set to one of V4L2_VP8_FRAME_FILTER_TYPE_{}. > + * @loop_filter_level: sets the strength of the applied loop filter. > + * Set to a value from the rage 0..63. > + * @sharpness_level: sets the sharpness of the applied loop filter. > + * Set to a value from the range 0..7. > + * @log2_nbr_of_dct_partitions: determines the number of separate partitions > + * containing the DCT coefficients of macroblocks. > + * Set to one of V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_{}. > + * @prob_intra: indicates the probability of an intra macroblock. > + * Set to a value from the range 0..255. > + * @prob_last: indicates the probability that the last reference frame is used for inter-prediction. > + * Set to a value from the range 0..255. > + * @prob_gf: indicates the probability that the golden reference frame is used for inter-prediction. > + * Set to a value from the range 0..255. > + * @copy_buffer_to_golden: specifies the golden frame refresh strategy. > + * Set to one of V4L2_VP8_FRAME_FLAG_GOLDEN_{}. > + * @copy_buffer_to_alternate: specifies the atlref frame refresh strategy. > + * Set to one of V4L2_VP8_FRAME_FLAG_ALTREF_{}. > + * @reference_type: specifies what kind of reference to use for current inter frame. > + * V4L2_VP8_FRAME_TYPE_KEYFRAME shall set this field to zero. > + * Set to one of V4L2_VP8_FRAME_REF_{}. > + */ > +struct v4l2_ctrl_vp8_encode_params { > + __u32 flags; > + __u8 frame_type; > + __u8 color_space; > + __u8 clamping_type; > + __u8 loop_filter_type; > + __u8 loop_filter_level; > + __u8 sharpness_level; > + __u8 log2_nbr_of_dct_partitions; > + __u8 prob_intra; > + __u8 prob_last; > + __u8 prob_gf; > + __u8 copy_buffer_to_golden; > + __u8 copy_buffer_to_alternate; > + __u8 reference_type; > +}; > + > +#define V4L2_CID_STATELESS_VP8_ENCODE_QP (V4L2_CID_CODEC_STATELESS_BASE + 602) > + > /* MPEG-compression definitions kept for backwards compatibility */ > #ifndef __KERNEL__ > #define V4L2_CTRL_CLASS_MPEG V4L2_CTRL_CLASS_CODEC > diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h > index 78260e5d9985..b3cbdc60b82c 100644 > --- a/include/uapi/linux/videodev2.h > +++ b/include/uapi/linux/videodev2.h > @@ -1836,6 +1836,7 @@ struct v4l2_ext_control { > struct v4l2_ctrl_av1_tile_group_entry __user *p_av1_tile_group_entry; > struct v4l2_ctrl_av1_frame __user *p_av1_frame; > struct v4l2_ctrl_av1_film_grain __user *p_av1_film_grain; > + struct v4l2_ctrl_vp8_encode_params __user *p_vp8_encode_params; > void __user *ptr; > }; > } __attribute__ ((packed)); > @@ -1914,6 +1915,8 @@ enum v4l2_ctrl_type { > V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY = 0x281, > V4L2_CTRL_TYPE_AV1_FRAME = 0x282, > V4L2_CTRL_TYPE_AV1_FILM_GRAIN = 0x283, > + > + V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS = 0x0290, > }; > > /* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ > -- > 2.25.1 >
diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c index a662fb60f73f..c7799ceb3d6d 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c @@ -811,6 +811,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, struct v4l2_ctrl_hevc_pps *p_hevc_pps; struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering; struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params; + struct v4l2_ctrl_vp8_encode_params *p_vp8_encode_params; struct v4l2_area *area; void *p = ptr.p + idx * ctrl->elem_size; unsigned int i; @@ -1047,6 +1048,15 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, zero_padding(p_vp8_frame->coder_state); break; + case V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS: + p_vp8_encode_params = p; + if (p_vp8_encode_params->loop_filter_level > 63) + return -EINVAL; + + if (p_vp8_encode_params->sharpness_level > 7) + return -EINVAL; + break; + case V4L2_CTRL_TYPE_HEVC_SPS: p_hevc_sps = p; @@ -1868,6 +1878,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, case V4L2_CTRL_TYPE_AREA: elem_size = sizeof(struct v4l2_area); break; + case V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS: + elem_size = sizeof(struct v4l2_ctrl_vp8_encode_params); + break; default: if (type < V4L2_CTRL_COMPOUND_TYPES) elem_size = sizeof(s32); diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c index 8696eb1cdd61..bd26f1d89bd5 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c @@ -1236,6 +1236,8 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY: return "AV1 Tile Group Entry"; case V4L2_CID_STATELESS_AV1_FRAME: return "AV1 Frame Parameters"; case V4L2_CID_STATELESS_AV1_FILM_GRAIN: return "AV1 Film Grain"; + case V4L2_CID_STATELESS_VP8_ENCODE_PARAMS: return "VP8 Encode Parameters"; + case V4L2_CID_STATELESS_VP8_ENCODE_QP: return "VP8 Encode QP"; /* Colorimetry controls */ /* Keep the order of the 'case's the same as in v4l2-controls.h! */ @@ -1592,6 +1594,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, case V4L2_CID_STATELESS_AV1_FILM_GRAIN: *type = V4L2_CTRL_TYPE_AV1_FILM_GRAIN; break; + case V4L2_CID_STATELESS_VP8_ENCODE_PARAMS: + *type = V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS; + break; case V4L2_CID_UNIT_CELL_SIZE: *type = V4L2_CTRL_TYPE_AREA; *flags |= V4L2_CTRL_FLAG_READ_ONLY; diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 59679a42b3e7..a165719e1139 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -56,6 +56,7 @@ struct video_device; * @p_av1_tile_group_entry: Pointer to an AV1 tile group entry structure. * @p_av1_frame: Pointer to an AV1 frame structure. * @p_av1_film_grain: Pointer to an AV1 film grain structure. + * @p_vp8_encode_params: Pointer to a VP8 encode parameter structure. * @p: Pointer to a compound value. * @p_const: Pointer to a constant compound value. */ @@ -89,6 +90,7 @@ union v4l2_ctrl_ptr { struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry; struct v4l2_ctrl_av1_frame *p_av1_frame; struct v4l2_ctrl_av1_film_grain *p_av1_film_grain; + struct v4l2_ctrl_vp8_encode_params *p_vp8_encode_params; void *p; const void *p_const; }; diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index c3604a0a3e30..fdec5764e09c 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -3479,6 +3479,97 @@ struct v4l2_ctrl_av1_film_grain { __u8 reserved[4]; }; +#define V4L2_CID_STATELESS_VP8_ENCODE_PARAMS (V4L2_CID_CODEC_STATELESS_BASE + 601) + +#define V4L2_VP8_FRAME_FLAG_SHOWFRAME 0x1 +#define V4L2_VP8_FRAME_FLAG_GOLDEN_REFRESH 0x2 +#define V4L2_VP8_FRAME_FLAG_ALTREF_REFRESH 0x4 +#define V4L2_VP8_FRAME_FLAG_SEGMENT_ENABLED 0x8 +#define V4L2_VP8_FRAME_FLAG_LOOP_FILTER_ADJ_ENABLED 0x10 +#define V4L2_VP8_FRAME_FLAG_REFRESH_ENTROPY_PROBS 0x20 + +#define V4L2_VP8_FRAME_TYPE_KEYFRAME 0 +#define V4L2_VP8_FRAME_TYPE_INTER 1 + +#define V4L2_VP8_FRAME_COLOR_SPACE_YUV 0 +#define V4L2_VP8_FRAME_COLOR_SPACE_RESERVED 1 + +#define V4L2_VP8_FRAME_CLAMPING_REQUIRED 0 +#define V4L2_VP8_FRAME_CLAMPING_NO 1 + +#define V4L2_VP8_FRAME_FILTER_TYPE_NORMAL 0 +#define V4L2_VP8_FRAME_FILTER_TYPE_SIMPLE 1 + +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_1 0 +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_2 1 +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_4 2 +#define V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_8 3 + +#define V4L2_VP8_FRAME_GOLDEN_KEEP 0 +#define V4L2_VP8_FRAME_GOLDEN_LASTFRAME 1 +#define V4L2_VP8_FRAME_GOLDEN_ALTREF 2 + +#define V4L2_VP8_FRAME_ALTREF_KEEP 0 +#define V4L2_VP8_FRAME_ALTREF_LASTFRAME 1 +#define V4L2_VP8_FRAME_ALTREF_GOLDEN 2 + +#define V4L2_VP8_FRAME_REF_LAST 0 +#define V4L2_VP8_FRAME_REF_GOLDEN 1 +#define V4L2_VP8_FRAME_REF_ALT 2 + +/** + * struct v4l2_ctrl_vp8_encode_params - VP8 encode parameters + * @flags: combination of V4L2_VP8_FRAME_FLAG_{} flags. + * @frame_type: specifies the frame type (key or inter). + * Set to one of V4L2_VP8_FRAME_TYPE_{}. + * @color_space: defines the YUV color space of the sequence. + * V4L2_VP8_FRAME_TYPE_INTER frames shall set this field to zero. + * Set to one of V4L2_VP8_FRAME_COLOR_SPACE_{}. + * @clamping_type: defines pixel value clamping type. + * V4L2_VP8_FRAME_TYPE_INTER frames shall set this field to zero. + * Set to one of V4L2_VP8_FRAME_CLAMPING_{}. + * @loop_filter_type: selects the type of loop filter applied. + * Set to one of V4L2_VP8_FRAME_FILTER_TYPE_{}. + * @loop_filter_level: sets the strength of the applied loop filter. + * Set to a value from the rage 0..63. + * @sharpness_level: sets the sharpness of the applied loop filter. + * Set to a value from the range 0..7. + * @log2_nbr_of_dct_partitions: determines the number of separate partitions + * containing the DCT coefficients of macroblocks. + * Set to one of V4L2_VP8_FRAME_NBR_DCT_PARTITIONS_{}. + * @prob_intra: indicates the probability of an intra macroblock. + * Set to a value from the range 0..255. + * @prob_last: indicates the probability that the last reference frame is used for inter-prediction. + * Set to a value from the range 0..255. + * @prob_gf: indicates the probability that the golden reference frame is used for inter-prediction. + * Set to a value from the range 0..255. + * @copy_buffer_to_golden: specifies the golden frame refresh strategy. + * Set to one of V4L2_VP8_FRAME_FLAG_GOLDEN_{}. + * @copy_buffer_to_alternate: specifies the atlref frame refresh strategy. + * Set to one of V4L2_VP8_FRAME_FLAG_ALTREF_{}. + * @reference_type: specifies what kind of reference to use for current inter frame. + * V4L2_VP8_FRAME_TYPE_KEYFRAME shall set this field to zero. + * Set to one of V4L2_VP8_FRAME_REF_{}. + */ +struct v4l2_ctrl_vp8_encode_params { + __u32 flags; + __u8 frame_type; + __u8 color_space; + __u8 clamping_type; + __u8 loop_filter_type; + __u8 loop_filter_level; + __u8 sharpness_level; + __u8 log2_nbr_of_dct_partitions; + __u8 prob_intra; + __u8 prob_last; + __u8 prob_gf; + __u8 copy_buffer_to_golden; + __u8 copy_buffer_to_alternate; + __u8 reference_type; +}; + +#define V4L2_CID_STATELESS_VP8_ENCODE_QP (V4L2_CID_CODEC_STATELESS_BASE + 602) + /* MPEG-compression definitions kept for backwards compatibility */ #ifndef __KERNEL__ #define V4L2_CTRL_CLASS_MPEG V4L2_CTRL_CLASS_CODEC diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 78260e5d9985..b3cbdc60b82c 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -1836,6 +1836,7 @@ struct v4l2_ext_control { struct v4l2_ctrl_av1_tile_group_entry __user *p_av1_tile_group_entry; struct v4l2_ctrl_av1_frame __user *p_av1_frame; struct v4l2_ctrl_av1_film_grain __user *p_av1_film_grain; + struct v4l2_ctrl_vp8_encode_params __user *p_vp8_encode_params; void __user *ptr; }; } __attribute__ ((packed)); @@ -1914,6 +1915,8 @@ enum v4l2_ctrl_type { V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY = 0x281, V4L2_CTRL_TYPE_AV1_FRAME = 0x282, V4L2_CTRL_TYPE_AV1_FILM_GRAIN = 0x283, + + V4L2_CTRL_TYPE_VP8_ENCODE_PARAMS = 0x0290, }; /* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */