FFmpeg
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
libvvenc.c
Go to the documentation of this file.
1 /*
2  * H.266 encoding using the VVenC library
3  *
4  * Copyright (C) 2022, Thomas Siedel
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 FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include <vvenc/vvenc.h>
24 #include <vvenc/vvencCfg.h>
25 #include <vvenc/version.h>
26 
27 #include "libavutil/avstring.h"
28 #include "libavutil/avutil.h"
29 #include "libavutil/common.h"
30 #include "libavutil/frame.h"
31 #include "libavutil/imgutils.h"
32 #include "libavutil/log.h"
33 #include "libavutil/mem.h"
34 #include "libavutil/pixdesc.h"
35 #include "libavutil/opt.h"
36 
37 #include "avcodec.h"
38 #include "codec_internal.h"
39 #include "encode.h"
40 #include "internal.h"
41 #include "packet_internal.h"
42 #include "profiles.h"
43 
44 #define VVENC_VERSION_INT AV_VERSION_INT(VVENC_VERSION_MAJOR, \
45  VVENC_VERSION_MINOR, \
46  VVENC_VERSION_PATCH)
47 
48 typedef struct VVenCContext {
49  AVClass *class;
50  vvencEncoder *encoder;
51  vvencAccessUnit *au;
53  int preset;
54  int qp;
55  int qpa;
57  char *level;
58  int tier;
59  char *stats;
61 } VVenCContext;
62 
63 static void vvenc_log_callback(void *ctx, int level,
64  const char *fmt, va_list args)
65 {
66  vvenc_config params;
67  vvencEncoder *encoder = ctx;
68  if (encoder) {
69  vvenc_config_default(&params);
70  vvenc_get_config(encoder, &params);
71  if ((int)params.m_verbosity >= level)
72  vfprintf(level == 1 ? stderr : stdout, fmt, args);
73  }
74 }
75 
76 static void vvenc_set_verbository(vvenc_config *params)
77 {
78  int loglevel = av_log_get_level();
79  params->m_verbosity = VVENC_SILENT;
80  if (loglevel >= AV_LOG_DEBUG)
81  params->m_verbosity = VVENC_DETAILS;
82  else if (loglevel >= AV_LOG_VERBOSE)
83  params->m_verbosity = VVENC_NOTICE;
84  else if (loglevel >= AV_LOG_INFO)
85  params->m_verbosity = VVENC_WARNING;
86 }
87 
88 static void vvenc_set_pic_format(AVCodecContext *avctx, vvenc_config *params)
89 {
90  params->m_internChromaFormat = VVENC_CHROMA_420;
91  params->m_inputBitDepth[0] = 10;
92 }
93 
94 static void vvenc_set_color_format(AVCodecContext *avctx, vvenc_config *params)
95 {
97  params->m_colourPrimaries = (int) avctx->color_primaries;
99  params->m_matrixCoefficients = (int) avctx->colorspace;
100  if (avctx->color_trc != AVCOL_TRC_UNSPECIFIED) {
101  params->m_transferCharacteristics = (int) avctx->color_trc;
102 
103  if (avctx->color_trc == AVCOL_TRC_SMPTE2084)
104  params->m_HdrMode = (avctx->color_primaries == AVCOL_PRI_BT2020) ?
105  VVENC_HDR_PQ_BT2020 : VVENC_HDR_PQ;
106  else if (avctx->color_trc == AVCOL_TRC_BT2020_10 || avctx->color_trc == AVCOL_TRC_ARIB_STD_B67)
107  params->m_HdrMode = (avctx->color_trc == AVCOL_TRC_BT2020_10 ||
108  avctx->color_primaries == AVCOL_PRI_BT2020 ||
109  avctx->colorspace == AVCOL_SPC_BT2020_NCL ||
110  avctx->colorspace == AVCOL_SPC_BT2020_CL) ?
111  VVENC_HDR_HLG_BT2020 : VVENC_HDR_HLG;
112  }
113 
114  if (params->m_HdrMode == VVENC_HDR_OFF &&
116  params->m_vuiParametersPresent = 1;
117  params->m_colourDescriptionPresent = true;
118  }
119 }
120 
121 static void vvenc_set_framerate(AVCodecContext *avctx, vvenc_config *params)
122 {
123  if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
124  params->m_FrameRate = avctx->framerate.num;
125  params->m_FrameScale = avctx->framerate.den;
126  } else {
127  params->m_FrameRate = avctx->time_base.den;
128  params->m_FrameScale = avctx->time_base.num;
129  }
130 
131  params->m_TicksPerSecond = -1; /* auto mode for ticks per frame = 1 */
132 }
133 
134 static int vvenc_parse_vvenc_params(AVCodecContext *avctx, vvenc_config *params)
135 {
136  VVenCContext *s = avctx->priv_data;
137  const AVDictionaryEntry *en = NULL;
138  int parse_ret;
139  int ret = 0;
140 
141  while ((en = av_dict_iterate(s->vvenc_opts, en))) {
142  av_log(avctx, AV_LOG_DEBUG, "vvenc_set_param: '%s:%s'\n", en->key,
143  en->value);
144  parse_ret = vvenc_set_param(params, en->key, en->value);
145  switch (parse_ret) {
146  case VVENC_PARAM_BAD_NAME:
147  av_log(avctx, AV_LOG_ERROR, "Unknown vvenc option: %s.\n", en->key);
148  ret = AVERROR(EINVAL);
149  break;
150  case VVENC_PARAM_BAD_VALUE:
151  av_log(avctx, AV_LOG_ERROR, "Invalid vvenc value for %s: %s.\n", en->key, en->value);
152  ret = AVERROR(EINVAL);
153  break;
154  default:
155  break;
156  }
157 
158  if (!av_strcasecmp(en->key, "rcstatsfile")) {
159  av_log(avctx, AV_LOG_ERROR, "vvenc-params 2pass option 'rcstatsfile' "
160  "not available. Use option 'passlogfile'\n");
161  ret = AVERROR(EINVAL);
162  }
163  if (!av_strcasecmp(en->key, "passes") || !av_strcasecmp(en->key, "pass")) {
164  av_log(avctx, AV_LOG_ERROR, "vvenc-params 2pass option '%s' "
165  "not available. Use option 'pass'\n", en->key);
166  ret = AVERROR(EINVAL);
167  }
168  }
169  return ret;
170 }
171 
172 static int vvenc_set_rc_mode(AVCodecContext *avctx, vvenc_config *params)
173 {
174  params->m_RCNumPasses = 1;
175  if ((avctx->flags & AV_CODEC_FLAG_PASS1 || avctx->flags & AV_CODEC_FLAG_PASS2)) {
176  if (!avctx->bit_rate) {
177  av_log(avctx, AV_LOG_ERROR, "A bitrate must be set to use two pass mode.\n");
178  return AVERROR(EINVAL);
179  }
180  params->m_RCNumPasses = 2;
181  if (avctx->flags & AV_CODEC_FLAG_PASS1)
182  params->m_RCPass = 1;
183  else
184  params->m_RCPass = 2;
185  }
186 
187  if (avctx->rc_max_rate) {
188 #if VVENC_VERSION_INT >= AV_VERSION_INT(1,8,0)
189  params->m_RCMaxBitrate = avctx->rc_max_rate;
190 #endif
191 
192 #if VVENC_VERSION_INT < AV_VERSION_INT(1,11,0)
193  /* rc_max_rate without a bit_rate enables capped CQF mode.
194  (QP + subj. optimization + max. bitrate) */
195  if (!avctx->bit_rate) {
196  av_log(avctx, AV_LOG_ERROR, "Capped Constant Quality Factor mode (capped CQF) "
197  "needs at least vvenc version >= 1.11.0 (current version %s)\n", vvenc_get_version());
198  return AVERROR(EINVAL);
199  }
200 #endif
201  }
202  return 0;
203 }
204 
206 {
207  int ret;
208  if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
209  ret = vvenc_get_headers(s->encoder, s->au);
210  if (0 != ret) {
211  av_log(avctx, AV_LOG_ERROR, "cannot get (SPS,PPS) headers: %s\n",
212  vvenc_get_last_error(s->encoder));
213  return AVERROR(EINVAL);
214  }
215 
216  if (s->au->payloadUsedSize <= 0) {
217  return AVERROR_INVALIDDATA;
218  }
219 
220  avctx->extradata_size = s->au->payloadUsedSize;
222  if (!avctx->extradata) {
223  return AVERROR(ENOMEM);
224  }
225 
226  memcpy(avctx->extradata, s->au->payload, avctx->extradata_size);
227  }
228  return 0;
229 }
230 
232 {
233  int ret;
234  int framerate;
235  VVenCContext *s = avctx->priv_data;
236  vvenc_config params;
237  vvencPresetMode preset = (vvencPresetMode) s->preset;
238 
240  av_log(avctx, AV_LOG_ERROR, "interlaced not supported\n");
241  return AVERROR(EINVAL);
242  }
243 
244  vvenc_config_default(&params);
245 
246  if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
247  framerate = avctx->framerate.num / avctx->framerate.den;
248  else
249  framerate = avctx->time_base.den / avctx->time_base.num;
250 
251  vvenc_init_default(&params, avctx->width, avctx->height, framerate,
252  avctx->bit_rate, s->qp, preset);
253 
254  vvenc_set_verbository(&params);
255 
256  if (avctx->thread_count > 0)
257  params.m_numThreads = avctx->thread_count;
258 
259  /* GOP settings (IDR/CRA) */
260  if (avctx->flags & AV_CODEC_FLAG_CLOSED_GOP)
261  params.m_DecodingRefreshType = VVENC_DRT_IDR;
262 
263  if (avctx->gop_size == 1) {
264  params.m_GOPSize = 1;
265  params.m_IntraPeriod = 1;
266  } else
267  params.m_IntraPeriodSec = s->intra_refresh_sec;
268 
269  params.m_AccessUnitDelimiter = true;
270  params.m_usePerceptQPA = s->qpa;
271  params.m_levelTier = (vvencTier) s->tier;
272 
273  if (avctx->level > 0)
274  params.m_level = (vvencLevel)avctx->level;
275 
276  if (s->level) {
277  if (VVENC_PARAM_BAD_VALUE == vvenc_set_param(&params, "level", s->level)) {
278  av_log(avctx, AV_LOG_ERROR, "Invalid level_idc: %s.\n", s->level);
279  return AVERROR(EINVAL);
280  }
281  }
282 
283  vvenc_set_framerate(avctx, &params);
284 
285  vvenc_set_pic_format(avctx, &params);
286 
287  vvenc_set_color_format(avctx, &params);
288 
289  ret = vvenc_parse_vvenc_params(avctx, &params);
290  if (ret != 0)
291  return ret;
292 
293  ret = vvenc_set_rc_mode(avctx, &params);
294  if (ret != 0)
295  return ret;
296 
297  s->encoder = vvenc_encoder_create();
298  if (!s->encoder) {
299  av_log(avctx, AV_LOG_ERROR, "cannot create libvvenc encoder\n");
300  return AVERROR(ENOMEM);
301  }
302 
303  vvenc_set_msg_callback(&params, s->encoder, vvenc_log_callback);
304  ret = vvenc_encoder_open(s->encoder, &params);
305  if (ret != 0) {
306  av_log(avctx, AV_LOG_ERROR, "cannot open libvvenc encoder: %s\n",
307  vvenc_get_last_error(s->encoder));
308  return AVERROR_EXTERNAL;
309  }
310 
311  vvenc_get_config(s->encoder, &params); /* get the adapted config */
312 
313  av_log(avctx, AV_LOG_INFO, "libvvenc version: %s\n", vvenc_get_version());
315  av_log(avctx, AV_LOG_INFO, "%s\n", vvenc_get_config_as_string(&params, params.m_verbosity));
316 
317  if (params.m_RCNumPasses == 2) {
318  ret = vvenc_init_pass(s->encoder, params.m_RCPass - 1, s->stats);
319  if (ret != 0) {
320  av_log(avctx, AV_LOG_ERROR, "cannot init pass %d: %s\n", params.m_RCPass,
321  vvenc_get_last_error(s->encoder));
322  return AVERROR_EXTERNAL;
323  }
324  }
325 
326  s->au = vvenc_accessUnit_alloc();
327  if (!s->au) {
328  av_log(avctx, AV_LOG_FATAL, "cannot allocate memory for AU payload\n");
329  return AVERROR(ENOMEM);
330  }
331  vvenc_accessUnit_alloc_payload(s->au, avctx->width * avctx->height);
332  if (!s->au->payload) {
333  av_log(avctx, AV_LOG_FATAL, "cannot allocate payload memory of size %d\n",
334  avctx->width * avctx->height);
335  return AVERROR(ENOMEM);
336  }
337 
338  ret = vvenc_init_extradata(avctx, s);
339  if (ret != 0)
340  return ret;
341 
342  s->encode_done = false;
343  return 0;
344 }
345 
347 {
348  VVenCContext *s = avctx->priv_data;
349 
350  if (s->au)
351  vvenc_accessUnit_free(s->au, true);
352 
353  if (s->encoder) {
354  vvenc_print_summary(s->encoder);
355 
356  if (0 != vvenc_encoder_close(s->encoder))
357  return AVERROR_EXTERNAL;
358  }
359 
360  return 0;
361 }
362 
364  int *got_packet)
365 {
366  VVenCContext *s = avctx->priv_data;
367  vvencYUVBuffer *pyuvbuf;
368  vvencYUVBuffer yuvbuf;
369  int ret;
370 
371  pyuvbuf = NULL;
372  if (frame) {
373  vvenc_YUVBuffer_default(&yuvbuf);
374  yuvbuf.planes[0].ptr = (int16_t *) frame->data[0];
375  yuvbuf.planes[1].ptr = (int16_t *) frame->data[1];
376  yuvbuf.planes[2].ptr = (int16_t *) frame->data[2];
377 
378  yuvbuf.planes[0].width = frame->width;
379  yuvbuf.planes[0].height = frame->height;
380  yuvbuf.planes[0].stride = frame->linesize[0] >> 1; /* stride is used in 16bit samples in vvenc */
381 
382  yuvbuf.planes[1].width = frame->width >> 1;
383  yuvbuf.planes[1].height = frame->height >> 1;
384  yuvbuf.planes[1].stride = frame->linesize[1] >> 1;
385 
386  yuvbuf.planes[2].width = frame->width >> 1;
387  yuvbuf.planes[2].height = frame->height >> 1;
388  yuvbuf.planes[2].stride = frame->linesize[2] >> 1;
389 
390  yuvbuf.cts = frame->pts;
391  yuvbuf.ctsValid = true;
392  pyuvbuf = &yuvbuf;
393  }
394 
395  if (!s->encode_done) {
396  if (vvenc_encode(s->encoder, pyuvbuf, s->au, &s->encode_done) != 0)
397  return AVERROR_EXTERNAL;
398  } else
399  return 0;
400 
401  if (s->au->payloadUsedSize > 0) {
402  ret = ff_get_encode_buffer(avctx, pkt, s->au->payloadUsedSize, 0);
403  if (ret < 0)
404  return ret;
405 
406  memcpy(pkt->data, s->au->payload, s->au->payloadUsedSize);
407 
408  if (s->au->ctsValid)
409  pkt->pts = s->au->cts;
410  if (s->au->dtsValid)
411  pkt->dts = s->au->dts;
412  pkt->flags |= AV_PKT_FLAG_KEY * s->au->rap;
413 
414  *got_packet = 1;
415  return 0;
416  }
417 
418  return 0;
419 }
420 
421 static const enum AVPixelFormat pix_fmts_vvenc[] = {
424 };
425 
426 #define OFFSET(x) offsetof(VVenCContext, x)
427 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
428 static const AVOption options[] = {
429  { "preset", "set encoding preset", OFFSET(preset), AV_OPT_TYPE_INT, {.i64 = 2}, 0, 4, VE, "preset"},
430  { "faster", "0", 0, AV_OPT_TYPE_CONST, {.i64 = VVENC_FASTER}, INT_MIN, INT_MAX, VE, "preset" },
431  { "fast", "1", 0, AV_OPT_TYPE_CONST, {.i64 = VVENC_FAST}, INT_MIN, INT_MAX, VE, "preset" },
432  { "medium", "2", 0, AV_OPT_TYPE_CONST, {.i64 = VVENC_MEDIUM}, INT_MIN, INT_MAX, VE, "preset" },
433  { "slow", "3", 0, AV_OPT_TYPE_CONST, {.i64 = VVENC_SLOW}, INT_MIN, INT_MAX, VE, "preset" },
434  { "slower", "4", 0, AV_OPT_TYPE_CONST, {.i64 = VVENC_SLOWER}, INT_MIN, INT_MAX, VE, "preset" },
435  { "qp", "set quantization", OFFSET(qp), AV_OPT_TYPE_INT, {.i64 = 32}, -1, 63, VE },
436  { "qpa", "set subjective (perceptually motivated) optimization", OFFSET(qpa), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, VE},
437  { "passlogfile", "Filename for 2 pass stats", OFFSET(stats), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, VE},
438  { "stats", "Filename for 2 pass stats", OFFSET(stats), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, VE},
439  { "period", "set (intra) refresh period in seconds", OFFSET(intra_refresh_sec), AV_OPT_TYPE_INT, {.i64 = 1}, 1, INT_MAX, VE },
440  { "vvenc-params", "set the vvenc configuration using a :-separated list of key=value parameters", OFFSET(vvenc_opts), AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE },
441  { "level", "Specify level (as defined by Annex A)", OFFSET(level), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, VE},
442  { "tier", "set vvc tier", OFFSET(tier), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, VE, "tier"},
443  { "main", "main", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, INT_MIN, INT_MAX, VE, "tier"},
444  { "high", "high", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, INT_MIN, INT_MAX, VE, "tier"},
445  {NULL}
446 };
447 
448 static const AVClass class = {
449  .class_name = "libvvenc",
450  .item_name = av_default_item_name,
451  .option = options,
453 };
454 
455 static const FFCodecDefault vvenc_defaults[] = {
456  { "b", "0" },
457  { "g", "-1" },
458  { NULL },
459 };
460 
462  .p.name = "libvvenc",
463  CODEC_LONG_NAME("libvvenc H.266 / VVC"),
464  .p.type = AVMEDIA_TYPE_VIDEO,
465  .p.id = AV_CODEC_ID_VVC,
466  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
468  .p.profiles = NULL_IF_CONFIG_SMALL(ff_vvc_profiles),
469  .p.priv_class = &class,
470  .p.wrapper_name = "libvvenc",
471  .priv_data_size = sizeof(VVenCContext),
473  .init = vvenc_init,
475  .close = vvenc_close,
476  .defaults = vvenc_defaults,
478 };
VVenCContext::qp
int qp
Definition: libvvenc.c:54
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
level
uint8_t level
Definition: svq3.c:205
VVenCContext::qpa
int qpa
Definition: libvvenc.c:55
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:662
av_strcasecmp
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
Definition: avstring.c:207
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:410
pixdesc.h
AVCodecContext::color_trc
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:655
internal.h
AVPacket::data
uint8_t * data
Definition: packet.h:535
AVOption
AVOption.
Definition: opt.h:429
encode.h
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:647
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:528
FFCodec
Definition: codec_internal.h:127
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:225
AVDictionary
Definition: dict.c:32
vvenc_defaults
static const FFCodecDefault vvenc_defaults[]
Definition: libvvenc.c:455
VVenCContext::preset
int preset
Definition: libvvenc.c:53
VVenCContext::encode_done
bool encode_done
Definition: libvvenc.c:52
AVCOL_SPC_BT2020_CL
@ AVCOL_SPC_BT2020_CL
ITU-R BT2020 constant luminance system.
Definition: pixfmt.h:685
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:590
AV_CODEC_FLAG_GLOBAL_HEADER
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
Definition: avcodec.h:318
AVCodecContext::framerate
AVRational framerate
Definition: avcodec.h:554
FFCodecDefault
Definition: codec_internal.h:96
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
AVCodecContext::thread_count
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
Definition: avcodec.h:1564
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:488
VE
#define VE
Definition: libvvenc.c:427
FF_CODEC_ENCODE_CB
#define FF_CODEC_ENCODE_CB(func)
Definition: codec_internal.h:353
AVRational::num
int num
Numerator.
Definition: rational.h:59
vvenc_parse_vvenc_params
static int vvenc_parse_vvenc_params(AVCodecContext *avctx, vvenc_config *params)
Definition: libvvenc.c:134
AV_CODEC_FLAG_INTERLACED_DCT
#define AV_CODEC_FLAG_INTERLACED_DCT
Use interlaced DCT.
Definition: avcodec.h:310
vvenc_log_callback
static void vvenc_log_callback(void *ctx, int level, const char *fmt, va_list args)
Definition: libvvenc.c:63
preset
preset
Definition: vf_curves.c:47
AVCodecContext::color_primaries
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:648
pkt
AVPacket * pkt
Definition: movenc.c:60
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
av_cold
#define av_cold
Definition: attributes.h:90
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:518
s
#define s(width, name)
Definition: cbs_vp9.c:198
ff_libvvenc_encoder
const FFCodec ff_libvvenc_encoder
Definition: libvvenc.c:461
AVDictionaryEntry::key
char * key
Definition: dict.h:90
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:109
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:230
ctx
AVFormatContext * ctx
Definition: movenc.c:49
tier
int tier
Definition: av1_levels.c:48
AVCodecContext::rc_max_rate
int64_t rc_max_rate
maximum bitrate
Definition: avcodec.h:1273
VVenCContext
Definition: libvvenc.c:48
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:622
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:326
if
if(ret)
Definition: filter_design.txt:179
av_log_get_level
int av_log_get_level(void)
Get the current log level.
Definition: log.c:468
framerate
float framerate
Definition: av1_levels.c:29
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
NULL
#define NULL
Definition: coverity.c:32
OFFSET
#define OFFSET(x)
Definition: libvvenc.c:426
CODEC_PIXFMTS_ARRAY
#define CODEC_PIXFMTS_ARRAY(array)
Definition: codec_internal.h:387
vvenc_frame
static av_cold int vvenc_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: libvvenc.c:363
AVCodecContext::bit_rate
int64_t bit_rate
the average bitrate
Definition: avcodec.h:481
AV_OPT_TYPE_DICT
@ AV_OPT_TYPE_DICT
Underlying C type is AVDictionary*.
Definition: opt.h:290
VVenCContext::stats
char * stats
Definition: libvvenc.c:59
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:239
profiles.h
options
Definition: swscale.c:43
AVCOL_TRC_BT2020_10
@ AVCOL_TRC_BT2020_10
ITU-R BT2020 for 10-bit system.
Definition: pixfmt.h:659
VVenCContext::au
vvencAccessUnit * au
Definition: libvvenc.c:51
AVCodecContext::level
int level
Encoding level descriptor.
Definition: avcodec.h:1631
stats
static void stats(AVPacket *const *in, int n_in, unsigned *_max, unsigned *_sum)
Definition: vp9_superframe.c:34
vvenc_set_color_format
static void vvenc_set_color_format(AVCodecContext *avctx, vvenc_config *params)
Definition: libvvenc.c:94
AVCOL_PRI_BT2020
@ AVCOL_PRI_BT2020
ITU-R BT2020.
Definition: pixfmt.h:630
VVenCContext::tier
int tier
Definition: libvvenc.c:58
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:538
AVCOL_TRC_SMPTE2084
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition: pixfmt.h:661
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
AVCodecContext::gop_size
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
Definition: avcodec.h:1008
codec_internal.h
pix_fmts_vvenc
static enum AVPixelFormat pix_fmts_vvenc[]
Definition: libvvenc.c:421
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:534
AV_CODEC_FLAG_PASS2
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
Definition: avcodec.h:294
AV_CODEC_ID_VVC
@ AV_CODEC_ID_VVC
Definition: codec_id.h:252
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:541
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:220
log.h
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:528
AVCOL_SPC_BT2020_NCL
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
Definition: pixfmt.h:684
AVCodecContext::extradata
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
Definition: avcodec.h:517
options
static const AVOption options[]
Definition: libvvenc.c:428
vvenc_set_rc_mode
static int vvenc_set_rc_mode(AVCodecContext *avctx, vvenc_config *params)
Definition: libvvenc.c:172
common.h
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:256
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:179
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:676
AVCodecContext::height
int height
Definition: avcodec.h:595
avcodec.h
vvenc_close
static av_cold int vvenc_close(AVCodecContext *avctx)
Definition: libvvenc.c:346
VVenCContext::vvenc_opts
AVDictionary * vvenc_opts
Definition: libvvenc.c:60
AV_CODEC_FLAG_CLOSED_GOP
#define AV_CODEC_FLAG_CLOSED_GOP
Definition: avcodec.h:332
ret
ret
Definition: filter_design.txt:187
AV_LOG_FATAL
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition: log.h:203
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:80
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
vvenc_set_framerate
static void vvenc_set_framerate(AVCodecContext *avctx, vvenc_config *params)
Definition: libvvenc.c:121
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: defs.h:40
AVCodecContext
main external API structure.
Definition: avcodec.h:431
AVCOL_TRC_ARIB_STD_B67
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
Definition: pixfmt.h:665
ff_get_encode_buffer
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
Definition: encode.c:106
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
vvenc_set_pic_format
static void vvenc_set_pic_format(AVCodecContext *avctx, vvenc_config *params)
Definition: libvvenc.c:88
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
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
vvenc_init
static av_cold int vvenc_init(AVCodecContext *avctx)
Definition: libvvenc.c:231
vvenc_set_verbository
static void vvenc_set_verbository(vvenc_config *params)
Definition: libvvenc.c:76
ff_vvc_profiles
const AVProfile ff_vvc_profiles[]
Definition: profiles.c:91
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
avutil.h
mem.h
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:72
VVenCContext::encoder
vvencEncoder * encoder
Definition: libvvenc.c:50
AVDictionaryEntry
Definition: dict.h:89
AVPacket
This structure stores compressed data.
Definition: packet.h:512
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:458
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:595
imgutils.h
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
vvenc_init_extradata
static int vvenc_init_extradata(AVCodecContext *avctx, VVenCContext *s)
Definition: libvvenc.c:205
AVDictionaryEntry::value
char * value
Definition: dict.h:91
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:276
VVenCContext::intra_refresh_sec
int intra_refresh_sec
Definition: libvvenc.c:56
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
av_dict_iterate
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
Definition: dict.c:42
VVenCContext::level
char * level
Definition: libvvenc.c:57
AV_CODEC_FLAG_PASS1
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
Definition: avcodec.h:290