]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
media: uapi: h264: Increase size of DPB entry pic_num
authorEzequiel Garcia <ezequiel@collabora.com>
Tue, 25 Aug 2020 03:52:33 +0000 (05:52 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 1 Sep 2020 12:13:28 +0000 (14:13 +0200)
DPB entry PicNum maximum value is 2*MaxFrameNum for interlaced
content (field_pic_flag=1).

As specified, MaxFrameNum is 2^(log2_max_frame_num_minus4 + 4)
and log2_max_frame_num_minus4 is in the range of 0 to 12,
which means pic_num should be a 32-bit field.

The v4l2_h264_dpb_entry struct needs to be padded to avoid a hole,
which might be also useful to allow future uAPI extensions.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Tested-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
drivers/media/v4l2-core/v4l2-ctrls.c
include/media/h264-ctrls.h
include/media/v4l2-h264.h

index 49febae8fd0f42e2d1bc9aad385323cd56e59393..3808c46718ad6500efb8704473c6226c07a19016 100644 (file)
@@ -2051,15 +2051,18 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type -
         ``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.
-    * - __u16
-      - ``frame_num``
+    * - __u32
+      - ``pic_num``
       -
     * - __u16
-      - ``pic_num``
+      - ``frame_num``
       -
     * - __u8
       - ``fields``
       - Specifies how the DPB entry is referenced. See :ref:`Reference Fields <h264_ref_fields>`
+    * - __u8
+      - ``reserved[5]``
+      - Applications and drivers must set this to zero.
     * - __s32
       - ``top_field_order_cnt``
       -
index 76c8dc8fb31c401240808b4755bf00264069a3d8..b9457789fa5557bf73c9135ab9f71b901b615a60 100644 (file)
@@ -1725,6 +1725,8 @@ static void std_log(const struct v4l2_ctrl *ctrl)
 
 #define zero_padding(s) \
        memset(&(s).padding, 0, sizeof((s).padding))
+#define zero_reserved(s) \
+       memset(&(s).reserved, 0, sizeof((s).reserved))
 
 /*
  * Compound controls validation requires setting unused fields/flags to zero
@@ -1735,6 +1737,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
 {
        struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params;
        struct v4l2_ctrl_vp8_frame_header *p_vp8_frame_header;
+       struct v4l2_ctrl_h264_decode_params *p_h264_dec_params;
        struct v4l2_ctrl_hevc_sps *p_hevc_sps;
        struct v4l2_ctrl_hevc_pps *p_hevc_pps;
        struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
@@ -1796,7 +1799,17 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
        case V4L2_CTRL_TYPE_H264_SCALING_MATRIX:
        case V4L2_CTRL_TYPE_H264_PRED_WEIGHTS:
        case V4L2_CTRL_TYPE_H264_SLICE_PARAMS:
+               break;
+
        case V4L2_CTRL_TYPE_H264_DECODE_PARAMS:
+               p_h264_dec_params = p;
+
+               for (i = 0; i < V4L2_H264_NUM_DPB_ENTRIES; i++) {
+                       struct v4l2_h264_dpb_entry *dpb_entry =
+                               &p_h264_dec_params->dpb[i];
+
+                       zero_reserved(*dpb_entry);
+               }
                break;
 
        case V4L2_CTRL_TYPE_VP8_FRAME_HEADER:
index 0529e75cce5f7722abe02464a3be6534927c77e1..91f6f0d43e116bf6cabba092e4a4f42a4ecfc4bc 100644 (file)
@@ -213,9 +213,10 @@ struct v4l2_ctrl_h264_slice_params {
 
 struct v4l2_h264_dpb_entry {
        __u64 reference_ts;
+       __u32 pic_num;
        __u16 frame_num;
-       __u16 pic_num;
        __u8 fields;
+       __u8 reserved[5];
        /* Note that field is indicated by v4l2_buffer.field */
        __s32 top_field_order_cnt;
        __s32 bottom_field_order_cnt;
index bc9ebb560ccfdb60b4ca658027162e62592a6b50..1a5f26fc2a9a2f533ce4b5d1473d7ad20fbef821 100644 (file)
@@ -33,7 +33,7 @@ struct v4l2_h264_reflist_builder {
        struct {
                s32 pic_order_count;
                int frame_num;
-               u16 pic_num;
+               u32 pic_num;
                u16 longterm : 1;
        } refs[V4L2_H264_NUM_DPB_ENTRIES];
        s32 cur_pic_order_count;