Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp5070220pjb; Mon, 27 Jul 2020 12:08:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/yfbVuDMSFhVc9SE8/OvkCq9UdvjRn4pHIGb1JH6+rjVu0mogvfJkhzIPB9L3wj1Nhyvb X-Received: by 2002:a17:906:d9c4:: with SMTP id qk4mr23424717ejb.100.1595876917934; Mon, 27 Jul 2020 12:08:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595876917; cv=none; d=google.com; s=arc-20160816; b=MA6LurZEEIeQPAvMJRRPKbauOUUu41syFLRiqpg2NFS1D8kUPUTga+o8W957Q4Oq7g cG757EJpxqLt0VNSP74j1nO3mnGKrtVGl/h5TJSIH5noMD4n0unk3qkspgeAPl+hfD+p g+bBvDOEihdLkrh7vskv8eaX3XaqxOD+L6OrvtyfTHD3b50Ik1fXYi/Br/i5R+wiSMqh 1bWlARFn9KYoEzp2sjsdea2n6XJhxxh8WEOb0N6JAwtlArETL5rdkEQeXqhE0xUUtc2m YQK2P83dcadlZYD7PKp9mHX7+lej6gGUQpwZAp8m6wUzH9If2fuinkpo281u8RTaKGMt nDSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=n4QxOm62T7cLBVumNmkxBcX70WS+ZyLV/uGeaA5Yi0I=; b=KKgMM71PSrxmPEgxu8S99Ucw0gRn+LT37FxDQtUPc6yFeI7CZummDz/vYwjvxOjO/5 /WDBcDEGZ8b73yBNdqwywNhfV9gijSRokN54BD/HrLVojDmXJCpPUebEECTFxBGWBvLG 1/qe9pTbLr3OSeL3nPPSVWhPicRY7/htEaND0HD4mLcfV9DZyp4ifvVWHyeatOcoTua9 zqvDiQ41WZFNdk2qCSe+6Tk1yQEWeCqAv2vlqiZa7xw4F1wdepgYnTk5sQQTR2r4JgQM jS2DVq+L71Z++GbeDz8H3ggudbSufRxmANEgEDGP5CLZ1CG+pKvKv7AH4Qh+72ueMMPX Yy/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dumtdY0V; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mh23si1381972ejb.493.2020.07.27.12.08.16; Mon, 27 Jul 2020 12:08:37 -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=@chromium.org header.s=google header.b=dumtdY0V; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729284AbgG0SKS (ORCPT + 99 others); Mon, 27 Jul 2020 14:10:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728346AbgG0SKS (ORCPT ); Mon, 27 Jul 2020 14:10:18 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D671BC061794 for ; Mon, 27 Jul 2020 11:10:17 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id o10so3152193edh.6 for ; Mon, 27 Jul 2020 11:10:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=n4QxOm62T7cLBVumNmkxBcX70WS+ZyLV/uGeaA5Yi0I=; b=dumtdY0VczqQ+QU6R96PDWCDuvnG1h/EJf1eTVn/O7/cMDaPpwJQvx9cc9LSm3YIzu OIQ7k2Z5xfyGXJMIxqjaV1eT/3eYIK7NMC4RCpiycEE0LNebpVExO9dhqVy1XRlmDNUw N3nxV0RTtOjNMa7GFQ3ggM/4HbC7D4yh20LNA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=n4QxOm62T7cLBVumNmkxBcX70WS+ZyLV/uGeaA5Yi0I=; b=AdQfqArRstTpZf/1SOPt4kas8BfA8eTev6atdcOBhdRVWEE3JTXPOmU5ZK+J5mXTv7 ur1DOA5neTFbYlzd/EFlJVeG7WAn9ivBWAB45WQckUvdhLogGrkKK+hnN9UcI2op3AeO sKHmPOQWvUMVVm7WiDSU68HhOCJnNDqpB1rRFBD/YCMM2W++9dj4h4M/3rK9G2vu/dIK SBMrMYpjiZ3v4W8wLat1+CaqbRXl/5A6RVWT2FixJXzcnlPtLgd2tNJcxQ0NY9ytz7v0 5emZuNZUv7F/r5bR2Qs3vZ0Bos8DW0QwPHNKcuupTxE4PC4PBbWgv8xfohqPX01KfvIK 5JPA== X-Gm-Message-State: AOAM531W/OvZpBoeESCf9tZfsPTPos9eh4E16E3lTC15EVUaVtN/Polb mZM2uRqnlp7Gmprpcmw246FmM0W0sLntjg== X-Received: by 2002:a50:e60d:: with SMTP id y13mr21927481edm.225.1595873416012; Mon, 27 Jul 2020 11:10:16 -0700 (PDT) Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com. [209.85.221.53]) by smtp.gmail.com with ESMTPSA id qc23sm5439137ejb.97.2020.07.27.11.10.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 27 Jul 2020 11:10:15 -0700 (PDT) Received: by mail-wr1-f53.google.com with SMTP id a5so5830149wrm.6 for ; Mon, 27 Jul 2020 11:10:14 -0700 (PDT) X-Received: by 2002:adf:fe12:: with SMTP id n18mr21409892wrr.295.1595873414404; Mon, 27 Jul 2020 11:10:14 -0700 (PDT) MIME-Version: 1.0 References: <20200715202233.185680-1-ezequiel@collabora.com> <20200715202233.185680-9-ezequiel@collabora.com> <636aab0a2be83e751a82a84ac3946afec2c87a17.camel@collabora.com> In-Reply-To: From: Tomasz Figa Date: Mon, 27 Jul 2020 20:10:01 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 08/10] media: uapi: h264: Clean slice invariants syntax elements To: Ezequiel Garcia Cc: Alexandre Courbot , Linux Media Mailing List , LKML , kernel@collabora.com, Jonas Karlman , Hans Verkuil , Jeffrey Kardatzke , Nicolas Dufresne , Philipp Zabel , Maxime Ripard , Paul Kocialkowski Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 27, 2020 at 6:18 PM Ezequiel Garcia wrote: > > On Mon, 2020-07-27 at 16:52 +0200, Tomasz Figa wrote: > > On Mon, Jul 27, 2020 at 4:39 PM Ezequiel Garcia wrote: > > > Hi Alexandre, > > > > > > Thanks a lot for the review. > > > > > > On Sat, 2020-07-25 at 23:34 +0900, Alexandre Courbot wrote: > > > > On Thu, Jul 16, 2020 at 5:23 AM Ezequiel Garcia wrote: > > > > > The H.264 specification requires in its "Slice header semantics" > > > > > section that the following values shall be the same in all slice headers: > > > > > > > > > > pic_parameter_set_id > > > > > frame_num > > > > > field_pic_flag > > > > > bottom_field_flag > > > > > idr_pic_id > > > > > pic_order_cnt_lsb > > > > > delta_pic_order_cnt_bottom > > > > > delta_pic_order_cnt[ 0 ] > > > > > delta_pic_order_cnt[ 1 ] > > > > > sp_for_switch_flag > > > > > slice_group_change_cycle > > > > > > > > > > and can therefore be moved to the per-frame decode parameters control. > > > > > > > > I am really not a H.264 expert, so this question may not be relevant, > > > > > > All questions are welcome. I'm more than happy to discuss this patchset. > > > > > > > but are these values specified for every slice header in the > > > > bitstream, or are they specified only once per frame? > > > > > > > > I am asking this because it would certainly make user-space code > > > > simpler if we could remain as close to the bitstream as possible. If > > > > these values are specified once per slice, then factorizing them would > > > > leave user-space with the burden of deciding what to do if they change > > > > across slices. > > > > > > > > Note that this is a double-edged sword, because it is not necessarily > > > > better to leave the firmware in charge of deciding what to do in such > > > > a case. :) So hopefully these are only specified once per frame in the > > > > bitstream, in which case your proposal makes complete sense. > > > > > > Frame-based hardwares accelerators such as Hantro and Rockchip VDEC > > > are doing the slice header parsing themselves. Therefore, the > > > driver is not really parsing these fields on each slice header. > > > > > > Currently, we are already using only the first slice in a frame, > > > as you can see from: > > > > > > if (slices[0].flags & V4L2_H264_SLICE_FLAG_FIELD_PIC) > > > reg |= G1_REG_DEC_CTRL0_PIC_FIELDMODE_E; > > > > > > Even if these fields are transported in the slice header, > > > I think it makes sense for us to split them into the decode params > > > (per-frame) control. > > > > > > They are really specified to be the same across all slices, > > > so even I'd say if a bitstream violates this, it's likely > > > either a corrupted bitstream or an encoder bug. > > > > > > OTOH, one thing this makes me realize is that the slice params control > > > is wrongly specified as an array. > > > > It is _not_. > > > > We introduced the hold capture buffer specifically to support > this without having a slice array. > > I don't think we have a plan to support this control properly > as an array. > > If we decide to support the slice control as an array, > we would have to implement a mechanism to specify the array size, > which we currently don't have AFAIK. > That wasn't the conclusion when we discussed this last time on IRC. +Nicolas Dufresne Currently the 1-slice per buffer model is quite impractical: 1) the maximum number of buffers is 32, which for some streams can be less than needed to queue a single frame, 2) even more system call overhead due to the need to repeat various operations (e.g. qbuf/dqbuf) per-slice rather than per-frame, 3) no way to do hardware batching for hardware which supports queuing multiple slices at a time, 4) waste of memory - one needs to allocate all the OUTPUT buffers pessimistically to accommodate the biggest possible slice, while with all-slices-per-frame 1 buffer could be just heuristically allocated to be enough for the whole frame. These need to be carefully evaluated, with some proper testing done to confirm whether they are really a problem or not. > > > Namely, this text > > > should be removed: > > > > > > This structure is expected to be passed as an array, with one > > > entry for each slice included in the bitstream buffer. > > > > > > As the API is really not defined that way. > > > > > > I'll remove that on next iteration. > > > > The v4l2_ctrl_h264_slice_params struct has more data than those that > > are deemed to be the same across all the slices. A remarkable example > > are the size and start_byte_offset fields. > > Not sure how this applies to this discussion. These fields need to be specified for each slice in the buffer to make it possible to handle multiple slices per buffer. Best regards, Tomasz