2 * Copyright (c) 2007-2011 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 The H.264 encoding API
29 * This file contains the \ref api_enc_h264 "H.264 encoding API".
39 #include <va/va_enc.h>
42 * \defgroup api_enc_h264 H.264 encoding API
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.
56 * \brief Marks the last picture in the sequence.
58 * i.e. the driver appends \c end_of_seq() NAL unit to the encoded frame.
60 #define H264_LAST_PICTURE_EOSEQ VA_ENC_LAST_PICTURE_EOSEQ
62 * \brief Marks the last picture in the stream.
64 * i.e. the driver appends \c end_of_stream() NAL unit to the encoded frame.
66 #define H264_LAST_PICTURE_EOSTREAM VA_ENC_LAST_PICTURE_EOSTREAM
70 * \brief Packed header types specific to H.264 encoding.
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.
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,
83 * \brief Packed Sequence Parameter Set (SPS).
85 * The corresponding packed header data buffer shall contain the
86 * complete seq_parameter_set_rbsp() syntax element.
88 * Note: packed \c nal_unit_type shall be equal to 7.
90 VAEncPackedHeaderH264_SPS = VAEncPackedHeaderSequence,
92 * \brief Packed Picture Parameter Set (PPS).
94 * The corresponding packed header data buffer shall contain the
95 * complete pic_parameter_set_rbsp() syntax element.
97 * Note: packed \c nal_unit_type shall be equal to 8.
99 VAEncPackedHeaderH264_PPS = VAEncPackedHeaderPicture,
101 * \brief Packed slice header.
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().
109 * Note: packed \c nal_unit_type shall be equal to 1 (non-IDR
110 * picture), or 5 (IDR picture).
112 VAEncPackedHeaderH264_Slice = VAEncPackedHeaderSlice,
114 * \brief Packed Supplemental Enhancement Information (SEI).
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.
120 * Note: packed \c nal_unit_type shall be equal to 6.
122 VAEncPackedHeaderH264_SEI = (VAEncPackedHeaderMiscMask | 1),
123 } VAEncPackedHeaderTypeH264;
126 * \brief Sequence parameter for H.264 encoding in baseline, main & high
129 * This structure holds information for \c seq_parameter_set_data() as
130 * defined by the H.264 specification.
132 * If packed sequence headers mode is used, i.e. if the encoding
133 * pipeline was configured with the #VA_ENC_PACKED_HEADER_SEQUENCE
134 * flag, then the driver expects two more buffers to be provided to
135 * the same \c vaRenderPicture() as this buffer:
136 * - a #VAEncPackedHeaderParameterBuffer with type set to
137 * VAEncPackedHeaderType::VAEncPackedHeaderSequence ;
138 * - a #VAEncPackedHeaderDataBuffer which holds the actual packed
141 * If \c seq_scaling_matrix_present_flag is set to \c 1, then a
142 * #VAIQMatrixBufferH264 buffer shall also be provided within the same
143 * \c vaRenderPicture() call as this sequence parameter buffer.
145 typedef struct _VAEncSequenceParameterBufferH264 {
146 /** \brief Same as the H.264 bitstream syntax element. */
147 unsigned char seq_parameter_set_id;
148 /** \brief Same as the H.264 bitstream syntax element. */
149 unsigned char level_idc;
150 /** \brief Period between I frames. */
151 unsigned int intra_period;
152 /** \brief Period between IDR frames. */
153 unsigned int intra_idr_period;
154 /** \brief Period between I/P frames. */
155 unsigned int ip_period;
157 * \brief Initial bitrate set for this sequence in CBR or VBR modes.
159 * This field represents the initial bitrate value for this
160 * sequence if CBR or VBR mode is used, i.e. if the encoder
161 * pipeline was created with a #VAConfigAttribRateControl
162 * attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR.
164 * The bitrate can be modified later on through
165 * #VAEncMiscParameterRateControl buffers.
167 unsigned int bits_per_second;
168 /** \brief Same as the H.264 bitstream syntax element. */
169 unsigned int max_num_ref_frames;
170 /** \brief Picture width in macroblocks. */
171 unsigned short picture_width_in_mbs;
172 /** \brief Picture height in macroblocks. */
173 unsigned short picture_height_in_mbs;
177 /** \brief Same as the H.264 bitstream syntax element. */
178 unsigned int chroma_format_idc : 2;
179 /** \brief Same as the H.264 bitstream syntax element. */
180 unsigned int frame_mbs_only_flag : 1;
181 /** \brief Same as the H.264 bitstream syntax element. */
182 unsigned int mb_adaptive_frame_field_flag : 1;
183 /** \brief Same as the H.264 bitstream syntax element. */
184 unsigned int seq_scaling_matrix_present_flag : 1;
185 /** \brief Same as the H.264 bitstream syntax element. */
186 unsigned int direct_8x8_inference_flag : 1;
187 /** \brief Same as the H.264 bitstream syntax element. */
188 unsigned int log2_max_frame_num_minus4 : 4;
189 /** \brief Same as the H.264 bitstream syntax element. */
190 unsigned int pic_order_cnt_type : 2;
191 /** \brief Same as the H.264 bitstream syntax element. */
192 unsigned int log2_max_pic_order_cnt_lsb_minus4 : 4;
193 /** \brief Same as the H.264 bitstream syntax element. */
194 unsigned int delta_pic_order_always_zero_flag : 1;
199 /** \brief Same as the H.264 bitstream syntax element. */
200 unsigned char bit_depth_luma_minus8;
201 /** \brief Same as the H.264 bitstream syntax element. */
202 unsigned char bit_depth_chroma_minus8;
204 /** if pic_order_cnt_type == 1 */
206 /** \brief Same as the H.264 bitstream syntax element. */
207 unsigned char num_ref_frames_in_pic_order_cnt_cycle;
208 /** \brief Same as the H.264 bitstream syntax element. */
209 int offset_for_non_ref_pic;
210 /** \brief Same as the H.264 bitstream syntax element. */
211 int offset_for_top_to_bottom_field;
212 /** \brief Same as the H.264 bitstream syntax element. */
213 int offset_for_ref_frame[256];
216 /** @name Cropping (optional) */
218 /** \brief Same as the H.264 bitstream syntax element. */
219 unsigned char frame_cropping_flag;
220 /** \brief Same as the H.264 bitstream syntax element. */
221 unsigned int frame_crop_left_offset;
222 /** \brief Same as the H.264 bitstream syntax element. */
223 unsigned int frame_crop_right_offset;
224 /** \brief Same as the H.264 bitstream syntax element. */
225 unsigned int frame_crop_top_offset;
226 /** \brief Same as the H.264 bitstream syntax element. */
227 unsigned int frame_crop_bottom_offset;
230 /** @name VUI parameters (optional) */
232 /** \brief Same as the H.264 bitstream syntax element. */
233 unsigned char vui_parameters_present_flag;
236 /** \brief Same as the H.264 bitstream syntax element. */
237 unsigned int aspect_ratio_info_present_flag : 1;
238 /** \brief Same as the H.264 bitstream syntax element. */
239 unsigned int timing_info_present_flag : 1;
240 /** \brief Same as the H.264 bitstream syntax element. */
241 unsigned int bitstream_restriction_flag : 1;
242 /** \brief Range: 0 to 16, inclusive. */
243 unsigned int log2_max_mv_length_horizontal : 5;
244 /** \brief Range: 0 to 16, inclusive. */
245 unsigned int log2_max_mv_length_vertical : 5;
249 /** \brief Same as the H.264 bitstream syntax element. */
250 unsigned char aspect_ratio_idc;
251 /** \brief Same as the H.264 bitstream syntax element. */
252 unsigned int sar_width;
253 /** \brief Same as the H.264 bitstream syntax element. */
254 unsigned int sar_height;
255 /** \brief Same as the H.264 bitstream syntax element. */
256 unsigned int num_units_in_tick;
257 /** \brief Same as the H.264 bitstream syntax element. */
258 unsigned int time_scale;
260 } VAEncSequenceParameterBufferH264;
263 * \brief Picture parameter for H.264 encoding in baseline, main & high
266 * This structure holds information for \c pic_parameter_set_rbsp() as
267 * defined by the H.264 specification.
269 * If packed picture headers mode is used, i.e. if the encoding
270 * pipeline was configured with the #VA_ENC_PACKED_HEADER_PICTURE
271 * flag, then the driver expects two more buffers to be provided to
272 * the same \c vaRenderPicture() as this buffer:
273 * - a #VAEncPackedHeaderParameterBuffer with type set to
274 * VAEncPackedHeaderType::VAEncPackedHeaderPicture ;
275 * - a #VAEncPackedHeaderDataBuffer which holds the actual packed
278 * If \c pic_scaling_matrix_present_flag is set to \c 1, then a
279 * #VAIQMatrixBufferH264 buffer shall also be provided within the same
280 * \c vaRenderPicture() call as this picture parameter buffer.
282 typedef struct _VAEncPictureParameterBufferH264 {
284 * \brief Information about the picture to be encoded.
286 * See #VAPictureH264 for further description of each field.
287 * Note that CurrPic.picture_id represents the reconstructed
288 * (decoded) picture. User provides a scratch VA surface ID here.
290 VAPictureH264 CurrPic;
292 * \brief Decoded Picture Buffer (DPB).
294 * This array represents the list of reconstructed (decoded)
295 * frames used as reference. It is important to keep track of
296 * reconstructed frames so that they can be used later on as
297 * reference for P or B-frames encoding.
299 VAPictureH264 ReferenceFrames[16];
301 * \brief Output encoded bitstream.
303 * \ref coded_buf has type #VAEncCodedBufferType. It should be
304 * large enough to hold the compressed NAL slice and possibly SPS
307 VABufferID coded_buf;
309 /** \brief The picture parameter set referred to in the slice header. */
310 unsigned char pic_parameter_set_id;
311 /** \brief The active sequence parameter set. Range: 0 to 31, inclusive. */
312 unsigned char seq_parameter_set_id;
315 * \brief OR'd flags describing whether the picture is the last one or not.
317 * This fields holds 0 if the picture to be encoded is not the last
318 * one in the stream or sequence. Otherwise, it is a combination of
319 * \ref H264_LAST_PICTURE_EOSEQ or \ref H264_LAST_PICTURE_EOSTREAM.
321 unsigned char last_picture;
323 /** \brief The picture identifier.
324 * Range: 0 to \f$2^{log2\_max\_frame\_num\_minus4 + 4} - 1\f$, inclusive.
326 unsigned short frame_num;
328 /** \brief \c pic_init_qp_minus26 + 26. */
329 unsigned char pic_init_qp;
330 /** \brief Maximum reference index for reference picture list 0.
331 * Range: 0 to 31, inclusive.
333 unsigned char num_ref_idx_l0_active_minus1;
334 /** \brief Maximum reference index for reference picture list 1.
335 * Range: 0 to 31, inclusive.
337 unsigned char num_ref_idx_l1_active_minus1;
339 /** \brief Range: -12 to 12, inclusive. */
340 signed char chroma_qp_index_offset;
341 /** \brief Range: -12 to 12, inclusive. */
342 signed char second_chroma_qp_index_offset;
346 /** \brief Is picture an IDR picture? */
347 unsigned int idr_pic_flag : 1;
348 /** \brief Is picture a reference picture? */
349 unsigned int reference_pic_flag : 2;
350 /** \brief Selects CAVLC (0) or CABAC (1) entropy coding mode. */
351 unsigned int entropy_coding_mode_flag : 1;
352 /** \brief Is weighted prediction applied to P slices? */
353 unsigned int weighted_pred_flag : 1;
354 /** \brief Range: 0 to 2, inclusive. */
355 unsigned int weighted_bipred_idc : 2;
356 /** \brief Same as the H.264 bitstream syntax element. */
357 unsigned int constrained_intra_pred_flag : 1;
358 /** \brief Same as the H.264 bitstream syntax element. */
359 unsigned int transform_8x8_mode_flag : 1;
360 /** \brief Same as the H.264 bitstream syntax element. */
361 unsigned int deblocking_filter_control_present_flag : 1;
362 /** \brief Same as the H.264 bitstream syntax element. */
363 unsigned int redundant_pic_cnt_present_flag : 1;
364 /** \brief Same as the H.264 bitstream syntax element. */
365 unsigned int pic_order_present_flag : 1;
366 /** \brief Same as the H.264 bitstream syntax element. */
367 unsigned int pic_scaling_matrix_present_flag : 1;
371 } VAEncPictureParameterBufferH264;
374 * \brief Slice parameter for H.264 encoding in baseline, main & high profiles.
376 * This structure holds information for \c
377 * slice_layer_without_partitioning_rbsp() as defined by the H.264
380 * If packed slice headers mode is used, i.e. if the encoding
381 * pipeline was configured with the #VA_ENC_PACKED_HEADER_SLICE
382 * flag, then the driver expects two more buffers to be provided to
383 * the same \c vaRenderPicture() as this buffer:
384 * - a #VAEncPackedHeaderParameterBuffer with type set to
385 * VAEncPackedHeaderType::VAEncPackedHeaderSlice ;
386 * - a #VAEncPackedHeaderDataBuffer which holds the actual packed
389 * If per-macroblock encoder configuration is needed, \c macroblock_info
390 * references a buffer of type #VAEncMacroblockParameterBufferH264. This
391 * buffer is not passed to vaRenderPicture(). i.e. it is not destroyed
392 * by subsequent calls to vaRenderPicture() and then can be re-used
393 * without re-allocating the whole buffer.
395 typedef struct _VAEncSliceParameterBufferH264 {
396 /** \brief Starting MB address for this slice. */
397 unsigned int macroblock_address;
398 /** \brief Number of macroblocks in this slice. */
399 unsigned int num_macroblocks;
401 * \brief Per-MB encoder configuration buffer, or \c VA_INVALID_ID.
403 * If per-MB encoder configuration is needed, then \ref macroblock_info
404 * references a buffer of type #VAEncMacroblockParameterBufferH264
405 * (\c VAEncMacroblockParameterBufferType). Otherwise, buffer id
406 * is set to \c VA_INVALID_ID and per-MB configuration is derived
407 * from this slice parameter.
409 * The \c macroblock_info buffer must hold \ref num_macroblocks
412 VABufferID macroblock_info;
413 /** \brief Slice type.
414 * Range: 0..2, 5..7, i.e. no switching slices.
416 unsigned char slice_type;
417 /** \brief Same as the H.264 bitstream syntax element. */
418 unsigned char pic_parameter_set_id;
419 /** \brief Same as the H.264 bitstream syntax element. */
420 unsigned short idr_pic_id;
422 /** @name If pic_order_cnt_type == 0 */
424 /** \brief The picture order count modulo MaxPicOrderCntLsb. */
425 unsigned short pic_order_cnt_lsb;
426 /** \brief Valid if \c pic_order_present_flag and this is a bottom field. */
427 int delta_pic_order_cnt_bottom;
429 /** @name If pic_order_cnt_type == 1 && !delta_pic_order_always_zero_flag */
431 /** \brief [0]: top, [1]: bottom. */
432 int delta_pic_order_cnt[2];
435 /** @name If slice_type == B */
437 unsigned char direct_spatial_mv_pred_flag;
440 /** @name If slice_type == P */
442 /** \brief Specifies if
443 * \ref _VAEncPictureParameterBufferH264::num_ref_idx_l0_active_minus1 or
444 * \ref _VAEncPictureParameterBufferH264::num_ref_idx_l1_active_minus1 are
445 * overriden by the values for this slice.
447 unsigned char num_ref_idx_active_override_flag;
448 /** \brief Maximum reference index for reference picture list 0.
449 * Range: 0 to 31, inclusive.
451 unsigned char num_ref_idx_l0_active_minus1;
452 /** \brief Maximum reference index for reference picture list 1.
453 * Range: 0 to 31, inclusive.
455 unsigned char num_ref_idx_l1_active_minus1;
456 /** \brief Reference picture list 0 (for P slices). */
457 VAPictureH264 RefPicList0[32];
458 /** \brief Reference picture list 1 (for B slices). */
459 VAPictureH264 RefPicList1[32];
462 /** @name pred_weight_table() */
464 /** \brief Same as the H.264 bitstream syntax element. */
465 unsigned char luma_log2_weight_denom;
466 /** \brief Same as the H.264 bitstream syntax element. */
467 unsigned char chroma_log2_weight_denom;
468 /** \brief Same as the H.264 bitstream syntax element. */
469 unsigned char luma_weight_l0_flag;
470 /** \brief Same as the H.264 bitstream syntax element. */
471 signed short luma_weight_l0[32];
472 /** \brief Same as the H.264 bitstream syntax element. */
473 signed short luma_offset_l0[32];
474 /** \brief Same as the H.264 bitstream syntax element. */
475 unsigned char chroma_weight_l0_flag;
476 /** \brief Same as the H.264 bitstream syntax element. */
477 signed short chroma_weight_l0[32][2];
478 /** \brief Same as the H.264 bitstream syntax element. */
479 signed short chroma_offset_l0[32][2];
480 /** \brief Same as the H.264 bitstream syntax element. */
481 unsigned char luma_weight_l1_flag;
482 /** \brief Same as the H.264 bitstream syntax element. */
483 signed short luma_weight_l1[32];
484 /** \brief Same as the H.264 bitstream syntax element. */
485 signed short luma_offset_l1[32];
486 /** \brief Same as the H.264 bitstream syntax element. */
487 unsigned char chroma_weight_l1_flag;
488 /** \brief Same as the H.264 bitstream syntax element. */
489 signed short chroma_weight_l1[32][2];
490 /** \brief Same as the H.264 bitstream syntax element. */
491 signed short chroma_offset_l1[32][2];
494 /** \brief Range: 0 to 2, inclusive. */
495 unsigned char cabac_init_idc;
496 /** \brief Same as the H.264 bitstream syntax element. */
497 signed char slice_qp_delta;
498 /** @name If deblocking_filter_control_present_flag */
500 /** \brief Range: 0 to 2, inclusive. */
501 unsigned char disable_deblocking_filter_idc;
502 /** \brief Same as the H.264 bitstream syntax element. */
503 signed char slice_alpha_c0_offset_div2;
504 /** \brief Same as the H.264 bitstream syntax element. */
505 signed char slice_beta_offset_div2;
507 } VAEncSliceParameterBufferH264;
510 * @name Macroblock neighbour availability bits
512 * \anchor api_enc_h264_mb_pred_avail_bits
513 * Definitions for macroblock neighbour availability bits used in
514 * intra prediction mode (non MBAFF only).
518 /** \brief References macroblock in the top-left corner. */
519 #define VA_MB_PRED_AVAIL_TOP_LEFT (1 << 2)
520 /** \brief References macroblock above the current macroblock. */
521 #define VA_MB_PRED_AVAIL_TOP (1 << 4)
522 /** \brief References macroblock in the top-right corner. */
523 #define VA_MB_PRED_AVAIL_TOP_RIGHT (1 << 3)
524 /** \brief References macroblock on the left of the current macroblock. */
525 #define VA_MB_PRED_AVAIL_LEFT (1 << 6)
529 * \brief Macroblock parameter for H.264 encoding in baseline, main & high
532 * This structure holds per-macroblock information. The buffer must be
533 * allocated with as many elements (macroblocks) as necessary to fit
534 * the slice to be encoded. Besides, the per-macroblock records must
535 * be written in a strict raster order and with no gap. i.e. every
536 * macroblock, regardless of its type, shall have an entry.
538 typedef struct _VAEncMacroblockParameterBufferH264 {
540 * \brief Quantization parameter.
542 * Requested quantization parameter. Range: 0 to 51, inclusive.
543 * If \ref qp is set to 0xff, then the actual value is derived
544 * from the slice-level value: \c pic_init_qp + \c slice_qp_delta.
549 /** @name Data for intra macroblock */
554 * \brief Flag specified to override MB neighbour
555 * availability bits from VME stage.
557 * This flag specifies that macroblock neighbour
558 * availability bits from the VME stage are overriden
559 * by the \ref pred_avail_flags hereunder.
561 unsigned int pred_avail_override_flag : 1;
563 * \brief Bitwise representation of which macroblocks
564 * are available for intra prediction.
566 * If the slice is intra-coded, this field represents
567 * the macroblocks available for intra prediction.
568 * See \ref api_enc_h264_mb_pred_avail_bits
569 * "macroblock neighbour availability" bit definitions.
571 unsigned int pred_avail_flags : 8;
577 /** @name Data for inter macroblock */
586 } VAEncMacroblockParameterBufferH264;
588 /** \brief Bitstream writer attribute types specific to H.264 encoding. */
591 * \brief Flag: specifies whether to insert emulation prevention
594 VAEncBitstreamAttribEmulationPreventionH264 = (
595 VAEncBitstreamAttribMiscMask | 1),
596 } VAEncBitstreamAttribTypeH264;
599 * \brief Allocates a new H.264 bitstream writer.
601 * Allocates a new bitstream writer. By default, libva allocates and
602 * maintains its own buffer. However, the user can pass down his own
603 * buffer with the \c VAEncBitstreamAttribBuffer attribute, along with
604 * the size of that buffer with the \c VAEncBitstreamAttribBufferSize
607 * By default, emulation prevention bytes are not inserted. However,
608 * the user can still request emulation prevention by setting the
609 * \c VAEncBitstreamAttribEmulationPreventionH264 attribute to 1.
611 * @param[in] attribs the optional attributes, or NULL
612 * @param[in] num_attribs the number of attributes available in \c attribs
613 * @return a new #VAEncBitstream, or NULL if an error occurred
616 va_enc_bitstream_h264_new(
617 VAEncBitstreamAttrib *attribs,
618 unsigned int num_attribs
622 * \brief Destroys an H.264 bitstream writer.
624 * @param[in] bs the bitstream writer to destroy
627 va_enc_bitstream_h264_destroy(VAEncBitstream *bs);
630 * \brief Writes an unsigned integer as \c ue(v).
632 * Writes a 32-bit unsigned int value by following \c ue(v) from the
633 * H.264 specification.
635 * @param[in] bs the bitstream writer
636 * @param[in] value the unsigned int value
637 * @return the number of bits written, or a negative value to indicate an error
640 va_enc_bitstream_h264_write_ue(VAEncBitstream *bs, unsigned int value);
643 * \brief Writes a signed integer as \c se(v).
645 * Writes a 32-bit signed int value by following \c se(v) from the
646 * H.264 specification.
648 * @param[in] bs the bitstream writer
649 * @param[in] value the signed int value
650 * @return the number of bits written, or a negative value to indicate an error
653 va_enc_bitstream_h264_write_se(VAEncBitstream *bs, int value);
656 * \brief Helper function to write trailing bits into the bitstream.
658 * @param[in] bs the bitstream writer
659 * @return the number of bits written, or a negative value to indicate an error
662 va_enc_bitstream_h264_write_trailing_bits(VAEncBitstream *bs);
670 #endif /* VA_ENC_H264_H */