History

media: uapi: Add VP9 stateless decoder controls

Add the VP9 stateless decoder controls plus the documentation that goes with it.

Andrzej Pietrasiewicz committed 4 years ago

Commit b88dbe31 parent bb91e4612 files · +1103 −0Browse files

Showing the changes to include/uapi (2 of 12 files). Show all

Unified · Split

2 files
  1. include/uapi/linux/v4l2-controls.h +284 −0
  2. include/uapi/linux/videodev2.h +6 −0
include/uapi/linux/v4l2-controls.h+284−0
@@ -2018,6 +2018,290 @@ struct v4l2_ctrl_hdr10_mastering_display { · 2017 unmodified lines
2018 __u32 min_display_mastering_luminance;2018 __u32 min_display_mastering_luminance;
2019};2019};
2020 2020
2021/* Stateless VP9 controls */
2022
2023#define V4L2_VP9_LOOP_FILTER_FLAG_DELTA_ENABLED 0x1
2024#define V4L2_VP9_LOOP_FILTER_FLAG_DELTA_UPDATE 0x2
2025
2026/**
2027 * struct v4l2_vp9_loop_filter - VP9 loop filter parameters
2028 *
2029 * @ref_deltas: contains the adjustment needed for the filter level based on the
2030 * chosen reference frame. If this syntax element is not present in the bitstream,
2031 * users should pass its last value.
2032 * @mode_deltas: contains the adjustment needed for the filter level based on the
2033 * chosen mode. If this syntax element is not present in the bitstream, users should
2034 * pass its last value.
2035 * @level: indicates the loop filter strength.
2036 * @sharpness: indicates the sharpness level.
2037 * @flags: combination of V4L2_VP9_LOOP_FILTER_FLAG_{} flags.
2038 * @reserved: padding field. Should be zeroed by applications.
2039 *
2040 * This structure contains all loop filter related parameters. See sections
2041 * '7.2.8 Loop filter semantics' of the VP9 specification for more details.
2042 */
2043struct v4l2_vp9_loop_filter {
2044 __s8 ref_deltas[4];
2045 __s8 mode_deltas[2];
2046 __u8 level;
2047 __u8 sharpness;
2048 __u8 flags;
2049 __u8 reserved[7];
2050};
2051
2052/**
2053 * struct v4l2_vp9_quantization - VP9 quantization parameters
2054 *
2055 * @base_q_idx: indicates the base frame qindex.
2056 * @delta_q_y_dc: indicates the Y DC quantizer relative to base_q_idx.
2057 * @delta_q_uv_dc: indicates the UV DC quantizer relative to base_q_idx.
2058 * @delta_q_uv_ac: indicates the UV AC quantizer relative to base_q_idx.
2059 * @reserved: padding field. Should be zeroed by applications.
2060 *
2061 * Encodes the quantization parameters. See section '7.2.9 Quantization params
2062 * syntax' of the VP9 specification for more details.
2063 */
2064struct v4l2_vp9_quantization {
2065 __u8 base_q_idx;
2066 __s8 delta_q_y_dc;
2067 __s8 delta_q_uv_dc;
2068 __s8 delta_q_uv_ac;
2069 __u8 reserved[4];
2070};
2071
2072#define V4L2_VP9_SEGMENTATION_FLAG_ENABLED 0x01
2073#define V4L2_VP9_SEGMENTATION_FLAG_UPDATE_MAP 0x02
2074#define V4L2_VP9_SEGMENTATION_FLAG_TEMPORAL_UPDATE 0x04
2075#define V4L2_VP9_SEGMENTATION_FLAG_UPDATE_DATA 0x08
2076#define V4L2_VP9_SEGMENTATION_FLAG_ABS_OR_DELTA_UPDATE 0x10
2077
2078#define V4L2_VP9_SEG_LVL_ALT_Q 0
2079#define V4L2_VP9_SEG_LVL_ALT_L 1
2080#define V4L2_VP9_SEG_LVL_REF_FRAME 2
2081#define V4L2_VP9_SEG_LVL_SKIP 3
2082#define V4L2_VP9_SEG_LVL_MAX 4
2083
2084#define V4L2_VP9_SEGMENT_FEATURE_ENABLED(id) (1 << (id))
2085#define V4L2_VP9_SEGMENT_FEATURE_ENABLED_MASK 0xf
2086
2087/**
2088 * struct v4l2_vp9_segmentation - VP9 segmentation parameters
2089 *
2090 * @feature_data: data attached to each feature. Data entry is only valid if
2091 * the feature is enabled. The array shall be indexed with segment number as
2092 * the first dimension (0..7) and one of V4L2_VP9_SEG_{} as the second dimension.
2093 * @feature_enabled: bitmask defining which features are enabled in each segment.
2094 * The value for each segment is a combination of V4L2_VP9_SEGMENT_FEATURE_ENABLED(id)
2095 * values where id is one of V4L2_VP9_SEG_LVL_{}.
2096 * @tree_probs: specifies the probability values to be used when decoding a
2097 * Segment-ID. See '5.15. Segmentation map' section of the VP9 specification
2098 * for more details.
2099 * @pred_probs: specifies the probability values to be used when decoding a
2100 * Predicted-Segment-ID. See '6.4.14. Get segment id syntax' section of :ref:`vp9`
2101 * for more details.
2102 * @flags: combination of V4L2_VP9_SEGMENTATION_FLAG_{} flags.
2103 * @reserved: padding field. Should be zeroed by applications.
2104 *
2105 * Encodes the quantization parameters. See section '7.2.10 Segmentation params syntax' of
2106 * the VP9 specification for more details.
2107 */
2108struct v4l2_vp9_segmentation {
2109 __s16 feature_data[8][4];
2110 __u8 feature_enabled[8];
2111 __u8 tree_probs[7];
2112 __u8 pred_probs[3];
2113 __u8 flags;
2114 __u8 reserved[5];
2115};
2116
2117#define V4L2_VP9_FRAME_FLAG_KEY_FRAME 0x001
2118#define V4L2_VP9_FRAME_FLAG_SHOW_FRAME 0x002
2119#define V4L2_VP9_FRAME_FLAG_ERROR_RESILIENT 0x004
2120#define V4L2_VP9_FRAME_FLAG_INTRA_ONLY 0x008
2121#define V4L2_VP9_FRAME_FLAG_ALLOW_HIGH_PREC_MV 0x010
2122#define V4L2_VP9_FRAME_FLAG_REFRESH_FRAME_CTX 0x020
2123#define V4L2_VP9_FRAME_FLAG_PARALLEL_DEC_MODE 0x040
2124#define V4L2_VP9_FRAME_FLAG_X_SUBSAMPLING 0x080
2125#define V4L2_VP9_FRAME_FLAG_Y_SUBSAMPLING 0x100
2126#define V4L2_VP9_FRAME_FLAG_COLOR_RANGE_FULL_SWING 0x200
2127
2128#define V4L2_VP9_SIGN_BIAS_LAST 0x1
2129#define V4L2_VP9_SIGN_BIAS_GOLDEN 0x2
2130#define V4L2_VP9_SIGN_BIAS_ALT 0x4
2131
2132#define V4L2_VP9_RESET_FRAME_CTX_NONE 0
2133#define V4L2_VP9_RESET_FRAME_CTX_SPEC 1
2134#define V4L2_VP9_RESET_FRAME_CTX_ALL 2
2135
2136#define V4L2_VP9_INTERP_FILTER_EIGHTTAP 0
2137#define V4L2_VP9_INTERP_FILTER_EIGHTTAP_SMOOTH 1
2138#define V4L2_VP9_INTERP_FILTER_EIGHTTAP_SHARP 2
2139#define V4L2_VP9_INTERP_FILTER_BILINEAR 3
2140#define V4L2_VP9_INTERP_FILTER_SWITCHABLE 4
2141
2142#define V4L2_VP9_REFERENCE_MODE_SINGLE_REFERENCE 0
2143#define V4L2_VP9_REFERENCE_MODE_COMPOUND_REFERENCE 1
2144#define V4L2_VP9_REFERENCE_MODE_SELECT 2
2145
2146#define V4L2_VP9_PROFILE_MAX 3
2147
2148#define V4L2_CID_STATELESS_VP9_FRAME (V4L2_CID_CODEC_STATELESS_BASE + 300)
2149/**
2150 * struct v4l2_ctrl_vp9_frame - VP9 frame decoding control
2151 *
2152 * @lf: loop filter parameters. See &v4l2_vp9_loop_filter for more details.
2153 * @quant: quantization parameters. See &v4l2_vp9_quantization for more details.
2154 * @seg: segmentation parameters. See &v4l2_vp9_segmentation for more details.
2155 * @flags: combination of V4L2_VP9_FRAME_FLAG_{} flags.
2156 * @compressed_header_size: compressed header size in bytes.
2157 * @uncompressed_header_size: uncompressed header size in bytes.
2158 * @frame_width_minus_1: add 1 to it and you'll get the frame width expressed in pixels.
2159 * @frame_height_minus_1: add 1 to it and you'll get the frame height expressed in pixels.
2160 * @render_width_minus_1: add 1 to it and you'll get the expected render width expressed in
2161 * pixels. This is not used during the decoding process but might be used by HW scalers
2162 * to prepare a frame that's ready for scanout.
2163 * @render_height_minus_1: add 1 to it and you'll get the expected render height expressed in
2164 * pixels. This is not used during the decoding process but might be used by HW scalers
2165 * to prepare a frame that's ready for scanout.
2166 * @last_frame_ts: "last" reference buffer timestamp.
2167 * The timestamp refers to the timestamp field in struct v4l2_buffer.
2168 * Use v4l2_timeval_to_ns() to convert the struct timeval to a __u64.
2169 * @golden_frame_ts: "golden" reference buffer timestamp.
2170 * The timestamp refers to the timestamp field in struct v4l2_buffer.
2171 * Use v4l2_timeval_to_ns() to convert the struct timeval to a __u64.
2172 * @alt_frame_ts: "alt" reference buffer timestamp.
2173 * The timestamp refers to the timestamp field in struct v4l2_buffer.
2174 * Use v4l2_timeval_to_ns() to convert the struct timeval to a __u64.
2175 * @ref_frame_sign_bias: a bitfield specifying whether the sign bias is set for a given
2176 * reference frame. Either of V4L2_VP9_SIGN_BIAS_{}.
2177 * @reset_frame_context: specifies whether the frame context should be reset to default values.
2178 * Either of V4L2_VP9_RESET_FRAME_CTX_{}.
2179 * @frame_context_idx: frame context that should be used/updated.
2180 * @profile: VP9 profile. Can be 0, 1, 2 or 3.
2181 * @bit_depth: bits per components. Can be 8, 10 or 12. Note that not all profiles support
2182 * 10 and/or 12 bits depths.
2183 * @interpolation_filter: specifies the filter selection used for performing inter prediction.
2184 * Set to one of V4L2_VP9_INTERP_FILTER_{}.
2185 * @tile_cols_log2: specifies the base 2 logarithm of the width of each tile (where the width
2186 * is measured in units of 8x8 blocks). Shall be less than or equal to 6.
2187 * @tile_rows_log2: specifies the base 2 logarithm of the height of each tile (where the height
2188 * is measured in units of 8x8 blocks).
2189 * @reference_mode: specifies the type of inter prediction to be used.
2190 * Set to one of V4L2_VP9_REFERENCE_MODE_{}.
2191 * @reserved: padding field. Should be zeroed by applications.
2192 */
2193struct v4l2_ctrl_vp9_frame {
2194 struct v4l2_vp9_loop_filter lf;
2195 struct v4l2_vp9_quantization quant;
2196 struct v4l2_vp9_segmentation seg;
2197 __u32 flags;
2198 __u16 compressed_header_size;
2199 __u16 uncompressed_header_size;
2200 __u16 frame_width_minus_1;
2201 __u16 frame_height_minus_1;
2202 __u16 render_width_minus_1;
2203 __u16 render_height_minus_1;
2204 __u64 last_frame_ts;
2205 __u64 golden_frame_ts;
2206 __u64 alt_frame_ts;
2207 __u8 ref_frame_sign_bias;
2208 __u8 reset_frame_context;
2209 __u8 frame_context_idx;
2210 __u8 profile;
2211 __u8 bit_depth;
2212 __u8 interpolation_filter;
2213 __u8 tile_cols_log2;
2214 __u8 tile_rows_log2;
2215 __u8 reference_mode;
2216 __u8 reserved[7];
2217};
2218
2219#define V4L2_VP9_NUM_FRAME_CTX 4
2220
2221/**
2222 * struct v4l2_vp9_mv_probs - VP9 Motion vector probability updates
2223 * @joint: motion vector joint probability updates.
2224 * @sign: motion vector sign probability updates.
2225 * @classes: motion vector class probability updates.
2226 * @class0_bit: motion vector class0 bit probability updates.
2227 * @bits: motion vector bits probability updates.
2228 * @class0_fr: motion vector class0 fractional bit probability updates.
2229 * @fr: motion vector fractional bit probability updates.
2230 * @class0_hp: motion vector class0 high precision fractional bit probability updates.
2231 * @hp: motion vector high precision fractional bit probability updates.
2232 *
2233 * This structure contains new values of motion vector probabilities.
2234 * A value of zero in an array element means there is no update of the relevant probability.
2235 * See `struct v4l2_vp9_prob_updates` for details.
2236 */
2237struct v4l2_vp9_mv_probs {
2238 __u8 joint[3];
2239 __u8 sign[2];
2240 __u8 classes[2][10];
2241 __u8 class0_bit[2];
2242 __u8 bits[2][10];
2243 __u8 class0_fr[2][2][3];
2244 __u8 fr[2][3];
2245 __u8 class0_hp[2];
2246 __u8 hp[2];
2247};
2248
2249#define V4L2_CID_STATELESS_VP9_COMPRESSED_HDR (V4L2_CID_CODEC_STATELESS_BASE + 301)
2250
2251#define V4L2_VP9_TX_MODE_ONLY_4X4 0
2252#define V4L2_VP9_TX_MODE_ALLOW_8X8 1
2253#define V4L2_VP9_TX_MODE_ALLOW_16X16 2
2254#define V4L2_VP9_TX_MODE_ALLOW_32X32 3
2255#define V4L2_VP9_TX_MODE_SELECT 4
2256
2257/**
2258 * struct v4l2_ctrl_vp9_compressed_hdr - VP9 probability updates control
2259 * @tx_mode: specifies the TX mode. Set to one of V4L2_VP9_TX_MODE_{}.
2260 * @tx8: TX 8x8 probability updates.
2261 * @tx16: TX 16x16 probability updates.
2262 * @tx32: TX 32x32 probability updates.
2263 * @coef: coefficient probability updates.
2264 * @skip: skip probability updates.
2265 * @inter_mode: inter mode probability updates.
2266 * @interp_filter: interpolation filter probability updates.
2267 * @is_inter: is inter-block probability updates.
2268 * @comp_mode: compound prediction mode probability updates.
2269 * @single_ref: single ref probability updates.
2270 * @comp_ref: compound ref probability updates.
2271 * @y_mode: Y prediction mode probability updates.
2272 * @uv_mode: UV prediction mode probability updates.
2273 * @partition: partition probability updates.
2274 * @mv: motion vector probability updates.
2275 *
2276 * This structure holds the probabilities update as parsed in the compressed
2277 * header (Spec 6.3). These values represent the value of probability update after
2278 * being translated with inv_map_table[] (see 6.3.5). A value of zero in an array element
2279 * means that there is no update of the relevant probability.
2280 *
2281 * This control is optional and needs to be used when dealing with the hardware which is
2282 * not capable of parsing the compressed header itself. Only drivers which need it will
2283 * implement it.
2284 */
2285struct v4l2_ctrl_vp9_compressed_hdr {
2286 __u8 tx_mode;
2287 __u8 tx8[2][1];
2288 __u8 tx16[2][2];
2289 __u8 tx32[2][3];
2290 __u8 coef[4][2][2][6][6][3];
2291 __u8 skip[3];
2292 __u8 inter_mode[7][3];
2293 __u8 interp_filter[4][2];
2294 __u8 is_inter[4];
2295 __u8 comp_mode[5];
2296 __u8 single_ref[5][2];
2297 __u8 comp_ref[5];
2298 __u8 y_mode[4][9];
2299 __u8 uv_mode[10][9];
2300 __u8 partition[16][3];
2301
2302 struct v4l2_vp9_mv_probs mv;
2303};
2304
2021/* MPEG-compression definitions kept for backwards compatibility */2305/* MPEG-compression definitions kept for backwards compatibility */
2022#ifndef __KERNEL__2306#ifndef __KERNEL__
2023#define V4L2_CTRL_CLASS_MPEG V4L2_CTRL_CLASS_CODEC2307#define V4L2_CTRL_CLASS_MPEG V4L2_CTRL_CLASS_CODEC
include/uapi/linux/videodev2.h+6−0
@@ -703,6 +703,7 @@ struct v4l2_pix_format { · 702 unmodified lines
703#define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0') /* VP8 */703#define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0') /* VP8 */
704#define V4L2_PIX_FMT_VP8_FRAME v4l2_fourcc('V', 'P', '8', 'F') /* VP8 parsed frame */704#define V4L2_PIX_FMT_VP8_FRAME v4l2_fourcc('V', 'P', '8', 'F') /* VP8 parsed frame */
705#define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0') /* VP9 */705#define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0') /* VP9 */
706#define V4L2_PIX_FMT_VP9_FRAME v4l2_fourcc('V', 'P', '9', 'F') /* VP9 parsed frame */
706#define V4L2_PIX_FMT_HEVC v4l2_fourcc('H', 'E', 'V', 'C') /* HEVC aka H.265 */707#define V4L2_PIX_FMT_HEVC v4l2_fourcc('H', 'E', 'V', 'C') /* HEVC aka H.265 */
707#define V4L2_PIX_FMT_FWHT v4l2_fourcc('F', 'W', 'H', 'T') /* Fast Walsh Hadamard Transform (vicodec) */708#define V4L2_PIX_FMT_FWHT v4l2_fourcc('F', 'W', 'H', 'T') /* Fast Walsh Hadamard Transform (vicodec) */
708#define V4L2_PIX_FMT_FWHT_STATELESS v4l2_fourcc('S', 'F', 'W', 'H') /* Stateless FWHT (vicodec) */709#define V4L2_PIX_FMT_FWHT_STATELESS v4l2_fourcc('S', 'F', 'W', 'H') /* Stateless FWHT (vicodec) */
@@ -1759,6 +1760,8 @@ struct v4l2_ext_control { · 1050 unmodified lines
1759 struct v4l2_ctrl_mpeg2_sequence __user *p_mpeg2_sequence;1760 struct v4l2_ctrl_mpeg2_sequence __user *p_mpeg2_sequence;
1760 struct v4l2_ctrl_mpeg2_picture __user *p_mpeg2_picture;1761 struct v4l2_ctrl_mpeg2_picture __user *p_mpeg2_picture;
1761 struct v4l2_ctrl_mpeg2_quantisation __user *p_mpeg2_quantisation;1762 struct v4l2_ctrl_mpeg2_quantisation __user *p_mpeg2_quantisation;
1763 struct v4l2_ctrl_vp9_compressed_hdr __user *p_vp9_compressed_hdr_probs;
1764 struct v4l2_ctrl_vp9_frame __user *p_vp9_frame;
1762 void __user *ptr;1765 void __user *ptr;
1763 };1766 };
1764} __attribute__ ((packed));1767} __attribute__ ((packed));
@@ -1823,6 +1826,9 @@ enum v4l2_ctrl_type { · 58 unmodified lines
1823 V4L2_CTRL_TYPE_MPEG2_QUANTISATION = 0x0250,1826 V4L2_CTRL_TYPE_MPEG2_QUANTISATION = 0x0250,
1824 V4L2_CTRL_TYPE_MPEG2_SEQUENCE = 0x0251,1827 V4L2_CTRL_TYPE_MPEG2_SEQUENCE = 0x0251,
1825 V4L2_CTRL_TYPE_MPEG2_PICTURE = 0x0252,1828 V4L2_CTRL_TYPE_MPEG2_PICTURE = 0x0252,
1829
1830 V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR = 0x0260,
1831 V4L2_CTRL_TYPE_VP9_FRAME = 0x0261,
1826};1832};
1827 1833
1828/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */1834/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */