Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4889376pjb; Mon, 27 Jul 2020 07:40:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEiL69lpbp73DUjfdS1Fti6G+w8vF9a1B5VwppGXNAhtGI7/J2KHCZL8NaZeR7jIauoXps X-Received: by 2002:a17:906:d92c:: with SMTP id rn12mr9484070ejb.187.1595860849628; Mon, 27 Jul 2020 07:40:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595860849; cv=none; d=google.com; s=arc-20160816; b=PNuIJChMBsTxqoKTBUbDt6MnuPSUundDTF6qgD+uzZzhPqY7k6YtDY4Rzb8uXe4KNt 7MbjaB3Dxb+uxv6l4rhdTXZOqWKLUS8Tv4HQWYh6iJ45LU76hLAturRHMaqscQNIXW+X 9L6IsjTmq2wNcufK4hvchJz9mYALNSb7jZzSVCgDqQ7s426NUmAa5dYaY7/mT33D9ftS mM6ZppMfv8sTlqyL+Ccd9zZSM4OXrgtvRBudz39jR6wXJ1qzCJYA4jabeBIagq17CoZw qXIEZb15VR2/0Ie4XT/ZSK8GP9iYiQfkd6PGYtpuOgiKC4DPmJHMd5GCvOaOkjAVeqL4 SjQA== 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:organization:references:in-reply-to:date:cc:to:from :subject:message-id; bh=iJ/wKkpfvy54xugWFBNkhxHs9B/rlKu3ZIHgjIHctDc=; b=e8dSA8oWkcc70sNPE76jGsWz1VV7hKS3isKPzBfB2okPBw91mMnF+W13P/Ikc7QjjI 9r3Ean058ck6YepWYjCqSerF4OQituTU9LNhHpRJQq1Pb9xZkmKhZDH76uIgvZRx90ai MlOPoeG2OhtLzySWKg4czGgh0u0uHlPIsWBiiBh1NtH68gadsaldSWmRIVvnInIrg33g q61fiWyw7Cwwi4WoQAWu7diYF2zBOigtl182cyfRFHehbDqD9/n2kjmPFnfK4if6pBlv dz7gNrIGMajHfXvMGIiHuEXaz+kBm5uD3U3/hIGq7JhAPLpov/R6FnjzkKrDBSm0kcdX zjgQ== 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 b12si5102035ejl.139.2020.07.27.07.40.27; Mon, 27 Jul 2020 07:40:49 -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 S1732990AbgG0Oj0 (ORCPT + 99 others); Mon, 27 Jul 2020 10:39:26 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:39000 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732992AbgG0OjY (ORCPT ); Mon, 27 Jul 2020 10:39:24 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 070152948A2 Message-ID: <636aab0a2be83e751a82a84ac3946afec2c87a17.camel@collabora.com> Subject: Re: [PATCH 08/10] media: uapi: h264: Clean slice invariants syntax elements From: Ezequiel Garcia To: Alexandre Courbot Cc: Linux Media Mailing List , LKML , Tomasz Figa , kernel@collabora.com, Jonas Karlman , Hans Verkuil , Jeffrey Kardatzke , Nicolas Dufresne , Philipp Zabel , Maxime Ripard , Paul Kocialkowski Date: Mon, 27 Jul 2020 11:39:12 -0300 In-Reply-To: References: <20200715202233.185680-1-ezequiel@collabora.com> <20200715202233.185680-9-ezequiel@collabora.com> Organization: Collabora Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.3-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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. Thanks for raising this point, Ezequiel