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
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.
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_
39 #include <va/va_enc.h>
42 * \defgroup api_enc_mpeg2 MPEG-2 encoding API
47 #define MPEG2_LAST_PICTURE_EOSTREAM VA_ENC_LAST_PICTURE_EOSTREAM
50 * \brief MPEG-2 Quantization Matrix Buffer
53 typedef VAIQMatrixBufferMPEG2 VAQMatrixBufferMPEG2;
56 * \brief Packed header types specific to MPEG-2 encoding.
58 * Types of packed headers generally used for MPEG-2 encoding.
62 * \brief Packed Sequence Parameter Set (SPS).
65 VAEncPackedHeaderMPEG2_SPS = VAEncPackedHeaderSequence,
67 * \brief Packed Picture Parameter Set (PPS).
70 VAEncPackedHeaderMPEG2_PPS = VAEncPackedHeaderPicture,
72 * \brief Packed slice header.
75 VAEncPackedHeaderMPEG2_Slice = VAEncPackedHeaderSlice,
76 } VAEncPackedHeaderTypeMPEG2;
79 * \brief Sequence parameter for MPEG-2 encoding
81 * This structure holds information for \c sequence_header() and
82 * sequence_extension().
84 * If packed sequence headers mode is used, i.e. if the encoding
85 * pipeline was configured with the #VA_ENC_PACKED_HEADER_SEQUENCE
86 * flag, then the driver expects two more buffers to be provided to
87 * the same \c vaRenderPicture() as this buffer:
88 * - a #VAEncPackedHeaderParameterBuffer with type set to
89 * VAEncPackedHeaderType::VAEncPackedHeaderSequence ;
90 * - a #VAEncPackedHeaderDataBuffer which holds the actual packed
94 typedef struct _VAEncSequenceParameterBufferMPEG2 {
95 /** \brief Period between I frames. */
96 unsigned int intra_period;
97 /** \brief Period between I/P frames. */
98 unsigned int ip_period;
99 /** \brief Picture width.
101 * A 14bits unsigned inter, the lower 12bits
102 * is horizontal_size_value, and the upper
103 * 2bits is \c horizontal_size_extension
106 unsigned short picture_width;
107 /** \brief Picture height.
109 * A 14bits unsigned inter, the lower 12bits
110 * is vertical_size_value, and the upper 2bits is
111 * vertical_size_size_extension
114 unsigned short picture_height;
116 * \brief Initial bitrate set for this sequence in CBR or VBR modes.
118 * This field represents the initial bitrate value for this
119 * sequence if CBR or VBR mode is used, i.e. if the encoder
120 * pipeline was created with a #VAConfigAttribRateControl
121 * attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR.
123 * bits_per_second may be derived from bit_rate.
126 unsigned int bits_per_second;
130 * Derived from frame_rate_value, frame_rate_extension_n and
131 * frame_rate_extension_d
135 /** \brief Same as the element in sequence_header() */
136 unsigned short aspect_ratio_information;
137 /** \brief Define the size of VBV */
138 unsigned int vbv_buffer_size;
142 /** \brief Same as the element in Sequence extension() */
143 unsigned int profile_and_level_indication : 8;
144 /** \brief Same as the element in Sequence extension() */
145 unsigned int progressive_sequence : 1;
146 /** \brief Same as the element in Sequence extension() */
147 unsigned int chroma_format : 2;
148 /** \brief Same as the element in Sequence extension() */
149 unsigned int low_delay : 1;
150 /** \brief Same as the element in Sequence extension() */
151 unsigned int frame_rate_extension_n : 2;
152 /** \brief Same as the element in Sequence extension() */
153 unsigned int frame_rate_extension_d : 5;
156 } sequence_extension;
158 /** \brief Flag to indicate the following GOP header are being updated */
159 unsigned int new_gop_header;
163 /** \brief Time code */
164 unsigned int time_code : 25;
165 /** \brief Same as the element in GOP header */
166 unsigned int closed_gop : 1;
167 /** \brief SAme as the element in GOP header */
168 unsigned int broken_link : 1;
172 } VAEncSequenceParameterBufferMPEG2;
175 * \brief Picture parameter for MPEG-2 encoding
177 * This structure holds information for picture_header() and
178 * picture_coding_extension()
180 * If packed picture headers mode is used, i.e. if the encoding
181 * pipeline was configured with the #VA_ENC_PACKED_HEADER_PICTURE
182 * flag, then the driver expects two more buffers to be provided to
183 * the same \c vaRenderPicture() as this buffer:
184 * - a #VAEncPackedHeaderParameterBuffer with type set to
185 * VAEncPackedHeaderType::VAEncPackedHeaderPicture ;
186 * - a #VAEncPackedHeaderDataBuffer which holds the actual packed
190 typedef struct _VAEncPictureParameterBufferMPEG2 {
191 /** \brief Forward reference picture */
192 VASurfaceID forward_reference_picture;
193 /** \brief Backward reference picture */
194 VASurfaceID backward_reference_picture;
195 /** \brief Reconstructed(decoded) picture */
196 VASurfaceID reconstructed_picture;
198 * \brief Output encoded bitstream.
200 * \ref coded_buf has type #VAEncCodedBufferType. It should be
201 * large enough to hold the compressed NAL slice and possibly SPS
204 VABufferID coded_buf;
206 * \brief Flag to indicate the picture is the last one or not.
208 * This fields holds 0 if the picture to be encoded is not
209 * the last one in the stream. Otherwise, it
210 * is \ref MPEG2_LAST_PICTURE_EOSTREAM.
212 unsigned char last_picture;
213 /** \brief Picture type */
214 VAEncPictureType picture_type;
215 /** \brief Same as the element in picture_header() */
216 unsigned int temporal_reference;
217 /** \brief Same as the element in picture_header() */
218 unsigned int vbv_delay;
219 /** \brief Same as the element in Picture coding extension */
220 unsigned char f_code[2][2];
223 /** \brief Same as the element in Picture coding extension */
224 unsigned int intra_dc_precision : 2;
225 /** \brief Same as the element in Picture coding extension */
226 unsigned int picture_structure : 2;
227 /** \brief Same as the element in Picture coding extension */
228 unsigned int top_field_first : 1;
229 /** \brief Same as the element in Picture coding extension */
230 unsigned int frame_pred_frame_dct : 1;
231 /** \brief Same as the element in Picture coding extension */
232 unsigned int concealment_motion_vectors : 1;
233 /** \brief Same as the element in Picture coding extension */
234 unsigned int q_scale_type : 1;
235 /** \brief Same as the element in Picture coding extension */
236 unsigned int intra_vlc_format : 1;
237 /** \brief Same as the element in Picture coding extension */
238 unsigned int alternate_scan : 1;
239 /** \brief Same as the element in Picture coding extension */
240 unsigned int repeat_first_field : 1;
241 /** \brief Same as the element in Picture coding extension */
242 unsigned int progressive_frame : 1;
243 /** \brief Same as the element in Picture coding extension */
244 unsigned int composite_display_flag : 1;
247 } picture_coding_extension;
249 /* \brief Parameters for composite display
251 * Valid only when omposite_display_flag is 1
255 /** \brief Same as the element in Picture coding extension */
256 unsigned int v_axis : 1;
257 /** \brief Same as the element in Picture coding extension */
258 unsigned int field_sequence : 3;
259 /** \brief Same as the element in Picture coding extension */
260 unsigned int sub_carrier : 1;
261 /** \brief Same as the element in Picture coding extension */
262 unsigned int burst_amplitude : 7;
263 /** \brief Same as the element in Picture coding extension */
264 unsigned int sub_carrier_phase : 8;
269 /** \brief The length of user data
271 * Append user data after picture coding extension
272 * if user_data_length isn't 0.
275 unsigned int user_data_length;
276 /** \brief User data */
277 unsigned char user_data[16];
278 } VAEncPictureParameterBufferMPEG2;
281 * \brief Slice parameter for MPEG-2 encoding
284 typedef struct _VAEncSliceParameterBufferMPEG2 {
285 /** \brief Starting MB address for this slice. */
286 unsigned int macroblock_address;
287 /** \brief Number of macroblocks in this slice. */
288 unsigned int num_macroblocks;
289 /** \brief Same as the element in slice() */
290 int quantiser_scale_code;
291 /** \brief Flag to indicate intra slice */
293 } VAEncSliceParameterBufferMPEG2;
301 #endif /* _VA_ENC_MPEG2_H_ */