Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1006044ybt; Wed, 8 Jul 2020 18:02:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmrafB85S1PNXnPQjqfNHPpPkxfKNHX2po8r/wHr2GMaTA5Wq/PIaAjv3PRgHJpmtPdj5Y X-Received: by 2002:aa7:c496:: with SMTP id m22mr56659549edq.336.1594256548307; Wed, 08 Jul 2020 18:02:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594256548; cv=none; d=google.com; s=arc-20160816; b=Xmd2xyIdSqT7slTmkr1l0vKNQwhvtjaszVPdQH2Uj+HVd3kvUZ678QJDhxchnBi+F7 UfPCl/VZ3rTQWq5dSHPfWUIQuLj3Ny5giiU07KyGyyP0Uzp0D7fgcWb5pDJHLXcRSJQz yy56fr7eSWylaFPlDMKR9NVJ1PnkI2rzB3V3AsOzeOfgjuQqpy1u1d3+K7y9PStpJq4Z rL5ywcIDmuGZGeZIpybFdizXV2uNHzIWEPhqMV2RZRQI3emiaOpm3X78/kOGj6D7zBbv 2/JAAIhDGcCbFKxIwNLm63GNQa2suHI63BSCUXhVBWNV6E4obq4zSP2tKBNQRejYk2w/ 8CpQ== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=Lwy/TUmMO5Z/1GlX8cJ31apZHSAxwS7d7SzRutu1MJ0=; b=MOVtlj/J5H66vDH9yiUjCIlhcP4BLZmbPRcHkZ7e4FguaYARF/vGed1hRqgJJ2GMtZ PP2d5TLK1frdKX8856WgNiQyBw7UxMo3vm4IrroQSKug7mSV6p0hTBhMw7cgsTpNHDsF S46HzQHyoyLCirV+lTPB6Wtn0uRBaYfSrVQL0pY2yD+c3kZdvkBQLWGl4ab7PRH87P0O D0zZwyY8aoWi0a7HkLOmL1UlsequK7+V1ZsCqNbky45+n098mR78NdHLN/ewnAzo/6Tk oKWf/Wl4kD/YNKG+/hKM/hDEzcHPqms79W2zJVsjFuzBoSfIvkkFnShjlc4K+zP1sMi+ IT+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ndufresne-ca.20150623.gappssmtp.com header.s=20150623 header.b="ET/M19TQ"; 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 b13si1312622edz.152.2020.07.08.18.02.05; Wed, 08 Jul 2020 18:02:28 -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=@ndufresne-ca.20150623.gappssmtp.com header.s=20150623 header.b="ET/M19TQ"; 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 S1726228AbgGIA7i (ORCPT + 99 others); Wed, 8 Jul 2020 20:59:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726116AbgGIA7h (ORCPT ); Wed, 8 Jul 2020 20:59:37 -0400 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82772C08C5C1 for ; Wed, 8 Jul 2020 17:59:37 -0700 (PDT) Received: by mail-qv1-xf42.google.com with SMTP id u8so224117qvj.12 for ; Wed, 08 Jul 2020 17:59:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ndufresne-ca.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=Lwy/TUmMO5Z/1GlX8cJ31apZHSAxwS7d7SzRutu1MJ0=; b=ET/M19TQjjEkmefFj2CMQwprybD/BLQRr97CSRxnIaNeqxpWggWTX79xfT98AbQksA Itn1U3XblGbyN5j01FOIE4COxzij3/ecEXBQ28/B3+CkSLP6156pYvXrcd9CPuCCrBf8 n0mDyma6G/7AKmGDpNpG26QB2tYJpdGGDyjw5QnUSGIHsgk0KzHNRGSYODCLhHp9Botr CYYMkVsktfwHvdQP20FXID0+qLH/uu6vuahRLeJp0cwqJ9cUy/pOJwRPdRx1rm0mrVcs Q3bAcXL4kZRewbwjGVA2WDWRgVSfv/FkqzbwSk7U4je+rx/wZK5QqNKnHREnvbRWQbyC SCSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=Lwy/TUmMO5Z/1GlX8cJ31apZHSAxwS7d7SzRutu1MJ0=; b=PSEhW0Sj7IxCwcXO/hIWM5X3wyKpIB8C1Q1TZw5mtnuI7giQQoS2dIywDUEYNlFTep ePTMbqGYwbWY4zfBdM/zSU4DNzckFpTNMReeoFVAOwzr6a6rzG5bnACqokq3kIG41HgL JkyS9rOP2sry/bv0CkSFuqPMUDb73YY9QJPn1hzgOah0ZGvIoZUXM6VcWcE28kxMuYTg YdqMoOcs81lAcqFqWh6WxjJFhyS7HNkehnk1W1wlxCIO9er2qP7bG0NXzUT44zrHzznQ L9RavBCHUbsC1cl6Uv5S5B/eUFBmJVBHmUhhFTK7KbJ9svRcVw+OiE+1QDMr+dE0P7E7 zxUw== X-Gm-Message-State: AOAM5319K1hFtKILwDQLepaSRDh35hPSH4dmnzd0jHoieLpVXhZCdhiK YZEKqPPJGW6U/rlTLm/AXsO5jw== X-Received: by 2002:ad4:57c7:: with SMTP id y7mr61409102qvx.124.1594256376656; Wed, 08 Jul 2020 17:59:36 -0700 (PDT) Received: from skullcanyon ([192.222.193.21]) by smtp.gmail.com with ESMTPSA id g17sm1593649qto.73.2020.07.08.17.59.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2020 17:59:35 -0700 (PDT) Message-ID: Subject: Re: [PATCH 1/3] media: uapi: h264: update reference lists From: Nicolas Dufresne To: Jernej =?UTF-8?Q?=C5=A0krabec?= , Ezequiel Garcia Cc: Paul Kocialkowski , Maxime Ripard , Mauro Carvalho Chehab , Chen-Yu Tsai , Hans Verkuil , Greg KH , Jonas Karlman , linux-media , Linux Kernel Mailing List , devel@driverdev.osuosl.org, linux-arm-kernel Date: Wed, 08 Jul 2020 20:59:34 -0400 In-Reply-To: <3602665.eG79kSnugm@jernej-laptop> References: <20200604185745.23568-1-jernej.skrabec@siol.net> <20200604185745.23568-2-jernej.skrabec@siol.net> <3602665.eG79kSnugm@jernej-laptop> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.3 (3.36.3-1.fc32) 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 Le mercredi 08 juillet 2020 à 17:57 +0200, Jernej Škrabec a écrit : > Hi! > > Dne sreda, 08. julij 2020 ob 15:28:52 CEST je Ezequiel Garcia napisal(a): > > Hello Jernej, > > > > I'd like to post a new H264 uAPI cleanup series soon, > > would you mind resending this, or otherwise do you > > mind if I include this patch in the series? > > I don't mind at all. Currently my focus was elsewhere... > > > See below for a tiny comment. > > > > On Thu, 4 Jun 2020 at 15:55, Jernej Skrabec wrote: > > > 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 flags along > > > index into DPB array. Flags will tell if reference is meant for top or > > > bottom field. > > > > > > Currently the only user of these lists is Cedrus which is just compile > > > fixed here. Actual usage of newly introduced flags will come in > > > following commit. > > > > > > Signed-off-by: Jernej Skrabec > > > --- > > > > > > .../media/v4l/ext-ctrls-codec.rst | 40 ++++++++++++++++++- > > > .../staging/media/sunxi/cedrus/cedrus_h264.c | 6 +-- > > > include/media/h264-ctrls.h | 12 +++++- > > > 3 files changed, 51 insertions(+), 7 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..6c36d298db20 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,42 @@ 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 > > > + > > > + * - __u16 > > > + - ``flags`` > > > + - See :ref:`Picture Reference Flags ` > > > + * - __u8 > > > + - ``index`` > > > + - > > > + > > > +.. _h264_reference_flags: > > > + > > > +``Picture Reference Flags`` > > > + > > > +.. cssclass:: longtable > > > + > > > +.. flat-table:: > > > + :header-rows: 0 > > > + :stub-columns: 0 > > > + :widths: 1 1 2 > > > + > > > + * - ``V4L2_H264_REFERENCE_FLAG_TOP_FIELD`` > > > + - 0x00000001 > > > + - > > > + * - ``V4L2_H264_REFERENCE_FLAG_BOTTOM_FIELD`` > > > + - 0x00000002 > > > + - > > > + > > > > > > ``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..9b1cbc9bc38e 100644 > > > --- a/include/media/h264-ctrls.h > > > +++ b/include/media/h264-ctrls.h > > > @@ -140,6 +140,14 @@ 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 > > > > > > +#define V4L2_H264_REFERENCE_FLAG_TOP_FIELD 0x01 > > > +#define V4L2_H264_REFERENCE_FLAG_BOTTOM_FIELD 0x02 > > > + > > > +struct v4l2_h264_reference { > > > + __u8 flags; > > > + __u8 index; > > > +}; > > > + > > > > > > struct v4l2_ctrl_h264_slice_params { > > > > > > /* Size in bytes, including header */ > > > __u32 size; > > > > > > @@ -182,8 +190,8 @@ struct v4l2_ctrl_h264_slice_params { > > > > > > * 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[32]; > > > + struct v4l2_h264_reference ref_pic_list1[32]; > > > > Could we use a macro for "32" here? Something like: > > > > #define V4L2_H264_REF_PIC_LIST_LEN (V4L2_H264_NUM_DPB_ENTRIES * 2). > > > > Does it make sense to add a comment as well? > > > > I was thinking something along these lines: > > > > """ > > Pictures in the DPB can be a frame, a complementary field pair or a > > single field. > > To be honest, I don't know if user has a free choice to select same or > different destination (capture) buffer for another field. I never tested it and > I'm not sure how to test it with ffmpeg. HW deinterlacing cores on Allwinner > SoCs support only interleaved fields as a input, that's why I never though > about separate fields. When setting the format, one will choose V4L2_FIELD_INTERLACED_TB/BT. Most driver will support that, but if not, they can update field in the structure. Interlaced being very common, I think it's fine to only support that, but the drive must enforce this field value. But I know the Xilinx ZynqMP will do ALTERNATE instead, which would be each field get decoded in it's own buffer. That, to be honest, I haven't though about. The tricky part is for H264, since it means 1 slice may populate two capture buffers and I don't know if we can support this right now. For now I'd say we should just ensure that whatever userspace ask, we enforce V4L2_FIELD_INTERLACED_TB/BT appropriately. That is likely not complete, just look at how interlacing is signal in the bitstream. > > Best regards, > Jernej > > > Therefore, reference pictures lists need twice as much entries, so it > > can reference > > either field of a field pair. > > """ > > > > While it doesn't replace proper H264 specification reading, > > it would add some clarity. > > > > Thanks, > > Ezequiel > > >