Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1094034pxa; Thu, 20 Aug 2020 02:13:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTjrJhIRhGRrt361kBihrHMpGccAMOw5P/Tq/aQQI1vmRY6ud0b/lDZD0yR1brbuRKYc84 X-Received: by 2002:a17:906:3715:: with SMTP id d21mr2233539ejc.281.1597914797822; Thu, 20 Aug 2020 02:13:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597914797; cv=none; d=google.com; s=arc-20160816; b=ARa8Vzhz72lH/rVg4j0hiAj0YdnZGjqXtyUneLe0fAfF+KT9/j2f2yyHSOaykduGO5 QDlhbFHmw1XXpmj0ovKcXMAJzQbgipl+Kfw6oPtD5j5VXJLKJC5ca5T7UFgVGS+tw14G nDMNwaxbPwJzyUR4qvdE0Q5kZPdPPROQM3mUwxipug0OB6hbElg/2ljwzxN3GIHAuoHD pXEAvmcTsmb7V+oGRwGZA1HNSvi76lTXryN38Y7bpZ61qYJlZWKocDDEi3j2gyCdmLJ0 hLq6lAW/z349uDDhaFrnuhh/4ltEZEqBPt4CznzC8+bbjkG4OY3foO54iA6T72q1lA5e sW3w== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=U7xBLcM2J0jpHAEK5uZYaH2c1oV3hUq9xBqu8R3Xk5s=; b=shMLHqMEp2AAAoyGkCNDNmFagV7Yne71cuCQuqOcPpV09Tb3RrPHPYd/uBpNgaSN+Z 6o89CGbaFr2tYzxKRsFVmMnDswZbyiMzKd8iKZ/H2Ekq3PKfAc72bUyEuP3AC+Ts2suF 0SURTt0PD/2AUKdoonZ8oxgdPdZSV1YmFg40UFeFowHZGblgRml1WHCulG9bXRgbzeso /vIMKo8Qqtarq94Q14JJmjsKFoMUHIUWX6raw0sP1nufxKz+fMAcsT9BpaY8u1HchUPI xb13h9p0uFmiHwxTaU3d/UXpewSGdtUw/nWJtQxMGpnRoB1mCq58sGxCck0ozBpiFbHX SQ9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xs4all.nl header.s=s1 header.b=LaaXzekv; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p3si1003290edq.281.2020.08.20.02.12.53; Thu, 20 Aug 2020 02:13:17 -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; dkim=pass header.i=@xs4all.nl header.s=s1 header.b=LaaXzekv; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726759AbgHTJLw (ORCPT + 99 others); Thu, 20 Aug 2020 05:11:52 -0400 Received: from lb1-smtp-cloud7.xs4all.net ([194.109.24.24]:56033 "EHLO lb1-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726364AbgHTJLp (ORCPT ); Thu, 20 Aug 2020 05:11:45 -0400 Received: from cust-b5b5937f ([IPv6:fc0c:c16d:66b8:757f:c639:739b:9d66:799d]) by smtp-cloud7.xs4all.net with ESMTPA id 8gblkFRmeywL58gbmkZ5pf; Thu, 20 Aug 2020 11:11:42 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=s1; t=1597914702; bh=U7xBLcM2J0jpHAEK5uZYaH2c1oV3hUq9xBqu8R3Xk5s=; h=Subject:To:From:Message-ID:Date:MIME-Version:Content-Type:From: Subject; b=LaaXzekvbv04aXLJUi0eJAG8g7ODXfUELwhFsahrBUUuM8RZsp582BjyuPOu3E9V4 Q9K/quCO7BiIStMa3WS24eFIxfSpStTQSooqgIacXM07Rmn+1KgfQLZgjDyBvSmVqj 64T77nOLZ0rnpi6qbwnTAIR0eI9Sb28u2hyCv6yLSVYpG8ba6aLVqT5u44QfsE2irn mSpcZyUFZePb7FEQ3wuyqJ1g9j5fc+VamCqtIKg9uRZ1kljhrVyxoCHCSkKLixPwPF yR/jrCV8Z7jHRJQVDX7g18mlv5cusaAxpIp1m+X0Q/cpkrjvtpA+jCv6deCLxt+wB5 AlL+djRYrd/eA== Subject: Re: [PATCH v3 01/19] media: uapi: h264: Update reference lists To: Ezequiel Garcia , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tomasz Figa , kernel@collabora.com, Jonas Karlman , Alexandre Courbot , Jeffrey Kardatzke , Nicolas Dufresne , Philipp Zabel , Maxime Ripard , Paul Kocialkowski , Jernej Skrabec References: <20200814133634.95665-1-ezequiel@collabora.com> <20200814133634.95665-2-ezequiel@collabora.com> From: Hans Verkuil Message-ID: Date: Thu, 20 Aug 2020 11:11:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200814133634.95665-2-ezequiel@collabora.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfAjTqbisxxfuHqWvIRIOhnI8MK49adN3g+IHofEpheCosvb8sv3BNbTYJN7+/spl3+u2qEBz4tvjmIyx1P5HxD3b59gnrjvS2FVBX1bfCxNPMszZDk11 IbnXH6nPsnEdkBrjcm5wzfwkoX0Wv5K58gSAbYgode3aK6TDgznTDFK4itsJRmZ8FGlfta9h/oejjldypeAkLvnGoxglyGvzY8YkyUZg8sBbDzn0uYC73Sna dcOfWCKoeT8Uj+h+/RyMTpMok3zlGhDqZ6lyQwp9QAHX0+0WXHkDSQvHxdecTV70yNwzPn0rmAF3RCQbOqTCgRZdtlRe/kAbDH+IhrI8zd3BRhl0xxV7m1zR idjJl3/NowOJf/drEWEy0nwphqv2jgeP4rDJNZd5J0APqfwIlm+A6rGuYce5fykr8olAAQgkP0T/kh7a4sKCqH+TaHRSH2NfRSeQMWveeKqcyzLPpHrcX2eo o7DGoXmx5l1ssB0RJYMBg5u6MroIzPymTaNSkLzREaaOhQGhgNa1R2/NreKZwXKmkVDuwh1brqmYI8mGyZchOPl8qo5+eQ2Rc8llKrSgDT39lYuEVOldUY1A P57e48XWqPvxMNfr9xo9L/1Ghsm+VFNJibxkp+MqJdCaB8BLC9ueO+AV1LKPkuYp8HQibWCAOSL9m/nKk0RmkN+Vk9k5m8kMlXZrt9YHMZPpYw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/08/2020 15:36, Ezequiel Garcia wrote: > From: Jernej Skrabec > > When dealing with with interlaced frames, reference lists must tell if > each particular reference is meant for top or bottom field. This info > is currently not provided at all in the H264 related controls. > > Make reference lists hold a structure which will also hold an > enumerator type along index into DPB array. The enumerator must > be used to specify if reference is for top or bottom field. > > Currently the only user of these lists is Cedrus which is just compile > fixed here. Actual usage of will come in a following commit. > > Signed-off-by: Jernej Skrabec > Signed-off-by: Ezequiel Garcia > --- > v3: > * Rename to avoid mentioning the DPB. > v2: > * As pointed out by Jonas, enum v4l2_h264_dpb_reference here. > --- > .../media/v4l/ext-ctrls-codec.rst | 44 ++++++++++++++++++- > .../staging/media/sunxi/cedrus/cedrus_h264.c | 6 +-- > include/media/h264-ctrls.h | 23 +++++++--- > 3 files changed, 62 insertions(+), 11 deletions(-) > > diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst > index d0d506a444b1..b9b2617c3bda 100644 > --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst > +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst > @@ -1843,10 +1843,10 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - > * - __u32 > - ``slice_group_change_cycle`` > - > - * - __u8 > + * - struct :c:type:`v4l2_h264_reference` > - ``ref_pic_list0[32]`` > - Reference picture list after applying the per-slice modifications > - * - __u8 > + * - struct :c:type:`v4l2_h264_reference` > - ``ref_pic_list1[32]`` > - Reference picture list after applying the per-slice modifications > * - __u32 > @@ -1926,6 +1926,46 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - > - ``chroma_offset[32][2]`` > - > > +``Picture Reference`` > + > +.. c:type:: v4l2_h264_reference > + > +.. cssclass:: longtable > + > +.. flat-table:: struct v4l2_h264_reference > + :header-rows: 0 > + :stub-columns: 0 > + :widths: 1 1 2 > + > + * - enum :c:type:`v4l2_h264_field_reference` > + - ``reference`` > + - Specifies how the picture is referenced. > + * - __u8 > + - ``index`` > + - Index into the :c:type:`v4l2_ctrl_h264_decode_params`.dpb array. > + > +.. c:type:: v4l2_h264_field_reference > + > +.. cssclass:: longtable > + > +.. flat-table:: > + :header-rows: 0 > + :stub-columns: 0 > + :widths: 1 1 2 > + > + * - ``V4L2_H264_TOP_FIELD_REF`` > + - 0x1 > + - The top field in field pair is used for > + short-term reference. > + * - ``V4L2_H264_BOTTOM_FIELD_REF`` > + - 0x2 > + - The bottom field in field pair is used for > + short-term reference. > + * - ``V4L2_H264_FRAME_REF`` > + - 0x3 > + - The frame (or the top/bottom fields, if it's a field pair) > + is used for short-term reference. > + > ``V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS (struct)`` > Specifies the decode parameters (as extracted from the bitstream) > for the associated H264 slice data. This includes the necessary > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c > index 54ee2aa423e2..cce527bbdf86 100644 > --- a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c > +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c > @@ -166,8 +166,8 @@ static void cedrus_write_frame_list(struct cedrus_ctx *ctx, > > static void _cedrus_write_ref_list(struct cedrus_ctx *ctx, > struct cedrus_run *run, > - const u8 *ref_list, u8 num_ref, > - enum cedrus_h264_sram_off sram) > + const struct v4l2_h264_reference *ref_list, > + u8 num_ref, enum cedrus_h264_sram_off sram) > { > const struct v4l2_ctrl_h264_decode_params *decode = run->h264.decode_params; > struct vb2_queue *cap_q; > @@ -188,7 +188,7 @@ static void _cedrus_write_ref_list(struct cedrus_ctx *ctx, > int buf_idx; > u8 dpb_idx; > > - dpb_idx = ref_list[i]; > + dpb_idx = ref_list[i].index; > dpb = &decode->dpb[dpb_idx]; > > if (!(dpb->flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) > diff --git a/include/media/h264-ctrls.h b/include/media/h264-ctrls.h > index 080fd1293c42..5f635e8d25e2 100644 > --- a/include/media/h264-ctrls.h > +++ b/include/media/h264-ctrls.h > @@ -19,6 +19,8 @@ > */ > #define V4L2_H264_NUM_DPB_ENTRIES 16 > > +#define V4L2_H264_REF_LIST_LEN (2 * V4L2_H264_NUM_DPB_ENTRIES) > + > /* Our pixel format isn't stable at the moment */ > #define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4') /* H264 parsed slices */ > > @@ -140,6 +142,19 @@ struct v4l2_h264_pred_weight_table { > #define V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED 0x04 > #define V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH 0x08 > > +enum v4l2_h264_field_reference { > + V4L2_H264_TOP_FIELD_REF = 0x1, > + V4L2_H264_BOTTOM_FIELD_REF = 0x2, > + V4L2_H264_FRAME_REF = 0x3, > +}; > + > +struct v4l2_h264_reference { > + enum v4l2_h264_field_reference fields; > + > + /* Index into v4l2_ctrl_h264_decode_params.dpb[] */ > + __u8 index; > +}; This introducing 3 bytes of padding at the end of this struct... > + > struct v4l2_ctrl_h264_slice_params { > /* Size in bytes, including header */ > __u32 size; > @@ -178,12 +193,8 @@ struct v4l2_ctrl_h264_slice_params { > __u8 num_ref_idx_l1_active_minus1; > __u32 slice_group_change_cycle; > > - /* > - * Entries on each list are indices into > - * v4l2_ctrl_h264_decode_params.dpb[]. > - */ > - __u8 ref_pic_list0[32]; > - __u8 ref_pic_list1[32]; > + struct v4l2_h264_reference ref_pic_list0[V4L2_H264_REF_LIST_LEN]; > + struct v4l2_h264_reference ref_pic_list1[V4L2_H264_REF_LIST_LEN]; ...which leads to a lot of holes of uninitialized data in these arrays. I recommend to replace 'enum v4l2_h264_field_reference fields;' in struct v4l2_h264_reference by '__u8 fields; /* enum v4l2_h264_field_reference */'. This also saves a lot of memory (2*32*6 = 384 bytes!) and avoids the padding issue. Regards, Hans > > __u32 flags; > }; >