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 Core encoding API
29 * This file contains the \ref api_enc_core "Core encoding API".
42 * \defgroup api_enc_core Core encoding API
47 /** \brief Abstract representation of a bitstream writer. */
48 typedef struct _VAEncBitstream VAEncBitstream;
53 * Those flags flags are meant to signal when a picture marks the end
54 * of a sequence, a stream, or even both at once.
59 * \brief Marks the last picture in the sequence.
62 #define VA_ENC_LAST_PICTURE_EOSEQ 0x01
64 * \brief Marks the last picture in the stream.
67 #define VA_ENC_LAST_PICTURE_EOSTREAM 0x02
71 /** @name The set of all possible error codes */
73 /** \brief An invalid bitstream writer handle was supplied. */
74 #define VA_ENC_STATUS_ERROR_INVALID_BITSTREAM_WRITER (-1)
75 /** \brief An invalid/unsupported parameter value was supplied. */
76 #define VA_ENC_STATUS_ERROR_INVALID_VALUE (-2)
77 /** \brief A buffer overflow has occurred. */
78 #define VA_ENC_STATUS_ERROR_BUFFER_OVERFLOW (-3)
81 typedef int (*VAEncBitstreamFlushFunc)(
83 unsigned char *buffer,
84 unsigned int buffer_size
87 /** \brief Bitstream writer attribute types. */
90 * \brief User-provided buffer to hold output bitstream (pointer).
92 * If this attribute is provided, then \c VAencBitstreamAttribBufferSize
93 * shall also be supplied or va_enc_bitstream_new() will ignore that
94 * attribute and allocate its own buffer.
96 VAEncBitstreamAttribBuffer = 1,
97 /** \brief Size of the user-provided buffer (integer). */
98 VAEncBitstreamAttribBufferSize = 2,
99 /** \brief User-provided \c flush() callback (pointer-to-function). */
100 VAEncBitstreamAttribFlushFunc = 3,
101 /** \brief Placeholder for codec-specific attributes. */
102 VAEncBitstreamAttribMiscMask = 0x80000000
103 } VAEncBitstreamAttribType;
105 /** \brief Bitstream writer attribute value. */
107 /** \brief Attribute type (#VAEncBitstreamAttribType). */
108 VAEncBitstreamAttribType type;
109 /** \brief Attribute value (#VAGenericValue). */
110 VAGenericValue value;
111 } VAEncBitstreamAttrib;
114 * \brief Allocates a new bitstream writer.
116 * Allocates a new bitstream writer. By default, libva allocates and
117 * maintains its own buffer. However, the user can pass down his own
118 * buffer with the \c VAEncBitstreamAttribBuffer attribute, along with
119 * the size of that buffer with the \c VAEncBitstreamAttribBufferSize
122 * @param[in] attribs the optional attributes, or NULL
123 * @param[in] num_attribs the number of attributes available in \c attribs
124 * @return a new #VAEncBitstream, or NULL if an error occurred
127 va_enc_bitstream_new(VAEncBitstreamAttrib *attribs, unsigned int num_attribs);
130 * \brief Destroys a bitstream writer.
132 * @param[in] bs the bitstream writer to destroy
135 va_enc_bitstream_destroy(VAEncBitstream *bs);
138 * \brief Writes an unsigned integer.
140 * Writes an unsigned int value of the specified length in bits. The
141 * value is implicitly zero-extended to the number of specified bits.
143 * @param[in] bs the bitstream writer
144 * @param[in] value the unsigned int value to write
145 * @param[in] length the length (in bits) of the value
146 * @return the number of bits written, or a negative value to indicate an error
149 va_enc_bitstream_write_ui(VAEncBitstream *bs, unsigned int value, int length);
152 * \brief Writes a signed integer.
154 * Writes a signed int value of the specified length in bits. The
155 * value is implicitly sign-extended to the number of specified bits.
157 * @param[in] bs the bitstream writer
158 * @param[in] value the signed int value to write
159 * @param[in] length the length (in bits) of the value
160 * @return the number of bits written, or a negative value to indicate an error
163 va_enc_bitstream_write_si(VAEncBitstream *bs, int value, int length);
166 /* XXX: expose such API? */
168 va_enc_bitstream_skip(VAEncBitstream *bs, unsigned int length);
172 * \brief Byte aligns the bitstream.
174 * Align the bitstream to next byte boundary, while filling in bits
175 * with the specified value (0 or 1).
177 * @param[in] bs the bitstream writer
178 * @param[in] value the bit filler value (0 or 1)
179 * @return the number of bits written, or a negative value to indicate an error
182 va_enc_bitstream_align(VAEncBitstream *bs, unsigned int value);
185 * \brief Flushes the bitstream.
187 * Flushes the bitstream, while padding with zeroe's up to the next
188 * byte boundary. This functions resets the bitstream writer to its
189 * initial state. If the user provided a flush function through the
190 * \c VAEncBitstreamFlushFunc attribute, then his callback will be
193 * @param[in] bs the bitstream writer
194 * @return the number of bytes written, or a negative value to indicate an error
197 va_enc_bitstream_flush(VAEncBitstream *bs);
205 #endif /* VA_ENC_H */