From patchwork Fri Apr 28 13:25:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugues FRUCHET X-Patchwork-Id: 9704707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4BAF3603F7 for ; Fri, 28 Apr 2017 13:29:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3946A28684 for ; Fri, 28 Apr 2017 13:29:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E41D2868F; Fri, 28 Apr 2017 13:29:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2B3B2868C for ; Fri, 28 Apr 2017 13:29:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2997148AbdD1N3W (ORCPT ); Fri, 28 Apr 2017 09:29:22 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:30920 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2997130AbdD1N3T (ORCPT ); Fri, 28 Apr 2017 09:29:19 -0400 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by m0046037.ppops.net (8.16.0.11/8.16.0.11) with SMTP id v3SDTFkh032131; Fri, 28 Apr 2017 15:29:17 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-.pphosted.com with ESMTP id 2a24ac6fe7-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 28 Apr 2017 15:29:17 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 3693434; Fri, 28 Apr 2017 13:29:17 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas23.st.com [10.75.90.46]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 021612405; Fri, 28 Apr 2017 13:29:16 +0000 (GMT) Received: from localhost (10.201.23.73) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.339.0; Fri, 28 Apr 2017 15:29:16 +0200 From: Hugues Fruchet To: , Hans Verkuil CC: Benjamin Gaignard , Hugues Fruchet , Jean-Christophe Trotin Subject: [PATCH v6 1/3] [media] v4l: add parsed MPEG-2 support Date: Fri, 28 Apr 2017 15:25:47 +0200 Message-ID: <1493385949-2962-2-git-send-email-hugues.fruchet@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1493385949-2962-1-git-send-email-hugues.fruchet@st.com> References: <1493385949-2962-1-git-send-email-hugues.fruchet@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.23.73] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-28_06:, , signatures=0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add "parsed MPEG-2" pixel format & related controls needed by stateless video decoders. In order to decode the video bitstream chunk provided by user on output queue, stateless decoders require also some extra data resulting from this video bitstream chunk parsing. Those parsed extra data have to be set by user through control framework using the dedicated mpeg video extended controls introduced in this patchset. Signed-off-by: Hugues Fruchet --- Documentation/media/uapi/v4l/extended-controls.rst | 363 +++++++++++++++++++++ Documentation/media/uapi/v4l/pixfmt-013.rst | 10 + Documentation/media/uapi/v4l/vidioc-queryctrl.rst | 38 ++- Documentation/media/videodev2.h.rst.exceptions | 6 + drivers/media/v4l2-core/v4l2-ctrls.c | 53 +++ drivers/media/v4l2-core/v4l2-ioctl.c | 2 + include/uapi/linux/v4l2-controls.h | 94 ++++++ include/uapi/linux/videodev2.h | 8 + 8 files changed, 572 insertions(+), 2 deletions(-) diff --git a/Documentation/media/uapi/v4l/extended-controls.rst b/Documentation/media/uapi/v4l/extended-controls.rst index abb1057..b48eac9 100644 --- a/Documentation/media/uapi/v4l/extended-controls.rst +++ b/Documentation/media/uapi/v4l/extended-controls.rst @@ -1827,6 +1827,369 @@ enum v4l2_mpeg_cx2341x_video_median_filter_type - not insert, 1 = insert packets. +MPEG-2 Parsed Control Reference +--------------------------------- + +The MPEG-2 parsed decoding controls are needed by stateless video decoders. +Those decoders expose :ref:`Compressed formats ` :ref:`V4L2_PIX_FMT_MPEG1_PARSED` or :ref:`V4L2_PIX_FMT_MPEG2_PARSED`. +In order to decode the video bitstream chunk provided by user on output queue, +stateless decoders require also some extra data resulting from this video +bitstream chunk parsing. Those parsed extra data have to be set by user +through control framework using the mpeg video extended controls defined +in this section. Those controls have been defined based on MPEG-2 standard +ISO/IEC 13818-2, and so derive directly from the MPEG-2 video bitstream syntax +including how it is coded inside bitstream (enumeration values for ex.). + +MPEG-2 Parsed Control IDs +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. _mpeg2-parsed-control-id: + +.. c:type:: V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_HDR + (enum) + +.. tabularcolumns:: |p{4.0cm}|p{2.5cm}|p{11.0cm}| + +.. c:type:: v4l2_mpeg_video_mpeg2_seq_hdr + +.. cssclass:: longtable + +.. flat-table:: struct v4l2_mpeg_video_mpeg2_seq_hdr + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - __u16 + - ``width`` + - Video width in pixels. + * - __u16 + - ``height`` + - Video height in pixels. + * - __u8 + - ``aspect_ratio_info`` + - Aspect ratio code as in the bitstream (1: 1:1 square pixels, + 2: 4:3 display, 3: 16:9 display, 4: 2.21:1 display) + * - __u8 + - ``framerate code`` + - Framerate code as in the bitstream + (1: 24000/1001.0 '23.976 fps, 2: 24.0, 3: 25.0, + 4: 30000/1001.0 '29.97, 5: 30.0, 6: 50.0, 7: 60000/1001.0, + 8: 60.0) + * - __u16 + - ``vbv_buffer_size`` + - Video Buffering Verifier size, expressed in 16KBytes unit. + * - __u32 + - ``bitrate_value`` + - Bitrate value as in the bitstream, expressed in 400bps unit + * - __u16 + - ``constrained_parameters_flag`` + - Set to 1 if this bitstream uses constrained parameters. + * - __u8 + - ``load_intra_quantiser_matrix`` + - If set to 1, ``intra_quantiser_matrix`` table is to be used for + decoding. + * - __u8 + - ``load_non_intra_quantiser_matrix`` + - If set to 1, ``non_intra_quantiser_matrix`` table is to be used for + decoding. + * - __u8 + - ``intra_quantiser_matrix[64]`` + - Intra quantization table, in zig-zag scan order. + * - __u8 + - ``non_intra_quantiser_matrix[64]`` + - Non-intra quantization table, in zig-zag scan order. + * - __u32 + - ``par_w`` + - Pixel aspect ratio width in pixels. + * - __u32 + - ``par_h`` + - Pixel aspect ratio height in pixels. + * - __u32 + - ``fps_n`` + - Framerate nominator. + * - __u32 + - ``fps_d`` + - Framerate denominator. + * - __u32 + - ``bitrate`` + - Bitrate in bps if constant bitrate, 0 otherwise. + * - :cspan:`2` + + +.. c:type:: V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_EXT + (enum) + +.. tabularcolumns:: |p{4.0cm}|p{2.5cm}|p{11.0cm}| + +.. c:type:: v4l2_mpeg_video_mpeg2_seq_ext + +.. cssclass:: longtable + +.. flat-table:: struct v4l2_mpeg_video_mpeg2_seq_ext + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - __u8 + - ``profile`` + - Encoding profile used to encode this bitstream. + (1: High Profile, 2: Spatially Scalable Profile, + 3: SNR Scalable Profile, 4: Main Profile, 5: Simple Profile). + * - __u8 + - ``level`` + - Encoding level used to encode this bitstream + (4: High Level, 6: High 1440 Level, 8: Main Level, 10: Low Level). + * - __u8 + - ``progressive`` + - Set to 1 if frames are progressive (vs interlaced). + * - __u8 + - ``chroma_format`` + - Chrominance format (1: 420, 2: 422, 3: 444). + * - __u8 + - ``horiz_size_ext`` + - Horizontal size extension. This value is to be shifted 12 bits left + and added to ''seq_hdr->width'' to get the final video width: + `width = seq_hdr->width + seq_ext->horiz_size_ext << 12` + * - __u8 + - ``vert_size_ext`` + - Vertical size extension. This value is to be shifted 12 bits left + and added to ''seq_hdr->height'' to get the final video height: + `height = seq_hdr->height + seq_ext->vert_size_ext << 12` + * - __u16 + - ``bitrate_ext`` + - Bitrate extension. This value, expressed in 400bps unit, is to be + shifted 18 bits left and added to ''seq_hdr->bitrate'' to get the + final bitrate: + `bitrate = seq_hdr->bitrate + (seq_ext->bitrate_ext << 18) * 400` + * - __u8 + - ``vbv_buffer_size_ext`` + - Video Buffering Verifier size extension in bits. + * - __u8 + - ``low_delay`` + - Low delay. Set to 1 if no B pictures are present. + * - __u8 + - ``fps_n_ext`` + - Framerate extension nominator. This value is to be incremented and + multiplied by ''seq_hdr->fps_n'' to get the final framerate + nominator: + `fps_n = seq_hdr->fps_n * (seq_ext->fps_n_ext + 1)` + * - __u8 + - ``fps_d_ext`` + - Framerate extension denominator. This value is to be incremented and + multiplied by ''seq_hdr->fps_d'' to get the final framerate + denominator: + `fps_d = seq_hdr->fps_d * (seq_ext->fps_d_ext + 1)` + * - :cspan:`2` + + +.. c:type:: V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_DISPLAY_EXT + (enum) + +.. tabularcolumns:: |p{4.0cm}|p{2.5cm}|p{11.0cm}| + +.. c:type:: v4l2_mpeg_video_mpeg2_seq_display_ext + +.. cssclass:: longtable + +.. flat-table:: struct v4l2_mpeg_video_mpeg2_seq_display_ext + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - __u16 + - ``display_horizontal_size``, ``display_vertical_size`` + - Dimensions of the video to be displayed. If those dimensions + are smaller than the final video dimensions, only this area + must be displayed. + * - __u8 + - ``video_format`` + - Video standard (0: Components, 1: PAL, 2: NTSC, 3: SECAM, 4:MAC) + * - __u8 + - ``colour_description_flag`` + - If set to 1, ''colour_primaries'', ''transfer_characteristics'', + ''matrix_coefficients'' are to be used for decoding. + * - __u8 + - ``colour_primaries`` + - Colour coding standard (1: ITU-R Rec. 709 (1990), + 4: ITU-R Rec. 624-4 System M, 5: ITU-R Rec. 624-4 System B, G, + 6: SMPTE 170M, 7: SMPTE 240M (1987)) + * - __u8 + - ``transfer_characteristics`` + - Transfer characteristics coding standard (1: ITU-R Rec. 709 (1990), + 4: ITU-R Rec. 624-4 System M, 5: ITU-R Rec. 624-4 System B, G, + 6: SMPTE 170M, 7: SMPTE 240M (1987)) + * - __u8 + - ``matrix_coefficients`` + - Matrix coefficients coding standard (1: ITU-R Rec. 709 (1990), + 4: FCC, 5: ITU-R Rec. 624-4 System B, G, 6: SMPTE 170M, + 7: SMPTE 240M (1987)) + * - :cspan:`2` + + +.. c:type:: V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_MATRIX_EXT + (enum) + +.. tabularcolumns:: |p{4.0cm}|p{2.5cm}|p{11.0cm}| + +.. c:type:: v4l2_mpeg_video_mpeg2_seq_matrix_ext + +.. cssclass:: longtable + +.. flat-table:: struct v4l2_mpeg_video_mpeg2_seq_matrix_ext + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - __u8 + - ``load_intra_quantiser_matrix`` + - If set to 1, ``intra_quantiser_matrix`` table is to be used for + decoding. + * - __u8 + - ``intra_quantiser_matrix[64]`` + - Intra quantization table, in zig-zag scan order. + * - __u8 + - ``load_non_intra_quantiser_matrix`` + - If set to 1, ``non_intra_quantiser_matrix`` table is to be used for + decoding. + * - __u8 + - ``non_intra_quantiser_matrix[64]`` + - Non-intra quantization table, in zig-zag scan order. + * - __u8 + - ``load_chroma_intra_quantiser_matrix`` + - If set to 1, ``chroma_intra_quantiser_matrix`` table is to be used for + decoding. + * - __u8 + - ``chroma_intra_quantiser_matrix[64]`` + - Chroma intra quantization table, in zig-zag scan order. + * - __u8 + - ``load_chroma_non_intra_quantiser_matrix`` + - If set to 1, ``chroma_non_intra_quantiser_matrix`` table is to be used for + decoding. + * - __u8 + - ``chroma_non_intra_quantiser_matrix[64]`` + - Chroma non-intra quantization table, in zig-zag scan order. + * - :cspan:`2` + + +.. c:type:: V4L2_CID_MPEG_VIDEO_MPEG2_PIC_HDR + (enum) + +.. tabularcolumns:: |p{4.0cm}|p{2.5cm}|p{11.0cm}| + +.. c:type:: v4l2_mpeg_video_mpeg2_pic_hdr + +.. cssclass:: longtable + +.. flat-table:: struct v4l2_mpeg_video_mpeg2_pic_hdr + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - __u32 + - ``offset`` + - Offset in bytes of the slice data from the beginning of packet. + * - __u16 + - ``tsn`` + - Temporal Sequence Number: order in which the frames must be displayed. + * - __u16 + - ``vbv_delay`` + - Video Buffering Verifier delay, in 90KHz cycles unit. + * - __u8 + - ``pic_type`` + - Picture coding type (1: Intra, 2: Predictive, + 3: B, Bidirectionally Predictive, 4: D, DC Intra). + * - __u8 + - ``full_pel_forward_vector`` + - If set to 1, forward vectors are expressed in full pixel unit instead + half pixel unit. + * - __u8 + - ``full_pel_backward_vector`` + - If set to 1, backward vectors are expressed in full pixel unit instead + half pixel unit. + * - __u8 + - ``f_code[2][2]`` + - Motion vectors code. + * - :cspan:`2` + + +.. c:type:: V4L2_CID_MPEG_VIDEO_MPEG2_PIC_EXT + (enum) + +.. tabularcolumns:: |p{4.0cm}|p{2.5cm}|p{11.0cm}| + +.. c:type:: v4l2_mpeg_video_mpeg2_pic_ext + +.. cssclass:: longtable + +.. flat-table:: struct v4l2_mpeg_video_mpeg2_pic_ext + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - __u8 + - ``f_code[2][2]`` + - Motion vectors code. + * - __u8 + - ``intra_dc_precision`` + - Precision of Discrete Cosine transform (0: 8 bits precision, + 1: 9 bits precision, 2: 10 bits precision, 11: 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 quantisation 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 how the frames or fields are output by decoder. + * - __u8 + - ``chroma_420_type`` + - Set the same as ``progressive_frame``. Exists for historical reasons. + * - __u8 + - ``progressive_frame`` + - If this flag is set to 0, the two fields of a frame are two interlaced fields, + ``repeat_first_field`` must be 0 (two field duration). If the flag is set to 1, + the two fields are merged into one frame, ``picture_structure`` is so set to "Frame" + and ``frame_pred_frame_dct`` to 1. + * - __u8 + - ``composite_display`` + - This flag is set to 1 if pictures are encoded as (analog) composite video. + * - __u8 + - ``v_axis`` + - Used only when pictures are encoded according to PAL systems. This flag is set to 1 + on a positive sign, 0 otherwise. + * - __u8 + - ``field_sequence`` + - Specifies the number of the field of an eight Field Sequence for a PAL system or + a five Field Sequence for a NTSC system + * - __u8 + - ``sub_carrier`` + - If the flag is set to 0, the sub-carrier/line-frequency relationship is correct. + * - __u8 + - ``burst_amplitude`` + - Specifies the burst amplitude for PAL and NTSC. + * - __u8 + - ``sub_carrier_phase`` + - Specifies the phase of the reference sub-carrier for the field synchronization. + * - :cspan:`2` + + VPX Control Reference --------------------- diff --git a/Documentation/media/uapi/v4l/pixfmt-013.rst b/Documentation/media/uapi/v4l/pixfmt-013.rst index 728d7ed..32c9ef7 100644 --- a/Documentation/media/uapi/v4l/pixfmt-013.rst +++ b/Documentation/media/uapi/v4l/pixfmt-013.rst @@ -55,11 +55,21 @@ Compressed Formats - ``V4L2_PIX_FMT_MPEG1`` - 'MPG1' - MPEG1 video elementary stream. + * .. _V4L2-PIX-FMT-MPEG1-PARSED: + + - ``V4L2_PIX_FMT_MPEG1_PARSED`` + - 'MG1P' + - MPEG-1 with parsing metadata given through controls, see :ref:`MPEG-2 Parsed Control IDs`. * .. _V4L2-PIX-FMT-MPEG2: - ``V4L2_PIX_FMT_MPEG2`` - 'MPG2' - MPEG2 video elementary stream. + * .. _V4L2-PIX-FMT-MPEG2-PARSED: + + - ``V4L2_PIX_FMT_MPEG2_PARSED`` + - 'MG2P' + - MPEG-2 with parsing metadata given through controls, see :ref:`MPEG-2 Parsed Control IDs`. * .. _V4L2-PIX-FMT-MPEG4: - ``V4L2_PIX_FMT_MPEG4`` diff --git a/Documentation/media/uapi/v4l/vidioc-queryctrl.rst b/Documentation/media/uapi/v4l/vidioc-queryctrl.rst index 41c5744..467f498 100644 --- a/Documentation/media/uapi/v4l/vidioc-queryctrl.rst +++ b/Documentation/media/uapi/v4l/vidioc-queryctrl.rst @@ -422,8 +422,42 @@ 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_SEQ_HDR`` + - n/a + - n/a + - n/a + - Type of control + :c:type:`V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_HDR`. + * - ``V4L2_CTRL_TYPE_MPEG2_SEQ_EXT`` + - n/a + - n/a + - n/a + - Type of control + :c:type:`V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_EXT`. + * - ``V4L2_CTRL_TYPE_MPEG2_SEQ_DISPLAY_EXT`` + - n/a + - n/a + - n/a + - Type of control + :c:type:`V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_DISPLAY_EXT`. + * - ``V4L2_CTRL_TYPE_MPEG2_SEQ_MATRIX_EXT`` + - n/a + - n/a + - n/a + - Type of control + :c:type:`V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_MATRIX_EXT`. + * - ``V4L2_CTRL_TYPE_MPEG2_PIC_HDR`` + - n/a + - n/a + - n/a + - Type of control + :c:type:`V4L2_CID_MPEG_VIDEO_MPEG2_PIC_HDR`. + * - ``V4L2_CTRL_TYPE_MPEG2_PIC_EXT`` + - n/a + - n/a + - n/a + - Type of control + :c:type:`V4L2_CID_MPEG_VIDEO_MPEG2_PIC_EXT`. .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| diff --git a/Documentation/media/videodev2.h.rst.exceptions b/Documentation/media/videodev2.h.rst.exceptions index a5cb0a8..b2e2844 100644 --- a/Documentation/media/videodev2.h.rst.exceptions +++ b/Documentation/media/videodev2.h.rst.exceptions @@ -129,6 +129,12 @@ 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_SEQ_HDR :c:type:`v4l2-ctrl-type-mpeg2-seq-hdr` +replace symbol V4L2_CTRL_TYPE_MPEG2_SEQ_EXT :c:type:`v4l2-ctrl-type-mpeg2-seq-ext` +replace symbol V4L2_CTRL_TYPE_MPEG2_SEQ_DISPLAY_EXT :c:type:`v4l2-ctrl-type-mpeg2-seq-display-ext` +replace symbol V4L2_CTRL_TYPE_MPEG2_SEQ_MATRIX_EXT :c:type:`v4l2-ctrl-type-mpeg2-seq-matrix-ext` +replace symbol V4L2_CTRL_TYPE_MPEG2_PIC_HDR :c:type:`v4l2-ctrl-type-mpeg2-pic-hdr` +replace symbol V4L2_CTRL_TYPE_MPEG2_PIC_EXT :c:type:`v4l2-ctrl-type-mpeg2-pic-ext` # 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 ec42872..163b122 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -760,6 +760,13 @@ 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"; + /* parsed MPEG-2 controls */ + case V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_HDR: return "MPEG-2 Sequence Header"; + case V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_EXT: return "MPEG-2 Sequence Extension"; + case V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_DISPLAY_EXT: return "MPEG-2 Sequence Display Extension"; + case V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_MATRIX_EXT: return "MPEG-2 Sequence Quantization Matrix"; + case V4L2_CID_MPEG_VIDEO_MPEG2_PIC_HDR: return "MPEG-2 Picture Header"; + case V4L2_CID_MPEG_VIDEO_MPEG2_PIC_EXT: return "MPEG-2 Picture Extension"; /* VPX controls */ case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS: return "VPX Number of Partitions"; @@ -1150,6 +1157,24 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, case V4L2_CID_RDS_TX_ALT_FREQS: *type = V4L2_CTRL_TYPE_U32; break; + case V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_HDR: + *type = V4L2_CTRL_TYPE_MPEG2_SEQ_HDR; + break; + case V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_EXT: + *type = V4L2_CTRL_TYPE_MPEG2_SEQ_EXT; + break; + case V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_DISPLAY_EXT: + *type = V4L2_CTRL_TYPE_MPEG2_SEQ_DISPLAY_EXT; + break; + case V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_MATRIX_EXT: + *type = V4L2_CTRL_TYPE_MPEG2_SEQ_MATRIX_EXT; + break; + case V4L2_CID_MPEG_VIDEO_MPEG2_PIC_HDR: + *type = V4L2_CTRL_TYPE_MPEG2_PIC_HDR; + break; + case V4L2_CID_MPEG_VIDEO_MPEG2_PIC_EXT: + *type = V4L2_CTRL_TYPE_MPEG2_PIC_EXT; + break; default: *type = V4L2_CTRL_TYPE_INTEGER; break; @@ -1460,6 +1485,14 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx, return -ERANGE; return 0; + case V4L2_CTRL_TYPE_MPEG2_SEQ_HDR: + case V4L2_CTRL_TYPE_MPEG2_SEQ_EXT: + case V4L2_CTRL_TYPE_MPEG2_SEQ_DISPLAY_EXT: + case V4L2_CTRL_TYPE_MPEG2_SEQ_MATRIX_EXT: + case V4L2_CTRL_TYPE_MPEG2_PIC_HDR: + case V4L2_CTRL_TYPE_MPEG2_PIC_EXT: + return 0; + default: return -EINVAL; } @@ -1979,6 +2012,26 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, case V4L2_CTRL_TYPE_U32: elem_size = sizeof(u32); break; + case V4L2_CTRL_TYPE_MPEG2_SEQ_HDR: + elem_size = sizeof(struct v4l2_mpeg_video_mpeg2_seq_hdr); + break; + case V4L2_CTRL_TYPE_MPEG2_SEQ_EXT: + elem_size = sizeof(struct v4l2_mpeg_video_mpeg2_seq_ext); + break; + case V4L2_CTRL_TYPE_MPEG2_SEQ_DISPLAY_EXT: + elem_size = + sizeof(struct v4l2_mpeg_video_mpeg2_seq_display_ext); + break; + case V4L2_CTRL_TYPE_MPEG2_SEQ_MATRIX_EXT: + elem_size = + sizeof(struct v4l2_mpeg_video_mpeg2_seq_matrix_ext); + break; + case V4L2_CTRL_TYPE_MPEG2_PIC_HDR: + elem_size = sizeof(struct v4l2_mpeg_video_mpeg2_pic_hdr); + break; + case V4L2_CTRL_TYPE_MPEG2_PIC_EXT: + elem_size = sizeof(struct v4l2_mpeg_video_mpeg2_pic_ext); + break; default: if (type < V4L2_CTRL_COMPOUND_TYPES) elem_size = sizeof(s32); diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index e5a2187..394e636 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -1250,7 +1250,9 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) case V4L2_PIX_FMT_H264_MVC: descr = "H.264 MVC"; break; case V4L2_PIX_FMT_H263: descr = "H.263"; break; case V4L2_PIX_FMT_MPEG1: descr = "MPEG-1 ES"; break; + case V4L2_PIX_FMT_MPEG1_PARSED: descr = "MPEG-1 with parsing metadata"; break; case V4L2_PIX_FMT_MPEG2: descr = "MPEG-2 ES"; break; + case V4L2_PIX_FMT_MPEG2_PARSED: descr = "MPEG-2 with parsing metadata"; break; case V4L2_PIX_FMT_MPEG4: descr = "MPEG-4 part 2 ES"; break; case V4L2_PIX_FMT_XVID: descr = "Xvid"; break; case V4L2_PIX_FMT_VC1_ANNEX_G: descr = "VC-1 (SMPTE 412M Annex G)"; break; diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 0d2e1e0..2be9db2 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -547,6 +547,100 @@ enum v4l2_mpeg_video_mpeg4_profile { }; #define V4L2_CID_MPEG_VIDEO_MPEG4_QPEL (V4L2_CID_MPEG_BASE+407) +/* + * parsed MPEG-2 controls + * (needed by stateless video decoders) + * Those controls have been defined based on MPEG-2 standard ISO/IEC 13818-2, + * and so derive directly from the MPEG-2 video bitstream syntax including + * how it is coded inside bitstream (enumeration values for ex.). + */ +#define MPEG2_QUANTISER_MATRIX_SIZE 64 +#define V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_HDR (V4L2_CID_MPEG_BASE+450) +struct v4l2_mpeg_video_mpeg2_seq_hdr { + __u16 width; + __u16 height; + __u8 aspect_ratio_info; + __u8 frame_rate_code; + __u16 vbv_buffer_size; + __u32 bitrate_value; + __u16 constrained_parameters_flag; + __u8 load_intra_quantiser_matrix; + __u8 load_non_intra_quantiser_matrix; + __u8 intra_quantiser_matrix[MPEG2_QUANTISER_MATRIX_SIZE]; + __u8 non_intra_quantiser_matrix[MPEG2_QUANTISER_MATRIX_SIZE]; + __u32 par_w; + __u32 par_h; + __u32 fps_n; + __u32 fps_d; + __u32 bitrate; +}; +#define V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_EXT (V4L2_CID_MPEG_BASE+451) +struct v4l2_mpeg_video_mpeg2_seq_ext { + __u8 profile; + __u8 level; + __u8 progressive; + __u8 chroma_format; + __u8 horiz_size_ext; + __u8 vert_size_ext; + __u16 bitrate_ext; + __u8 vbv_buffer_size_ext; + __u8 low_delay; + __u8 fps_n_ext; + __u8 fps_d_ext; +}; +#define V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_DISPLAY_EXT (V4L2_CID_MPEG_BASE+452) +struct v4l2_mpeg_video_mpeg2_seq_display_ext { + __u16 display_horizontal_size; + __u16 display_vertical_size; + __u8 video_format; + __u8 colour_description_flag; + __u8 colour_primaries; + __u8 transfer_characteristics; + __u8 matrix_coefficients; +}; +#define V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_MATRIX_EXT (V4L2_CID_MPEG_BASE+453) +struct v4l2_mpeg_video_mpeg2_seq_matrix_ext { + __u8 load_intra_quantiser_matrix; + __u8 intra_quantiser_matrix[MPEG2_QUANTISER_MATRIX_SIZE]; + __u8 load_non_intra_quantiser_matrix; + __u8 non_intra_quantiser_matrix[MPEG2_QUANTISER_MATRIX_SIZE]; + __u8 load_chroma_intra_quantiser_matrix; + __u8 chroma_intra_quantiser_matrix[MPEG2_QUANTISER_MATRIX_SIZE]; + __u8 load_chroma_non_intra_quantiser_matrix; + __u8 chroma_non_intra_quantiser_matrix[MPEG2_QUANTISER_MATRIX_SIZE]; +}; +#define V4L2_CID_MPEG_VIDEO_MPEG2_PIC_HDR (V4L2_CID_MPEG_BASE+454) +struct v4l2_mpeg_video_mpeg2_pic_hdr { + __u32 offset; + __u16 tsn; + __u16 vbv_delay; + __u8 pic_type; + __u8 full_pel_forward_vector; + __u8 full_pel_backward_vector; + __u8 f_code[2][2]; +}; +#define V4L2_CID_MPEG_VIDEO_MPEG2_PIC_EXT (V4L2_CID_MPEG_BASE+455) +struct v4l2_mpeg_video_mpeg2_pic_ext { + __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 chroma_420_type; + __u8 progressive_frame; + __u8 composite_display; + __u8 v_axis; + __u8 field_sequence; + __u8 sub_carrier; + __u8 burst_amplitude; + __u8 sub_carrier_phase; +}; + /* Control IDs for VP8 streams * Although VP8 is not part of MPEG we add these controls to the MPEG class * as that class is already handling other video compression standards diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 2b8feb8..abf05f49 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -622,7 +622,9 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_H264_MVC v4l2_fourcc('M', '2', '6', '4') /* H264 MVC */ #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_MPEG1_PARSED v4l2_fourcc('M', 'G', '1', 'P') /* MPEG1 with parsing metadata given through controls */ #define V4L2_PIX_FMT_MPEG2 v4l2_fourcc('M', 'P', 'G', '2') /* MPEG-2 ES */ +#define V4L2_PIX_FMT_MPEG2_PARSED v4l2_fourcc('M', 'G', '2', 'P') /* MPEG2 with parsing metadata given through controls */ #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 */ @@ -1605,6 +1607,12 @@ enum v4l2_ctrl_type { V4L2_CTRL_TYPE_U8 = 0x0100, V4L2_CTRL_TYPE_U16 = 0x0101, V4L2_CTRL_TYPE_U32 = 0x0102, + V4L2_CTRL_TYPE_MPEG2_SEQ_HDR = 0x0109, + V4L2_CTRL_TYPE_MPEG2_SEQ_EXT = 0x010A, + V4L2_CTRL_TYPE_MPEG2_SEQ_DISPLAY_EXT = 0x010B, + V4L2_CTRL_TYPE_MPEG2_SEQ_MATRIX_EXT = 0x010C, + V4L2_CTRL_TYPE_MPEG2_PIC_HDR = 0x010D, + V4L2_CTRL_TYPE_MPEG2_PIC_EXT = 0x010E, }; /* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */