- 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
 
        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";
        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;
        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;
        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;
 
                .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,
 
        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 {
 
                        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:
 
 static void cedrus_write_pred_weight_table(struct cedrus_ctx *ctx,
                                           struct cedrus_run *run)
 {
-       const struct v4l2_ctrl_h264_slice_params *slice =
-               run->h264.slice_params;
-       const struct v4l2_h264_pred_weight_table *pred_weight =
-               &slice->pred_weight_table;
+       const struct v4l2_ctrl_h264_pred_weights *pred_weight =
+               run->h264.pred_weights;
        struct cedrus_dev *dev = ctx->dev;
        int i, j, k;
 
 
        cedrus_skip_bits(dev, slice->header_bit_size);
 
-       if (((pps->flags & V4L2_H264_PPS_FLAG_WEIGHTED_PRED) &&
-            (slice->slice_type == V4L2_H264_SLICE_TYPE_P ||
-             slice->slice_type == V4L2_H264_SLICE_TYPE_SP)) ||
-           (pps->weighted_bipred_idc == 1 &&
-            slice->slice_type == V4L2_H264_SLICE_TYPE_B))
+       if (V4L2_H264_CTRL_PRED_WEIGHTS_REQUIRED(pps, slice))
                cedrus_write_pred_weight_table(ctx, run);
 
        if ((slice->slice_type == V4L2_H264_SLICE_TYPE_P) ||
 
 #define V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS (V4L2_CID_MPEG_BASE+1004)
 #define V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE   (V4L2_CID_MPEG_BASE+1005)
 #define V4L2_CID_MPEG_VIDEO_H264_START_CODE    (V4L2_CID_MPEG_BASE+1006)
+#define V4L2_CID_MPEG_VIDEO_H264_PRED_WEIGHTS  (V4L2_CID_MPEG_BASE+1007)
 
 /* enum v4l2_ctrl_type type values */
 #define V4L2_CTRL_TYPE_H264_SPS                        0x0110
 #define V4L2_CTRL_TYPE_H264_SCALING_MATRIX     0x0112
 #define V4L2_CTRL_TYPE_H264_SLICE_PARAMS       0x0113
 #define V4L2_CTRL_TYPE_H264_DECODE_PARAMS      0x0114
+#define V4L2_CTRL_TYPE_H264_PRED_WEIGHTS       0x0115
 
 enum v4l2_mpeg_video_h264_decode_mode {
        V4L2_MPEG_VIDEO_H264_DECODE_MODE_SLICE_BASED,
        __s16 chroma_offset[32][2];
 };
 
-struct v4l2_h264_pred_weight_table {
+#define V4L2_H264_CTRL_PRED_WEIGHTS_REQUIRED(pps, slice) \
+       ((((pps)->flags & V4L2_H264_PPS_FLAG_WEIGHTED_PRED) && \
+        ((slice)->slice_type == V4L2_H264_SLICE_TYPE_P || \
+         (slice)->slice_type == V4L2_H264_SLICE_TYPE_SP)) || \
+        ((pps)->weighted_bipred_idc == 1 && \
+         (slice)->slice_type == V4L2_H264_SLICE_TYPE_B))
+
+struct v4l2_ctrl_h264_pred_weights {
        __u16 luma_log2_weight_denom;
        __u16 chroma_log2_weight_denom;
        struct v4l2_h264_weight_factors weight_factors[2];
        __s32 delta_pic_order_cnt0;
        __s32 delta_pic_order_cnt1;
 
-       struct v4l2_h264_pred_weight_table pred_weight_table;
        /* Size in bits of dec_ref_pic_marking() syntax element. */
        __u32 dec_ref_pic_marking_bit_size;
        /* Size in bits of pic order count syntax. */
 
  * @p_h264_scaling_matrix:     Pointer to a struct v4l2_ctrl_h264_scaling_matrix.
  * @p_h264_slice_params:       Pointer to a struct v4l2_ctrl_h264_slice_params.
  * @p_h264_decode_params:      Pointer to a struct v4l2_ctrl_h264_decode_params.
+ * @p_h264_pred_weights:       Pointer to a struct v4l2_ctrl_h264_pred_weights.
  * @p_vp8_frame_header:                Pointer to a VP8 frame header structure.
  * @p_hevc_sps:                        Pointer to an HEVC sequence parameter set structure.
  * @p_hevc_pps:                        Pointer to an HEVC picture parameter set structure.
        struct v4l2_ctrl_h264_scaling_matrix *p_h264_scaling_matrix;
        struct v4l2_ctrl_h264_slice_params *p_h264_slice_params;
        struct v4l2_ctrl_h264_decode_params *p_h264_decode_params;
+       struct v4l2_ctrl_h264_pred_weights *p_h264_pred_weights;
        struct v4l2_ctrl_vp8_frame_header *p_vp8_frame_header;
        struct v4l2_ctrl_hevc_sps *p_hevc_sps;
        struct v4l2_ctrl_hevc_pps *p_hevc_pps;