Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3972017imm; Wed, 5 Sep 2018 08:45:01 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbEmoCjrMj93tXKcdJAEhiTS6rPrg1MZG0iDwfDNpmZKmQ177L87ywCOzsAAzfCHLXGLDb9 X-Received: by 2002:a63:555c:: with SMTP id f28-v6mr37542110pgm.37.1536162301744; Wed, 05 Sep 2018 08:45:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536162301; cv=none; d=google.com; s=arc-20160816; b=CzDIHdMscE6ZOjxyenTt7+UVF9lc5pV1NYspAgD0IaWs2ChtP5rP6i3SIF7i8UIZNF Xd2fZQRb8a/5SwhTMtZLlCoFAVVOXvw3lDaVJr/4+Rs8w/mG88gIhsJH1VP558nmUDx4 y80nUKAY0ojcFNSI6reKoNCKFobCMZGcHAjBhfzUNMYy3Obdk4z3rTHz2IHIvs0AfqZt fGtMFW+c54x1/TFIroTcJg8HHPbaLtxtYNuWZQbMTLP4845pkFqyTzaqhroPrnJQ5VEo lL8sYZ8ZNyDxOaYTyVcHUd1r99IJVvQrnWwLzCRlsYjentlUTVRyRPx8fIlbIU5SnJq3 vJ8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to:date :cc:to:from:subject:message-id; bh=A/O43qoVaxRGC3dwu5SHRbHCcFKd+zjab6Z7GeIhrsQ=; b=K/e9y8DAHiXvnBsft0mLPZ2ieLrdi9GCOQnWniv4b5Pu/FW/yad7+7WH1C5+LVCQvW RNPOrDRzWRD+IQjo2iVhQ1wI0ueb68A/6UYydObUJK69yRvkdXFTzKYZUW/WTnmIffsO rdBIQexG17u1p1ecy84qWifPYCbHhw1q8jWO2c+c7W0+k145AwQEw0iKiazO6u16Gcpc LYzbuYNdfvzXAadMkZUoCxnCwedTsjTxmzgVwkyzwPIkLMCNU9hNZT7zRia5yS9cKt63 yDAWqDF6FwYldmj22ZVVOV8+gd+EmRT0O1A3eX//+QLPXhE7gPgnkTAXhvkVDN6J4cKQ +wrg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d6-v6si2257644pgh.569.2018.09.05.08.44.46; Wed, 05 Sep 2018 08:45:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727373AbeIEUO0 (ORCPT + 99 others); Wed, 5 Sep 2018 16:14:26 -0400 Received: from leonov.paulk.fr ([185.233.101.22]:47102 "EHLO leonov.paulk.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726046AbeIEUO0 (ORCPT ); Wed, 5 Sep 2018 16:14:26 -0400 Received: from gagarine.paulk.fr (gagarine [192.168.1.127]) by leonov.paulk.fr (Postfix) with ESMTPS id 586FFBFDA9; Wed, 5 Sep 2018 17:43:40 +0200 (CEST) Received: by gagarine.paulk.fr (Postfix, from userid 114) id ED7E7C0F51; Wed, 5 Sep 2018 17:43:38 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on gagarine.paulk.fr X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT autolearn=disabled version=3.4.1 Received: from collins (unknown [192.168.1.1]) by gagarine.paulk.fr (Postfix) with ESMTPSA id E9B47BFFE3; Wed, 5 Sep 2018 17:42:59 +0200 (CEST) Message-ID: Subject: Re: [PATCH v8 1/8] media: v4l: Add definitions for MPEG2 slice format and metadata From: Paul Kocialkowski To: Hans Verkuil , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devel@driverdev.osuosl.org Cc: Mauro Carvalho Chehab , Rob Herring , Mark Rutland , Maxime Ripard , Chen-Yu Tsai , Greg Kroah-Hartman , Thomas Petazzoni , Randy Li , Ezequiel Garcia , Tomasz Figa , Alexandre Courbot , Philipp Zabel , Laurent Pinchart , Sakari Ailus , linux-sunxi@googlegroups.com Date: Wed, 05 Sep 2018 17:42:53 +0200 In-Reply-To: References: <20180828073424.30247-1-paul.kocialkowski@bootlin.com> <20180828073424.30247-2-paul.kocialkowski@bootlin.com> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-KKtmpGhZ1gmJYvnYEFWj" X-Mailer: Evolution 3.28.5 Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-KKtmpGhZ1gmJYvnYEFWj Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Hans, Le lundi 03 septembre 2018 =C3=A0 10:32 +0200, Hans Verkuil a =C3=A9crit : > This looks very nice. I have two more comments, but they can be added > using a follow-up patch (unless you need a v9 anyway): I suppose I'll send a v9 to keep things in order here. And thanks for the review! > On 08/28/2018 09:34 AM, Paul Kocialkowski wrote: > > Stateless video decoding engines require both the MPEG slices and > > associated metadata from the video stream in order to decode > > frames. > >=20 > > This introduces definitions for a new pixel format, describing > > buffers > > with MPEG2 slice data, as well as a control structure for passing > > the > > frame metadata to drivers. > >=20 > > This is based on work from both Florent Revest and Hugues Fruchet. > >=20 > > Signed-off-by: Paul Kocialkowski > > --- > > .../media/uapi/v4l/extended-controls.rst | 177 > > ++++++++++++++++++ > > .../media/uapi/v4l/pixfmt-compressed.rst | 14 ++ > > .../media/uapi/v4l/vidioc-queryctrl.rst | 14 +- > > .../media/videodev2.h.rst.exceptions | 2 + > > drivers/media/v4l2-core/v4l2-ctrls.c | 63 +++++++ > > drivers/media/v4l2-core/v4l2-ioctl.c | 1 + > > include/media/v4l2-ctrls.h | 18 +- > > include/uapi/linux/v4l2-controls.h | 65 +++++++ > > include/uapi/linux/videodev2.h | 5 + > > 9 files changed, 350 insertions(+), 9 deletions(-) > >=20 > > diff --git a/Documentation/media/uapi/v4l/extended-controls.rst > > b/Documentation/media/uapi/v4l/extended-controls.rst > > index 9f7312bf3365..a9252225b63e 100644 > > --- a/Documentation/media/uapi/v4l/extended-controls.rst > > +++ b/Documentation/media/uapi/v4l/extended-controls.rst > > @@ -1497,6 +1497,183 @@ enum > > v4l2_mpeg_video_h264_hierarchical_coding_type - > > =20 > > =20 > > =20 > > +.. _v4l2-mpeg-mpeg2: > > + > > +``V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS (struct)`` > > + Specifies the slice parameters (as extracted from the > > bitstream) for the > > + associated MPEG-2 slice data. This includes the necessary > > parameters for > > + configuring a stateless hardware decoding pipeline for MPEG-2. > > + The bitstream parameters are defined according to the ISO/IEC > > 13818-2 and > > + ITU-T Rec. H.262 specifications. >=20 > You need to use references to the specs in the biblio.rst file. > ISO/IEC 13818-2 > is there already. As far as I can see ISO/IEC 13818-2 =3D=3D ITU-T Rec. > H.262, so > it's only one spec, not two. Alright, I had missed that. Will do! > > + > > +.. c:type:: v4l2_ctrl_mpeg2_slice_params > > + > > +.. cssclass:: longtable > > + > > +.. flat-table:: struct v4l2_ctrl_mpeg2_slice_params > > + :header-rows: 0 > > + :stub-columns: 0 > > + :widths: 1 1 2 > > + > > + * - __u32 > > + - ``bit_size`` > > + - Size (in bits) of the current slice data. > > + * - __u32 > > + - ``data_bit_offset`` > > + - Offset (in bits) to the video data in the current slice > > data. > > + * - struct :c:type:`v4l2_mpeg2_sequence` > > + - ``sequence`` > > + - Structure with MPEG-2 sequence metadata, merging relevant > > fields from > > + the sequence header and sequence extension parts of the > > bitstream. > > + * - struct :c:type:`v4l2_mpeg2_picture` > > + - ``picture`` > > + - Structure with MPEG-2 picture metadata, merging relevant > > fields from > > + the picture header and picture coding extension parts of the > > bitstream. > > + * - __u8 > > + - ``quantiser_scale_code`` > > + - Code used to determine the quantization scale to use for > > the IDCT. > > + * - __u8 > > + - ``backward_ref_index`` > > + - Index for the V4L2 buffer to use as backward reference, > > used with > > + B-coded and P-coded frames. > > + * - __u8 > > + - ``forward_ref_index`` > > + - Index for the V4L2 buffer to use as forward reference, > > used with > > + P-coded frames. > > + > > +.. c:type:: v4l2_mpeg2_sequence > > + > > +.. cssclass:: longtable > > + > > +.. flat-table:: struct v4l2_mpeg2_sequence > > + :header-rows: 0 > > + :stub-columns: 0 > > + :widths: 1 1 2 > > + > > + * - __u16 > > + - ``horizontal_size`` > > + - The width of the displayable part of the frame's luminance > > component. > > + * - __u16 > > + - ``vertical_size`` > > + - The height of the displayable part of the frame's > > luminance component. > > + * - __u32 > > + - ``vbv_buffer_size`` > > + - Used to calculate the required size of the video buffering > > verifier, > > + defined (in bits) as: 16 * 1024 * vbv_buffer_size. > > + * - __u8 > > + - ``profile_and_level_indication`` > > + - The current profile and level indication as extracted from > > the > > + bitstream. > > + * - __u8 > > + - ``progressive_sequence`` > > + - Indication that all the frames for the sequence are > > progressive instead > > + of interlaced. > > + * - __u8 > > + - ``chroma_format`` > > + - The chrominance sub-sampling format (1: 4:2:0, 2: 4:2:2, > > 3: 4:4:4). > > + > > +.. c:type:: v4l2_mpeg2_picture > > + > > +.. cssclass:: longtable > > + > > +.. flat-table:: struct v4l2_mpeg2_picture > > + :header-rows: 0 > > + :stub-columns: 0 > > + :widths: 1 1 2 > > + > > + * - __u8 > > + - ``picture_coding_type`` > > + - Picture coding type for the frame covered by the current > > slice > > + (V4L2_MPEG2_PICTURE_CODING_TYPE_I, > > V4L2_MPEG2_PICTURE_CODING_TYPE_P or > > + V4L2_MPEG2_PICTURE_CODING_TYPE_B). > > + * - __u8 > > + - ``f_code[2][2]`` > > + - Motion vector codes. > > + * - __u8 > > + - ``intra_dc_precision`` > > + - Precision of Discrete Cosine transform (0: 8 bits > > precision, > > + 1: 9 bits precision, 2: 10 bits precision, 3: 11 bits > > precision). > > + * - __u8 > > + - ``picture_structure`` > > + - Picture structure (1: interlaced top field, 2: interlaced > > bottom field, > > + 3: progressive frame). > > + * - __u8 > > + - ``top_field_first`` > > + - If set to 1 and interlaced stream, top field is output > > first. > > + * - __u8 > > + - ``frame_pred_frame_dct`` > > + - If set to 1, only frame-DCT and frame prediction are used. > > + * - __u8 > > + - ``concealment_motion_vectors`` > > + - If set to 1, motion vectors are coded for intra > > macroblocks. > > + * - __u8 > > + - ``q_scale_type`` > > + - This flag affects the inverse quantization process. > > + * - __u8 > > + - ``intra_vlc_format`` > > + - This flag affects the decoding of transform coefficient > > data. > > + * - __u8 > > + - ``alternate_scan`` > > + - This flag affects the decoding of transform coefficient > > data. > > + * - __u8 > > + - ``repeat_first_field`` > > + - This flag affects the decoding process of progressive > > frames. > > + * - __u8 > > + - ``progressive_frame`` > > + - Indicates whether the current frame is progressive. > > + > > +``V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION (struct)`` > > + Specifies quantization matrices (as extracted from the > > bitstream) for the > > + associated MPEG-2 slice data. > > + > > +.. c:type:: v4l2_ctrl_mpeg2_quantization > > + > > +.. cssclass:: longtable > > + > > +.. flat-table:: struct v4l2_ctrl_mpeg2_quantization > > + :header-rows: 0 > > + :stub-columns: 0 > > + :widths: 1 1 2 > > + > > + * - __u8 > > + - ``load_intra_quantiser_matrix`` > > + - One bit to indicate whether to load the > > ``intra_quantiser_matrix`` data. > > + * - __u8 > > + - ``load_non_intra_quantiser_matrix`` > > + - One bit to indicate whether to load the > > ``non_intra_quantiser_matrix`` > > + data. > > + * - __u8 > > + - ``load_chroma_intra_quantiser_matrix`` > > + - One bit to indicate whether to load the > > + ``chroma_intra_quantiser_matrix`` data, only relevant for non- > > 4:2:0 YUV > > + formats. > > + * - __u8 > > + - ``load_chroma_non_intra_quantiser_matrix`` > > + - One bit to indicate whether to load the > > + ``chroma_non_intra_quantiser_matrix`` data, only relevant for > > non-4:2:0 > > + YUV formats. > > + * - __u8 > > + - ``intra_quantiser_matrix[64]`` > > + - The quantization matrix coefficients for intra-coded > > frames, in zigzag > > + scanning order. It is relevant for both luma and chroma > > components, > > + although it can be superseded by the chroma-specific matrix for > > + non-4:2:0 YUV formats. > > + * - __u8 > > + - ``non_intra_quantiser_matrix[64]`` > > + - The quantization matrix coefficients for non-intra-coded > > frames, in > > + zigzag scanning order. It is relevant for both luma and chroma > > + components, although it can be superseded by the chroma- > > specific matrix > > + for non-4:2:0 YUV formats. > > + * - __u8 > > + - ``chroma_intra_quantiser_matrix[64]`` > > + - The quantization matrix coefficients for the chominance > > component of > > + intra-coded frames, in zigzag scanning order. Only relevant for > > + non-4:2:0 YUV formats. > > + * - __u8 > > + - ``chroma_non_intra_quantiser_matrix[64]`` > > + - The quantization matrix coefficients for the chrominance > > component of > > + non-intra-coded frames, in zigzag scanning order. Only relevant > > for > > + non-4:2:0 YUV formats. > > =20 > > MFC 5.1 MPEG Controls > > --------------------- > > diff --git a/Documentation/media/uapi/v4l/pixfmt-compressed.rst > > b/Documentation/media/uapi/v4l/pixfmt-compressed.rst > > index d382e7a5c38e..a86b59f770dd 100644 > > --- a/Documentation/media/uapi/v4l/pixfmt-compressed.rst > > +++ b/Documentation/media/uapi/v4l/pixfmt-compressed.rst > > @@ -60,6 +60,20 @@ Compressed Formats > > - ``V4L2_PIX_FMT_MPEG2`` > > - 'MPG2' > > - MPEG2 video elementary stream. > > + * .. _V4L2-PIX-FMT-MPEG2-SLICE: > > + > > + - ``V4L2_PIX_FMT_MPEG2_SLICE`` > > + - 'MG2S' > > + - MPEG-2 parsed slice data, as extracted from the MPEG-2 > > bitstream. > > + This format is adapted for stateless video decoders that > > implement a > > + MPEG-2 pipeline (using the Memory to Memory and Media Request > > APIs). >=20 > Use references to the corresponding sections in the spec so the > reader can just > click on the link. Sure thing! Cheers, Paul > Regards, >=20 > Hans >=20 > > + Metadata associated with the frame to decode is required to be > > passed > > + through the ``V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS`` control > > and > > + quantization matrices can optionally be specified through the > > + ``V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION`` control. > > + See the :ref:`associated Codec Control IDs `. > > + Buffers associated with this pixel format must contain the > > appropriate > > + number of macroblocks to decode a full corresponding frame. > > * .. _V4L2-PIX-FMT-MPEG4: > > =20 > > - ``V4L2_PIX_FMT_MPEG4`` > > diff --git a/Documentation/media/uapi/v4l/vidioc-queryctrl.rst > > b/Documentation/media/uapi/v4l/vidioc-queryctrl.rst > > index 5bd26e8c9a1a..258f5813f281 100644 > > --- a/Documentation/media/uapi/v4l/vidioc-queryctrl.rst > > +++ b/Documentation/media/uapi/v4l/vidioc-queryctrl.rst > > @@ -424,8 +424,18 @@ See also the examples in :ref:`control`. > > - any > > - An unsigned 32-bit valued control ranging from minimum to > > maximum > > inclusive. The step value indicates the increment between > > values. > > - > > - > > + * - ``V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS`` > > + - n/a > > + - n/a > > + - n/a > > + - A struct :c:type:`v4l2_ctrl_mpeg2_slice_params`, > > containing MPEG-2 > > + slice parameters for stateless video decoders. > > + * - ``V4L2_CTRL_TYPE_MPEG2_QUANTIZATION`` > > + - n/a > > + - n/a > > + - n/a > > + - A struct :c:type:`v4l2_ctrl_mpeg2_quantization`, > > containing MPEG-2 > > + quantization matrices for stateless video decoders. > > =20 > > .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| > > =20 > > diff --git a/Documentation/media/videodev2.h.rst.exceptions > > b/Documentation/media/videodev2.h.rst.exceptions > > index 99256a2c003e..30ba0d6f546f 100644 > > --- a/Documentation/media/videodev2.h.rst.exceptions > > +++ b/Documentation/media/videodev2.h.rst.exceptions > > @@ -129,6 +129,8 @@ replace symbol V4L2_CTRL_TYPE_STRING > > :c:type:`v4l2_ctrl_type` > > replace symbol V4L2_CTRL_TYPE_U16 :c:type:`v4l2_ctrl_type` > > replace symbol V4L2_CTRL_TYPE_U32 :c:type:`v4l2_ctrl_type` > > replace symbol V4L2_CTRL_TYPE_U8 :c:type:`v4l2_ctrl_type` > > +replace symbol V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS > > :c:type:`v4l2_ctrl_type` > > +replace symbol V4L2_CTRL_TYPE_MPEG2_QUANTIZATION > > :c:type:`v4l2_ctrl_type` > > =20 > > # V4L2 capability defines > > replace define V4L2_CAP_VIDEO_CAPTURE device-capabilities > > diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c > > b/drivers/media/v4l2-core/v4l2-ctrls.c > > index ccaf3068de6d..bcf520e0f61c 100644 > > --- a/drivers/media/v4l2-core/v4l2-ctrls.c > > +++ b/drivers/media/v4l2-core/v4l2-ctrls.c > > @@ -844,6 +844,8 @@ const char *v4l2_ctrl_get_name(u32 id) > > case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE: return > > "Vertical MV Search Range"; > > case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER: return > > "Repeat Sequence Header"; > > case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME: return > > "Force Key Frame"; > > + case V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS: ret > > urn "MPEG-2 Slice Parameters"; > > + case V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION: ret > > urn "MPEG-2 Quantization Matrices"; > > =20 > > /* VPX controls */ > > case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS: ret > > urn "VPX Number of Partitions"; > > @@ -1292,6 +1294,12 @@ void v4l2_ctrl_fill(u32 id, const char > > **name, enum v4l2_ctrl_type *type, > > case V4L2_CID_RDS_TX_ALT_FREQS: > > *type =3D V4L2_CTRL_TYPE_U32; > > break; > > + case V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS: > > + *type =3D V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS; > > + break; > > + case V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION: > > + *type =3D V4L2_CTRL_TYPE_MPEG2_QUANTIZATION; > > + break; > > default: > > *type =3D V4L2_CTRL_TYPE_INTEGER; > > break; > > @@ -1550,6 +1558,7 @@ static void std_log(const struct v4l2_ctrl > > *ctrl) > > static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx, > > union v4l2_ctrl_ptr ptr) > > { > > + struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; > > size_t len; > > u64 offset; > > s64 val; > > @@ -1612,6 +1621,54 @@ static int std_validate(const struct > > v4l2_ctrl *ctrl, u32 idx, > > return -ERANGE; > > return 0; > > =20 > > + case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS: > > + p_mpeg2_slice_params =3D ptr.p; > > + > > + switch (p_mpeg2_slice_params->sequence.chroma_format) { > > + case 1: /* 4:2:0 */ > > + case 2: /* 4:2:2 */ > > + case 3: /* 4:4:4 */ > > + break; > > + default: > > + return -EINVAL; > > + } > > + > > + switch (p_mpeg2_slice_params- > > >picture.intra_dc_precision) { > > + case 0: /* 8 bits */ > > + case 1: /* 9 bits */ > > + case 11: /* 11 bits */ > > + break; > > + default: > > + return -EINVAL; > > + } > > + > > + switch (p_mpeg2_slice_params- > > >picture.picture_structure) { > > + case 1: /* interlaced top field */ > > + case 2: /* interlaced bottom field */ > > + case 3: /* progressive */ > > + break; > > + default: > > + return -EINVAL; > > + } > > + > > + switch (p_mpeg2_slice_params- > > >picture.picture_coding_type) { > > + case V4L2_MPEG2_PICTURE_CODING_TYPE_I: > > + case V4L2_MPEG2_PICTURE_CODING_TYPE_P: > > + case V4L2_MPEG2_PICTURE_CODING_TYPE_B: > > + break; > > + default: > > + return -EINVAL; > > + } > > + > > + if (p_mpeg2_slice_params->backward_ref_index >=3D > > VIDEO_MAX_FRAME || > > + p_mpeg2_slice_params->forward_ref_index >=3D > > VIDEO_MAX_FRAME) > > + return -EINVAL; > > + > > + return 0; > > + > > + case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION: > > + return 0; > > + > > default: > > return -EINVAL; > > } > > @@ -2186,6 +2243,12 @@ static struct v4l2_ctrl > > *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, > > case V4L2_CTRL_TYPE_U32: > > elem_size =3D sizeof(u32); > > break; > > + case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS: > > + elem_size =3D sizeof(struct > > v4l2_ctrl_mpeg2_slice_params); > > + break; > > + case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION: > > + elem_size =3D sizeof(struct > > v4l2_ctrl_mpeg2_quantization); > > + break; > > default: > > if (type < V4L2_CTRL_COMPOUND_TYPES) > > elem_size =3D sizeof(s32); > > diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c > > b/drivers/media/v4l2-core/v4l2-ioctl.c > > index 87dba0b9c0a7..1a8feaf6c3f7 100644 > > --- a/drivers/media/v4l2-core/v4l2-ioctl.c > > +++ b/drivers/media/v4l2-core/v4l2-ioctl.c > > @@ -1309,6 +1309,7 @@ static void v4l_fill_fmtdesc(struct > > v4l2_fmtdesc *fmt) > > case V4L2_PIX_FMT_H263: descr =3D "H.263"; > > break; > > case V4L2_PIX_FMT_MPEG1: descr =3D "MPEG-1 ES"; break; > > case V4L2_PIX_FMT_MPEG2: descr =3D "MPEG-2 ES"; break; > > + case V4L2_PIX_FMT_MPEG2_SLICE: descr =3D "MPEG-2 > > Parsed Slice Data"; break; > > case V4L2_PIX_FMT_MPEG4: descr =3D "MPEG-4 part 2 ES"; > > break; > > case V4L2_PIX_FMT_XVID: descr =3D "Xvid"; > > break; > > case V4L2_PIX_FMT_VC1_ANNEX_G: descr =3D "VC-1 > > (SMPTE 412M Annex G)"; break; > > diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2- > > ctrls.h > > index 53ca4df0c353..0dae03dd5b06 100644 > > --- a/include/media/v4l2-ctrls.h > > +++ b/include/media/v4l2-ctrls.h > > @@ -35,13 +35,15 @@ struct poll_table_struct; > > =20 > > /** > > * union v4l2_ctrl_ptr - A pointer to a control value. > > - * @p_s32: Pointer to a 32-bit signed value. > > - * @p_s64: Pointer to a 64-bit signed value. > > - * @p_u8: Pointer to a 8-bit unsigned value. > > - * @p_u16: Pointer to a 16-bit unsigned value. > > - * @p_u32: Pointer to a 32-bit unsigned value. > > - * @p_char: Pointer to a string. > > - * @p: Pointer to a compound value. > > + * @p_s32: Pointer to a 32-bit signed value. > > + * @p_s64: Pointer to a 64-bit signed value. > > + * @p_u8: Pointer to a 8-bit unsigned value. > > + * @p_u16: Pointer to a 16-bit unsigned value. > > + * @p_u32: Pointer to a 32-bit unsigned value. > > + * @p_char: Pointer to a string. > > + * @p_mpeg2_slice_params: Pointer to a MPEG2 slice parameters > > structure. > > + * @p_mpeg2_quantization: Pointer to a MPEG2 quantization data > > structure. > > + * @p: Pointer to a compound value. > > */ > > union v4l2_ctrl_ptr { > > s32 *p_s32; > > @@ -50,6 +52,8 @@ union v4l2_ctrl_ptr { > > u16 *p_u16; > > u32 *p_u32; > > char *p_char; > > + struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; > > + struct v4l2_ctrl_mpeg2_quantization *p_mpeg2_quantization; > > void *p; > > }; > > =20 > > diff --git a/include/uapi/linux/v4l2-controls.h > > b/include/uapi/linux/v4l2-controls.h > > index e4ee10ee917d..51b095898f4b 100644 > > --- a/include/uapi/linux/v4l2-controls.h > > +++ b/include/uapi/linux/v4l2-controls.h > > @@ -402,6 +402,9 @@ enum v4l2_mpeg_video_multi_slice_mode { > > #define V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE (V4L2_C > > ID_MPEG_BASE+228) > > #define V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME (V4L2_C > > ID_MPEG_BASE+229) > > =20 > > +#define V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS (V4L2_C > > ID_MPEG_BASE+250) > > +#define V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION (V4L2_C > > ID_MPEG_BASE+251) > > + > > #define V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP (V4L2_C > > ID_MPEG_BASE+300) > > #define V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP (V4L2_C > > ID_MPEG_BASE+301) > > #define V4L2_CID_MPEG_VIDEO_H263_B_FRAME_QP (V4L2_C > > ID_MPEG_BASE+302) > > @@ -1092,4 +1095,66 @@ enum v4l2_detect_md_mode { > > #define V4L2_CID_DETECT_MD_THRESHOLD_GRID (V4L2_CID_DETECT_CLASS_ > > BASE + 3) > > #define V4L2_CID_DETECT_MD_REGION_GRID (V4L2_CID_DETEC > > T_CLASS_BASE + 4) > > =20 > > +#define V4L2_MPEG2_PICTURE_CODING_TYPE_I 1 > > +#define V4L2_MPEG2_PICTURE_CODING_TYPE_P 2 > > +#define V4L2_MPEG2_PICTURE_CODING_TYPE_B 3 > > +#define V4L2_MPEG2_PICTURE_CODING_TYPE_D 4 > > + > > +struct v4l2_mpeg2_sequence { > > + /* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence header */ > > + __u16 horizontal_size; > > + __u16 vertical_size; > > + __u32 vbv_buffer_size; > > + > > + /* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence extension */ > > + __u8 profile_and_level_indication; > > + __u8 progressive_sequence; > > + __u8 chroma_format; > > +}; > > + > > +struct v4l2_mpeg2_picture { > > + /* ISO/IEC 13818-2, ITU-T Rec. H.262: Picture header */ > > + __u8 picture_coding_type; > > + > > + /* ISO/IEC 13818-2, ITU-T Rec. H.262: Picture coding extension > > */ > > + __u8 f_code[2][2]; > > + __u8 intra_dc_precision; > > + __u8 picture_structure; > > + __u8 top_field_first; > > + __u8 frame_pred_frame_dct; > > + __u8 concealment_motion_vectors; > > + __u8 q_scale_type; > > + __u8 intra_vlc_format; > > + __u8 alternate_scan; > > + __u8 repeat_first_field; > > + __u8 progressive_frame; > > +}; > > + > > +struct v4l2_ctrl_mpeg2_slice_params { > > + __u32 bit_size; > > + __u32 data_bit_offset; > > + > > + struct v4l2_mpeg2_sequence sequence; > > + struct v4l2_mpeg2_picture picture; > > + > > + /* ISO/IEC 13818-2, ITU-T Rec. H.262: Slice */ > > + __u8 quantiser_scale_code; > > + > > + __u8 backward_ref_index; > > + __u8 forward_ref_index; > > +}; > > + > > +struct v4l2_ctrl_mpeg2_quantization { > > + /* ISO/IEC 13818-2, ITU-T Rec. H.262: Quant matrix extension */ > > + __u8 load_intra_quantiser_matrix; > > + __u8 load_non_intra_quantiser_matrix; > > + __u8 load_chroma_intra_quantiser_matrix; > > + __u8 load_chroma_non_intra_quantiser_matrix; > > + > > + __u8 intra_quantiser_matrix[64]; > > + __u8 non_intra_quantiser_matrix[64]; > > + __u8 chroma_intra_quantiser_matrix[64]; > > + __u8 chroma_non_intra_quantiser_matrix[64]; > > +}; > > + > > #endif > > diff --git a/include/uapi/linux/videodev2.h > > b/include/uapi/linux/videodev2.h > > index 490fc9964d97..ad7064fcccea 100644 > > --- a/include/uapi/linux/videodev2.h > > +++ b/include/uapi/linux/videodev2.h > > @@ -635,6 +635,7 @@ struct v4l2_pix_format { > > #define V4L2_PIX_FMT_H263 v4l2_fourcc('H', '2', '6', '3') /* > > H263 */ > > #define V4L2_PIX_FMT_MPEG1 v4l2_fourcc('M', 'P', 'G', '1') /* > > MPEG-1 ES */ > > #define V4L2_PIX_FMT_MPEG2 v4l2_fourcc('M', 'P', 'G', '2') /* > > MPEG-2 ES */ > > +#define V4L2_PIX_FMT_MPEG2_SLICE v4l2_fourcc('M', 'G', '2', 'S') > > /* MPEG-2 parsed slice data */ > > #define V4L2_PIX_FMT_MPEG4 v4l2_fourcc('M', 'P', 'G', '4') /* > > MPEG-4 part 2 ES */ > > #define V4L2_PIX_FMT_XVID v4l2_fourcc('X', 'V', 'I', 'D') /* > > Xvid */ > > #define V4L2_PIX_FMT_VC1_ANNEX_G v4l2_fourcc('V', 'C', '1', 'G') > > /* SMPTE 421M Annex G compliant stream */ > > @@ -1601,6 +1602,8 @@ struct v4l2_ext_control { > > __u8 __user *p_u8; > > __u16 __user *p_u16; > > __u32 __user *p_u32; > > + struct v4l2_ctrl_mpeg2_slice_params __user > > *p_mpeg2_slice_params; > > + struct v4l2_ctrl_mpeg2_quantization __user > > *p_mpeg2_quantization; > > void __user *ptr; > > }; > > } __attribute__ ((packed)); > > @@ -1646,6 +1649,8 @@ enum v4l2_ctrl_type { > > V4L2_CTRL_TYPE_U8 =3D 0x0100, > > V4L2_CTRL_TYPE_U16 =3D 0x0101, > > V4L2_CTRL_TYPE_U32 =3D 0x0102, > > + V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS =3D 0x0103, > > + V4L2_CTRL_TYPE_MPEG2_QUANTIZATION =3D 0x0104, > > }; > > =20 > > /* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ > >=20 >=20 >=20 --=20 Developer of free digital technology and hardware support. Website: https://www.paulk.fr/ Coding blog: https://code.paulk.fr/ Git repositories: https://git.paulk.fr/ https://git.code.paulk.fr/ --=-KKtmpGhZ1gmJYvnYEFWj Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEAbcMXZQMtj1fphLChP3B6o/ulQwFAluP+X0ACgkQhP3B6o/u lQzNAg/+O1VXlOFSP3dK/0eEY0aGJ7Bl6C8Tf1HJ6G0bzR2wcMC4rS6Z3ePf/Exw 6aInL2O0G7sMC9af2jw7SN5mUBQSVGfxoge9Cd5IqkbQRK/YQBiIqev/BznRARvN EHiQNPRiU/K8VBv0Qk09uQg4tQhNPmPonmaRm+2a5o1PUoqs5xHrArMjnpNRNRrj LTIwVrQX1Y1DR4XD39QSvejDrphih7FKMwMfvRMHAsGpOYyJqTlQ2FDNnmNUhC8p FSL+DA28XKSGEDcIuDf+Z7Rt3uoVpC0DCae3siyUEmpR6h2rIYLlcPD16zh57UA6 MVTRsT3MwdFpjHJJKgG+D6sIlqQjih+bu3Vwjl0Oq5W1dcFy+phQsCWE++COQoLo 7c/UNwImYhINOk/brU+KvXzEe9+ue4blTeNcXNZSzrywoCPMJsaQYBo8iXin+zz8 1QwdU1Gy7WinFSUtOAsHcguG8DYCXuUtQhOhl5fh1P0hTvUhhDI0UM8+ZZuOpKoj 5UoXnc7k8l/KiGwx64VK7xMlXL2RlgCtZq4uhhCt2wvJeZ0PGjB2xmFkVYGeIRf7 cXRXX5/obEouc+fDfmp8w5PWMUo48pBgxqilDwEFjms/oc/02Ml8zqOn4CFuULIg ouE1MOYyP5re7PNWf9nyxFQq8qPIInsGq53fXmPjtirSKRnc7hc= =Ufc/ -----END PGP SIGNATURE----- --=-KKtmpGhZ1gmJYvnYEFWj--