1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #ifndef AVCODEC_VAAPI_ENCODE_H
20 #define AVCODEC_VAAPI_ENCODE_H
21
22 #include <stdint.h>
23
24 #include <va/va.h>
25
28
30
33
34 enum {
40 };
41
42 enum {
47 };
48
54
57
61
66
69
72
75
78
81
84
88
91
92 // Codec-specific hooks.
94
95 // Encoding profile (VAProfileXXX).
97 // Encoding entrypoint (usually VAEntryointEncSlice).
99 // Surface colour/sampling format (usually VA_RT_FORMAT_YUV420).
101 // Rate control mode.
103 // Supported packed headers (initially the desired set, modified
104 // later to what is actually supported).
106
107 // The required size of surfaces. This is probably the input
108 // size (AVCodecContext.width|height) aligned up to whatever
109 // block size is required by the codec.
112
113 // Everything above this point must be set before calling
114 // ff_vaapi_encode_init().
115
116 // Codec-specific state.
118
119 // Configuration attributes to use when creating va_config.
122
125
129
130 // The hardware frame context containing the input frames.
133
134 // The hardware frame context containing the reconstructed frames.
137
138 // Pool of (reusable) bitstream output buffers.
140
141 // Global parameters which will be applied at the start of the
142 // sequence (includes rate control parameters below).
146
147 // Rate control parameters.
148 struct {
150 VAEncMiscParameterRateControl
rc;
152 struct {
153 VAEncMiscParameterBuffer
misc;
154 VAEncMiscParameterHRD
hrd;
156 struct {
157 VAEncMiscParameterBuffer
misc;
158 VAEncMiscParameterFrameRate
fr;
160 #if VA_CHECK_VERSION(0, 36, 0)
161 struct {
162 VAEncMiscParameterBuffer
misc;
163 VAEncMiscParameterBufferQualityLevel quality;
164 } quality_params;
165 #endif
166
167 // Per-sequence parameter structure (VAEncSequenceParameterBuffer*).
169
170 // Per-sequence parameters found in the per-picture parameter
171 // structure (VAEncPictureParameterBuffer*).
173
174 // Current encoding window, in display (input) order.
176
177 // Next input order index (display order).
179 // Number of frames that output is behind input.
181 // Number of frames decode output will need to be delayed.
183 // Next output order index (encode order).
185
186 enum {
187 // All encode operations are done independently (synchronise
188 // immediately after every operation).
190 // Overlap as many operations as possible.
192 // Overlap operations only when satisfying parallel dependencies.
195
196 // Timestamp handling.
200
201 // Frame type decision.
208
209 // Codec-local options are allocated to follow this structure in
210 // memory (in the AVCodec definition, set priv_data_size to
211 // sizeof(VAAPIEncodeContext) + sizeof(VAAPIEncodeFooOptions)).
215
216
219
220 // Perform any extra codec-specific configuration after the
221 // codec context is initialised (set up the private data and
222 // add any necessary global parameters).
224
225 // The size of the parameter structures:
226 // sizeof(VAEnc{type}ParameterBuffer{codec}).
230
231 // Fill the parameter structures.
238
239 // The type used by the packed header: this should look like
240 // VAEncPackedHeader{something}.
244
245 // Write the packed header data to the provided buffer.
246 // The sequence header is also used to fill the codec extradata
247 // when the encoder is starting.
249 char *
data,
size_t *data_len);
252 char *
data,
size_t *data_len);
256 char *
data,
size_t *data_len);
257
258 // Fill an extra parameter structure, which will then be
259 // passed to vaRenderPicture(). Will be called repeatedly
260 // with increasing index argument until AVERROR_EOF is
261 // returned.
265 char *
data,
size_t *data_len);
266
267 // Write an extra packed header. Will be called repeatedly
268 // with increasing index argument until AVERROR_EOF is
269 // returned.
273 char *
data,
size_t *data_len);
275
276
278 const AVFrame *input_image,
int *got_packet);
279
282
283 #endif /* AVCODEC_VAAPI_ENCODE_H */
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
VASurfaceID input_surface
VAEncMiscParameterBuffer misc
This structure describes decoded (raw) audio or video data.
VAEntrypoint va_entrypoint
ptrdiff_t const GLvoid * data
char codec_options_data[0]
int(* write_slice_header)(AVCodecContext *avctx, VAAPIEncodePicture *pic, VAAPIEncodeSlice *slice, char *data, size_t *data_len)
void * codec_sequence_params
AVBufferRef * input_frames_ref
VAEncMiscParameterHRD hrd
size_t picture_params_size
AVHWDeviceContext * device
struct VAAPIEncodeContext::@129 hrd_params
API-specific header for AV_HWDEVICE_TYPE_VAAPI.
unsigned int va_packed_headers
VAEncMiscParameterFrameRate fr
int(* write_picture_header)(AVCodecContext *avctx, VAAPIEncodePicture *pic, char *data, size_t *data_len)
AVBufferRef * output_buffer_ref
VABufferID * param_buffers
VASurfaceID recon_surface
int ff_vaapi_encode_init(AVCodecContext *avctx)
VAConfigAttrib config_attributes[MAX_CONFIG_ATTRIBUTES]
AVHWFramesContext * input_frames
VAEncMiscParameterBuffer * global_params[MAX_GLOBAL_PARAMS]
int(* configure)(AVCodecContext *avctx)
int ff_vaapi_encode_close(AVCodecContext *avctx)
int(* init_picture_params)(AVCodecContext *avctx, VAAPIEncodePicture *pic)
void * codec_picture_params
int(* write_extra_header)(AVCodecContext *avctx, VAAPIEncodePicture *pic, int index, int *type, char *data, size_t *data_len)
AVHWFramesContext * recon_frames
VAAPIEncodeSlice * slices
unsigned int va_rt_format
struct VAAPIEncodePicture * next
void * codec_picture_params
int64_t ts_ring[MAX_REORDER_DELAY *3]
AVBufferPool * output_buffer_pool
int(* write_sequence_header)(AVCodecContext *avctx, char *data, size_t *data_len)
struct VAAPIEncodePicture * refs[MAX_PICTURE_REFERENCES]
int ff_vaapi_encode2(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *input_image, int *got_packet)
const struct VAAPIEncodeType * codec
Libavcodec external API header.
VAAPIEncodePicture * pic_start
main external API structure.
int(* write_extra_buffer)(AVCodecContext *avctx, VAAPIEncodePicture *pic, int index, int *type, char *data, size_t *data_len)
Describe the class of an AVClass context structure.
This struct describes a set or pool of "hardware" frames (i.e.
AVBufferRef * recon_frames_ref
VAAPIEncodePicture * pic_end
size_t global_params_size[MAX_GLOBAL_PARAMS]
VAEncMiscParameterRateControl rc
A reference to a data buffer.
size_t sequence_params_size
void * codec_slice_params
int(* init_slice_params)(AVCodecContext *avctx, VAAPIEncodePicture *pic, VAAPIEncodeSlice *slice)
VAAPI connection details.
enum VAAPIEncodeContext::@131 issue_mode
int(* init_sequence_params)(AVCodecContext *avctx)
struct VAAPIEncodeContext::@128 rc_params
This structure stores compressed data.
struct VAAPIEncodeContext::@130 fr_params
AVVAAPIDeviceContext * hwctx