Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp370191pxa; Fri, 14 Aug 2020 06:40:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHQoFBrdXMzVTbssepDE6T0iaGpscfoEgV6an24NNblOUJFHK+3AkjGTa2OpPugllIto9C X-Received: by 2002:aa7:c74f:: with SMTP id c15mr2292248eds.331.1597412403575; Fri, 14 Aug 2020 06:40:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597412403; cv=none; d=google.com; s=arc-20160816; b=iJCuls+7MkLTCsYAUB22o+WSNG6MkYGT8eQKQt5in/27aaWufUcskB9wB8zyDowIqR JGMgYzSCcmQlYJ0sDXqYIu7i6akyN6SjyTKJKmjLQim4kgb5x/YJTllowuj3awhkxpRY 6O6hwmFHwieF3ONeoE1VtZihF0aQ1CPkBJwKAHCi3XLeUFDDGlSCzocGwIn98LPxNCCX TF5ricC+RRjLbuSXcL20IFZh/ELU+rdrnfLKUtjbtG9BaeajoTh7zMig5EFGB5ayeyud //zXSkIv0hQ63uOwnUaRZvDrA+JEnx6ufvH0Nn3gHqxVr2GyXnK+s5l/7zlNDqsRvP/q XY3w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=KT5Dikyb09V6+d8ATT4WC6B8RNc48wq16g8wC9OPyLw=; b=uboocZuBJbf+iBEk01u0kjvdqiB6IXk1SgYZqDQM31td61GcjQdiqQ2/4H7Tr1re2P pQUf7DqHsayXipIoJh9MfUhNC0rwuCqeoP3g4HoJLw83LQ+z2SyuGoJYylHBc/+Dejw6 E+VvOwCkNPWGgU1Nvw7Ky7AuhNDDp7CPs+e4IjgVG0FvReTOPp2fvUQR1+T2j9mnY28l VfYBJwqukNTID84zV5MTDEXzMT/280f+5/wJ61EOttVbLBgpC52YWSctHIXD4tm+x8/G B3ZuI6l3uHyIRdzRfE++FIqNKPaIj8KZif30IMBX6SASxFI2sD3SvifguT+uYZSeprGq ZgWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x2si5767135ejy.84.2020.08.14.06.39.41; Fri, 14 Aug 2020 06:40:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728788AbgHNNhU (ORCPT + 99 others); Fri, 14 Aug 2020 09:37:20 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:43260 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728723AbgHNNhR (ORCPT ); Fri, 14 Aug 2020 09:37:17 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id ADDCF29A823 From: Ezequiel Garcia To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tomasz Figa , kernel@collabora.com, Jonas Karlman , Hans Verkuil , Alexandre Courbot , Jeffrey Kardatzke , Nicolas Dufresne , Philipp Zabel , Maxime Ripard , Paul Kocialkowski , Jernej Skrabec , Ezequiel Garcia Subject: [PATCH v3 07/19] media: uapi: h264: Increase size of DPB entry pic_num Date: Fri, 14 Aug 2020 10:36:22 -0300 Message-Id: <20200814133634.95665-8-ezequiel@collabora.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200814133634.95665-1-ezequiel@collabora.com> References: <20200814133634.95665-1-ezequiel@collabora.com> 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 DPB entry PicNum maximum value is 2*MaxFrameNum for interlaced content (field_pic_flag=1). As specified, MaxFrameNum is 2^(log2_max_frame_num_minus4 + 4) and log2_max_frame_num_minus4 is in the range of 0 to 12, which means pic_num should be a 32-bit field. The v4l2_h264_dpb_entry struct needs to be padded to avoid a hole, which might be also useful to allow future uAPI extensions. Signed-off-by: Ezequiel Garcia --- .../userspace-api/media/v4l/ext-ctrls-codec.rst | 5 ++++- drivers/media/v4l2-core/v4l2-ctrls.c | 13 +++++++++++++ include/media/h264-ctrls.h | 3 ++- include/media/v4l2-h264.h | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst index d14da8325382..c0ae7fda803e 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -2054,7 +2054,10 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - * - __u16 - ``frame_num`` - - * - __u16 + * - __u8 + - ``reserved[2]`` + - Applications and drivers must set this to zero. + * - __u32 - ``pic_num`` - * - __s32 diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 76c8dc8fb31c..b9457789fa55 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -1725,6 +1725,8 @@ static void std_log(const struct v4l2_ctrl *ctrl) #define zero_padding(s) \ memset(&(s).padding, 0, sizeof((s).padding)) +#define zero_reserved(s) \ + memset(&(s).reserved, 0, sizeof((s).reserved)) /* * Compound controls validation requires setting unused fields/flags to zero @@ -1735,6 +1737,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, { struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; struct v4l2_ctrl_vp8_frame_header *p_vp8_frame_header; + struct v4l2_ctrl_h264_decode_params *p_h264_dec_params; struct v4l2_ctrl_hevc_sps *p_hevc_sps; struct v4l2_ctrl_hevc_pps *p_hevc_pps; struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params; @@ -1796,7 +1799,17 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, case V4L2_CTRL_TYPE_H264_SCALING_MATRIX: case V4L2_CTRL_TYPE_H264_PRED_WEIGHTS: case V4L2_CTRL_TYPE_H264_SLICE_PARAMS: + break; + case V4L2_CTRL_TYPE_H264_DECODE_PARAMS: + p_h264_dec_params = p; + + for (i = 0; i < V4L2_H264_NUM_DPB_ENTRIES; i++) { + struct v4l2_h264_dpb_entry *dpb_entry = + &p_h264_dec_params->dpb[i]; + + zero_reserved(*dpb_entry); + } break; case V4L2_CTRL_TYPE_VP8_FRAME_HEADER: diff --git a/include/media/h264-ctrls.h b/include/media/h264-ctrls.h index 4447697e9465..d178d7ad53b6 100644 --- a/include/media/h264-ctrls.h +++ b/include/media/h264-ctrls.h @@ -216,7 +216,8 @@ struct v4l2_ctrl_h264_slice_params { struct v4l2_h264_dpb_entry { __u64 reference_ts; __u16 frame_num; - __u16 pic_num; + __u8 reserved[2]; + __u32 pic_num; /* Note that field is indicated by v4l2_buffer.field */ __s32 top_field_order_cnt; __s32 bottom_field_order_cnt; diff --git a/include/media/v4l2-h264.h b/include/media/v4l2-h264.h index bc9ebb560ccf..1a5f26fc2a9a 100644 --- a/include/media/v4l2-h264.h +++ b/include/media/v4l2-h264.h @@ -33,7 +33,7 @@ struct v4l2_h264_reflist_builder { struct { s32 pic_order_count; int frame_num; - u16 pic_num; + u32 pic_num; u16 longterm : 1; } refs[V4L2_H264_NUM_DPB_ENTRIES]; s32 cur_pic_order_count; -- 2.27.0