MPEG-2 stateless API cleanup and destaging
v4 cover MPEG-2 stateless API cleanup and destaging
Hi everyone,
Over the last few weeks Daniel Almeida and Nicolas Dufresne have been working on GStreamer v4l2codecs support for stateless MPEG-2 decoding.
This allowed us to re-review the MPEG-2 specification and re-discuss the API with some additional insight. The API now looks quite cleaner, and hopefully ready for destaging.
This series is mostly thanks to Daniel and Nicolas!
Patches 1 to 6 cleanup the API, and patches 7 to 9 move it out of staging.
This is tested on i.MX8M and RK3399 platforms, using GStreamer v4l2codecs, which will be upstream very soon.
v4:
* Rework and clarify quantization matrices control semantics.
* Move reference buffer fields to the picture parameter control.
* Remove slice parameters control. This can be added back in the future if needed, but for now it's not used.
See patch 6/9 for details.
* Destage the API.
v3:
* No API changes, just minor boilerplate fixes for the new controls to be properly exposed, initialized and validated.
v2:
* Fixed bad use of boolean negation in a flag, which was fortunately reported by 0day bot.
Ezequiel Garcia (9):
media: uapi: mpeg2: Rework quantization matrices semantics
media: uapi: mpeg2: Cleanup flags
media: uapi: mpeg2: Split sequence and picture parameters
media: uapi: mpeg2: Move reference buffer fields
media: hantro/cedrus: Remove unneeded slice size and slice offset
media: uapi: mpeg2: Remove V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS
media: controls: Log MPEG-2 stateless control in .std_log
media: uapi: Move the MPEG-2 stateless control type out of staging
media: uapi: Move MPEG-2 stateless controls out of staging
.../media/v4l/ext-ctrls-codec-stateless.rst | 218 ++++++++++++++++++ .../media/v4l/ext-ctrls-codec.rst | 217 ----------------- .../media/v4l/pixfmt-compressed.rst | 11 +- .../media/v4l/vidioc-g-ext-ctrls.rst | 12 + .../media/v4l/vidioc-queryctrl.rst | 18 +- .../media/videodev2.h.rst.exceptions | 3 +- drivers/media/v4l2-core/v4l2-ctrls.c | 110 ++++++--- drivers/staging/media/hantro/hantro_drv.c | 9 +- .../media/hantro/hantro_g1_mpeg2_dec.c | 95 ++++---- .../media/hantro/rk3399_vpu_hw_mpeg2_dec.c | 94 ++++---- drivers/staging/media/sunxi/cedrus/cedrus.c | 10 +- drivers/staging/media/sunxi/cedrus/cedrus.h | 3 +- .../staging/media/sunxi/cedrus/cedrus_dec.c | 8 +- .../staging/media/sunxi/cedrus/cedrus_mpeg2.c | 89 +++---- include/media/mpeg2-ctrls.h | 82 ------- include/media/v4l2-ctrls.h | 7 +- include/uapi/linux/v4l2-controls.h | 114 +++++++++ include/uapi/linux/videodev2.h | 7 + 18 files changed, 586 insertions(+), 521 deletions(-) delete mode 100644 include/media/mpeg2-ctrls.h
Signature · 1 line
2.30.0
PATCH v4 1/9 media: uapi: mpeg2: Rework quantization matrices semantics
As stated in the MPEG-2 specification, section 6.3.7 "Quant matrix extension":
Each quantisation matrix has a default set of values. When a sequence_header_code is decoded all matrices shall be reset to their default values. User defined matrices may be downloaded and this can occur in a sequence_header() or in a quant_matrix_extension().
The load_intra_quantiser_matrix syntax elements are transmitted in the bistream headers, signalling that a quantization matrix needs to be loaded and used for pictures transmitted afterwards (until the matrices are reset).
These "load" semantics are implemented in the V4L2 interface without the need of any "load" flags: passing the control is effectively a load.
Therefore, rework the V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION semantics to match the MPEG-2 semantics. Quantization matrices values are now initialized by the V4L2 control core to their reset default value, and applications are expected to reset their values as specified.
The quantization control is therefore optional, and used to load bitstream-defined values in the quantization matrices.
--- .../media/v4l/ext-ctrls-codec.rst | 17 --------- drivers/media/v4l2-core/v4l2-ctrls.c | 21 ++++++++++ .../staging/media/sunxi/cedrus/cedrus_mpeg2.c | 38 +------------------ include/media/mpeg2-ctrls.h | 5 --- 4 files changed, 23 insertions(+), 58 deletions(-)
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +0 -17
@@ -1746,23 +1746,6 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - :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
drivers/media/v4l2-core/v4l2-ctrls.c +21 -0
@@ -57,6 +57,18 @@ static bool is_new_manual(const struct v4l2_ctrl *master)return master->is_auto && master->val == master->manual_mode_value; } +/* Default MPEG-2 quantization coefficients, from the specification. */ +static const u8 mpeg2_intra_quant_matrix[64 ] = { +8 ,16 ,16 ,19 ,16 ,19 ,22 ,22 , +22 ,22 ,22 ,22 ,26 ,24 ,26 ,27 , +27 ,27 ,26 ,26 ,26 ,26 ,27 ,27 , +27 ,29 ,29 ,29 ,34 ,34 ,34 ,29 , +29 ,29 ,27 ,27 ,29 ,29 ,32 ,32 , +34 ,34 ,37 ,38 ,37 ,35 ,35 ,34 , +35 ,38 ,38 ,40 ,40 ,40 ,48 ,48 , +46 ,46 ,56 ,56 ,58 ,69 ,69 ,83 +}; +/* Returns NULL or a character pointer array containing the menu for the given control ID. The pointer array ends with a NULL pointer. An empty string signifies a menu entry that is invalid. This allows
@@ -1656,6 +1668,7 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, union v4l2_ctrl_ptr ptr) {struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; +struct v4l2_ctrl_mpeg2_quantization *p_mpeg2_quant;struct v4l2_ctrl_vp8_frame *p_vp8_frame;struct v4l2_ctrl_fwht_params *p_fwht_params;void *p = ptr.p + idx * ctrl->elem_size;
@@ -1680,6 +1693,14 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, p_mpeg2_slice_params->picture.picture_coding_type =V4L2_MPEG2_PICTURE_CODING_TYPE_I ;break ; +case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION : + p_mpeg2_quant = p; + +memcpy (p_mpeg2_quant->intra_quantiser_matrix, + mpeg2_intra_quant_matrix, +ARRAY_SIZE (mpeg2_intra_quant_matrix)); +memset (p_mpeg2_quant->non_intra_quantiser_matrix,16 ,64 ); +break ;case V4L2_CTRL_TYPE_VP8_FRAME : p_vp8_frame = p; p_vp8_frame->num_dct_parts =1 ;
drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c +2 -36
@@ -13,30 +13,6 @@#include "cedrus_hw.h" #include "cedrus_regs.h" -/* Default MPEG-2 quantization coefficients, from the specification. */ - -static const u8 intra_quantization_matrix_default[64 ] = { -8 ,16 ,16 ,19 ,16 ,19 ,22 ,22 , -22 ,22 ,22 ,22 ,26 ,24 ,26 ,27 , -27 ,27 ,26 ,26 ,26 ,26 ,27 ,27 , -27 ,29 ,29 ,29 ,34 ,34 ,34 ,29 , -29 ,29 ,27 ,27 ,29 ,29 ,32 ,32 , -34 ,34 ,37 ,38 ,37 ,35 ,35 ,34 , -35 ,38 ,38 ,40 ,40 ,40 ,48 ,48 , -46 ,46 ,56 ,56 ,58 ,69 ,69 ,83 -}; - -static const u8 non_intra_quantization_matrix_default[64 ] = { -16 ,16 ,16 ,16 ,16 ,16 ,16 ,16 , -16 ,16 ,16 ,16 ,16 ,16 ,16 ,16 , -16 ,16 ,16 ,16 ,16 ,16 ,16 ,16 , -16 ,16 ,16 ,16 ,16 ,16 ,16 ,16 , -16 ,16 ,16 ,16 ,16 ,16 ,16 ,16 , -16 ,16 ,16 ,16 ,16 ,16 ,16 ,16 , -16 ,16 ,16 ,16 ,16 ,16 ,16 ,16 , -16 ,16 ,16 ,16 ,16 ,16 ,16 ,16 -}; -static enum cedrus_irq_status cedrus_mpeg2_irq_status (struct cedrus_ctx *ctx) {struct cedrus_dev *dev = ctx->dev;
@@ -99,12 +75,7 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)cedrus_engine_enable (ctx,CEDRUS_CODEC_MPEG2 );/* Set intra quantization matrix. */ - -if (quantization && quantization->load_intra_quantiser_matrix) - matrix = quantization->intra_quantiser_matrix; -else - matrix = intra_quantization_matrix_default; - + matrix = quantization->intra_quantiser_matrix;for (i =0 ; i <64 ; i++) { reg =VE_DEC_MPEG_IQMINPUT_WEIGHT (i, matrix[i]); reg |=VE_DEC_MPEG_IQMINPUT_FLAG_INTRA ;
@@ -113,12 +84,7 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) }/* Set non-intra quantization matrix. */ - -if (quantization && quantization->load_non_intra_quantiser_matrix) - matrix = quantization->non_intra_quantiser_matrix; -else - matrix = non_intra_quantization_matrix_default; - + matrix = quantization->non_intra_quantiser_matrix;for (i =0 ; i <64 ; i++) { reg =VE_DEC_MPEG_IQMINPUT_WEIGHT (i, matrix[i]); reg |=VE_DEC_MPEG_IQMINPUT_FLAG_NON_INTRA ;
include/media/mpeg2-ctrls.h +0 -5
@@ -68,11 +68,6 @@ struct v4l2_ctrl_mpeg2_slice_params {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 ];
Signature · 1 line
2.30.0
Re: [PATCH v4 1/9] media: uapi: mpeg2: Rework quantization matrices semantics
Le lundi 29 mars 2021 à 15:13 -0300, Ezequiel Garcia a écrit :
Quoted 11 lines
As stated in the MPEG-2 specification, section 6.3.7 "Quant matrix extension":
Each quantisation matrix has a default set of values. When a
sequence_header_codeis decoded all matrices shall be reset to their default values. User defined matrices may be downloaded and this can occur in asequence_header()or in aquant_matrix_extension().The
load_intra_quantiser_matrixsyntax elements are transmitted in the bistream headers, signalling that a quantization matrix
quantisation
Not really a typo, just a suggestion to follow the specification spelling. I would like to see concistant spelling the API. My rational is that you can copy and paste the strings when searching inside the specification PDF, and you don't mix both in the API like we do now.
Quoted 8 lines
needs to be loaded and used for pictures transmitted afterwards (until the matrices are reset).
These "load" semantics are implemented in the V4L2 interface without the need of any "load" flags: passing the control is effectively a load.
Therefore, rework the
V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION
S
Quoted 1 line
semantics to match the MPEG-2 semantics. Quantization matrices
s
etc.
Quoted 6 lines
values are now initialized by the V4L2 control core to their reset default value, and applications are expected to reset their values as specified.
The quantization control is therefore optional, and used to load bitstream-defined values in the quantization matrices.
Perhaps:
"The quantisation controls is therefore optional for decoding streams that uses the default matrices."
A stack that would not handle the default, would have to read the control at least once in order to avoid overriding valid values with 0s, not sure if that is worth mentioning ?
Quoted 36 lines
Signed-off-by Ezequiel Garcia <[email protected]>Co-developed-by Nicolas Dufresne <[email protected]>Signed-off-by Nicolas Dufresne <[email protected]>---
.../media/v4l/ext-ctrls-codec.rst | 17 --------- drivers/media/v4l2-core/v4l2-ctrls.c | 21 ++++++++++ .../staging/media/sunxi/cedrus/cedrus_mpeg2.c | 38 +------------------ include/media/mpeg2-ctrls.h | 5 --- 4 files changed, 23 insertions(+), 58 deletions(-)Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +0
-0@@ -1746,23 +1746,6 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type -:stub-columns: 0
:widths: 1 1 2Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +0
-17- * - __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.
Quoted 3 lines
* -
__u8
- ``intra_quantiser_matrix[64]``
- The quantization matrix coefficients for intra-coded frames, in zigzag
s
Careful, since parameters follow the spec, doc does not always.
Quoted 125 lines
drivers/media/v4l2-core/v4l2-ctrls.c +0
-0@@ -57,6 +57,18 @@ static bool is_new_manual(const struct v4l2_ctrl *master) return master->is_auto && master->val == master->manual_mode_value; }drivers/media/v4l2-core/v4l2-ctrls.c +12
-0+/* Default MPEG-2 quantization coefficients, from the specification. */ +static const u8 mpeg2_intra_quant_matrix[64 ] = { +8 ,16 ,16 ,19 ,16 ,19 ,22 ,22 , +22 ,22 ,22 ,22 ,26 ,24 ,26 ,27 , +27 ,27 ,26 ,26 ,26 ,26 ,27 ,27 , +27 ,29 ,29 ,29 ,34 ,34 ,34 ,29 , +29 ,29 ,27 ,27 ,29 ,29 ,32 ,32 , +34 ,34 ,37 ,38 ,37 ,35 ,35 ,34 , +35 ,38 ,38 ,40 ,40 ,40 ,48 ,48 , +46 ,46 ,56 ,56 ,58 ,69 ,69 ,83 +}; +/* Returns NULL or a character pointer array containing the menu for the given control ID. The pointer array ends with a NULL pointer. An empty string signifies a menu entry that is invalid. This allows
drivers/media/v4l2-core/v4l2-ctrls.c +1
-0@@ -1656,6 +1668,7 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, union v4l2_ctrl_ptr ptr) { struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; +struct v4l2_ctrl_mpeg2_quantization *p_mpeg2_quant; struct v4l2_ctrl_vp8_frame *p_vp8_frame; struct v4l2_ctrl_fwht_params *p_fwht_params; void *p = ptr.p + idx * ctrl->elem_size;@@ -1680,6 +1693,14 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx,
p_mpeg2_slice_params->picture.picture_coding_type=V4L2_MPEG2_PICTURE_CODING_TYPE_I; break;drivers/media/v4l2-core/v4l2-ctrls.c +8
-0+case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION : + p_mpeg2_quant = p; + +memcpy (p_mpeg2_quant->intra_quantiser_matrix, + mpeg2_intra_quant_matrix, +ARRAY_SIZE (mpeg2_intra_quant_matrix)); +memset (p_mpeg2_quant->non_intra_quantiser_matrix,16 ,64 ); +break ;case
V4L2_CTRL_TYPE_VP8_FRAME:
p_vp8_frame= p;
p_vp8_frame->num_dct_parts= 1;drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c +2
-36@@ -13,30 +13,6 @@ #include "cedrus_hw.h" #include "cedrus_regs.h" -/* Default MPEG-2 quantization coefficients, from the specification. */ - -static const u8 intra_quantization_matrix_default[64 ] = { -8 ,16 ,16 ,19 ,16 ,19 ,22 ,22 , -22 ,22 ,22 ,22 ,26 ,24 ,26 ,27 , -27 ,27 ,26 ,26 ,26 ,26 ,27 ,27 , -27 ,29 ,29 ,29 ,34 ,34 ,34 ,29 , -29 ,29 ,27 ,27 ,29 ,29 ,32 ,32 , -34 ,34 ,37 ,38 ,37 ,35 ,35 ,34 , -35 ,38 ,38 ,40 ,40 ,40 ,48 ,48 , -46 ,46 ,56 ,56 ,58 ,69 ,69 ,83 -}; - -static const u8 non_intra_quantization_matrix_default[64 ] = { -16 ,16 ,16 ,16 ,16 ,16 ,16 ,16 , -16 ,16 ,16 ,16 ,16 ,16 ,16 ,16 , -16 ,16 ,16 ,16 ,16 ,16 ,16 ,16 , -16 ,16 ,16 ,16 ,16 ,16 ,16 ,16 , -16 ,16 ,16 ,16 ,16 ,16 ,16 ,16 , -16 ,16 ,16 ,16 ,16 ,16 ,16 ,16 , -16 ,16 ,16 ,16 ,16 ,16 ,16 ,16 , -16 ,16 ,16 ,16 ,16 ,16 ,16 ,16 -}; - static enum cedrus_irq_status cedrus_mpeg2_irq_status(struct cedrus_ctx *ctx) { struct cedrus_dev *dev = ctx->dev;@@ -99,12 +75,7 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) cedrus_engine_enable(ctx, CEDRUS_CODEC_MPEG2); /* Set intra quantization matrix. */ - -if (quantization && quantization->load_intra_quantiser_matrix) - matrix = quantization->intra_quantiser_matrix; -else - matrix = intra_quantization_matrix_default; - + matrix = quantization->intra_quantiser_matrix; for (i = 0; i < 64; i++) { reg = VE_DEC_MPEG_IQMINPUT_WEIGHT(i, matrix[i]); reg |= VE_DEC_MPEG_IQMINPUT_FLAG_INTRA;@@ -113,12 +84,7 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) } /* Set non-intra quantization matrix. */ - -if (quantization && quantization->load_non_intra_quantiser_matrix) - matrix = quantization->non_intra_quantiser_matrix; -else - matrix = non_intra_quantization_matrix_default; - + matrix = quantization->non_intra_quantiser_matrix; for (i = 0; i < 64; i++) { reg = VE_DEC_MPEG_IQMINPUT_WEIGHT(i, matrix[i]); reg |= VE_DEC_MPEG_IQMINPUT_FLAG_NON_INTRA;include/media/mpeg2-ctrls.h +0
-5@@ -68,11 +68,6 @@ struct v4l2_ctrl_mpeg2_slice_params { 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];
Re: [PATCH v4 1/9] media: uapi: mpeg2: Rework quantization matrices semantics
Hi Nicolas,
Quoted 10 lines · Nicolas Dufresne
Le lundi 29 mars 2021 à 15:13 -0300, Ezequiel Garcia a écrit :
Quoted 9 lines
As stated in the MPEG-2 specification, section 6.3.7 "Quant matrix extension":
Each quantisation matrix has a default set of values. When a
sequence_header_codeis decoded all matrices shall be reset to their default values. User defined matrices may be downloaded and this can occur in asequence_header()or in aquant_matrix_extension().
Quoted 9 lines
Quoted 2 lines
The
load_intra_quantiser_matrixsyntax elements are transmitted in the bistream headers, signalling that a quantization matrixquantisation
Not really a typo, just a suggestion to follow the specification spelling. I would like to see concistant spelling the API. My rational is that you can copy and paste the strings when searching inside the specification PDF, and you don't mix both in the API like we do now.
Absolutely. Thanks for spotting this.
Quoted 22 lines
Quoted 8 lines
needs to be loaded and used for pictures transmitted afterwards (until the matrices are reset).
These "load" semantics are implemented in the V4L2 interface without the need of any "load" flags: passing the control is effectively a load.
Therefore, rework the
V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATIONS
Quoted 1 line
semantics to match the MPEG-2 semantics. Quantization matrices
s
etc.
Quoted 6 lines
values are now initialized by the V4L2 control core to their reset default value, and applications are expected to reset their values as specified.
The quantization control is therefore optional, and used to load bitstream-defined values in the quantization matrices.
Quoted 9 lines
Perhaps:
"The quantisation controls is therefore optional for decoding streams that uses the default matrices."
A stack that would not handle the default, would have to read the control at least once in order to avoid overriding valid values with 0s, not sure if that is worth mentioning ?
Hm, not entirely sure. If application calls S_EXT_CTRL with 0s, then that's what will happen.
Thanks,
Ezequiel
PATCH v4 2/9 media: uapi: mpeg2: Cleanup flags
In reply to Ezequiel GarciaOur current MPEG-2 uAPI uses 1-byte fields for MPEG-2 boolean syntax elements. Clean these by adding a 'flags' field and flag macro for each boolean syntax element.
A follow-up change will refactor this uAPI so we don't need to add padding fields just yet.
--- .../media/v4l/ext-ctrls-codec.rst | 77 +++++++++++++------ drivers/media/v4l2-core/v4l2-ctrls.c | 14 ++-- .../media/hantro/hantro_g1_mpeg2_dec.c | 76 +++++++++--------- .../media/hantro/rk3399_vpu_hw_mpeg2_dec.c | 76 +++++++++--------- .../staging/media/sunxi/cedrus/cedrus_mpeg2.c | 38 ++++----- include/media/mpeg2-ctrls.h | 36 +++++---- 6 files changed, 175 insertions(+), 142 deletions(-)
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +54 -23
@@ -1654,13 +1654,28 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - - ``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). + * - __u32 + - ``flags`` + - See :ref:`MPEG-2 Sequence Flags <mpeg2_sequence_flags>`. + +.. _mpeg2_sequence_flags: + +``MPEG-2 Sequence Flags`` + +.. cssclass:: longtable + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - ``V4L2_MPEG2_SEQ_FLAG_PROGRESSIVE`` + - 0x00000001 + - Indication that all the frames for the sequence are progressive instead + of interlaced. .. c:type:: v4l2_mpeg2_picture
@@ -1693,29 +1708,45 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - - ``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`` + * - __u32 + - ``flags`` + - See :ref:`MPEG-2 Picture Flags <mpeg2_picture_flags>`. + + +.. _mpeg2_picture_flags: + +``MPEG-2 Picture Flags`` + +.. cssclass:: longtable + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - ``V4L2_MPEG2_PIC_FLAG_TOP_FIELD_FIRST`` + - 0x00000001 + - If set and it's an interlaced stream, top field is output first. + * - ``V4L2_MPEG2_PIC_FLAG_FRAME_PRED_DCT`` + - 0x00000002 + - If set only frame-DCT and frame prediction are used. + * - ``V4L2_MPEG2_PIC_FLAG_CONCEALMENT_MV`` + - 0x00000004 + - If set motion vectors are coded for intra macroblocks. + * - ``V4L2_MPEG2_PIC_FLAG_Q_SCALE_TYPE`` + - 0x00000008 - This flag affects the inverse quantization process. - * - __u8 - - ``intra_vlc_format`` + * - ``V4L2_MPEG2_PIC_FLAG_INTRA_VLC`` + - 0x00000010 - This flag affects the decoding of transform coefficient data. - * - __u8 - - ``alternate_scan`` + * - ``V4L2_MPEG2_PIC_FLAG_ALT_SCAN`` + - 0x00000020 - This flag affects the decoding of transform coefficient data. - * - __u8 - - ``repeat_first_field`` + * - ``V4L2_MPEG2_PIC_FLAG_REPEAT_FIRST`` + - 0x00000040 - This flag affects the decoding process of progressive frames. - * - __u16 - - ``progressive_frame`` + * - ``V4L2_MPEG2_PIC_FLAG_PROGRESSIVE`` + - 0x00000080 - Indicates whether the current frame is progressive. .. raw:: latex
drivers/media/v4l2-core/v4l2-ctrls.c +7 -7
@@ -1691,7 +1691,7 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx,/* interlaced top field */ p_mpeg2_slice_params->picture.picture_structure =1 ; p_mpeg2_slice_params->picture.picture_coding_type = -V4L2_MPEG2_PICTURE_CODING_TYPE_I ; +V4L2_MPEG2_PIC_CODING_TYPE_I ;break ;case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION : p_mpeg2_quant = p;
@@ -1901,18 +1901,18 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, }switch (p_mpeg2_slice_params->picture.picture_structure) { -case 1 :/* interlaced top field */ -case 2 :/* interlaced bottom field */ -case 3 :/* progressive */ +case V4L2_MPEG2_PIC_TOP_FIELD : +case V4L2_MPEG2_PIC_BOTTOM_FIELD : +case V4L2_MPEG2_PIC_FRAME :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 : +case V4L2_MPEG2_PIC_CODING_TYPE_I : +case V4L2_MPEG2_PIC_CODING_TYPE_P : +case V4L2_MPEG2_PIC_CODING_TYPE_B :break ;default :return -EINVAL ;
drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c +36 -40
151 lines not on this page · raw message
drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c +36 -40
147 lines not on this page · raw message
drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c +19 -19
@@ -51,8 +51,8 @@ static void cedrus_mpeg2_irq_disable(struct cedrus_ctx *ctx)static void cedrus_mpeg2_setup (struct cedrus_ctx *ctx,struct cedrus_run *run) {const struct v4l2_ctrl_mpeg2_slice_params *slice_params; -const struct v4l2_mpeg2_sequence *sequence; -const struct v4l2_mpeg2_picture *picture; +const struct v4l2_mpeg2_sequence *seq; +const struct v4l2_mpeg2_picture *pic;const struct v4l2_ctrl_mpeg2_quantization *quantization;dma_addr_t src_buf_addr, dst_luma_addr, dst_chroma_addr;dma_addr_t fwd_luma_addr, fwd_chroma_addr;
@@ -66,8 +66,8 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)u32 reg; slice_params = run->mpeg2.slice_params; - sequence = &slice_params->sequence; - picture = &slice_params->picture; + seq = &slice_params->sequence; + pic = &slice_params->picture; quantization = run->mpeg2.quantization;
@@ -94,19 +94,19 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)/* Set MPEG picture header. */ - reg =VE_DEC_MPEG_MP12HDR_SLICE_TYPE (picture->picture_coding_type); - reg |=VE_DEC_MPEG_MP12HDR_F_CODE (0 ,0 , picture->f_code[0 ][0 ]); - reg |=VE_DEC_MPEG_MP12HDR_F_CODE (0 ,1 , picture->f_code[0 ][1 ]); - reg |=VE_DEC_MPEG_MP12HDR_F_CODE (1 ,0 , picture->f_code[1 ][0 ]); - reg |=VE_DEC_MPEG_MP12HDR_F_CODE (1 ,1 , picture->f_code[1 ][1 ]); - reg |=VE_DEC_MPEG_MP12HDR_INTRA_DC_PRECISION (picture->intra_dc_precision); - reg |=VE_DEC_MPEG_MP12HDR_INTRA_PICTURE_STRUCTURE (picture->picture_structure); - reg |=VE_DEC_MPEG_MP12HDR_TOP_FIELD_FIRST (picture->top_field_first); - reg |=VE_DEC_MPEG_MP12HDR_FRAME_PRED_FRAME_DCT (picture->frame_pred_frame_dct); - reg |=VE_DEC_MPEG_MP12HDR_CONCEALMENT_MOTION_VECTORS (picture->concealment_motion_vectors); - reg |=VE_DEC_MPEG_MP12HDR_Q_SCALE_TYPE (picture->q_scale_type); - reg |=VE_DEC_MPEG_MP12HDR_INTRA_VLC_FORMAT (picture->intra_vlc_format); - reg |=VE_DEC_MPEG_MP12HDR_ALTERNATE_SCAN (picture->alternate_scan); + reg =VE_DEC_MPEG_MP12HDR_SLICE_TYPE (pic->picture_coding_type); + reg |=VE_DEC_MPEG_MP12HDR_F_CODE (0 ,0 , pic->f_code[0 ][0 ]); + reg |=VE_DEC_MPEG_MP12HDR_F_CODE (0 ,1 , pic->f_code[0 ][1 ]); + reg |=VE_DEC_MPEG_MP12HDR_F_CODE (1 ,0 , pic->f_code[1 ][0 ]); + reg |=VE_DEC_MPEG_MP12HDR_F_CODE (1 ,1 , pic->f_code[1 ][1 ]); + reg |=VE_DEC_MPEG_MP12HDR_INTRA_DC_PRECISION (pic->intra_dc_precision); + reg |=VE_DEC_MPEG_MP12HDR_INTRA_PICTURE_STRUCTURE (pic->picture_structure); + reg |=VE_DEC_MPEG_MP12HDR_TOP_FIELD_FIRST (pic->flags &V4L2_MPEG2_PIC_FLAG_TOP_FIELD_FIRST ); + reg |=VE_DEC_MPEG_MP12HDR_FRAME_PRED_FRAME_DCT (pic->flags &V4L2_MPEG2_PIC_FLAG_FRAME_PRED_DCT ); + reg |=VE_DEC_MPEG_MP12HDR_CONCEALMENT_MOTION_VECTORS (pic->flags &V4L2_MPEG2_PIC_FLAG_CONCEALMENT_MV ); + reg |=VE_DEC_MPEG_MP12HDR_Q_SCALE_TYPE (pic->flags &V4L2_MPEG2_PIC_FLAG_Q_SCALE_TYPE ); + reg |=VE_DEC_MPEG_MP12HDR_INTRA_VLC_FORMAT (pic->flags &V4L2_MPEG2_PIC_FLAG_INTRA_VLC ); + reg |=VE_DEC_MPEG_MP12HDR_ALTERNATE_SCAN (pic->flags &V4L2_MPEG2_PIC_FLAG_ALT_SCAN ); reg |=VE_DEC_MPEG_MP12HDR_FULL_PEL_FORWARD_VECTOR (0 ); reg |=VE_DEC_MPEG_MP12HDR_FULL_PEL_BACKWARD_VECTOR (0 );
@@ -114,8 +114,8 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)/* Set frame dimensions. */ - reg =VE_DEC_MPEG_PICCODEDSIZE_WIDTH (sequence->horizontal_size); - reg |=VE_DEC_MPEG_PICCODEDSIZE_HEIGHT (sequence->vertical_size); + reg =VE_DEC_MPEG_PICCODEDSIZE_WIDTH (seq->horizontal_size); + reg |=VE_DEC_MPEG_PICCODEDSIZE_HEIGHT (seq->vertical_size);cedrus_write (dev,VE_DEC_MPEG_PICCODEDSIZE , reg);
include/media/mpeg2-ctrls.h +23 -13
@@ -18,10 +18,7 @@#define V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS 0x0103#define V4L2_CTRL_TYPE_MPEG2_QUANTIZATION 0x0104 -#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 +#define V4L2_MPEG2_SEQ_FLAG_PROGRESSIVE 0x0001struct v4l2_mpeg2_sequence {/* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence header */
@@ -31,10 +28,29 @@ struct v4l2_mpeg2_sequence {/* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence extension */ __u16 profile_and_level_indication; -__u8 progressive_sequence;__u8 chroma_format; + +__u32 flags; }; +#define V4L2_MPEG2_PIC_CODING_TYPE_I 1 +#define V4L2_MPEG2_PIC_CODING_TYPE_P 2 +#define V4L2_MPEG2_PIC_CODING_TYPE_B 3 +#define V4L2_MPEG2_PIC_CODING_TYPE_D 4 + +#define V4L2_MPEG2_PIC_TOP_FIELD 0x1 +#define V4L2_MPEG2_PIC_BOTTOM_FIELD 0x2 +#define V4L2_MPEG2_PIC_FRAME 0x3 + +#define V4L2_MPEG2_PIC_FLAG_TOP_FIELD_FIRST 0x0001 +#define V4L2_MPEG2_PIC_FLAG_FRAME_PRED_DCT 0x0002 +#define V4L2_MPEG2_PIC_FLAG_CONCEALMENT_MV 0x0004 +#define V4L2_MPEG2_PIC_FLAG_Q_SCALE_TYPE 0x0008 +#define V4L2_MPEG2_PIC_FLAG_INTRA_VLC 0x0010 +#define V4L2_MPEG2_PIC_FLAG_ALT_SCAN 0x0020 +#define V4L2_MPEG2_PIC_FLAG_REPEAT_FIRST 0x0040 +#define V4L2_MPEG2_PIC_FLAG_PROGRESSIVE 0x0080 +struct v4l2_mpeg2_picture {/* ISO/IEC 13818-2, ITU-T Rec. H.262: Picture header */ __u8 picture_coding_type;
@@ -43,14 +59,8 @@ struct v4l2_mpeg2_picture {__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; -__u16 progressive_frame; + +__u32 flags; };struct v4l2_ctrl_mpeg2_slice_params {
Signature · 1 line
2.30.0
PATCH v4 3/9 media: uapi: mpeg2: Split sequence and picture parameters
In reply to Ezequiel GarciaTypically, bitstreams are composed of a sequence header, followed by a number of picture header and picture coding extension headers. Each picture can be composed by a number of slices.
Let's split the MPEG-2 uAPI to follow these semantics more closely, allowing more usage flexibility. Having these controls split allows applications to set a sequence control at the beginning of a sequence, and then set a picture control for each frame.
While here add padding fields where needed, and document the uAPI header thoroughly.
Note that the V4L2_CTRL_TYPE_{} defines had to be moved because it clashes with existing ones. This is not really an issue since they will be re-defined when the controls are moved out of staging.
--- .../media/v4l/ext-ctrls-codec.rst | 47 ++++++--- .../media/v4l/pixfmt-compressed.rst | 5 +- .../media/v4l/vidioc-queryctrl.rst | 12 +++ .../media/videodev2.h.rst.exceptions | 2 + drivers/media/v4l2-core/v4l2-ctrls.c | 57 ++++++++--- drivers/staging/media/hantro/hantro_drv.c | 10 ++ .../media/hantro/hantro_g1_mpeg2_dec.c | 14 +-- .../media/hantro/rk3399_vpu_hw_mpeg2_dec.c | 14 +-- drivers/staging/media/sunxi/cedrus/cedrus.c | 12 +++ drivers/staging/media/sunxi/cedrus/cedrus.h | 2 + .../staging/media/sunxi/cedrus/cedrus_dec.c | 4 + .../staging/media/sunxi/cedrus/cedrus_mpeg2.c | 8 +- include/media/mpeg2-ctrls.h | 97 +++++++++++++++---- include/media/v4l2-ctrls.h | 4 + 14 files changed, 228 insertions(+), 60 deletions(-)
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +35 -12
@@ -1603,14 +1603,6 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - * - __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. * - __u64 - ``backward_ref_ts`` - Timestamp of the V4L2 capture buffer to use as backward reference, used
@@ -1628,14 +1620,28 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - * - __u32 - ``quantiser_scale_code`` - Code used to determine the quantization scale to use for the IDCT. + * - __u8 + - ``reserved`` + - Applications and drivers must set this to zero. -.. c:type:: v4l2_mpeg2_sequence +``V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE (struct)`` + Specifies the sequence parameters (as extracted from the bitstream) for the + associated MPEG-2 slice data. This includes fields matching the syntax + elements from the sequence header and sequence extension parts of the + bitstream as specified by :ref:`mpeg2part2`. + + .. note:: + + This compound control is not yet part of the public kernel API and + it is expected to change. + +.. c:type:: v4l2_ctrl_mpeg2_sequence .. cssclass:: longtable .. tabularcolumns:: |p{1.4cm}|p{6.5cm}|p{9.4cm}| -.. flat-table:: struct v4l2_mpeg2_sequence +.. flat-table:: struct v4l2_ctrl_mpeg2_sequence :header-rows: 0 :stub-columns: 0 :widths: 1 1 2
@@ -1657,6 +1663,9 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - * - __u8 - ``chroma_format`` - The chrominance sub-sampling format (1: 4:2:0, 2: 4:2:2, 3: 4:4:4). + * - __u8 + - ``reserved`` + - Applications and drivers must set this to zero. * - __u32 - ``flags`` - See :ref:`MPEG-2 Sequence Flags <mpeg2_sequence_flags>`.
@@ -1677,7 +1686,18 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - - Indication that all the frames for the sequence are progressive instead of interlaced. -.. c:type:: v4l2_mpeg2_picture +``V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE (struct)`` + Specifies the picture parameters (as extracted from the bitstream) for the + associated MPEG-2 slice data. This includes fields matching the syntax + elements from the picture header and picture coding extension parts of the + bitstream as specified by :ref:`mpeg2part2`. + + .. note:: + + This compound control is not yet part of the public kernel API and + it is expected to change. + +.. c:type:: v4l2_ctrl_mpeg2_picture .. raw:: latex
@@ -1687,7 +1707,7 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - .. tabularcolumns:: |p{1.0cm}|p{5.6cm}|p{10.7cm}| -.. flat-table:: struct v4l2_mpeg2_picture +.. flat-table:: struct v4l2_ctrl_mpeg2_picture :header-rows: 0 :stub-columns: 0 :widths: 1 1 2
@@ -1708,6 +1728,9 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - - ``picture_structure`` - Picture structure (1: interlaced top field, 2: interlaced bottom field, 3: progressive frame). + * - __u8 + - ``reserved`` + - Applications and drivers must set this to zero. * - __u32 - ``flags`` - See :ref:`MPEG-2 Picture Flags <mpeg2_picture_flags>`.
Documentation/userspace-api/media/v4l/pixfmt-compressed.rst +3 -2
@@ -114,8 +114,9 @@ Compressed Formats This format is adapted for stateless video decoders that implement a MPEG-2 pipeline (using the :ref:`mem2mem` and :ref:`media-request-api`). 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 + through the ``V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE``, + ``V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE``, and ``V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS`` + controls. Quantization matrices can optionally be specified through the ``V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION`` control. See the :ref:`associated Codec Control IDs <v4l2-mpeg-mpeg2>`. Exactly one output and one capture buffer must be provided for use with
Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst +12 -0
@@ -429,6 +429,18 @@ See also the examples in :ref:`control`. - n/a - A struct :c:type:`v4l2_ctrl_mpeg2_quantization`, containing MPEG-2 quantization matrices for stateless video decoders. + * - ``V4L2_CTRL_TYPE_MPEG2_SEQUENCE`` + - n/a + - n/a + - n/a + - A struct :c:type:`v4l2_ctrl_mpeg2_sequence`, containing MPEG-2 + sequence parameters for stateless video decoders. + * - ``V4L2_CTRL_TYPE_MPEG2_PICTURE`` + - n/a + - n/a + - n/a + - A struct :c:type:`v4l2_ctrl_mpeg2_picture`, containing MPEG-2 + picture parameters for stateless video decoders. * - ``V4L2_CTRL_TYPE_AREA`` - n/a - n/a
Documentation/userspace-api/media/videodev2.h.rst.exceptions +2 -0
@@ -134,6 +134,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_SEQUENCE :c:type:`v4l2_ctrl_type` +replace symbol V4L2_CTRL_TYPE_MPEG2_PICTURE :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` replace symbol V4L2_CTRL_TYPE_H264_SPS :c:type:`v4l2_ctrl_type`
drivers/media/v4l2-core/v4l2-ctrls.c +45 -12
128 lines not on this page · raw message
drivers/staging/media/hantro/hantro_drv.c +10 -0
@@ -286,6 +286,16 @@ static const struct hantro_ctrl controls[] = { .def = 50, .ops = &hantro_jpeg_ctrl_ops, }, + }, { + .codec = HANTRO_MPEG2_DECODER, + .cfg = { + .id = V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE, + }, + }, { + .codec = HANTRO_MPEG2_DECODER, + .cfg = { + .id = V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE, + }, }, { .codec = HANTRO_MPEG2_DECODER, .cfg = {
drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c +8 -6
@@ -95,8 +95,8 @@ static void hantro_g1_mpeg2_dec_set_buffers(struct hantro_dev *vpu, struct hantro_ctx *ctx, struct vb2_buffer *src_buf, struct vb2_buffer *dst_buf, - const struct v4l2_mpeg2_sequence *seq, - const struct v4l2_mpeg2_picture *pic, + const struct v4l2_ctrl_mpeg2_sequence *seq, + const struct v4l2_ctrl_mpeg2_picture *pic, const struct v4l2_ctrl_mpeg2_slice_params *slice_params) { dma_addr_t forward_addr = 0, backward_addr = 0;
@@ -156,8 +156,8 @@ void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx)struct hantro_dev *vpu = ctx->dev;struct vb2_v4l2_buffer *src_buf, *dst_buf;const struct v4l2_ctrl_mpeg2_slice_params *slice_params; -const struct v4l2_mpeg2_sequence *seq; -const struct v4l2_mpeg2_picture *pic; +const struct v4l2_ctrl_mpeg2_sequence *seq; +const struct v4l2_ctrl_mpeg2_picture *pic;u32 reg; src_buf =hantro_get_src_buf (ctx);
@@ -168,8 +168,10 @@ void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx) slice_params =hantro_get_ctrl (ctx,V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS ); - seq = &slice_params->sequence; - pic = &slice_params->picture; + seq =hantro_get_ctrl (ctx, +V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE ); + pic =hantro_get_ctrl (ctx, +V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE ); reg =G1_REG_DEC_AXI_RD_ID (0 ) | G1_REG_DEC_TIMEOUT_E(1) |
drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c +8 -6
@@ -97,8 +97,8 @@ rk3399_vpu_mpeg2_dec_set_buffers(struct hantro_dev *vpu,struct hantro_ctx *ctx, struct vb2_buffer *src_buf, struct vb2_buffer *dst_buf, - const struct v4l2_mpeg2_sequence *seq, - const struct v4l2_mpeg2_picture *pic, + const struct v4l2_ctrl_mpeg2_sequence *seq, + const struct v4l2_ctrl_mpeg2_picture *pic, const struct v4l2_ctrl_mpeg2_slice_params *slice_params) { dma_addr_t forward_addr = 0, backward_addr = 0;
@@ -158,8 +158,8 @@ void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx)struct hantro_dev *vpu = ctx->dev;struct vb2_v4l2_buffer *src_buf, *dst_buf;const struct v4l2_ctrl_mpeg2_slice_params *slice_params; -const struct v4l2_mpeg2_sequence *seq; -const struct v4l2_mpeg2_picture *pic; +const struct v4l2_ctrl_mpeg2_sequence *seq; +const struct v4l2_ctrl_mpeg2_picture *pic;u32 reg; src_buf =hantro_get_src_buf (ctx);
@@ -169,8 +169,10 @@ void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx) slice_params =hantro_get_ctrl (ctx,V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS ); - seq = &slice_params->sequence; - pic = &slice_params->picture; + seq =hantro_get_ctrl (ctx, +V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE ); + pic =hantro_get_ctrl (ctx, +V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE ); reg =VDPU_REG_DEC_ADV_PRE_DIS (0 ) | VDPU_REG_DEC_SCMD_DIS(0) |
drivers/staging/media/sunxi/cedrus/cedrus.c +12 -0
@@ -29,6 +29,18 @@#include "cedrus_hw.h" static const struct cedrus_control cedrus_controls[] = { + { + .cfg = { + .id =V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE , + }, + .codec =CEDRUS_CODEC_MPEG2 , + }, + { + .cfg = { + .id =V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE , + }, + .codec =CEDRUS_CODEC_MPEG2 , + }, { .cfg = { .id =V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS ,
drivers/staging/media/sunxi/cedrus/cedrus.h +2 -0
@@ -68,6 +68,8 @@ struct cedrus_h264_run { };struct cedrus_mpeg2_run { +const struct v4l2_ctrl_mpeg2_sequence *sequence; +const struct v4l2_ctrl_mpeg2_picture *picture;const struct v4l2_ctrl_mpeg2_slice_params *slice_params;const struct v4l2_ctrl_mpeg2_quantization *quantization; };
drivers/staging/media/sunxi/cedrus/cedrus_dec.c +4 -0
@@ -40,6 +40,10 @@ void cedrus_device_run(void *priv)switch (ctx->src_fmt.pixelformat) {case V4L2_PIX_FMT_MPEG2_SLICE : + run.mpeg2.sequence =cedrus_find_control_data (ctx, +V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE ); + run.mpeg2.picture =cedrus_find_control_data (ctx, +V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE ); run.mpeg2.slice_params =cedrus_find_control_data (ctx,V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS ); run.mpeg2.quantization = cedrus_find_control_data(ctx,
drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c +4 -4
@@ -51,8 +51,8 @@ static void cedrus_mpeg2_irq_disable(struct cedrus_ctx *ctx)static void cedrus_mpeg2_setup (struct cedrus_ctx *ctx,struct cedrus_run *run) {const struct v4l2_ctrl_mpeg2_slice_params *slice_params; -const struct v4l2_mpeg2_sequence *seq; -const struct v4l2_mpeg2_picture *pic; +const struct v4l2_ctrl_mpeg2_sequence *seq; +const struct v4l2_ctrl_mpeg2_picture *pic;const struct v4l2_ctrl_mpeg2_quantization *quantization;dma_addr_t src_buf_addr, dst_luma_addr, dst_chroma_addr;dma_addr_t fwd_luma_addr, fwd_chroma_addr;
@@ -66,8 +66,8 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)u32 reg; slice_params = run->mpeg2.slice_params; - seq = &slice_params->sequence; - pic = &slice_params->picture; + seq = run->mpeg2.sequence; + pic = run->mpeg2.picture; quantization = run->mpeg2.quantization;
include/media/mpeg2-ctrls.h +79 -18
135 lines not on this page · raw message
include/media/v4l2-ctrls.h +4 -0
@@ -40,6 +40,8 @@ struct video_device;* @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_sequence: Pointer to a MPEG2 sequence structure. +* @p_mpeg2_picture: Pointer to a MPEG2 picture structure. * @p_mpeg2_slice_params: Pointer to a MPEG2 slice parameters structure. * @p_mpeg2_quantization: Pointer to a MPEG2 quantization data structure. * @p_fwht_params: Pointer to a FWHT stateless parameters structure.
@@ -64,6 +66,8 @@ union v4l2_ctrl_ptr {u16 *p_u16;u32 *p_u32;char *p_char; +struct v4l2_ctrl_mpeg2_sequence *p_mpeg2_sequence; +struct v4l2_ctrl_mpeg2_picture *p_mpeg2_picture;struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params;struct v4l2_ctrl_mpeg2_quantization *p_mpeg2_quantization;struct v4l2_ctrl_fwht_params *p_fwht_params;
Signature · 1 line
2.30.0
PATCH v4 4/9 media: uapi: mpeg2: Move reference buffer fields
In reply to Ezequiel GarciaThe forward and backwards references are specified per-picture and not per-slice. Move it to V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE.
--- .../media/v4l/ext-ctrls-codec.rst | 28 +++++++++---------- .../media/hantro/hantro_g1_mpeg2_dec.c | 6 ++-- .../media/hantro/rk3399_vpu_hw_mpeg2_dec.c | 6 ++-- .../staging/media/sunxi/cedrus/cedrus_mpeg2.c | 4 +-- include/media/mpeg2-ctrls.h | 16 +++++------ 5 files changed, 28 insertions(+), 32 deletions(-)
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +14 -14
@@ -1603,20 +1603,6 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - * - __u32 - ``data_bit_offset`` - Offset (in bits) to the video data in the current slice data. - * - __u64 - - ``backward_ref_ts`` - - Timestamp of the V4L2 capture buffer to use as backward reference, used - with B-coded and P-coded frames. The timestamp refers to the - ``timestamp`` field in struct :c:type:`v4l2_buffer`. Use the - :c:func:`v4l2_timeval_to_ns()` function to convert the struct - :c:type:`timeval` in struct :c:type:`v4l2_buffer` to a __u64. - * - __u64 - - ``forward_ref_ts`` - - Timestamp for the V4L2 capture buffer to use as forward reference, used - with B-coded frames. The timestamp refers to the ``timestamp`` field in - struct :c:type:`v4l2_buffer`. Use the :c:func:`v4l2_timeval_to_ns()` - function to convert the struct :c:type:`timeval` in struct - :c:type:`v4l2_buffer` to a __u64. * - __u32 - ``quantiser_scale_code`` - Code used to determine the quantization scale to use for the IDCT.
@@ -1712,6 +1698,20 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - :stub-columns: 0 :widths: 1 1 2 + * - __u64 + - ``backward_ref_ts`` + - Timestamp of the V4L2 capture buffer to use as backward reference, used + with B-coded and P-coded frames. The timestamp refers to the + ``timestamp`` field in struct :c:type:`v4l2_buffer`. Use the + :c:func:`v4l2_timeval_to_ns()` function to convert the struct + :c:type:`timeval` in struct :c:type:`v4l2_buffer` to a __u64. + * - __u64 + - ``forward_ref_ts`` + - Timestamp for the V4L2 capture buffer to use as forward reference, used + with B-coded frames. The timestamp refers to the ``timestamp`` field in + struct :c:type:`v4l2_buffer`. Use the :c:func:`v4l2_timeval_to_ns()` + function to convert the struct :c:type:`timeval` in struct + :c:type:`v4l2_buffer` to a __u64. * - __u8 - ``picture_coding_type`` - Picture coding type for the frame covered by the current slice
drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c +2 -4
@@ -104,12 +104,10 @@ hantro_g1_mpeg2_dec_set_buffers(struct hantro_dev *vpu, struct hantro_ctx *ctx,switch (pic->picture_coding_type) {case V4L2_MPEG2_PIC_CODING_TYPE_B : - backward_addr =hantro_get_ref (ctx, - slice_params->backward_ref_ts); + backward_addr =hantro_get_ref (ctx, pic->backward_ref_ts); fallthrough;case V4L2_MPEG2_PIC_CODING_TYPE_P : - forward_addr =hantro_get_ref (ctx, - slice_params->forward_ref_ts); + forward_addr =hantro_get_ref (ctx, pic->forward_ref_ts); }/* Source bitstream buffer */
drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c +2 -4
@@ -106,12 +106,10 @@ rk3399_vpu_mpeg2_dec_set_buffers(struct hantro_dev *vpu,switch (pic->picture_coding_type) {case V4L2_MPEG2_PIC_CODING_TYPE_B : - backward_addr =hantro_get_ref (ctx, - slice_params->backward_ref_ts); + backward_addr =hantro_get_ref (ctx, pic->backward_ref_ts); fallthrough;case V4L2_MPEG2_PIC_CODING_TYPE_P : - forward_addr =hantro_get_ref (ctx, - slice_params->forward_ref_ts); + forward_addr =hantro_get_ref (ctx, pic->forward_ref_ts); }/* Source bitstream buffer */
drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c +2 -2
@@ -128,14 +128,14 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) vq =v4l2_m2m_get_vq (ctx->fh.m2m_ctx,V4L2_BUF_TYPE_VIDEO_CAPTURE ); - forward_idx =vb2_find_timestamp (vq, slice_params->forward_ref_ts,0 ); + forward_idx =vb2_find_timestamp (vq, pic->forward_ref_ts,0 ); fwd_luma_addr =cedrus_dst_buf_addr (ctx, forward_idx,0 ); fwd_chroma_addr =cedrus_dst_buf_addr (ctx, forward_idx,1 );cedrus_write (dev,VE_DEC_MPEG_FWD_REF_LUMA_ADDR , fwd_luma_addr);cedrus_write (dev,VE_DEC_MPEG_FWD_REF_CHROMA_ADDR , fwd_chroma_addr); - backward_idx =vb2_find_timestamp (vq, slice_params->backward_ref_ts,0 ); + backward_idx =vb2_find_timestamp (vq, pic->backward_ref_ts,0 ); bwd_luma_addr =cedrus_dst_buf_addr (ctx, backward_idx,0 ); bwd_chroma_addr =cedrus_dst_buf_addr (ctx, backward_idx,1 );
include/media/mpeg2-ctrls.h +8 -8
@@ -79,6 +79,12 @@ struct v4l2_ctrl_mpeg2_sequence {* All the members on this structure match the picture header and picture * coding extension syntaxes as specified by the MPEG-2 specification. * +* @backward_ref_ts: timestamp of the V4L2 capture buffer to use as +* reference for backward prediction. +* @forward_ref_ts: timestamp of the V4L2 capture buffer to use as +* reference for forward prediction. These timestamp refers to the +* timestamp field in struct v4l2_buffer. Use v4l2_timeval_to_ns() +* to convert the struct timeval to a __u64. * @picture_coding_type: see MPEG-2 specification. * @f_code[2][2]: see MPEG-2 specification. * @intra_dc_precision: see MPEG-2 specification.
@@ -87,6 +93,8 @@ struct v4l2_ctrl_mpeg2_sequence {* @flags: see V4L2_MPEG2_PIC_FLAG_{}. */ struct v4l2_ctrl_mpeg2_picture { +__u64 backward_ref_ts; +__u64 forward_ref_ts;__u8 picture_coding_type;__u8 f_code[2 ][2 ];__u8 intra_dc_precision;
@@ -98,12 +106,6 @@ struct v4l2_ctrl_mpeg2_picture {/** * struct v4l2_ctrl_mpeg2_slice_params - MPEG-2 slice header * -* @backward_ref_ts: timestamp of the V4L2 capture buffer to use as -* reference for backward prediction. -* @forward_ref_ts: timestamp of the V4L2 capture buffer to use as -* reference for forward prediction. These timestamp refers to the -* timestamp field in struct v4l2_buffer. Use v4l2_timeval_to_ns() -* to convert the struct timeval to a __u64. * @quantiser_scale_code: quantiser scale integer matching an * homonymous syntax element. * @reserved: padding field. Should be zeroed by applications.
@@ -111,8 +113,6 @@ struct v4l2_ctrl_mpeg2_picture {struct v4l2_ctrl_mpeg2_slice_params {__u32 bit_size;__u32 data_bit_offset; -__u64 backward_ref_ts; -__u64 forward_ref_ts;__u32 quantiser_scale_code;__u32 reserved; };
Signature · 1 line
2.30.0
PATCH v4 5/9 media: hantro/cedrus: Remove unneeded slice size and slice offset
In reply to Ezequiel GarciaThe MPEG2_SLICE_PARAMS control is designed to refer to a single slice. However, the Hantro and Cedrus drivers operate in per-frame mode, and so does the current Ffmpeg and GStreamer implementations that are tested with these two drivers.
In other words, the drivers are expecting all the slices in a picture (with either frame or field structure) to be contained in
the OUTPUT buffer, which means the slice size and offset shouldn't be used.
--- drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c | 4 ++-- drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c | 4 ++-- drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-)
drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c +2 -2
@@ -206,7 +206,7 @@ void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx)G1_REG_TOPFIELDFIRST_E (pic->flags &V4L2_MPEG2_PIC_FLAG_TOP_FIELD_FIRST );vdpu_write_relaxed (vpu, reg,G1_SWREG (4 )); - reg =G1_REG_STRM_START_BIT (slice_params->data_bit_offset) | + reg =G1_REG_STRM_START_BIT (0 ) |G1_REG_QSCALE_TYPE (pic->flags &V4L2_MPEG2_PIC_FLAG_Q_SCALE_TYPE ) |G1_REG_CON_MV_E (pic->flags &V4L2_MPEG2_PIC_FLAG_CONCEALMENT_MV ) | G1_REG_INTRA_DC_PREC(pic->intra_dc_precision) |
@@ -215,7 +215,7 @@ void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx)vdpu_write_relaxed (vpu, reg,G1_SWREG (5 )); reg =G1_REG_INIT_QP (1 ) | -G1_REG_STREAM_LEN (slice_params->bit_size >>3 ); +G1_REG_STREAM_LEN (vb2_get_plane_payload (&src_buf->vb2_buf,0 ));vdpu_write_relaxed (vpu, reg,G1_SWREG (6 )); reg = G1_REG_ALT_SCAN_FLAG_E(pic->flags & V4L2_MPEG2_PIC_FLAG_ALT_SCAN) |
drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c +2 -2
@@ -179,7 +179,7 @@ void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx)vdpu_write_relaxed (vpu, reg,VDPU_SWREG (50 )); reg =VDPU_REG_INIT_QP (1 ) | -VDPU_REG_STREAM_LEN (slice_params->bit_size >>3 ); +VDPU_REG_STREAM_LEN (vb2_get_plane_payload (&src_buf->vb2_buf,0 ));vdpu_write_relaxed (vpu, reg,VDPU_SWREG (51 )); reg = VDPU_REG_APF_THRESHOLD(8) |
@@ -222,7 +222,7 @@ void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx)VDPU_REG_TOPFIELDFIRST_E (pic->flags &V4L2_MPEG2_PIC_FLAG_TOP_FIELD_FIRST );vdpu_write_relaxed (vpu, reg,VDPU_SWREG (120 )); - reg =VDPU_REG_STRM_START_BIT (slice_params->data_bit_offset) | + reg =VDPU_REG_STRM_START_BIT (0 ) |VDPU_REG_QSCALE_TYPE (pic->flags &V4L2_MPEG2_PIC_FLAG_Q_SCALE_TYPE ) |VDPU_REG_CON_MV_E (pic->flags &V4L2_MPEG2_PIC_FLAG_CONCEALMENT_MV ) | VDPU_REG_INTRA_DC_PREC(pic->intra_dc_precision) |
drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c +3 -4
@@ -152,10 +152,9 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)/* Source offset and length in bits. */ -cedrus_write (dev,VE_DEC_MPEG_VLD_OFFSET , - slice_params->data_bit_offset); +cedrus_write (dev,VE_DEC_MPEG_VLD_OFFSET ,0 ); - reg = slice_params->bit_size - slice_params->data_bit_offset; + reg =vb2_get_plane_payload (&run->src->vb2_buf,0 ) *8 ;cedrus_write (dev,VE_DEC_MPEG_VLD_LEN , reg);/* Source beginning and end addresses. */
@@ -169,7 +168,7 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)cedrus_write (dev,VE_DEC_MPEG_VLD_ADDR , reg); - reg = src_buf_addr +DIV_ROUND_UP (slice_params->bit_size,8 ); + reg = src_buf_addr +vb2_get_plane_payload (&run->src->vb2_buf,0 );cedrus_write (dev,VE_DEC_MPEG_VLD_END_ADDR , reg);/* Macroblock address: start at the beginning. */
Signature · 1 line
2.30.0
PATCH v4 6/9 media: uapi: mpeg2: Remove V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS
In reply to Ezequiel GarciaThe Hantro and Cedrus drivers work in frame-mode, meaning they expect all the slices in a picture (either frame or field structure) to be passed in each OUTPUT buffer.
These two are the only V4L2 MPEG-2 stateless decoders currently supported. Given the VA-API drivers also work per-frame, coalescing all the MPEG-2 slices in a buffer before the decoding operation, it makes sense to not expect slice-mode drivers and therefore remove V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS.
This is done to avoid carrying an unused interface. If needed, this control can be added without breaking backwards compatibility. Note that this would mean introducing a enumerator control to specify the decoding mode (see V4L2_CID_STATELESS_H264_DECODE_MODE).
--- .../media/v4l/ext-ctrls-codec.rst | 35 ------------------- .../media/v4l/pixfmt-compressed.rst | 6 ++-- .../media/v4l/vidioc-queryctrl.rst | 6 ---- .../media/videodev2.h.rst.exceptions | 1 - drivers/media/v4l2-core/v4l2-ctrls.c | 19 ---------- drivers/staging/media/hantro/hantro_drv.c | 5 --- .../media/hantro/hantro_g1_mpeg2_dec.c | 9 ++--- .../media/hantro/rk3399_vpu_hw_mpeg2_dec.c | 8 ++--- drivers/staging/media/sunxi/cedrus/cedrus.c | 6 ---- drivers/staging/media/sunxi/cedrus/cedrus.h | 1 - .../staging/media/sunxi/cedrus/cedrus_dec.c | 2 -- .../staging/media/sunxi/cedrus/cedrus_mpeg2.c | 2 -- include/media/mpeg2-ctrls.h | 16 --------- include/media/v4l2-ctrls.h | 2 -- 14 files changed, 7 insertions(+), 111 deletions(-)
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +0 -35
@@ -1575,41 +1575,6 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - .. _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 :ref:`mpeg2part2`. - - .. note:: - - This compound control is not yet part of the public kernel API and - it is expected to change. - -.. c:type:: v4l2_ctrl_mpeg2_slice_params - -.. tabularcolumns:: |p{5.6cm}|p{4.6cm}|p{7.1cm}| - -.. 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. - * - __u32 - - ``quantiser_scale_code`` - - Code used to determine the quantization scale to use for the IDCT. - * - __u8 - - ``reserved`` - - Applications and drivers must set this to zero. - ``V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE (struct)`` Specifies the sequence parameters (as extracted from the bitstream) for the associated MPEG-2 slice data. This includes fields matching the syntax
Documentation/userspace-api/media/v4l/pixfmt-compressed.rst +3 -3
@@ -114,9 +114,9 @@ Compressed Formats This format is adapted for stateless video decoders that implement a MPEG-2 pipeline (using the :ref:`mem2mem` and :ref:`media-request-api`). Metadata associated with the frame to decode is required to be passed - through the ``V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE``, - ``V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE``, and ``V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS`` - controls. Quantization matrices can optionally be specified through the + through the ``V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE`` and + ``V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE`` controls. + Quantization matrices can optionally be specified through the ``V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION`` control. See the :ref:`associated Codec Control IDs <v4l2-mpeg-mpeg2>`. Exactly one output and one capture buffer must be provided for use with
Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst +0 -6
@@ -417,12 +417,6 @@ 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
Documentation/userspace-api/media/videodev2.h.rst.exceptions +0 -1
@@ -136,7 +136,6 @@ 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_SEQUENCE :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_MPEG2_PICTURE :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` replace symbol V4L2_CTRL_TYPE_H264_SPS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_H264_PPS :c:type:`v4l2_ctrl_type`
drivers/media/v4l2-core/v4l2-ctrls.c +0 -19
@@ -975,7 +975,6 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID :return "Base Layer Priority ID" ;case V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE :return "MPEG-2 Sequence Header" ;case V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE :return "MPEG-2 Picture Header" ; -case V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS :return "MPEG-2 Slice Parameters" ;case V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION :return "MPEG-2 Quantization Matrices" ;case V4L2_CID_FWHT_I_FRAME_QP :return "FWHT I-Frame QP Value" ;case V4L2_CID_FWHT_P_FRAME_QP :return "FWHT P-Frame QP Value" ;
@@ -1477,9 +1476,6 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,case V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE : *type =V4L2_CTRL_TYPE_MPEG2_PICTURE ;break ; -case V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS : - *type =V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS ; -break ;case V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION : *type =V4L2_CTRL_TYPE_MPEG2_QUANTIZATION ;break ;
@@ -1687,11 +1683,6 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx,else memset (p,0 , ctrl->elem_size); -/* -* The cast is needed to get rid of a gcc warning complaining that -* V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS is not part of the -* v4l2_ctrl_type enum. -*/ switch ((u32 )ctrl->type) {case V4L2_CTRL_TYPE_MPEG2_SEQUENCE : p_mpeg2_sequence = p;
@@ -1878,7 +1869,6 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, {struct v4l2_ctrl_mpeg2_sequence *p_mpeg2_sequence;struct v4l2_ctrl_mpeg2_picture *p_mpeg2_picture; -struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params;struct v4l2_ctrl_vp8_frame *p_vp8_frame;struct v4l2_ctrl_fwht_params *p_fwht_params;struct v4l2_ctrl_h264_sps *p_h264_sps;
@@ -1941,12 +1931,6 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,zero_reserved (*p_mpeg2_picture);break ; -case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS : - p_mpeg2_slice_params = p; - -zero_reserved (*p_mpeg2_slice_params); -break ; -case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION :break ;
@@ -2855,9 +2839,6 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,case V4L2_CTRL_TYPE_MPEG2_PICTURE : elem_size =sizeof (struct v4l2_ctrl_mpeg2_picture );break ; -case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS : - elem_size =sizeof (struct v4l2_ctrl_mpeg2_slice_params ); -break ;case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION : elem_size =sizeof (struct v4l2_ctrl_mpeg2_quantization );break ;
drivers/staging/media/hantro/hantro_drv.c +0 -5
@@ -296,11 +296,6 @@ static const struct hantro_ctrl controls[] = { .cfg = { .id = V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE, }, - }, { - .codec = HANTRO_MPEG2_DECODER, - .cfg = { - .id = V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS, - }, }, { .codec = HANTRO_MPEG2_DECODER, .cfg = {
drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c +2 -7
@@ -96,8 +96,7 @@ hantro_g1_mpeg2_dec_set_buffers(struct hantro_dev *vpu, struct hantro_ctx *ctx,struct vb2_buffer *src_buf, struct vb2_buffer *dst_buf, const struct v4l2_ctrl_mpeg2_sequence *seq, - const struct v4l2_ctrl_mpeg2_picture *pic, - const struct v4l2_ctrl_mpeg2_slice_params *slice_params) + const struct v4l2_ctrl_mpeg2_picture *pic) { dma_addr_t forward_addr = 0, backward_addr = 0;dma_addr_t current_addr, addr;
@@ -153,7 +152,6 @@ void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;struct vb2_v4l2_buffer *src_buf, *dst_buf; -const struct v4l2_ctrl_mpeg2_slice_params *slice_params;const struct v4l2_ctrl_mpeg2_sequence *seq;const struct v4l2_ctrl_mpeg2_picture *pic;u32 reg;
@@ -164,8 +162,6 @@ void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx)/* Apply request controls if any */ hantro_start_prepare_run (ctx); - slice_params =hantro_get_ctrl (ctx, -V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS ); seq =hantro_get_ctrl (ctx,V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE ); pic = hantro_get_ctrl(ctx,
@@ -235,10 +231,9 @@ void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx)vdpu_write_relaxed (vpu, reg,G1_SWREG (55 ));hantro_g1_mpeg2_dec_set_quantization (vpu, ctx); -hantro_g1_mpeg2_dec_set_buffers (vpu, ctx, &src_buf->vb2_buf, &dst_buf->vb2_buf, - seq, pic, slice_params); + seq, pic);hantro_end_prepare_run (ctx);
drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c +2 -6
@@ -98,8 +98,7 @@ rk3399_vpu_mpeg2_dec_set_buffers(struct hantro_dev *vpu,struct vb2_buffer *src_buf, struct vb2_buffer *dst_buf, const struct v4l2_ctrl_mpeg2_sequence *seq, - const struct v4l2_ctrl_mpeg2_picture *pic, - const struct v4l2_ctrl_mpeg2_slice_params *slice_params) + const struct v4l2_ctrl_mpeg2_picture *pic) { dma_addr_t forward_addr = 0, backward_addr = 0;dma_addr_t current_addr, addr;
@@ -155,7 +154,6 @@ void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;struct vb2_v4l2_buffer *src_buf, *dst_buf; -const struct v4l2_ctrl_mpeg2_slice_params *slice_params;const struct v4l2_ctrl_mpeg2_sequence *seq;const struct v4l2_ctrl_mpeg2_picture *pic;u32 reg;
@@ -165,8 +163,6 @@ void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx)hantro_start_prepare_run (ctx); - slice_params =hantro_get_ctrl (ctx, -V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS ); seq =hantro_get_ctrl (ctx,V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE ); pic = hantro_get_ctrl(ctx,
@@ -243,7 +239,7 @@ void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx)rk3399_vpu_mpeg2_dec_set_buffers (vpu, ctx, &src_buf->vb2_buf, &dst_buf->vb2_buf, - seq, pic, slice_params); + seq, pic);/* Kick the watchdog and start decoding */ hantro_end_prepare_run (ctx);
drivers/staging/media/sunxi/cedrus/cedrus.c +0 -6
@@ -41,12 +41,6 @@ static const struct cedrus_control cedrus_controls[] = { }, .codec = CEDRUS_CODEC_MPEG2, }, - { - .cfg = { - .id = V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS, - }, - .codec = CEDRUS_CODEC_MPEG2, - }, { .cfg = { .id = V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION,
drivers/staging/media/sunxi/cedrus/cedrus.h +0 -1
@@ -70,7 +70,6 @@ struct cedrus_h264_run {struct cedrus_mpeg2_run {const struct v4l2_ctrl_mpeg2_sequence *sequence;const struct v4l2_ctrl_mpeg2_picture *picture; -const struct v4l2_ctrl_mpeg2_slice_params *slice_params;const struct v4l2_ctrl_mpeg2_quantization *quantization; };
drivers/staging/media/sunxi/cedrus/cedrus_dec.c +0 -2
@@ -44,8 +44,6 @@ void cedrus_device_run(void *priv) V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE); run.mpeg2.picture =cedrus_find_control_data (ctx,V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE ); - run.mpeg2.slice_params =cedrus_find_control_data (ctx, -V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS ); run.mpeg2.quantization =cedrus_find_control_data (ctx,V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION );break ;
drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c +0 -2
@@ -50,7 +50,6 @@ static void cedrus_mpeg2_irq_disable(struct cedrus_ctx *ctx)static void cedrus_mpeg2_setup (struct cedrus_ctx *ctx,struct cedrus_run *run) { -const struct v4l2_ctrl_mpeg2_slice_params *slice_params;const struct v4l2_ctrl_mpeg2_sequence *seq;const struct v4l2_ctrl_mpeg2_picture *pic;const struct v4l2_ctrl_mpeg2_quantization *quantization;
@@ -65,7 +64,6 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)unsigned int i;u32 reg; - slice_params = run->mpeg2.slice_params; seq = run->mpeg2.sequence; pic = run->mpeg2.picture;
include/media/mpeg2-ctrls.h +0 -16
@@ -11,13 +11,11 @@#ifndef _MPEG2_CTRLS_H_#define _MPEG2_CTRLS_H_ -#define V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS (V4L2_CID_CODEC_BASE+250)#define V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION (V4L2_CID_CODEC_BASE+251)#define V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE (V4L2_CID_CODEC_BASE+252)#define V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE (V4L2_CID_CODEC_BASE+253)/* enum v4l2_ctrl_type type values */ -#define V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS 0x0130#define V4L2_CTRL_TYPE_MPEG2_QUANTIZATION 0x0131#define V4L2_CTRL_TYPE_MPEG2_SEQUENCE 0x0132#define V4L2_CTRL_TYPE_MPEG2_PICTURE 0x0133
@@ -103,20 +101,6 @@ struct v4l2_ctrl_mpeg2_picture {__u32 flags; }; -/** -* struct v4l2_ctrl_mpeg2_slice_params - MPEG-2 slice header -* -* @quantiser_scale_code: quantiser scale integer matching an -* homonymous syntax element. -* @reserved: padding field. Should be zeroed by applications. -*/ -struct v4l2_ctrl_mpeg2_slice_params { -__u32 bit_size; -__u32 data_bit_offset; -__u32 quantiser_scale_code; -__u32 reserved; -}; -/** * struct v4l2_ctrl_mpeg2_quantization - MPEG-2 quantization *
include/media/v4l2-ctrls.h +0 -2
@@ -42,7 +42,6 @@ struct video_device;* @p_char: Pointer to a string. * @p_mpeg2_sequence: Pointer to a MPEG2 sequence structure. * @p_mpeg2_picture: Pointer to a MPEG2 picture structure. -* @p_mpeg2_slice_params: Pointer to a MPEG2 slice parameters structure. * @p_mpeg2_quantization: Pointer to a MPEG2 quantization data structure. * @p_fwht_params: Pointer to a FWHT stateless parameters structure. * @p_h264_sps: Pointer to a struct v4l2_ctrl_h264_sps.
@@ -68,7 +67,6 @@ union v4l2_ctrl_ptr {char *p_char;struct v4l2_ctrl_mpeg2_sequence *p_mpeg2_sequence;struct v4l2_ctrl_mpeg2_picture *p_mpeg2_picture; -struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params;struct v4l2_ctrl_mpeg2_quantization *p_mpeg2_quantization;struct v4l2_ctrl_fwht_params *p_fwht_params;struct v4l2_ctrl_h264_sps *p_h264_sps;
Signature · 1 line
2.30.0
PATCH v4 7/9 media: controls: Log MPEG-2 stateless control in .std_log
In reply to Ezequiel GarciaSimply print the type of the control.
--- drivers/media/v4l2-core/v4l2-ctrls.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/media/v4l2-core/v4l2-ctrls.c +9 -0
@@ -1826,6 +1826,15 @@ static void std_log(const struct v4l2_ctrl *ctrl)case V4L2_CTRL_TYPE_VP8_FRAME :pr_cont ("VP8_FRAME" );break ; +case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION : +pr_cont ("MPEG2_QUANTIZATION" ); +break ; +case V4L2_CTRL_TYPE_MPEG2_SEQUENCE : +pr_cont ("MPEG2_SEQUENCE" ); +break ; +case V4L2_CTRL_TYPE_MPEG2_PICTURE : +pr_cont ("MPEG2_PICTURE" ); +break ;default :pr_cont ("unknown type %d" , ctrl->type);break ;
Signature · 1 line
2.30.0
PATCH v4 8/9 media: uapi: Move the MPEG-2 stateless control type out of staging
In reply to Ezequiel GarciaMove the MPEG-2 stateless control types out of staging, and re-number it to avoid any confusion.
--- include/media/mpeg2-ctrls.h | 4 ---- include/uapi/linux/videodev2.h | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-)
include/media/mpeg2-ctrls.h +0 -4
@@ -16,10 +16,6 @@#define V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE (V4L2_CID_CODEC_BASE+253)/* enum v4l2_ctrl_type type values */ -#define V4L2_CTRL_TYPE_MPEG2_QUANTIZATION 0x0131 -#define V4L2_CTRL_TYPE_MPEG2_SEQUENCE 0x0132 -#define V4L2_CTRL_TYPE_MPEG2_PICTURE 0x0133 -#define V4L2_MPEG2_SEQ_FLAG_PROGRESSIVE 0x0001/**
include/uapi/linux/videodev2.h +4 -0
@@ -1804,6 +1804,10 @@ enum v4l2_ctrl_type {V4L2_CTRL_TYPE_FWHT_PARAMS =0x0220 ,V4L2_CTRL_TYPE_VP8_FRAME =0x0240 , + +V4L2_CTRL_TYPE_MPEG2_QUANTIZATION =0x0250 , +V4L2_CTRL_TYPE_MPEG2_SEQUENCE =0x0251 , + V4L2_CTRL_TYPE_MPEG2_PICTURE = 0x0252, };/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
Signature · 1 line
2.30.0
PATCH v4 9/9 media: uapi: Move MPEG-2 stateless controls out of staging
In reply to Ezequiel GarciaUntil now, the MPEG-2 V4L2 API was not exported as a public API, and only defined in a private media header (media/mpeg2-ctrls.h).
After reviewing the MPEG-2 specification in detail, and reworking the controls so they match the MPEG-2 semantics properly, we can consider it ready.
--- .../media/v4l/ext-ctrls-codec-stateless.rst | 218 +++++++++++++++++ .../media/v4l/ext-ctrls-codec.rst | 219 ------------------ .../media/v4l/pixfmt-compressed.rst | 10 +- .../media/v4l/vidioc-g-ext-ctrls.rst | 12 + drivers/media/v4l2-core/v4l2-ctrls.c | 12 +- drivers/staging/media/hantro/hantro_drv.c | 6 +- .../media/hantro/hantro_g1_mpeg2_dec.c | 6 +- .../media/hantro/rk3399_vpu_hw_mpeg2_dec.c | 6 +- drivers/staging/media/sunxi/cedrus/cedrus.c | 6 +- .../staging/media/sunxi/cedrus/cedrus_dec.c | 6 +- include/media/mpeg2-ctrls.h | 128 ---------- include/media/v4l2-ctrls.h | 1 - include/uapi/linux/v4l2-controls.h | 114 +++++++++ include/uapi/linux/videodev2.h | 3 + 14 files changed, 373 insertions(+), 374 deletions(-) delete mode 100644 include/media/mpeg2-ctrls.h
Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst +218 -0
@@ -1244,3 +1244,221 @@ FWHT Flags * - __u8 - ``padding[3]`` - Applications and drivers must set this to zero. + +.. _v4l2-codec-stateless-mpeg2: + +``V4L2_CID_STATELESS_MPEG2_SEQUENCE (struct)`` + Specifies the sequence parameters (as extracted from the bitstream) for the + associated MPEG-2 slice data. This includes fields matching the syntax + elements from the sequence header and sequence extension parts of the + bitstream as specified by :ref:`mpeg2part2`. + +.. c:type:: v4l2_ctrl_mpeg2_sequence + +.. raw:: latex + + \small + +.. cssclass:: longtable + +.. tabularcolumns:: |p{1.4cm}|p{6.5cm}|p{9.4cm}| + +.. flat-table:: struct v4l2_ctrl_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. + * - __u16 + - ``profile_and_level_indication`` + - The current profile and level indication as extracted from the + bitstream. + * - __u8 + - ``chroma_format`` + - The chrominance sub-sampling format (1: 4:2:0, 2: 4:2:2, 3: 4:4:4). + * - __u8 + - ``reserved`` + - Applications and drivers must set this to zero. + * - __u32 + - ``flags`` + - See :ref:`MPEG-2 Sequence Flags <mpeg2_sequence_flags>`. + +.. _mpeg2_sequence_flags: + +``MPEG-2 Sequence Flags`` + +.. cssclass:: longtable + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - ``V4L2_MPEG2_SEQ_FLAG_PROGRESSIVE`` + - 0x00000001 + - Indication that all the frames for the sequence are progressive instead + of interlaced. + +.. raw:: latex + + \normalsize + +``V4L2_CID_STATELESS_MPEG2_PICTURE (struct)`` + Specifies the picture parameters (as extracted from the bitstream) for the + associated MPEG-2 slice data. This includes fields matching the syntax + elements from the picture header and picture coding extension parts of the + bitstream as specified by :ref:`mpeg2part2`. + +.. c:type:: v4l2_ctrl_mpeg2_picture + +.. raw:: latex + + \small + +.. cssclass:: longtable + +.. tabularcolumns:: |p{1.0cm}|p{5.6cm}|p{10.7cm}| + +.. flat-table:: struct v4l2_ctrl_mpeg2_picture + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - __u64 + - ``backward_ref_ts`` + - Timestamp of the V4L2 capture buffer to use as backward reference, used + with B-coded and P-coded frames. The timestamp refers to the + ``timestamp`` field in struct :c:type:`v4l2_buffer`. Use the + :c:func:`v4l2_timeval_to_ns()` function to convert the struct + :c:type:`timeval` in struct :c:type:`v4l2_buffer` to a __u64. + * - __u64 + - ``forward_ref_ts`` + - Timestamp for the V4L2 capture buffer to use as forward reference, used + with B-coded frames. The timestamp refers to the ``timestamp`` field in + struct :c:type:`v4l2_buffer`. Use the :c:func:`v4l2_timeval_to_ns()` + function to convert the struct :c:type:`timeval` in struct + :c:type:`v4l2_buffer` to a __u64. + * - __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 + - ``reserved`` + - Applications and drivers must set this to zero. + * - __u32 + - ``flags`` + - See :ref:`MPEG-2 Picture Flags <mpeg2_picture_flags>`. + + +.. _mpeg2_picture_flags: + +``MPEG-2 Picture Flags`` + +.. cssclass:: longtable + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - ``V4L2_MPEG2_PIC_FLAG_TOP_FIELD_FIRST`` + - 0x00000001 + - If set and it's an interlaced stream, top field is output first. + * - ``V4L2_MPEG2_PIC_FLAG_FRAME_PRED_DCT`` + - 0x00000002 + - If set only frame-DCT and frame prediction are used. + * - ``V4L2_MPEG2_PIC_FLAG_CONCEALMENT_MV`` + - 0x00000004 + - If set motion vectors are coded for intra macroblocks. + * - ``V4L2_MPEG2_PIC_FLAG_Q_SCALE_TYPE`` + - 0x00000008 + - This flag affects the inverse quantization process. + * - ``V4L2_MPEG2_PIC_FLAG_INTRA_VLC`` + - 0x00000010 + - This flag affects the decoding of transform coefficient data. + * - ``V4L2_MPEG2_PIC_FLAG_ALT_SCAN`` + - 0x00000020 + - This flag affects the decoding of transform coefficient data. + * - ``V4L2_MPEG2_PIC_FLAG_REPEAT_FIRST`` + - 0x00000040 + - This flag affects the decoding process of progressive frames. + * - ``V4L2_MPEG2_PIC_FLAG_PROGRESSIVE`` + - 0x00000080 + - Indicates whether the current frame is progressive. + +.. raw:: latex + + \normalsize + +``V4L2_CID_STATELESS_MPEG2_QUANTIZATION (struct)`` + Specifies quantization matrices, in zigzag scanning order, for the + associated MPEG-2 slice data. This control is initialized by the kernel + to the matrices default values. If a bitstream transmits a user-defined + quantization matrices load, applications are expected to use this control. + Applications are also expected to set the control loading the default + values, if the quantization matrices need to be reset, for instance on a + sequence header. This process is specified by section 6.3.7. + "Quant matrix extension" of the specification. + +.. c:type:: v4l2_ctrl_mpeg2_quantization + +.. tabularcolumns:: |p{0.8cm}|p{8.0cm}|p{8.5cm}| + +.. cssclass:: longtable + +.. raw:: latex + + \small + +.. flat-table:: struct v4l2_ctrl_mpeg2_quantization + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - __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. + +.. raw:: latex + + \normalsize
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +0 -219
225 lines not on this page · raw message
Documentation/userspace-api/media/v4l/pixfmt-compressed.rst +5 -5
@@ -112,13 +112,13 @@ Compressed Formats - '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 :ref:`mem2mem` and :ref:`media-request-api`). + MPEG-2 pipeline with the :ref:`stateless_decoder`. Metadata associated with the frame to decode is required to be passed - through the ``V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE`` and - ``V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE`` controls. + through the ``V4L2_CID_STATELESS_MPEG2_SEQUENCE`` and + ``V4L2_CID_STATELESS_MPEG2_PICTURE`` controls. Quantization matrices can optionally be specified through the - ``V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION`` control. - See the :ref:`associated Codec Control IDs <v4l2-mpeg-mpeg2>`. + ``V4L2_CID_STATELESS_MPEG2_QUANTIZATION`` control. + See the :ref:`associated Codec Control IDs <v4l2-codec-stateless-mpeg2>`. Exactly one output and one capture buffer must be provided for use with this pixel format. The output buffer must contain the appropriate number of macroblocks to decode a full corresponding frame to the matching
Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst +12 -0
@@ -221,6 +221,18 @@ still cause this situation. - ``p_vp8_frame`` - A pointer to a struct :c:type:`v4l2_ctrl_vp8_frame`. Valid if this control is of type ``V4L2_CTRL_TYPE_VP8_FRAME``. + * - struct :c:type:`v4l2_ctrl_mpeg2_sequence` * + - ``p_mpeg2_sequence`` + - A pointer to a struct :c:type:`v4l2_ctrl_mpeg2_sequence`. Valid if this control is + of type ``V4L2_CTRL_TYPE_MPEG2_SEQUENCE``. + * - struct :c:type:`v4l2_ctrl_mpeg2_picture` * + - ``p_mpeg2_picture`` + - A pointer to a struct :c:type:`v4l2_ctrl_mpeg2_picture`. Valid if this control is + of type ``V4L2_CTRL_TYPE_MPEG2_PICTURE``. + * - struct :c:type:`v4l2_ctrl_mpeg2_quantization` * + - ``p_mpeg2_quantization`` + - A pointer to a struct :c:type:`v4l2_ctrl_mpeg2_quantization`. Valid if this control is + of type ``V4L2_CTRL_TYPE_MPEG2_QUANTIZATION``. * - void * - ``ptr`` - A pointer to a compound type which can be an N-dimensional array
drivers/media/v4l2-core/v4l2-ctrls.c +6 -6
@@ -973,9 +973,6 @@ const char *v4l2_ctrl_get_name(u32 id)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_BASELAYER_PRIORITY_ID :return "Base Layer Priority ID" ; -case V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE :return "MPEG-2 Sequence Header" ; -case V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE :return "MPEG-2 Picture Header" ; -case V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION :return "MPEG-2 Quantization Matrices" ;case V4L2_CID_FWHT_I_FRAME_QP :return "FWHT I-Frame QP Value" ;case V4L2_CID_FWHT_P_FRAME_QP :return "FWHT P-Frame QP Value" ;
@@ -1224,6 +1221,9 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_STATELESS_H264_DECODE_PARAMS :return "H264 Decode Parameters" ;case V4L2_CID_STATELESS_FWHT_PARAMS :return "FWHT Stateless Parameters" ;case V4L2_CID_STATELESS_VP8_FRAME :return "VP8 Frame Parameters" ; +case V4L2_CID_STATELESS_MPEG2_SEQUENCE :return "MPEG-2 Sequence Header" ; +case V4L2_CID_STATELESS_MPEG2_PICTURE :return "MPEG-2 Picture Header" ; +case V4L2_CID_STATELESS_MPEG2_QUANTIZATION :return "MPEG-2 Quantization Matrices" ;default :return NULL ; }
@@ -1470,13 +1470,13 @@ 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_SEQUENCE : +case V4L2_CID_STATELESS_MPEG2_SEQUENCE : *type =V4L2_CTRL_TYPE_MPEG2_SEQUENCE ;break ; -case V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE : +case V4L2_CID_STATELESS_MPEG2_PICTURE : *type =V4L2_CTRL_TYPE_MPEG2_PICTURE ;break ; -case V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION : +case V4L2_CID_STATELESS_MPEG2_QUANTIZATION : *type =V4L2_CTRL_TYPE_MPEG2_QUANTIZATION ;break ;case V4L2_CID_STATELESS_FWHT_PARAMS :
drivers/staging/media/hantro/hantro_drv.c +3 -3
@@ -289,17 +289,17 @@ static const struct hantro_ctrl controls[] = { }, { .codec = HANTRO_MPEG2_DECODER, .cfg = { - .id = V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE, + .id = V4L2_CID_STATELESS_MPEG2_SEQUENCE, }, }, { .codec = HANTRO_MPEG2_DECODER, .cfg = { - .id = V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE, + .id = V4L2_CID_STATELESS_MPEG2_PICTURE, }, }, { .codec = HANTRO_MPEG2_DECODER, .cfg = { - .id = V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION, + .id = V4L2_CID_STATELESS_MPEG2_QUANTIZATION, }, }, { .codec = HANTRO_VP8_DECODER,
drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c +3 -3
@@ -84,7 +84,7 @@ hantro_g1_mpeg2_dec_set_quantization(struct hantro_dev *vpu,struct v4l2_ctrl_mpeg2_quantization *quantization; quantization =hantro_get_ctrl (ctx, -V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION ); +V4L2_CID_STATELESS_MPEG2_QUANTIZATION );hantro_mpeg2_dec_copy_qtable (ctx->mpeg2_dec.qtable.cpu, quantization); vdpu_write_relaxed(vpu, ctx->mpeg2_dec.qtable.dma,
@@ -163,9 +163,9 @@ void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx)hantro_start_prepare_run (ctx); seq =hantro_get_ctrl (ctx, -V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE ); +V4L2_CID_STATELESS_MPEG2_SEQUENCE ); pic =hantro_get_ctrl (ctx, -V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE ); +V4L2_CID_STATELESS_MPEG2_PICTURE ); reg =G1_REG_DEC_AXI_RD_ID (0 ) | G1_REG_DEC_TIMEOUT_E(1) |
drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c +3 -3
@@ -86,7 +86,7 @@ rk3399_vpu_mpeg2_dec_set_quantization(struct hantro_dev *vpu,struct v4l2_ctrl_mpeg2_quantization *quantization; quantization =hantro_get_ctrl (ctx, -V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION ); +V4L2_CID_STATELESS_MPEG2_QUANTIZATION );hantro_mpeg2_dec_copy_qtable (ctx->mpeg2_dec.qtable.cpu, quantization);vdpu_write_relaxed (vpu, ctx->mpeg2_dec.qtable.dma,VDPU_REG_QTABLE_BASE );
@@ -164,9 +164,9 @@ void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx)hantro_start_prepare_run (ctx); seq =hantro_get_ctrl (ctx, -V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE ); +V4L2_CID_STATELESS_MPEG2_SEQUENCE ); pic =hantro_get_ctrl (ctx, -V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE ); +V4L2_CID_STATELESS_MPEG2_PICTURE ); reg =VDPU_REG_DEC_ADV_PRE_DIS (0 ) | VDPU_REG_DEC_SCMD_DIS(0) |
drivers/staging/media/sunxi/cedrus/cedrus.c +3 -3
@@ -31,19 +31,19 @@static const struct cedrus_control cedrus_controls[] = { { .cfg = { - .id =V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE , + .id =V4L2_CID_STATELESS_MPEG2_SEQUENCE , }, .codec =CEDRUS_CODEC_MPEG2 , }, { .cfg = { - .id =V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE , + .id =V4L2_CID_STATELESS_MPEG2_PICTURE , }, .codec =CEDRUS_CODEC_MPEG2 , }, { .cfg = { - .id =V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION , + .id =V4L2_CID_STATELESS_MPEG2_QUANTIZATION , }, .codec =CEDRUS_CODEC_MPEG2 , },
drivers/staging/media/sunxi/cedrus/cedrus_dec.c +3 -3
@@ -41,11 +41,11 @@ void cedrus_device_run(void *priv)switch (ctx->src_fmt.pixelformat) {case V4L2_PIX_FMT_MPEG2_SLICE : run.mpeg2.sequence =cedrus_find_control_data (ctx, -V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE ); +V4L2_CID_STATELESS_MPEG2_SEQUENCE ); run.mpeg2.picture =cedrus_find_control_data (ctx, -V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE ); +V4L2_CID_STATELESS_MPEG2_PICTURE ); run.mpeg2.quantization =cedrus_find_control_data (ctx, -V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION ); +V4L2_CID_STATELESS_MPEG2_QUANTIZATION );break ;case V4L2_PIX_FMT_H264_SLICE :
include/media/mpeg2-ctrls.h deleted +0 -128
128 lines not on this page · raw message
include/media/v4l2-ctrls.h +0 -1
@@ -17,7 +17,6 @@* Include the stateless codec compound control definitions. * This will move to the public headers once this API is fully stable. */ -#include <media/mpeg2-ctrls.h> #include <media/hevc-ctrls.h> /* forward references */
include/uapi/linux/v4l2-controls.h +114 -0
120 lines not on this page · raw message
include/uapi/linux/videodev2.h +3 -0
@@ -1747,6 +1747,9 @@ struct v4l2_ext_control {struct v4l2_ctrl_h264_decode_params __user *p_h264_decode_params;struct v4l2_ctrl_fwht_params __user *p_fwht_params;struct v4l2_ctrl_vp8_frame __user *p_vp8_frame; +struct v4l2_ctrl_mpeg2_sequence __user *p_mpeg2_sequence; +struct v4l2_ctrl_mpeg2_picture __user *p_mpeg2_picture; +struct v4l2_ctrl_mpeg2_quantization __user *p_mpeg2_quantization;void __user *ptr; }; } __attribute__ ((packed));
Signature · 1 line
2.30.0