Update mojo sdk to rev 1dc8a9a5db73d3718d99917fadf31f5fb2ebad4f
[chromium-blink-merge.git] / third_party / libva / va / va_enc_mpeg2.h
blobc12c8defc45c6910d93a934d20801ccbe8664818
1 /*
2 * Copyright (c) 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
14 * of the Software.
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.
25 /**
26 * \file va_enc_mpeg2.h
27 * \brief The MPEG-2 encoding API
29 * This file contains the \ref api_enc_mpeg2 "MPEG-2 encoding API".
32 #ifndef _VA_ENC_MPEG2_H_
33 #define _VA_ENC_MPEG2_H_
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
39 /**
40 * \defgroup api_enc_mpeg2 MPEG-2 encoding API
42 * @{
45 /**
46 * \brief MPEG-2 Quantization Matrix Buffer
49 typedef VAIQMatrixBufferMPEG2 VAQMatrixBufferMPEG2;
51 /**
52 * \brief Packed header types specific to MPEG-2 encoding.
54 * Types of packed headers generally used for MPEG-2 encoding.
56 typedef enum {
57 /**
58 * \brief Packed Sequence Parameter Set (SPS).
61 VAEncPackedHeaderMPEG2_SPS = VAEncPackedHeaderSequence,
62 /**
63 * \brief Packed Picture Parameter Set (PPS).
66 VAEncPackedHeaderMPEG2_PPS = VAEncPackedHeaderPicture,
67 /**
68 * \brief Packed slice header.
71 VAEncPackedHeaderMPEG2_Slice = VAEncPackedHeaderSlice,
72 } VAEncPackedHeaderTypeMPEG2;
74 /**
75 * \brief Sequence parameter for MPEG-2 encoding
77 * This structure holds information for \c sequence_header() and
78 * sequence_extension().
80 * If packed sequence headers mode is used, i.e. if the encoding
81 * pipeline was configured with the #VA_ENC_PACKED_HEADER_SEQUENCE
82 * flag, then the driver expects two more buffers to be provided to
83 * the same \c vaRenderPicture() as this buffer:
84 * - a #VAEncPackedHeaderParameterBuffer with type set to
85 * VAEncPackedHeaderType::VAEncPackedHeaderSequence ;
86 * - a #VAEncPackedHeaderDataBuffer which holds the actual packed
87 * header data.
90 typedef struct _VAEncSequenceParameterBufferMPEG2 {
91 /** \brief Period between I frames. */
92 unsigned int intra_period;
93 /** \brief Period between I/P frames. */
94 unsigned int ip_period;
95 /** \brief Picture width.
97 * A 14bits unsigned inter, the lower 12bits
98 * is horizontal_size_value, and the upper
99 * 2bits is \c horizontal_size_extension
102 unsigned short picture_width;
103 /** \brief Picture height.
105 * A 14bits unsigned inter, the lower 12bits
106 * is vertical_size_value, and the upper 2bits is
107 * vertical_size_size_extension
110 unsigned short picture_height;
112 * \brief Initial bitrate set for this sequence in CBR or VBR modes.
114 * This field represents the initial bitrate value for this
115 * sequence if CBR or VBR mode is used, i.e. if the encoder
116 * pipeline was created with a #VAConfigAttribRateControl
117 * attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR.
119 * bits_per_second may be derived from bit_rate.
122 unsigned int bits_per_second;
124 * \brief Frame rate
126 * Derived from frame_rate_value, frame_rate_extension_n and
127 * frame_rate_extension_d
130 float frame_rate;
131 /** \brief Same as the element in sequence_header() */
132 unsigned short aspect_ratio_information;
133 /** \brief Define the size of VBV */
134 unsigned int vbv_buffer_size;
136 union {
137 struct {
138 /** \brief Same as the element in Sequence extension() */
139 unsigned int profile_and_level_indication : 8;
140 /** \brief Same as the element in Sequence extension() */
141 unsigned int progressive_sequence : 1;
142 /** \brief Same as the element in Sequence extension() */
143 unsigned int chroma_format : 2;
144 /** \brief Same as the element in Sequence extension() */
145 unsigned int low_delay : 1;
146 /** \brief Same as the element in Sequence extension() */
147 unsigned int frame_rate_extension_n : 2;
148 /** \brief Same as the element in Sequence extension() */
149 unsigned int frame_rate_extension_d : 5;
150 } bits;
151 unsigned int value;
152 } sequence_extension;
154 /** \brief Flag to indicate the following GOP header are being updated */
155 unsigned int new_gop_header;
157 union {
158 struct {
159 /** \brief Time code */
160 unsigned int time_code : 25;
161 /** \brief Same as the element in GOP header */
162 unsigned int closed_gop : 1;
163 /** \brief SAme as the element in GOP header */
164 unsigned int broken_link : 1;
165 } bits;
166 unsigned int value;
167 } gop_header;
168 } VAEncSequenceParameterBufferMPEG2;
171 * \brief Picture parameter for MPEG-2 encoding
173 * This structure holds information for picture_header() and
174 * picture_coding_extension()
176 * If packed picture headers mode is used, i.e. if the encoding
177 * pipeline was configured with the #VA_ENC_PACKED_HEADER_PICTURE
178 * flag, then the driver expects two more buffers to be provided to
179 * the same \c vaRenderPicture() as this buffer:
180 * - a #VAEncPackedHeaderParameterBuffer with type set to
181 * VAEncPackedHeaderType::VAEncPackedHeaderPicture ;
182 * - a #VAEncPackedHeaderDataBuffer which holds the actual packed
183 * header data.
186 typedef struct _VAEncPictureParameterBufferMPEG2 {
187 /** \brief Forward reference picture */
188 VASurfaceID forward_reference_picture;
189 /** \brief Backward reference picture */
190 VASurfaceID backward_reference_picture;
191 /** \brief Reconstructed(decoded) picture */
192 VASurfaceID reconstructed_picture;
194 * \brief Output encoded bitstream.
196 * \ref coded_buf has type #VAEncCodedBufferType. It should be
197 * large enough to hold the compressed NAL slice and possibly SPS
198 * and PPS NAL units.
200 VABufferID coded_buf;
202 * \brief Flag to indicate the picture is the last one or not.
204 * This fields holds 0 if the picture to be encoded is not
205 * the last one in the stream. Otherwise, it
206 * is \ref MPEG2_LAST_PICTURE_EOSTREAM.
208 unsigned char last_picture;
209 /** \brief Picture type */
210 VAEncPictureType picture_type;
211 /** \brief Same as the element in picture_header() */
212 unsigned int temporal_reference;
213 /** \brief Same as the element in picture_header() */
214 unsigned int vbv_delay;
215 /** \brief Same as the element in Picture coding extension */
216 unsigned char f_code[2][2];
217 union {
218 struct {
219 /** \brief Same as the element in Picture coding extension */
220 unsigned int intra_dc_precision : 2;
221 /** \brief Same as the element in Picture coding extension */
222 unsigned int picture_structure : 2;
223 /** \brief Same as the element in Picture coding extension */
224 unsigned int top_field_first : 1;
225 /** \brief Same as the element in Picture coding extension */
226 unsigned int frame_pred_frame_dct : 1;
227 /** \brief Same as the element in Picture coding extension */
228 unsigned int concealment_motion_vectors : 1;
229 /** \brief Same as the element in Picture coding extension */
230 unsigned int q_scale_type : 1;
231 /** \brief Same as the element in Picture coding extension */
232 unsigned int intra_vlc_format : 1;
233 /** \brief Same as the element in Picture coding extension */
234 unsigned int alternate_scan : 1;
235 /** \brief Same as the element in Picture coding extension */
236 unsigned int repeat_first_field : 1;
237 /** \brief Same as the element in Picture coding extension */
238 unsigned int progressive_frame : 1;
239 /** \brief Same as the element in Picture coding extension */
240 unsigned int composite_display_flag : 1;
241 } bits;
242 unsigned int value;
243 } picture_coding_extension;
245 /* \brief Parameters for composite display
247 * Valid only when omposite_display_flag is 1
249 union {
250 struct {
251 /** \brief Same as the element in Picture coding extension */
252 unsigned int v_axis : 1;
253 /** \brief Same as the element in Picture coding extension */
254 unsigned int field_sequence : 3;
255 /** \brief Same as the element in Picture coding extension */
256 unsigned int sub_carrier : 1;
257 /** \brief Same as the element in Picture coding extension */
258 unsigned int burst_amplitude : 7;
259 /** \brief Same as the element in Picture coding extension */
260 unsigned int sub_carrier_phase : 8;
261 } bits;
262 unsigned int value;
263 } composite_display;
264 } VAEncPictureParameterBufferMPEG2;
267 * \brief Slice parameter for MPEG-2 encoding
270 typedef struct _VAEncSliceParameterBufferMPEG2 {
271 /** \brief Starting MB address for this slice. */
272 unsigned int macroblock_address;
273 /** \brief Number of macroblocks in this slice. */
274 unsigned int num_macroblocks;
275 /** \brief Same as the element in slice() */
276 int quantiser_scale_code;
277 /** \brief Flag to indicate intra slice */
278 int is_intra_slice;
279 } VAEncSliceParameterBufferMPEG2;
281 /**@}*/
283 #ifdef __cplusplus
285 #endif
287 #endif /* _VA_ENC_MPEG2_H_ */