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 #include <limits.h>
27 
28 #define AOM_DISABLE_CTRL_TYPECHECKS 1
29 #include <aom/aom_encoder.h>
30 #include <aom/aomcx.h>
31 
32 #include "libavutil/avassert.h"
33 #include "libavutil/base64.h"
34 #include "libavutil/common.h"
35 #include "libavutil/cpu.h"
37 #include "libavutil/imgutils.h"
38 #include "libavutil/mathematics.h"
39 #include "libavutil/mem.h"
40 #include "libavutil/opt.h"
41 #include "libavutil/pixdesc.h"
42 
43 #include "av1.h"
44 #include "avcodec.h"
45 #include "bsf.h"
46 #include "bytestream.h"
47 #include "codec_internal.h"
48 #include "dovi_rpu.h"
49 #include "encode.h"
50 #include "internal.h"
51 #include "itut35.h"
52 #include "libaom.h"
53 #include "packet_internal.h"
54 #include "profiles.h"
55 
56 /*
57  * Portion of struct aom_codec_cx_pkt from aom_encoder.h.
58  * One encoded frame returned from the library.
59  */
60 struct FrameListData {
61  void *buf; /**< compressed data buffer */
62  size_t sz; /**< length of compressed data */
63  int64_t pts; /**< time stamp to show frame
64  (in timebase units) */
65  unsigned long duration; /**< duration to show frame
66  (in timebase units) */
67  uint32_t flags; /**< flags for this frame */
68  uint64_t sse[4];
69  int have_sse; /**< true if we have pending sse[] */
70  uint64_t frame_number;
72 };
73 
74 typedef struct AOMEncoderContext {
75  AVClass *class;
78  struct aom_codec_ctx encoder;
79  struct aom_image rawimg;
80  struct aom_fixed_buf twopass_stats;
83  int cpu_used;
87  int aq_mode;
90  int crf;
95  uint64_t sse[4];
96  int have_sse; /**< true if we have pending sse[] */
97  uint64_t frame_number;
105  aom_superblock_size_t superblock_size;
107  int row_mt;
112  int usage;
113  int tune;
144 } AOMContext;
145 
146 #define OFFSET(x) offsetof(AOMContext, x)
147 
148 static const char *const ctlidstr[] = {
149  [AOME_SET_CPUUSED] = "AOME_SET_CPUUSED",
150  [AOME_SET_CQ_LEVEL] = "AOME_SET_CQ_LEVEL",
151  [AOME_SET_ENABLEAUTOALTREF] = "AOME_SET_ENABLEAUTOALTREF",
152  [AOME_SET_ARNR_MAXFRAMES] = "AOME_SET_ARNR_MAXFRAMES",
153  [AOME_SET_ARNR_STRENGTH] = "AOME_SET_ARNR_STRENGTH",
154  [AOME_SET_STATIC_THRESHOLD] = "AOME_SET_STATIC_THRESHOLD",
155  [AV1E_SET_COLOR_RANGE] = "AV1E_SET_COLOR_RANGE",
156  [AV1E_SET_COLOR_PRIMARIES] = "AV1E_SET_COLOR_PRIMARIES",
157  [AV1E_SET_MATRIX_COEFFICIENTS] = "AV1E_SET_MATRIX_COEFFICIENTS",
158  [AV1E_SET_TRANSFER_CHARACTERISTICS] = "AV1E_SET_TRANSFER_CHARACTERISTICS",
159  [AV1E_SET_AQ_MODE] = "AV1E_SET_AQ_MODE",
160  [AV1E_SET_FRAME_PARALLEL_DECODING] = "AV1E_SET_FRAME_PARALLEL_DECODING",
161  [AV1E_SET_SUPERBLOCK_SIZE] = "AV1E_SET_SUPERBLOCK_SIZE",
162  [AV1E_SET_TILE_COLUMNS] = "AV1E_SET_TILE_COLUMNS",
163  [AV1E_SET_TILE_ROWS] = "AV1E_SET_TILE_ROWS",
164  [AV1E_SET_ENABLE_RESTORATION] = "AV1E_SET_ENABLE_RESTORATION",
165  [AV1E_SET_ROW_MT] = "AV1E_SET_ROW_MT",
166  [AV1E_SET_DENOISE_NOISE_LEVEL] = "AV1E_SET_DENOISE_NOISE_LEVEL",
167  [AV1E_SET_DENOISE_BLOCK_SIZE] = "AV1E_SET_DENOISE_BLOCK_SIZE",
168  [AV1E_SET_MAX_REFERENCE_FRAMES] = "AV1E_SET_MAX_REFERENCE_FRAMES",
169  [AV1E_SET_ENABLE_GLOBAL_MOTION] = "AV1E_SET_ENABLE_GLOBAL_MOTION",
170  [AV1E_SET_ENABLE_INTRABC] = "AV1E_SET_ENABLE_INTRABC",
171  [AV1E_SET_ENABLE_CDEF] = "AV1E_SET_ENABLE_CDEF",
172  [AOME_SET_TUNING] = "AOME_SET_TUNING",
173  [AV1E_SET_ENABLE_1TO4_PARTITIONS] = "AV1E_SET_ENABLE_1TO4_PARTITIONS",
174  [AV1E_SET_ENABLE_AB_PARTITIONS] = "AV1E_SET_ENABLE_AB_PARTITIONS",
175  [AV1E_SET_ENABLE_RECT_PARTITIONS] = "AV1E_SET_ENABLE_RECT_PARTITIONS",
176  [AV1E_SET_ENABLE_ANGLE_DELTA] = "AV1E_SET_ENABLE_ANGLE_DELTA",
177  [AV1E_SET_ENABLE_CFL_INTRA] = "AV1E_SET_ENABLE_CFL_INTRA",
178  [AV1E_SET_ENABLE_FILTER_INTRA] = "AV1E_SET_ENABLE_FILTER_INTRA",
179  [AV1E_SET_ENABLE_INTRA_EDGE_FILTER] = "AV1E_SET_ENABLE_INTRA_EDGE_FILTER",
180  [AV1E_SET_ENABLE_PAETH_INTRA] = "AV1E_SET_ENABLE_PAETH_INTRA",
181  [AV1E_SET_ENABLE_SMOOTH_INTRA] = "AV1E_SET_ENABLE_SMOOTH_INTRA",
182  [AV1E_SET_ENABLE_PALETTE] = "AV1E_SET_ENABLE_PALETTE",
183  [AV1E_SET_ENABLE_FLIP_IDTX] = "AV1E_SET_ENABLE_FLIP_IDTX",
184  [AV1E_SET_ENABLE_TX64] = "AV1E_SET_ENABLE_TX64",
185  [AV1E_SET_INTRA_DCT_ONLY] = "AV1E_SET_INTRA_DCT_ONLY",
186  [AV1E_SET_INTER_DCT_ONLY] = "AV1E_SET_INTER_DCT_ONLY",
187  [AV1E_SET_INTRA_DEFAULT_TX_ONLY] = "AV1E_SET_INTRA_DEFAULT_TX_ONLY",
188  [AV1E_SET_REDUCED_TX_TYPE_SET] = "AV1E_SET_REDUCED_TX_TYPE_SET",
189  [AV1E_SET_ENABLE_DIFF_WTD_COMP] = "AV1E_SET_ENABLE_DIFF_WTD_COMP",
190  [AV1E_SET_ENABLE_DIST_WTD_COMP] = "AV1E_SET_ENABLE_DIST_WTD_COMP",
191  [AV1E_SET_ENABLE_DUAL_FILTER] = "AV1E_SET_ENABLE_DUAL_FILTER",
192  [AV1E_SET_ENABLE_INTERINTER_WEDGE] = "AV1E_SET_ENABLE_INTERINTER_WEDGE",
193  [AV1E_SET_ENABLE_INTERINTRA_WEDGE] = "AV1E_SET_ENABLE_INTERINTRA_WEDGE",
194  [AV1E_SET_ENABLE_MASKED_COMP] = "AV1E_SET_ENABLE_MASKED_COMP",
195  [AV1E_SET_ENABLE_INTERINTRA_COMP] = "AV1E_SET_ENABLE_INTERINTRA_COMP",
196  [AV1E_SET_ENABLE_OBMC] = "AV1E_SET_ENABLE_OBMC",
197  [AV1E_SET_ENABLE_ONESIDED_COMP] = "AV1E_SET_ENABLE_ONESIDED_COMP",
198  [AV1E_SET_REDUCED_REFERENCE_SET] = "AV1E_SET_REDUCED_REFERENCE_SET",
199  [AV1E_SET_ENABLE_SMOOTH_INTERINTRA] = "AV1E_SET_ENABLE_SMOOTH_INTERINTRA",
200  [AV1E_SET_ENABLE_REF_FRAME_MVS] = "AV1E_SET_ENABLE_REF_FRAME_MVS",
201 #ifdef AOM_CTRL_AV1E_GET_NUM_OPERATING_POINTS
202  [AV1E_GET_NUM_OPERATING_POINTS] = "AV1E_GET_NUM_OPERATING_POINTS",
203 #endif
204  [AV1E_GET_SEQ_LEVEL_IDX] = "AV1E_GET_SEQ_LEVEL_IDX",
205 #ifdef AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX
206  [AV1E_GET_TARGET_SEQ_LEVEL_IDX] = "AV1E_GET_TARGET_SEQ_LEVEL_IDX",
207 #endif
208  [AV1_GET_NEW_FRAME_IMAGE] = "AV1_GET_NEW_FRAME_IMAGE",
209 };
210 
211 static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
212 {
213  AOMContext *ctx = avctx->priv_data;
214  const char *error = aom_codec_error(&ctx->encoder);
215  const char *detail = aom_codec_error_detail(&ctx->encoder);
216 
217  av_log(avctx, AV_LOG_ERROR, "%s: %s\n", desc, error);
218  if (detail)
219  av_log(avctx, AV_LOG_ERROR, " Additional information: %s\n", detail);
220 }
221 
223  const struct aom_codec_enc_cfg *cfg,
224  int level)
225 {
226  int width = -30;
227 
228  av_log(avctx, level, "aom_codec_enc_cfg\n");
229  av_log(avctx, level, "generic settings\n"
230  " %*s%u\n %*s%u\n %*s%u\n %*s%u\n %*s%u\n"
231  " %*s%u\n %*s%u\n"
232  " %*s{%u/%u}\n %*s%u\n %*s%d\n %*s%u\n",
233  width, "g_usage:", cfg->g_usage,
234  width, "g_threads:", cfg->g_threads,
235  width, "g_profile:", cfg->g_profile,
236  width, "g_w:", cfg->g_w,
237  width, "g_h:", cfg->g_h,
238  width, "g_bit_depth:", cfg->g_bit_depth,
239  width, "g_input_bit_depth:", cfg->g_input_bit_depth,
240  width, "g_timebase:", cfg->g_timebase.num, cfg->g_timebase.den,
241  width, "g_error_resilient:", cfg->g_error_resilient,
242  width, "g_pass:", cfg->g_pass,
243  width, "g_lag_in_frames:", cfg->g_lag_in_frames);
244  av_log(avctx, level, "rate control settings\n"
245  " %*s%u\n %*s%d\n %*s%p(%"SIZE_SPECIFIER")\n %*s%u\n",
246  width, "rc_dropframe_thresh:", cfg->rc_dropframe_thresh,
247  width, "rc_end_usage:", cfg->rc_end_usage,
248  width, "rc_twopass_stats_in:", cfg->rc_twopass_stats_in.buf, cfg->rc_twopass_stats_in.sz,
249  width, "rc_target_bitrate:", cfg->rc_target_bitrate);
250  av_log(avctx, level, "quantizer settings\n"
251  " %*s%u\n %*s%u\n",
252  width, "rc_min_quantizer:", cfg->rc_min_quantizer,
253  width, "rc_max_quantizer:", cfg->rc_max_quantizer);
254  av_log(avctx, level, "bitrate tolerance\n"
255  " %*s%u\n %*s%u\n",
256  width, "rc_undershoot_pct:", cfg->rc_undershoot_pct,
257  width, "rc_overshoot_pct:", cfg->rc_overshoot_pct);
258  av_log(avctx, level, "decoder buffer model\n"
259  " %*s%u\n %*s%u\n %*s%u\n",
260  width, "rc_buf_sz:", cfg->rc_buf_sz,
261  width, "rc_buf_initial_sz:", cfg->rc_buf_initial_sz,
262  width, "rc_buf_optimal_sz:", cfg->rc_buf_optimal_sz);
263  av_log(avctx, level, "2 pass rate control settings\n"
264  " %*s%u\n %*s%u\n %*s%u\n",
265  width, "rc_2pass_vbr_bias_pct:", cfg->rc_2pass_vbr_bias_pct,
266  width, "rc_2pass_vbr_minsection_pct:", cfg->rc_2pass_vbr_minsection_pct,
267  width, "rc_2pass_vbr_maxsection_pct:", cfg->rc_2pass_vbr_maxsection_pct);
268  av_log(avctx, level, "keyframing settings\n"
269  " %*s%d\n %*s%u\n %*s%u\n",
270  width, "kf_mode:", cfg->kf_mode,
271  width, "kf_min_dist:", cfg->kf_min_dist,
272  width, "kf_max_dist:", cfg->kf_max_dist);
273  av_log(avctx, level, "tile settings\n"
274  " %*s%d\n %*s%d\n",
275  width, "tile_width_count:", cfg->tile_width_count,
276  width, "tile_height_count:", cfg->tile_height_count);
277  av_log(avctx, level, "\n");
278 }
279 
280 static void coded_frame_add(void *list, struct FrameListData *cx_frame)
281 {
282  struct FrameListData **p = list;
283 
284  while (*p)
285  p = &(*p)->next;
286  *p = cx_frame;
287  cx_frame->next = NULL;
288 }
289 
290 static av_cold void free_coded_frame(struct FrameListData *cx_frame)
291 {
292  av_freep(&cx_frame->buf);
293  av_freep(&cx_frame);
294 }
295 
297 {
298  struct FrameListData *p = list;
299 
300  while (p) {
301  list = list->next;
302  free_coded_frame(p);
303  p = list;
304  }
305 }
306 
308 #ifdef UENUM1BYTE
309  aome_enc_control_id id,
310 #else
311  enum aome_enc_control_id id,
312 #endif
313  int val)
314 {
315  AOMContext *ctx = avctx->priv_data;
316  char buf[80];
317  int width = -30;
318  int res;
319 
320  snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]);
321  av_log(avctx, AV_LOG_DEBUG, " %*s%d\n", width, buf, val);
322 
323  res = aom_codec_control(&ctx->encoder, id, val);
324  if (res != AOM_CODEC_OK) {
325  snprintf(buf, sizeof(buf), "Failed to set %s codec control",
326  ctlidstr[id]);
327  log_encoder_error(avctx, buf);
328  return AVERROR(EINVAL);
329  }
330 
331  return 0;
332 }
333 
334 static int add_hdr_plus(AVCodecContext *avctx, struct aom_image *img, const AVFrame *frame)
335 {
336  // Check for HDR10+
337  AVFrameSideData *side_data =
339  if (!side_data)
340  return 0;
341 
342  size_t payload_size;
343  AVDynamicHDRPlus *hdr_plus = (AVDynamicHDRPlus *)side_data->buf->data;
344  int res = av_dynamic_hdr_plus_to_t35(hdr_plus, NULL, &payload_size);
345  if (res < 0) {
346  log_encoder_error(avctx, "Error finding the size of HDR10+");
347  return res;
348  }
349 
350  uint8_t *hdr_plus_buf;
351  // Extra bytes for the country code, provider code, provider oriented code and app id.
352  const size_t hdr_plus_buf_size = payload_size + 6;
353  hdr_plus_buf = av_malloc(hdr_plus_buf_size);
354  if (!hdr_plus_buf)
355  return AVERROR(ENOMEM);
356 
357  uint8_t *payload = hdr_plus_buf;
358  // See "HDR10+ AV1 Metadata Handling Specification" v1.0.1, Section 2.1.
359  bytestream_put_byte(&payload, ITU_T_T35_COUNTRY_CODE_US);
360  bytestream_put_be16(&payload, ITU_T_T35_PROVIDER_CODE_SAMSUNG);
361  bytestream_put_be16(&payload, 0x0001); // provider_oriented_code
362  bytestream_put_byte(&payload, 0x04); // application_identifier
363 
364  res = av_dynamic_hdr_plus_to_t35(hdr_plus, &payload, &payload_size);
365  if (res < 0) {
366  av_free(hdr_plus_buf);
367  log_encoder_error(avctx, "Error encoding HDR10+ from side data");
368  return res;
369  }
370 
371  res = aom_img_add_metadata(img, OBU_METADATA_TYPE_ITUT_T35,
372  hdr_plus_buf, hdr_plus_buf_size, AOM_MIF_ANY_FRAME);
373  av_free(hdr_plus_buf);
374  if (res < 0) {
375  log_encoder_error(avctx, "Error adding HDR10+ to aom_img");
376  return res;
377  }
378  return 0;
379 }
380 
381 #if defined(AOM_CTRL_AV1E_GET_NUM_OPERATING_POINTS) && \
382  defined(AOM_CTRL_AV1E_GET_SEQ_LEVEL_IDX) && \
383  defined(AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX)
384 static av_cold int codecctl_intp(AVCodecContext *avctx,
385 #ifdef UENUM1BYTE
386  aome_enc_control_id id,
387 #else
388  enum aome_enc_control_id id,
389 #endif
390  int* ptr)
391 {
392  AOMContext *ctx = avctx->priv_data;
393  char buf[80];
394  int width = -30;
395  int res;
396 
397  snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]);
398  av_log(avctx, AV_LOG_DEBUG, " %*s%d\n", width, buf, *ptr);
399 
400  res = aom_codec_control(&ctx->encoder, id, ptr);
401  if (res != AOM_CODEC_OK) {
402  snprintf(buf, sizeof(buf), "Failed to set %s codec control",
403  ctlidstr[id]);
404  log_encoder_error(avctx, buf);
405  return AVERROR(EINVAL);
406  }
407 
408  return 0;
409 }
410 #endif
411 
413 #ifdef UENUM1BYTE
414  aome_enc_control_id id,
415 #else
416  enum aome_enc_control_id id,
417 #endif
418  struct aom_image *img)
419 {
420  AOMContext *ctx = avctx->priv_data;
421  char buf[80];
422  int res;
423 
424  snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]);
425 
426  res = aom_codec_control(&ctx->encoder, id, img);
427  if (res != AOM_CODEC_OK) {
428  snprintf(buf, sizeof(buf), "Failed to get %s codec control",
429  ctlidstr[id]);
430  log_encoder_error(avctx, buf);
431  return AVERROR(EINVAL);
432  }
433 
434  return 0;
435 }
436 
437 static av_cold int aom_free(AVCodecContext *avctx)
438 {
439  AOMContext *ctx = avctx->priv_data;
440 
441 #if defined(AOM_CTRL_AV1E_GET_NUM_OPERATING_POINTS) && \
442  defined(AOM_CTRL_AV1E_GET_SEQ_LEVEL_IDX) && \
443  defined(AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX)
444  if (ctx->encoder.iface && !(avctx->flags & AV_CODEC_FLAG_PASS1)) {
445  int num_operating_points;
446  int levels[32];
447  int target_levels[32];
448 
449  if (!codecctl_intp(avctx, AV1E_GET_NUM_OPERATING_POINTS,
450  &num_operating_points) &&
451  !codecctl_intp(avctx, AV1E_GET_SEQ_LEVEL_IDX, levels) &&
452  !codecctl_intp(avctx, AV1E_GET_TARGET_SEQ_LEVEL_IDX,
453  target_levels)) {
454  for (int i = 0; i < num_operating_points; i++) {
455  if (levels[i] > target_levels[i]) {
456  // Warn when the target level was not met
457  av_log(avctx, AV_LOG_WARNING,
458  "Could not encode to target level %d.%d for "
459  "operating point %d. The output level is %d.%d.\n",
460  2 + (target_levels[i] >> 2), target_levels[i] & 3,
461  i, 2 + (levels[i] >> 2), levels[i] & 3);
462  } else if (target_levels[i] < 31) {
463  // Log the encoded level if a target level was given
464  av_log(avctx, AV_LOG_INFO,
465  "Output level for operating point %d is %d.%d.\n",
466  i, 2 + (levels[i] >> 2), levels[i] & 3);
467  }
468  }
469  }
470  }
471 #endif
472 
473  aom_codec_destroy(&ctx->encoder);
474  aom_img_remove_metadata(&ctx->rawimg);
475  av_freep(&ctx->twopass_stats.buf);
476  av_freep(&avctx->stats_out);
477  free_frame_list(ctx->coded_frame_list);
478  av_bsf_free(&ctx->bsf);
479  ff_dovi_ctx_unref(&ctx->dovi);
480  return 0;
481 }
482 
483 static int set_pix_fmt(AVCodecContext *avctx, aom_codec_caps_t codec_caps,
484  struct aom_codec_enc_cfg *enccfg, aom_codec_flags_t *flags,
485  aom_img_fmt_t *img_fmt)
486 {
487  AOMContext av_unused *ctx = avctx->priv_data;
489  enccfg->g_bit_depth = enccfg->g_input_bit_depth = desc->comp[0].depth;
490  switch (avctx->pix_fmt) {
491  case AV_PIX_FMT_GRAY8:
492  enccfg->monochrome = 1;
493  /* Fall-through */
494  case AV_PIX_FMT_YUV420P:
495  enccfg->g_profile = AV_PROFILE_AV1_MAIN;
496  *img_fmt = AOM_IMG_FMT_I420;
497  return 0;
498  case AV_PIX_FMT_YUV422P:
499  enccfg->g_profile = AV_PROFILE_AV1_PROFESSIONAL;
500  *img_fmt = AOM_IMG_FMT_I422;
501  return 0;
502  case AV_PIX_FMT_YUV444P:
503  case AV_PIX_FMT_GBRP:
504  enccfg->g_profile = AV_PROFILE_AV1_HIGH;
505  *img_fmt = AOM_IMG_FMT_I444;
506  return 0;
507  case AV_PIX_FMT_GRAY10:
508  case AV_PIX_FMT_GRAY12:
509  enccfg->monochrome = 1;
510  /* Fall-through */
513  if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
514  enccfg->g_profile =
515  enccfg->g_bit_depth == 10 ? AV_PROFILE_AV1_MAIN : AV_PROFILE_AV1_PROFESSIONAL;
516  *img_fmt = AOM_IMG_FMT_I42016;
517  *flags |= AOM_CODEC_USE_HIGHBITDEPTH;
518  return 0;
519  }
520  break;
523  if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
524  enccfg->g_profile = AV_PROFILE_AV1_PROFESSIONAL;
525  *img_fmt = AOM_IMG_FMT_I42216;
526  *flags |= AOM_CODEC_USE_HIGHBITDEPTH;
527  return 0;
528  }
529  break;
532  case AV_PIX_FMT_GBRP10:
533  case AV_PIX_FMT_GBRP12:
534  if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
535  enccfg->g_profile =
536  enccfg->g_bit_depth == 10 ? AV_PROFILE_AV1_HIGH : AV_PROFILE_AV1_PROFESSIONAL;
537  *img_fmt = AOM_IMG_FMT_I44416;
538  *flags |= AOM_CODEC_USE_HIGHBITDEPTH;
539  return 0;
540  }
541  break;
542  default:
543  break;
544  }
545  av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format.\n");
546  return AVERROR_INVALIDDATA;
547 }
548 
549 static void set_color_range(AVCodecContext *avctx)
550 {
551  aom_color_range_t aom_cr;
552  switch (avctx->color_range) {
554  case AVCOL_RANGE_MPEG: aom_cr = AOM_CR_STUDIO_RANGE; break;
555  case AVCOL_RANGE_JPEG: aom_cr = AOM_CR_FULL_RANGE; break;
556  default:
557  av_log(avctx, AV_LOG_WARNING, "Unsupported color range (%d)\n",
558  avctx->color_range);
559  return;
560  }
561 
562  codecctl_int(avctx, AV1E_SET_COLOR_RANGE, aom_cr);
563 }
564 
565 static int count_uniform_tiling(int dim, int sb_size, int tiles_log2)
566 {
567  int sb_dim = (dim + sb_size - 1) / sb_size;
568  int tile_dim = (sb_dim + (1 << tiles_log2) - 1) >> tiles_log2;
569  av_assert0(tile_dim > 0);
570  return (sb_dim + tile_dim - 1) / tile_dim;
571 }
572 
573 static int choose_tiling(AVCodecContext *avctx,
574  struct aom_codec_enc_cfg *enccfg)
575 {
576  AOMContext *ctx = avctx->priv_data;
577  int sb_128x128_possible, sb_size, sb_width, sb_height;
578  int uniform_rows, uniform_cols;
579  int uniform_64x64_possible, uniform_128x128_possible;
580  int tile_size, rounding, i;
581 
582  if (ctx->tile_cols_log2 >= 0)
583  ctx->tile_cols = 1 << ctx->tile_cols_log2;
584  if (ctx->tile_rows_log2 >= 0)
585  ctx->tile_rows = 1 << ctx->tile_rows_log2;
586 
587  if (ctx->tile_cols == 0) {
588  ctx->tile_cols = (avctx->width + AV1_MAX_TILE_WIDTH - 1) /
590  if (ctx->tile_cols > 1) {
591  av_log(avctx, AV_LOG_DEBUG, "Automatically using %d tile "
592  "columns to fill width.\n", ctx->tile_cols);
593  }
594  }
595  av_assert0(ctx->tile_cols > 0);
596  if (ctx->tile_rows == 0) {
597  int max_tile_width =
598  FFALIGN((FFALIGN(avctx->width, 128) +
599  ctx->tile_cols - 1) / ctx->tile_cols, 128);
600  ctx->tile_rows =
601  (max_tile_width * FFALIGN(avctx->height, 128) +
603  if (ctx->tile_rows > 1) {
604  av_log(avctx, AV_LOG_DEBUG, "Automatically using %d tile "
605  "rows to fill area.\n", ctx->tile_rows);
606  }
607  }
608  av_assert0(ctx->tile_rows > 0);
609 
610  if ((avctx->width + 63) / 64 < ctx->tile_cols ||
611  (avctx->height + 63) / 64 < ctx->tile_rows) {
612  av_log(avctx, AV_LOG_ERROR, "Invalid tile sizing: frame not "
613  "large enough to fit specified tile arrangement.\n");
614  return AVERROR(EINVAL);
615  }
616  if (ctx->tile_cols > AV1_MAX_TILE_COLS ||
617  ctx->tile_rows > AV1_MAX_TILE_ROWS) {
618  av_log(avctx, AV_LOG_ERROR, "Invalid tile sizing: AV1 does "
619  "not allow more than %dx%d tiles.\n",
621  return AVERROR(EINVAL);
622  }
623  if (avctx->width / ctx->tile_cols > AV1_MAX_TILE_WIDTH) {
624  av_log(avctx, AV_LOG_ERROR, "Invalid tile sizing: AV1 does "
625  "not allow tiles of width greater than %d.\n",
627  return AVERROR(EINVAL);
628  }
629 
630  ctx->superblock_size = AOM_SUPERBLOCK_SIZE_DYNAMIC;
631 
632  if (ctx->tile_cols == 1 && ctx->tile_rows == 1) {
633  av_log(avctx, AV_LOG_DEBUG, "Using a single tile.\n");
634  return 0;
635  }
636 
637  sb_128x128_possible =
638  (avctx->width + 127) / 128 >= ctx->tile_cols &&
639  (avctx->height + 127) / 128 >= ctx->tile_rows;
640 
641  ctx->tile_cols_log2 = ctx->tile_cols == 1 ? 0 :
642  av_log2(ctx->tile_cols - 1) + 1;
643  ctx->tile_rows_log2 = ctx->tile_rows == 1 ? 0 :
644  av_log2(ctx->tile_rows - 1) + 1;
645 
646  uniform_cols = count_uniform_tiling(avctx->width,
647  64, ctx->tile_cols_log2);
648  uniform_rows = count_uniform_tiling(avctx->height,
649  64, ctx->tile_rows_log2);
650  av_log(avctx, AV_LOG_DEBUG, "Uniform with 64x64 superblocks "
651  "-> %dx%d tiles.\n", uniform_cols, uniform_rows);
652  uniform_64x64_possible = uniform_cols == ctx->tile_cols &&
653  uniform_rows == ctx->tile_rows;
654 
655  if (sb_128x128_possible) {
656  uniform_cols = count_uniform_tiling(avctx->width,
657  128, ctx->tile_cols_log2);
658  uniform_rows = count_uniform_tiling(avctx->height,
659  128, ctx->tile_rows_log2);
660  av_log(avctx, AV_LOG_DEBUG, "Uniform with 128x128 superblocks "
661  "-> %dx%d tiles.\n", uniform_cols, uniform_rows);
662  uniform_128x128_possible = uniform_cols == ctx->tile_cols &&
663  uniform_rows == ctx->tile_rows;
664  } else {
665  av_log(avctx, AV_LOG_DEBUG, "128x128 superblocks not possible.\n");
666  uniform_128x128_possible = 0;
667  }
668 
669  ctx->uniform_tiles = 1;
670  if (uniform_64x64_possible && uniform_128x128_possible) {
671  av_log(avctx, AV_LOG_DEBUG, "Using uniform tiling with dynamic "
672  "superblocks (tile_cols_log2 = %d, tile_rows_log2 = %d).\n",
673  ctx->tile_cols_log2, ctx->tile_rows_log2);
674  return 0;
675  }
676  if (uniform_64x64_possible && !sb_128x128_possible) {
677  av_log(avctx, AV_LOG_DEBUG, "Using uniform tiling with 64x64 "
678  "superblocks (tile_cols_log2 = %d, tile_rows_log2 = %d).\n",
679  ctx->tile_cols_log2, ctx->tile_rows_log2);
680  ctx->superblock_size = AOM_SUPERBLOCK_SIZE_64X64;
681  return 0;
682  }
683  if (uniform_128x128_possible) {
684  av_log(avctx, AV_LOG_DEBUG, "Using uniform tiling with 128x128 "
685  "superblocks (tile_cols_log2 = %d, tile_rows_log2 = %d).\n",
686  ctx->tile_cols_log2, ctx->tile_rows_log2);
687  ctx->superblock_size = AOM_SUPERBLOCK_SIZE_128X128;
688  return 0;
689  }
690  ctx->uniform_tiles = 0;
691 
692  if (sb_128x128_possible) {
693  sb_size = 128;
694  ctx->superblock_size = AOM_SUPERBLOCK_SIZE_128X128;
695  } else {
696  sb_size = 64;
697  ctx->superblock_size = AOM_SUPERBLOCK_SIZE_64X64;
698  }
699  av_log(avctx, AV_LOG_DEBUG, "Using fixed tiling with %dx%d "
700  "superblocks (tile_cols = %d, tile_rows = %d).\n",
701  sb_size, sb_size, ctx->tile_cols, ctx->tile_rows);
702 
703  enccfg->tile_width_count = ctx->tile_cols;
704  enccfg->tile_height_count = ctx->tile_rows;
705 
706  sb_width = (avctx->width + sb_size - 1) / sb_size;
707  sb_height = (avctx->height + sb_size - 1) / sb_size;
708 
709  tile_size = sb_width / ctx->tile_cols;
710  rounding = sb_width % ctx->tile_cols;
711  for (i = 0; i < ctx->tile_cols; i++) {
712  enccfg->tile_widths[i] = tile_size +
713  (i < rounding / 2 ||
714  i > ctx->tile_cols - 1 - (rounding + 1) / 2);
715  }
716 
717  tile_size = sb_height / ctx->tile_rows;
718  rounding = sb_height % ctx->tile_rows;
719  for (i = 0; i < ctx->tile_rows; i++) {
720  enccfg->tile_heights[i] = tile_size +
721  (i < rounding / 2 ||
722  i > ctx->tile_rows - 1 - (rounding + 1) / 2);
723  }
724 
725  return 0;
726 }
727 
728 
729 static const struct {
730  int aom_enum;
731  unsigned offset;
732 } option_map[] = {
733  { AOME_SET_ENABLEAUTOALTREF, OFFSET(auto_alt_ref) },
734  { AOME_SET_ARNR_MAXFRAMES, OFFSET(arnr_max_frames) },
735  { AOME_SET_ARNR_STRENGTH, OFFSET(arnr_strength) },
736  { AV1E_SET_ENABLE_CDEF, OFFSET(enable_cdef) },
737  { AV1E_SET_ENABLE_RESTORATION, OFFSET(enable_restoration) },
738  { AV1E_SET_ENABLE_RECT_PARTITIONS, OFFSET(enable_rect_partitions) },
739  { AV1E_SET_ENABLE_1TO4_PARTITIONS, OFFSET(enable_1to4_partitions) },
740  { AV1E_SET_ENABLE_AB_PARTITIONS, OFFSET(enable_ab_partitions) },
741  { AV1E_SET_ENABLE_ANGLE_DELTA, OFFSET(enable_angle_delta) },
742  { AV1E_SET_ENABLE_CFL_INTRA, OFFSET(enable_cfl_intra) },
743  { AV1E_SET_ENABLE_FILTER_INTRA, OFFSET(enable_filter_intra) },
744  { AV1E_SET_ENABLE_INTRA_EDGE_FILTER, OFFSET(enable_intra_edge_filter) },
745  { AV1E_SET_ENABLE_PAETH_INTRA, OFFSET(enable_paeth_intra) },
746  { AV1E_SET_ENABLE_SMOOTH_INTRA, OFFSET(enable_smooth_intra) },
747  { AV1E_SET_ENABLE_PALETTE, OFFSET(enable_palette) },
748  { AV1E_SET_ENABLE_TX64, OFFSET(enable_tx64) },
749  { AV1E_SET_ENABLE_FLIP_IDTX, OFFSET(enable_flip_idtx) },
750  { AV1E_SET_INTRA_DCT_ONLY, OFFSET(use_intra_dct_only) },
751  { AV1E_SET_INTER_DCT_ONLY, OFFSET(use_inter_dct_only) },
752  { AV1E_SET_INTRA_DEFAULT_TX_ONLY, OFFSET(use_intra_default_tx_only) },
753  { AV1E_SET_REDUCED_TX_TYPE_SET, OFFSET(reduced_tx_type_set) },
754  { AV1E_SET_ENABLE_REF_FRAME_MVS, OFFSET(enable_ref_frame_mvs) },
755  { AV1E_SET_REDUCED_REFERENCE_SET, OFFSET(enable_reduced_reference_set) },
756  { AV1E_SET_ENABLE_DIFF_WTD_COMP, OFFSET(enable_diff_wtd_comp) },
757  { AV1E_SET_ENABLE_DIST_WTD_COMP, OFFSET(enable_dist_wtd_comp) },
758  { AV1E_SET_ENABLE_DUAL_FILTER, OFFSET(enable_dual_filter) },
759  { AV1E_SET_ENABLE_INTERINTER_WEDGE, OFFSET(enable_interinter_wedge) },
760  { AV1E_SET_ENABLE_MASKED_COMP, OFFSET(enable_masked_comp) },
761  { AV1E_SET_ENABLE_INTERINTRA_COMP, OFFSET(enable_interintra_comp) },
762  { AV1E_SET_ENABLE_INTERINTRA_WEDGE, OFFSET(enable_interintra_wedge) },
763  { AV1E_SET_ENABLE_OBMC, OFFSET(enable_obmc) },
764  { AV1E_SET_ENABLE_ONESIDED_COMP, OFFSET(enable_onesided_comp) },
765  { AV1E_SET_ENABLE_SMOOTH_INTERINTRA, OFFSET(enable_smooth_interintra) },
766 };
767 
768 static av_cold int aom_init(AVCodecContext *avctx,
769  const struct aom_codec_iface *iface)
770 {
771  AOMContext *ctx = avctx->priv_data;
773  struct aom_codec_enc_cfg enccfg = { 0 };
774  aom_codec_flags_t flags =
775  (avctx->flags & AV_CODEC_FLAG_PSNR) ? AOM_CODEC_USE_PSNR : 0;
776  int res;
777  aom_img_fmt_t img_fmt;
778  aom_codec_caps_t codec_caps = aom_codec_get_caps(iface);
779 
780  av_log(avctx, AV_LOG_INFO, "%s\n", aom_codec_version_str());
781  av_log(avctx, AV_LOG_VERBOSE, "%s\n", aom_codec_build_config());
782 
783  if ((res = aom_codec_enc_config_default(iface, &enccfg, ctx->usage)) != AOM_CODEC_OK) {
784  av_log(avctx, AV_LOG_ERROR, "Failed to get config: %s\n",
785  aom_codec_err_to_string(res));
786  return AVERROR(EINVAL);
787  }
788 
789  if (set_pix_fmt(avctx, codec_caps, &enccfg, &flags, &img_fmt))
790  return AVERROR(EINVAL);
791 
792  if(!avctx->bit_rate)
793  if(avctx->rc_max_rate || avctx->rc_buffer_size || avctx->rc_initial_buffer_occupancy) {
794  av_log( avctx, AV_LOG_ERROR, "Rate control parameters set without a bitrate\n");
795  return AVERROR(EINVAL);
796  }
797 
798  dump_enc_cfg(avctx, &enccfg, AV_LOG_DEBUG);
799 
800  enccfg.g_w = avctx->width;
801  enccfg.g_h = avctx->height;
802  enccfg.g_timebase.num = avctx->time_base.num;
803  enccfg.g_timebase.den = avctx->time_base.den;
804  enccfg.g_threads =
805  FFMIN(avctx->thread_count ? avctx->thread_count : av_cpu_count(), 64);
806 
807  if (ctx->lag_in_frames >= 0)
808  enccfg.g_lag_in_frames = ctx->lag_in_frames;
809 
810  if (avctx->flags & AV_CODEC_FLAG_PASS1)
811  enccfg.g_pass = AOM_RC_FIRST_PASS;
812  else if (avctx->flags & AV_CODEC_FLAG_PASS2)
813  enccfg.g_pass = AOM_RC_LAST_PASS;
814  else
815  enccfg.g_pass = AOM_RC_ONE_PASS;
816 
817  if (avctx->rc_min_rate == avctx->rc_max_rate &&
818  avctx->rc_min_rate == avctx->bit_rate && avctx->bit_rate) {
819  enccfg.rc_end_usage = AOM_CBR;
820  } else if (ctx->crf >= 0) {
821  enccfg.rc_end_usage = AOM_CQ;
822  if (!avctx->bit_rate)
823  enccfg.rc_end_usage = AOM_Q;
824  }
825 
826  if (avctx->bit_rate) {
827  enccfg.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000,
829  } else if (enccfg.rc_end_usage != AOM_Q) {
830  enccfg.rc_end_usage = AOM_Q;
831  ctx->crf = 32;
832  av_log(avctx, AV_LOG_WARNING,
833  "Neither bitrate nor constrained quality specified, using default CRF of %d\n",
834  ctx->crf);
835  }
836 
837  if (avctx->qmin >= 0)
838  enccfg.rc_min_quantizer = avctx->qmin;
839  if (avctx->qmax >= 0) {
840  enccfg.rc_max_quantizer = avctx->qmax;
841  } else if (!ctx->crf) {
842  enccfg.rc_max_quantizer = 0;
843  }
844 
845  if (enccfg.rc_end_usage == AOM_CQ || enccfg.rc_end_usage == AOM_Q) {
846  if (ctx->crf < enccfg.rc_min_quantizer || ctx->crf > enccfg.rc_max_quantizer) {
847  av_log(avctx, AV_LOG_ERROR,
848  "CQ level %d must be between minimum and maximum quantizer value (%d-%d)\n",
849  ctx->crf, enccfg.rc_min_quantizer, enccfg.rc_max_quantizer);
850  return AVERROR(EINVAL);
851  }
852  }
853 
854  enccfg.rc_dropframe_thresh = ctx->drop_threshold;
855 
856  // 0-100 (0 => CBR, 100 => VBR)
857  enccfg.rc_2pass_vbr_bias_pct = round(avctx->qcompress * 100);
858  if (ctx->minsection_pct >= 0)
859  enccfg.rc_2pass_vbr_minsection_pct = ctx->minsection_pct;
860  else if (avctx->bit_rate)
861  enccfg.rc_2pass_vbr_minsection_pct =
862  avctx->rc_min_rate * 100LL / avctx->bit_rate;
863  if (ctx->maxsection_pct >= 0)
864  enccfg.rc_2pass_vbr_maxsection_pct = ctx->maxsection_pct;
865  else if (avctx->rc_max_rate)
866  enccfg.rc_2pass_vbr_maxsection_pct =
867  avctx->rc_max_rate * 100LL / avctx->bit_rate;
868 
869  if (avctx->rc_buffer_size)
870  enccfg.rc_buf_sz =
871  avctx->rc_buffer_size * 1000LL / avctx->bit_rate;
872  if (avctx->rc_initial_buffer_occupancy)
873  enccfg.rc_buf_initial_sz =
874  avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate;
875  enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
876 
877  if (ctx->rc_undershoot_pct >= 0)
878  enccfg.rc_undershoot_pct = ctx->rc_undershoot_pct;
879  if (ctx->rc_overshoot_pct >= 0)
880  enccfg.rc_overshoot_pct = ctx->rc_overshoot_pct;
881 
882  // _enc_init() will balk if kf_min_dist differs from max w/AOM_KF_AUTO
883  if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size)
884  enccfg.kf_min_dist = avctx->keyint_min;
885  if (avctx->gop_size >= 0)
886  enccfg.kf_max_dist = avctx->gop_size;
887 
888  if (enccfg.g_pass == AOM_RC_FIRST_PASS)
889  enccfg.g_lag_in_frames = 0;
890  else if (enccfg.g_pass == AOM_RC_LAST_PASS) {
891  int decode_size, ret;
892 
893  if (!avctx->stats_in) {
894  av_log(avctx, AV_LOG_ERROR, "No stats file for second pass\n");
895  return AVERROR_INVALIDDATA;
896  }
897 
898  ctx->twopass_stats.sz = strlen(avctx->stats_in) * 3 / 4;
899  ret = av_reallocp(&ctx->twopass_stats.buf, ctx->twopass_stats.sz);
900  if (ret < 0) {
901  av_log(avctx, AV_LOG_ERROR,
902  "Stat buffer alloc (%"SIZE_SPECIFIER" bytes) failed\n",
903  ctx->twopass_stats.sz);
904  ctx->twopass_stats.sz = 0;
905  return ret;
906  }
907  decode_size = av_base64_decode(ctx->twopass_stats.buf, avctx->stats_in,
908  ctx->twopass_stats.sz);
909  if (decode_size < 0) {
910  av_log(avctx, AV_LOG_ERROR, "Stat buffer decode failed\n");
911  return AVERROR_INVALIDDATA;
912  }
913 
914  ctx->twopass_stats.sz = decode_size;
915  enccfg.rc_twopass_stats_in = ctx->twopass_stats;
916  }
917 
918  /* 0-3: For non-zero values the encoder increasingly optimizes for reduced
919  * complexity playback on low powered devices at the expense of encode
920  * quality. */
921  if (avctx->profile != AV_PROFILE_UNKNOWN)
922  enccfg.g_profile = avctx->profile;
923 
924  enccfg.g_error_resilient = ctx->error_resilient;
925 
926  res = choose_tiling(avctx, &enccfg);
927  if (res < 0)
928  return res;
929 
930  if (ctx->still_picture) {
931  // Set the maximum number of frames to 1. This will let libaom set
932  // still_picture and reduced_still_picture_header to 1 in the Sequence
933  // Header as required by AVIF still images.
934  enccfg.g_limit = 1;
935  // Reduce memory usage for still images.
936  enccfg.g_lag_in_frames = 0;
937  // All frames will be key frames.
938  enccfg.kf_max_dist = 0;
939  enccfg.kf_mode = AOM_KF_DISABLED;
940  }
941 
942  /* Construct Encoder Context */
943  res = aom_codec_enc_init(&ctx->encoder, iface, &enccfg, flags);
944  if (res != AOM_CODEC_OK) {
945  dump_enc_cfg(avctx, &enccfg, AV_LOG_WARNING);
946  log_encoder_error(avctx, "Failed to initialize encoder");
947  return AVERROR(EINVAL);
948  }
949  dump_enc_cfg(avctx, &enccfg, AV_LOG_DEBUG);
950 
951  // codec control failures are currently treated only as warnings
952  av_log(avctx, AV_LOG_DEBUG, "aom_codec_control\n");
953  codecctl_int(avctx, AOME_SET_CPUUSED, ctx->cpu_used);
954 
955  for (size_t i = 0; i < FF_ARRAY_ELEMS(option_map); ++i) {
956  int val = *(int*)((char*)ctx + option_map[i].offset);
957  if (val >= 0)
959  }
960  codecctl_int(avctx, AOME_SET_STATIC_THRESHOLD, ctx->static_thresh);
961  if (ctx->crf >= 0)
962  codecctl_int(avctx, AOME_SET_CQ_LEVEL, ctx->crf);
963  if (ctx->tune >= 0)
964  codecctl_int(avctx, AOME_SET_TUNING, ctx->tune);
965 
966  if (desc->flags & AV_PIX_FMT_FLAG_RGB) {
967  codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, AVCOL_PRI_BT709);
968  codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, AVCOL_SPC_RGB);
969  codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, AVCOL_TRC_IEC61966_2_1);
970  } else {
971  codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, avctx->color_primaries);
972  codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, avctx->colorspace);
973  codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, avctx->color_trc);
974  }
975  if (ctx->aq_mode >= 0)
976  codecctl_int(avctx, AV1E_SET_AQ_MODE, ctx->aq_mode);
977  if (ctx->frame_parallel >= 0)
978  codecctl_int(avctx, AV1E_SET_FRAME_PARALLEL_DECODING, ctx->frame_parallel);
979  set_color_range(avctx);
980 
981  codecctl_int(avctx, AV1E_SET_SUPERBLOCK_SIZE, ctx->superblock_size);
982  if (ctx->uniform_tiles) {
983  codecctl_int(avctx, AV1E_SET_TILE_COLUMNS, ctx->tile_cols_log2);
984  codecctl_int(avctx, AV1E_SET_TILE_ROWS, ctx->tile_rows_log2);
985  }
986 
987  if (ctx->denoise_noise_level >= 0)
988  codecctl_int(avctx, AV1E_SET_DENOISE_NOISE_LEVEL, ctx->denoise_noise_level);
989  if (ctx->denoise_block_size >= 0)
990  codecctl_int(avctx, AV1E_SET_DENOISE_BLOCK_SIZE, ctx->denoise_block_size);
991  if (ctx->enable_global_motion >= 0)
992  codecctl_int(avctx, AV1E_SET_ENABLE_GLOBAL_MOTION, ctx->enable_global_motion);
993  if (avctx->refs >= 3) {
994  codecctl_int(avctx, AV1E_SET_MAX_REFERENCE_FRAMES, avctx->refs);
995  }
996  if (ctx->row_mt >= 0)
997  codecctl_int(avctx, AV1E_SET_ROW_MT, ctx->row_mt);
998  if (ctx->enable_intrabc >= 0)
999  codecctl_int(avctx, AV1E_SET_ENABLE_INTRABC, ctx->enable_intrabc);
1000 
1001 #if AOM_ENCODER_ABI_VERSION >= 23
1002  {
1003  const AVDictionaryEntry *en = NULL;
1004 
1005  while ((en = av_dict_iterate(ctx->aom_params, en))) {
1006  int ret = aom_codec_set_option(&ctx->encoder, en->key, en->value);
1007  if (ret != AOM_CODEC_OK) {
1008  log_encoder_error(avctx, en->key);
1009  return AVERROR_EXTERNAL;
1010  }
1011  }
1012  }
1013 #endif
1014 
1015  // provide dummy value to initialize wrapper, values will be updated each _encode()
1016  aom_img_wrap(&ctx->rawimg, img_fmt, avctx->width, avctx->height, 1,
1017  (unsigned char*)1);
1018 
1019  if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH)
1020  ctx->rawimg.bit_depth = enccfg.g_bit_depth;
1021 
1022  ctx->dovi.logctx = avctx;
1023  if ((res = ff_dovi_configure(&ctx->dovi, avctx)) < 0)
1024  return res;
1025 
1026  if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
1027  const AVBitStreamFilter *filter = av_bsf_get_by_name("extract_extradata");
1028  int ret;
1029 
1030  if (!filter) {
1031  av_log(avctx, AV_LOG_ERROR, "extract_extradata bitstream filter "
1032  "not found. This is a bug, please report it.\n");
1033  return AVERROR_BUG;
1034  }
1035  ret = av_bsf_alloc(filter, &ctx->bsf);
1036  if (ret < 0)
1037  return ret;
1038 
1039  ret = avcodec_parameters_from_context(ctx->bsf->par_in, avctx);
1040  if (ret < 0)
1041  return ret;
1042 
1043  ret = av_bsf_init(ctx->bsf);
1044  if (ret < 0)
1045  return ret;
1046  }
1047 
1048  AVCPBProperties *cpb_props = ff_encode_add_cpb_side_data(avctx);
1049  if (!cpb_props)
1050  return AVERROR(ENOMEM);
1051 
1052  if (enccfg.rc_end_usage == AOM_CBR ||
1053  enccfg.g_pass != AOM_RC_ONE_PASS) {
1054  cpb_props->max_bitrate = avctx->rc_max_rate;
1055  cpb_props->min_bitrate = avctx->rc_min_rate;
1056  cpb_props->avg_bitrate = avctx->bit_rate;
1057  }
1058  cpb_props->buffer_size = avctx->rc_buffer_size;
1059 
1060  return 0;
1061 }
1062 
1063 static inline void cx_pktcpy(AOMContext *ctx,
1064  struct FrameListData *dst,
1065  const struct aom_codec_cx_pkt *src)
1066 {
1067  dst->pts = src->data.frame.pts;
1068  dst->duration = src->data.frame.duration;
1069  dst->flags = src->data.frame.flags;
1070  dst->sz = src->data.frame.sz;
1071  dst->buf = src->data.frame.buf;
1072  dst->frame_number = ++ctx->frame_number;
1073  dst->have_sse = ctx->have_sse;
1074  if (ctx->have_sse) {
1075  /* associate last-seen SSE to the frame. */
1076  /* Transfers ownership from ctx to dst. */
1077  memcpy(dst->sse, ctx->sse, sizeof(dst->sse));
1078  ctx->have_sse = 0;
1079  }
1080 }
1081 
1082 /**
1083  * Store coded frame information in format suitable for return from encode2().
1084  *
1085  * Write information from @a cx_frame to @a pkt
1086  * @return packet data size on success
1087  * @return a negative AVERROR on error
1088  */
1089 static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame,
1090  AVPacket *pkt)
1091 {
1092  AOMContext *ctx = avctx->priv_data;
1093  int av_unused pict_type;
1094  int ret = ff_get_encode_buffer(avctx, pkt, cx_frame->sz, 0);
1095  if (ret < 0) {
1096  av_log(avctx, AV_LOG_ERROR,
1097  "Error getting output packet of size %"SIZE_SPECIFIER".\n", cx_frame->sz);
1098  return ret;
1099  }
1100  memcpy(pkt->data, cx_frame->buf, pkt->size);
1101  pkt->pts = pkt->dts = cx_frame->pts;
1102  pkt->duration = cx_frame->duration;
1103 
1104  if (!!(cx_frame->flags & AOM_FRAME_IS_KEY)) {
1106  pict_type = AV_PICTURE_TYPE_I;
1107  } else if (cx_frame->flags & AOM_FRAME_IS_INTRAONLY) {
1108  pict_type = AV_PICTURE_TYPE_I;
1109  } else {
1110  pict_type = AV_PICTURE_TYPE_P;
1111  }
1112 
1113  ff_side_data_set_encoder_stats(pkt, 0, cx_frame->sse + 1,
1114  cx_frame->have_sse ? 3 : 0, pict_type);
1115 
1116  if (cx_frame->have_sse) {
1117  int i;
1118  for (i = 0; i < 3; ++i) {
1119  avctx->error[i] += cx_frame->sse[i + 1];
1120  }
1121  cx_frame->have_sse = 0;
1122  }
1123 
1124  if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
1125  ret = av_bsf_send_packet(ctx->bsf, pkt);
1126  if (ret < 0) {
1127  av_log(avctx, AV_LOG_ERROR, "extract_extradata filter "
1128  "failed to send input packet\n");
1129  return ret;
1130  }
1131  ret = av_bsf_receive_packet(ctx->bsf, pkt);
1132 
1133  if (ret < 0) {
1134  av_log(avctx, AV_LOG_ERROR, "extract_extradata filter "
1135  "failed to receive output packet\n");
1136  return ret;
1137  }
1138  }
1139  return pkt->size;
1140 }
1141 
1142 /**
1143  * Queue multiple output frames from the encoder, returning the front-most.
1144  * In cases where aom_codec_get_cx_data() returns more than 1 frame append
1145  * the frame queue. Return the head frame if available.
1146  * @return Stored frame size
1147  * @return AVERROR(EINVAL) on output size error
1148  * @return AVERROR(ENOMEM) on coded frame queue data allocation error
1149  */
1150 static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out)
1151 {
1152  AOMContext *ctx = avctx->priv_data;
1153  const struct aom_codec_cx_pkt *pkt;
1154  const void *iter = NULL;
1155  int size = 0;
1156 
1157  if (ctx->coded_frame_list) {
1158  struct FrameListData *cx_frame = ctx->coded_frame_list;
1159  /* return the leading frame if we've already begun queueing */
1160  size = storeframe(avctx, cx_frame, pkt_out);
1161  if (size < 0)
1162  return size;
1163  ctx->coded_frame_list = cx_frame->next;
1164  free_coded_frame(cx_frame);
1165  }
1166 
1167  /* consume all available output from the encoder before returning. buffers
1168  * are only good through the next aom_codec call */
1169  while ((pkt = aom_codec_get_cx_data(&ctx->encoder, &iter))) {
1170  switch (pkt->kind) {
1171  case AOM_CODEC_CX_FRAME_PKT:
1172  if (!size) {
1173  struct FrameListData cx_frame;
1174 
1175  /* avoid storing the frame when the list is empty and we haven't yet
1176  * provided a frame for output */
1177  av_assert0(!ctx->coded_frame_list);
1178  cx_pktcpy(ctx, &cx_frame, pkt);
1179  size = storeframe(avctx, &cx_frame, pkt_out);
1180  if (size < 0)
1181  return size;
1182  } else {
1183  struct FrameListData *cx_frame =
1184  av_malloc(sizeof(struct FrameListData));
1185 
1186  if (!cx_frame) {
1187  av_log(avctx, AV_LOG_ERROR,
1188  "Frame queue element alloc failed\n");
1189  return AVERROR(ENOMEM);
1190  }
1191  cx_pktcpy(ctx, cx_frame, pkt);
1192  cx_frame->buf = av_malloc(cx_frame->sz);
1193 
1194  if (!cx_frame->buf) {
1195  av_log(avctx, AV_LOG_ERROR,
1196  "Data buffer alloc (%"SIZE_SPECIFIER" bytes) failed\n",
1197  cx_frame->sz);
1198  av_freep(&cx_frame);
1199  return AVERROR(ENOMEM);
1200  }
1201  memcpy(cx_frame->buf, pkt->data.frame.buf, pkt->data.frame.sz);
1202  coded_frame_add(&ctx->coded_frame_list, cx_frame);
1203  }
1204  break;
1205  case AOM_CODEC_STATS_PKT:
1206  {
1207  struct aom_fixed_buf *stats = &ctx->twopass_stats;
1208  uint8_t *tmp = av_fast_realloc(stats->buf,
1209  &ctx->twopass_stats_size,
1210  stats->sz +
1211  pkt->data.twopass_stats.sz);
1212  if (!tmp) {
1213  av_freep(&stats->buf);
1214  stats->sz = 0;
1215  av_log(avctx, AV_LOG_ERROR, "Stat buffer realloc failed\n");
1216  return AVERROR(ENOMEM);
1217  }
1218  stats->buf = tmp;
1219  memcpy((uint8_t *)stats->buf + stats->sz,
1220  pkt->data.twopass_stats.buf, pkt->data.twopass_stats.sz);
1221  stats->sz += pkt->data.twopass_stats.sz;
1222  break;
1223  }
1224  case AOM_CODEC_PSNR_PKT:
1225  {
1226  av_assert0(!ctx->have_sse);
1227  ctx->sse[0] = pkt->data.psnr.sse[0];
1228  ctx->sse[1] = pkt->data.psnr.sse[1];
1229  ctx->sse[2] = pkt->data.psnr.sse[2];
1230  ctx->sse[3] = pkt->data.psnr.sse[3];
1231  ctx->have_sse = 1;
1232  break;
1233  }
1234  case AOM_CODEC_CUSTOM_PKT:
1235  // ignore unsupported/unrecognized packet types
1236  break;
1237  }
1238  }
1239 
1240  return size;
1241 }
1242 
1243 static enum AVPixelFormat aomfmt_to_pixfmt(struct aom_image *img)
1244 {
1245  switch (img->fmt) {
1246  case AOM_IMG_FMT_I420:
1247  case AOM_IMG_FMT_I42016:
1248  if (img->bit_depth == 8)
1249  return img->monochrome ? AV_PIX_FMT_GRAY8 : AV_PIX_FMT_YUV420P;
1250  else if (img->bit_depth == 10)
1251  return img->monochrome ? AV_PIX_FMT_GRAY10 : AV_PIX_FMT_YUV420P10;
1252  else
1253  return img->monochrome ? AV_PIX_FMT_GRAY12 : AV_PIX_FMT_YUV420P12;
1254  case AOM_IMG_FMT_I422:
1255  case AOM_IMG_FMT_I42216:
1256  if (img->bit_depth == 8)
1257  return AV_PIX_FMT_YUV422P;
1258  else if (img->bit_depth == 10)
1259  return AV_PIX_FMT_YUV422P10;
1260  else
1261  return AV_PIX_FMT_YUV422P12;
1262  case AOM_IMG_FMT_I444:
1263  case AOM_IMG_FMT_I44416:
1264  if (img->bit_depth == 8)
1265  return AV_PIX_FMT_YUV444P;
1266  else if (img->bit_depth == 10)
1267  return AV_PIX_FMT_YUV444P10;
1268  else
1269  return AV_PIX_FMT_YUV444P12;
1270  };
1271  return AV_PIX_FMT_NONE;
1272 }
1273 
1275  const AVFrame *frame, int *got_packet)
1276 {
1277  AOMContext *ctx = avctx->priv_data;
1278  struct aom_image *rawimg = NULL;
1279  int64_t timestamp = 0;
1280  unsigned long duration = 0;
1281  int res, coded_size;
1282  aom_enc_frame_flags_t flags = 0;
1283  AVFrameSideData *sd;
1284 
1285  if (frame) {
1286  rawimg = &ctx->rawimg;
1287  aom_img_remove_metadata(rawimg);
1288  rawimg->planes[AOM_PLANE_Y] = frame->data[0];
1289  rawimg->planes[AOM_PLANE_U] = frame->data[1];
1290  rawimg->planes[AOM_PLANE_V] = frame->data[2];
1291  rawimg->stride[AOM_PLANE_Y] = frame->linesize[0];
1292  rawimg->stride[AOM_PLANE_U] = frame->linesize[1];
1293  rawimg->stride[AOM_PLANE_V] = frame->linesize[2];
1294  timestamp = frame->pts;
1295 
1296  if (frame->duration > ULONG_MAX) {
1297  av_log(avctx, AV_LOG_WARNING,
1298  "Frame duration too large: %"PRId64"\n", frame->duration);
1299  } else if (frame->duration)
1300  duration = frame->duration;
1301  else if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
1302  duration = av_rescale_q(1, av_inv_q(avctx->framerate), avctx->time_base);
1303  else {
1304  duration = 1;
1305  }
1306 
1307  switch (frame->color_range) {
1308  case AVCOL_RANGE_MPEG:
1309  rawimg->range = AOM_CR_STUDIO_RANGE;
1310  break;
1311  case AVCOL_RANGE_JPEG:
1312  rawimg->range = AOM_CR_FULL_RANGE;
1313  break;
1314  }
1315 
1316  aom_img_remove_metadata(rawimg);
1318  if (ctx->dovi.cfg.dv_profile && sd) {
1319  const AVDOVIMetadata *metadata = (const AVDOVIMetadata *)sd->data;
1320  uint8_t *t35;
1321  int size;
1323  &t35, &size)) < 0)
1324  return res;
1325  res = aom_img_add_metadata(rawimg, OBU_METADATA_TYPE_ITUT_T35,
1326  t35, size, AOM_MIF_ANY_FRAME);
1327  av_free(t35);
1328  if (res != AOM_CODEC_OK)
1329  return AVERROR(ENOMEM);
1330  } else if (ctx->dovi.cfg.dv_profile) {
1331  av_log(avctx, AV_LOG_ERROR, "Dolby Vision enabled, but received frame "
1332  "without AV_FRAME_DATA_DOVI_METADATA\n");
1333  return AVERROR_INVALIDDATA;
1334  }
1335 
1336  if (frame->pict_type == AV_PICTURE_TYPE_I)
1337  flags |= AOM_EFLAG_FORCE_KF;
1338 
1339  res = add_hdr_plus(avctx, rawimg, frame);
1340  if (res < 0)
1341  return res;
1342  }
1343 
1344  res = aom_codec_encode(&ctx->encoder, rawimg, timestamp, duration, flags);
1345  if (res != AOM_CODEC_OK) {
1346  log_encoder_error(avctx, "Error encoding frame");
1347  return AVERROR_INVALIDDATA;
1348  }
1349  coded_size = queue_frames(avctx, pkt);
1350  if (coded_size < 0)
1351  return coded_size;
1352 
1353  if (!frame && avctx->flags & AV_CODEC_FLAG_PASS1) {
1354  size_t b64_size = AV_BASE64_SIZE(ctx->twopass_stats.sz);
1355 
1356  avctx->stats_out = av_malloc(b64_size);
1357  if (!avctx->stats_out) {
1358  av_log(avctx, AV_LOG_ERROR, "Stat buffer alloc (%"SIZE_SPECIFIER" bytes) failed\n",
1359  b64_size);
1360  return AVERROR(ENOMEM);
1361  }
1362  av_base64_encode(avctx->stats_out, b64_size, ctx->twopass_stats.buf,
1363  ctx->twopass_stats.sz);
1364  }
1365 
1366  *got_packet = !!coded_size;
1367 
1368  if (*got_packet && avctx->flags & AV_CODEC_FLAG_RECON_FRAME) {
1369  AVCodecInternal *avci = avctx->internal;
1370  struct aom_image img;
1371 
1372  av_frame_unref(avci->recon_frame);
1373 
1374  res = codecctl_imgp(avctx, AV1_GET_NEW_FRAME_IMAGE, &img);
1375  if (res < 0)
1376  return res;
1377 
1379  if (avci->recon_frame->format == AV_PIX_FMT_NONE) {
1381  "Unhandled reconstructed frame colorspace: %d\n",
1382  img.fmt);
1383  return AVERROR(ENOSYS);
1384  }
1385 
1386  avci->recon_frame->width = img.d_w;
1387  avci->recon_frame->height = img.d_h;
1388 
1389  res = av_frame_get_buffer(avci->recon_frame, 0);
1390  if (res < 0)
1391  return res;
1392 
1393  if ((img.fmt & AOM_IMG_FMT_HIGHBITDEPTH) && img.bit_depth == 8)
1395  else {
1396  const uint8_t *planes[4] = { img.planes[0], img.planes[1], img.planes[2] };
1397  const int stride[4] = { img.stride[0], img.stride[1], img.stride[2] };
1398 
1400  stride, avci->recon_frame->format, img.d_w, img.d_h);
1401  }
1402  }
1403 
1404  return 0;
1405 }
1406 
1407 static const enum AVPixelFormat av1_pix_fmts[] = {
1413 };
1414 
1415 static const enum AVPixelFormat av1_pix_fmts_with_gray[] = {
1422 };
1423 
1424 static const enum AVPixelFormat av1_pix_fmts_highbd[] = {
1438 };
1439 
1457 };
1458 
1460  const AVCodec *codec,
1461  enum AVCodecConfig config,
1462  unsigned flags, const void **out,
1463  int *out_num)
1464 {
1466  int supports_monochrome = aom_codec_version() >= 20001;
1467  aom_codec_caps_t codec_caps = aom_codec_get_caps(aom_codec_av1_cx());
1468  if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
1469  if (supports_monochrome) {
1472  } else {
1474  *out_num = FF_ARRAY_ELEMS(av1_pix_fmts_highbd) - 1;
1475  }
1476  } else {
1477  if (supports_monochrome) {
1479  *out_num = FF_ARRAY_ELEMS(av1_pix_fmts_with_gray) - 1;
1480  } else {
1481  *out = av1_pix_fmts;
1482  *out_num = FF_ARRAY_ELEMS(av1_pix_fmts) - 1;
1483  }
1484  }
1485  return 0;
1486  }
1487 
1488  return ff_default_get_supported_config(avctx, codec, config, flags, out, out_num);
1489 }
1490 
1491 static av_cold int av1_init(AVCodecContext *avctx)
1492 {
1493  return aom_init(avctx, aom_codec_av1_cx());
1494 }
1495 
1496 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1497 static const AVOption options[] = {
1498  { "cpu-used", "Quality/Speed ratio modifier", OFFSET(cpu_used), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 8, VE},
1499  { "auto-alt-ref", "Enable use of alternate reference "
1500  "frames (2-pass only)", OFFSET(auto_alt_ref), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, VE},
1501  { "lag-in-frames", "Number of frames to look ahead at for "
1502  "alternate reference frame selection", OFFSET(lag_in_frames), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE},
1503  { "arnr-max-frames", "altref noise reduction max frame count", OFFSET(arnr_max_frames), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE},
1504  { "arnr-strength", "altref noise reduction filter strength", OFFSET(arnr_strength), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
1505  { "aq-mode", "adaptive quantization mode", OFFSET(aq_mode), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 4, VE, .unit = "aq_mode"},
1506  { "none", "Aq not used", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, VE, .unit = "aq_mode"},
1507  { "variance", "Variance based Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, .unit = "aq_mode"},
1508  { "complexity", "Complexity based Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE, .unit = "aq_mode"},
1509  { "cyclic", "Cyclic Refresh Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 0, VE, .unit = "aq_mode"},
1510  { "error-resilience", "Error resilience configuration", OFFSET(error_resilient), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, VE, .unit = "er"},
1511  { "default", "Improve resiliency against losses of whole frames", 0, AV_OPT_TYPE_CONST, {.i64 = AOM_ERROR_RESILIENT_DEFAULT}, 0, 0, VE, .unit = "er"},
1512  { "crf", "Select the quality for constant quality mode", offsetof(AOMContext, crf), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, VE },
1513  { "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 },
1514  { "drop-threshold", "Frame drop threshold", offsetof(AOMContext, drop_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE },
1515  { "denoise-noise-level", "Amount of noise to be removed", OFFSET(denoise_noise_level), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE},
1516  { "denoise-block-size", "Denoise block size ", OFFSET(denoise_block_size), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE},
1517  { "undershoot-pct", "Datarate undershoot (min) target (%)", OFFSET(rc_undershoot_pct), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 100, VE},
1518  { "overshoot-pct", "Datarate overshoot (max) target (%)", OFFSET(rc_overshoot_pct), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1000, VE},
1519  { "minsection-pct", "GOP min bitrate (% of target)", OFFSET(minsection_pct), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 100, VE},
1520  { "maxsection-pct", "GOP max bitrate (% of target)", OFFSET(maxsection_pct), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 5000, VE},
1521  { "frame-parallel", "Enable frame parallel decodability features", OFFSET(frame_parallel), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1522  { "tiles", "Tile columns x rows", OFFSET(tile_cols), AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, 0, VE },
1523  { "tile-columns", "Log2 of number of tile columns to use", OFFSET(tile_cols_log2), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
1524  { "tile-rows", "Log2 of number of tile rows to use", OFFSET(tile_rows_log2), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
1525  { "row-mt", "Enable row based multi-threading", OFFSET(row_mt), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1526  { "enable-cdef", "Enable CDEF filtering", OFFSET(enable_cdef), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1527  { "enable-global-motion", "Enable global motion", OFFSET(enable_global_motion), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1528  { "enable-intrabc", "Enable intra block copy prediction mode", OFFSET(enable_intrabc), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1529  { "enable-restoration", "Enable Loop Restoration filtering", OFFSET(enable_restoration), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1530  { "usage", "Quality and compression efficiency vs speed trade-off", OFFSET(usage), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, .unit = "usage"},
1531  { "good", "Good quality", 0, AV_OPT_TYPE_CONST, {.i64 = 0 /* AOM_USAGE_GOOD_QUALITY */}, 0, 0, VE, .unit = "usage"},
1532  { "realtime", "Realtime encoding", 0, AV_OPT_TYPE_CONST, {.i64 = 1 /* AOM_USAGE_REALTIME */}, 0, 0, VE, .unit = "usage"},
1533  { "allintra", "All Intra encoding", 0, AV_OPT_TYPE_CONST, {.i64 = 2 /* AOM_USAGE_ALL_INTRA */}, 0, 0, VE, .unit = "usage"},
1534  { "tune", "The metric that the encoder tunes for. Automatically chosen by the encoder by default", OFFSET(tune), AV_OPT_TYPE_INT, {.i64 = -1}, -1, AOM_TUNE_SSIM, VE, .unit = "tune"},
1535  { "psnr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AOM_TUNE_PSNR}, 0, 0, VE, .unit = "tune"},
1536  { "ssim", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AOM_TUNE_SSIM}, 0, 0, VE, .unit = "tune"},
1538  { "still-picture", "Encode in single frame mode (typically used for still AVIF images).", OFFSET(still_picture), AV_OPT_TYPE_BOOL, {.i64 = 0}, -1, 1, VE },
1539  { "dolbyvision", "Enable Dolby Vision RPU coding", OFFSET(dovi.enable), AV_OPT_TYPE_BOOL, {.i64 = FF_DOVI_AUTOMATIC }, -1, 1, VE, .unit = "dovi" },
1540  { "auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DOVI_AUTOMATIC}, .flags = VE, .unit = "dovi" },
1541  { "enable-rect-partitions", "Enable rectangular partitions", OFFSET(enable_rect_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1542  { "enable-1to4-partitions", "Enable 1:4/4:1 partitions", OFFSET(enable_1to4_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1543  { "enable-ab-partitions", "Enable ab shape partitions", OFFSET(enable_ab_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1544  { "enable-angle-delta", "Enable angle delta intra prediction", OFFSET(enable_angle_delta), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1545  { "enable-cfl-intra", "Enable chroma predicted from luma intra prediction", OFFSET(enable_cfl_intra), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1546  { "enable-filter-intra", "Enable filter intra predictor", OFFSET(enable_filter_intra), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1547  { "enable-intra-edge-filter", "Enable intra edge filter", OFFSET(enable_intra_edge_filter), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1548  { "enable-smooth-intra", "Enable smooth intra prediction mode", OFFSET(enable_smooth_intra), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1549  { "enable-paeth-intra", "Enable paeth predictor in intra prediction", OFFSET(enable_paeth_intra), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1550  { "enable-palette", "Enable palette prediction mode", OFFSET(enable_palette), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1551  { "enable-flip-idtx", "Enable extended transform type", OFFSET(enable_flip_idtx), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1552  { "enable-tx64", "Enable 64-pt transform", OFFSET(enable_tx64), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1553  { "reduced-tx-type-set", "Use reduced set of transform types", OFFSET(reduced_tx_type_set), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1554  { "use-intra-dct-only", "Use DCT only for INTRA modes", OFFSET(use_intra_dct_only), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1555  { "use-inter-dct-only", "Use DCT only for INTER modes", OFFSET(use_inter_dct_only), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1556  { "use-intra-default-tx-only", "Use default-transform only for INTRA modes", OFFSET(use_intra_default_tx_only), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1557  { "enable-ref-frame-mvs", "Enable temporal mv prediction", OFFSET(enable_ref_frame_mvs), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1558  { "enable-reduced-reference-set", "Use reduced set of single and compound references", OFFSET(enable_reduced_reference_set), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1559  { "enable-obmc", "Enable obmc", OFFSET(enable_obmc), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1560  { "enable-dual-filter", "Enable dual filter", OFFSET(enable_dual_filter), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1561  { "enable-diff-wtd-comp", "Enable difference-weighted compound", OFFSET(enable_diff_wtd_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1562  { "enable-dist-wtd-comp", "Enable distance-weighted compound", OFFSET(enable_dist_wtd_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1563  { "enable-onesided-comp", "Enable one sided compound", OFFSET(enable_onesided_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1564  { "enable-interinter-wedge", "Enable interinter wedge compound", OFFSET(enable_interinter_wedge), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1565  { "enable-interintra-wedge", "Enable interintra wedge compound", OFFSET(enable_interintra_wedge), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1566  { "enable-masked-comp", "Enable masked compound", OFFSET(enable_masked_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1567  { "enable-interintra-comp", "Enable interintra compound", OFFSET(enable_interintra_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1568  { "enable-smooth-interintra", "Enable smooth interintra mode", OFFSET(enable_smooth_interintra), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1569 #if AOM_ENCODER_ABI_VERSION >= 23
1570  { "aom-params", "Set libaom options using a :-separated list of key=value pairs", OFFSET(aom_params), AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE },
1571 #endif
1572  { NULL },
1573 };
1574 
1575 static const FFCodecDefault defaults[] = {
1576  { "b", "0" },
1577  { "qmin", "-1" },
1578  { "qmax", "-1" },
1579  { "g", "-1" },
1580  { "keyint_min", "-1" },
1581  { NULL },
1582 };
1583 
1584 static const AVClass class_aom = {
1585  .class_name = "libaom-av1 encoder",
1586  .item_name = av_default_item_name,
1587  .option = options,
1588  .version = LIBAVUTIL_VERSION_INT,
1589 };
1590 
1592  .p.name = "libaom-av1",
1593  CODEC_LONG_NAME("libaom AV1"),
1594  .p.type = AVMEDIA_TYPE_VIDEO,
1595  .p.id = AV_CODEC_ID_AV1,
1596  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
1599  .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG,
1600  .p.profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles),
1601  .p.priv_class = &class_aom,
1602  .p.wrapper_name = "libaom",
1603  .priv_data_size = sizeof(AOMContext),
1604  .init = av1_init,
1606  .close = aom_free,
1607  .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE |
1610  .defaults = defaults,
1611  .get_supported_config = av1_get_supported_config,
1612 };
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:32
flags
const SwsFlags flags[]
Definition: swscale.c:61
AOMEncoderContext::error_resilient
int error_resilient
Definition: libaomenc.c:89
AOMEncoderContext::usage
int usage
Definition: libaomenc.c:112
AVCodec
AVCodec.
Definition: codec.h:172
dump_enc_cfg
static av_cold void dump_enc_cfg(AVCodecContext *avctx, const struct aom_codec_enc_cfg *cfg, int level)
Definition: libaomenc.c:222
AOMEncoderContext::enable_filter_intra
int enable_filter_intra
Definition: libaomenc.c:124
AOMEncoderContext::enable_paeth_intra
int enable_paeth_intra
Definition: libaomenc.c:120
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:216
AOMEncoderContext::tile_rows_log2
int tile_rows_log2
Definition: libaomenc.c:104
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
AOMEncoderContext::enable_interintra_comp
int enable_interintra_comp
Definition: libaomenc.c:134
level
uint8_t level
Definition: svq3.c:208
FrameListData::pts
int64_t pts
time stamp to show frame (in timebase units)
Definition: libaomenc.c:63
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
AVCodecContext::keyint_min
int keyint_min
minimum GOP size
Definition: avcodec.h:998
AOMEncoderContext::sse
uint64_t sse[4]
Definition: libaomenc.c:95
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
set_color_range
static void set_color_range(AVCodecContext *avctx)
Definition: libaomenc.c:549
ff_dovi_ctx_unref
void ff_dovi_ctx_unref(DOVIContext *s)
Completely reset a DOVIContext, preserving only logctx.
Definition: dovi_rpu.c:29
AVCodecContext::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:659
out
FILE * out
Definition: movenc.c:55
av_frame_get_buffer
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
Definition: frame.c:206
av_frame_get_side_data
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition: frame.c:659
AVCodecContext::rc_min_rate
int64_t rc_min_rate
minimum bitrate
Definition: avcodec.h:1277
defaults
static const FFCodecDefault defaults[]
Definition: libaomenc.c:1575
aom_init
static av_cold int aom_init(AVCodecContext *avctx, const struct aom_codec_iface *iface)
Definition: libaomenc.c:768
AOMEncoderContext::enable_restoration
int enable_restoration
Definition: libaomenc.c:111
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3447
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
AOMEncoderContext::enable_smooth_intra
int enable_smooth_intra
Definition: libaomenc.c:121
AOMEncoderContext::enable_1to4_partitions
int enable_1to4_partitions
Definition: libaomenc.c:116
AV_FRAME_DATA_DOVI_METADATA
@ AV_FRAME_DATA_DOVI_METADATA
Parsed Dolby Vision metadata, suitable for passing to a software implementation.
Definition: frame.h:208
int64_t
long long int64_t
Definition: coverity.c:34
metadata
Stream codec metadata
Definition: ogg-flac-chained-meta.txt:2
FF_AV1_PROFILE_OPTS
#define FF_AV1_PROFILE_OPTS
Definition: profiles.h:56
AV_CODEC_CAP_ENCODER_RECON_FRAME
#define AV_CODEC_CAP_ENCODER_RECON_FRAME
The encoder is able to output reconstructed frame data, i.e.
Definition: codec.h:159
AOMEncoderContext::denoise_noise_level
int denoise_noise_level
Definition: libaomenc.c:93
av_unused
#define av_unused
Definition: attributes.h:131
AOMEncoderContext::still_picture
int still_picture
Definition: libaomenc.c:114
AOMEncoderContext::lag_in_frames
int lag_in_frames
Definition: libaomenc.c:88
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:427
pixdesc.h
AVFrameSideData::buf
AVBufferRef * buf
Definition: frame.h:287
AVCodecContext::color_trc
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:652
AVFrame::width
int width
Definition: frame.h:499
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:767
coded_frame_add
static void coded_frame_add(void *list, struct FrameListData *cx_frame)
Definition: libaomenc.c:280
internal.h
av_dynamic_hdr_plus_to_t35
int av_dynamic_hdr_plus_to_t35(const AVDynamicHDRPlus *s, uint8_t **data, size_t *size)
Serialize dynamic HDR10+ metadata to a user data registered ITU-T T.35 buffer, excluding the first 48...
Definition: hdr_dynamic_metadata.c:239
AVPacket::data
uint8_t * data
Definition: packet.h:558
AOMEncoderContext::frame_number
uint64_t frame_number
Definition: libaomenc.c:97
AVOption
AVOption.
Definition: opt.h:429
encode.h
AOMEncoderContext::use_intra_default_tx_only
int use_intra_default_tx_only
Definition: libaomenc.c:130
cx_pktcpy
static void cx_pktcpy(AOMContext *ctx, struct FrameListData *dst, const struct aom_codec_cx_pkt *src)
Definition: libaomenc.c:1063
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:539
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
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:226
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:691
filter
void(* filter)(uint8_t *src, int stride, int qscale)
Definition: h263dsp.c:29
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:576
mathematics.h
AVDictionary
Definition: dict.c:32
AV_CODEC_FLAG_PSNR
#define AV_CODEC_FLAG_PSNR
error[?] variables will be set during encoding.
Definition: avcodec.h:306
AV_CODEC_CONFIG_PIX_FORMAT
@ AV_CODEC_CONFIG_PIX_FORMAT
AVPixelFormat, terminated by AV_PIX_FMT_NONE.
Definition: avcodec.h:2531
AOMEncoderContext::aom_params
AVDictionary * aom_params
Definition: libaomenc.c:143
AV_PROFILE_AV1_PROFESSIONAL
#define AV_PROFILE_AV1_PROFESSIONAL
Definition: defs.h:171
AVCodecContext::qmax
int qmax
maximum quantizer
Definition: avcodec.h:1241
options
static const AVOption options[]
Definition: libaomenc.c:1497
av_bsf_free
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
Definition: bsf.c:52
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:613
AOMEncoderContext::twopass_stats_size
unsigned twopass_stats_size
Definition: libaomenc.c:81
AVBSFContext
The bitstream filter state.
Definition: bsf.h:68
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:448
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
AV_CODEC_FLAG_GLOBAL_HEADER
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
Definition: avcodec.h:318
FF_DOVI_WRAP_T35
@ FF_DOVI_WRAP_T35
wrap inside T.35+EMDF
Definition: dovi_rpu.h:160
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:1089
AVCodecContext::framerate
AVRational framerate
Definition: avcodec.h:551
FrameListData::flags
uint32_t flags
flags for this frame
Definition: libaomenc.c:67
AOMEncoderContext::cpu_used
int cpu_used
Definition: libaomenc.c:83
FFCodecDefault
Definition: codec_internal.h:96
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
AVCOL_TRC_IEC61966_2_1
@ AVCOL_TRC_IEC61966_2_1
IEC 61966-2-1 (sRGB or sYCC)
Definition: pixfmt.h:675
bsf.h
AOMEncoderContext::enable_ab_partitions
int enable_ab_partitions
Definition: libaomenc.c:117
DOVIContext
Definition: dovi_rpu.h:42
AOMEncoderContext::coded_frame_list
struct FrameListData * coded_frame_list
Definition: libaomenc.c:82
AOMEncoderContext::static_thresh
int static_thresh
Definition: libaomenc.c:91
AVCodecContext::thread_count
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
Definition: avcodec.h:1561
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:558
AOMEncoderContext::minsection_pct
int minsection_pct
Definition: libaomenc.c:100
AOMEncoderContext::uniform_tiles
int uniform_tiles
Definition: libaomenc.c:106
AOMEncoderContext::enable_ref_frame_mvs
int enable_ref_frame_mvs
Definition: libaomenc.c:131
AOMEncoderContext::row_mt
int row_mt
Definition: libaomenc.c:107
AVCodecContext::refs
int refs
number of reference frames
Definition: avcodec.h:689
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:488
AOMEncoderContext::denoise_block_size
int denoise_block_size
Definition: libaomenc.c:94
val
static double val(void *priv, double ch)
Definition: aeval.c:77
dovi_rpu.h
FF_CODEC_ENCODE_CB
#define FF_CODEC_ENCODE_CB(func)
Definition: codec_internal.h:358
AVRational::num
int num
Numerator.
Definition: rational.h:59
ff_dovi_configure
int ff_dovi_configure(DOVIContext *s, AVCodecContext *avctx)
Variant of ff_dovi_configure_from_codedpar which infers the codec parameters from an AVCodecContext.
Definition: dovi_rpuenc.c:260
AOMEncoderContext::use_inter_dct_only
int use_inter_dct_only
Definition: libaomenc.c:129
FF_DOVI_AUTOMATIC
#define FF_DOVI_AUTOMATIC
Enable tri-state.
Definition: dovi_rpu.h:49
ff_libaom_av1_encoder
FFCodec ff_libaom_av1_encoder
Definition: libaomenc.c:1591
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:542
free_coded_frame
static av_cold void free_coded_frame(struct FrameListData *cx_frame)
Definition: libaomenc.c:290
avassert.h
AVCodecContext::color_primaries
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:645
count_uniform_tiling
static int count_uniform_tiling(int dim, int sb_size, int tiles_log2)
Definition: libaomenc.c:565
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:210
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
AOMEncoderContext::enable_angle_delta
int enable_angle_delta
Definition: libaomenc.c:118
AV_PROFILE_UNKNOWN
#define AV_PROFILE_UNKNOWN
Definition: defs.h:65
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:1298
duration
int64_t duration
Definition: movenc.c:65
AOMEncoderContext::enable_cdef
int enable_cdef
Definition: libaomenc.c:108
AOMEncoderContext::enable_smooth_interintra
int enable_smooth_interintra
Definition: libaomenc.c:139
av_fast_realloc
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
Definition: mem.c:497
AOMEncoderContext::twopass_stats
struct aom_fixed_buf twopass_stats
Definition: libaomenc.c:80
AVDOVIMetadata
Combined struct representing a combination of header, mapping and color metadata, for attaching to fr...
Definition: dovi_meta.h:337
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:1150
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:1320
codecctl_int
static av_cold int codecctl_int(AVCodecContext *avctx, enum aome_enc_control_id id, int val)
Definition: libaomenc.c:307
AVDictionaryEntry::key
char * key
Definition: dict.h:91
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
FrameListData::sse
uint64_t sse[4]
Definition: libaomenc.c:68
AOMEncoderContext::enable_interintra_wedge
int enable_interintra_wedge
Definition: libaomenc.c:133
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:41
AOMEncoderContext::have_sse
int have_sse
true if we have pending sse[]
Definition: libaomenc.c:96
tile_cols
int tile_cols
Definition: av1_levels.c:73
AOMEncoderContext::enable_obmc
int enable_obmc
Definition: libaomenc.c:136
FrameListData::frame_number
uint64_t frame_number
Definition: libaomenc.c:70
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:231
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:483
ctx
AVFormatContext * ctx
Definition: movenc.c:49
ff_av1_profiles
const AVProfile ff_av1_profiles[]
Definition: profiles.c:163
limits.h
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_bsf_alloc
int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
Allocate a context for a given bitstream filter.
Definition: bsf.c:104
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:1270
AOMEncoderContext::superblock_size
aom_superblock_size_t superblock_size
Definition: libaomenc.c:105
AVCodecContext::error
uint64_t error[AV_NUM_DATA_POINTERS]
error
Definition: avcodec.h:1505
AV_ROUND_NEAR_INF
@ AV_ROUND_NEAR_INF
Round to nearest and halfway cases away from zero.
Definition: mathematics.h:135
AVCPBProperties
This structure describes the bitrate properties of an encoded bitstream.
Definition: defs.h:282
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:331
AOMEncoderContext::enable_dist_wtd_comp
int enable_dist_wtd_comp
Definition: libaomenc.c:141
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:519
if
if(ret)
Definition: filter_design.txt:179
AVCodecContext::rc_buffer_size
int rc_buffer_size
decoder bitstream buffer size
Definition: avcodec.h:1255
AOMEncoderContext::drop_threshold
int drop_threshold
Definition: libaomenc.c:92
AOMEncoderContext::dovi
DOVIContext dovi
Definition: libaomenc.c:77
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
av_bsf_init
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
Definition: bsf.c:149
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
AOMEncoderContext::tile_rows
int tile_rows
Definition: libaomenc.c:103
NULL
#define NULL
Definition: coverity.c:32
AOMEncoderContext
Definition: libaomenc.c:74
AOMEncoderContext::rc_overshoot_pct
int rc_overshoot_pct
Definition: libaomenc.c:99
AOMEncoderContext::enable_diff_wtd_comp
int enable_diff_wtd_comp
Definition: libaomenc.c:140
AVCodecContext::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:669
AV_CODEC_ID_AV1
@ AV_CODEC_ID_AV1
Definition: codec_id.h:284
tmp
static uint8_t tmp[20]
Definition: aes_ctr.c:47
av_bsf_receive_packet
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
Definition: bsf.c:230
ff_dovi_rpu_generate
int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata, int flags, uint8_t **out_rpu, int *out_size)
Synthesize a Dolby Vision RPU reflecting the current state.
Definition: dovi_rpuenc.c:567
AOMEncoderContext::enable_palette
int enable_palette
Definition: libaomenc.c:123
AOMEncoderContext::arnr_max_frames
int arnr_max_frames
Definition: libaomenc.c:85
AVCodecContext::internal
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:466
AVCodecContext::bit_rate
int64_t bit_rate
the average bitrate
Definition: avcodec.h:481
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition: opt.h:303
AV_OPT_TYPE_DICT
@ AV_OPT_TYPE_DICT
Underlying C type is AVDictionary*.
Definition: opt.h:290
AOMEncoderContext::enable_tx64
int enable_tx64
Definition: libaomenc.c:126
AVCOL_PRI_BT709
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
Definition: pixfmt.h:638
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:241
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:278
profiles.h
list
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 list
Definition: filter_design.txt:25
options
Definition: swscale.c:43
FrameListData::buf
void * buf
compressed data buffer
Definition: libaomenc.c:61
AV1_MAX_TILE_WIDTH
@ AV1_MAX_TILE_WIDTH
Definition: av1.h:79
AOMEncoderContext::rc_undershoot_pct
int rc_undershoot_pct
Definition: libaomenc.c:98
option_map
static const struct @168 option_map[]
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:540
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:81
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
codecctl_imgp
static av_cold int codecctl_imgp(AVCodecContext *avctx, enum aome_enc_control_id id, struct aom_image *img)
Definition: libaomenc.c:412
base64.h
stats
static void stats(AVPacket *const *in, int n_in, unsigned *_max, unsigned *_sum)
Definition: vp9_superframe.c:34
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:733
AOMEncoderContext::enable_global_motion
int enable_global_motion
Definition: libaomenc.c:109
AOMEncoderContext::encoder
struct aom_codec_ctx encoder
Definition: libaomenc.c:78
av1_init
static av_cold int av1_init(AVCodecContext *avctx)
Definition: libaomenc.c:1491
aom_enum
int aom_enum
Definition: libaomenc.c:730
AOMEncoderContext::enable_onesided_comp
int enable_onesided_comp
Definition: libaomenc.c:137
av_cpu_count
int av_cpu_count(void)
Definition: cpu.c:221
usage
const char * usage
Definition: floatimg_cmp.c:62
AVCodecContext::qcompress
float qcompress
amount of qscale change between easy & hard scenes (0.0-1.0)
Definition: avcodec.h:1226
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:535
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
FrameListData::next
struct FrameListData * next
Definition: libaomenc.c:71
AVCodecContext::stats_out
char * stats_out
pass1 encoding statistics output buffer
Definition: avcodec.h:1312
ctlidstr
static const char *const ctlidstr[]
Definition: libaomenc.c:148
av1_get_supported_config
static int av1_get_supported_config(const AVCodecContext *avctx, const AVCodec *codec, enum AVCodecConfig config, unsigned flags, const void **out, int *out_num)
Definition: libaomenc.c:1459
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
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
AVPacket::size
int size
Definition: packet.h:559
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:1005
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
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:87
AOMEncoderContext::enable_flip_idtx
int enable_flip_idtx
Definition: libaomenc.c:125
av_bsf_send_packet
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
Definition: bsf.c:202
cpu.h
offset
unsigned offset
Definition: libaomenc.c:731
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:544
size
int size
Definition: twinvq_data.h:10344
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:188
planes
static const struct @522 planes[]
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:546
AVFrameSideData::data
uint8_t * data
Definition: frame.h:284
aom_encode
static int aom_encode(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: libaomenc.c:1274
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:514
AVCPBProperties::min_bitrate
int64_t min_bitrate
Minimum bitrate of the stream, in bits per second.
Definition: defs.h:292
av1.h
FrameListData
Portion of struct vpx_codec_cx_pkt from vpx_encoder.h.
Definition: libaomenc.c:60
AOMEncoderContext::tile_cols_log2
int tile_cols_log2
Definition: libaomenc.c:104
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:557
AV_CODEC_FLAG_PASS2
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
Definition: avcodec.h:294
AOMEncoderContext::tile_cols
int tile_cols
Definition: libaomenc.c:103
img
#define img
Definition: vf_colormatrix.c:114
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:170
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:564
AVCodecInternal
Definition: internal.h:49
AOMEncoderContext::rawimg
struct aom_image rawimg
Definition: libaomenc.c:79
AVCPBProperties::avg_bitrate
int64_t avg_bitrate
Average bitrate of the stream, in bits per second.
Definition: defs.h:297
AOMEncoderContext::enable_dual_filter
int enable_dual_filter
Definition: libaomenc.c:142
AOMEncoderContext::aq_mode
int aq_mode
Definition: libaomenc.c:87
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:221
add_hdr_plus
static int add_hdr_plus(AVCodecContext *avctx, struct aom_image *img, const AVFrame *frame)
Definition: libaomenc.c:334
AOMEncoderContext::enable_cfl_intra
int enable_cfl_intra
Definition: libaomenc.c:119
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
AV_CODEC_FLAG_RECON_FRAME
#define AV_CODEC_FLAG_RECON_FRAME
Request the encoder to output reconstructed frames, i.e. frames that would be produced by decoding th...
Definition: avcodec.h:244
ff_default_get_supported_config
int ff_default_get_supported_config(const AVCodecContext *avctx, const AVCodec *codec, enum AVCodecConfig config, unsigned flags, const void **out_configs, int *out_num_configs)
Definition: avcodec.c:755
AOMEncoderContext::arnr_strength
int arnr_strength
Definition: libaomenc.c:86
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:551
round
static av_always_inline av_const double round(double x)
Definition: libm.h:446
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:559
AOMEncoderContext::enable_interinter_wedge
int enable_interinter_wedge
Definition: libaomenc.c:132
common.h
AVCPBProperties::max_bitrate
int64_t max_bitrate
Maximum bitrate of the stream, in bits per second.
Definition: defs.h:287
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:496
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:179
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
AVCodecContext::height
int height
Definition: avcodec.h:592
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:631
FrameListData::duration
unsigned long duration
duration to show frame (in timebase units)
Definition: libaomenc.c:65
AOMEncoderContext::auto_alt_ref
int auto_alt_ref
Definition: libaomenc.c:84
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:750
AVDynamicHDRPlus
This struct represents dynamic metadata for color volume transform - application 4 of SMPTE 2094-40:2...
Definition: hdr_dynamic_metadata.h:243
avcodec.h
stride
#define stride
Definition: h264pred_template.c:536
dim
int dim
Definition: vorbis_enc_data.h:425
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:81
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:265
av1_pix_fmts_with_gray
static enum AVPixelFormat av1_pix_fmts_with_gray[]
Definition: libaomenc.c:1415
AVCPBProperties::buffer_size
int64_t buffer_size
The size of the buffer to which the ratecontrol is applied, in bits.
Definition: defs.h:303
AOMEncoderContext::bsf
AVBSFContext * bsf
Definition: libaomenc.c:76
log_encoder_error
static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
Definition: libaomenc.c:211
AVCodecInternal::recon_frame
AVFrame * recon_frame
When the AV_CODEC_FLAG_RECON_FRAME flag is used.
Definition: internal.h:114
VE
#define VE
Definition: libaomenc.c:1496
AV1_MAX_TILE_COLS
@ AV1_MAX_TILE_COLS
Definition: av1.h:82
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:543
SIZE_SPECIFIER
#define SIZE_SPECIFIER
Definition: internal.h:129
free_frame_list
static av_cold void free_frame_list(struct FrameListData *list)
Definition: libaomenc.c:296
AV_FRAME_DATA_DYNAMIC_HDR_PLUS
@ AV_FRAME_DATA_DYNAMIC_HDR_PLUS
HDR dynamic metadata associated with a video frame.
Definition: frame.h:159
AVCodecContext
main external API structure.
Definition: avcodec.h:431
AVFrame::height
int height
Definition: frame.h:499
itut35.h
AOMEncoderContext::enable_rect_partitions
int enable_rect_partitions
Definition: libaomenc.c:115
AVBitStreamFilter
Definition: bsf.h:111
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
aomfmt_to_pixfmt
static enum AVPixelFormat aomfmt_to_pixfmt(struct aom_image *img)
Definition: libaomenc.c:1243
AVCodecContext::qmin
int qmin
minimum quantizer
Definition: avcodec.h:1234
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
Underlying C type is int.
Definition: opt.h:259
AVCodecContext::profile
int profile
profile
Definition: avcodec.h:1618
choose_tiling
static int choose_tiling(AVCodecContext *avctx, struct aom_codec_enc_cfg *enccfg)
Definition: libaomenc.c:573
AV1_MAX_TILE_AREA
@ AV1_MAX_TILE_AREA
Definition: av1.h:80
hdr_dynamic_metadata.h
AOMEncoderContext::maxsection_pct
int maxsection_pct
Definition: libaomenc.c:101
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:147
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
AOMEncoderContext::enable_intra_edge_filter
int enable_intra_edge_filter
Definition: libaomenc.c:122
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:78
class_aom
static const AVClass class_aom
Definition: libaomenc.c:1584
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
desc
const char * desc
Definition: libsvtav1.c:79
AV_PICTURE_TYPE_P
@ AV_PICTURE_TYPE_P
Predicted.
Definition: avutil.h:279
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:77
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
ITU_T_T35_COUNTRY_CODE_US
#define ITU_T_T35_COUNTRY_CODE_US
Definition: itut35.h:24
avcodec_parameters_from_context
int avcodec_parameters_from_context(struct AVCodecParameters *par, const AVCodecContext *codec)
Fill the parameters struct based on the values from the supplied codec context.
Definition: codec_par.c:138
AVFrameSideData
Structure to hold side data for an AVFrame.
Definition: frame.h:282
av1_pix_fmts
static enum AVPixelFormat av1_pix_fmts[]
Definition: libaomenc.c:1407
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
AOMEncoderContext::enable_reduced_reference_set
int enable_reduced_reference_set
Definition: libaomenc.c:138
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
AVDictionaryEntry
Definition: dict.h:90
ff_aom_image_copy_16_to_8
void ff_aom_image_copy_16_to_8(AVFrame *pic, struct aom_image *img)
Definition: libaom.c:27
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
AOMEncoderContext::frame_parallel
int frame_parallel
Definition: libaomenc.c:102
AVPacket
This structure stores compressed data.
Definition: packet.h:535
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
av1_pix_fmts_highbd
static enum AVPixelFormat av1_pix_fmts_highbd[]
Definition: libaomenc.c:1424
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:592
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
Definition: opt.h:255
bytestream.h
imgutils.h
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:52
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:472
AOMEncoderContext::enable_masked_comp
int enable_masked_comp
Definition: libaomenc.c:135
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
FrameListData::sz
size_t sz
length of compressed data
Definition: libaomenc.c:62
ITU_T_T35_PROVIDER_CODE_SAMSUNG
#define ITU_T_T35_PROVIDER_CODE_SAMSUNG
Definition: itut35.h:41
AOMEncoderContext::reduced_tx_type_set
int reduced_tx_type_set
Definition: libaomenc.c:127
AV1_MAX_TILE_ROWS
@ AV1_MAX_TILE_ROWS
Definition: av1.h:81
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
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: packet.c:613
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:902
AVDictionaryEntry::value
char * value
Definition: dict.h:92
width
#define width
Definition: dsp.h:89
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:520
av_image_copy
void av_image_copy(uint8_t *const dst_data[4], const int dst_linesizes[4], const uint8_t *const src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
Definition: imgutils.c:422
libaom.h
AV_PROFILE_AV1_MAIN
#define AV_PROFILE_AV1_MAIN
Definition: defs.h:169
AOMEncoderContext::enable_intrabc
int enable_intrabc
Definition: libaomenc.c:110
aom_free
static av_cold int aom_free(AVCodecContext *avctx)
Definition: libaomenc.c:437
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
snprintf
#define snprintf
Definition: snprintf.h:34
AOMEncoderContext::tune
int tune
Definition: libaomenc.c:113
av_log2
int av_log2(unsigned v)
Definition: intmath.c:26
AOMEncoderContext::crf
int crf
Definition: libaomenc.c:90
OFFSET
#define OFFSET(x)
Definition: libaomenc.c:146
AVCodecConfig
AVCodecConfig
Definition: avcodec.h:2530
av_dict_iterate
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
Definition: dict.c:42
src
#define src
Definition: vp8dsp.c:248
AOMEncoderContext::use_intra_dct_only
int use_intra_dct_only
Definition: libaomenc.c:128
AV_CODEC_FLAG_PASS1
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
Definition: avcodec.h:290
av_bsf_get_by_name
const AVBitStreamFilter * av_bsf_get_by_name(const char *name)
Definition: bitstream_filters.c:90
FrameListData::have_sse
int have_sse
true if we have pending sse[]
Definition: libaomenc.c:69
av1_pix_fmts_highbd_with_gray
static enum AVPixelFormat av1_pix_fmts_highbd_with_gray[]
Definition: libaomenc.c:1440