Commit eb44c6c9 authored by Ezequiel Garcia's avatar Ezequiel Garcia Committed by Mauro Carvalho Chehab
Browse files

media: uapi: h264: Split prediction weight parameters



The prediction weight parameters are only required under
certain conditions, which depend on slice header parameters.

As specified in section 7.3.3 Slice header syntax, the prediction
weight table is present if:

((weighted_pred_flag && (slice_type == P || slice_type == SP)) || \
(weighted_bipred_idc == 1 && slice_type == B))

Given its size, it makes sense to move this table to its control,
so applications can avoid passing it if the slice doesn't specify it.

Before this change struct v4l2_ctrl_h264_slice_params was 960 bytes.
With this change, it's 188 bytes and struct v4l2_ctrl_h264_pred_weight
is 772 bytes.

Signed-off-by: default avatarEzequiel Garcia <ezequiel@collabora.com>
Tested-by: default avatarJonas Karlman <jonas@kwiboo.se>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent cefdf805
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -1879,18 +1879,23 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type -
      - 0x00000008
      -

``Prediction Weight Table``
``V4L2_CID_MPEG_VIDEO_H264_PRED_WEIGHTS (struct)``
    Prediction weight table defined according to :ref:`h264`,
    section 7.4.3.2 "Prediction Weight Table Semantics".
    The prediction weight table must be passed by applications
    under the conditions explained in section 7.3.3 "Slice header
    syntax".

    The bitstream parameters are defined according to :ref:`h264`,
    section 7.4.3.2 "Prediction Weight Table Semantics". For further
    documentation, refer to the above specification, unless there is
    an explicit comment stating otherwise.
    .. note::

       This compound control is not yet part of the public kernel API and
       it is expected to change.

.. c:type:: v4l2_h264_pred_weight_table
.. c:type:: v4l2_ctrl_h264_pred_weights

.. cssclass:: longtable

.. flat-table:: struct v4l2_h264_pred_weight_table
.. flat-table:: struct v4l2_ctrl_h264_pred_weights
    :header-rows:  0
    :stub-columns: 0
    :widths:       1 1 2
+8 −0
Original line number Diff line number Diff line
@@ -897,6 +897,7 @@ const char *v4l2_ctrl_get_name(u32 id)
	case V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS:		return "H264 Decode Parameters";
	case V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE:		return "H264 Decode Mode";
	case V4L2_CID_MPEG_VIDEO_H264_START_CODE:		return "H264 Start Code";
	case V4L2_CID_MPEG_VIDEO_H264_PRED_WEIGHTS:		return "H264 Prediction Weight Table";
	case V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL:			return "MPEG2 Level";
	case V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE:			return "MPEG2 Profile";
	case V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP:		return "MPEG4 I-Frame QP Value";
@@ -1412,6 +1413,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
	case V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS:
		*type = V4L2_CTRL_TYPE_H264_DECODE_PARAMS;
		break;
	case V4L2_CID_MPEG_VIDEO_H264_PRED_WEIGHTS:
		*type = V4L2_CTRL_TYPE_H264_PRED_WEIGHTS;
		break;
	case V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER:
		*type = V4L2_CTRL_TYPE_VP8_FRAME_HEADER;
		break;
@@ -1790,6 +1794,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
	case V4L2_CTRL_TYPE_H264_SPS:
	case V4L2_CTRL_TYPE_H264_PPS:
	case V4L2_CTRL_TYPE_H264_SCALING_MATRIX:
	case V4L2_CTRL_TYPE_H264_PRED_WEIGHTS:
	case V4L2_CTRL_TYPE_H264_SLICE_PARAMS:
	case V4L2_CTRL_TYPE_H264_DECODE_PARAMS:
		break;
@@ -2553,6 +2558,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
	case V4L2_CTRL_TYPE_H264_DECODE_PARAMS:
		elem_size = sizeof(struct v4l2_ctrl_h264_decode_params);
		break;
	case V4L2_CTRL_TYPE_H264_PRED_WEIGHTS:
		elem_size = sizeof(struct v4l2_ctrl_h264_pred_weights);
		break;
	case V4L2_CTRL_TYPE_VP8_FRAME_HEADER:
		elem_size = sizeof(struct v4l2_ctrl_vp8_frame_header);
		break;
+7 −0
Original line number Diff line number Diff line
@@ -78,6 +78,13 @@ static const struct cedrus_control cedrus_controls[] = {
		.codec		= CEDRUS_CODEC_H264,
		.required	= true,
	},
	{
		.cfg = {
			.id	= V4L2_CID_MPEG_VIDEO_H264_PRED_WEIGHTS,
		},
		.codec		= CEDRUS_CODEC_H264,
		.required	= false,
	},
	{
		.cfg = {
			.id	= V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE,
+1 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ struct cedrus_h264_run {
	const struct v4l2_ctrl_h264_scaling_matrix	*scaling_matrix;
	const struct v4l2_ctrl_h264_slice_params	*slice_params;
	const struct v4l2_ctrl_h264_sps			*sps;
	const struct v4l2_ctrl_h264_pred_weights	*pred_weights;
};

struct cedrus_mpeg2_run {
+2 −0
Original line number Diff line number Diff line
@@ -57,6 +57,8 @@ void cedrus_device_run(void *priv)
			V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS);
		run.h264.sps = cedrus_find_control_data(ctx,
			V4L2_CID_MPEG_VIDEO_H264_SPS);
		run.h264.pred_weights = cedrus_find_control_data(ctx,
			V4L2_CID_MPEG_VIDEO_H264_PRED_WEIGHTS);
		break;

	case V4L2_PIX_FMT_HEVC_SLICE:
Loading