VA_STATUS_ERROR_HW_BUSY: error code to indicate HW is busy
[profile/ivi/libva.git] / va / va_enc_h264.h
1 /*
2  * Copyright (c) 2007-2011 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_h264.h
27  * \brief The H.264 encoding API
28  *
29  * This file contains the \ref api_enc_h264 "H.264 encoding API".
30  */
31
32 #ifndef VA_ENC_H264_H
33 #define VA_ENC_H264_H
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 #include <va/va_enc.h>
40
41 /**
42  * \defgroup api_enc_h264 H.264 encoding API
43  *
44  * @{
45  */
46
47 /**
48  * @name Picture flags
49  *
50  * Those flags flags are meant to signal when a picture marks the end
51  * of a sequence, a stream, or even both at once.
52  *
53  * @{
54  */
55 /**
56  * \brief Marks the last picture in the sequence.
57  *
58  * i.e. the driver appends \c end_of_seq() NAL unit to the encoded frame.
59  */
60 #define H264_LAST_PICTURE_EOSEQ     0x01
61 /**
62  * \brief Marks the last picture in the stream.
63  *
64  * i.e. the driver appends \c end_of_stream() NAL unit to the encoded frame.
65  */
66 #define H264_LAST_PICTURE_EOSTREAM  0x02
67 /**@}*/
68
69 /**
70  * \brief Packed header types specific to H.264 encoding.
71  *
72  * Types of packed headers generally used for H.264 encoding. Each
73  * associated packed header data buffer shall contain the start code
74  * prefix 0x000001 followed by the complete NAL unit, thus also
75  * including the \c nal_unit_type.
76  *
77  * Note: the start code prefix can contain an arbitrary number of leading
78  * zeros. The driver will skip them for emulation prevention bytes insertion,
79  * if necessary.
80  */
81 typedef enum {
82     /**
83      * \brief Packed Sequence Parameter Set (SPS).
84      *
85      * The corresponding packed header data buffer shall contain the
86      * complete seq_parameter_set_rbsp() syntax element.
87      *
88      * Note: packed \c nal_unit_type shall be equal to 7.
89      */
90     VAEncPackedHeaderH264_SPS   = VAEncPackedHeaderSequence,
91     /**
92      * \brief Packed Picture Parameter Set (PPS).
93      *
94      * The corresponding packed header data buffer shall contain the
95      * complete pic_parameter_set_rbsp() syntax element.
96      *
97      * Note: packed \c nal_unit_type shall be equal to 8.
98      */
99     VAEncPackedHeaderH264_PPS   = VAEncPackedHeaderPicture,
100     /**
101      * \brief Packed slice header.
102      *
103      * The corresponding packed header data buffer shall contain the
104      * \c slice_header() syntax element only, along with any start
105      * code prefix and NAL unit type preceeding it. i.e. this means
106      * that the buffer does not contain any of the \c slice_data() or
107      * the \c rbsp_slice_trailing_bits().
108      *
109      * Note: packed \c nal_unit_type shall be equal to 1 (non-IDR
110      * picture), or 5 (IDR picture).
111      */
112     VAEncPackedHeaderH264_Slice = VAEncPackedHeaderSlice,
113     /**
114      * \brief Packed Supplemental Enhancement Information (SEI).
115      *
116      * The corresponding packed header data buffer shall contain the
117      * complete sei_rbsp() syntax element, thus including several
118      * sei_message() elements if necessary.
119      *
120      * Note: packed \c nal_unit_type shall be equal to 6.
121      */
122     VAEncPackedHeaderH264_SEI   = (VAEncPackedHeaderMiscMask | 1),
123 } VAEncPackedHeaderTypeH264;
124
125 /**
126  * \brief Sequence parameter for H.264 encoding in main & high profiles.
127  *
128  * This structure holds information for \c seq_parameter_set_data() as
129  * defined by the H.264 specification.
130  *
131  * If packed sequence headers mode is used, i.e. if the encoding
132  * pipeline was configured with the #VA_ENC_PACKED_HEADER_SEQUENCE
133  * flag, then the driver expects two more buffers to be provided to
134  * the same \c vaRenderPicture() as this buffer:
135  * - a #VAEncPackedHeaderParameterBuffer with type set to
136  *   VAEncPackedHeaderType::VAEncPackedHeaderSequence ;
137  * - a #VAEncPackedHeaderDataBuffer which holds the actual packed
138  *   header data.
139  *
140  * If \c seq_scaling_matrix_present_flag is set to \c 1, then a
141  * #VAIQMatrixBufferH264 buffer shall also be provided within the same
142  * \c vaRenderPicture() call as this sequence parameter buffer.
143  */
144 typedef struct _VAEncSequenceParameterBufferH264 {
145     /** \brief Same as the H.264 bitstream syntax element. */
146     unsigned char   seq_parameter_set_id;
147     /** \brief Same as the H.264 bitstream syntax element. */
148     unsigned char   level_idc;
149     /** \brief Period between I frames. */
150     unsigned int    intra_period;
151     /** \brief Period between IDR frames. */
152     unsigned int    intra_idr_period;
153     /** \brief Period between I/P frames. */
154     unsigned int    ip_period;
155     /**
156      * \brief Initial bitrate set for this sequence in CBR or VBR modes.
157      *
158      * This field represents the initial bitrate value for this
159      * sequence if CBR or VBR mode is used, i.e. if the encoder
160      * pipeline was created with a #VAConfigAttribRateControl
161      * attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR.
162      *
163      * The bitrate can be modified later on through
164      * #VAEncMiscParameterRateControl buffers.
165      */
166     unsigned int    bits_per_second;
167     /** \brief Same as the H.264 bitstream syntax element. */
168     unsigned int    max_num_ref_frames;
169     /** \brief Picture width in macroblocks. */
170     unsigned short  picture_width_in_mbs;
171     /** \brief Picture height in macroblocks. */
172     unsigned short  picture_height_in_mbs;
173
174     union {
175         struct {
176             /** \brief Same as the H.264 bitstream syntax element. */
177             unsigned int chroma_format_idc                      : 2;
178             /** \brief Same as the H.264 bitstream syntax element. */
179             unsigned int frame_mbs_only_flag                    : 1;
180             /** \brief Same as the H.264 bitstream syntax element. */
181             unsigned int mb_adaptive_frame_field_flag           : 1;
182             /** \brief Same as the H.264 bitstream syntax element. */
183             unsigned int seq_scaling_matrix_present_flag        : 1;
184             /** \brief Same as the H.264 bitstream syntax element. */
185             unsigned int direct_8x8_inference_flag              : 1;
186             /** \brief Same as the H.264 bitstream syntax element. */
187             unsigned int log2_max_frame_num_minus4              : 4;
188             /** \brief Same as the H.264 bitstream syntax element. */
189             unsigned int pic_order_cnt_type                     : 2;
190             /** \brief Same as the H.264 bitstream syntax element. */
191             unsigned int log2_max_pic_order_cnt_lsb_minus4      : 4;
192             /** \brief Same as the H.264 bitstream syntax element. */
193             unsigned int delta_pic_order_always_zero_flag       : 1;
194         } bits;
195         unsigned int value;
196     } seq_fields;
197
198     /** \brief Same as the H.264 bitstream syntax element. */
199     unsigned char   bit_depth_luma_minus8;
200     /** \brief Same as the H.264 bitstream syntax element. */
201     unsigned char   bit_depth_chroma_minus8;
202
203     /** if pic_order_cnt_type == 1 */
204     /**@{*/
205     /** \brief Same as the H.264 bitstream syntax element. */
206     unsigned char   num_ref_frames_in_pic_order_cnt_cycle;
207     /** \brief Same as the H.264 bitstream syntax element. */
208     int             offset_for_non_ref_pic;
209     /** \brief Same as the H.264 bitstream syntax element. */
210     int             offset_for_top_to_bottom_field;
211     /** \brief Same as the H.264 bitstream syntax element. */
212     int             offset_for_ref_frame[256];
213     /**@}*/
214
215     /** @name Cropping (optional) */
216     /**@{*/
217     /** \brief Same as the H.264 bitstream syntax element. */
218     unsigned char   frame_cropping_flag;
219     /** \brief Same as the H.264 bitstream syntax element. */
220     unsigned int    frame_crop_left_offset;
221     /** \brief Same as the H.264 bitstream syntax element. */
222     unsigned int    frame_crop_right_offset;
223     /** \brief Same as the H.264 bitstream syntax element. */
224     unsigned int    frame_crop_top_offset;
225     /** \brief Same as the H.264 bitstream syntax element. */
226     unsigned int    frame_crop_bottom_offset;
227     /**@}*/
228
229     /** @name VUI parameters (optional) */
230     /**@{*/
231     /** \brief Same as the H.264 bitstream syntax element. */
232     unsigned char   vui_parameters_present_flag;
233     union {
234         struct {
235             /** \brief Same as the H.264 bitstream syntax element. */
236             unsigned int timing_info_present_flag               : 1;
237             /** \brief Same as the H.264 bitstream syntax element. */
238             unsigned int bitstream_restriction_flag             : 1;
239             /** \brief Range: 0 to 16, inclusive. */
240             unsigned int log2_max_mv_length_horizontal          : 5;
241             /** \brief Range: 0 to 16, inclusive. */
242             unsigned int log2_max_mv_length_vertical            : 5;
243         } bits;
244         unsigned int value;
245     } vui_fields;
246     /** \brief Same as the H.264 bitstream syntax element. */
247     unsigned int    num_units_in_tick;
248     /** \brief Same as the H.264 bitstream syntax element. */
249     unsigned int    time_scale;
250     /**@}*/
251 } VAEncSequenceParameterBufferH264;
252
253 /**
254  * \brief Picture parameter for H.264 encoding in main & high profiles.
255  *
256  * This structure holds information for \c pic_parameter_set_rbsp() as
257  * defined by the H.264 specification.
258  *
259  * If packed picture headers mode is used, i.e. if the encoding
260  * pipeline was configured with the #VA_ENC_PACKED_HEADER_PICTURE
261  * flag, then the driver expects two more buffers to be provided to
262  * the same \c vaRenderPicture() as this buffer:
263  * - a #VAEncPackedHeaderParameterBuffer with type set to
264  *   VAEncPackedHeaderType::VAEncPackedHeaderPicture ;
265  * - a #VAEncPackedHeaderDataBuffer which holds the actual packed
266  *   header data.
267  *
268  * If \c pic_scaling_matrix_present_flag is set to \c 1, then a
269  * #VAIQMatrixBufferH264 buffer shall also be provided within the same
270  * \c vaRenderPicture() call as this picture parameter buffer.
271  */
272 typedef struct _VAEncPictureParameterBufferH264 {
273     /**
274      * \brief Information about the picture to be encoded.
275      *
276      * See #VAPictureH264 for further description of each field.
277      * Note that CurrPic.picture_id represents the reconstructed
278      * (decoded) picture. User provides a scratch VA surface ID here.
279      */
280     VAPictureH264   CurrPic;
281     /**
282      * \brief Decoded Picture Buffer (DPB).
283      *
284      * This array represents the list of reconstructed (decoded)
285      * frames used as reference. It is important to keep track of
286      * reconstructed frames so that they can be used later on as
287      * reference for P or B-frames encoding.
288      */
289     VAPictureH264   ReferenceFrames[16];
290     /**
291      * \brief Output encoded bitstream.
292      *
293      * \ref coded_buf has type #VAEncCodedBufferType. It should be
294      * large enough to hold the compressed NAL slice and possibly SPS
295      * and PPS NAL units.
296      */
297     VABufferID      coded_buf;
298
299     /** \brief The picture parameter set referred to in the slice header. */
300     unsigned char   pic_parameter_set_id;
301     /** \brief The active sequence parameter set. Range: 0 to 31, inclusive. */
302     unsigned char   seq_parameter_set_id;
303
304     /**
305      * \brief OR'd flags describing whether the picture is the last one or not.
306      *
307      * This fields holds 0 if the picture to be encoded is not the last
308      * one in the stream or sequence. Otherwise, it is a combination of
309      * \ref H264_LAST_PICTURE_EOSEQ or \ref H264_LAST_PICTURE_EOSTREAM.
310      */
311     unsigned char   last_picture;
312
313     /** \brief The picture identifier.
314      *   Range: 0 to \f$2^{log2\_max\_frame\_num\_minus4 + 4} - 1\f$, inclusive.
315      */
316     unsigned short  frame_num;
317
318     /** \brief \c pic_init_qp_minus26 + 26. */
319     unsigned char   pic_init_qp;
320     /** \brief Maximum reference index for reference picture list 0.
321      *   Range: 0 to 31, inclusive.
322      */
323     unsigned char   num_ref_idx_l0_active_minus1;
324     /** \brief Maximum reference index for reference picture list 1.
325      *  Range: 0 to 31, inclusive.
326      */
327     unsigned char   num_ref_idx_l1_active_minus1;
328
329     /** \brief Range: -12 to 12, inclusive. */
330     signed char     chroma_qp_index_offset;
331     /** \brief Range: -12 to 12, inclusive. */
332     signed char     second_chroma_qp_index_offset;
333
334     union {
335         struct {
336             /** \brief Is picture an IDR picture? */
337             unsigned int idr_pic_flag                           : 1;
338             /** \brief Is picture a reference picture? */
339             unsigned int reference_pic_flag                     : 2;
340             /** \brief Selects CAVLC (0) or CABAC (1) entropy coding mode. */
341             unsigned int entropy_coding_mode_flag               : 1;
342             /** \brief Is weighted prediction applied to P slices? */
343             unsigned int weighted_pred_flag                     : 1;
344             /** \brief Range: 0 to 2, inclusive. */
345             unsigned int weighted_bipred_idc                    : 2;
346             /** \brief Same as the H.264 bitstream syntax element. */
347             unsigned int constrained_intra_pred_flag            : 1;
348             /** \brief Same as the H.264 bitstream syntax element. */
349             unsigned int transform_8x8_mode_flag                : 1;
350             /** \brief Same as the H.264 bitstream syntax element. */
351             unsigned int deblocking_filter_control_present_flag : 1;
352             /** \brief Same as the H.264 bitstream syntax element. */
353             unsigned int redundant_pic_cnt_present_flag         : 1;
354             /** \brief Same as the H.264 bitstream syntax element. */
355             unsigned int pic_order_present_flag                 : 1;
356             /** \brief Same as the H.264 bitstream syntax element. */
357             unsigned int pic_scaling_matrix_present_flag        : 1;
358         } bits;
359         unsigned int value;
360     } pic_fields;
361 } VAEncPictureParameterBufferH264;
362
363 /**
364  * \brief Slice parameter for H.264 encoding in main & high profiles.
365  *
366  * This structure holds information for \c
367  * slice_layer_without_partitioning_rbsp() as defined by the H.264
368  * specification.
369  *
370  * If packed slice headers mode is used, i.e. if the encoding
371  * pipeline was configured with the #VA_ENC_PACKED_HEADER_SLICE
372  * flag, then the driver expects two more buffers to be provided to
373  * the same \c vaRenderPicture() as this buffer:
374  * - a #VAEncPackedHeaderParameterBuffer with type set to
375  *   VAEncPackedHeaderType::VAEncPackedHeaderSlice ;
376  * - a #VAEncPackedHeaderDataBuffer which holds the actual packed
377  *   header data.
378  *
379  * If per-macroblock encoder configuration is needed, \c macroblock_info
380  * references a buffer of type #VAEncMacroblockParameterBufferH264. This
381  * buffer is not passed to vaRenderPicture(). i.e. it is not destroyed
382  * by subsequent calls to vaRenderPicture() and then can be re-used
383  * without re-allocating the whole buffer.
384  */
385 typedef struct _VAEncSliceParameterBufferH264 {
386     /** \brief Starting MB address for this slice. */
387     unsigned int    macroblock_address;
388     /** \brief Number of macroblocks in this slice. */
389     unsigned int    num_macroblocks;
390     /**
391      * \brief Per-MB encoder configuration buffer, or \c VA_INVALID_ID.
392      *
393      * If per-MB encoder configuration is needed, then \ref macroblock_info
394      * references a buffer of type #VAEncMacroblockParameterBufferH264
395      * (\c VAEncMacroblockParameterBufferType). Otherwise, buffer id
396      * is set to \c VA_INVALID_ID and per-MB configuration is derived
397      * from this slice parameter.
398      *
399      * The \c macroblock_info buffer must hold \ref num_macroblocks
400      * elements.
401      */
402     VABufferID      macroblock_info;
403     /** \brief Slice type.
404      *  Range: 0..2, 5..7, i.e. no switching slices.
405      */
406     unsigned char   slice_type;
407     /** \brief Same as the H.264 bitstream syntax element. */
408     unsigned char   pic_parameter_set_id;
409     /** \brief Same as the H.264 bitstream syntax element. */
410     unsigned short  idr_pic_id;
411
412     /** @name If pic_order_cnt_type == 0 */
413     /**@{*/
414     /** \brief The picture order count modulo MaxPicOrderCntLsb. */
415     unsigned short  pic_order_cnt_lsb;
416     /** \brief Valid if \c pic_order_present_flag and this is a bottom field. */
417     int             delta_pic_order_cnt_bottom;
418     /**@}*/
419     /** @name If pic_order_cnt_type == 1 && !delta_pic_order_always_zero_flag */
420     /**@{*/
421     /** \brief [0]: top, [1]: bottom. */
422     int             delta_pic_order_cnt[2];
423     /**@}*/
424
425     /** @name If slice_type == B */
426     /**@{*/
427     unsigned char   direct_spatial_mv_pred_flag;
428     /**@}*/
429
430     /** @name If slice_type == P */
431     /**@{*/
432     /** \brief Specifies if
433      * \ref _VAEncPictureParameterBufferH264::num_ref_idx_l0_active_minus1 or
434      * \ref _VAEncPictureParameterBufferH264::num_ref_idx_l1_active_minus1 are
435      * overriden by the values for this slice.
436      */
437     unsigned char   num_ref_idx_active_override_flag;
438     /** \brief Maximum reference index for reference picture list 0.
439      *  Range: 0 to 31, inclusive.
440      */
441     unsigned char   num_ref_idx_l0_active_minus1;
442     /** \brief Maximum reference index for reference picture list 1.
443      *  Range: 0 to 31, inclusive.
444      */
445     unsigned char   num_ref_idx_l1_active_minus1;
446     /** \brief Reference picture list 0 (for P slices). */
447     VAPictureH264   RefPicList0[32];
448     /** \brief Reference picture list 1 (for B slices). */
449     VAPictureH264   RefPicList1[32];
450     /**@}*/
451
452     /** @name pred_weight_table() */
453     /**@{*/
454     /** \brief Same as the H.264 bitstream syntax element. */
455     unsigned char   luma_log2_weight_denom;
456     /** \brief Same as the H.264 bitstream syntax element. */
457     unsigned char   chroma_log2_weight_denom;
458     /** \brief Same as the H.264 bitstream syntax element. */
459     unsigned char   luma_weight_l0_flag;
460     /** \brief Same as the H.264 bitstream syntax element. */
461     signed short    luma_weight_l0[32];
462     /** \brief Same as the H.264 bitstream syntax element. */
463     signed short    luma_offset_l0[32];
464     /** \brief Same as the H.264 bitstream syntax element. */
465     unsigned char   chroma_weight_l0_flag;
466     /** \brief Same as the H.264 bitstream syntax element. */
467     signed short    chroma_weight_l0[32][2];
468     /** \brief Same as the H.264 bitstream syntax element. */
469     signed short    chroma_offset_l0[32][2];
470     /** \brief Same as the H.264 bitstream syntax element. */
471     unsigned char   luma_weight_l1_flag;
472     /** \brief Same as the H.264 bitstream syntax element. */
473     signed short    luma_weight_l1[32];
474     /** \brief Same as the H.264 bitstream syntax element. */
475     signed short    luma_offset_l1[32];
476     /** \brief Same as the H.264 bitstream syntax element. */
477     unsigned char   chroma_weight_l1_flag;
478     /** \brief Same as the H.264 bitstream syntax element. */
479     signed short    chroma_weight_l1[32][2];
480     /** \brief Same as the H.264 bitstream syntax element. */
481     signed short    chroma_offset_l1[32][2];
482     /**@}*/
483
484     /** \brief Range: 0 to 2, inclusive. */
485     unsigned char   cabac_init_idc;
486     /** \brief Same as the H.264 bitstream syntax element. */
487     signed char     slice_qp_delta;
488     /** @name If deblocking_filter_control_present_flag */
489     /**@{*/
490     /** \brief Range: 0 to 2, inclusive. */
491     unsigned char   disable_deblocking_filter_idc;
492     /** \brief Same as the H.264 bitstream syntax element. */
493     signed char     slice_alpha_c0_offset_div2;
494     /** \brief Same as the H.264 bitstream syntax element. */
495     signed char     slice_beta_offset_div2;
496     /**@}*/
497 } VAEncSliceParameterBufferH264;
498
499 /**
500  * @name Macroblock neighbour availability bits
501  *
502  * \anchor api_enc_h264_mb_pred_avail_bits
503  * Definitions for macroblock neighbour availability bits used in
504  * intra prediction mode (non MBAFF only).
505  *
506  * @{
507  */
508 /** \brief References macroblock in the top-left corner. */
509 #define VA_MB_PRED_AVAIL_TOP_LEFT         (1 << 2)
510 /** \brief References macroblock above the current macroblock. */
511 #define VA_MB_PRED_AVAIL_TOP              (1 << 4)
512 /** \brief References macroblock in the top-right corner. */
513 #define VA_MB_PRED_AVAIL_TOP_RIGHT        (1 << 3)
514 /** \brief References macroblock on the left of the current macroblock. */
515 #define VA_MB_PRED_AVAIL_LEFT             (1 << 6)
516 /**@}*/
517
518 /**
519  * \brief Macroblock parameter for H.264 encoding in main & high profiles.
520  *
521  * This structure holds per-macroblock information. The buffer must be
522  * allocated with as many elements (macroblocks) as necessary to fit
523  * the slice to be encoded. Besides, the per-macroblock records must
524  * be written in a strict raster order and with no gap. i.e. every
525  * macroblock, regardless of its type, shall have an entry.
526  */
527 typedef struct _VAEncMacroblockParameterBufferH264 {
528     /**
529      * \brief Quantization parameter.
530      *
531      * Requested quantization parameter. Range: 0 to 51, inclusive.
532      * If \ref qp is set to 0xff, then the actual value is derived
533      * from the slice-level value: \c pic_init_qp + \c slice_qp_delta.
534      */
535     unsigned char   qp;
536
537     union {
538         /** @name Data for intra macroblock */
539         /**@{*/
540         struct {
541             union {
542                 /**
543                  * \brief Flag specified to override MB neighbour
544                  * availability bits from VME stage.
545                  *
546                  * This flag specifies that macroblock neighbour
547                  * availability bits from the VME stage are overriden
548                  * by the \ref pred_avail_flags hereunder.
549                  */
550                 unsigned int    pred_avail_override_flag        : 1;
551                 /**
552                  * \brief Bitwise representation of which macroblocks
553                  * are available for intra prediction.
554                  *
555                  * If the slice is intra-coded, this field represents
556                  * the macroblocks available for intra prediction.
557                  * See \ref api_enc_h264_mb_pred_avail_bits
558                  * "macroblock neighbour availability" bit definitions.
559                  */
560                 unsigned int    pred_avail_flags                : 8;
561             } bits;
562             unsigned int value;
563         } intra_fields;
564         /**@}*/
565
566         /** @name Data for inter macroblock */
567         /**@{*/
568         struct {
569             union {
570             } bits;
571             unsigned int value;
572         } inter_fields;
573         /**@}*/
574     } info;
575 } VAEncMacroblockParameterBufferH264;
576
577 /** \brief Bitstream writer attribute types specific to H.264 encoding. */
578 typedef enum {
579     /**
580      * \brief Flag: specifies whether to insert emulation prevention
581      * bytes (integer).
582      */
583     VAEncBitstreamAttribEmulationPreventionH264 = (
584         VAEncBitstreamAttribMiscMask | 1),
585 } VAEncBitstreamAttribTypeH264;
586
587 /**
588  * \brief Allocates a new H.264 bitstream writer.
589  *
590  * Allocates a new bitstream writer. By default, libva allocates and
591  * maintains its own buffer. However, the user can pass down his own
592  * buffer with the \c VAEncBitstreamAttribBuffer attribute, along with
593  * the size of that buffer with the \c VAEncBitstreamAttribBufferSize
594  * attribute.
595  *
596  * By default, emulation prevention bytes are not inserted. However,
597  * the user can still request emulation prevention by setting the
598  * \c VAEncBitstreamAttribEmulationPreventionH264 attribute to 1.
599  *
600  * @param[in] attribs       the optional attributes, or NULL
601  * @param[in] num_attribs   the number of attributes available in \c attribs
602  * @return a new #VAEncBitstream, or NULL if an error occurred
603  */
604 VAEncBitstream *
605 va_enc_bitstream_h264_new(
606     VAEncBitstreamAttrib *attribs,
607     unsigned int          num_attribs
608 );
609
610 /**
611  * \brief Destroys an H.264 bitstream writer.
612  *
613  * @param[in] bs            the bitstream writer to destroy
614  */
615 void
616 va_enc_bitstream_h264_destroy(VAEncBitstream *bs);
617
618 /**
619  * \brief Writes an unsigned integer as \c ue(v).
620  *
621  * Writes a 32-bit unsigned int value by following \c ue(v) from the
622  * H.264 specification.
623  *
624  * @param[in] bs            the bitstream writer
625  * @param[in] value         the unsigned int value
626  * @return the number of bits written, or a negative value to indicate an error
627  */
628 int
629 va_enc_bitstream_h264_write_ue(VAEncBitstream *bs, unsigned int value);
630
631 /**
632  * \brief Writes a signed integer as \c se(v).
633  *
634  * Writes a 32-bit signed int value by following \c se(v) from the
635  * H.264 specification.
636  *
637  * @param[in] bs            the bitstream writer
638  * @param[in] value         the signed int value
639  * @return the number of bits written, or a negative value to indicate an error
640  */
641 int
642 va_enc_bitstream_h264_write_se(VAEncBitstream *bs, int value);
643
644 /**
645  * \brief Helper function to write trailing bits into the bitstream.
646  *
647  * @param[in] bs            the bitstream writer
648  * @return the number of bits written, or a negative value to indicate an error
649  */
650 int
651 va_enc_bitstream_h264_write_trailing_bits(VAEncBitstream *bs);
652
653 /**@}*/
654
655 #ifdef __cplusplus
656 }
657 #endif
658
659 #endif /* VA_ENC_H264_H */