1 /*
2 * Scalable Video Technology for AV1 encoder library plugin
3 *
4 * Copyright (c) 2018 Intel Corporation
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include <stdint.h>
24 #include <EbSvtAv1ErrorCodes.h>
25 #include <EbSvtAv1Enc.h>
26
27 #include "libavutil/common.h"
28 #include "libavutil/frame.h"
29 #include "libavutil/imgutils.h"
30 #include "libavutil/opt.h"
31 #include "libavutil/pixdesc.h"
32 #include "libavutil/avassert.h"
33
34 #include "internal.h"
35 #include "encode.h"
36 #include "packet_internal.h"
37 #include "avcodec.h"
38 #include "profiles.h"
39
40 typedef enum eos_status {
41 EOS_NOT_REACHED = 0,
42 EOS_SENT,
43 EOS_RECEIVED
44 }EOS_STATUS;
45
46 typedef struct SvtContext {
47 const AVClass *class;
48
49 EbSvtAv1EncConfiguration enc_params;
50 EbComponentType *svt_handle;
51
52 EbBufferHeaderType *in_buf;
53 int raw_size;
54 int max_tu_size;
55
56 AVFrame *frame;
57
58 AVBufferPool *pool;
59
60 EOS_STATUS eos_flag;
61
62 // User options.
63 int hierarchical_level;
64 int la_depth;
65 int enc_mode;
66 int rc_mode;
67 int scd;
68 int qp;
69
70 int tier;
71
72 int tile_columns;
73 int tile_rows;
74 } SvtContext;
75
76 static const struct {
77 EbErrorType eb_err;
78 int av_err;
79 const char *desc;
80 } svt_errors[] = {
81 { EB_ErrorNone, 0, "success" },
82 { EB_ErrorInsufficientResources, AVERROR(ENOMEM), "insufficient resources" },
83 { EB_ErrorUndefined, AVERROR(EINVAL), "undefined error" },
84 { EB_ErrorInvalidComponent, AVERROR(EINVAL), "invalid component" },
85 { EB_ErrorBadParameter, AVERROR(EINVAL), "bad parameter" },
86 { EB_ErrorDestroyThreadFailed, AVERROR_EXTERNAL, "failed to destroy thread" },
87 { EB_ErrorSemaphoreUnresponsive, AVERROR_EXTERNAL, "semaphore unresponsive" },
88 { EB_ErrorDestroySemaphoreFailed, AVERROR_EXTERNAL, "failed to destroy semaphore"},
89 { EB_ErrorCreateMutexFailed, AVERROR_EXTERNAL, "failed to create mutex" },
90 { EB_ErrorMutexUnresponsive, AVERROR_EXTERNAL, "mutex unresponsive" },
91 { EB_ErrorDestroyMutexFailed, AVERROR_EXTERNAL, "failed to destroy mutex" },
92 { EB_NoErrorEmptyQueue, AVERROR(EAGAIN), "empty queue" },
93 };
94
svt_map_error(EbErrorType eb_err,const char ** desc)95 static int svt_map_error(EbErrorType eb_err, const char **desc)
96 {
97 int i;
98
99 av_assert0(desc);
100 for (i = 0; i < FF_ARRAY_ELEMS(svt_errors); i++) {
101 if (svt_errors[i].eb_err == eb_err) {
102 *desc = svt_errors[i].desc;
103 return svt_errors[i].av_err;
104 }
105 }
106 *desc = "unknown error";
107 return AVERROR_UNKNOWN;
108 }
109
svt_print_error(void * log_ctx,EbErrorType err,const char * error_string)110 static int svt_print_error(void *log_ctx, EbErrorType err,
111 const char *error_string)
112 {
113 const char *desc;
114 int ret = svt_map_error(err, &desc);
115
116 av_log(log_ctx, AV_LOG_ERROR, "%s: %s (0x%x)\n", error_string, desc, err);
117
118 return ret;
119 }
120
alloc_buffer(EbSvtAv1EncConfiguration * config,SvtContext * svt_enc)121 static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
122 {
123 const int pack_mode_10bit =
124 (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
125 const size_t luma_size_8bit =
126 config->source_width * config->source_height * (1 << pack_mode_10bit);
127 const size_t luma_size_10bit =
128 (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
129
130 EbSvtIOFormat *in_data;
131
132 svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
133
134 // allocate buffer for in and out
135 svt_enc->in_buf = av_mallocz(sizeof(*svt_enc->in_buf));
136 if (!svt_enc->in_buf)
137 return AVERROR(ENOMEM);
138
139 svt_enc->in_buf->p_buffer = av_mallocz(sizeof(*in_data));
140 if (!svt_enc->in_buf->p_buffer)
141 return AVERROR(ENOMEM);
142
143 svt_enc->in_buf->size = sizeof(*svt_enc->in_buf);
144
145 return 0;
146
147 }
148
config_enc_params(EbSvtAv1EncConfiguration * param,AVCodecContext * avctx)149 static int config_enc_params(EbSvtAv1EncConfiguration *param,
150 AVCodecContext *avctx)
151 {
152 SvtContext *svt_enc = avctx->priv_data;
153 const AVPixFmtDescriptor *desc;
154
155 param->source_width = avctx->width;
156 param->source_height = avctx->height;
157
158 desc = av_pix_fmt_desc_get(avctx->pix_fmt);
159 param->encoder_bit_depth = desc->comp[0].depth;
160
161 if (desc->log2_chroma_w == 1 && desc->log2_chroma_h == 1)
162 param->encoder_color_format = EB_YUV420;
163 else if (desc->log2_chroma_w == 1 && desc->log2_chroma_h == 0)
164 param->encoder_color_format = EB_YUV422;
165 else if (!desc->log2_chroma_w && !desc->log2_chroma_h)
166 param->encoder_color_format = EB_YUV444;
167 else {
168 av_log(avctx, AV_LOG_ERROR , "Unsupported pixel format\n");
169 return AVERROR(EINVAL);
170 }
171
172 if (avctx->profile != FF_PROFILE_UNKNOWN)
173 param->profile = avctx->profile;
174
175 if (avctx->level != FF_LEVEL_UNKNOWN)
176 param->level = avctx->level;
177
178 if ((param->encoder_color_format == EB_YUV422 || param->encoder_bit_depth > 10)
179 && param->profile != FF_PROFILE_AV1_PROFESSIONAL ) {
180 av_log(avctx, AV_LOG_WARNING, "Forcing Professional profile\n");
181 param->profile = FF_PROFILE_AV1_PROFESSIONAL;
182 } else if (param->encoder_color_format == EB_YUV444 && param->profile != FF_PROFILE_AV1_HIGH) {
183 av_log(avctx, AV_LOG_WARNING, "Forcing High profile\n");
184 param->profile = FF_PROFILE_AV1_HIGH;
185 }
186
187 // Update param from options
188 param->hierarchical_levels = svt_enc->hierarchical_level;
189 param->enc_mode = svt_enc->enc_mode;
190 param->tier = svt_enc->tier;
191 param->rate_control_mode = svt_enc->rc_mode;
192 param->scene_change_detection = svt_enc->scd;
193 param->qp = svt_enc->qp;
194
195 param->target_bit_rate = avctx->bit_rate;
196
197 if (avctx->gop_size > 0)
198 param->intra_period_length = avctx->gop_size - 1;
199
200 if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
201 param->frame_rate_numerator = avctx->framerate.num;
202 param->frame_rate_denominator = avctx->framerate.den;
203 } else {
204 param->frame_rate_numerator = avctx->time_base.den;
205 param->frame_rate_denominator = avctx->time_base.num * avctx->ticks_per_frame;
206 }
207
208 if (param->rate_control_mode) {
209 param->max_qp_allowed = avctx->qmax;
210 param->min_qp_allowed = avctx->qmin;
211 }
212
213 param->intra_refresh_type = 2; /* Real keyframes only */
214
215 if (svt_enc->la_depth >= 0)
216 param->look_ahead_distance = svt_enc->la_depth;
217
218 param->tile_columns = svt_enc->tile_columns;
219 param->tile_rows = svt_enc->tile_rows;
220
221 return 0;
222 }
223
read_in_data(EbSvtAv1EncConfiguration * param,const AVFrame * frame,EbBufferHeaderType * header_ptr)224 static int read_in_data(EbSvtAv1EncConfiguration *param, const AVFrame *frame,
225 EbBufferHeaderType *header_ptr)
226 {
227 EbSvtIOFormat *in_data = (EbSvtIOFormat *)header_ptr->p_buffer;
228 ptrdiff_t linesizes[4];
229 size_t sizes[4];
230 int bytes_shift = param->encoder_bit_depth > 8 ? 1 : 0;
231 int ret, frame_size;
232
233 for (int i = 0; i < 4; i++)
234 linesizes[i] = frame->linesize[i];
235
236 ret = av_image_fill_plane_sizes(sizes, frame->format, frame->height,
237 linesizes);
238 if (ret < 0)
239 return ret;
240
241 frame_size = 0;
242 for (int i = 0; i < 4; i++) {
243 if (sizes[i] > INT_MAX - frame_size)
244 return AVERROR(EINVAL);
245 frame_size += sizes[i];
246 }
247
248 in_data->luma = frame->data[0];
249 in_data->cb = frame->data[1];
250 in_data->cr = frame->data[2];
251
252 in_data->y_stride = AV_CEIL_RSHIFT(frame->linesize[0], bytes_shift);
253 in_data->cb_stride = AV_CEIL_RSHIFT(frame->linesize[1], bytes_shift);
254 in_data->cr_stride = AV_CEIL_RSHIFT(frame->linesize[2], bytes_shift);
255
256 header_ptr->n_filled_len = frame_size;
257
258 return 0;
259 }
260
eb_enc_init(AVCodecContext * avctx)261 static av_cold int eb_enc_init(AVCodecContext *avctx)
262 {
263 SvtContext *svt_enc = avctx->priv_data;
264 EbErrorType svt_ret;
265 int ret;
266
267 svt_enc->eos_flag = EOS_NOT_REACHED;
268
269 svt_ret = svt_av1_enc_init_handle(&svt_enc->svt_handle, svt_enc, &svt_enc->enc_params);
270 if (svt_ret != EB_ErrorNone) {
271 return svt_print_error(avctx, svt_ret, "Error initializing encoder handle");
272 }
273
274 ret = config_enc_params(&svt_enc->enc_params, avctx);
275 if (ret < 0) {
276 av_log(avctx, AV_LOG_ERROR, "Error configuring encoder parameters\n");
277 return ret;
278 }
279
280 svt_ret = svt_av1_enc_set_parameter(svt_enc->svt_handle, &svt_enc->enc_params);
281 if (svt_ret != EB_ErrorNone) {
282 return svt_print_error(avctx, svt_ret, "Error setting encoder parameters");
283 }
284
285 svt_ret = svt_av1_enc_init(svt_enc->svt_handle);
286 if (svt_ret != EB_ErrorNone) {
287 return svt_print_error(avctx, svt_ret, "Error initializing encoder");
288 }
289
290 if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
291 EbBufferHeaderType *headerPtr = NULL;
292
293 svt_ret = svt_av1_enc_stream_header(svt_enc->svt_handle, &headerPtr);
294 if (svt_ret != EB_ErrorNone) {
295 return svt_print_error(avctx, svt_ret, "Error building stream header");
296 }
297
298 avctx->extradata_size = headerPtr->n_filled_len;
299 avctx->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
300 if (!avctx->extradata) {
301 av_log(avctx, AV_LOG_ERROR,
302 "Cannot allocate AV1 header of size %d.\n", avctx->extradata_size);
303 return AVERROR(ENOMEM);
304 }
305
306 memcpy(avctx->extradata, headerPtr->p_buffer, avctx->extradata_size);
307
308 svt_ret = svt_av1_enc_stream_header_release(headerPtr);
309 if (svt_ret != EB_ErrorNone) {
310 return svt_print_error(avctx, svt_ret, "Error freeing stream header");
311 }
312 }
313
314 svt_enc->frame = av_frame_alloc();
315 if (!svt_enc->frame)
316 return AVERROR(ENOMEM);
317
318 return alloc_buffer(&svt_enc->enc_params, svt_enc);
319 }
320
eb_send_frame(AVCodecContext * avctx,const AVFrame * frame)321 static int eb_send_frame(AVCodecContext *avctx, const AVFrame *frame)
322 {
323 SvtContext *svt_enc = avctx->priv_data;
324 EbBufferHeaderType *headerPtr = svt_enc->in_buf;
325 int ret;
326
327 if (!frame) {
328 EbBufferHeaderType headerPtrLast;
329
330 if (svt_enc->eos_flag == EOS_SENT)
331 return 0;
332
333 headerPtrLast.n_alloc_len = 0;
334 headerPtrLast.n_filled_len = 0;
335 headerPtrLast.n_tick_count = 0;
336 headerPtrLast.p_app_private = NULL;
337 headerPtrLast.p_buffer = NULL;
338 headerPtrLast.flags = EB_BUFFERFLAG_EOS;
339
340 svt_av1_enc_send_picture(svt_enc->svt_handle, &headerPtrLast);
341 svt_enc->eos_flag = EOS_SENT;
342 return 0;
343 }
344
345 ret = read_in_data(&svt_enc->enc_params, frame, headerPtr);
346 if (ret < 0)
347 return ret;
348
349 headerPtr->flags = 0;
350 headerPtr->p_app_private = NULL;
351 headerPtr->pts = frame->pts;
352
353 svt_av1_enc_send_picture(svt_enc->svt_handle, headerPtr);
354
355 return 0;
356 }
357
get_output_ref(AVCodecContext * avctx,SvtContext * svt_enc,int filled_len)358 static AVBufferRef *get_output_ref(AVCodecContext *avctx, SvtContext *svt_enc, int filled_len)
359 {
360 if (filled_len > svt_enc->max_tu_size) {
361 const int max_frames = 8;
362 int max_tu_size;
363
364 if (filled_len > svt_enc->raw_size * max_frames) {
365 av_log(avctx, AV_LOG_ERROR, "TU size > %d raw frame size.\n", max_frames);
366 return NULL;
367 }
368
369 max_tu_size = 1 << av_ceil_log2(filled_len);
370 av_buffer_pool_uninit(&svt_enc->pool);
371 svt_enc->pool = av_buffer_pool_init(max_tu_size + AV_INPUT_BUFFER_PADDING_SIZE, NULL);
372 if (!svt_enc->pool)
373 return NULL;
374
375 svt_enc->max_tu_size = max_tu_size;
376 }
377 av_assert0(svt_enc->pool);
378
379 return av_buffer_pool_get(svt_enc->pool);
380 }
381
eb_receive_packet(AVCodecContext * avctx,AVPacket * pkt)382 static int eb_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
383 {
384 SvtContext *svt_enc = avctx->priv_data;
385 EbBufferHeaderType *headerPtr;
386 AVFrame *frame = svt_enc->frame;
387 EbErrorType svt_ret;
388 AVBufferRef *ref;
389 int ret = 0, pict_type;
390
391 if (svt_enc->eos_flag == EOS_RECEIVED)
392 return AVERROR_EOF;
393
394 ret = ff_encode_get_frame(avctx, frame);
395 if (ret < 0 && ret != AVERROR_EOF)
396 return ret;
397 if (ret == AVERROR_EOF)
398 frame = NULL;
399
400 ret = eb_send_frame(avctx, frame);
401 if (ret < 0)
402 return ret;
403 av_frame_unref(svt_enc->frame);
404
405 svt_ret = svt_av1_enc_get_packet(svt_enc->svt_handle, &headerPtr, svt_enc->eos_flag);
406 if (svt_ret == EB_NoErrorEmptyQueue)
407 return AVERROR(EAGAIN);
408
409 ref = get_output_ref(avctx, svt_enc, headerPtr->n_filled_len);
410 if (!ref) {
411 av_log(avctx, AV_LOG_ERROR, "Failed to allocate output packet.\n");
412 svt_av1_enc_release_out_buffer(&headerPtr);
413 return AVERROR(ENOMEM);
414 }
415 pkt->buf = ref;
416 pkt->data = ref->data;
417
418 memcpy(pkt->data, headerPtr->p_buffer, headerPtr->n_filled_len);
419 memset(pkt->data + headerPtr->n_filled_len, 0, AV_INPUT_BUFFER_PADDING_SIZE);
420
421 pkt->size = headerPtr->n_filled_len;
422 pkt->pts = headerPtr->pts;
423 pkt->dts = headerPtr->dts;
424
425 switch (headerPtr->pic_type) {
426 case EB_AV1_KEY_PICTURE:
427 pkt->flags |= AV_PKT_FLAG_KEY;
428 // fall-through
429 case EB_AV1_INTRA_ONLY_PICTURE:
430 pict_type = AV_PICTURE_TYPE_I;
431 break;
432 case EB_AV1_INVALID_PICTURE:
433 pict_type = AV_PICTURE_TYPE_NONE;
434 break;
435 default:
436 pict_type = AV_PICTURE_TYPE_P;
437 break;
438 }
439
440 if (headerPtr->pic_type == EB_AV1_NON_REF_PICTURE)
441 pkt->flags |= AV_PKT_FLAG_DISPOSABLE;
442
443 if (headerPtr->flags & EB_BUFFERFLAG_EOS)
444 svt_enc->eos_flag = EOS_RECEIVED;
445
446 ff_side_data_set_encoder_stats(pkt, headerPtr->qp * FF_QP2LAMBDA, NULL, 0, pict_type);
447
448 svt_av1_enc_release_out_buffer(&headerPtr);
449
450 return 0;
451 }
452
eb_enc_close(AVCodecContext * avctx)453 static av_cold int eb_enc_close(AVCodecContext *avctx)
454 {
455 SvtContext *svt_enc = avctx->priv_data;
456
457 if (svt_enc->svt_handle) {
458 svt_av1_enc_deinit(svt_enc->svt_handle);
459 svt_av1_enc_deinit_handle(svt_enc->svt_handle);
460 }
461 if (svt_enc->in_buf) {
462 av_free(svt_enc->in_buf->p_buffer);
463 av_freep(&svt_enc->in_buf);
464 }
465
466 av_buffer_pool_uninit(&svt_enc->pool);
467 av_frame_free(&svt_enc->frame);
468
469 return 0;
470 }
471
472 #define OFFSET(x) offsetof(SvtContext, x)
473 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
474 static const AVOption options[] = {
475 { "hielevel", "Hierarchical prediction levels setting", OFFSET(hierarchical_level),
476 AV_OPT_TYPE_INT, { .i64 = 4 }, 3, 4, VE , "hielevel"},
477 { "3level", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, INT_MIN, INT_MAX, VE, "hielevel" },
478 { "4level", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 4 }, INT_MIN, INT_MAX, VE, "hielevel" },
479
480 { "la_depth", "Look ahead distance [0, 120]", OFFSET(la_depth),
481 AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 120, VE },
482
483 { "preset", "Encoding preset [0, 8]",
484 OFFSET(enc_mode), AV_OPT_TYPE_INT, { .i64 = MAX_ENC_PRESET }, 0, MAX_ENC_PRESET, VE },
485
486 { "tier", "Set operating point tier", OFFSET(tier),
487 AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE, "tier" },
488 { "main", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, VE, "tier" },
489 { "high", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, VE, "tier" },
490
491 FF_AV1_PROFILE_OPTS
492
493 #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
494 { .i64 = value }, 0, 0, VE, "avctx.level"
495 { LEVEL("2.0", 20) },
496 { LEVEL("2.1", 21) },
497 { LEVEL("2.2", 22) },
498 { LEVEL("2.3", 23) },
499 { LEVEL("3.0", 30) },
500 { LEVEL("3.1", 31) },
501 { LEVEL("3.2", 32) },
502 { LEVEL("3.3", 33) },
503 { LEVEL("4.0", 40) },
504 { LEVEL("4.1", 41) },
505 { LEVEL("4.2", 42) },
506 { LEVEL("4.3", 43) },
507 { LEVEL("5.0", 50) },
508 { LEVEL("5.1", 51) },
509 { LEVEL("5.2", 52) },
510 { LEVEL("5.3", 53) },
511 { LEVEL("6.0", 60) },
512 { LEVEL("6.1", 61) },
513 { LEVEL("6.2", 62) },
514 { LEVEL("6.3", 63) },
515 { LEVEL("7.0", 70) },
516 { LEVEL("7.1", 71) },
517 { LEVEL("7.2", 72) },
518 { LEVEL("7.3", 73) },
519 #undef LEVEL
520
521 { "rc", "Bit rate control mode", OFFSET(rc_mode),
522 AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 3, VE , "rc"},
523 { "cqp", "Constant quantizer", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "rc" },
524 { "vbr", "Variable Bit Rate, use a target bitrate for the entire stream", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "rc" },
525 { "cvbr", "Constrained Variable Bit Rate, use a target bitrate for each GOP", 0, AV_OPT_TYPE_CONST,{ .i64 = 2 }, INT_MIN, INT_MAX, VE, "rc" },
526
527 { "qp", "Quantizer to use with cqp rate control mode", OFFSET(qp),
528 AV_OPT_TYPE_INT, { .i64 = 50 }, 0, 63, VE },
529
530 { "sc_detection", "Scene change detection", OFFSET(scd),
531 AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
532
533 { "tile_columns", "Log2 of number of tile columns to use", OFFSET(tile_columns), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, VE},
534 { "tile_rows", "Log2 of number of tile rows to use", OFFSET(tile_rows), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 6, VE},
535
536 {NULL},
537 };
538
539 static const AVClass class = {
540 .class_name = "libsvtav1",
541 .item_name = av_default_item_name,
542 .option = options,
543 .version = LIBAVUTIL_VERSION_INT,
544 };
545
546 static const AVCodecDefault eb_enc_defaults[] = {
547 { "b", "7M" },
548 { "g", "-1" },
549 { "qmin", "0" },
550 { "qmax", "63" },
551 { NULL },
552 };
553
554 AVCodec ff_libsvtav1_encoder = {
555 .name = "libsvtav1",
556 .long_name = NULL_IF_CONFIG_SMALL("SVT-AV1(Scalable Video Technology for AV1) encoder"),
557 .priv_data_size = sizeof(SvtContext),
558 .type = AVMEDIA_TYPE_VIDEO,
559 .id = AV_CODEC_ID_AV1,
560 .init = eb_enc_init,
561 .receive_packet = eb_receive_packet,
562 .close = eb_enc_close,
563 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS,
564 .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
565 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
566 AV_PIX_FMT_YUV420P10,
567 AV_PIX_FMT_NONE },
568 .priv_class = &class,
569 .defaults = eb_enc_defaults,
570 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
571 .wrapper_name = "libsvtav1",
572 };
573