Browse code

lavc: VAAPI H.264 encoder

Signed-off-by: Anton Khirnov <anton@khirnov.net>

Mark Thompson authored on 2016/03/24 08:49:35
Showing 8 changed files
... ...
@@ -53,6 +53,7 @@ version <next>:
53 53
 - compressed SWF
54 54
 - VAAPI-accelerated format conversion and scaling
55 55
 - libnpp/CUDA-accelerated format conversion and scaling
56
+- VAAPI-accelerate H.264 encoding
56 57
 
57 58
 
58 59
 version 11:
... ...
@@ -1956,6 +1956,8 @@ h264_qsv_decoder_deps="libmfx"
1956 1956
 h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser qsvdec h264_qsv_hwaccel"
1957 1957
 h264_qsv_encoder_deps="libmfx"
1958 1958
 h264_qsv_encoder_select="qsvenc"
1959
+h264_vaapi_encoder_deps="VAEncPictureParameterBufferH264"
1960
+h264_vaapi_encoder_select="vaapi_encode golomb"
1959 1961
 hap_decoder_select="snappy texturedsp"
1960 1962
 hap_encoder_deps="libsnappy"
1961 1963
 hap_encoder_select="texturedspenc"
... ...
@@ -4467,6 +4469,7 @@ check_type "windows.h d3d11.h" "ID3D11VideoDecoder"
4467 4467
 check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602
4468 4468
 
4469 4469
 check_type "va/va.h va/va_vpp.h" "VAProcPipelineParameterBuffer"
4470
+check_type "va/va.h va/va_enc_h264.h" "VAEncPictureParameterBufferH264"
4470 4471
 
4471 4472
 check_type "vdpau/vdpau.h" "VdpPictureInfoHEVC"
4472 4473
 
... ...
@@ -259,6 +259,7 @@ OBJS-$(CONFIG_H264_MMAL_DECODER)       += mmaldec.o
259 259
 OBJS-$(CONFIG_H264_NVENC_ENCODER)      += nvenc_h264.o
260 260
 OBJS-$(CONFIG_H264_QSV_DECODER)        += qsvdec_h2645.o
261 261
 OBJS-$(CONFIG_H264_QSV_ENCODER)        += qsvenc_h264.o
262
+OBJS-$(CONFIG_H264_VAAPI_ENCODER)      += vaapi_encode_h264.o vaapi_encode_h26x.o
262 263
 OBJS-$(CONFIG_HAP_DECODER)             += hapdec.o hap.o
263 264
 OBJS-$(CONFIG_HAP_ENCODER)             += hapenc.o hap.o
264 265
 OBJS-$(CONFIG_HEVC_DECODER)            += hevc.o hevc_mvs.o hevc_ps.o hevc_sei.o \
... ...
@@ -166,6 +166,7 @@ void avcodec_register_all(void)
166 166
     REGISTER_DECODER(H264,              h264);
167 167
     REGISTER_DECODER(H264_MMAL,         h264_mmal);
168 168
     REGISTER_DECODER(H264_QSV,          h264_qsv);
169
+    REGISTER_ENCODER(H264_VAAPI,        h264_vaapi);
169 170
     REGISTER_ENCDEC (HAP,               hap);
170 171
     REGISTER_DECODER(HEVC,              hevc);
171 172
     REGISTER_DECODER(HEVC_QSV,          hevc_qsv);
