| From 2ee7da4dbe934f60eccf880e5b59ac9c82a23b1c Mon Sep 17 00:00:00 2001 |
| From: Pawel Osciak <posciak@chromium.org> |
| Date: Mon, 11 Jul 2016 18:25:17 +0900 |
| Subject: [PATCH] CHROMIUM: v4l: Add VP9 low-level decoder API controls. |
| |
| Signed-off-by: Pawel Osciak <posciak@chromium.org> |
| |
| [fbuergisser@chromium.org: original patch modified as h264 headers were moved |
| to other header files which cause a failure when applying the original patch. |
| Keeping part of the original patch for context.] |
| --- |
| include/uapi/linux/v4l2-controls.h | 147 +++++++++++++++++++++++++++++ |
| include/uapi/linux/videodev2.h | 7 ++ |
| 2 files changed, 154 insertions(+) |
| |
| diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h |
| index a692623e0236..3e7bb32fd3e8 100644 |
| --- a/include/uapi/linux/v4l2-controls.h |
| +++ b/include/uapi/linux/v4l2-controls.h |
| @@ -589,6 +589,10 @@ enum v4l2_vp8_golden_frame_sel { |
| #define V4L2_CID_MPEG_VIDEO_VPX_P_FRAME_QP (V4L2_CID_MPEG_BASE+510) |
| #define V4L2_CID_MPEG_VIDEO_VPX_PROFILE (V4L2_CID_MPEG_BASE+511) |
| |
| +#define V4L2_CID_MPEG_VIDEO_VP9_FRAME_HDR (V4L2_CID_MPEG_BASE+591) |
| +#define V4L2_CID_MPEG_VIDEO_VP9_DECODE_PARAM (V4L2_CID_MPEG_BASE+592) |
| +#define V4L2_CID_MPEG_VIDEO_VP9_ENTROPY (V4L2_CID_MPEG_BASE+593) |
| + |
| /* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */ |
| #define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000) |
| #define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+0) |
| @@ -970,6 +974,149 @@ enum v4l2_deemphasis { |
| #define V4L2_CID_RF_TUNER_PLL_LOCK (V4L2_CID_RF_TUNER_CLASS_BASE + 91) |
| |
| |
| +#define V4L2_VP9_SGMNT_PARAM_FLAG_ENABLED 0x01 |
| +#define V4L2_VP9_SGMNT_PARAM_FLAG_UPDATE_MAP 0x02 |
| +#define V4L2_VP9_SGMNT_PARAM_FLAG_TEMPORAL_UPDATE 0x04 |
| +#define V4L2_VP9_SGMNT_PARAM_FLAG_UPDATE_DATA 0x08 |
| +#define V4L2_VP9_SGMNT_PARAM_FLAG_ABS_OR_DELTA_UPDATE 0x10 |
| +struct v4l2_vp9_segmentation_params { |
| + __u8 tree_probs[7]; |
| + __u8 pred_probs[3]; |
| + __u8 feature_enabled[8][4]; |
| + __s16 feature_data[8][4]; |
| + |
| + __u8 flags; |
| +}; |
| + |
| +#define V4L2_VP9_LOOP_FLTR_FLAG_DELTA_ENABLED 0x01 |
| +#define V4L2_VP9_LOOP_FLTR_FLAG_DELTA_UPDATE 0x02 |
| +struct v4l2_vp9_loop_filter_params { |
| + __u8 level; |
| + __u8 sharpness; |
| + __s8 deltas[4]; |
| + __s8 mode_deltas[2]; |
| + __u8 lvl_lookup[8][4][2]; |
| + |
| + __u8 flags; |
| +}; |
| + |
| +#define V4L2_VP9_QUANT_PARAMS_FLAG_LOSSLESS 0x01 |
| +struct v4l2_vp9_quantization_params { |
| + __u8 base_q_idx; |
| + __s8 delta_q_y_dc; |
| + __s8 delta_q_uv_dc; |
| + __s8 delta_q_uv_ac; |
| + |
| + __u8 flags; |
| +}; |
| + |
| +#define V4L2_VP9_FRAME_HDR_FLAG_SHOW_FRAME 0x01 |
| +/* Error resilient mode enabled flag */ |
| +#define V4L2_VP9_FRAME_HDR_FLAG_ERR_RES 0x02 |
| +#define V4L2_VP9_FRAME_HDR_FLAG_FRAME_INTRA 0x04 |
| +#define V4L2_VP9_FRAME_HDR_ALLOW_HIGH_PREC_MV 0x08 |
| +#define V4L2_VP9_FRAME_HDR_REFRESH_FRAME_CTX 0x10 |
| +#define V4L2_VP9_FRAME_HDR_PARALLEL_DEC_MODE 0x20 |
| +struct v4l2_ctrl_vp9_frame_hdr { |
| + __u8 profile; |
| + /* 0: keyframe, 1: non-keyframe */ |
| + __u8 frame_type; |
| + |
| + __u8 bit_depth; |
| + __u8 color_space; |
| + __u8 color_range; |
| + __u8 subsampling_x; |
| + __u8 subsampling_y; |
| + |
| + __u32 frame_width; |
| + __u32 frame_height; |
| + __u32 render_width; |
| + __u32 render_height; |
| + |
| + __u8 reset_frame_context; |
| + |
| + __u8 interpolation_filter; |
| + __u8 frame_context_idx; |
| + |
| + struct v4l2_vp9_loop_filter_params lf_params; |
| + struct v4l2_vp9_quantization_params quant_params; |
| + struct v4l2_vp9_segmentation_params sgmnt_params; |
| + |
| + __u8 tile_cols_log2; |
| + __u8 tile_rows_log2; |
| + |
| + __u16 header_size_in_bytes; |
| + |
| + __u8 flags; |
| +}; |
| + |
| +struct v4l2_vp9_reference_frame { |
| + /* v4l2_buffer index */ |
| + __u32 buf_index; |
| + |
| + __u32 frame_width; |
| + __u32 frame_height; |
| + __u8 bit_depth; |
| + __u8 subsampling_x; |
| + __u8 subsampling_y; |
| +}; |
| + |
| +struct v4l2_ctrl_vp9_decode_param { |
| + /* v4l2_buffer index for all reference frames (frame slots). */ |
| + __u32 ref_frames[8]; |
| + |
| + /* Active reference frames, [0]: last, [1]: golden, [2]: altref */ |
| + struct v4l2_vp9_reference_frame active_ref_frames[3]; |
| +}; |
| + |
| +struct v4l2_vp9_entropy_ctx { |
| + __u8 tx_probs_8x8[2][1]; |
| + __u8 tx_probs_16x16[2][2]; |
| + __u8 tx_probs_32x32[2][3]; |
| + |
| + __u8 coef_probs[4][2][2][6][6][3]; |
| + __u8 skip_prob[3]; |
| + __u8 inter_mode_probs[7][3]; |
| + __u8 interp_filter_probs[4][2]; |
| + __u8 is_inter_prob[4]; |
| + |
| + __u8 comp_mode_prob[5]; |
| + __u8 single_ref_prob[5][2]; |
| + __u8 comp_ref_prob[5]; |
| + |
| + __u8 y_mode_probs[4][9]; |
| + __u8 uv_mode_probs[10][9]; |
| + |
| + __u8 partition_probs[16][3]; |
| + |
| + __u8 mv_joint_probs[3]; |
| + __u8 mv_sign_prob[2]; |
| + __u8 mv_class_probs[2][10]; |
| + __u8 mv_class0_bit_prob[2]; |
| + __u8 mv_bits_prob[2][10]; |
| + __u8 mv_class0_fr_probs[2][2][3]; |
| + __u8 mv_fr_probs[2][3]; |
| + __u8 mv_class0_hp_prob[2]; |
| + __u8 mv_hp_prob[2]; |
| +}; |
| + |
| +/* Entropy context state for current frame (frame_context_idx). */ |
| +struct v4l2_ctrl_vp9_entropy { |
| + __u8 tx_mode; |
| + __u8 reference_mode; |
| + |
| + /* Entropy context after load_probs2(). */ |
| + struct v4l2_vp9_entropy_ctx initial_entropy_ctx; |
| + |
| + /* |
| + * Entropy context for the current decoding state: when passed to the |
| + * driver, contains the state of initial_entropy_ctx after parsing the |
| + * compressed header. After decoding is done (after vb2_buffer_done() is |
| + * called on the associated buffer), state as after refresh_probs(). |
| + */ |
| + struct v4l2_vp9_entropy_ctx current_entropy_ctx; |
| +}; |
| + |
| /* Detection-class control IDs defined by V4L2 */ |
| #define V4L2_CID_DETECT_CLASS_BASE (V4L2_CTRL_CLASS_DETECT | 0x900) |
| #define V4L2_CID_DETECT_CLASS (V4L2_CTRL_CLASS_DETECT | 1) |
| diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h |
| index 41e080891916..17332b06ef77 100644 |
| --- a/include/uapi/linux/videodev2.h |
| +++ b/include/uapi/linux/videodev2.h |
| @@ -639,6 +639,7 @@ struct v4l2_pix_format { |
| #define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0') /* VP8 */ |
| #define V4L2_PIX_FMT_VP8_FRAME v4l2_fourcc('V', 'P', '8', 'F') /* VP8 parsed frames */ |
| #define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0') /* VP9 */ |
| +#define V4L2_PIX_FMT_VP9_FRAME v4l2_fourcc('V', 'P', '9', 'F') /* VP9 parsed frames */ |
| |
| /* Vendor-specific formats */ |
| #define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */ |
| @@ -1576,6 +1577,9 @@ struct v4l2_ext_control { |
| __u8 __user *p_u8; |
| __u16 __user *p_u16; |
| __u32 __user *p_u32; |
| + struct v4l2_ctrl_vp9_frame_hdr __user *p_vp9_frame_hdr; |
| + struct v4l2_ctrl_vp9_decode_param __user *p_vp9_decode_param; |
| + struct v4l2_ctrl_vp9_entropy __user *p_vp9_entropy; |
| void __user *ptr; |
| }; |
| } __attribute__ ((packed)); |
| @@ -1620,6 +1624,9 @@ enum v4l2_ctrl_type { |
| V4L2_CTRL_TYPE_U8 = 0x0100, |
| V4L2_CTRL_TYPE_U16 = 0x0101, |
| V4L2_CTRL_TYPE_U32 = 0x0102, |
| + V4L2_CTRL_TYPE_VP9_FRAME_HDR = 0x109, |
| + V4L2_CTRL_TYPE_VP9_DECODE_PARAM = 0x110, |
| + V4L2_CTRL_TYPE_VP9_ENTROPY = 0x111, |
| |
| V4L2_CTRL_TYPE_PRIVATE = 0xffff, |
| }; |
| -- |
| 2.22.0.709.g102302147b-goog |
| |