Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2270081imw; Wed, 6 Jul 2022 03:05:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s14IJzJqtaUZvu1tixE7muAryxUjz92O3Ficjne5nh1p6JQUiPaxJspmmI1/NvXE0hp5lM X-Received: by 2002:a05:6a00:1a0c:b0:528:6baa:a2e3 with SMTP id g12-20020a056a001a0c00b005286baaa2e3mr14843592pfv.27.1657101932140; Wed, 06 Jul 2022 03:05:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657101932; cv=none; d=google.com; s=arc-20160816; b=yqo+ZwHT+hEWNyqoM9N91AI/PffcmpEWKBveRmEwYVRvfUfw0/k0w6Br7qn1bCQmoD QvUW0eeZ/YEQyiKTQyJJvrJwzEl6JtBYgcm5V6mA6zHhhWsGIAD6qK37CZtsv2HXa7Tw 16Ys4goVdY19chuHj+BhmXjeXJRaonLd05ND1X/wzUgVpCbRm5sg9Un0H3FXQl904+rL NWJJyCCUMiwmY269neznFpXzqLpudRWFAy5AcnfdytfqY8Ai7lw9Gt8WYvjjsGLTQXFa su+qs7wu71mz+LrrLIgBpo/G5AWSO1ZRLdQ3GjIxAQL+tOGQJ/SuCsnNXKhT3OAukKAk jXrg== 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=Sqw6/Mj1YlUpt+yMmHdbjUFinAHiC9q+t9epzFI5vyk=; b=BDv2Ba5dpsbwE2st3QVajjHzOqf3zVs1slpZDQfzEjkDGbCvCC63I46cqstIl8uY2t vuyJKKKaDepedZACL9SnhiWnmhj9jyHVNglqQm3kambDNfnwaGuYeYKx7flvs8ks740c f+ctLNt7ZEYzzwxfvlunlYJC01+X4wBIP6vkjQNreIhZ+FOGA6XogVs6mr75ql1yvjjE oQcpJRW1Rk9vAudO6nKdsb5l7om9msfGR582cKUu4NDLZCHYe3/cf91UoghZKEmtZcdi jfaExwAuLFheguD7o1sZKYEFsuCUox+oQ2IXC1hBGPQDXA+PVqK9eohYq7GPVN6C5HEA 2zsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=EYuFnNwx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m4-20020a170902db0400b0016a5c439a92si55567184plx.288.2022.07.06.03.05.20; Wed, 06 Jul 2022 03:05:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=EYuFnNwx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232288AbiGFJj1 (ORCPT + 99 others); Wed, 6 Jul 2022 05:39:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232907AbiGFJi3 (ORCPT ); Wed, 6 Jul 2022 05:38:29 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E3C3E42; Wed, 6 Jul 2022 02:38:23 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:3a70:988d:42ce:f5cc]) (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: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id 78AC266019DD; Wed, 6 Jul 2022 10:38:21 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1657100302; bh=qxR1F8ry0iFug22w2E8Lp+hA57rv+0jkQMuhDa4/mBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EYuFnNwxGs6dN/vL08XHmF/16BP6YYZuKHFYSaNLIxztRWWzL7DDUH11if4igRVOj 1LUqQg9LM2jiZla8ozW6eiqh77ZP/1UBiK9DkhJSHF+6LtGXyrJ9XqWkzCr8c5FHDA Zd1YE1zx+b6x6fkO08jBWkX72smqojIQ42HHHWAZvO85XmXmTyGi96OrWp4jBfOleL WoUmX7T/Cl6zZMI8R4ULwNXXOtZU4fF9hTigJuUG2aQGUh2XPpGn6RIDw5UJHLR8s8 JlbOVFuVDpUoiny0urcWxIlVK9MDhbvU+DHBtLmdy1BmV8HiyWcOz89ndTWsTD21Cp mVeOn8cQG+MBw== From: Benjamin Gaignard To: mchehab@kernel.org, hverkuil@xs4all.nl, ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, gregkh@linuxfoundation.org, mripard@kernel.org, paul.kocialkowski@bootlin.com, wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, nicolas.dufresne@collabora.com, andrzej.p@collabora.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, kernel@collabora.com, Benjamin Gaignard Subject: [PATCH v11 16/17] media: uapi: Change data_bit_offset definition Date: Wed, 6 Jul 2022 11:38:02 +0200 Message-Id: <20220706093803.158810-17-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220706093803.158810-1-benjamin.gaignard@collabora.com> References: <20220706093803.158810-1-benjamin.gaignard@collabora.com> 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, T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org 'F.7.3.6.1 General slice segment header syntax' section of HEVC specification describes that a slice header always end aligned on byte boundary, therefore we only need to provide the data offset in bytes. Signed-off-by: Benjamin Gaignard Reviewed-by: Ezequiel Garcia Acked-by: Nicolas Dufresne Tested-by: Jernej Skrabec --- .../media/v4l/ext-ctrls-codec.rst | 4 ++-- .../staging/media/sunxi/cedrus/cedrus_h265.c | 19 ++++++++++++++++++- .../staging/media/sunxi/cedrus/cedrus_video.c | 1 - include/media/hevc-ctrls.h | 4 ++-- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst index d5ef91ae3539..f012673a3e64 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -3008,8 +3008,8 @@ enum v4l2_mpeg_video_hevc_size_of_length_field - - ``bit_size`` - Size (in bits) of the current slice data. * - __u32 - - ``data_bit_offset`` - - Offset (in bits) to the video data in the current slice data. + - ``data_byte_offset`` + - Offset (in bytes) to the video data in the current slice data. * - __u32 - ``num_entry_point_offsets`` - Specifies the number of entry point offset syntax elements in the slice header. diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c index 411601975124..7b67cb4621cf 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c @@ -317,6 +317,8 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx, u32 chroma_log2_weight_denom; u32 output_pic_list_index; u32 pic_order_cnt[2]; + u8 *padding; + int count; u32 reg; sps = run->h265.sps; @@ -405,7 +407,22 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx, /* Initialize bitstream access. */ cedrus_write(dev, VE_DEC_H265_TRIGGER, VE_DEC_H265_TRIGGER_INIT_SWDEC); - cedrus_h265_skip_bits(dev, slice_params->data_bit_offset); + /* + * Cedrus expects that bitstream pointer is actually at the end of the slice header + * instead of start of slice data. Padding is 8 bits at most (one bit set to 1 and + * at most seven bits set to 0), so we have to inspect only one byte before slice data. + */ + padding = (u8 *)vb2_plane_vaddr(&run->src->vb2_buf, 0) + + slice_params->data_byte_offset - 1; + + for (count = 0; count < 8; count++) + if (*padding & (1 << count)) + break; + + /* Include the one bit. */ + count++; + + cedrus_h265_skip_bits(dev, slice_params->data_byte_offset * 8 - count); /* Bitstream parameters. */ diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index 33726175d980..66714609b577 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -568,7 +568,6 @@ int cedrus_queue_init(void *priv, struct vb2_queue *src_vq, src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; src_vq->io_modes = VB2_MMAP | VB2_DMABUF; - src_vq->dma_attrs = DMA_ATTR_NO_KERNEL_MAPPING; src_vq->drv_priv = ctx; src_vq->buf_struct_size = sizeof(struct cedrus_buffer); src_vq->ops = &cedrus_qops; diff --git a/include/media/hevc-ctrls.h b/include/media/hevc-ctrls.h index 7358cbfc3e4d..c89029b3c5da 100644 --- a/include/media/hevc-ctrls.h +++ b/include/media/hevc-ctrls.h @@ -310,7 +310,7 @@ struct v4l2_hevc_pred_weight_table { * V4L2_CTRL_FLAG_DYNAMIC_ARRAY flag must be set when using it. * * @bit_size: size (in bits) of the current slice data - * @data_bit_offset: offset (in bits) to the video data in the current slice data + * @data_byte_offset: offset (in bytes) to the video data in the current slice data * @num_entry_point_offsets: specifies the number of entry point offset syntax * elements in the slice header. * @nal_unit_type: specifies the coding type of the slice (B, P or I) @@ -356,7 +356,7 @@ struct v4l2_hevc_pred_weight_table { */ struct v4l2_ctrl_hevc_slice_params { __u32 bit_size; - __u32 data_bit_offset; + __u32 data_byte_offset; __u32 num_entry_point_offsets; /* ISO/IEC 23008-2, ITU-T Rec. H.265: NAL unit header */ __u8 nal_unit_type; -- 2.32.0