2 * This file is part of FFmpeg.
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.
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.
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
20 #include <va/va_enc_mpeg2.h>
22 #include "libavutil/avassert.h"
26 #include "cbs_mpeg2.h"
28 #include "vaapi_encode.h"
30 typedef struct VAAPIEncodeMPEG2Context {
31 VAAPIEncodeContext common;
42 unsigned int bit_rate;
43 unsigned int vbv_buffer_size;
45 AVRational frame_rate;
47 unsigned int f_code_horizontal;
48 unsigned int f_code_vertical;
54 MPEG2RawSequenceHeader sequence_header;
55 MPEG2RawExtensionData sequence_extension;
56 MPEG2RawExtensionData sequence_display_extension;
57 MPEG2RawGroupOfPicturesHeader gop_header;
58 MPEG2RawPictureHeader picture_header;
59 MPEG2RawExtensionData picture_coding_extension;
61 CodedBitstreamContext *cbc;
62 CodedBitstreamFragment current_fragment;
63 } VAAPIEncodeMPEG2Context;
66 static int vaapi_encode_mpeg2_write_fragment(AVCodecContext *avctx,
67 char *data, size_t *data_len,
68 CodedBitstreamFragment *frag)
70 VAAPIEncodeMPEG2Context *priv = avctx->priv_data;
73 err = ff_cbs_write_fragment_data(priv->cbc, frag);
75 av_log(avctx, AV_LOG_ERROR, "Failed to write packed header.\n");
79 if (*data_len < 8 * frag->data_size - frag->data_bit_padding) {
80 av_log(avctx, AV_LOG_ERROR, "Access unit too large: "
81 "%zu < %zu.\n", *data_len,
82 8 * frag->data_size - frag->data_bit_padding);
83 return AVERROR(ENOSPC);
86 memcpy(data, frag->data, frag->data_size);
87 *data_len = 8 * frag->data_size - frag->data_bit_padding;
92 static int vaapi_encode_mpeg2_add_header(AVCodecContext *avctx,
93 CodedBitstreamFragment *frag,
94 int type, void *header)
96 VAAPIEncodeMPEG2Context *priv = avctx->priv_data;
99 err = ff_cbs_insert_unit_content(priv->cbc, frag, -1, type, header, NULL);
101 av_log(avctx, AV_LOG_ERROR, "Failed to add header: "
102 "type = %d.\n", type);
109 static int vaapi_encode_mpeg2_write_sequence_header(AVCodecContext *avctx,
110 char *data, size_t *data_len)
112 VAAPIEncodeMPEG2Context *priv = avctx->priv_data;
113 CodedBitstreamFragment *frag = &priv->current_fragment;
116 err = vaapi_encode_mpeg2_add_header(avctx, frag, MPEG2_START_SEQUENCE_HEADER,
117 &priv->sequence_header);
121 err = vaapi_encode_mpeg2_add_header(avctx, frag, MPEG2_START_EXTENSION,
122 &priv->sequence_extension);
126 err = vaapi_encode_mpeg2_add_header(avctx, frag, MPEG2_START_EXTENSION,
127 &priv->sequence_display_extension);
131 err = vaapi_encode_mpeg2_add_header(avctx, frag, MPEG2_START_GROUP,
136 err = vaapi_encode_mpeg2_write_fragment(avctx, data, data_len, frag);
138 ff_cbs_fragment_reset(priv->cbc, frag);
142 static int vaapi_encode_mpeg2_write_picture_header(AVCodecContext *avctx,
143 VAAPIEncodePicture *pic,
144 char *data, size_t *data_len)
146 VAAPIEncodeMPEG2Context *priv = avctx->priv_data;
147 CodedBitstreamFragment *frag = &priv->current_fragment;
150 err = vaapi_encode_mpeg2_add_header(avctx, frag, MPEG2_START_PICTURE,
151 &priv->picture_header);
155 err = vaapi_encode_mpeg2_add_header(avctx, frag, MPEG2_START_EXTENSION,
156 &priv->picture_coding_extension);
160 err = vaapi_encode_mpeg2_write_fragment(avctx, data, data_len, frag);
162 ff_cbs_fragment_reset(priv->cbc, frag);
166 static int vaapi_encode_mpeg2_init_sequence_params(AVCodecContext *avctx)
168 VAAPIEncodeContext *ctx = avctx->priv_data;
169 VAAPIEncodeMPEG2Context *priv = avctx->priv_data;
170 MPEG2RawSequenceHeader *sh = &priv->sequence_header;
171 MPEG2RawSequenceExtension *se = &priv->sequence_extension.data.sequence;
172 MPEG2RawSequenceDisplayExtension *sde = &priv->sequence_display_extension.data.sequence_display;
173 MPEG2RawGroupOfPicturesHeader *goph = &priv->gop_header;
174 MPEG2RawPictureHeader *ph = &priv->picture_header;
175 MPEG2RawPictureCodingExtension *pce = &priv->picture_coding_extension.data.picture_coding;
176 VAEncSequenceParameterBufferMPEG2 *vseq = ctx->codec_sequence_params;
177 VAEncPictureParameterBufferMPEG2 *vpic = ctx->codec_picture_params;
178 int code, ext_n, ext_d;
180 memset(sh, 0, sizeof(*sh));
181 memset(se, 0, sizeof(*se));
182 memset(sde, 0, sizeof(*sde));
183 memset(goph, 0, sizeof(*goph));
184 memset(ph, 0, sizeof(*ph));
185 memset(pce, 0, sizeof(*pce));
188 if (ctx->va_bit_rate > 0) {
189 priv->bit_rate = (ctx->va_bit_rate + 399) / 400;
191 // Unknown (not a bitrate-targetting mode), so just use the
193 priv->bit_rate = 0x3fffffff;
195 if (avctx->rc_buffer_size > 0) {
196 priv->vbv_buffer_size = (avctx->rc_buffer_size + (1 << 14) - 1) >> 14;
198 // Unknown, so guess a value from the bitrate.
199 priv->vbv_buffer_size = priv->bit_rate >> 14;
202 switch (avctx->level) {
204 case 6: // High 1440.
205 priv->f_code_horizontal = 9;
206 priv->f_code_vertical = 5;
209 priv->f_code_horizontal = 8;
210 priv->f_code_vertical = 5;
214 priv->f_code_horizontal = 7;
215 priv->f_code_vertical = 4;
222 sh->sequence_header_code = MPEG2_START_SEQUENCE_HEADER;
224 sh->horizontal_size_value = avctx->width & 0xfff;
225 sh->vertical_size_value = avctx->height & 0xfff;
227 if (avctx->sample_aspect_ratio.num != 0 &&
228 avctx->sample_aspect_ratio.den != 0) {
229 AVRational dar = av_div_q(avctx->sample_aspect_ratio,
230 (AVRational) { avctx->width, avctx->height });
232 if (av_cmp_q(avctx->sample_aspect_ratio, (AVRational) { 1, 1 }) == 0) {
233 sh->aspect_ratio_information = 1;
234 } else if (av_cmp_q(dar, (AVRational) { 3, 4 }) == 0) {
235 sh->aspect_ratio_information = 2;
236 } else if (av_cmp_q(dar, (AVRational) { 9, 16 }) == 0) {
237 sh->aspect_ratio_information = 3;
238 } else if (av_cmp_q(dar, (AVRational) { 100, 221 }) == 0) {
239 sh->aspect_ratio_information = 4;
241 av_log(avctx, AV_LOG_WARNING, "Sample aspect ratio %d:%d is not "
242 "representable, signalling square pixels instead.\n",
243 avctx->sample_aspect_ratio.num,
244 avctx->sample_aspect_ratio.den);
245 sh->aspect_ratio_information = 1;
248 // Unknown - assume square pixels.
249 sh->aspect_ratio_information = 1;
252 if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
253 priv->frame_rate = avctx->framerate;
255 priv->frame_rate = av_inv_q(avctx->time_base);
256 ff_mpeg12_find_best_frame_rate(priv->frame_rate,
257 &code, &ext_n, &ext_d, 0);
258 sh->frame_rate_code = code;
260 sh->bit_rate_value = priv->bit_rate & 0x3ffff;
261 sh->vbv_buffer_size_value = priv->vbv_buffer_size & 0x3ff;
263 sh->constrained_parameters_flag = 0;
264 sh->load_intra_quantiser_matrix = 0;
265 sh->load_non_intra_quantiser_matrix = 0;
268 // Sequence extension
270 priv->sequence_extension.extension_start_code = MPEG2_START_EXTENSION;
271 priv->sequence_extension.extension_start_code_identifier =
272 MPEG2_EXTENSION_SEQUENCE;
274 se->profile_and_level_indication = avctx->profile << 4 | avctx->level;
275 se->progressive_sequence = 1;
276 se->chroma_format = 1;
278 se->horizontal_size_extension = avctx->width >> 12;
279 se->vertical_size_extension = avctx->height >> 12;
281 se->bit_rate_extension = priv->bit_rate >> 18;
282 se->vbv_buffer_size_extension = priv->vbv_buffer_size >> 10;
283 se->low_delay = ctx->b_per_p == 0;
285 se->frame_rate_extension_n = ext_n;
286 se->frame_rate_extension_d = ext_d;
289 // Sequence display extension
291 priv->sequence_display_extension.extension_start_code =
292 MPEG2_START_EXTENSION;
293 priv->sequence_display_extension.extension_start_code_identifier =
294 MPEG2_EXTENSION_SEQUENCE_DISPLAY;
296 sde->video_format = 5;
297 if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED ||
298 avctx->color_trc != AVCOL_TRC_UNSPECIFIED ||
299 avctx->colorspace != AVCOL_SPC_UNSPECIFIED) {
300 sde->colour_description = 1;
301 sde->colour_primaries = avctx->color_primaries;
302 sde->transfer_characteristics = avctx->color_trc;
303 sde->matrix_coefficients = avctx->colorspace;
305 sde->colour_description = 0;
308 sde->display_horizontal_size = avctx->width;
309 sde->display_vertical_size = avctx->height;
314 goph->group_start_code = MPEG2_START_GROUP;
316 // Marker bit in the middle of time_code.
317 goph->time_code = 1 << 12;
318 goph->closed_gop = 1;
319 goph->broken_link = 0;
322 // Defaults for picture header
324 ph->picture_start_code = MPEG2_START_PICTURE;
326 ph->vbv_delay = 0xffff; // Not currently calculated.
328 ph->full_pel_forward_vector = 0;
329 ph->forward_f_code = 7;
330 ph->full_pel_backward_vector = 0;
331 ph->forward_f_code = 7;
334 // Defaults for picture coding extension
336 priv->picture_coding_extension.extension_start_code =
337 MPEG2_START_EXTENSION;
338 priv->picture_coding_extension.extension_start_code_identifier =
339 MPEG2_EXTENSION_PICTURE_CODING;
341 pce->intra_dc_precision = 0;
342 pce->picture_structure = 3;
343 pce->top_field_first = 0;
344 pce->frame_pred_frame_dct = 1;
345 pce->concealment_motion_vectors = 0;
346 pce->q_scale_type = 0;
347 pce->intra_vlc_format = 0;
348 pce->alternate_scan = 0;
349 pce->repeat_first_field = 0;
350 pce->progressive_frame = 1;
351 pce->composite_display_flag = 0;
355 *vseq = (VAEncSequenceParameterBufferMPEG2) {
356 .intra_period = ctx->gop_size,
357 .ip_period = ctx->b_per_p + 1,
359 .picture_width = avctx->width,
360 .picture_height = avctx->height,
362 .bits_per_second = ctx->va_bit_rate,
363 .frame_rate = av_q2d(priv->frame_rate),
364 .aspect_ratio_information = sh->aspect_ratio_information,
365 .vbv_buffer_size = priv->vbv_buffer_size,
367 .sequence_extension.bits = {
368 .profile_and_level_indication = se->profile_and_level_indication,
369 .progressive_sequence = se->progressive_sequence,
370 .chroma_format = se->chroma_format,
371 .low_delay = se->low_delay,
372 .frame_rate_extension_n = se->frame_rate_extension_n,
373 .frame_rate_extension_d = se->frame_rate_extension_d,
378 .time_code = goph->time_code,
379 .closed_gop = goph->closed_gop,
380 .broken_link = goph->broken_link,
384 *vpic = (VAEncPictureParameterBufferMPEG2) {
385 .forward_reference_picture = VA_INVALID_ID,
386 .backward_reference_picture = VA_INVALID_ID,
387 .reconstructed_picture = VA_INVALID_ID,
388 .coded_buf = VA_INVALID_ID,
391 .f_code = { { 15, 15 }, { 15, 15 } },
393 .picture_coding_extension.bits = {
394 .intra_dc_precision = pce->intra_dc_precision,
395 .picture_structure = pce->picture_structure,
396 .top_field_first = pce->top_field_first,
397 .frame_pred_frame_dct = pce->frame_pred_frame_dct,
398 .concealment_motion_vectors = pce->concealment_motion_vectors,
399 .q_scale_type = pce->q_scale_type,
400 .intra_vlc_format = pce->intra_vlc_format,
401 .alternate_scan = pce->alternate_scan,
402 .repeat_first_field = pce->repeat_first_field,
403 .progressive_frame = pce->progressive_frame,
404 .composite_display_flag = pce->composite_display_flag,
407 .composite_display.bits = {
408 .v_axis = pce->v_axis,
409 .field_sequence = pce->field_sequence,
410 .sub_carrier = pce->sub_carrier,
411 .burst_amplitude = pce->burst_amplitude,
412 .sub_carrier_phase = pce->sub_carrier_phase,
419 static int vaapi_encode_mpeg2_init_picture_params(AVCodecContext *avctx,
420 VAAPIEncodePicture *pic)
422 VAAPIEncodeMPEG2Context *priv = avctx->priv_data;
423 MPEG2RawPictureHeader *ph = &priv->picture_header;
424 MPEG2RawPictureCodingExtension *pce = &priv->picture_coding_extension.data.picture_coding;
425 VAEncPictureParameterBufferMPEG2 *vpic = pic->codec_picture_params;
427 if (pic->type == PICTURE_TYPE_IDR || pic->type == PICTURE_TYPE_I) {
428 ph->temporal_reference = 0;
429 ph->picture_coding_type = 1;
430 priv->last_i_frame = pic->display_order;
432 ph->temporal_reference = pic->display_order - priv->last_i_frame;
433 ph->picture_coding_type = pic->type == PICTURE_TYPE_B ? 3 : 2;
436 if (pic->type == PICTURE_TYPE_P || pic->type == PICTURE_TYPE_B) {
437 pce->f_code[0][0] = priv->f_code_horizontal;
438 pce->f_code[0][1] = priv->f_code_vertical;
440 pce->f_code[0][0] = 15;
441 pce->f_code[0][1] = 15;
443 if (pic->type == PICTURE_TYPE_B) {
444 pce->f_code[1][0] = priv->f_code_horizontal;
445 pce->f_code[1][1] = priv->f_code_vertical;
447 pce->f_code[1][0] = 15;
448 pce->f_code[1][1] = 15;
451 vpic->reconstructed_picture = pic->recon_surface;
452 vpic->coded_buf = pic->output_buffer;
455 case PICTURE_TYPE_IDR:
457 vpic->picture_type = VAEncPictureTypeIntra;
460 vpic->picture_type = VAEncPictureTypePredictive;
461 vpic->forward_reference_picture = pic->refs[0]->recon_surface;
464 vpic->picture_type = VAEncPictureTypeBidirectional;
465 vpic->forward_reference_picture = pic->refs[0]->recon_surface;
466 vpic->backward_reference_picture = pic->refs[1]->recon_surface;
469 av_assert0(0 && "invalid picture type");
472 vpic->temporal_reference = ph->temporal_reference;
473 vpic->f_code[0][0] = pce->f_code[0][0];
474 vpic->f_code[0][1] = pce->f_code[0][1];
475 vpic->f_code[1][0] = pce->f_code[1][0];
476 vpic->f_code[1][1] = pce->f_code[1][1];
481 static int vaapi_encode_mpeg2_init_slice_params(AVCodecContext *avctx,
482 VAAPIEncodePicture *pic,
483 VAAPIEncodeSlice *slice)
485 VAAPIEncodeMPEG2Context *priv = avctx->priv_data;
486 VAEncSliceParameterBufferMPEG2 *vslice = slice->codec_slice_params;
489 vslice->macroblock_address = slice->block_start;
490 vslice->num_macroblocks = slice->block_size;
493 case PICTURE_TYPE_IDR:
504 av_assert0(0 && "invalid picture type");
507 vslice->quantiser_scale_code = qp;
508 vslice->is_intra_slice = (pic->type == PICTURE_TYPE_IDR ||
509 pic->type == PICTURE_TYPE_I);
514 static av_cold int vaapi_encode_mpeg2_configure(AVCodecContext *avctx)
516 VAAPIEncodeContext *ctx = avctx->priv_data;
517 VAAPIEncodeMPEG2Context *priv = avctx->priv_data;
520 err = ff_cbs_init(&priv->cbc, AV_CODEC_ID_MPEG2VIDEO, avctx);
524 if (ctx->va_rc_mode == VA_RC_CQP) {
525 priv->quant_p = av_clip(ctx->rc_quality, 1, 31);
526 if (avctx->i_quant_factor > 0.0)
528 av_clip((avctx->i_quant_factor * priv->quant_p +
529 avctx->i_quant_offset) + 0.5, 1, 31);
531 priv->quant_i = priv->quant_p;
532 if (avctx->b_quant_factor > 0.0)
534 av_clip((avctx->b_quant_factor * priv->quant_p +
535 avctx->b_quant_offset) + 0.5, 1, 31);
537 priv->quant_b = priv->quant_p;
539 av_log(avctx, AV_LOG_DEBUG, "Using fixed quantiser "
540 "%d / %d / %d for I- / P- / B-frames.\n",
541 priv->quant_i, priv->quant_p, priv->quant_b);
549 ctx->slice_block_rows = FFALIGN(avctx->height, 16) / 16;
550 ctx->slice_block_cols = FFALIGN(avctx->width, 16) / 16;
552 ctx->nb_slices = ctx->slice_block_rows;
558 static const VAAPIEncodeProfile vaapi_encode_mpeg2_profiles[] = {
559 { FF_PROFILE_MPEG2_MAIN, 8, 3, 1, 1, VAProfileMPEG2Main },
560 { FF_PROFILE_MPEG2_SIMPLE, 8, 3, 1, 1, VAProfileMPEG2Simple },
561 { FF_PROFILE_UNKNOWN }
564 static const VAAPIEncodeType vaapi_encode_type_mpeg2 = {
565 .profiles = vaapi_encode_mpeg2_profiles,
567 .flags = FLAG_B_PICTURES,
569 .configure = &vaapi_encode_mpeg2_configure,
571 .default_quality = 10,
573 .sequence_params_size = sizeof(VAEncSequenceParameterBufferMPEG2),
574 .init_sequence_params = &vaapi_encode_mpeg2_init_sequence_params,
576 .picture_params_size = sizeof(VAEncPictureParameterBufferMPEG2),
577 .init_picture_params = &vaapi_encode_mpeg2_init_picture_params,
579 .slice_params_size = sizeof(VAEncSliceParameterBufferMPEG2),
580 .init_slice_params = &vaapi_encode_mpeg2_init_slice_params,
582 .sequence_header_type = VAEncPackedHeaderSequence,
583 .write_sequence_header = &vaapi_encode_mpeg2_write_sequence_header,
585 .picture_header_type = VAEncPackedHeaderPicture,
586 .write_picture_header = &vaapi_encode_mpeg2_write_picture_header,
589 static av_cold int vaapi_encode_mpeg2_init(AVCodecContext *avctx)
591 VAAPIEncodeContext *ctx = avctx->priv_data;
592 VAAPIEncodeMPEG2Context *priv = avctx->priv_data;
594 ctx->codec = &vaapi_encode_type_mpeg2;
596 if (avctx->profile == FF_PROFILE_UNKNOWN)
597 avctx->profile = priv->profile;
598 if (avctx->level == FF_LEVEL_UNKNOWN)
599 avctx->level = priv->level;
601 // Reject unknown levels (these are required to set f_code for
602 // motion vector encoding).
603 switch (avctx->level) {
610 av_log(avctx, AV_LOG_ERROR, "Unknown MPEG-2 level %d.\n",
612 return AVERROR(EINVAL);
615 if (avctx->height % 4096 == 0 || avctx->width % 4096 == 0) {
616 av_log(avctx, AV_LOG_ERROR, "MPEG-2 does not support picture "
617 "height or width divisible by 4096.\n");
618 return AVERROR(EINVAL);
621 ctx->desired_packed_headers = VA_ENC_PACKED_HEADER_SEQUENCE |
622 VA_ENC_PACKED_HEADER_PICTURE;
624 ctx->surface_width = FFALIGN(avctx->width, 16);
625 ctx->surface_height = FFALIGN(avctx->height, 16);
627 return ff_vaapi_encode_init(avctx);
630 static av_cold int vaapi_encode_mpeg2_close(AVCodecContext *avctx)
632 VAAPIEncodeMPEG2Context *priv = avctx->priv_data;
634 ff_cbs_fragment_free(priv->cbc, &priv->current_fragment);
635 ff_cbs_close(&priv->cbc);
637 return ff_vaapi_encode_close(avctx);
640 #define OFFSET(x) offsetof(VAAPIEncodeMPEG2Context, x)
641 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
642 static const AVOption vaapi_encode_mpeg2_options[] = {
643 VAAPI_ENCODE_COMMON_OPTIONS,
644 VAAPI_ENCODE_RC_OPTIONS,
646 { "profile", "Set profile (in profile_and_level_indication)",
647 OFFSET(profile), AV_OPT_TYPE_INT,
648 { .i64 = FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, 7, FLAGS, "profile" },
650 #define PROFILE(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
651 { .i64 = value }, 0, 0, FLAGS, "profile"
652 { PROFILE("simple", FF_PROFILE_MPEG2_SIMPLE) },
653 { PROFILE("main", FF_PROFILE_MPEG2_MAIN) },
656 { "level", "Set level (in profile_and_level_indication)",
657 OFFSET(level), AV_OPT_TYPE_INT,
658 { .i64 = 4 }, 0, 15, FLAGS, "level" },
660 #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
661 { .i64 = value }, 0, 0, FLAGS, "level"
662 { LEVEL("low", 10) },
663 { LEVEL("main", 8) },
664 { LEVEL("high_1440", 6) },
665 { LEVEL("high", 4) },
671 static const AVCodecDefault vaapi_encode_mpeg2_defaults[] = {
675 { "i_qfactor", "1" },
676 { "i_qoffset", "0" },
677 { "b_qfactor", "6/5" },
678 { "b_qoffset", "0" },
684 static const AVClass vaapi_encode_mpeg2_class = {
685 .class_name = "mpeg2_vaapi",
686 .item_name = av_default_item_name,
687 .option = vaapi_encode_mpeg2_options,
688 .version = LIBAVUTIL_VERSION_INT,
691 AVCodec ff_mpeg2_vaapi_encoder = {
692 .name = "mpeg2_vaapi",
693 .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 (VAAPI)"),
694 .type = AVMEDIA_TYPE_VIDEO,
695 .id = AV_CODEC_ID_MPEG2VIDEO,
696 .priv_data_size = sizeof(VAAPIEncodeMPEG2Context),
697 .init = &vaapi_encode_mpeg2_init,
698 .send_frame = &ff_vaapi_encode_send_frame,
699 .receive_packet = &ff_vaapi_encode_receive_packet,
700 .close = &vaapi_encode_mpeg2_close,
701 .priv_class = &vaapi_encode_mpeg2_class,
702 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE,
703 .defaults = vaapi_encode_mpeg2_defaults,
704 .pix_fmts = (const enum AVPixelFormat[]) {
708 .wrapper_name = "vaapi",