OSDN Git Service

Revert "fei_hevc: Add control to use avc VME to do intra prediction for HEVC FEI"
[android-x86/hardware-intel-common-libva.git] / va / va_enc_mpeg2.h
1 /*
2  * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
3  *
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:
11  *
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.
15  *
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.
23  */
24
25 /**
26  * \file va_enc_mpeg2.h
27  * \brief The MPEG-2 encoding API
28  *
29  * This file contains the \ref api_enc_mpeg2 "MPEG-2 encoding API".
30  */
31
32 #ifndef _VA_ENC_MPEG2_H_
33 #define _VA_ENC_MPEG2_H_
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 /**
40  * \defgroup api_enc_mpeg2 MPEG-2 encoding API
41  *
42  * @{
43  */
44
45 /**
46  * \brief MPEG-2 Quantization Matrix Buffer
47  *
48  */
49 typedef VAIQMatrixBufferMPEG2 VAQMatrixBufferMPEG2;
50
51 /**
52  * \brief Packed header types specific to MPEG-2 encoding.
53  *
54  * Types of packed headers generally used for MPEG-2 encoding.
55  */
56 typedef enum {
57     /**
58      * \brief Packed Sequence Parameter Set (SPS).
59      *
60      */
61     VAEncPackedHeaderMPEG2_SPS = VAEncPackedHeaderSequence,
62     /**
63      * \brief Packed Picture Parameter Set (PPS).
64      *
65      */
66     VAEncPackedHeaderMPEG2_PPS = VAEncPackedHeaderPicture,
67     /**
68      * \brief Packed slice header.
69      *
70      */
71     VAEncPackedHeaderMPEG2_Slice = VAEncPackedHeaderSlice,
72 } VAEncPackedHeaderTypeMPEG2;
73
74 /**
75  * \brief Sequence parameter for MPEG-2 encoding
76  *
77  * This structure holds information for \c sequence_header() and
78  * sequence_extension().
79  *
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.
88  *
89  */
90 typedef struct _VAEncSequenceParameterBufferMPEG2 {
91     /** \brief Period between I frames. */
92     uint32_t intra_period;
93     /** \brief Period between I/P frames. */
94     uint32_t ip_period;
95     /** \brief Picture width.
96      *
97      * A 14bits unsigned inter, the lower 12bits 
98      * is horizontal_size_value, and the upper 
99      * 2bits is \c horizontal_size_extension
100      *
101      */
102     uint16_t picture_width;
103     /** \brief Picture height.
104      *
105      * A 14bits unsigned inter, the lower 12bits
106      * is vertical_size_value, and the upper 2bits is 
107      * vertical_size_size_extension
108      *
109      */
110     uint16_t picture_height;
111     /**
112      * \brief Initial bitrate set for this sequence in CBR or VBR modes.
113      *
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.
118      *
119      * bits_per_second may be derived from bit_rate.
120      *
121      */
122     uint32_t bits_per_second;
123     /**
124      * \brief Frame rate
125      * 
126      * Derived from frame_rate_value, frame_rate_extension_n and 
127      * frame_rate_extension_d
128      *
129      */
130     float frame_rate;
131     /** \brief Same as the element in sequence_header() */
132     uint16_t aspect_ratio_information;
133     /** \brief Define the size of VBV */
134     uint32_t vbv_buffer_size;
135
136     union {
137         struct {
138             /** \brief Same as the element in Sequence extension() */
139             uint32_t profile_and_level_indication   : 8;
140             /** \brief Same as the element in Sequence extension() */
141             uint32_t progressive_sequence           : 1;
142             /** \brief Same as the element in Sequence extension() */
143             uint32_t chroma_format                  : 2;
144             /** \brief Same as the element in Sequence extension() */
145             uint32_t low_delay                      : 1;
146             /** \brief Same as the element in Sequence extension() */
147             uint32_t frame_rate_extension_n         : 2;
148             /** \brief Same as the element in Sequence extension() */
149             uint32_t frame_rate_extension_d         : 5;
150         } bits;
151         uint32_t value;
152     } sequence_extension;
153
154     /** \brief Flag to indicate the following GOP header are being updated */
155     uint32_t new_gop_header;
156
157     union {
158         struct {
159             /** \brief Time code */
160             uint32_t time_code                      : 25;
161             /** \brief Same as the element in GOP header */
162             uint32_t closed_gop                     : 1;
163             /** \brief SAme as the element in GOP header */
164             uint32_t broken_link                    : 1;
165         } bits;
166         uint32_t value;
167     } gop_header;
168
169     /** \brief Reserved bytes for future use, must be zero */
170     uint32_t                va_reserved[VA_PADDING_LOW];
171 } VAEncSequenceParameterBufferMPEG2;
172
173 /**
174  * \brief Picture parameter for MPEG-2 encoding
175  *
176  * This structure holds information for picture_header() and 
177  * picture_coding_extension()
178  *
179  * If packed picture headers mode is used, i.e. if the encoding
180  * pipeline was configured with the #VA_ENC_PACKED_HEADER_PICTURE
181  * flag, then the driver expects two more buffers to be provided to
182  * the same \c vaRenderPicture() as this buffer:
183  * - a #VAEncPackedHeaderParameterBuffer with type set to
184  *   VAEncPackedHeaderType::VAEncPackedHeaderPicture ;
185  * - a #VAEncPackedHeaderDataBuffer which holds the actual packed
186  *   header data.
187  *
188  */
189 typedef struct _VAEncPictureParameterBufferMPEG2 {
190     /** \brief Forward reference picture */
191     VASurfaceID forward_reference_picture;
192     /** \brief Backward reference picture */
193     VASurfaceID backward_reference_picture;
194     /** \brief Reconstructed(decoded) picture */
195     VASurfaceID reconstructed_picture;
196     /**
197      * \brief Output encoded bitstream.
198      *
199      * \ref coded_buf has type #VAEncCodedBufferType. It should be
200      * large enough to hold the compressed NAL slice and possibly SPS
201      * and PPS NAL units.
202      */
203     VABufferID coded_buf;
204     /**
205      * \brief Flag to indicate the picture is the last one or not.
206      *
207      * This fields holds 0 if the picture to be encoded is not 
208      * the last one in the stream. Otherwise, it 
209      * is \ref MPEG2_LAST_PICTURE_EOSTREAM.
210      */
211     uint8_t last_picture;
212     /** \brief Picture type */
213     VAEncPictureType picture_type;
214     /** \brief Same as the element in picture_header() */
215     uint32_t temporal_reference;
216     /** \brief Same as the element in picture_header() */
217     uint32_t vbv_delay;
218     /** \brief Same as the element in Picture coding extension */
219     uint8_t f_code[2][2];
220     union {
221         struct {
222             /** \brief Same as the element in Picture coding extension */
223             uint32_t intra_dc_precision             : 2; 
224             /** \brief Same as the element in Picture coding extension */
225             uint32_t picture_structure              : 2; 
226             /** \brief Same as the element in Picture coding extension */
227             uint32_t top_field_first                : 1; 
228             /** \brief Same as the element in Picture coding extension */
229             uint32_t frame_pred_frame_dct           : 1; 
230             /** \brief Same as the element in Picture coding extension */
231             uint32_t concealment_motion_vectors     : 1;
232             /** \brief Same as the element in Picture coding extension */
233             uint32_t q_scale_type                   : 1;
234             /** \brief Same as the element in Picture coding extension */
235             uint32_t intra_vlc_format               : 1;
236             /** \brief Same as the element in Picture coding extension */
237             uint32_t alternate_scan                 : 1;
238             /** \brief Same as the element in Picture coding extension */
239             uint32_t repeat_first_field             : 1;
240             /** \brief Same as the element in Picture coding extension */
241             uint32_t progressive_frame              : 1;
242             /** \brief Same as the element in Picture coding extension */
243             uint32_t composite_display_flag         : 1;
244         } bits;
245         uint32_t value;
246     } picture_coding_extension;
247
248     /* \brief Parameters for composite display
249      *
250      * Valid only when omposite_display_flag is 1
251      */
252     union {
253         struct {
254             /** \brief Same as the element in Picture coding extension */            
255             uint32_t v_axis                         : 1;
256             /** \brief Same as the element in Picture coding extension */
257             uint32_t field_sequence                 : 3;
258             /** \brief Same as the element in Picture coding extension */
259             uint32_t sub_carrier                    : 1;
260             /** \brief Same as the element in Picture coding extension */
261             uint32_t burst_amplitude                : 7;
262             /** \brief Same as the element in Picture coding extension */
263             uint32_t sub_carrier_phase              : 8;
264         } bits;
265         uint32_t value;
266     } composite_display;
267
268     /** \brief Reserved bytes for future use, must be zero */
269     uint32_t                va_reserved[VA_PADDING_LOW];
270 } VAEncPictureParameterBufferMPEG2;
271
272 /**
273  * \brief Slice parameter for MPEG-2 encoding
274  *
275  */
276 typedef struct _VAEncSliceParameterBufferMPEG2 {
277     /** \brief Starting MB address for this slice. */
278     uint32_t macroblock_address;
279     /** \brief Number of macroblocks in this slice. */
280     uint32_t num_macroblocks;
281     /** \brief Same as the element in slice() */
282     int32_t quantiser_scale_code;
283     /** \brief Flag to indicate intra slice */
284     int32_t is_intra_slice;
285
286     /** \brief Reserved bytes for future use, must be zero */
287     uint32_t                va_reserved[VA_PADDING_LOW];
288 } VAEncSliceParameterBufferMPEG2;
289
290 typedef struct _VAEncMiscParameterExtensionDataSeqDisplayMPEG2
291 {
292     /** should always be 0x02 to identify it is Sequence Display Extension ISO-13818 */
293     uint8_t extension_start_code_identifier;
294     /** these field should follow ISO-13818 6.3.6 */
295     uint8_t video_format;
296     uint8_t colour_description;
297     uint8_t colour_primaries;
298     uint8_t transfer_characteristics;
299     uint8_t matrix_coefficients;
300     uint16_t display_horizontal_size;
301     uint16_t display_vertical_size;
302 } VAEncMiscParameterExtensionDataSeqDisplayMPEG2;
303 /**@}*/
304
305 #ifdef __cplusplus
306 }
307 #endif
308
309 #endif /* _VA_ENC_MPEG2_H_ */