2 * Copyright (c) 2007-2012 Intel Corporation. All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19 * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * \brief VP8 encoding API
29 * This file contains the \ref api_enc_vp8 "VP8 encoding API".
40 * \defgroup api_enc_vp8 VP8 encoding API
46 * \brief VP8 Encoding Sequence Parameter Buffer Structure
48 * This structure conveys sequence level parameters.
51 typedef struct _VAEncSequenceParameterBufferVP8
53 /* frame width in pixels */
55 /* frame height in pixels */
56 uint32_t frame_height;
57 /* horizontal scale */
58 uint32_t frame_width_scale;
60 uint32_t frame_height_scale;
62 /* whether to enable error resilience features */
63 uint32_t error_resilient;
64 /* auto keyframe placement, non-zero means enable auto keyframe placement */
66 /* keyframe minimum interval */
68 /* keyframe maximum interval */
72 /* RC related fields. RC modes are set with VAConfigAttribRateControl */
73 /* For VP8, CBR implies HRD conformance and VBR implies no HRD conformance */
76 * Initial bitrate set for this sequence in CBR or VBR modes.
78 * This field represents the initial bitrate value for this
79 * sequence if CBR or VBR mode is used, i.e. if the encoder
80 * pipeline was created with a #VAConfigAttribRateControl
81 * attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR.
83 * The bitrate can be modified later on through
84 * #VAEncMiscParameterRateControl buffers.
86 uint32_t bits_per_second;
87 /* Period between I frames. */
88 uint32_t intra_period;
90 /* reference and reconstructed frame buffers
91 * Used for driver auto reference management when configured through
92 * VAConfigAttribEncAutoReference.
94 VASurfaceID reference_frames[4];
96 /** \brief Reserved bytes for future use, must be zero */
97 uint32_t va_reserved[VA_PADDING_LOW];
98 } VAEncSequenceParameterBufferVP8;
102 * \brief VP8 Encoding Picture Parameter Buffer Structure
104 * This structure conveys picture level parameters.
107 typedef struct _VAEncPictureParameterBufferVP8
109 /* surface to store reconstructed frame */
110 VASurfaceID reconstructed_frame;
113 * surfaces to store reference frames in non auto reference mode
114 * VA_INVALID_SURFACE can be used to denote an invalid reference frame.
116 VASurfaceID ref_last_frame;
117 VASurfaceID ref_gf_frame;
118 VASurfaceID ref_arf_frame;
120 /* buffer to store coded data */
121 VABufferID coded_buf;
125 /* force this frame to be a keyframe */
126 uint32_t force_kf : 1;
127 /* don't reference the last frame */
128 uint32_t no_ref_last : 1;
129 /* don't reference the golden frame */
130 uint32_t no_ref_gf : 1;
131 /* don't reference the alternate reference frame */
132 uint32_t no_ref_arf : 1;
133 /* The temporal id the frame belongs to. */
134 uint32_t temporal_id : 8;
136 * following two flags indicate the reference order
137 * LastRef is specified by 01b;
138 * GoldRef is specified by 10b;
139 * AltRef is specified by 11b;
140 * first_ref specifies the reference frame which is searched first.
141 * second_ref specifies the reference frame which is searched second
144 uint32_t first_ref : 2;
145 uint32_t second_ref : 2;
146 /** \brief Reserved for future use, must be zero */
147 uint32_t reserved : 16;
155 uint32_t frame_type : 1;
156 uint32_t version : 3;
158 uint32_t show_frame : 1;
160 uint32_t color_space : 1;
161 /* 0: bicubic, 1: bilinear, other: none */
162 uint32_t recon_filter_type : 2;
163 /* 0: no loop fitler, 1: simple loop filter */
164 uint32_t loop_filter_type : 2;
165 /* 0: disabled, 1: normal, 2: simple */
166 uint32_t auto_partitions : 1;
167 /* same as log2_nbr_of_dct_partitions in frame header syntax */
168 uint32_t num_token_partitions : 2;
171 * The following fields correspond to the same VP8 syntax elements
172 * in the frame header.
175 * 0: clamping of reconstruction pixels is disabled,
176 * 1: clamping enabled.
178 uint32_t clamping_type : 1;
179 /* indicate segmentation is enabled for the current frame. */
180 uint32_t segmentation_enabled : 1;
182 * Determines if the MB segmentation map is updated in the current
185 uint32_t update_mb_segmentation_map : 1;
187 * Indicates if the segment feature data is updated in the current
190 uint32_t update_segment_feature_data : 1;
192 * indicates if the MB level loop filter adjustment is enabled for
193 * the current frame (0 off, 1 on).
195 uint32_t loop_filter_adj_enable : 1;
197 * Determines whether updated token probabilities are used only for
198 * this frame or until further update.
199 * It may be used by application to enable error resilient mode.
200 * In this mode probability updates are allowed only at Key Frames.
202 uint32_t refresh_entropy_probs : 1;
204 * Determines if the current decoded frame refreshes the golden frame.
206 uint32_t refresh_golden_frame : 1;
208 * Determines if the current decoded frame refreshes the alternate
211 uint32_t refresh_alternate_frame : 1;
213 * Determines if the current decoded frame refreshes the last frame
216 uint32_t refresh_last : 1;
218 * Determines if the golden reference is replaced by another reference.
220 uint32_t copy_buffer_to_golden : 2;
222 * Determines if the alternate reference is replaced by another reference.
224 uint32_t copy_buffer_to_alternate : 2;
226 * Controls the sign of motion vectors when the golden frame is referenced.
228 uint32_t sign_bias_golden : 1;
230 * Controls the sign of motion vectors when the alternate frame is
233 uint32_t sign_bias_alternate : 1;
235 * Enables or disables the skipping of macroblocks containing no
236 * non-zero coefficients.
238 uint32_t mb_no_coeff_skip : 1;
240 * Enforces unconditional per-MB loop filter delta update setting frame
241 * header flags mode_ref_lf_delta_update, all mb_mode_delta_update_flag[4],
242 * and all ref_frame_delta_update_flag[4] to 1.
243 * Since loop filter deltas are not automatically refreshed to default
244 * values at key frames, dropped frame with delta update may prevent
245 * correct decoding from the next key frame.
246 * Encoder application is advised to set this flag to 1 at key frames.
248 uint32_t forced_lf_adjustment : 1;
249 uint32_t reserved : 2;
255 * Contains a list of 4 loop filter level values (updated value if applicable)
256 * controlling the deblocking filter strength. Each entry represents a segment.
257 * When segmentation is disabled, use entry 0.
258 * When loop_filter_level is 0, loop filter shall be disabled.
260 int8_t loop_filter_level[4];
263 * Contains a list of 4 delta values for reference frame based MB-level
264 * loop filter adjustment.
265 * If no update, then set to 0.
267 int8_t ref_lf_delta[4];
270 * Contains a list of 4 delta values for coding mode based MB-level loop
272 * If no update, then set to 0.
274 int8_t mode_lf_delta[4];
277 * Controls the deblocking filter sensitivity.
278 * Corresponds to the same VP8 syntax element in frame header.
280 uint8_t sharpness_level;
283 * Application supplied maximum clamp value for Qindex used in quantization.
284 * Qindex will not be allowed to exceed this value.
285 * It has a valid range [0..127] inclusive.
287 uint8_t clamp_qindex_high;
290 * Application supplied minimum clamp value for Qindex used in quantization.
291 * Qindex will not be allowed to be lower than this value.
292 * It has a valid range [0..127] inclusive.
293 * Condition clamp_qindex_low <= clamp_qindex_high must be guaranteed,
294 * otherwise they are ignored.
296 uint8_t clamp_qindex_low;
298 /** \brief Reserved bytes for future use, must be zero */
299 uint32_t va_reserved[VA_PADDING_LOW];
300 } VAEncPictureParameterBufferVP8;
304 * \brief VP8 MB Segmentation ID Buffer
306 * application provides buffer containing the initial segmentation id for each
307 * MB, in raster scan order. Rate control may reassign it.
308 * For an 640x480 video, the buffer has 1200 entries.
309 * the value of each entry should be in the range [0..3], inclusive.
310 * If segmentation is not enabled, application does not need to provide it.
312 typedef struct _VAEncMBMapBufferVP8
315 * number of MBs in the frame.
316 * It is also the number of entries of mb_segment_id[];
320 * per MB Segmentation ID Buffer
322 uint8_t *mb_segment_id;
324 /** \brief Reserved bytes for future use, must be zero */
325 uint32_t va_reserved[VA_PADDING_LOW];
326 } VAEncMBMapBufferVP8;
330 * \brief VP8 Quantization Matrix Buffer Structure
332 * Contains quantization index for yac(0-3) for each segment and quantization
333 * index deltas, ydc(0), y2dc(1), y2ac(2), uvdc(3), uvac(4) that are applied
334 * to all segments. When segmentation is disabled, only quantization_index[0]
335 * will be used. This structure is sent once per frame.
337 typedef struct _VAQMatrixBufferVP8
339 uint16_t quantization_index[4];
340 int16_t quantization_index_delta[5];
342 /** \brief Reserved bytes for future use, must be zero */
343 uint32_t va_reserved[VA_PADDING_LOW];
344 } VAQMatrixBufferVP8;
354 #endif /* VA_ENC_VP8_H */