FFmpeg
libsvtav1.c
Go to the documentation of this file.
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/intreadwrite.h"
32 #include "libavutil/opt.h"
33 #include "libavutil/pixdesc.h"
34 #include "libavutil/avassert.h"
35 
36 #include "codec_internal.h"
37 #include "internal.h"
38 #include "encode.h"
39 #include "packet_internal.h"
40 #include "avcodec.h"
41 #include "profiles.h"
42 
43 typedef enum eos_status {
47 }EOS_STATUS;
48 
49 typedef struct SvtContext {
50  const AVClass *class;
51 
52  EbSvtAv1EncConfiguration enc_params;
53  EbComponentType *svt_handle;
54 
55  EbBufferHeaderType *in_buf;
56  int raw_size;
58 
60 
62 
63  EOS_STATUS eos_flag;
64 
65  // User options.
67  int enc_mode;
68  int crf;
69  int qp;
70 } SvtContext;
71 
72 static const struct {
73  EbErrorType eb_err;
74  int av_err;
75  const char *desc;
76 } svt_errors[] = {
77  { EB_ErrorNone, 0, "success" },
78  { EB_ErrorInsufficientResources, AVERROR(ENOMEM), "insufficient resources" },
79  { EB_ErrorUndefined, AVERROR(EINVAL), "undefined error" },
80  { EB_ErrorInvalidComponent, AVERROR(EINVAL), "invalid component" },
81  { EB_ErrorBadParameter, AVERROR(EINVAL), "bad parameter" },
82  { EB_ErrorDestroyThreadFailed, AVERROR_EXTERNAL, "failed to destroy thread" },
83  { EB_ErrorSemaphoreUnresponsive, AVERROR_EXTERNAL, "semaphore unresponsive" },
84  { EB_ErrorDestroySemaphoreFailed, AVERROR_EXTERNAL, "failed to destroy semaphore"},
85  { EB_ErrorCreateMutexFailed, AVERROR_EXTERNAL, "failed to create mutex" },
86  { EB_ErrorMutexUnresponsive, AVERROR_EXTERNAL, "mutex unresponsive" },
87  { EB_ErrorDestroyMutexFailed, AVERROR_EXTERNAL, "failed to destroy mutex" },
88  { EB_NoErrorEmptyQueue, AVERROR(EAGAIN), "empty queue" },
89 };
90 
91 static int svt_map_error(EbErrorType eb_err, const char **desc)
92 {
93  int i;
94 
96  for (i = 0; i < FF_ARRAY_ELEMS(svt_errors); i++) {
97  if (svt_errors[i].eb_err == eb_err) {
98  *desc = svt_errors[i].desc;
99  return svt_errors[i].av_err;
100  }
101  }
102  *desc = "unknown error";
103  return AVERROR_UNKNOWN;
104 }
105 
106 static int svt_print_error(void *log_ctx, EbErrorType err,
107  const char *error_string)
108 {
109  const char *desc;
110  int ret = svt_map_error(err, &desc);
111 
112  av_log(log_ctx, AV_LOG_ERROR, "%s: %s (0x%x)\n", error_string, desc, err);
113 
114  return ret;
115 }
116 
117 static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
118 {
119  const size_t luma_size = config->source_width * config->source_height *
120  (config->encoder_bit_depth > 8 ? 2 : 1);
121 
122  EbSvtIOFormat *in_data;
123 
124  svt_enc->raw_size = luma_size * 3 / 2;
125 
126  // allocate buffer for in and out
127  svt_enc->in_buf = av_mallocz(sizeof(*svt_enc->in_buf));
128  if (!svt_enc->in_buf)
129  return AVERROR(ENOMEM);
130 
131  svt_enc->in_buf->p_buffer = av_mallocz(sizeof(*in_data));
132  if (!svt_enc->in_buf->p_buffer)
133  return AVERROR(ENOMEM);
134 
135  svt_enc->in_buf->size = sizeof(*svt_enc->in_buf);
136 
137  return 0;
138 
139 }
140 
141 static void handle_mdcv(struct EbSvtAv1MasteringDisplayInfo *dst,
142  const AVMasteringDisplayMetadata *mdcv)
143 {
144  if (mdcv->has_primaries) {
145  const struct EbSvtAv1ChromaPoints *const points[] = {
146  &dst->r,
147  &dst->g,
148  &dst->b,
149  };
150 
151  for (int i = 0; i < 3; i++) {
152  const struct EbSvtAv1ChromaPoints *dst = points[i];
153  const AVRational *src = mdcv->display_primaries[i];
154 
155  AV_WB16(&dst->x,
156  av_rescale_q(1, src[0], (AVRational){ 1, (1 << 16) }));
157  AV_WB16(&dst->y,
158  av_rescale_q(1, src[1], (AVRational){ 1, (1 << 16) }));
159  }
160 
161  AV_WB16(&dst->white_point.x,
162  av_rescale_q(1, mdcv->white_point[0],
163  (AVRational){ 1, (1 << 16) }));
164  AV_WB16(&dst->white_point.y,
165  av_rescale_q(1, mdcv->white_point[1],
166  (AVRational){ 1, (1 << 16) }));
167  }
168 
169  if (mdcv->has_luminance) {
170  AV_WB32(&dst->max_luma,
171  av_rescale_q(1, mdcv->max_luminance,
172  (AVRational){ 1, (1 << 8) }));
173  AV_WB32(&dst->min_luma,
174  av_rescale_q(1, mdcv->min_luminance,
175  (AVRational){ 1, (1 << 14) }));
176  }
177 }
178 
179 static void handle_side_data(AVCodecContext *avctx,
180  EbSvtAv1EncConfiguration *param)
181 {
182  const AVFrameSideData *cll_sd =
185  const AVFrameSideData *mdcv_sd =
187  avctx->nb_decoded_side_data,
189 
190  if (cll_sd) {
191  const AVContentLightMetadata *cll =
192  (AVContentLightMetadata *)cll_sd->data;
193 
194  AV_WB16(&param->content_light_level.max_cll, cll->MaxCLL);
195  AV_WB16(&param->content_light_level.max_fall, cll->MaxFALL);
196  }
197 
198  if (mdcv_sd) {
199  handle_mdcv(&param->mastering_display,
200  (AVMasteringDisplayMetadata *)mdcv_sd->data);
201  }
202 }
203 
204 static int config_enc_params(EbSvtAv1EncConfiguration *param,
205  AVCodecContext *avctx)
206 {
207  SvtContext *svt_enc = avctx->priv_data;
208  const AVPixFmtDescriptor *desc;
209  AVDictionaryEntry *en = NULL;
210 
211  // Update param from options
212  if (svt_enc->enc_mode >= -1)
213  param->enc_mode = svt_enc->enc_mode;
214 
215  if (avctx->bit_rate) {
216  param->target_bit_rate = avctx->bit_rate;
217  if (avctx->rc_max_rate != avctx->bit_rate)
218  param->rate_control_mode = 1;
219  else
220  param->rate_control_mode = 2;
221 
222  param->max_qp_allowed = avctx->qmax;
223  param->min_qp_allowed = avctx->qmin;
224  }
225  param->max_bit_rate = avctx->rc_max_rate;
226  if ((avctx->bit_rate > 0 || avctx->rc_max_rate > 0) && avctx->rc_buffer_size)
227  param->maximum_buffer_size_ms =
228  avctx->rc_buffer_size * 1000LL /
229  FFMAX(avctx->bit_rate, avctx->rc_max_rate);
230 
231  if (svt_enc->crf > 0) {
232  param->qp = svt_enc->crf;
233  param->rate_control_mode = 0;
234  } else if (svt_enc->qp > 0) {
235  param->qp = svt_enc->qp;
236  param->rate_control_mode = 0;
237  param->enable_adaptive_quantization = 0;
238  }
239 
240  desc = av_pix_fmt_desc_get(avctx->pix_fmt);
241  param->color_primaries = avctx->color_primaries;
242  param->matrix_coefficients = (desc->flags & AV_PIX_FMT_FLAG_RGB) ?
243  AVCOL_SPC_RGB : avctx->colorspace;
244  param->transfer_characteristics = avctx->color_trc;
245 
247  param->color_range = avctx->color_range == AVCOL_RANGE_JPEG;
248  else
249  param->color_range = !!(desc->flags & AV_PIX_FMT_FLAG_RGB);
250 
251 #if SVT_AV1_CHECK_VERSION(1, 0, 0)
253  const char *name =
255 
256  switch (avctx->chroma_sample_location) {
257  case AVCHROMA_LOC_LEFT:
258  param->chroma_sample_position = EB_CSP_VERTICAL;
259  break;
261  param->chroma_sample_position = EB_CSP_COLOCATED;
262  break;
263  default:
264  if (!name)
265  break;
266 
267  av_log(avctx, AV_LOG_WARNING,
268  "Specified chroma sample location %s is unsupported "
269  "on the AV1 bit stream level. Usage of a container that "
270  "allows passing this information - such as Matroska - "
271  "is recommended.\n",
272  name);
273  break;
274  }
275  }
276 #endif
277 
278  if (avctx->profile != AV_PROFILE_UNKNOWN)
279  param->profile = avctx->profile;
280 
281  if (avctx->level != AV_LEVEL_UNKNOWN)
282  param->level = avctx->level;
283 
284  // gop_size == 1 case is handled when encoding each frame by setting
285  // pic_type to EB_AV1_KEY_PICTURE. For gop_size > 1, set the
286  // intra_period_length. Even though setting intra_period_length to 0 should
287  // work in this case, it does not.
288  // See: https://gitlab.com/AOMediaCodec/SVT-AV1/-/issues/2076
289  if (avctx->gop_size > 1)
290  param->intra_period_length = avctx->gop_size - 1;
291 
292 #if SVT_AV1_CHECK_VERSION(1, 1, 0)
293  // In order for SVT-AV1 to force keyframes by setting pic_type to
294  // EB_AV1_KEY_PICTURE on any frame, force_key_frames has to be set. Note
295  // that this does not force all frames to be keyframes (it only forces a
296  // keyframe with pic_type is set to EB_AV1_KEY_PICTURE). As of now, SVT-AV1
297  // does not support arbitrary keyframe requests by setting pic_type to
298  // EB_AV1_KEY_PICTURE, so it is done only when gop_size == 1.
299  // FIXME: When SVT-AV1 supports arbitrary keyframe requests, this code needs
300  // to be updated to set force_key_frames accordingly.
301  if (avctx->gop_size == 1)
302  param->force_key_frames = 1;
303 #endif
304 
305  if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
306  param->frame_rate_numerator = avctx->framerate.num;
307  param->frame_rate_denominator = avctx->framerate.den;
308  } else {
309  param->frame_rate_numerator = avctx->time_base.den;
311  param->frame_rate_denominator = avctx->time_base.num
312 #if FF_API_TICKS_PER_FRAME
313  * avctx->ticks_per_frame
314 #endif
315  ;
317  }
318 
319  /* 2 = IDR, closed GOP, 1 = CRA, open GOP */
320  param->intra_refresh_type = avctx->flags & AV_CODEC_FLAG_CLOSED_GOP ? 2 : 1;
321 
322  handle_side_data(avctx, param);
323 
324 #if SVT_AV1_CHECK_VERSION(0, 9, 1)
325  while ((en = av_dict_get(svt_enc->svtav1_opts, "", en, AV_DICT_IGNORE_SUFFIX))) {
326  EbErrorType ret = svt_av1_enc_parse_parameter(param, en->key, en->value);
327  if (ret != EB_ErrorNone) {
329  av_log(avctx, level, "Error parsing option %s: %s.\n", en->key, en->value);
330  if (avctx->err_recognition & AV_EF_EXPLODE)
331  return AVERROR(EINVAL);
332  }
333  }
334 #else
335  if ((en = av_dict_get(svt_enc->svtav1_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
337  av_log(avctx, level, "svt-params needs libavcodec to be compiled with SVT-AV1 "
338  "headers >= 0.9.1.\n");
339  if (avctx->err_recognition & AV_EF_EXPLODE)
340  return AVERROR(ENOSYS);
341  }
342 #endif
343 
344  param->source_width = avctx->width;
345  param->source_height = avctx->height;
346 
347  param->encoder_bit_depth = desc->comp[0].depth;
348 
349  if (desc->log2_chroma_w == 1 && desc->log2_chroma_h == 1)
350  param->encoder_color_format = EB_YUV420;
351  else if (desc->log2_chroma_w == 1 && desc->log2_chroma_h == 0)
352  param->encoder_color_format = EB_YUV422;
353  else if (!desc->log2_chroma_w && !desc->log2_chroma_h)
354  param->encoder_color_format = EB_YUV444;
355  else {
356  av_log(avctx, AV_LOG_ERROR , "Unsupported pixel format\n");
357  return AVERROR(EINVAL);
358  }
359 
360  if ((param->encoder_color_format == EB_YUV422 || param->encoder_bit_depth > 10)
361  && param->profile != AV_PROFILE_AV1_PROFESSIONAL ) {
362  av_log(avctx, AV_LOG_WARNING, "Forcing Professional profile\n");
363  param->profile = AV_PROFILE_AV1_PROFESSIONAL;
364  } else if (param->encoder_color_format == EB_YUV444 && param->profile != AV_PROFILE_AV1_HIGH) {
365  av_log(avctx, AV_LOG_WARNING, "Forcing High profile\n");
366  param->profile = AV_PROFILE_AV1_HIGH;
367  }
368 
369  avctx->bit_rate = param->rate_control_mode > 0 ?
370  param->target_bit_rate : 0;
371  avctx->rc_max_rate = param->max_bit_rate;
372  avctx->rc_buffer_size = param->maximum_buffer_size_ms *
373  FFMAX(avctx->bit_rate, avctx->rc_max_rate) / 1000LL;
374 
375  if (avctx->bit_rate || avctx->rc_max_rate || avctx->rc_buffer_size) {
376  AVCPBProperties *cpb_props = ff_encode_add_cpb_side_data(avctx);
377  if (!cpb_props)
378  return AVERROR(ENOMEM);
379 
380  cpb_props->buffer_size = avctx->rc_buffer_size;
381  cpb_props->max_bitrate = avctx->rc_max_rate;
382  cpb_props->avg_bitrate = avctx->bit_rate;
383  }
384 
385  return 0;
386 }
387 
388 static int read_in_data(EbSvtAv1EncConfiguration *param, const AVFrame *frame,
389  EbBufferHeaderType *header_ptr)
390 {
391  EbSvtIOFormat *in_data = (EbSvtIOFormat *)header_ptr->p_buffer;
392  ptrdiff_t linesizes[4];
393  size_t sizes[4];
394  int bytes_shift = param->encoder_bit_depth > 8 ? 1 : 0;
395  int ret, frame_size;
396 
397  for (int i = 0; i < 4; i++)
398  linesizes[i] = frame->linesize[i];
399 
401  linesizes);
402  if (ret < 0)
403  return ret;
404 
405  frame_size = 0;
406  for (int i = 0; i < 4; i++) {
407  if (sizes[i] > INT_MAX - frame_size)
408  return AVERROR(EINVAL);
409  frame_size += sizes[i];
410  }
411 
412  in_data->luma = frame->data[0];
413  in_data->cb = frame->data[1];
414  in_data->cr = frame->data[2];
415 
416  in_data->y_stride = AV_CEIL_RSHIFT(frame->linesize[0], bytes_shift);
417  in_data->cb_stride = AV_CEIL_RSHIFT(frame->linesize[1], bytes_shift);
418  in_data->cr_stride = AV_CEIL_RSHIFT(frame->linesize[2], bytes_shift);
419 
420  header_ptr->n_filled_len = frame_size;
421 
422  return 0;
423 }
424 
426 {
427  SvtContext *svt_enc = avctx->priv_data;
428  EbErrorType svt_ret;
429  int ret;
430 
431  svt_enc->eos_flag = EOS_NOT_REACHED;
432 
433  svt_ret = svt_av1_enc_init_handle(&svt_enc->svt_handle, svt_enc, &svt_enc->enc_params);
434  if (svt_ret != EB_ErrorNone) {
435  return svt_print_error(avctx, svt_ret, "Error initializing encoder handle");
436  }
437 
438  ret = config_enc_params(&svt_enc->enc_params, avctx);
439  if (ret < 0) {
440  av_log(avctx, AV_LOG_ERROR, "Error configuring encoder parameters\n");
441  return ret;
442  }
443 
444  svt_ret = svt_av1_enc_set_parameter(svt_enc->svt_handle, &svt_enc->enc_params);
445  if (svt_ret != EB_ErrorNone) {
446  return svt_print_error(avctx, svt_ret, "Error setting encoder parameters");
447  }
448 
449  svt_ret = svt_av1_enc_init(svt_enc->svt_handle);
450  if (svt_ret != EB_ErrorNone) {
451  return svt_print_error(avctx, svt_ret, "Error initializing encoder");
452  }
453 
454  if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
455  EbBufferHeaderType *headerPtr = NULL;
456 
457  svt_ret = svt_av1_enc_stream_header(svt_enc->svt_handle, &headerPtr);
458  if (svt_ret != EB_ErrorNone) {
459  return svt_print_error(avctx, svt_ret, "Error building stream header");
460  }
461 
462  avctx->extradata_size = headerPtr->n_filled_len;
464  if (!avctx->extradata) {
465  av_log(avctx, AV_LOG_ERROR,
466  "Cannot allocate AV1 header of size %d.\n", avctx->extradata_size);
467  return AVERROR(ENOMEM);
468  }
469 
470  memcpy(avctx->extradata, headerPtr->p_buffer, avctx->extradata_size);
471 
472  svt_ret = svt_av1_enc_stream_header_release(headerPtr);
473  if (svt_ret != EB_ErrorNone) {
474  return svt_print_error(avctx, svt_ret, "Error freeing stream header");
475  }
476  }
477 
478  svt_enc->frame = av_frame_alloc();
479  if (!svt_enc->frame)
480  return AVERROR(ENOMEM);
481 
482  return alloc_buffer(&svt_enc->enc_params, svt_enc);
483 }
484 
485 static int eb_send_frame(AVCodecContext *avctx, const AVFrame *frame)
486 {
487  SvtContext *svt_enc = avctx->priv_data;
488  EbBufferHeaderType *headerPtr = svt_enc->in_buf;
489  int ret;
490 
491  if (!frame) {
492  EbBufferHeaderType headerPtrLast;
493 
494  if (svt_enc->eos_flag == EOS_SENT)
495  return 0;
496 
497  memset(&headerPtrLast, 0, sizeof(headerPtrLast));
498  headerPtrLast.pic_type = EB_AV1_INVALID_PICTURE;
499  headerPtrLast.flags = EB_BUFFERFLAG_EOS;
500 
501  svt_av1_enc_send_picture(svt_enc->svt_handle, &headerPtrLast);
502  svt_enc->eos_flag = EOS_SENT;
503  return 0;
504  }
505 
506  ret = read_in_data(&svt_enc->enc_params, frame, headerPtr);
507  if (ret < 0)
508  return ret;
509 
510  headerPtr->flags = 0;
511  headerPtr->p_app_private = NULL;
512  headerPtr->pts = frame->pts;
513 
514  switch (frame->pict_type) {
515  case AV_PICTURE_TYPE_I:
516  headerPtr->pic_type = EB_AV1_KEY_PICTURE;
517  break;
518  default:
519  // Actually means auto, or default.
520  headerPtr->pic_type = EB_AV1_INVALID_PICTURE;
521  break;
522  }
523 
524  if (avctx->gop_size == 1)
525  headerPtr->pic_type = EB_AV1_KEY_PICTURE;
526 
527  svt_av1_enc_send_picture(svt_enc->svt_handle, headerPtr);
528 
529  return 0;
530 }
531 
532 static AVBufferRef *get_output_ref(AVCodecContext *avctx, SvtContext *svt_enc, int filled_len)
533 {
534  if (filled_len > svt_enc->max_tu_size) {
535  const int max_frames = 8;
536  int max_tu_size;
537 
538  if (filled_len > svt_enc->raw_size * max_frames) {
539  av_log(avctx, AV_LOG_ERROR, "TU size > %d raw frame size.\n", max_frames);
540  return NULL;
541  }
542 
543  max_tu_size = 1 << av_ceil_log2(filled_len);
544  av_buffer_pool_uninit(&svt_enc->pool);
545  svt_enc->pool = av_buffer_pool_init(max_tu_size + AV_INPUT_BUFFER_PADDING_SIZE, NULL);
546  if (!svt_enc->pool)
547  return NULL;
548 
549  svt_enc->max_tu_size = max_tu_size;
550  }
551  av_assert0(svt_enc->pool);
552 
553  return av_buffer_pool_get(svt_enc->pool);
554 }
555 
557 {
558  SvtContext *svt_enc = avctx->priv_data;
559  EbBufferHeaderType *headerPtr;
560  AVFrame *frame = svt_enc->frame;
561  EbErrorType svt_ret;
562  AVBufferRef *ref;
563  int ret = 0, pict_type;
564 
565  if (svt_enc->eos_flag == EOS_RECEIVED)
566  return AVERROR_EOF;
567 
568  ret = ff_encode_get_frame(avctx, frame);
569  if (ret < 0 && ret != AVERROR_EOF)
570  return ret;
571  if (ret == AVERROR_EOF)
572  frame = NULL;
573 
574  ret = eb_send_frame(avctx, frame);
575  if (ret < 0)
576  return ret;
577  av_frame_unref(svt_enc->frame);
578 
579  svt_ret = svt_av1_enc_get_packet(svt_enc->svt_handle, &headerPtr, svt_enc->eos_flag);
580  if (svt_ret == EB_NoErrorEmptyQueue)
581  return AVERROR(EAGAIN);
582 
583 #if SVT_AV1_CHECK_VERSION(2, 0, 0)
584  if (headerPtr->flags & EB_BUFFERFLAG_EOS) {
585  svt_enc->eos_flag = EOS_RECEIVED;
586  svt_av1_enc_release_out_buffer(&headerPtr);
587  return AVERROR_EOF;
588  }
589 #endif
590 
591  ref = get_output_ref(avctx, svt_enc, headerPtr->n_filled_len);
592  if (!ref) {
593  av_log(avctx, AV_LOG_ERROR, "Failed to allocate output packet.\n");
594  svt_av1_enc_release_out_buffer(&headerPtr);
595  return AVERROR(ENOMEM);
596  }
597  pkt->buf = ref;
598  pkt->data = ref->data;
599 
600  memcpy(pkt->data, headerPtr->p_buffer, headerPtr->n_filled_len);
601  memset(pkt->data + headerPtr->n_filled_len, 0, AV_INPUT_BUFFER_PADDING_SIZE);
602 
603  pkt->size = headerPtr->n_filled_len;
604  pkt->pts = headerPtr->pts;
605  pkt->dts = headerPtr->dts;
606 
607  switch (headerPtr->pic_type) {
608  case EB_AV1_KEY_PICTURE:
610  // fall-through
611  case EB_AV1_INTRA_ONLY_PICTURE:
612  pict_type = AV_PICTURE_TYPE_I;
613  break;
614  case EB_AV1_INVALID_PICTURE:
615  pict_type = AV_PICTURE_TYPE_NONE;
616  break;
617  default:
618  pict_type = AV_PICTURE_TYPE_P;
619  break;
620  }
621 
622  if (headerPtr->pic_type == EB_AV1_NON_REF_PICTURE)
624 
625 #if !(SVT_AV1_CHECK_VERSION(2, 0, 0))
626  if (headerPtr->flags & EB_BUFFERFLAG_EOS)
627  svt_enc->eos_flag = EOS_RECEIVED;
628 #endif
629 
630  ff_side_data_set_encoder_stats(pkt, headerPtr->qp * FF_QP2LAMBDA, NULL, 0, pict_type);
631 
632  svt_av1_enc_release_out_buffer(&headerPtr);
633 
634  return 0;
635 }
636 
638 {
639  SvtContext *svt_enc = avctx->priv_data;
640 
641  if (svt_enc->svt_handle) {
642  svt_av1_enc_deinit(svt_enc->svt_handle);
643  svt_av1_enc_deinit_handle(svt_enc->svt_handle);
644  }
645  if (svt_enc->in_buf) {
646  av_free(svt_enc->in_buf->p_buffer);
647  av_freep(&svt_enc->in_buf);
648  }
649 
650  av_buffer_pool_uninit(&svt_enc->pool);
651  av_frame_free(&svt_enc->frame);
652 
653  return 0;
654 }
655 
656 #define OFFSET(x) offsetof(SvtContext, x)
657 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
658 static const AVOption options[] = {
659  { "preset", "Encoding preset",
660  OFFSET(enc_mode), AV_OPT_TYPE_INT, { .i64 = -2 }, -2, MAX_ENC_PRESET, VE },
661 
663 
664 #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
665  { .i64 = value }, 0, 0, VE, .unit = "avctx.level"
666  { LEVEL("2.0", 20) },
667  { LEVEL("2.1", 21) },
668  { LEVEL("2.2", 22) },
669  { LEVEL("2.3", 23) },
670  { LEVEL("3.0", 30) },
671  { LEVEL("3.1", 31) },
672  { LEVEL("3.2", 32) },
673  { LEVEL("3.3", 33) },
674  { LEVEL("4.0", 40) },
675  { LEVEL("4.1", 41) },
676  { LEVEL("4.2", 42) },
677  { LEVEL("4.3", 43) },
678  { LEVEL("5.0", 50) },
679  { LEVEL("5.1", 51) },
680  { LEVEL("5.2", 52) },
681  { LEVEL("5.3", 53) },
682  { LEVEL("6.0", 60) },
683  { LEVEL("6.1", 61) },
684  { LEVEL("6.2", 62) },
685  { LEVEL("6.3", 63) },
686  { LEVEL("7.0", 70) },
687  { LEVEL("7.1", 71) },
688  { LEVEL("7.2", 72) },
689  { LEVEL("7.3", 73) },
690 #undef LEVEL
691 
692  { "crf", "Constant Rate Factor value", OFFSET(crf),
693  AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 63, VE },
694  { "qp", "Initial Quantizer level value", OFFSET(qp),
695  AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 63, VE },
696  { "svtav1-params", "Set the SVT-AV1 configuration using a :-separated list of key=value parameters", OFFSET(svtav1_opts), AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE },
697 
698  {NULL},
699 };
700 
701 static const AVClass class = {
702  .class_name = "libsvtav1",
703  .item_name = av_default_item_name,
704  .option = options,
706 };
707 
708 static const FFCodecDefault eb_enc_defaults[] = {
709  { "b", "0" },
710  { "flags", "+cgop" },
711  { "g", "-1" },
712  { "qmin", "1" },
713  { "qmax", "63" },
714  { NULL },
715 };
716 
718  .p.name = "libsvtav1",
719  CODEC_LONG_NAME("SVT-AV1(Scalable Video Technology for AV1) encoder"),
720  .priv_data_size = sizeof(SvtContext),
721  .p.type = AVMEDIA_TYPE_VIDEO,
722  .p.id = AV_CODEC_ID_AV1,
723  .init = eb_enc_init,
725  .close = eb_enc_close,
727  .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE |
729  .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
731  AV_PIX_FMT_NONE },
732  .p.priv_class = &class,
733  .defaults = eb_enc_defaults,
734  .p.wrapper_name = "libsvtav1",
735 };
AVMasteringDisplayMetadata::has_primaries
int has_primaries
Flag indicating whether the display primaries (and white point) are set.
Definition: mastering_display_metadata.h:62
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:73
av_buffer_pool_init
AVBufferPool * av_buffer_pool_init(size_t size, AVBufferRef *(*alloc)(size_t size))
Allocate and initialize a buffer pool.
Definition: buffer.c:280
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AVMasteringDisplayMetadata::max_luminance
AVRational max_luminance
Max luminance of mastering display (cd/m^2).
Definition: mastering_display_metadata.h:57
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
level
uint8_t level
Definition: svq3.c:204
AV_EF_EXPLODE
#define AV_EF_EXPLODE
abort decoding on minor error detection
Definition: defs.h:51
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
AVCodecContext::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:685
eb_enc_defaults
static const FFCodecDefault eb_enc_defaults[]
Definition: libsvtav1.c:708
AVCodecContext::decoded_side_data
AVFrameSideData ** decoded_side_data
Array containing static side data, such as HDR10 CLL / MDCV structures.
Definition: avcodec.h:2076
get_output_ref
static AVBufferRef * get_output_ref(AVCodecContext *avctx, SvtContext *svt_enc, int filled_len)
Definition: libsvtav1.c:532
AVBufferPool
The buffer pool.
Definition: buffer_internal.h:88
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2962
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
ff_side_data_set_encoder_stats
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
Definition: avpacket.c:607
SvtContext
Definition: libsvtav1.c:49
AVMasteringDisplayMetadata::display_primaries
AVRational display_primaries[3][2]
CIE 1931 xy chromaticity coords of color primaries (r, g, b order).
Definition: mastering_display_metadata.h:42
AVMasteringDisplayMetadata::has_luminance
int has_luminance
Flag indicating whether the luminance (min_ and max_) have been set.
Definition: mastering_display_metadata.h:67
AVCodecContext::err_recognition
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
Definition: avcodec.h:1420
FF_AV1_PROFILE_OPTS
#define FF_AV1_PROFILE_OPTS
Definition: profiles.h:54
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:130
AVContentLightMetadata::MaxCLL
unsigned MaxCLL
Max content light level (cd/m^2).
Definition: mastering_display_metadata.h:102
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:344
pixdesc.h
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:456
AVCodecContext::color_trc
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:678
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:683
internal.h
AVPacket::data
uint8_t * data
Definition: packet.h:522
AVOption
AVOption.
Definition: opt.h:346
encode.h
SvtContext::frame
AVFrame * frame
Definition: libsvtav1.c:59
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:478
eb_receive_packet
static int eb_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
Definition: libsvtav1.c:556
AV_DICT_IGNORE_SUFFIX
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
Definition: dict.h:75
FF_CODEC_CAP_NOT_INIT_THREADSAFE
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
Definition: codec_internal.h:34
FFCodec
Definition: codec_internal.h:127
eb_enc_init
static av_cold int eb_enc_init(AVCodecContext *avctx)
Definition: libsvtav1.c:425
AVCOL_SPC_RGB
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
Definition: pixfmt.h:610
AVDictionary
Definition: dict.c:34
eb_enc_close
static av_cold int eb_enc_close(AVCodecContext *avctx)
Definition: libsvtav1.c:637
AV_PKT_FLAG_DISPOSABLE
#define AV_PKT_FLAG_DISPOSABLE
Flag is used to indicate packets that contain frames that can be discarded by the decoder.
Definition: packet.h:596
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AV_PROFILE_AV1_PROFESSIONAL
#define AV_PROFILE_AV1_PROFESSIONAL
Definition: defs.h:169
AVERROR_UNKNOWN
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:73
AVCodecContext::qmax
int qmax
maximum quantizer
Definition: avcodec.h:1263
tf_sess_config.config
config
Definition: tf_sess_config.py:33
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:577
av_chroma_location_name
const char * av_chroma_location_name(enum AVChromaLocation location)
Definition: pixdesc.c:3359
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:365
AV_CODEC_FLAG_GLOBAL_HEADER
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
Definition: avcodec.h:338
AVContentLightMetadata
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
Definition: mastering_display_metadata.h:98
AVCodecContext::framerate
AVRational framerate
Definition: avcodec.h:560
FFCodecDefault
Definition: codec_internal.h:97
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
av_ceil_log2
#define av_ceil_log2
Definition: common.h:95
eb_err
EbErrorType eb_err
Definition: libsvtav1.c:73
eb_send_frame
static int eb_send_frame(AVCodecContext *avctx, const AVFrame *frame)
Definition: libsvtav1.c:485
svt_errors
static const struct @110 svt_errors[]
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:502
AVRational::num
int num
Numerator.
Definition: rational.h:59
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:118
avassert.h
AVCodecContext::color_primaries
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:671
EOS_RECEIVED
@ EOS_RECEIVED
Definition: libsvtav1.c:46
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
AV_PROFILE_UNKNOWN
#define AV_PROFILE_UNKNOWN
Definition: defs.h:65
av_dict_get
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:62
av_buffer_pool_get
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
Definition: buffer.c:384
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:524
AVMasteringDisplayMetadata::white_point
AVRational white_point[2]
CIE 1931 xy chromaticity coords of white point.
Definition: mastering_display_metadata.h:47
intreadwrite.h
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
AVCodecContext::nb_decoded_side_data
int nb_decoded_side_data
Definition: avcodec.h:2077
AVDictionaryEntry::key
char * key
Definition: dict.h:90
frame_size
int frame_size
Definition: mxfenc.c:2422
AV_CODEC_CAP_OTHER_THREADS
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
Definition: codec.h:124
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
SvtContext::enc_mode
int enc_mode
Definition: libsvtav1.c:67
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
AVCodecContext::rc_max_rate
int64_t rc_max_rate
maximum bitrate
Definition: avcodec.h:1292
handle_side_data
static void handle_side_data(AVCodecContext *avctx, EbSvtAv1EncConfiguration *param)
Definition: libsvtav1.c:179
AVCPBProperties
This structure describes the bitrate properties of an encoded bitstream.
Definition: defs.h:269
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
frame
static AVFrame * frame
Definition: demux_decode.c:54
if
if(ret)
Definition: filter_design.txt:179
AVCodecContext::rc_buffer_size
int rc_buffer_size
decoder bitstream buffer size
Definition: avcodec.h:1277
AVPacket::buf
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
Definition: packet.h:505
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
sizes
static const int sizes[][2]
Definition: img2dec.c:59
AVCodecContext::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:695
AV_CODEC_ID_AV1
@ AV_CODEC_ID_AV1
Definition: codec_id.h:280
AV_WB16
#define AV_WB16(p, v)
Definition: intreadwrite.h:403
AVCHROMA_LOC_LEFT
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
Definition: pixfmt.h:704
AV_LEVEL_UNKNOWN
#define AV_LEVEL_UNKNOWN
Definition: defs.h:196
av_image_fill_plane_sizes
int av_image_fill_plane_sizes(size_t sizes[4], enum AVPixelFormat pix_fmt, int height, const ptrdiff_t linesizes[4])
Fill plane sizes for an image with pixel format pix_fmt and height height.
Definition: imgutils.c:111
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVCHROMA_LOC_TOPLEFT
@ AVCHROMA_LOC_TOPLEFT
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
Definition: pixfmt.h:706
FF_CODEC_RECEIVE_PACKET_CB
#define FF_CODEC_RECEIVE_PACKET_CB(func)
Definition: codec_internal.h:302
AVCodecContext::bit_rate
int64_t bit_rate
the average bitrate
Definition: avcodec.h:495
AV_OPT_TYPE_DICT
@ AV_OPT_TYPE_DICT
Definition: opt.h:242
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:279
profiles.h
av_buffer_pool_uninit
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
Definition: buffer.c:322
SvtContext::pool
AVBufferPool * pool
Definition: libsvtav1.c:61
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
Definition: frame.h:120
AVCodecContext::level
int level
Encoding level descriptor.
Definition: avcodec.h:1783
ff_libsvtav1_encoder
const FFCodec ff_libsvtav1_encoder
Definition: libsvtav1.c:717
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:649
LEVEL
#define LEVEL(name, value)
AV_WB32
#define AV_WB32(p, v)
Definition: intreadwrite.h:417
AVCodecContext::time_base
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition: avcodec.h:544
AVFrame::pict_type
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:446
AVPacket::size
int size
Definition: packet.h:523
AVCodecContext::gop_size
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
Definition: avcodec.h:1031
codec_internal.h
AV_PIX_FMT_FLAG_RGB
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition: pixdesc.h:136
EOS_NOT_REACHED
@ EOS_NOT_REACHED
Definition: libsvtav1.c:44
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
SvtContext::crf
int crf
Definition: libsvtav1.c:68
config_enc_params
static int config_enc_params(EbSvtAv1EncConfiguration *param, AVCodecContext *avctx)
Definition: libsvtav1.c:204
AVFrameSideData::data
uint8_t * data
Definition: frame.h:252
SvtContext::svt_handle
EbComponentType * svt_handle
Definition: libsvtav1.c:53
SvtContext::svtav1_opts
AVDictionary * svtav1_opts
Definition: libsvtav1.c:66
AVCHROMA_LOC_UNSPECIFIED
@ AVCHROMA_LOC_UNSPECIFIED
Definition: pixfmt.h:703
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:431
AV_PICTURE_TYPE_NONE
@ AV_PICTURE_TYPE_NONE
Undefined.
Definition: avutil.h:278
alloc_buffer
static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
Definition: libsvtav1.c:117
frame.h
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:521
options
static const AVOption options[]
Definition: libsvtav1.c:658
VE
#define VE
Definition: libsvtav1.c:657
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
AV_PROFILE_AV1_HIGH
#define AV_PROFILE_AV1_HIGH
Definition: defs.h:168
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:528
svt_map_error
static int svt_map_error(EbErrorType eb_err, const char **desc)
Definition: libsvtav1.c:91
AVCPBProperties::avg_bitrate
int64_t avg_bitrate
Average bitrate of the stream, in bits per second.
Definition: defs.h:284
AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
@ AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition: frame.h:137
SvtContext::eos_flag
EOS_STATUS eos_flag
Definition: libsvtav1.c:63
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:515
eos_status
eos_status
Definition: libsvtav1.c:43
AVCodecContext::extradata
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:523
OFFSET
#define OFFSET(x)
Definition: libsvtav1.c:656
av_err
int av_err
Definition: libsvtav1.c:74
SvtContext::max_tu_size
int max_tu_size
Definition: libsvtav1.c:57
common.h
AVCPBProperties::max_bitrate
int64_t max_bitrate
Maximum bitrate of the stream, in bits per second.
Definition: defs.h:274
SvtContext::raw_size
int raw_size
Definition: libsvtav1.c:56
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:576
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:254
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
AVCodecContext::chroma_sample_location
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
Definition: avcodec.h:702
AVMasteringDisplayMetadata
Mastering display metadata capable of representing the color volume of the display used to master the...
Definition: mastering_display_metadata.h:38
AVCodecContext::height
int height
Definition: avcodec.h:618
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:657
SvtContext::enc_params
EbSvtAv1EncConfiguration enc_params
Definition: libsvtav1.c:52
avcodec.h
AV_CODEC_FLAG_CLOSED_GOP
#define AV_CODEC_FLAG_CLOSED_GOP
Definition: avcodec.h:352
ret
ret
Definition: filter_design.txt:187
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
AVCPBProperties::buffer_size
int64_t buffer_size
The size of the buffer to which the ratecontrol is applied, in bits.
Definition: defs.h:290
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: defs.h:40
svt_print_error
static int svt_print_error(void *log_ctx, EbErrorType err, const char *error_string)
Definition: libsvtav1.c:106
AVCodecContext
main external API structure.
Definition: avcodec.h:445
AVFrame::height
int height
Definition: frame.h:416
AVCodecContext::qmin
int qmin
minimum quantizer
Definition: avcodec.h:1256
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
AVCodecContext::profile
int profile
profile
Definition: avcodec.h:1639
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:112
AVCodecContext::ticks_per_frame
attribute_deprecated int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
Definition: avcodec.h:576
AV_CODEC_CAP_DELAY
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: codec.h:76
AVMasteringDisplayMetadata::min_luminance
AVRational min_luminance
Min luminance of mastering display (cd/m^2).
Definition: mastering_display_metadata.h:52
SvtContext::in_buf
EbBufferHeaderType * in_buf
Definition: libsvtav1.c:55
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:72
desc
const char * desc
Definition: libsvtav1.c:75
AV_PICTURE_TYPE_P
@ AV_PICTURE_TYPE_P
Predicted.
Definition: avutil.h:280
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
ff_encode_get_frame
int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame)
Called by encoders to get the next frame for encoding.
Definition: encode.c:204
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
packet_internal.h
FF_CODEC_CAP_AUTO_THREADS
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
Definition: codec_internal.h:73
mastering_display_metadata.h
AVFrameSideData
Structure to hold side data for an AVFrame.
Definition: frame.h:250
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
AVDictionaryEntry
Definition: dict.h:89
AVPacket
This structure stores compressed data.
Definition: packet.h:499
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:472
AVContentLightMetadata::MaxFALL
unsigned MaxFALL
Max average light level per frame (cd/m^2).
Definition: mastering_display_metadata.h:107
handle_mdcv
static void handle_mdcv(struct EbSvtAv1MasteringDisplayInfo *dst, const AVMasteringDisplayMetadata *mdcv)
Definition: libsvtav1.c:141
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
av_frame_side_data_get
static const AVFrameSideData * av_frame_side_data_get(AVFrameSideData *const *sd, const int nb_sd, enum AVFrameSideDataType type)
Wrapper around av_frame_side_data_get_c() to workaround the limitation that for any type T the conver...
Definition: frame.h:1069
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:618
EOS_SENT
@ EOS_SENT
Definition: libsvtav1.c:45
imgutils.h
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:389
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
SvtContext::qp
int qp
Definition: libsvtav1.c:69
ff_encode_add_cpb_side_data
AVCPBProperties * ff_encode_add_cpb_side_data(AVCodecContext *avctx)
Add a CPB properties side data to an encoding context.
Definition: encode.c:856
AVDictionaryEntry::value
char * value
Definition: dict.h:91
FF_QP2LAMBDA
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
Definition: avutil.h:227
read_in_data
static int read_in_data(EbSvtAv1EncConfiguration *param, const AVFrame *frame, EbBufferHeaderType *header_ptr)
Definition: libsvtav1.c:388