172 173
new file mode 100644
... ...
@@ -0,0 +1,847 @@
0
+/*
1
+ * This file is part of Libav.
2
+ *
3
+ * Libav is free software; you can redistribute it and/or
4
+ * modify it under the terms of the GNU Lesser General Public
5
+ * License as published by the Free Software Foundation; either
6
+ * version 2.1 of the License, or (at your option) any later version.
7
+ *
8
+ * Libav is distributed in the hope that it will be useful,
9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
+ * Lesser General Public License for more details.
12
+ *
13
+ * You should have received a copy of the GNU Lesser General Public
14
+ * License along with Libav; if not, write to the Free Software
15
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+ */
17
+
18
+#include <va/va.h>
19
+#include <va/va_enc_h264.h>
20
+
21
+#include "libavutil/avassert.h"
22
+#include "libavutil/internal.h"
23
+#include "libavutil/opt.h"
24
+#include "libavutil/pixfmt.h"
25
+
26
+#include "avcodec.h"
27
+#include "h264.h"
28
+#include "internal.h"
29
+#include "vaapi_encode.h"
30
+#include "vaapi_encode_h26x.h"
31
+
32
+enum {
33
+    SLICE_TYPE_P  = 0,
34
+    SLICE_TYPE_B  = 1,
35
+    SLICE_TYPE_I  = 2,
36
+    SLICE_TYPE_SP = 3,
37
+    SLICE_TYPE_SI = 4,
38
+};
39
+
40
+// This structure contains all possibly-useful per-sequence syntax elements
41
+// which are not already contained in the various VAAPI structures.
42
+typedef struct VAAPIEncodeH264MiscSequenceParams {
43
+    unsigned int profile_idc;
44
+    char constraint_set0_flag;
45
+    char constraint_set1_flag;
46
+    char constraint_set2_flag;
47
+    char constraint_set3_flag;
48
+    char constraint_set4_flag;
49
+    char constraint_set5_flag;
50
+
51
+    char separate_colour_plane_flag;
52
+    char qpprime_y_zero_transform_bypass_flag;
53
+
54
+    char gaps_in_frame_num_allowed_flag;
55
+    char delta_pic_order_always_zero_flag;
56
+    char bottom_field_pic_order_in_frame_present_flag;
57
+
58
+    unsigned int num_slice_groups_minus1;
59
+    unsigned int slice_group_map_type;
60
+
61
+    int pic_init_qs_minus26;
62
+
63
+    char vui_parameters_present_flag;
64
+} VAAPIEncodeH264MiscSequenceParams;
65
+
66
+// This structure contains all possibly-useful per-slice syntax elements
67
+// which are not already contained in the various VAAPI structures.
68
+typedef struct VAAPIEncodeH264MiscSliceParams {
69
+    unsigned int nal_unit_type;
70
+    unsigned int nal_ref_idc;
71
+
72
+    unsigned int colour_plane_id;
73
+    char field_pic_flag;
74
+    char bottom_field_flag;
75
+
76
+    unsigned int redundant_pic_cnt;
77
+
78
+    char sp_for_switch_flag;
79
+    int slice_qs_delta;
80
+
81
+    char ref_pic_list_modification_flag_l0;
82
+    char ref_pic_list_modification_flag_l1;
83
+
84
+    char no_output_of_prior_pics_flag;
85
+    char long_term_reference_flag;
86
+    char adaptive_ref_pic_marking_mode_flag;
87
+} VAAPIEncodeH264MiscSliceParams;
88
+
89
+typedef struct VAAPIEncodeH264Slice {
90
+    VAAPIEncodeH264MiscSliceParams misc_slice_params;
91
+} VAAPIEncodeH264Slice;
92
+
93
+typedef struct VAAPIEncodeH264Context {
94
+    VAAPIEncodeH264MiscSequenceParams misc_sequence_params;
95
+
96
+    int mb_width;
97
+    int mb_height;
98
+
99
+    int fixed_qp_idr;
100
+    int fixed_qp_p;
101
+    int fixed_qp_b;
102
+
103
+    int64_t idr_pic_count;
104
+    int64_t last_idr_frame;
105
+
106
+    // RefPicList management.
107
+} VAAPIEncodeH264Context;
108
+
109
+
110
+#define vseq_var(name)     vseq->name, name
111
+#define vseq_field(name)   vseq->seq_fields.bits.name, name
112
+#define vpic_var(name)     vpic->name, name
113
+#define vpic_field(name)   vpic->pic_fields.bits.name, name
114
+#define vslice_var(name)   vslice->name, name
115
+#define vslice_field(name) vslice->slice_fields.bits.name, name
116
+#define mseq_var(name)     mseq->name, name
117
+#define mslice_var(name)   mslice->name, name
118
+
119
+static void vaapi_encode_h264_write_nal_header(PutBitContext *pbc,
120
+                                               int nal_unit_type, int nal_ref_idc)
121
+{
122
+    u(1, 0, forbidden_zero_bit);
123
+    u(2, nal_ref_idc, nal_ref_idc);
124
+    u(5, nal_unit_type, nal_unit_type);
125
+}
126
+
127
+static void vaapi_encode_h264_write_trailing_rbsp(PutBitContext *pbc)
128
+{
129
+    u(1, 1, rbsp_stop_one_bit);
130
+    while (put_bits_count(pbc) & 7)
131
+        u(1, 0, rbsp_alignment_zero_bit);
132
+}
133
+
134
+static void vaapi_encode_h264_write_sps(PutBitContext *pbc,
135
+                                        VAAPIEncodeContext *ctx)
136
+{
137
+    VAEncSequenceParameterBufferH264  *vseq = ctx->codec_sequence_params;
138
+    VAAPIEncodeH264Context            *priv = ctx->priv_data;
139
+    VAAPIEncodeH264MiscSequenceParams *mseq = &priv->misc_sequence_params;
140
+    int i;
141
+
142
+    vaapi_encode_h264_write_nal_header(pbc, NAL_SPS, 3);
143
+
144
+    u(8, mseq_var(profile_idc));
145
+    u(1, mseq_var(constraint_set0_flag));
146
+    u(1, mseq_var(constraint_set1_flag));
147
+    u(1, mseq_var(constraint_set2_flag));
148
+    u(1, mseq_var(constraint_set3_flag));
149
+    u(1, mseq_var(constraint_set4_flag));
150
+    u(1, mseq_var(constraint_set5_flag));
151
+    u(2, 0, reserved_zero_2bits);
152
+
153
+    u(8, vseq_var(level_idc));
154
+
155
+    ue(vseq_var(seq_parameter_set_id));
156
+
157
+    if (mseq->profile_idc == 100 || mseq->profile_idc == 110 ||
158
+        mseq->profile_idc == 122 || mseq->profile_idc == 244 ||
159
+        mseq->profile_idc ==  44 || mseq->profile_idc ==  83 ||
160
+        mseq->profile_idc ==  86 || mseq->profile_idc == 118 ||
161
+        mseq->profile_idc == 128 || mseq->profile_idc == 138) {
162
+        ue(vseq_field(chroma_format_idc));
163
+
164
+        if (vseq->seq_fields.bits.chroma_format_idc == 3)
165
+            u(1, mseq_var(separate_colour_plane_flag));
166
+
167
+        ue(vseq_var(bit_depth_luma_minus8));
168
+        ue(vseq_var(bit_depth_chroma_minus8));
169
+
170
+        u(1, mseq_var(qpprime_y_zero_transform_bypass_flag));
171
+
172
+        u(1, vseq_field(seq_scaling_matrix_present_flag));
173
+        if (vseq->seq_fields.bits.seq_scaling_matrix_present_flag) {
174
+            av_assert0(0 && "scaling matrices not supported");
175
+        }
176
+    }
177
+
178
+    ue(vseq_field(log2_max_frame_num_minus4));
179
+    ue(vseq_field(pic_order_cnt_type));
180
+
181
+    if (vseq->seq_fields.bits.pic_order_cnt_type == 0) {
182
+        ue(vseq_field(log2_max_pic_order_cnt_lsb_minus4));
183
+    } else if (vseq->seq_fields.bits.pic_order_cnt_type == 1) {
184
+        u(1, mseq_var(delta_pic_order_always_zero_flag));
185
+        se(vseq_var(offset_for_non_ref_pic));
186
+        se(vseq_var(offset_for_top_to_bottom_field));
187
+        ue(vseq_var(num_ref_frames_in_pic_order_cnt_cycle));
188
+
189
+        for (i = 0; i < vseq->num_ref_frames_in_pic_order_cnt_cycle; i++)
190
+            se(vseq_var(offset_for_ref_frame[i]));
191
+    }
192
+
193
+    ue(vseq_var(max_num_ref_frames));
194
+    u(1, mseq_var(gaps_in_frame_num_allowed_flag));
195
+
196
+    ue(vseq->picture_width_in_mbs  - 1, pic_width_in_mbs_minus1);
197
+    ue(vseq->picture_height_in_mbs - 1, pic_height_in_mbs_minus1);
198
+
199
+    u(1, vseq_field(frame_mbs_only_flag));
200
+    if (!vseq->seq_fields.bits.frame_mbs_only_flag)
201
+        u(1, vseq_field(mb_adaptive_frame_field_flag));
202
+
203
+    u(1, vseq_field(direct_8x8_inference_flag));
204
+
205
+    u(1, vseq_var(frame_cropping_flag));
206
+    if (vseq->frame_cropping_flag) {
207
+        ue(vseq_var(frame_crop_left_offset));
208
+        ue(vseq_var(frame_crop_right_offset));
209
+        ue(vseq_var(frame_crop_top_offset));
210
+        ue(vseq_var(frame_crop_bottom_offset));
211
+    }
212
+
213
+    u(1, mseq_var(vui_parameters_present_flag));
214
+
215
+    vaapi_encode_h264_write_trailing_rbsp(pbc);
216
+}
217
+
218
+static void vaapi_encode_h264_write_pps(PutBitContext *pbc,
219
+                                        VAAPIEncodeContext *ctx)
220
+{
221
+    VAEncPictureParameterBufferH264   *vpic = ctx->codec_picture_params;
222
+    VAAPIEncodeH264Context            *priv = ctx->priv_data;
223
+    VAAPIEncodeH264MiscSequenceParams *mseq = &priv->misc_sequence_params;
224
+
225
+    vaapi_encode_h264_write_nal_header(pbc, NAL_PPS, 3);
226
+
227
+    ue(vpic_var(pic_parameter_set_id));
228
+    ue(vpic_var(seq_parameter_set_id));
229
+
230
+    u(1, vpic_field(entropy_coding_mode_flag));
231
+    u(1, mseq_var(bottom_field_pic_order_in_frame_present_flag));
232
+
233
+    ue(mseq_var(num_slice_groups_minus1));
234
+    if (mseq->num_slice_groups_minus1 > 0) {
235
+        ue(mseq_var(slice_group_map_type));
236
+        av_assert0(0 && "slice groups not supported");
237
+    }
238
+
239
+    ue(vpic_var(num_ref_idx_l0_active_minus1));
240
+    ue(vpic_var(num_ref_idx_l1_active_minus1));
241
+
242
+    u(1, vpic_field(weighted_pred_flag));
243
+    u(2, vpic_field(weighted_bipred_idc));
244
+
245
+    se(vpic->pic_init_qp - 26, pic_init_qp_minus26);
246
+    se(mseq_var(pic_init_qs_minus26));
247
+    se(vpic_var(chroma_qp_index_offset));
248
+
249
+    u(1, vpic_field(deblocking_filter_control_present_flag));
250
+    u(1, vpic_field(constrained_intra_pred_flag));
251
+    u(1, vpic_field(redundant_pic_cnt_present_flag));
252
+    u(1, vpic_field(transform_8x8_mode_flag));
253
+
254
+    u(1, vpic_field(pic_scaling_matrix_present_flag));
255
+    if (vpic->pic_fields.bits.pic_scaling_matrix_present_flag) {
256
+        av_assert0(0 && "scaling matrices not supported");
257
+    }
258
+
259
+    se(vpic_var(second_chroma_qp_index_offset));
260
+
261
+    vaapi_encode_h264_write_trailing_rbsp(pbc);
262
+}
263
+
264
+static void vaapi_encode_h264_write_slice_header2(PutBitContext *pbc,
265
+                                                  VAAPIEncodeContext *ctx,
266
+                                                  VAAPIEncodePicture *pic,
267
+                                                  VAAPIEncodeSlice *slice)
268
+{
269
+    VAEncSequenceParameterBufferH264  *vseq = ctx->codec_sequence_params;
270
+    VAEncPictureParameterBufferH264   *vpic = pic->codec_picture_params;
271
+    VAEncSliceParameterBufferH264   *vslice = slice->codec_slice_params;
272
+    VAAPIEncodeH264Context            *priv = ctx->priv_data;
273
+    VAAPIEncodeH264MiscSequenceParams *mseq = &priv->misc_sequence_params;
274
+    VAAPIEncodeH264Slice            *pslice = slice->priv_data;
275
+    VAAPIEncodeH264MiscSliceParams  *mslice = &pslice->misc_slice_params;
276
+
277
+    vaapi_encode_h264_write_nal_header(pbc, mslice->nal_unit_type,
278
+                                       mslice->nal_ref_idc);
279
+
280
+    ue(vslice->macroblock_address, first_mb_in_slice);
281
+    ue(vslice_var(slice_type));
282
+    ue(vpic_var(pic_parameter_set_id));
283
+
284
+    if (mseq->separate_colour_plane_flag) {
285
+        u(2, mslice_var(colour_plane_id));
286
+    }
287
+
288
+    u(4 + vseq->seq_fields.bits.log2_max_frame_num_minus4,
289
+      (vpic->frame_num &
290
+       ((1 << (4 + vseq->seq_fields.bits.log2_max_frame_num_minus4)) - 1)),
291
+      frame_num);
292
+
293
+    if (!vseq->seq_fields.bits.frame_mbs_only_flag) {
294
+        u(1, mslice_var(field_pic_flag));
295
+        if (mslice->field_pic_flag)
296
+            u(1, mslice_var(bottom_field_flag));
297
+    }
298
+
299
+    if (vpic->pic_fields.bits.idr_pic_flag) {
300
+        ue(vslice_var(idr_pic_id));
301
+    }
302
+
303
+    if (vseq->seq_fields.bits.pic_order_cnt_type == 0) {
304
+        u(4 + vseq->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4,
305
+          vslice_var(pic_order_cnt_lsb));
306
+        if (mseq->bottom_field_pic_order_in_frame_present_flag &&
307
+            !mslice->field_pic_flag) {
308
+            se(vslice_var(delta_pic_order_cnt_bottom));
309
+        }
310
+    }
311
+
312
+    if (vseq->seq_fields.bits.pic_order_cnt_type == 1 &&
313
+        !vseq->seq_fields.bits.delta_pic_order_always_zero_flag) {
314
+        se(vslice_var(delta_pic_order_cnt[0]));
315
+        if (mseq->bottom_field_pic_order_in_frame_present_flag &&
316
+            !mslice->field_pic_flag) {
317
+            se(vslice_var(delta_pic_order_cnt[1]));
318
+        }
319
+    }
320
+
321
+    if (vpic->pic_fields.bits.redundant_pic_cnt_present_flag) {
322
+        ue(mslice_var(redundant_pic_cnt));
323
+    }
324
+
325
+    if (vslice->slice_type == SLICE_TYPE_B) {
326
+        u(1, vslice_var(direct_spatial_mv_pred_flag));
327
+    }
328
+
329
+    if (vslice->slice_type == SLICE_TYPE_P ||
330
+        vslice->slice_type == SLICE_TYPE_SP ||
331
+        vslice->slice_type == SLICE_TYPE_B) {
332
+        u(1, vslice_var(num_ref_idx_active_override_flag));
333
+        if (vslice->num_ref_idx_active_override_flag) {
334
+            ue(vslice_var(num_ref_idx_l0_active_minus1));
335
+            if (vslice->slice_type == SLICE_TYPE_B)
336
+                ue(vslice_var(num_ref_idx_l1_active_minus1));
337
+        }
338
+    }
339
+
340
+    if (mslice->nal_unit_type == 20 || mslice->nal_unit_type == 21) {
341
+        av_assert0(0 && "no MVC support");
342
+    } else {
343
+        if (vslice->slice_type % 5 != 2 && vslice->slice_type % 5 != 4) {
344
+            u(1, mslice_var(ref_pic_list_modification_flag_l0));
345
+            if (mslice->ref_pic_list_modification_flag_l0) {
346
+                av_assert0(0 && "ref pic list modification");
347
+            }
348
+        }
349
+        if (vslice->slice_type % 5 == 1) {
350
+            u(1, mslice_var(ref_pic_list_modification_flag_l1));
351
+            if (mslice->ref_pic_list_modification_flag_l1) {
352
+                av_assert0(0 && "ref pic list modification");
353
+            }
354
+        }
355
+    }
356
+
357
+    if ((vpic->pic_fields.bits.weighted_pred_flag &&
358
+         (vslice->slice_type == SLICE_TYPE_P ||
359
+          vslice->slice_type == SLICE_TYPE_SP)) ||
360
+        (vpic->pic_fields.bits.weighted_bipred_idc == 1 &&
361
+         vslice->slice_type == SLICE_TYPE_B)) {
362
+        av_assert0(0 && "prediction weights not supported");
363
+    }
364
+
365
+    av_assert0(mslice->nal_ref_idc > 0 ==
366
+               vpic->pic_fields.bits.reference_pic_flag);
367
+    if (mslice->nal_ref_idc != 0) {
368
+        if (vpic->pic_fields.bits.idr_pic_flag) {
369
+            u(1, mslice_var(no_output_of_prior_pics_flag));
370
+            u(1, mslice_var(long_term_reference_flag));
371
+        } else {
372
+            u(1, mslice_var(adaptive_ref_pic_marking_mode_flag));
373
+            if (mslice->adaptive_ref_pic_marking_mode_flag) {
374
+                av_assert0(0 && "MMCOs not supported");
375
+            }
376
+        }
377
+    }
378
+
379
+    if (vpic->pic_fields.bits.entropy_coding_mode_flag &&
380
+        vslice->slice_type != SLICE_TYPE_I &&
381
+        vslice->slice_type != SLICE_TYPE_SI) {
382
+        ue(vslice_var(cabac_init_idc));
383
+    }
384
+
385
+    se(vslice_var(slice_qp_delta));
386
+    if (vslice->slice_type == SLICE_TYPE_SP ||
387
+        vslice->slice_type == SLICE_TYPE_SI) {
388
+        if (vslice->slice_type == SLICE_TYPE_SP)
389
+            u(1, mslice_var(sp_for_switch_flag));
390
+        se(mslice_var(slice_qs_delta));
391
+    }
392
+
393
+    if (vpic->pic_fields.bits.deblocking_filter_control_present_flag) {
394
+        ue(vslice_var(disable_deblocking_filter_idc));
395
+        if (vslice->disable_deblocking_filter_idc != 1) {
396
+            se(vslice_var(slice_alpha_c0_offset_div2));
397
+            se(vslice_var(slice_beta_offset_div2));
398
+        }
399
+    }
400
+
401
+    if (mseq->num_slice_groups_minus1 > 0 &&
402
+        mseq->slice_group_map_type >= 3 && mseq->slice_group_map_type <= 5) {
403
+        av_assert0(0 && "slice groups not supported");
404
+    }
405
+
406
+    // No alignment - this need not be a byte boundary.
407
+}
408
+
409
+static int vaapi_encode_h264_write_sequence_header(AVCodecContext *avctx,
410
+                                                   char *data, size_t *data_len)
411
+{
412
+    VAAPIEncodeContext *ctx = avctx->priv_data;
413
+    PutBitContext pbc;
414
+    char tmp[256];
415
+    int err;
416
+    size_t nal_len, bit_len, bit_pos, next_len;
417
+
418
+    bit_len = *data_len;
419
+    bit_pos = 0;
420
+
421
+    init_put_bits(&pbc, tmp, sizeof(tmp));
422
+    vaapi_encode_h264_write_sps(&pbc, ctx);
423
+    nal_len = put_bits_count(&pbc);
424
+    flush_put_bits(&pbc);
425
+
426
+    next_len = bit_len - bit_pos;
427
+    err = ff_vaapi_encode_h26x_nal_unit_to_byte_stream(data + bit_pos / 8,
428
+                                                       &next_len,
429
+                                                       tmp, nal_len);
430
+    if (err < 0)
431
+        return err;
432
+    bit_pos += next_len;
433
+
434
+    init_put_bits(&pbc, tmp, sizeof(tmp));
435
+    vaapi_encode_h264_write_pps(&pbc, ctx);
436
+    nal_len = put_bits_count(&pbc);
437
+    flush_put_bits(&pbc);
438
+
439
+    next_len = bit_len - bit_pos;
440
+    err = ff_vaapi_encode_h26x_nal_unit_to_byte_stream(data + bit_pos / 8,
441
+                                                       &next_len,
442
+                                                       tmp, nal_len);
443
+    if (err < 0)
444
+        return err;
445
+    bit_pos += next_len;
446
+
447
+    *data_len = bit_pos;
448
+    return 0;
449
+}
450
+
451
+static int vaapi_encode_h264_write_slice_header(AVCodecContext *avctx,
452
+                                                VAAPIEncodePicture *pic,
453
+                                                VAAPIEncodeSlice *slice,
454
+                                                char *data, size_t *data_len)
455
+{
456
+    VAAPIEncodeContext *ctx = avctx->priv_data;
457
+    PutBitContext pbc;
458
+    char tmp[256];
459
+    size_t header_len;
460
+
461
+    init_put_bits(&pbc, tmp, sizeof(tmp));
462
+    vaapi_encode_h264_write_slice_header2(&pbc, ctx, pic, slice);
463
+    header_len = put_bits_count(&pbc);
464
+    flush_put_bits(&pbc);
465
+
466
+    return ff_vaapi_encode_h26x_nal_unit_to_byte_stream(data, data_len,
467
+                                                        tmp, header_len);
468
+}
469
+
470
+static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
471
+{
472
+    VAAPIEncodeContext                 *ctx = avctx->priv_data;
473
+    VAEncSequenceParameterBufferH264  *vseq = ctx->codec_sequence_params;
474
+    VAEncPictureParameterBufferH264   *vpic = ctx->codec_picture_params;
475
+    VAAPIEncodeH264Context            *priv = ctx->priv_data;
476
+    VAAPIEncodeH264MiscSequenceParams *mseq = &priv->misc_sequence_params;
477
+    int i;
478
+
479
+    {
480
+        vseq->seq_parameter_set_id = 0;
481
+
482
+        vseq->level_idc = avctx->level;
483
+
484
+        vseq->max_num_ref_frames = 2;
485
+
486
+        vseq->picture_width_in_mbs  = priv->mb_width;
487
+        vseq->picture_height_in_mbs = priv->mb_height;
488
+
489
+        vseq->seq_fields.bits.chroma_format_idc = 1;
490
+        vseq->seq_fields.bits.frame_mbs_only_flag = 1;
491
+        vseq->seq_fields.bits.direct_8x8_inference_flag = 1;
492
+        vseq->seq_fields.bits.log2_max_frame_num_minus4 = 4;
493
+        vseq->seq_fields.bits.pic_order_cnt_type = 0;
494
+
495
+        if (ctx->input_width  != ctx->aligned_width ||
496
+            ctx->input_height != ctx->aligned_height) {
497
+            vseq->frame_cropping_flag = 1;
498
+
499
+            vseq->frame_crop_left_offset   = 0;
500
+            vseq->frame_crop_right_offset  =
501
+                (ctx->aligned_width - ctx->input_width) / 2;
502
+            vseq->frame_crop_top_offset    = 0;
503
+            vseq->frame_crop_bottom_offset =
504
+                (ctx->aligned_height - ctx->input_height) / 2;
505
+        } else {
506
+            vseq->frame_cropping_flag = 0;
507
+        }
508
+    }
509
+
510
+    {
511
+        vpic->CurrPic.picture_id = VA_INVALID_ID;
512
+        vpic->CurrPic.flags      = VA_PICTURE_H264_INVALID;
513
+
514
+        for (i = 0; i < FF_ARRAY_ELEMS(vpic->ReferenceFrames); i++) {
515
+            vpic->ReferenceFrames[i].picture_id = VA_INVALID_ID;
516
+            vpic->ReferenceFrames[i].flags      = VA_PICTURE_H264_INVALID;
517
+        }
518
+
519
+        vpic->coded_buf = VA_INVALID_ID;
520
+
521
+        vpic->pic_parameter_set_id = 0;
522
+        vpic->seq_parameter_set_id = 0;
523
+
524
+        vpic->num_ref_idx_l0_active_minus1 = 0;
525
+        vpic->num_ref_idx_l1_active_minus1 = 0;
526
+
527
+        vpic->pic_fields.bits.entropy_coding_mode_flag =
528
+            ((avctx->profile & 0xff) != 66);
529
+        vpic->pic_fields.bits.weighted_pred_flag = 0;
530
+        vpic->pic_fields.bits.weighted_bipred_idc = 0;
531
+        vpic->pic_fields.bits.transform_8x8_mode_flag =
532
+            ((avctx->profile & 0xff) >= 100);
533
+
534
+        vpic->pic_init_qp = priv->fixed_qp_idr;
535
+    }
536
+
537
+    {
538
+        mseq->profile_idc = avctx->profile & 0xff;
539
+
540
+        if (avctx->profile & FF_PROFILE_H264_CONSTRAINED)
541
+            mseq->constraint_set1_flag = 1;
542
+        if (avctx->profile & FF_PROFILE_H264_INTRA)
543
+            mseq->constraint_set3_flag = 1;
544
+    }
545
+
546
+    return 0;
547
+}
548
+
549
+static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
550
+                                                 VAAPIEncodePicture *pic)
551
+{
552
+    VAAPIEncodeContext                *ctx = avctx->priv_data;
553
+    VAEncSequenceParameterBufferH264 *vseq = ctx->codec_sequence_params;
554
+    VAEncPictureParameterBufferH264  *vpic = pic->codec_picture_params;
555
+    VAAPIEncodeH264Context           *priv = ctx->priv_data;
556
+    int i;
557
+
558
+    if (pic->type == PICTURE_TYPE_IDR) {
559
+        av_assert0(pic->display_order == pic->encode_order);
560
+        priv->last_idr_frame = pic->display_order;
561
+    } else {
562
+        av_assert0(pic->display_order > priv->last_idr_frame);
563
+    }
564
+
565
+    vpic->frame_num = (pic->encode_order - priv->last_idr_frame) &
566
+        ((1 << (4 + vseq->seq_fields.bits.log2_max_frame_num_minus4)) - 1);
567
+
568
+    vpic->CurrPic.picture_id          = pic->recon_surface;
569
+    vpic->CurrPic.frame_idx           = vpic->frame_num;
570
+    vpic->CurrPic.flags               = 0;
571
+    vpic->CurrPic.TopFieldOrderCnt    = pic->display_order;
572
+    vpic->CurrPic.BottomFieldOrderCnt = pic->display_order;
573
+
574
+    for (i = 0; i < pic->nb_refs; i++) {
575
+        VAAPIEncodePicture *ref = pic->refs[i];
576
+        av_assert0(ref && ref->encode_order >= priv->last_idr_frame);
577
+        vpic->ReferenceFrames[i].picture_id = ref->recon_surface;
578
+        vpic->ReferenceFrames[i].frame_idx =
579
+            ref->encode_order - priv->last_idr_frame;
580
+        vpic->ReferenceFrames[i].flags = VA_PICTURE_H264_SHORT_TERM_REFERENCE;
581
+        vpic->ReferenceFrames[i].TopFieldOrderCnt    = ref->display_order;
582
+        vpic->ReferenceFrames[i].BottomFieldOrderCnt = ref->display_order;
583
+    }
584
+    for (; i < FF_ARRAY_ELEMS(vpic->ReferenceFrames); i++) {
585
+        vpic->ReferenceFrames[i].picture_id = VA_INVALID_ID;
586
+        vpic->ReferenceFrames[i].flags = VA_PICTURE_H264_INVALID;
587
+    }
588
+
589
+    vpic->coded_buf = pic->output_buffer;
590
+
591
+    vpic->pic_fields.bits.idr_pic_flag = (pic->type == PICTURE_TYPE_IDR);
592
+    vpic->pic_fields.bits.reference_pic_flag = (pic->type != PICTURE_TYPE_B);
593
+
594
+    pic->nb_slices = 1;
595
+
596
+    return 0;
597
+}
598
+
599
+static int vaapi_encode_h264_init_slice_params(AVCodecContext *avctx,
600
+                                               VAAPIEncodePicture *pic,
601
+                                               VAAPIEncodeSlice *slice)
602
+{
603
+    VAAPIEncodeContext                 *ctx = avctx->priv_data;
604
+    VAEncSequenceParameterBufferH264  *vseq = ctx->codec_sequence_params;
605
+    VAEncPictureParameterBufferH264   *vpic = pic->codec_picture_params;
606
+    VAEncSliceParameterBufferH264   *vslice = slice->codec_slice_params;
607
+    VAAPIEncodeH264Context            *priv = ctx->priv_data;
608
+    VAAPIEncodeH264Slice            *pslice;
609
+    VAAPIEncodeH264MiscSliceParams  *mslice;
610
+    int i;
611
+
612
+    slice->priv_data = av_mallocz(sizeof(*pslice));
613
+    if (!slice->priv_data)
614
+        return AVERROR(ENOMEM);
615
+    pslice = slice->priv_data;
616
+    mslice = &pslice->misc_slice_params;
617
+
618
+    if (pic->type == PICTURE_TYPE_IDR)
619
+        mslice->nal_unit_type = NAL_IDR_SLICE;
620
+    else
621
+        mslice->nal_unit_type = NAL_SLICE;
622
+
623
+    switch (pic->type) {
624
+    case PICTURE_TYPE_IDR:
625
+        vslice->slice_type  = SLICE_TYPE_I;
626
+        mslice->nal_ref_idc = 3;
627
+        break;
628
+    case PICTURE_TYPE_I:
629
+        vslice->slice_type  = SLICE_TYPE_I;
630
+        mslice->nal_ref_idc = 2;
631
+        break;
632
+    case PICTURE_TYPE_P:
633
+        vslice->slice_type  = SLICE_TYPE_P;
634
+        mslice->nal_ref_idc = 1;
635
+        break;
636
+    case PICTURE_TYPE_B:
637
+        vslice->slice_type  = SLICE_TYPE_B;
638
+        mslice->nal_ref_idc = 0;
639
+        break;
640
+    default:
641
+        av_assert0(0 && "invalid picture type");
642
+    }
643
+
644
+    // Only one slice per frame.
645
+    vslice->macroblock_address = 0;
646
+    vslice->num_macroblocks = priv->mb_width * priv->mb_height;
647
+
648
+    vslice->macroblock_info = VA_INVALID_ID;
649
+
650
+    vslice->pic_parameter_set_id = vpic->pic_parameter_set_id;
651
+    vslice->idr_pic_id = priv->idr_pic_count++;
652
+
653
+    vslice->pic_order_cnt_lsb = pic->display_order &
654
+        ((1 << (4 + vseq->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4)) - 1);
655
+
656
+    for (i = 0; i < FF_ARRAY_ELEMS(vslice->RefPicList0); i++) {
657
+        vslice->RefPicList0[i].picture_id = VA_INVALID_ID;
658
+        vslice->RefPicList0[i].flags      = VA_PICTURE_H264_INVALID;
659
+        vslice->RefPicList1[i].picture_id = VA_INVALID_ID;
660
+        vslice->RefPicList1[i].flags      = VA_PICTURE_H264_INVALID;
661
+    }
662
+
663
+    av_assert0(pic->nb_refs <= 2);
664
+    if (pic->nb_refs >= 1) {
665
+        // Backward reference for P or B frame.
666
+        av_assert0(pic->type == PICTURE_TYPE_P ||
667
+                   pic->type == PICTURE_TYPE_B);
668
+
669
+        vslice->num_ref_idx_l0_active_minus1 = 0;
670
+        vslice->RefPicList0[0] = vpic->ReferenceFrames[0];
671
+    }
672
+    if (pic->nb_refs >= 2) {
673
+        // Forward reference for B frame.
674
+        av_assert0(pic->type == PICTURE_TYPE_B);
675
+
676
+        vslice->num_ref_idx_l1_active_minus1 = 0;
677
+        vslice->RefPicList1[0] = vpic->ReferenceFrames[1];
678
+    }
679
+
680
+    if (pic->type == PICTURE_TYPE_B)
681
+        vslice->slice_qp_delta = priv->fixed_qp_b - vpic->pic_init_qp;
682
+    else if (pic->type == PICTURE_TYPE_P)
683
+        vslice->slice_qp_delta = priv->fixed_qp_p - vpic->pic_init_qp;
684
+    else
685
+        vslice->slice_qp_delta = priv->fixed_qp_idr - vpic->pic_init_qp;
686
+
687
+    vslice->direct_spatial_mv_pred_flag = 1;
688
+
689
+    return 0;
690
+}
691
+
692
+static VAConfigAttrib vaapi_encode_h264_config_attributes[] = {
693
+    { .type  = VAConfigAttribRTFormat,
694
+      .value = VA_RT_FORMAT_YUV420 },
695
+    { .type  = VAConfigAttribRateControl,
696
+      .value = VA_RC_CQP },
697
+    { .type  = VAConfigAttribEncPackedHeaders,
698
+      .value = (VA_ENC_PACKED_HEADER_SEQUENCE |
699
+                VA_ENC_PACKED_HEADER_SLICE) },
700
+};
701
+
702
+static av_cold int vaapi_encode_h264_init_internal(AVCodecContext *avctx)
703
+{
704
+    VAAPIEncodeContext      *ctx = avctx->priv_data;
705
+    VAAPIEncodeH264Context *priv = ctx->priv_data;
706
+
707
+    switch (avctx->profile) {
708
+    case FF_PROFILE_H264_CONSTRAINED_BASELINE:
709
+        ctx->va_profile = VAProfileH264ConstrainedBaseline;
710
+        break;
711
+    case FF_PROFILE_H264_BASELINE:
712
+        ctx->va_profile = VAProfileH264Baseline;
713
+        break;
714
+    case FF_PROFILE_H264_MAIN:
715
+        ctx->va_profile = VAProfileH264Main;
716
+        break;
717
+    case FF_PROFILE_H264_EXTENDED:
718
+        av_log(avctx, AV_LOG_ERROR, "H.264 extended profile "
719
+               "is not supported.\n");
720
+        return AVERROR_PATCHWELCOME;
721
+    case FF_PROFILE_UNKNOWN:
722
+    case FF_PROFILE_H264_HIGH:
723
+        ctx->va_profile = VAProfileH264High;
724
+        break;
725
+    case FF_PROFILE_H264_HIGH_10:
726
+    case FF_PROFILE_H264_HIGH_10_INTRA:
727
+        av_log(avctx, AV_LOG_ERROR, "H.264 10-bit profiles "
728
+               "are not supported.\n");
729
+        return AVERROR_PATCHWELCOME;
730
+    case FF_PROFILE_H264_HIGH_422:
731
+    case FF_PROFILE_H264_HIGH_422_INTRA:
732
+    case FF_PROFILE_H264_HIGH_444:
733
+    case FF_PROFILE_H264_HIGH_444_PREDICTIVE:
734
+    case FF_PROFILE_H264_HIGH_444_INTRA:
735
+    case FF_PROFILE_H264_CAVLC_444:
736
+        av_log(avctx, AV_LOG_ERROR, "H.264 non-4:2:0 profiles "
737
+               "are not supported.\n");
738
+        return AVERROR_PATCHWELCOME;
739
+    default:
740
+        av_log(avctx, AV_LOG_ERROR, "Unknown H.264 profile %d.\n",
741
+               avctx->profile);
742
+        return AVERROR(EINVAL);
743
+    }
744
+    ctx->va_entrypoint = VAEntrypointEncSlice;
745
+
746
+    ctx->va_rc_mode  = VA_RC_CQP;
747
+
748
+    ctx->input_width    = avctx->width;
749
+    ctx->input_height   = avctx->height;
750
+    ctx->aligned_width  = FFALIGN(ctx->input_width,  16);
751
+    ctx->aligned_height = FFALIGN(ctx->input_height, 16);
752
+    priv->mb_width      = ctx->aligned_width  / 16;
753
+    priv->mb_height     = ctx->aligned_height / 16;
754
+
755
+    if (avctx->bit_rate > 0) {
756
+        av_log(avctx, AV_LOG_ERROR, "Constant bitrate encoding is not "
757
+               "supported!\n");
758
+        return AVERROR_PATCHWELCOME;
759
+    }
760
+
761
+    priv->fixed_qp_p = avctx->global_quality;
762
+    if (avctx->i_quant_factor > 0.0)
763
+        priv->fixed_qp_idr = (int)((priv->fixed_qp_p * avctx->i_quant_factor +
764
+                                    avctx->i_quant_offset) + 0.5);
765
+    else
766
+        priv->fixed_qp_idr = priv->fixed_qp_p;
767
+    if (avctx->b_quant_factor > 0.0)
768
+        priv->fixed_qp_b = (int)((priv->fixed_qp_p * avctx->b_quant_factor +
769
+                                  avctx->b_quant_offset) + 0.5);
770
+    else
771
+        priv->fixed_qp_b = priv->fixed_qp_p;
772
+    av_log(avctx, AV_LOG_DEBUG, "QP = %d / %d / %d for IDR / P / B frames.\n",
773
+           priv->fixed_qp_idr, priv->fixed_qp_p, priv->fixed_qp_b);
774
+
775
+    ctx->config_attributes = vaapi_encode_h264_config_attributes;
776
+    ctx->nb_config_attributes =
777
+        FF_ARRAY_ELEMS(vaapi_encode_h264_config_attributes);
778
+
779
+    ctx->nb_recon_frames = 20;
780
+
781
+    return 0;
782
+}
783
+
784
+static VAAPIEncodeType vaapi_encode_type_h264 = {
785
+    .priv_data_size        = sizeof(VAAPIEncodeH264Context),
786
+
787
+    .init                  = &vaapi_encode_h264_init_internal,
788
+
789
+    .sequence_params_size  = sizeof(VAEncSequenceParameterBufferH264),
790
+    .init_sequence_params  = &vaapi_encode_h264_init_sequence_params,
791
+
792
+    .picture_params_size   = sizeof(VAEncPictureParameterBufferH264),
793
+    .init_picture_params   = &vaapi_encode_h264_init_picture_params,
794
+
795
+    .slice_params_size     = sizeof(VAEncSliceParameterBufferH264),
796
+    .init_slice_params     = &vaapi_encode_h264_init_slice_params,
797
+
798
+    .sequence_header_type  = VAEncPackedHeaderSequence,
799
+    .write_sequence_header = &vaapi_encode_h264_write_sequence_header,
800
+
801
+    .slice_header_type     = VAEncPackedHeaderH264_Slice,
802
+    .write_slice_header    = &vaapi_encode_h264_write_slice_header,
803
+};
804
+
805
+static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)
806
+{
807
+    return ff_vaapi_encode_init(avctx, &vaapi_encode_type_h264);
808
+}
809
+
810
+static const AVCodecDefault vaapi_encode_h264_defaults[] = {
811
+    { "profile",        "100" },
812
+    { "level",          "51"  },
813
+    { "b",              "0"   },
814
+    { "bf",             "2"   },
815
+    { "g",              "120" },
816
+    { "global_quality", "20"  },
817
+    { "i_qfactor",      "1.0" },
818
+    { "i_qoffset",      "0.0" },
819
+    { "b_qfactor",      "1.2" },
820
+    { "b_qoffset",      "0.0" },
821
+    { NULL },
822
+};
823
+
824
+static const AVClass vaapi_encode_h264_class = {
825
+    .class_name = "h264_vaapi",
826
+    .item_name  = av_default_item_name,
827
+    .version    = LIBAVUTIL_VERSION_INT,
828
+};
829
+
830
+AVCodec ff_h264_vaapi_encoder = {
831
+    .name           = "h264_vaapi",
832
+    .long_name      = NULL_IF_CONFIG_SMALL("H.264/AVC (VAAPI)"),
833
+    .type           = AVMEDIA_TYPE_VIDEO,
834
+    .id             = AV_CODEC_ID_H264,
835
+    .priv_data_size = sizeof(VAAPIEncodeContext),
836
+    .init           = &vaapi_encode_h264_init,
837
+    .encode2        = &ff_vaapi_encode2,
838
+    .close          = &ff_vaapi_encode_close,
839
+    .priv_class     = &vaapi_encode_h264_class,
840
+    .capabilities   = AV_CODEC_CAP_DELAY,
841
+    .defaults       = vaapi_encode_h264_defaults,
842
+    .pix_fmts = (const enum AVPixelFormat[]) {
843
+        AV_PIX_FMT_VAAPI,
844
+        AV_PIX_FMT_NONE,
845
+    },
846
+};
0 847
new file mode 100644
... ...
@@ -0,0 +1,68 @@
0
+/*
1
+ * This file is part of Libav.
2
+ *
3
+ * Libav is free software; you can redistribute it and/or
4
+ * modify it under the terms of the GNU Lesser General Public
5
+ * License as published by the Free Software Foundation; either
6
+ * version 2.1 of the License, or (at your option) any later version.
7
+ *
8
+ * Libav is distributed in the hope that it will be useful,
9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
+ * Lesser General Public License for more details.
12
+ *
13
+ * You should have received a copy of the GNU Lesser General Public
14
+ * License along with Libav; if not, write to the Free Software
15
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+ */
17
+
18
+#include <stdint.h>
19
+
20
+#include "vaapi_encode_h26x.h"
21
+
22
+int ff_vaapi_encode_h26x_nal_unit_to_byte_stream(uint8_t *dst, size_t *dst_bit_len,
23
+                                                 uint8_t *src, size_t src_bit_len)
24
+{
25
+    size_t dp, sp;
26
+    int zero_run = 0;
27
+    size_t dst_len = *dst_bit_len / 8;
28
+    size_t src_len = (src_bit_len + 7) / 8;
29
+    int trailing_zeroes = src_len * 8 - src_bit_len;
30
+
31
+    if (dst_len < src_len + 4) {
32
+        // Definitely doesn't fit.
33
+        goto fail;
34
+    }
35
+
36
+    // Start code.
37
+    dst[0] = dst[1] = dst[2] = 0;
38
+    dst[3] = 1;
39
+    dp = 4;
40
+
41
+    for (sp = 0; sp < src_len; sp++) {
42
+        if (dp >= dst_len)
43
+            goto fail;
44
+        if (zero_run < 2) {
45
+            if (src[sp] == 0)
46
+                ++zero_run;
47
+            else
48
+                zero_run = 0;
49
+        } else {
50
+            if ((src[sp] & ~3) == 0) {
51
+                // emulation_prevention_three_byte
52
+                dst[dp++] = 3;
53
+                if (dp >= dst_len)
54
+                    goto fail;
55
+            }
56
+            zero_run = src[sp] == 0;
57
+        }
58
+        dst[dp++] = src[sp];
59
+    }
60
+
61
+    *dst_bit_len = 8 * dp - trailing_zeroes;
62
+    return 0;
63
+
64
+fail:
65
+    *dst_bit_len = 0;
66
+    return AVERROR(ENOSPC);
67
+}
0 68
new file mode 100644
... ...
@@ -0,0 +1,45 @@
0
+/*
1
+ * This file is part of Libav.
2
+ *
3
+ * Libav is free software; you can redistribute it and/or
4
+ * modify it under the terms of the GNU Lesser General Public
5
+ * License as published by the Free Software Foundation; either
6
+ * version 2.1 of the License, or (at your option) any later version.
7
+ *
8
+ * Libav is distributed in the hope that it will be useful,
9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
+ * Lesser General Public License for more details.
12
+ *
13
+ * You should have received a copy of the GNU Lesser General Public
14
+ * License along with Libav; if not, write to the Free Software
15
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+ */
17
+
18
+#ifndef AVCODEC_VAAPI_ENCODE_H26X_H
19
+#define AVCODEC_VAAPI_ENCODE_H26X_H
20
+
21
+#include <stddef.h>
22
+#include <stdint.h>
23
+
24
+#include "golomb.h"
25
+#include "put_bits.h"
26
+
27
+
28
+// Debug code may be interested in the name of the syntax element being
29
+// for tracing purposes.  Here, it is just discarded.
30
+
31
+#define write_u(pbc, width, value, name) put_bits(pbc, width, value)
32
+#define write_ue(pbc, value, name)       set_ue_golomb(pbc, value)
33
+#define write_se(pbc, value, name)       set_se_golomb(pbc, value)
34
+
35
+#define u(width, ...) write_u(pbc, width, __VA_ARGS__)
36
+#define ue(...)       write_ue(pbc, __VA_ARGS__)
37
+#define se(...)       write_se(pbc, __VA_ARGS__)
38
+
39
+
40
+// Copy from src to dst, applying emulation prevention.
41
+int ff_vaapi_encode_h26x_nal_unit_to_byte_stream(uint8_t *dst, size_t *dst_len,
42
+                                                 uint8_t *src, size_t src_len);
43
+
44
+#endif /* AVCODEC_VAAPI_ENCODE_H26X_H */
... ...
@@ -28,7 +28,7 @@
28 28
 #include "libavutil/version.h"
29 29
 
30 30
 #define LIBAVCODEC_VERSION_MAJOR 57
31
-#define LIBAVCODEC_VERSION_MINOR 16
31
+#define LIBAVCODEC_VERSION_MINOR 17
32 32
 #define LIBAVCODEC_VERSION_MICRO  0
33 33
 
34 34
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \