![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-or-later */ 0002 /* 0003 * Helper functions for vp9 codecs. 0004 * 0005 * Copyright (c) 2021 Collabora, Ltd. 0006 * 0007 * Author: Andrzej Pietrasiewicz <andrzej.p@collabora.com> 0008 */ 0009 0010 #ifndef _MEDIA_V4L2_VP9_H 0011 #define _MEDIA_V4L2_VP9_H 0012 0013 #include <media/v4l2-ctrls.h> 0014 0015 /** 0016 * struct v4l2_vp9_frame_mv_context - motion vector-related probabilities 0017 * 0018 * @joint: motion vector joint probabilities. 0019 * @sign: motion vector sign probabilities. 0020 * @classes: motion vector class probabilities. 0021 * @class0_bit: motion vector class0 bit probabilities. 0022 * @bits: motion vector bits probabilities. 0023 * @class0_fr: motion vector class0 fractional bit probabilities. 0024 * @fr: motion vector fractional bit probabilities. 0025 * @class0_hp: motion vector class0 high precision fractional bit probabilities. 0026 * @hp: motion vector high precision fractional bit probabilities. 0027 * 0028 * A member of v4l2_vp9_frame_context. 0029 */ 0030 struct v4l2_vp9_frame_mv_context { 0031 u8 joint[3]; 0032 u8 sign[2]; 0033 u8 classes[2][10]; 0034 u8 class0_bit[2]; 0035 u8 bits[2][10]; 0036 u8 class0_fr[2][2][3]; 0037 u8 fr[2][3]; 0038 u8 class0_hp[2]; 0039 u8 hp[2]; 0040 }; 0041 0042 /** 0043 * struct v4l2_vp9_frame_context - frame probabilities, including motion-vector related 0044 * 0045 * @tx8: TX 8x8 probabilities. 0046 * @tx16: TX 16x16 probabilities. 0047 * @tx32: TX 32x32 probabilities. 0048 * @coef: coefficient probabilities. 0049 * @skip: skip probabilities. 0050 * @inter_mode: inter mode probabilities. 0051 * @interp_filter: interpolation filter probabilities. 0052 * @is_inter: is inter-block probabilities. 0053 * @comp_mode: compound prediction mode probabilities. 0054 * @single_ref: single ref probabilities. 0055 * @comp_ref: compound ref probabilities. 0056 * @y_mode: Y prediction mode probabilities. 0057 * @uv_mode: UV prediction mode probabilities. 0058 * @partition: partition probabilities. 0059 * @mv: motion vector probabilities. 0060 * 0061 * Drivers which need to keep track of frame context(s) can use this struct. 0062 * The members correspond to probability tables, which are specified only implicitly in the 0063 * vp9 spec. Section 10.5 "Default probability tables" contains all the types of involved 0064 * tables, i.e. the actual tables are of the same kind, and when they are reset (which is 0065 * mandated by the spec sometimes) they are overwritten with values from the default tables. 0066 */ 0067 struct v4l2_vp9_frame_context { 0068 u8 tx8[2][1]; 0069 u8 tx16[2][2]; 0070 u8 tx32[2][3]; 0071 u8 coef[4][2][2][6][6][3]; 0072 u8 skip[3]; 0073 u8 inter_mode[7][3]; 0074 u8 interp_filter[4][2]; 0075 u8 is_inter[4]; 0076 u8 comp_mode[5]; 0077 u8 single_ref[5][2]; 0078 u8 comp_ref[5]; 0079 u8 y_mode[4][9]; 0080 u8 uv_mode[10][9]; 0081 u8 partition[16][3]; 0082 0083 struct v4l2_vp9_frame_mv_context mv; 0084 }; 0085 0086 /** 0087 * struct v4l2_vp9_frame_symbol_counts - pointers to arrays of symbol counts 0088 * 0089 * @partition: partition counts. 0090 * @skip: skip counts. 0091 * @intra_inter: is inter-block counts. 0092 * @tx32p: TX32 counts. 0093 * @tx16p: TX16 counts. 0094 * @tx8p: TX8 counts. 0095 * @y_mode: Y prediction mode counts. 0096 * @uv_mode: UV prediction mode counts. 0097 * @comp: compound prediction mode counts. 0098 * @comp_ref: compound ref counts. 0099 * @single_ref: single ref counts. 0100 * @mv_mode: inter mode counts. 0101 * @filter: interpolation filter counts. 0102 * @mv_joint: motion vector joint counts. 0103 * @sign: motion vector sign counts. 0104 * @classes: motion vector class counts. 0105 * @class0: motion vector class0 bit counts. 0106 * @bits: motion vector bits counts. 0107 * @class0_fp: motion vector class0 fractional bit counts. 0108 * @fp: motion vector fractional bit counts. 0109 * @class0_hp: motion vector class0 high precision fractional bit counts. 0110 * @hp: motion vector high precision fractional bit counts. 0111 * @coeff: coefficient counts. 0112 * @eob: eob counts 0113 * 0114 * The fields correspond to what is specified in section 8.3 "Clear counts process" of the spec. 0115 * Different pieces of hardware can report the counts in different order, so we cannot rely on 0116 * simply overlaying a struct on a relevant block of memory. Instead we provide pointers to 0117 * arrays or array of pointers to arrays in case of coeff, or array of pointers for eob. 0118 */ 0119 struct v4l2_vp9_frame_symbol_counts { 0120 u32 (*partition)[16][4]; 0121 u32 (*skip)[3][2]; 0122 u32 (*intra_inter)[4][2]; 0123 u32 (*tx32p)[2][4]; 0124 u32 (*tx16p)[2][4]; 0125 u32 (*tx8p)[2][2]; 0126 u32 (*y_mode)[4][10]; 0127 u32 (*uv_mode)[10][10]; 0128 u32 (*comp)[5][2]; 0129 u32 (*comp_ref)[5][2]; 0130 u32 (*single_ref)[5][2][2]; 0131 u32 (*mv_mode)[7][4]; 0132 u32 (*filter)[4][3]; 0133 u32 (*mv_joint)[4]; 0134 u32 (*sign)[2][2]; 0135 u32 (*classes)[2][11]; 0136 u32 (*class0)[2][2]; 0137 u32 (*bits)[2][10][2]; 0138 u32 (*class0_fp)[2][2][4]; 0139 u32 (*fp)[2][4]; 0140 u32 (*class0_hp)[2][2]; 0141 u32 (*hp)[2][2]; 0142 u32 (*coeff[4][2][2][6][6])[3]; 0143 u32 *eob[4][2][2][6][6][2]; 0144 }; 0145 0146 extern const u8 v4l2_vp9_kf_y_mode_prob[10][10][9]; /* Section 10.4 of the spec */ 0147 extern const u8 v4l2_vp9_kf_partition_probs[16][3]; /* Section 10.4 of the spec */ 0148 extern const u8 v4l2_vp9_kf_uv_mode_prob[10][9]; /* Section 10.4 of the spec */ 0149 extern const struct v4l2_vp9_frame_context v4l2_vp9_default_probs; /* Section 10.5 of the spec */ 0150 0151 /** 0152 * v4l2_vp9_fw_update_probs() - Perform forward update of vp9 probabilities 0153 * 0154 * @probs: current probabilities values 0155 * @deltas: delta values from compressed header 0156 * @dec_params: vp9 frame decoding parameters 0157 * 0158 * This function performs forward updates of probabilities for the vp9 boolean decoder. 0159 * The frame header can contain a directive to update the probabilities (deltas), if so, then 0160 * the deltas are provided in the header, too. The userspace parses those and passes the said 0161 * deltas struct to the kernel. 0162 */ 0163 void v4l2_vp9_fw_update_probs(struct v4l2_vp9_frame_context *probs, 0164 const struct v4l2_ctrl_vp9_compressed_hdr *deltas, 0165 const struct v4l2_ctrl_vp9_frame *dec_params); 0166 0167 /** 0168 * v4l2_vp9_reset_frame_ctx() - Reset appropriate frame context 0169 * 0170 * @dec_params: vp9 frame decoding parameters 0171 * @frame_context: array of the 4 frame contexts 0172 * 0173 * This function resets appropriate frame contexts, based on what's in dec_params. 0174 * 0175 * Returns the frame context index after the update, which might be reset to zero if 0176 * mandated by the spec. 0177 */ 0178 u8 v4l2_vp9_reset_frame_ctx(const struct v4l2_ctrl_vp9_frame *dec_params, 0179 struct v4l2_vp9_frame_context *frame_context); 0180 0181 /** 0182 * v4l2_vp9_adapt_coef_probs() - Perform backward update of vp9 coefficients probabilities 0183 * 0184 * @probs: current probabilities values 0185 * @counts: values of symbol counts after the current frame has been decoded 0186 * @use_128: flag to request that 128 is used as update factor if true, otherwise 112 is used 0187 * @frame_is_intra: flag indicating that FrameIsIntra is true 0188 * 0189 * This function performs backward updates of coefficients probabilities for the vp9 boolean 0190 * decoder. After a frame has been decoded the counts of how many times a given symbol has 0191 * occurred are known and are used to update the probability of each symbol. 0192 */ 0193 void v4l2_vp9_adapt_coef_probs(struct v4l2_vp9_frame_context *probs, 0194 struct v4l2_vp9_frame_symbol_counts *counts, 0195 bool use_128, 0196 bool frame_is_intra); 0197 0198 /** 0199 * v4l2_vp9_adapt_noncoef_probs() - Perform backward update of vp9 non-coefficients probabilities 0200 * 0201 * @probs: current probabilities values 0202 * @counts: values of symbol counts after the current frame has been decoded 0203 * @reference_mode: specifies the type of inter prediction to be used. See 0204 * &v4l2_vp9_reference_mode for more details 0205 * @interpolation_filter: specifies the filter selection used for performing inter prediction. 0206 * See &v4l2_vp9_interpolation_filter for more details 0207 * @tx_mode: specifies the TX mode. See &v4l2_vp9_tx_mode for more details 0208 * @flags: combination of V4L2_VP9_FRAME_FLAG_* flags 0209 * 0210 * This function performs backward updates of non-coefficients probabilities for the vp9 boolean 0211 * decoder. After a frame has been decoded the counts of how many times a given symbol has 0212 * occurred are known and are used to update the probability of each symbol. 0213 */ 0214 void v4l2_vp9_adapt_noncoef_probs(struct v4l2_vp9_frame_context *probs, 0215 struct v4l2_vp9_frame_symbol_counts *counts, 0216 u8 reference_mode, u8 interpolation_filter, u8 tx_mode, 0217 u32 flags); 0218 0219 /** 0220 * v4l2_vp9_seg_feat_enabled() - Check if a segmentation feature is enabled 0221 * 0222 * @feature_enabled: array of 8-bit flags (for all segments) 0223 * @feature: id of the feature to check 0224 * @segid: id of the segment to look up 0225 * 0226 * This function returns true if a given feature is active in a given segment. 0227 */ 0228 bool 0229 v4l2_vp9_seg_feat_enabled(const u8 *feature_enabled, 0230 unsigned int feature, 0231 unsigned int segid); 0232 0233 #endif /* _MEDIA_V4L2_VP9_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |