FFmpeg: libavcodec/libaomenc.c Source File

FFmpeg
libaomenc.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010, Google, Inc.
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file
23  * AV1 encoder support via libaom
24  */
25 
26  #define AOM_DISABLE_CTRL_TYPECHECKS 1
27 #include <aom/aom_encoder.h>
28 #include <aom/aomcx.h>
29 
30 #include "libavutil/avassert.h"
31 #include "libavutil/base64.h"
32 #include "libavutil/common.h"
33 #include "libavutil/mathematics.h"
34 #include "libavutil/opt.h"
35 #include "libavutil/pixdesc.h"
36 
37 #include "avcodec.h"
38 #include "internal.h"
39 #include "profiles.h"
40 
41 /*
42  * Portion of struct aom_codec_cx_pkt from aom_encoder.h.
43  * One encoded frame returned from the library.
44  */
45  struct FrameListData {
46   void *buf; /**< compressed data buffer */
47   size_t sz; /**< length of compressed data */
48   int64_t pts; /**< time stamp to show frame
49  (in timebase units) */
50   unsigned long duration; /**< duration to show frame
51  (in timebase units) */
52   uint32_t flags; /**< flags for this frame */
53   struct FrameListData *next;
54 };
55 
56  typedef struct AOMEncoderContext {
57   AVClass *class;
58   struct aom_codec_ctx encoder;
59   struct aom_image rawimg;
60   struct aom_fixed_buf twopass_stats;
61   struct FrameListData *coded_frame_list;
62   int cpu_used;
63   int auto_alt_ref;
64   int lag_in_frames;
65   int error_resilient;
66   int crf;
67   int static_thresh;
68   int drop_threshold;
69   int noise_sensitivity;
70 } AOMContext;
71 
72  static const char *const ctlidstr[] = {
73  [AOME_SET_CPUUSED] = "AOME_SET_CPUUSED",
74  [AOME_SET_CQ_LEVEL] = "AOME_SET_CQ_LEVEL",
75  [AOME_SET_ENABLEAUTOALTREF] = "AOME_SET_ENABLEAUTOALTREF",
76  [AOME_SET_STATIC_THRESHOLD] = "AOME_SET_STATIC_THRESHOLD",
77  [AV1E_SET_COLOR_RANGE] = "AV1E_SET_COLOR_RANGE",
78  [AV1E_SET_COLOR_PRIMARIES] = "AV1E_SET_COLOR_PRIMARIES",
79  [AV1E_SET_MATRIX_COEFFICIENTS] = "AV1E_SET_MATRIX_COEFFICIENTS",
80  [AV1E_SET_TRANSFER_CHARACTERISTICS] = "AV1E_SET_TRANSFER_CHARACTERISTICS",
81 };
82 
83  static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
84 {
85  AOMContext *ctx = avctx->priv_data;
86  const char *error = aom_codec_error(&ctx->encoder);
87  const char *detail = aom_codec_error_detail(&ctx->encoder);
88 
89  av_log(avctx, AV_LOG_ERROR, "%s: %s\n", desc, error);
90  if (detail)
91  av_log(avctx, AV_LOG_ERROR, " Additional information: %s\n", detail);
92 }
93 
94  static av_cold void dump_enc_cfg(AVCodecContext *avctx,
95  const struct aom_codec_enc_cfg *cfg)
96 {
97  int width = -30;
98  int level = AV_LOG_DEBUG;
99 
100  av_log(avctx, level, "aom_codec_enc_cfg\n");
101  av_log(avctx, level, "generic settings\n"
102  " %*s%u\n %*s%u\n %*s%u\n %*s%u\n %*s%u\n"
103  " %*s%u\n %*s%u\n"
104  " %*s{%u/%u}\n %*s%u\n %*s%d\n %*s%u\n",
105  width, "g_usage:", cfg->g_usage,
106  width, "g_threads:", cfg->g_threads,
107  width, "g_profile:", cfg->g_profile,
108  width, "g_w:", cfg->g_w,
109  width, "g_h:", cfg->g_h,
110  width, "g_bit_depth:", cfg->g_bit_depth,
111  width, "g_input_bit_depth:", cfg->g_input_bit_depth,
112  width, "g_timebase:", cfg->g_timebase.num, cfg->g_timebase.den,
113  width, "g_error_resilient:", cfg->g_error_resilient,
114  width, "g_pass:", cfg->g_pass,
115  width, "g_lag_in_frames:", cfg->g_lag_in_frames);
116  av_log(avctx, level, "rate control settings\n"
117  " %*s%u\n %*s%d\n %*s%p(%"SIZE_SPECIFIER ")\n %*s%u\n",
118  width, "rc_dropframe_thresh:", cfg->rc_dropframe_thresh,
119  width, "rc_end_usage:", cfg->rc_end_usage,
120  width, "rc_twopass_stats_in:", cfg->rc_twopass_stats_in.buf, cfg->rc_twopass_stats_in.sz,
121  width, "rc_target_bitrate:", cfg->rc_target_bitrate);
122  av_log(avctx, level, "quantizer settings\n"
123  " %*s%u\n %*s%u\n",
124  width, "rc_min_quantizer:", cfg->rc_min_quantizer,
125  width, "rc_max_quantizer:", cfg->rc_max_quantizer);
126  av_log(avctx, level, "bitrate tolerance\n"
127  " %*s%u\n %*s%u\n",
128  width, "rc_undershoot_pct:", cfg->rc_undershoot_pct,
129  width, "rc_overshoot_pct:", cfg->rc_overshoot_pct);
130  av_log(avctx, level, "decoder buffer model\n"
131  " %*s%u\n %*s%u\n %*s%u\n",
132  width, "rc_buf_sz:", cfg->rc_buf_sz,
133  width, "rc_buf_initial_sz:", cfg->rc_buf_initial_sz,
134  width, "rc_buf_optimal_sz:", cfg->rc_buf_optimal_sz);
135  av_log(avctx, level, "2 pass rate control settings\n"
136  " %*s%u\n %*s%u\n %*s%u\n",
137  width, "rc_2pass_vbr_bias_pct:", cfg->rc_2pass_vbr_bias_pct,
138  width, "rc_2pass_vbr_minsection_pct:", cfg->rc_2pass_vbr_minsection_pct,
139  width, "rc_2pass_vbr_maxsection_pct:", cfg->rc_2pass_vbr_maxsection_pct);
140  av_log(avctx, level, "keyframing settings\n"
141  " %*s%d\n %*s%u\n %*s%u\n",
142  width, "kf_mode:", cfg->kf_mode,
143  width, "kf_min_dist:", cfg->kf_min_dist,
144  width, "kf_max_dist:", cfg->kf_max_dist);
145  av_log(avctx, level, "\n");
146 }
147 
148  static void coded_frame_add(void *list, struct FrameListData *cx_frame)
149 {
150  struct FrameListData **p = list;
151 
152  while (*p)
153  p = &(*p)->next;
154  *p = cx_frame;
155  cx_frame->next = NULL;
156 }
157 
158  static av_cold void free_coded_frame(struct FrameListData *cx_frame)
159 {
160  av_freep(&cx_frame->buf);
161  av_freep(&cx_frame);
162 }
163 
164  static av_cold void free_frame_list(struct FrameListData *list)
165 {
166  struct FrameListData *p = list;
167 
168  while (p) {
169  list = list->next;
170  free_coded_frame(p);
171  p = list;
172  }
173 }
174 
175  static av_cold int codecctl_int(AVCodecContext *avctx,
176  enum aome_enc_control_id id, int val)
177 {
178  AOMContext *ctx = avctx->priv_data;
179  char buf[80];
180  int width = -30;
181  int res;
182 
183  snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]);
184  av_log(avctx, AV_LOG_DEBUG, " %*s%d\n", width, buf, val);
185 
186  res = aom_codec_control(&ctx->encoder, id, val);
187  if (res != AOM_CODEC_OK) {
188  snprintf(buf, sizeof(buf), "Failed to set %s codec control",
189  ctlidstr[id]);
190  log_encoder_error(avctx, buf);
191  return AVERROR(EINVAL);
192  }
193 
194  return 0;
195 }
196 
197  static av_cold int aom_free(AVCodecContext *avctx)
198 {
199  AOMContext *ctx = avctx->priv_data;
200 
201  aom_codec_destroy(&ctx->encoder);
202  av_freep(&ctx->twopass_stats.buf);
203  av_freep(&avctx->stats_out);
204  free_frame_list(ctx->coded_frame_list);
205  return 0;
206 }
207 
208  static int set_pix_fmt(AVCodecContext *avctx, aom_codec_caps_t codec_caps,
209  struct aom_codec_enc_cfg *enccfg, aom_codec_flags_t *flags,
210  aom_img_fmt_t *img_fmt)
211 {
212  AOMContext av_unused *ctx = avctx->priv_data;
213  enccfg->g_bit_depth = enccfg->g_input_bit_depth = 8;
214  switch (avctx->pix_fmt) {
215  case AV_PIX_FMT_YUV420P:
216  enccfg->g_profile = FF_PROFILE_AV1_MAIN;
217  *img_fmt = AOM_IMG_FMT_I420;
218  return 0;
219  case AV_PIX_FMT_YUV422P:
220  enccfg->g_profile = FF_PROFILE_AV1_PROFESSIONAL;
221  *img_fmt = AOM_IMG_FMT_I422;
222  return 0;
223  case AV_PIX_FMT_YUV444P:
224  enccfg->g_profile = FF_PROFILE_AV1_HIGH;
225  *img_fmt = AOM_IMG_FMT_I444;
226  return 0;
227  case AV_PIX_FMT_YUV420P10:
228  case AV_PIX_FMT_YUV420P12:
229  if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
230  enccfg->g_bit_depth = enccfg->g_input_bit_depth =
231  avctx->pix_fmt == AV_PIX_FMT_YUV420P10 ? 10 : 12;
232  enccfg->g_profile =
233  enccfg->g_bit_depth == 10 ? FF_PROFILE_AV1_MAIN : FF_PROFILE_AV1_PROFESSIONAL;
234  *img_fmt = AOM_IMG_FMT_I42016;
235  *flags |= AOM_CODEC_USE_HIGHBITDEPTH;
236  return 0;
237  }
238  break;
239  case AV_PIX_FMT_YUV422P10:
240  case AV_PIX_FMT_YUV422P12:
241  if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
242  enccfg->g_bit_depth = enccfg->g_input_bit_depth =
243  avctx->pix_fmt == AV_PIX_FMT_YUV422P10 ? 10 : 12;
244  enccfg->g_profile = FF_PROFILE_AV1_PROFESSIONAL;
245  *img_fmt = AOM_IMG_FMT_I42216;
246  *flags |= AOM_CODEC_USE_HIGHBITDEPTH;
247  return 0;
248  }
249  break;
250  case AV_PIX_FMT_YUV444P10:
251  case AV_PIX_FMT_YUV444P12:
252  if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
253  enccfg->g_bit_depth = enccfg->g_input_bit_depth =
254  avctx->pix_fmt == AV_PIX_FMT_YUV444P10 ? 10 : 12;
255  enccfg->g_profile =
256  enccfg->g_bit_depth == 10 ? FF_PROFILE_AV1_HIGH : FF_PROFILE_AV1_PROFESSIONAL;
257  *img_fmt = AOM_IMG_FMT_I44416;
258  *flags |= AOM_CODEC_USE_HIGHBITDEPTH;
259  return 0;
260  }
261  break;
262  default:
263  break;
264  }
265  av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format.\n");
266  return AVERROR_INVALIDDATA;
267 }
268 
269  static void set_color_range(AVCodecContext *avctx)
270 {
271  enum aom_color_range aom_cr;
272  switch (avctx->color_range) {
273  case AVCOL_RANGE_UNSPECIFIED:
274  case AVCOL_RANGE_MPEG: aom_cr = AOM_CR_STUDIO_RANGE; break;
275  case AVCOL_RANGE_JPEG: aom_cr = AOM_CR_FULL_RANGE; break;
276  default:
277  av_log(avctx, AV_LOG_WARNING, "Unsupported color range (%d)\n",
278  avctx->color_range);
279  return;
280  }
281 
282  codecctl_int(avctx, AV1E_SET_COLOR_RANGE, aom_cr);
283 }
284 
285  static av_cold int aom_init(AVCodecContext *avctx,
286  const struct aom_codec_iface *iface)
287 {
288  AOMContext *ctx = avctx->priv_data;
289  struct aom_codec_enc_cfg enccfg = { 0 };
290  aom_codec_flags_t flags = 0;
291  AVCPBProperties *cpb_props;
292  int res;
293  aom_img_fmt_t img_fmt;
294  aom_codec_caps_t codec_caps = aom_codec_get_caps(iface);
295 
296  av_log(avctx, AV_LOG_INFO, "%s\n", aom_codec_version_str());
297  av_log(avctx, AV_LOG_VERBOSE, "%s\n", aom_codec_build_config());
298 
299  if ((res = aom_codec_enc_config_default(iface, &enccfg, 0)) != AOM_CODEC_OK) {
300  av_log(avctx, AV_LOG_ERROR, "Failed to get config: %s\n",
301  aom_codec_err_to_string(res));
302  return AVERROR(EINVAL);
303  }
304 
305  if (set_pix_fmt(avctx, codec_caps, &enccfg, &flags, &img_fmt))
306  return AVERROR(EINVAL);
307 
308  if(!avctx->bit_rate)
309  if(avctx->rc_max_rate || avctx->rc_buffer_size || avctx->rc_initial_buffer_occupancy) {
310  av_log( avctx, AV_LOG_ERROR, "Rate control parameters set without a bitrate\n");
311  return AVERROR(EINVAL);
312  }
313 
314  dump_enc_cfg(avctx, &enccfg);
315 
316  enccfg.g_w = avctx->width;
317  enccfg.g_h = avctx->height;
318  enccfg.g_timebase.num = avctx->time_base.num;
319  enccfg.g_timebase.den = avctx->time_base.den;
320  enccfg.g_threads = avctx->thread_count;
321 
322  if (ctx->lag_in_frames >= 0)
323  enccfg.g_lag_in_frames = ctx->lag_in_frames;
324 
325  if (avctx->flags & AV_CODEC_FLAG_PASS1)
326  enccfg.g_pass = AOM_RC_FIRST_PASS;
327  else if (avctx->flags & AV_CODEC_FLAG_PASS2)
328  enccfg.g_pass = AOM_RC_LAST_PASS;
329  else
330  enccfg.g_pass = AOM_RC_ONE_PASS;
331 
332  if (avctx->rc_min_rate == avctx->rc_max_rate &&
333  avctx->rc_min_rate == avctx->bit_rate && avctx->bit_rate) {
334  enccfg.rc_end_usage = AOM_CBR;
335  } else if (ctx->crf >= 0) {
336  enccfg.rc_end_usage = AOM_CQ;
337  if (!avctx->bit_rate)
338  enccfg.rc_end_usage = AOM_Q;
339  }
340 
341  if (avctx->bit_rate) {
342  enccfg.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000,
343  AV_ROUND_NEAR_INF);
344  } else if (enccfg.rc_end_usage != AOM_Q) {
345  if (enccfg.rc_end_usage == AOM_CQ) {
346  enccfg.rc_target_bitrate = 1000000;
347  } else {
348  avctx->bit_rate = enccfg.rc_target_bitrate * 1000;
349  av_log(avctx, AV_LOG_WARNING,
350  "Neither bitrate nor constrained quality specified, using default bitrate of %dkbit/sec\n",
351  enccfg.rc_target_bitrate);
352  }
353  }
354 
355  if (avctx->qmin >= 0)
356  enccfg.rc_min_quantizer = avctx->qmin;
357  if (avctx->qmax >= 0)
358  enccfg.rc_max_quantizer = avctx->qmax;
359 
360  if (enccfg.rc_end_usage == AOM_CQ || enccfg.rc_end_usage == AOM_Q) {
361  if (ctx->crf < enccfg.rc_min_quantizer || ctx->crf > enccfg.rc_max_quantizer) {
362  av_log(avctx, AV_LOG_ERROR,
363  "CQ level %d must be between minimum and maximum quantizer value (%d-%d)\n",
364  ctx->crf, enccfg.rc_min_quantizer, enccfg.rc_max_quantizer);
365  return AVERROR(EINVAL);
366  }
367  }
368 
369  enccfg.rc_dropframe_thresh = ctx->drop_threshold;
370 
371  // 0-100 (0 => CBR, 100 => VBR)
372  enccfg.rc_2pass_vbr_bias_pct = round(avctx->qcompress * 100);
373  if (avctx->bit_rate)
374  enccfg.rc_2pass_vbr_minsection_pct =
375  avctx->rc_min_rate * 100LL / avctx->bit_rate;
376  if (avctx->rc_max_rate)
377  enccfg.rc_2pass_vbr_maxsection_pct =
378  avctx->rc_max_rate * 100LL / avctx->bit_rate;
379 
380  if (avctx->rc_buffer_size)
381  enccfg.rc_buf_sz =
382  avctx->rc_buffer_size * 1000LL / avctx->bit_rate;
383  if (avctx->rc_initial_buffer_occupancy)
384  enccfg.rc_buf_initial_sz =
385  avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate;
386  enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
387 
388  // _enc_init() will balk if kf_min_dist differs from max w/AOM_KF_AUTO
389  if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size)
390  enccfg.kf_min_dist = avctx->keyint_min;
391  if (avctx->gop_size >= 0)
392  enccfg.kf_max_dist = avctx->gop_size;
393 
394  if (enccfg.g_pass == AOM_RC_FIRST_PASS)
395  enccfg.g_lag_in_frames = 0;
396  else if (enccfg.g_pass == AOM_RC_LAST_PASS) {
397  int decode_size, ret;
398 
399  if (!avctx->stats_in) {
400  av_log(avctx, AV_LOG_ERROR, "No stats file for second pass\n");
401  return AVERROR_INVALIDDATA;
402  }
403 
404  ctx->twopass_stats.sz = strlen(avctx->stats_in) * 3 / 4;
405  ret = av_reallocp(&ctx->twopass_stats.buf, ctx->twopass_stats.sz);
406  if (ret < 0) {
407  av_log(avctx, AV_LOG_ERROR,
408  "Stat buffer alloc (%"SIZE_SPECIFIER " bytes) failed\n",
409  ctx->twopass_stats.sz);
410  ctx->twopass_stats.sz = 0;
411  return ret;
412  }
413  decode_size = av_base64_decode(ctx->twopass_stats.buf, avctx->stats_in,
414  ctx->twopass_stats.sz);
415  if (decode_size < 0) {
416  av_log(avctx, AV_LOG_ERROR, "Stat buffer decode failed\n");
417  return AVERROR_INVALIDDATA;
418  }
419 
420  ctx->twopass_stats.sz = decode_size;
421  enccfg.rc_twopass_stats_in = ctx->twopass_stats;
422  }
423 
424  /* 0-3: For non-zero values the encoder increasingly optimizes for reduced
425  * complexity playback on low powered devices at the expense of encode
426  * quality. */
427  if (avctx->profile != FF_PROFILE_UNKNOWN)
428  enccfg.g_profile = avctx->profile;
429 
430  enccfg.g_error_resilient = ctx->error_resilient;
431 
432  dump_enc_cfg(avctx, &enccfg);
433  /* Construct Encoder Context */
434  res = aom_codec_enc_init(&ctx->encoder, iface, &enccfg, flags);
435  if (res != AOM_CODEC_OK) {
436  log_encoder_error(avctx, "Failed to initialize encoder");
437  return AVERROR(EINVAL);
438  }
439 
440  // codec control failures are currently treated only as warnings
441  av_log(avctx, AV_LOG_DEBUG, "aom_codec_control\n");
442  codecctl_int(avctx, AOME_SET_CPUUSED, ctx->cpu_used);
443  if (ctx->auto_alt_ref >= 0)
444  codecctl_int(avctx, AOME_SET_ENABLEAUTOALTREF, ctx->auto_alt_ref);
445 
446  codecctl_int(avctx, AOME_SET_STATIC_THRESHOLD, ctx->static_thresh);
447  if (ctx->crf >= 0)
448  codecctl_int(avctx, AOME_SET_CQ_LEVEL, ctx->crf);
449 
450  codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, avctx->color_primaries);
451  codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, avctx->colorspace);
452  codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, avctx->color_trc);
453  set_color_range(avctx);
454 
455  // provide dummy value to initialize wrapper, values will be updated each _encode()
456  aom_img_wrap(&ctx->rawimg, img_fmt, avctx->width, avctx->height, 1,
457  (unsigned char*)1);
458 
459  if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH)
460  ctx->rawimg.bit_depth = enccfg.g_bit_depth;
461 
462  cpb_props = ff_add_cpb_side_data(avctx);
463  if (!cpb_props)
464  return AVERROR(ENOMEM);
465 
466  if (enccfg.rc_end_usage == AOM_CBR ||
467  enccfg.g_pass != AOM_RC_ONE_PASS) {
468  cpb_props->max_bitrate = avctx->rc_max_rate;
469  cpb_props->min_bitrate = avctx->rc_min_rate;
470  cpb_props->avg_bitrate = avctx->bit_rate;
471  }
472  cpb_props->buffer_size = avctx->rc_buffer_size;
473 
474  return 0;
475 }
476 
477  static inline void cx_pktcpy(struct FrameListData *dst,
478  const struct aom_codec_cx_pkt *src)
479 {
480  dst->pts = src->data.frame.pts;
481  dst->duration = src->data.frame.duration;
482  dst->flags = src->data.frame.flags;
483  dst->sz = src->data.frame.sz;
484  dst->buf = src->data.frame.buf;
485 }
486 
487 /**
488  * Store coded frame information in format suitable for return from encode2().
489  *
490  * Write information from @a cx_frame to @a pkt
491  * @return packet data size on success
492  * @return a negative AVERROR on error
493  */
494  static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame,
495  AVPacket *pkt)
496 {
497  int ret = ff_alloc_packet2(avctx, pkt, cx_frame->sz, 0);
498  if (ret < 0) {
499  av_log(avctx, AV_LOG_ERROR,
500  "Error getting output packet of size %"SIZE_SPECIFIER ".\n", cx_frame->sz);
501  return ret;
502  }
503  memcpy(pkt->data, cx_frame->buf, pkt->size);
504  pkt->pts = pkt->dts = cx_frame->pts;
505 
506  if (!!(cx_frame->flags & AOM_FRAME_IS_KEY))
507  pkt->flags |= AV_PKT_FLAG_KEY;
508  return pkt->size;
509 }
510 
511 /**
512  * Queue multiple output frames from the encoder, returning the front-most.
513  * In cases where aom_codec_get_cx_data() returns more than 1 frame append
514  * the frame queue. Return the head frame if available.
515  * @return Stored frame size
516  * @return AVERROR(EINVAL) on output size error
517  * @return AVERROR(ENOMEM) on coded frame queue data allocation error
518  */
519  static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out)
520 {
521  AOMContext *ctx = avctx->priv_data;
522  const struct aom_codec_cx_pkt *pkt;
523  const void *iter = NULL;
524  int size = 0;
525 
526  if (ctx->coded_frame_list) {
527  struct FrameListData *cx_frame = ctx->coded_frame_list;
528  /* return the leading frame if we've already begun queueing */
529  size = storeframe(avctx, cx_frame, pkt_out);
530  if (size < 0)
531  return size;
532  ctx->coded_frame_list = cx_frame->next;
533  free_coded_frame(cx_frame);
534  }
535 
536  /* consume all available output from the encoder before returning. buffers
537  * are only good through the next aom_codec call */
538  while ((pkt = aom_codec_get_cx_data(&ctx->encoder, &iter))) {
539  switch (pkt->kind) {
540  case AOM_CODEC_CX_FRAME_PKT:
541  if (!size) {
542  struct FrameListData cx_frame;
543 
544  /* avoid storing the frame when the list is empty and we haven't yet
545  * provided a frame for output */
546  av_assert0(!ctx->coded_frame_list);
547  cx_pktcpy(&cx_frame, pkt);
548  size = storeframe(avctx, &cx_frame, pkt_out);
549  if (size < 0)
550  return size;
551  } else {
552  struct FrameListData *cx_frame =
553  av_malloc(sizeof(struct FrameListData));
554 
555  if (!cx_frame) {
556  av_log(avctx, AV_LOG_ERROR,
557  "Frame queue element alloc failed\n");
558  return AVERROR(ENOMEM);
559  }
560  cx_pktcpy(cx_frame, pkt);
561  cx_frame->buf = av_malloc(cx_frame->sz);
562 
563  if (!cx_frame->buf) {
564  av_log(avctx, AV_LOG_ERROR,
565  "Data buffer alloc (%"SIZE_SPECIFIER " bytes) failed\n",
566  cx_frame->sz);
567  av_freep(&cx_frame);
568  return AVERROR(ENOMEM);
569  }
570  memcpy(cx_frame->buf, pkt->data.frame.buf, pkt->data.frame.sz);
571  coded_frame_add(&ctx->coded_frame_list, cx_frame);
572  }
573  break;
574  case AOM_CODEC_STATS_PKT:
575  {
576  struct aom_fixed_buf *stats = &ctx->twopass_stats;
577  int err;
578  if ((err = av_reallocp(&stats->buf,
579  stats->sz +
580  pkt->data.twopass_stats.sz)) < 0) {
581  stats->sz = 0;
582  av_log(avctx, AV_LOG_ERROR, "Stat buffer realloc failed\n");
583  return err;
584  }
585  memcpy((uint8_t *)stats->buf + stats->sz,
586  pkt->data.twopass_stats.buf, pkt->data.twopass_stats.sz);
587  stats->sz += pkt->data.twopass_stats.sz;
588  break;
589  }
590  case AOM_CODEC_PSNR_PKT: // FIXME add support for AV_CODEC_FLAG_PSNR
591  case AOM_CODEC_CUSTOM_PKT:
592  // ignore unsupported/unrecognized packet types
593  break;
594  }
595  }
596 
597  return size;
598 }
599 
600  static int aom_encode(AVCodecContext *avctx, AVPacket *pkt,
601  const AVFrame *frame, int *got_packet)
602 {
603  AOMContext *ctx = avctx->priv_data;
604  struct aom_image *rawimg = NULL;
605  int64_t timestamp = 0;
606  int res, coded_size;
607  aom_enc_frame_flags_t flags = 0;
608 
609  if (frame) {
610  rawimg = &ctx->rawimg;
611  rawimg->planes[AOM_PLANE_Y] = frame->data[0];
612  rawimg->planes[AOM_PLANE_U] = frame->data[1];
613  rawimg->planes[AOM_PLANE_V] = frame->data[2];
614  rawimg->stride[AOM_PLANE_Y] = frame->linesize[0];
615  rawimg->stride[AOM_PLANE_U] = frame->linesize[1];
616  rawimg->stride[AOM_PLANE_V] = frame->linesize[2];
617  timestamp = frame->pts;
618  switch (frame->color_range) {
619  case AVCOL_RANGE_MPEG:
620  rawimg->range = AOM_CR_STUDIO_RANGE;
621  break;
622  case AVCOL_RANGE_JPEG:
623  rawimg->range = AOM_CR_FULL_RANGE;
624  break;
625  }
626 
627  if (frame->pict_type == AV_PICTURE_TYPE_I)
628  flags |= AOM_EFLAG_FORCE_KF;
629  }
630 
631  res = aom_codec_encode(&ctx->encoder, rawimg, timestamp,
632  avctx->ticks_per_frame, flags);
633  if (res != AOM_CODEC_OK) {
634  log_encoder_error(avctx, "Error encoding frame");
635  return AVERROR_INVALIDDATA;
636  }
637  coded_size = queue_frames(avctx, pkt);
638 
639  if (!frame && avctx->flags & AV_CODEC_FLAG_PASS1) {
640  size_t b64_size = AV_BASE64_SIZE(ctx->twopass_stats.sz);
641 
642  avctx->stats_out = av_malloc(b64_size);
643  if (!avctx->stats_out) {
644  av_log(avctx, AV_LOG_ERROR, "Stat buffer alloc (%"SIZE_SPECIFIER " bytes) failed\n",
645  b64_size);
646  return AVERROR(ENOMEM);
647  }
648  av_base64_encode(avctx->stats_out, b64_size, ctx->twopass_stats.buf,
649  ctx->twopass_stats.sz);
650  }
651 
652  *got_packet = !!coded_size;
653  return 0;
654 }
655 
656  static const enum AVPixelFormat av1_pix_fmts[] = {
657  AV_PIX_FMT_YUV420P,
658  AV_PIX_FMT_YUV422P,
659  AV_PIX_FMT_YUV444P,
660  AV_PIX_FMT_NONE
661 };
662 
663  static const enum AVPixelFormat av1_pix_fmts_highbd[] = {
664  AV_PIX_FMT_YUV420P,
665  AV_PIX_FMT_YUV422P,
666  AV_PIX_FMT_YUV444P,
667  AV_PIX_FMT_YUV420P10,
668  AV_PIX_FMT_YUV422P10,
669  AV_PIX_FMT_YUV444P10,
670  AV_PIX_FMT_YUV420P12,
671  AV_PIX_FMT_YUV422P12,
672  AV_PIX_FMT_YUV444P12,
673  AV_PIX_FMT_NONE
674 };
675 
676  static av_cold void av1_init_static(AVCodec *codec)
677 {
678  aom_codec_caps_t codec_caps = aom_codec_get_caps(aom_codec_av1_cx());
679  if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH)
680  codec->pix_fmts = av1_pix_fmts_highbd;
681  else
682  codec->pix_fmts = av1_pix_fmts;
683 }
684 
685  static av_cold int av1_init(AVCodecContext *avctx)
686 {
687  return aom_init(avctx, aom_codec_av1_cx());
688 }
689 
690  #define OFFSET(x) offsetof(AOMContext, x)
691  #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
692  static const AVOption options[] = {
693  { "cpu-used", "Quality/Speed ratio modifier", OFFSET(cpu_used), AV_OPT_TYPE_INT, {.i64 = 1}, -8, 8, VE},
694  { "auto-alt-ref", "Enable use of alternate reference "
695  "frames (2-pass only)", OFFSET(auto_alt_ref), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, VE},
696  { "lag-in-frames", "Number of frames to look ahead at for "
697  "alternate reference frame selection", OFFSET(lag_in_frames), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE},
698  { "error-resilience", "Error resilience configuration", OFFSET(error_resilient), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, VE, "er"},
699  { "default", "Improve resiliency against losses of whole frames", 0, AV_OPT_TYPE_CONST, {.i64 = AOM_ERROR_RESILIENT_DEFAULT}, 0, 0, VE, "er"},
700  { "partitions", "The frame partitions are independently decodable "
701  "by the bool decoder, meaning that partitions can be decoded even "
702  "though earlier partitions have been lost. Note that intra predicition"
703  " is still done over the partition boundary.", 0, AV_OPT_TYPE_CONST, {.i64 = AOM_ERROR_RESILIENT_PARTITIONS}, 0, 0, VE, "er"},
704  { "crf", "Select the quality for constant quality mode", offsetof(AOMContext, crf), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, VE },
705  { "static-thresh", "A change threshold on blocks below which they will be skipped by the encoder", OFFSET(static_thresh), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
706  { "drop-threshold", "Frame drop threshold", offsetof(AOMContext, drop_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE },
707  { "noise-sensitivity", "Noise sensitivity", OFFSET(noise_sensitivity), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 4, VE},
708  { NULL }
709 };
710 
711  static const AVCodecDefault defaults[] = {
712  { "qmin", "-1" },
713  { "qmax", "-1" },
714  { "g", "-1" },
715  { "keyint_min", "-1" },
716  { NULL },
717 };
718 
719  static const AVClass class_aom = {
720  .class_name = "libaom-av1 encoder",
721  .item_name = av_default_item_name,
722  .option = options,
723  .version = LIBAVUTIL_VERSION_INT,
724 };
725 
726  AVCodec ff_libaom_av1_encoder = {
727  .name = "libaom-av1",
728  .long_name = NULL_IF_CONFIG_SMALL("libaom AV1"),
729  .type = AVMEDIA_TYPE_VIDEO,
730  .id = AV_CODEC_ID_AV1,
731  .priv_data_size = sizeof(AOMContext),
732  .init = av1_init,
733  .encode2 = aom_encode,
734  .close = aom_free,
735  .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS | AV_CODEC_CAP_EXPERIMENTAL,
736  .profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles),
737  .priv_class = &class_aom,
738  .defaults = defaults,
739  .init_static_data = av1_init_static,
740  .wrapper_name = "libaom",
741 };
OFFSET
#define OFFSET(x)
Definition: libaomenc.c:690
NULL
#define NULL
Definition: coverity.c:32
val
const char const char void * val
Definition: avisynth_c.h:771
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:218
AVOption
AVOption.
Definition: opt.h:246
cx_pktcpy
static void cx_pktcpy(struct FrameListData *dst, const struct aom_codec_cx_pkt *src)
Definition: libaomenc.c:477
AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
AVCodecContext::bit_rate
int64_t bit_rate
the average bitrate
Definition: avcodec.h:1568
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
desc
const char * desc
Definition: nvenc.c:65
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
AVCPBProperties::max_bitrate
int max_bitrate
Maximum bitrate of the stream, in bits per second.
Definition: avcodec.h:1104
AVCodecContext::rc_initial_buffer_occupancy
int rc_initial_buffer_occupancy
Number of bits which should be loaded into the rc buffer before decoding starts.
Definition: avcodec.h:2419
aom_init
static av_cold int aom_init(AVCodecContext *avctx, const struct aom_codec_iface *iface)
Definition: libaomenc.c:285
AVCodecContext::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:2148
AVRational::num
int num
Numerator.
Definition: rational.h:59
AVPacket::size
int size
Definition: avcodec.h:1431
FrameListData::buf
void * buf
compressed data buffer
Definition: libaomenc.c:46
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1727
FrameListData::sz
size_t sz
length of compressed data
Definition: libaomenc.c:47
AV_CODEC_CAP_EXPERIMENTAL
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
Definition: avcodec.h:1007
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:372
AVCodecContext::stats_in
char * stats_in
pass2 encoding statistics input buffer Concatenated stuff from stats_out of pass1 should be placed he...
Definition: avcodec.h:2540
pkt
static AVPacket pkt
Definition: demuxing_decoding.c:54
options
static const AVOption options[]
Definition: libaomenc.c:692
AV_CODEC_CAP_AUTO_THREADS
#define AV_CODEC_CAP_AUTO_THREADS
Codec supports avctx->thread_count == 0 (auto).
Definition: avcodec.h:1027
src
#define src
Definition: vp8dsp.c:254
AVCodecContext::profile
int profile
profile
Definition: avcodec.h:2843
AVCodec
AVCodec.
Definition: avcodec.h:3408
AVCPBProperties::min_bitrate
int min_bitrate
Minimum bitrate of the stream, in bits per second.
Definition: avcodec.h:1109
AOMContext::error_resilient
int error_resilient
Definition: libaomenc.c:65
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:1640
AOMContext::crf
int crf
Definition: libaomenc.c:66
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:72
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: avcodec.h:984
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
ff_alloc_packet2
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
Definition: encode.c:32
free_frame_list
static av_cold void free_frame_list(struct FrameListData *list)
Definition: libaomenc.c:164
FrameListData::next
struct FrameListData * next
Definition: libaomenc.c:53
uint8_t
uint8_t
Definition: audio_convert.c:194
AOMContext::twopass_stats
struct aom_fixed_buf twopass_stats
Definition: libaomenc.c:60
av_cold
#define av_cold
Definition: attributes.h:82
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
FrameListData::pts
int64_t pts
time stamp to show frame (in timebase units)
Definition: libaomenc.c:48
opt.h
AVOptions.
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:311
frame
static AVFrame * frame
Definition: demuxing_decoding.c:53
AOMContext::rawimg
struct aom_image rawimg
Definition: libaomenc.c:59
AVPacket::data
uint8_t * data
Definition: avcodec.h:1430
flags
static int flags
Definition: log.c:55
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
codecctl_int
static av_cold int codecctl_int(AVCodecContext *avctx, enum aome_enc_control_id id, int val)
Definition: libaomenc.c:175
AVCPBProperties::buffer_size
int buffer_size
The size of the buffer to which the ratecontrol is applied, in bits.
Definition: avcodec.h:1120
size
ptrdiff_t size
Definition: opengl_enc.c:101
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:373
AVCodecContext::stats_out
char * stats_out
pass1 encoding statistics output buffer
Definition: avcodec.h:2532
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: avcodec.h:1462
VE
#define VE
Definition: libaomenc.c:691
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
av1_init_static
static av_cold void av1_init_static(AVCodec *codec)
Definition: libaomenc.c:676
AVERROR
#define AVERROR(e)
Definition: error.h:43
AVCodecContext::qmax
int qmax
maximum quantizer
Definition: avcodec.h:2362
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:186
AVFrame::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: frame.h:463
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:1598
width
uint16_t width
Definition: gdv.c:47
AV_ROUND_NEAR_INF
Round to nearest and halfway cases away from zero.
Definition: mathematics.h:84
avassert.h
simple assert() macros that are a bit more flexible than ISO C assert().
AVCodec::name
const char * name
Name of the codec implementation.
Definition: avcodec.h:3415
round
static av_always_inline av_const double round(double x)
Definition: libm.h:444
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:371
av_base64_encode
char * av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size)
Encode data to base64 and null-terminate.
Definition: base64.c:138
storeframe
static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame, AVPacket *pkt)
Store coded frame information in format suitable for return from encode2().
Definition: libaomenc.c:494
set_color_range
static void set_color_range(AVCodecContext *avctx)
Definition: libaomenc.c:269
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: avcodec.h:1436
AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
AVCodecContext::rc_buffer_size
int rc_buffer_size
decoder bitstream buffer size
Definition: avcodec.h:2376
class_aom
static const AVClass class_aom
Definition: libaomenc.c:719
AVCodecContext::rc_min_rate
int64_t rc_min_rate
minimum bitrate
Definition: avcodec.h:2398
ff_libaom_av1_encoder
AVCodec ff_libaom_av1_encoder
Definition: libaomenc.c:726
AOMContext::coded_frame_list
struct FrameListData * coded_frame_list
Definition: libaomenc.c:61
av1_pix_fmts_highbd
static enum AVPixelFormat av1_pix_fmts_highbd[]
Definition: libaomenc.c:663
AVCodec::pix_fmts
enum AVPixelFormat * pix_fmts
array of supported pixel formats, or NULL if unknown, array is terminated by -1
Definition: avcodec.h:3429
AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
AVFrame::pict_type
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:301
AV_BASE64_SIZE
#define AV_BASE64_SIZE(x)
Calculate the output size needed to base64-encode x bytes to a null-terminated string.
Definition: base64.h:66
queue_frames
static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out)
Queue multiple output frames from the encoder, returning the front-most.
Definition: libaomenc.c:519
AOMContext::noise_sensitivity
int noise_sensitivity
Definition: libaomenc.c:69
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:1690
FF_PROFILE_UNKNOWN
#define FF_PROFILE_UNKNOWN
Definition: avcodec.h:2844
free_coded_frame
static av_cold void free_coded_frame(struct FrameListData *cx_frame)
Definition: libaomenc.c:158
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AV_CODEC_FLAG_PASS1
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
Definition: avcodec.h:849
AVCodecContext::color_primaries
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:2127
stats
static void stats(AVPacket *const *in, int n_in, unsigned *_max, unsigned *_sum)
Definition: vp9_superframe_bsf.c:33
AVCodecContext::ticks_per_frame
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
Definition: avcodec.h:1649
ctlidstr
static const char *const ctlidstr[]
Definition: libaomenc.c:72
AVCodecContext::height
int height
Definition: avcodec.h:1690
av_rescale_rnd
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
Definition: mathematics.c:58
error
static void error(const char *err)
Definition: target_dec_fuzzer.c:59
AOMContext::cpu_used
int cpu_used
Definition: libaomenc.c:62
AVCodecContext::thread_count
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
Definition: avcodec.h:2769
AVCOL_RANGE_JPEG
the normal 2^n-1 "JPEG" YUV ranges
Definition: pixfmt.h:499
set_pix_fmt
static int set_pix_fmt(AVCodecContext *avctx, aom_codec_caps_t codec_caps, struct aom_codec_enc_cfg *enccfg, aom_codec_flags_t *flags, aom_img_fmt_t *img_fmt)
Definition: libaomenc.c:208
AVCPBProperties
This structure describes the bitrate properties of an encoded bitstream.
Definition: avcodec.h:1099
AOMContext::encoder
struct aom_codec_ctx encoder
Definition: libaomenc.c:58
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
av_reallocp
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
Definition: mem.c:163
avcodec.h
Libavcodec external API header.
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:249
ff_av1_profiles
const AVProfile ff_av1_profiles[]
Definition: profiles.c:143
AVCodecContext
main external API structure.
Definition: avcodec.h:1518
av1_pix_fmts
static enum AVPixelFormat av1_pix_fmts[]
Definition: libaomenc.c:656
AVCodecContext::qmin
int qmin
minimum quantizer
Definition: avcodec.h:2355
buf
void * buf
Definition: avisynth_c.h:690
av1_init
static av_cold int av1_init(AVCodecContext *avctx)
Definition: libaomenc.c:685
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:368
coded_frame_add
static void coded_frame_add(void *list, struct FrameListData *cx_frame)
Definition: libaomenc.c:148
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
profiles
static const AVProfile profiles[]
Definition: libfdk-aacenc.c:381
FF_PROFILE_AV1_PROFESSIONAL
#define FF_PROFILE_AV1_PROFESSIONAL
Definition: avcodec.h:2938
AVCodecContext::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:2141
AVCodecContext::color_trc
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:2134
FF_PROFILE_AV1_MAIN
#define FF_PROFILE_AV1_MAIN
Definition: avcodec.h:2936
FrameListData::flags
uint32_t flags
flags for this frame
Definition: libaomenc.c:52
snprintf
#define snprintf
Definition: snprintf.h:34
AOMContext::static_thresh
int static_thresh
Definition: libaomenc.c:67
dump_enc_cfg
static av_cold void dump_enc_cfg(AVCodecContext *avctx, const struct aom_codec_enc_cfg *cfg)
Definition: libaomenc.c:94
AVCodecContext::qcompress
float qcompress
amount of qscale change between easy & hard scenes (0.0-1.0)
Definition: avcodec.h:2347
AOMContext::drop_threshold
int drop_threshold
Definition: libaomenc.c:68
SIZE_SPECIFIER
#define SIZE_SPECIFIER
Definition: internal.h:262
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:369
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:375
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:232
level
uint8_t level
Definition: svq3.c:207
AVCOL_RANGE_MPEG
the normal 219*2^(n-8) "MPEG" YUV ranges
Definition: pixfmt.h:498
AVCodecContext::gop_size
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
Definition: avcodec.h:1712
AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
internal.h
common internal api header.
log_encoder_error
static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
Definition: libaomenc.c:83
common.h
common internal and external API header
AOMContext::auto_alt_ref
int auto_alt_ref
Definition: libaomenc.c:63
aom_encode
static int aom_encode(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: libaomenc.c:600
AVRational::den
int den
Denominator.
Definition: rational.h:60
ff_add_cpb_side_data
AVCPBProperties * ff_add_cpb_side_data(AVCodecContext *avctx)
Add a CPB properties side data to an encoding context.
Definition: utils.c:1936
AV_CODEC_FLAG_PASS2
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
Definition: avcodec.h:853
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:1545
FrameListData
Portion of struct vpx_codec_cx_pkt from vpx_encoder.h.
Definition: libaomenc.c:45
AVCPBProperties::avg_bitrate
int avg_bitrate
Average bitrate of the stream, in bits per second.
Definition: avcodec.h:1114
FrameListData::duration
unsigned long duration
duration to show frame (in timebase units)
Definition: libaomenc.c:50
av_base64_decode
int av_base64_decode(uint8_t *out, const char *in_str, int out_size)
Decode a base64-encoded string.
Definition: base64.c:79
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
Definition: avcodec.h:1429
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
defaults
static const AVCodecDefault defaults[]
Definition: libaomenc.c:711
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
AVPacket
This structure stores compressed data.
Definition: avcodec.h:1407
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1423
aom_free
static av_cold int aom_free(AVCodecContext *avctx)
Definition: libaomenc.c:197
AOMContext::lag_in_frames
int lag_in_frames
Definition: libaomenc.c:64
av_unused
#define av_unused
Definition: attributes.h:125
FF_PROFILE_AV1_HIGH
#define FF_PROFILE_AV1_HIGH
Definition: avcodec.h:2937
AVCodecContext::rc_max_rate
int64_t rc_max_rate
maximum bitrate
Definition: avcodec.h:2391
AVCodecContext::keyint_min
int keyint_min
minimum GOP size
Definition: avcodec.h:2094

Generated on Sun May 13 2018 02:03:49 for FFmpeg by   doxygen 1.8.6

AltStyle によって変換されたページ (->オリジナル) /