Re: [PATCH v3 1/3] [media] v4l: add parsed MPEG-2 support

2017-02-21 Thread Hugues FRUCHET
Thanks for review Nicolas, my comments thereafter.

On 02/10/2017 03:07 AM, Nicolas Dufresne wrote:
> Le jeudi 09 février 2017 à 18:07 +0100, Hugues Fruchet a écrit :
>> 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 +
>>  drivers/media/v4l2-core/v4l2-ctrls.c   |  53 +++
>>  drivers/media/v4l2-core/v4l2-ioctl.c   |   2 +
>>  include/uapi/linux/v4l2-controls.h |  86 +
>>  include/uapi/linux/videodev2.h |   8 +
>>  6 files changed, 522 insertions(+)
>>
>> diff --git a/Documentation/media/uapi/v4l/extended-controls.rst
>> b/Documentation/media/uapi/v4l/extended-controls.rst
>> index abb1057..cd1a8d6 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:
>> +
>> +``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: 3/1001.0 '29.97, 5: 30.0, 6: 50.0, 7: 6/1001.0,
>> +8: 60.0)
>> +* - __u32
>> +  - ``bitrate_value``
>> +  - Bitrate value as in the bitstream, expressed in 400bps unit
>> +* - __u16
>> +  - ``vbv_buffer_size``
>> +  -  Video Buffering Verifier size, expressed in 16KBytes unit.
>> +* - __u8
>> +  - ``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`
>> +
>> +
>> +``V4L2_CID_MPEG_VIDEO_MPEG2_SEQ_EXT``
>> +(enum)
>> +
>> +.. tabularcolumns:: |p{4.0cm}|p{2.5cm}|p{11.0cm}|
>> +
>> +.. c:type:: 

Re: [PATCH v3 1/3] [media] v4l: add parsed MPEG-2 support

2017-02-09 Thread Nicolas Dufresne
Le jeudi 09 février 2017 à 18:07 +0100, Hugues Fruchet a écrit :
> 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 +
>  drivers/media/v4l2-core/v4l2-ctrls.c   |  53 +++
>  drivers/media/v4l2-core/v4l2-ioctl.c   |   2 +
>  include/uapi/linux/v4l2-controls.h |  86 +
>  include/uapi/linux/videodev2.h |   8 +
>  6 files changed, 522 insertions(+)
> 
> diff --git a/Documentation/media/uapi/v4l/extended-controls.rst
> b/Documentation/media/uapi/v4l/extended-controls.rst
> index abb1057..cd1a8d6 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:
> +
> +``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: 3/1001.0 '29.97, 5: 30.0, 6: 50.0, 7: 6/1001.0,
> +8: 60.0)
> +* - __u32
> +  - ``bitrate_value``
> +  - Bitrate value as in the bitstream, expressed in 400bps unit
> +* - __u16
> +  - ``vbv_buffer_size``
> +  -  Video Buffering Verifier size, expressed in 16KBytes unit.
> +* - __u8
> +  - ``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`
> +
> +
> +``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``
> + 

[PATCH v3 1/3] [media] v4l: add parsed MPEG-2 support

2017-02-09 Thread Hugues Fruchet
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 +
 drivers/media/v4l2-core/v4l2-ctrls.c   |  53 +++
 drivers/media/v4l2-core/v4l2-ioctl.c   |   2 +
 include/uapi/linux/v4l2-controls.h |  86 +
 include/uapi/linux/videodev2.h |   8 +
 6 files changed, 522 insertions(+)

diff --git a/Documentation/media/uapi/v4l/extended-controls.rst 
b/Documentation/media/uapi/v4l/extended-controls.rst
index abb1057..cd1a8d6 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:
+
+``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: 3/1001.0 '29.97, 5: 30.0, 6: 50.0, 7: 6/1001.0,
+8: 60.0)
+* - __u32
+  - ``bitrate_value``
+  - Bitrate value as in the bitstream, expressed in 400bps unit
+* - __u16
+  - ``vbv_buffer_size``
+  -  Video Buffering Verifier size, expressed in 16KBytes unit.
+* - __u8
+  - ``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`
+
+
+``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