26 #define AOM_DISABLE_CTRL_TYPECHECKS 1 27 #include <aom/aom_encoder.h> 28 #include <aom/aomcx.h> 61 typedef struct AOMEncoderContext {
64 struct aom_codec_ctx encoder;
65 struct aom_image rawimg;
66 struct aom_fixed_buf twopass_stats;
131 [AOME_SET_CPUUSED] =
"AOME_SET_CPUUSED",
132 [AOME_SET_CQ_LEVEL] =
"AOME_SET_CQ_LEVEL",
133 [AOME_SET_ENABLEAUTOALTREF] =
"AOME_SET_ENABLEAUTOALTREF",
134 [AOME_SET_ARNR_MAXFRAMES] =
"AOME_SET_ARNR_MAXFRAMES",
135 [AOME_SET_ARNR_STRENGTH] =
"AOME_SET_ARNR_STRENGTH",
136 [AOME_SET_STATIC_THRESHOLD] =
"AOME_SET_STATIC_THRESHOLD",
137 [AV1E_SET_COLOR_RANGE] =
"AV1E_SET_COLOR_RANGE",
138 [AV1E_SET_COLOR_PRIMARIES] =
"AV1E_SET_COLOR_PRIMARIES",
139 [AV1E_SET_MATRIX_COEFFICIENTS] =
"AV1E_SET_MATRIX_COEFFICIENTS",
140 [AV1E_SET_TRANSFER_CHARACTERISTICS] =
"AV1E_SET_TRANSFER_CHARACTERISTICS",
141 [AV1E_SET_AQ_MODE] =
"AV1E_SET_AQ_MODE",
142 [AV1E_SET_FRAME_PARALLEL_DECODING] =
"AV1E_SET_FRAME_PARALLEL_DECODING",
143 [AV1E_SET_SUPERBLOCK_SIZE] =
"AV1E_SET_SUPERBLOCK_SIZE",
144 [AV1E_SET_TILE_COLUMNS] =
"AV1E_SET_TILE_COLUMNS",
145 [AV1E_SET_TILE_ROWS] =
"AV1E_SET_TILE_ROWS",
146 [AV1E_SET_ENABLE_RESTORATION] =
"AV1E_SET_ENABLE_RESTORATION",
147 #ifdef AOM_CTRL_AV1E_SET_ROW_MT 148 [AV1E_SET_ROW_MT] =
"AV1E_SET_ROW_MT",
150 #ifdef AOM_CTRL_AV1E_SET_DENOISE_NOISE_LEVEL 151 [AV1E_SET_DENOISE_NOISE_LEVEL] =
"AV1E_SET_DENOISE_NOISE_LEVEL",
153 #ifdef AOM_CTRL_AV1E_SET_DENOISE_BLOCK_SIZE 154 [AV1E_SET_DENOISE_BLOCK_SIZE] =
"AV1E_SET_DENOISE_BLOCK_SIZE",
156 #ifdef AOM_CTRL_AV1E_SET_MAX_REFERENCE_FRAMES 157 [AV1E_SET_MAX_REFERENCE_FRAMES] =
"AV1E_SET_MAX_REFERENCE_FRAMES",
159 #ifdef AOM_CTRL_AV1E_SET_ENABLE_GLOBAL_MOTION 160 [AV1E_SET_ENABLE_GLOBAL_MOTION] =
"AV1E_SET_ENABLE_GLOBAL_MOTION",
162 #ifdef AOM_CTRL_AV1E_SET_ENABLE_INTRABC 163 [AV1E_SET_ENABLE_INTRABC] =
"AV1E_SET_ENABLE_INTRABC",
165 [AV1E_SET_ENABLE_CDEF] =
"AV1E_SET_ENABLE_CDEF",
166 [AOME_SET_TUNING] =
"AOME_SET_TUNING",
167 #if AOM_ENCODER_ABI_VERSION >= 22 168 [AV1E_SET_ENABLE_1TO4_PARTITIONS] =
"AV1E_SET_ENABLE_1TO4_PARTITIONS",
169 [AV1E_SET_ENABLE_AB_PARTITIONS] =
"AV1E_SET_ENABLE_AB_PARTITIONS",
170 [AV1E_SET_ENABLE_RECT_PARTITIONS] =
"AV1E_SET_ENABLE_RECT_PARTITIONS",
171 [AV1E_SET_ENABLE_ANGLE_DELTA] =
"AV1E_SET_ENABLE_ANGLE_DELTA",
172 [AV1E_SET_ENABLE_CFL_INTRA] =
"AV1E_SET_ENABLE_CFL_INTRA",
173 [AV1E_SET_ENABLE_FILTER_INTRA] =
"AV1E_SET_ENABLE_FILTER_INTRA",
174 [AV1E_SET_ENABLE_INTRA_EDGE_FILTER] =
"AV1E_SET_ENABLE_INTRA_EDGE_FILTER",
175 [AV1E_SET_ENABLE_PAETH_INTRA] =
"AV1E_SET_ENABLE_PAETH_INTRA",
176 [AV1E_SET_ENABLE_SMOOTH_INTRA] =
"AV1E_SET_ENABLE_SMOOTH_INTRA",
177 [AV1E_SET_ENABLE_PALETTE] =
"AV1E_SET_ENABLE_PALETTE",
178 [AV1E_SET_ENABLE_FLIP_IDTX] =
"AV1E_SET_ENABLE_FLIP_IDTX",
179 [AV1E_SET_ENABLE_TX64] =
"AV1E_SET_ENABLE_TX64",
180 [AV1E_SET_INTRA_DCT_ONLY] =
"AV1E_SET_INTRA_DCT_ONLY",
181 [AV1E_SET_INTER_DCT_ONLY] =
"AV1E_SET_INTER_DCT_ONLY",
182 [AV1E_SET_INTRA_DEFAULT_TX_ONLY] =
"AV1E_SET_INTRA_DEFAULT_TX_ONLY",
183 [AV1E_SET_REDUCED_TX_TYPE_SET] =
"AV1E_SET_REDUCED_TX_TYPE_SET",
184 [AV1E_SET_ENABLE_DIFF_WTD_COMP] =
"AV1E_SET_ENABLE_DIFF_WTD_COMP",
185 [AV1E_SET_ENABLE_DIST_WTD_COMP] =
"AV1E_SET_ENABLE_DIST_WTD_COMP",
186 [AV1E_SET_ENABLE_DUAL_FILTER] =
"AV1E_SET_ENABLE_DUAL_FILTER",
187 [AV1E_SET_ENABLE_INTERINTER_WEDGE] =
"AV1E_SET_ENABLE_INTERINTER_WEDGE",
188 [AV1E_SET_ENABLE_INTERINTRA_WEDGE] =
"AV1E_SET_ENABLE_INTERINTRA_WEDGE",
189 [AV1E_SET_ENABLE_MASKED_COMP] =
"AV1E_SET_ENABLE_MASKED_COMP",
190 [AV1E_SET_ENABLE_INTERINTRA_COMP] =
"AV1E_SET_ENABLE_INTERINTRA_COMP",
191 [AV1E_SET_ENABLE_OBMC] =
"AV1E_SET_ENABLE_OBMC",
192 [AV1E_SET_ENABLE_ONESIDED_COMP] =
"AV1E_SET_ENABLE_ONESIDED_COMP",
193 [AV1E_SET_REDUCED_REFERENCE_SET] =
"AV1E_SET_REDUCED_REFERENCE_SET",
194 [AV1E_SET_ENABLE_SMOOTH_INTERINTRA] =
"AV1E_SET_ENABLE_SMOOTH_INTERINTRA",
195 [AV1E_SET_ENABLE_REF_FRAME_MVS] =
"AV1E_SET_ENABLE_REF_FRAME_MVS",
203 const char *detail = aom_codec_error_detail(&ctx->
encoder);
211 const struct aom_codec_enc_cfg *cfg)
216 av_log(avctx, level,
"aom_codec_enc_cfg\n");
217 av_log(avctx, level,
"generic settings\n" 218 " %*s%u\n %*s%u\n %*s%u\n %*s%u\n %*s%u\n" 220 " %*s{%u/%u}\n %*s%u\n %*s%d\n %*s%u\n",
221 width,
"g_usage:", cfg->g_usage,
222 width,
"g_threads:", cfg->g_threads,
223 width,
"g_profile:", cfg->g_profile,
224 width,
"g_w:", cfg->g_w,
225 width,
"g_h:", cfg->g_h,
226 width,
"g_bit_depth:", cfg->g_bit_depth,
227 width,
"g_input_bit_depth:", cfg->g_input_bit_depth,
228 width,
"g_timebase:", cfg->g_timebase.num, cfg->g_timebase.den,
229 width,
"g_error_resilient:", cfg->g_error_resilient,
230 width,
"g_pass:", cfg->g_pass,
231 width,
"g_lag_in_frames:", cfg->g_lag_in_frames);
232 av_log(avctx, level,
"rate control settings\n" 234 width,
"rc_dropframe_thresh:", cfg->rc_dropframe_thresh,
235 width,
"rc_end_usage:", cfg->rc_end_usage,
236 width,
"rc_twopass_stats_in:", cfg->rc_twopass_stats_in.buf, cfg->rc_twopass_stats_in.sz,
237 width,
"rc_target_bitrate:", cfg->rc_target_bitrate);
238 av_log(avctx, level,
"quantizer settings\n" 240 width,
"rc_min_quantizer:", cfg->rc_min_quantizer,
241 width,
"rc_max_quantizer:", cfg->rc_max_quantizer);
242 av_log(avctx, level,
"bitrate tolerance\n" 244 width,
"rc_undershoot_pct:", cfg->rc_undershoot_pct,
245 width,
"rc_overshoot_pct:", cfg->rc_overshoot_pct);
246 av_log(avctx, level,
"decoder buffer model\n" 247 " %*s%u\n %*s%u\n %*s%u\n",
248 width,
"rc_buf_sz:", cfg->rc_buf_sz,
249 width,
"rc_buf_initial_sz:", cfg->rc_buf_initial_sz,
250 width,
"rc_buf_optimal_sz:", cfg->rc_buf_optimal_sz);
251 av_log(avctx, level,
"2 pass rate control settings\n" 252 " %*s%u\n %*s%u\n %*s%u\n",
253 width,
"rc_2pass_vbr_bias_pct:", cfg->rc_2pass_vbr_bias_pct,
254 width,
"rc_2pass_vbr_minsection_pct:", cfg->rc_2pass_vbr_minsection_pct,
255 width,
"rc_2pass_vbr_maxsection_pct:", cfg->rc_2pass_vbr_maxsection_pct);
256 av_log(avctx, level,
"keyframing settings\n" 257 " %*s%d\n %*s%u\n %*s%u\n",
258 width,
"kf_mode:", cfg->kf_mode,
259 width,
"kf_min_dist:", cfg->kf_min_dist,
260 width,
"kf_max_dist:", cfg->kf_max_dist);
261 av_log(avctx, level,
"tile settings\n" 263 width,
"tile_width_count:", cfg->tile_width_count,
264 width,
"tile_height_count:", cfg->tile_height_count);
265 av_log(avctx, level,
"\n");
297 aome_enc_control_id
id,
299 enum aome_enc_control_id
id,
311 res = aom_codec_control(&ctx->
encoder,
id, val);
312 if (res != AOM_CODEC_OK) {
313 snprintf(buf,
sizeof(buf),
"Failed to set %s codec control",
326 aom_codec_destroy(&ctx->
encoder);
335 struct aom_codec_enc_cfg *enccfg, aom_codec_flags_t *
flags,
336 aom_img_fmt_t *img_fmt)
340 enccfg->g_bit_depth = enccfg->g_input_bit_depth = desc->
comp[0].
depth;
343 enccfg->monochrome = 1;
347 *img_fmt = AOM_IMG_FMT_I420;
351 *img_fmt = AOM_IMG_FMT_I422;
356 *img_fmt = AOM_IMG_FMT_I444;
360 enccfg->monochrome = 1;
364 if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
367 *img_fmt = AOM_IMG_FMT_I42016;
368 *flags |= AOM_CODEC_USE_HIGHBITDEPTH;
374 if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
376 *img_fmt = AOM_IMG_FMT_I42216;
377 *flags |= AOM_CODEC_USE_HIGHBITDEPTH;
385 if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
388 *img_fmt = AOM_IMG_FMT_I44416;
389 *flags |= AOM_CODEC_USE_HIGHBITDEPTH;
402 aom_color_range_t aom_cr;
418 int sb_dim = (dim + sb_size - 1) / sb_size;
419 int tile_dim = (sb_dim + (1 << tiles_log2) - 1) >> tiles_log2;
421 return (sb_dim + tile_dim - 1) / tile_dim;
425 struct aom_codec_enc_cfg *enccfg)
428 int sb_128x128_possible, sb_size, sb_width, sb_height;
429 int uniform_rows, uniform_cols;
430 int uniform_64x64_possible, uniform_128x128_possible;
431 int tile_size, rounding,
i;
443 "columns to fill width.\n", ctx->
tile_cols);
464 "large enough to fit specified tile arrangement.\n");
470 "not allow more than %dx%d tiles.\n",
476 "not allow tiles of width greater than %d.\n",
488 sb_128x128_possible =
502 "-> %dx%d tiles.\n", uniform_cols, uniform_rows);
503 uniform_64x64_possible = uniform_cols == ctx->
tile_cols &&
506 if (sb_128x128_possible) {
512 "-> %dx%d tiles.\n", uniform_cols, uniform_rows);
513 uniform_128x128_possible = uniform_cols == ctx->
tile_cols &&
517 uniform_128x128_possible = 0;
521 if (uniform_64x64_possible && uniform_128x128_possible) {
523 "superblocks (tile_cols_log2 = %d, tile_rows_log2 = %d).\n",
527 if (uniform_64x64_possible && !sb_128x128_possible) {
529 "superblocks (tile_cols_log2 = %d, tile_rows_log2 = %d).\n",
534 if (uniform_128x128_possible) {
536 "superblocks (tile_cols_log2 = %d, tile_rows_log2 = %d).\n",
543 if (sb_128x128_possible) {
551 "superblocks (tile_cols = %d, tile_rows = %d).\n",
554 enccfg->tile_width_count = ctx->
tile_cols;
555 enccfg->tile_height_count = ctx->
tile_rows;
557 sb_width = (avctx->
width + sb_size - 1) / sb_size;
558 sb_height = (avctx->
height + sb_size - 1) / sb_size;
563 enccfg->tile_widths[
i] = tile_size +
565 i > ctx->
tile_cols - 1 - (rounding + 1) / 2);
571 enccfg->tile_heights[
i] = tile_size +
573 i > ctx->
tile_rows - 1 - (rounding + 1) / 2);
580 const struct aom_codec_iface *iface)
584 struct aom_codec_enc_cfg enccfg = { 0 };
585 #ifdef AOM_FRAME_IS_INTRAONLY 586 aom_codec_flags_t
flags =
589 aom_codec_flags_t flags = 0;
593 aom_img_fmt_t img_fmt;
594 aom_codec_caps_t codec_caps = aom_codec_get_caps(iface);
599 if ((res = aom_codec_enc_config_default(iface, &enccfg, 0)) != AOM_CODEC_OK) {
601 aom_codec_err_to_string(res));
605 if (
set_pix_fmt(avctx, codec_caps, &enccfg, &flags, &img_fmt))
616 enccfg.g_w = avctx->
width;
617 enccfg.g_h = avctx->
height;
623 enccfg.g_usage = ctx->
usage;
629 enccfg.g_pass = AOM_RC_FIRST_PASS;
631 enccfg.g_pass = AOM_RC_LAST_PASS;
633 enccfg.g_pass = AOM_RC_ONE_PASS;
637 enccfg.rc_end_usage = AOM_CBR;
638 }
else if (ctx->
crf >= 0) {
639 enccfg.rc_end_usage = AOM_CQ;
641 enccfg.rc_end_usage = AOM_Q;
647 }
else if (enccfg.rc_end_usage != AOM_Q) {
648 enccfg.rc_end_usage = AOM_Q;
651 "Neither bitrate nor constrained quality specified, using default CRF of %d\n",
655 if (avctx->
qmin >= 0)
656 enccfg.rc_min_quantizer = avctx->
qmin;
657 if (avctx->
qmax >= 0) {
658 enccfg.rc_max_quantizer = avctx->
qmax;
659 }
else if (!ctx->
crf) {
660 enccfg.rc_max_quantizer = 0;
663 if (enccfg.rc_end_usage == AOM_CQ || enccfg.rc_end_usage == AOM_Q) {
664 if (ctx->
crf < enccfg.rc_min_quantizer || ctx->
crf > enccfg.rc_max_quantizer) {
666 "CQ level %d must be between minimum and maximum quantizer value (%d-%d)\n",
667 ctx->
crf, enccfg.rc_min_quantizer, enccfg.rc_max_quantizer);
679 enccfg.rc_2pass_vbr_minsection_pct =
684 enccfg.rc_2pass_vbr_maxsection_pct =
691 enccfg.rc_buf_initial_sz =
693 enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
704 enccfg.kf_max_dist = avctx->
gop_size;
706 if (enccfg.g_pass == AOM_RC_FIRST_PASS)
707 enccfg.g_lag_in_frames = 0;
708 else if (enccfg.g_pass == AOM_RC_LAST_PASS) {
709 int decode_size,
ret;
727 if (decode_size < 0) {
740 enccfg.g_profile = avctx->
profile;
750 res = aom_codec_enc_init(&ctx->
encoder, iface, &enccfg, flags);
751 if (res != AOM_CODEC_OK) {
769 #if AOM_ENCODER_ABI_VERSION >= 22 855 #ifdef AOM_CTRL_AV1E_SET_DENOISE_NOISE_LEVEL 859 #ifdef AOM_CTRL_AV1E_SET_DENOISE_BLOCK_SIZE 863 #ifdef AOM_CTRL_AV1E_SET_ENABLE_GLOBAL_MOTION 867 #ifdef AOM_CTRL_AV1E_SET_MAX_REFERENCE_FRAMES 868 if (avctx->
refs >= 3) {
872 #ifdef AOM_CTRL_AV1E_SET_ROW_MT 876 #ifdef AOM_CTRL_AV1E_SET_ENABLE_INTRABC 881 #if AOM_ENCODER_ABI_VERSION >= 23 887 if (ret != AOM_CODEC_OK) {
899 if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH)
900 ctx->
rawimg.bit_depth = enccfg.g_bit_depth;
912 "not found. This is a bug, please report it.\n");
928 if (enccfg.rc_end_usage == AOM_CBR ||
929 enccfg.g_pass != AOM_RC_ONE_PASS) {
941 const struct aom_codec_cx_pkt *
src)
943 dst->
pts = src->data.frame.pts;
944 dst->
duration = src->data.frame.duration;
945 dst->
flags = src->data.frame.flags;
946 dst->
sz = src->data.frame.sz;
947 dst->
buf = src->data.frame.buf;
948 #ifdef AOM_FRAME_IS_INTRAONLY 955 memcpy(dst->
sse, ctx->
sse,
sizeof(dst->
sse));
982 if (!!(cx_frame->
flags & AOM_FRAME_IS_KEY)) {
984 #ifdef AOM_FRAME_IS_INTRAONLY 986 }
else if (cx_frame->
flags & AOM_FRAME_IS_INTRAONLY) {
993 cx_frame->
have_sse ? 3 : 0, pict_type);
997 for (i = 0; i < 3; ++
i) {
1008 "failed to send input packet\n");
1015 "failed to receive output packet\n");
1033 const struct aom_codec_cx_pkt *
pkt;
1034 const void *iter =
NULL;
1049 while ((pkt = aom_codec_get_cx_data(&ctx->
encoder, &iter))) {
1050 switch (pkt->kind) {
1051 case AOM_CODEC_CX_FRAME_PKT:
1059 size =
storeframe(avctx, &cx_frame, pkt_out);
1068 "Frame queue element alloc failed\n");
1074 if (!cx_frame->
buf) {
1081 memcpy(cx_frame->
buf, pkt->data.frame.buf, pkt->data.frame.sz);
1085 case AOM_CODEC_STATS_PKT:
1091 pkt->data.twopass_stats.sz)) < 0) {
1096 memcpy((
uint8_t *)stats->buf + stats->sz,
1097 pkt->data.twopass_stats.buf, pkt->data.twopass_stats.sz);
1098 stats->sz += pkt->data.twopass_stats.sz;
1101 #ifdef AOM_FRAME_IS_INTRAONLY 1102 case AOM_CODEC_PSNR_PKT:
1105 ctx->
sse[0] = pkt->data.psnr.sse[0];
1106 ctx->
sse[1] = pkt->data.psnr.sse[1];
1107 ctx->
sse[2] = pkt->data.psnr.sse[2];
1108 ctx->
sse[3] = pkt->data.psnr.sse[3];
1113 case AOM_CODEC_CUSTOM_PKT:
1126 struct aom_image *rawimg =
NULL;
1127 int64_t timestamp = 0;
1128 int res, coded_size;
1129 aom_enc_frame_flags_t
flags = 0;
1133 rawimg->planes[AOM_PLANE_Y] = frame->
data[0];
1134 rawimg->planes[AOM_PLANE_U] = frame->
data[1];
1135 rawimg->planes[AOM_PLANE_V] = frame->
data[2];
1136 rawimg->stride[AOM_PLANE_Y] = frame->
linesize[0];
1137 rawimg->stride[AOM_PLANE_U] = frame->
linesize[1];
1138 rawimg->stride[AOM_PLANE_V] = frame->
linesize[2];
1139 timestamp = frame->
pts;
1142 rawimg->range = AOM_CR_STUDIO_RANGE;
1145 rawimg->range = AOM_CR_FULL_RANGE;
1150 flags |= AOM_EFLAG_FORCE_KF;
1153 res = aom_codec_encode(&ctx->
encoder, rawimg, timestamp,
1155 if (res != AOM_CODEC_OK) {
1174 *got_packet = !!coded_size;
1232 int supports_monochrome = aom_codec_version() >= 20001;
1233 aom_codec_caps_t codec_caps = aom_codec_get_caps(aom_codec_av1_cx());
1234 if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH)
1241 if (aom_codec_version_major() < 2)
1247 return aom_init(avctx, aom_codec_av1_cx());
1250 #define OFFSET(x) offsetof(AOMContext, x) 1251 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM 1254 {
"auto-alt-ref",
"Enable use of alternate reference " 1256 {
"lag-in-frames",
"Number of frames to look ahead at for " 1258 {
"arnr-max-frames",
"altref noise reduction max frame count",
OFFSET(arnr_max_frames),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE},
1259 {
"arnr-strength",
"altref noise reduction filter strength",
OFFSET(arnr_strength),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
1260 {
"aq-mode",
"adaptive quantization mode",
OFFSET(aq_mode),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 4,
VE,
"aq_mode"},
1262 {
"variance",
"Variance based Aq", 0,
AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0,
VE,
"aq_mode"},
1263 {
"complexity",
"Complexity based Aq", 0,
AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0,
VE,
"aq_mode"},
1265 {
"error-resilience",
"Error resilience configuration",
OFFSET(error_resilient),
AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX,
VE,
"er"},
1266 {
"default",
"Improve resiliency against losses of whole frames", 0,
AV_OPT_TYPE_CONST, {.i64 = AOM_ERROR_RESILIENT_DEFAULT}, 0, 0,
VE,
"er"},
1267 {
"crf",
"Select the quality for constant quality mode", offsetof(
AOMContext, crf),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, VE },
1268 {
"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 },
1269 {
"drop-threshold",
"Frame drop threshold", offsetof(
AOMContext, drop_threshold),
AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE },
1270 {
"denoise-noise-level",
"Amount of noise to be removed",
OFFSET(denoise_noise_level),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE},
1271 {
"denoise-block-size",
"Denoise block size ",
OFFSET(denoise_block_size),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE},
1272 {
"undershoot-pct",
"Datarate undershoot (min) target (%)",
OFFSET(rc_undershoot_pct),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 100, VE},
1273 {
"overshoot-pct",
"Datarate overshoot (max) target (%)",
OFFSET(rc_overshoot_pct),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1000, VE},
1274 {
"minsection-pct",
"GOP min bitrate (% of target)",
OFFSET(minsection_pct),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 100, VE},
1275 {
"maxsection-pct",
"GOP max bitrate (% of target)",
OFFSET(maxsection_pct),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 5000, VE},
1276 {
"frame-parallel",
"Enable frame parallel decodability features",
OFFSET(frame_parallel),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1278 {
"tile-columns",
"Log2 of number of tile columns to use",
OFFSET(tile_cols_log2),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
1279 {
"tile-rows",
"Log2 of number of tile rows to use",
OFFSET(tile_rows_log2),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
1280 {
"row-mt",
"Enable row based multi-threading",
OFFSET(row_mt),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1281 {
"enable-cdef",
"Enable CDEF filtering",
OFFSET(enable_cdef),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1282 {
"enable-global-motion",
"Enable global motion",
OFFSET(enable_global_motion),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1283 {
"enable-intrabc",
"Enable intra block copy prediction mode",
OFFSET(enable_intrabc),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1284 {
"enable-restoration",
"Enable Loop Restoration filtering",
OFFSET(enable_restoration),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1285 {
"usage",
"Quality and compression efficiency vs speed trade-off",
OFFSET(
usage),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX,
VE,
"usage"},
1288 {
"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,
"tune"},
1292 {
"enable-rect-partitions",
"Enable rectangular partitions",
OFFSET(enable_rect_partitions),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1293 {
"enable-1to4-partitions",
"Enable 1:4/4:1 partitions",
OFFSET(enable_1to4_partitions),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1294 {
"enable-ab-partitions",
"Enable ab shape partitions",
OFFSET(enable_ab_partitions),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1295 {
"enable-angle-delta",
"Enable angle delta intra prediction",
OFFSET(enable_angle_delta),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1296 {
"enable-cfl-intra",
"Enable chroma predicted from luma intra prediction",
OFFSET(enable_cfl_intra),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1297 {
"enable-filter-intra",
"Enable filter intra predictor",
OFFSET(enable_filter_intra),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1298 {
"enable-intra-edge-filter",
"Enable intra edge filter",
OFFSET(enable_intra_edge_filter),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1299 {
"enable-smooth-intra",
"Enable smooth intra prediction mode",
OFFSET(enable_smooth_intra),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1300 {
"enable-paeth-intra",
"Enable paeth predictor in intra prediction",
OFFSET(enable_paeth_intra),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1301 {
"enable-palette",
"Enable palette prediction mode",
OFFSET(enable_palette),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1302 {
"enable-flip-idtx",
"Enable extended transform type",
OFFSET(enable_flip_idtx),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1303 {
"enable-tx64",
"Enable 64-pt transform",
OFFSET(enable_tx64),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1304 {
"reduced-tx-type-set",
"Use reduced set of transform types",
OFFSET(reduced_tx_type_set),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1305 {
"use-intra-dct-only",
"Use DCT only for INTRA modes",
OFFSET(use_intra_dct_only),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1306 {
"use-inter-dct-only",
"Use DCT only for INTER modes",
OFFSET(use_inter_dct_only),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1307 {
"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},
1308 {
"enable-ref-frame-mvs",
"Enable temporal mv prediction",
OFFSET(enable_ref_frame_mvs),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1309 {
"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},
1311 {
"enable-dual-filter",
"Enable dual filter",
OFFSET(enable_dual_filter),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1312 {
"enable-diff-wtd-comp",
"Enable difference-weighted compound",
OFFSET(enable_diff_wtd_comp),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1313 {
"enable-dist-wtd-comp",
"Enable distance-weighted compound",
OFFSET(enable_dist_wtd_comp),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1314 {
"enable-onesided-comp",
"Enable one sided compound",
OFFSET(enable_onesided_comp),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1315 {
"enable-interinter-wedge",
"Enable interinter wedge compound",
OFFSET(enable_interinter_wedge),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1316 {
"enable-interintra-wedge",
"Enable interintra wedge compound",
OFFSET(enable_interintra_wedge),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1317 {
"enable-masked-comp",
"Enable masked compound",
OFFSET(enable_masked_comp),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1318 {
"enable-interintra-comp",
"Enable interintra compound",
OFFSET(enable_interintra_comp),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1319 {
"enable-smooth-interintra",
"Enable smooth interintra mode",
OFFSET(enable_smooth_interintra),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1320 #if AOM_ENCODER_ABI_VERSION >= 23 1321 {
"aom-params",
"Set libaom options using a :-separated list of key=value pairs",
OFFSET(aom_params),
AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE },
1331 {
"keyint_min",
"-1" },
1343 .
name =
"libaom-av1",
1357 .wrapper_name =
"libaom",
const AVBitStreamFilter * av_bsf_get_by_name(const char *name)
ptrdiff_t const GLvoid GLenum usage
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static enum AVPixelFormat av1_pix_fmts_highbd_with_gray[]
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
uint64_t error[AV_NUM_DATA_POINTERS]
error
int use_intra_default_tx_only
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t bit_rate
the average bitrate
#define LIBAVUTIL_VERSION_INT
static av_cold int init(AVCodecContext *avctx)
int max_bitrate
Maximum bitrate of the stream, in bits per second.
int rc_initial_buffer_occupancy
Number of bits which should be loaded into the rc buffer before decoding starts.
int enable_smooth_interintra
static av_cold int aom_init(AVCodecContext *avctx, const struct aom_codec_iface *iface)
enum AVColorRange color_range
MPEG vs JPEG YUV range.
The bitstream filter state.
void * buf
compressed data buffer
#define AV_PIX_FMT_GBRP10
const char * av_default_item_name(void *ptr)
Return the context name.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
size_t sz
length of compressed data
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
#define AV_PIX_FMT_YUV420P12
char * stats_in
pass2 encoding statistics input buffer Concatenated stuff from stats_out of pass1 should be placed he...
static const AVOption options[]
#define FF_AV1_PROFILE_OPTS
static void error(const char *err)
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
int min_bitrate
Minimum bitrate of the stream, in bits per second.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
#define AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY12
static int choose_tiling(AVCodecContext *avctx, struct aom_codec_enc_cfg *enccfg)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
static av_cold void free_frame_list(struct FrameListData *list)
int enable_reduced_reference_set
int enable_interintra_wedge
struct FrameListData * next
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
struct aom_fixed_buf twopass_stats
int64_t pts
time stamp to show frame (in timebase units)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
#define AV_LOG_VERBOSE
Detailed information.
static av_cold int codecctl_int(AVCodecContext *avctx, enum aome_enc_control_id id, int val)
int buffer_size
The size of the buffer to which the ratecontrol is applied, in bits.
#define AV_PIX_FMT_YUV422P12
char * stats_out
pass1 encoding statistics output buffer
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int enable_rect_partitions
static void cx_pktcpy(AOMContext *ctx, struct FrameListData *dst, const struct aom_codec_cx_pkt *src)
int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
Allocate a context for a given bitstream filter.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
static av_cold void av1_init_static(AVCodec *codec)
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
int qmax
maximum quantizer
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int capabilities
Codec capabilities.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int flags
AV_CODEC_FLAG_*.
Round to nearest and halfway cases away from zero.
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
simple assert() macros that are a bit more flexible than ISO C assert().
const char * name
Name of the codec implementation.
int enable_1to4_partitions
static av_always_inline av_const double round(double x)
#define AV_PIX_FMT_YUV444P10
AVDictionary * aom_params
char * av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size)
Encode data to base64 and null-terminate.
static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame, AVPacket *pkt)
Store coded frame information in format suitable for return from encode2().
static void set_color_range(AVCodecContext *avctx)
int flags
A combination of AV_PKT_FLAG values.
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int rc_buffer_size
decoder bitstream buffer size
static const AVClass class_aom
int64_t rc_min_rate
minimum bitrate
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
AVCodec ff_libaom_av1_encoder
int refs
number of reference frames
struct FrameListData * coded_frame_list
static enum AVPixelFormat av1_pix_fmts_highbd[]
enum AVPixelFormat * pix_fmts
array of supported pixel formats, or NULL if unknown, array is terminated by -1
enum AVPictureType pict_type
Picture type of the frame.
#define AV_BASE64_SIZE(x)
Calculate the output size needed to base64-encode x bytes to a null-terminated string.
static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out)
Queue multiple output frames from the encoder, returning the front-most.
int width
picture width / height.
#define FF_PROFILE_UNKNOWN
static av_cold void free_coded_frame(struct FrameListData *cx_frame)
#define AV_CODEC_FLAG_PSNR
error[?] variables will be set during encoding.
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
static int count_uniform_tiling(int dim, int sb_size, int tiles_log2)
static void stats(AVPacket *const *in, int n_in, unsigned *_max, unsigned *_sum)
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
int enable_interintra_comp
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
static const char *const ctlidstr[]
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.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
int have_sse
true if we have pending sse[]
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)
This structure describes the bitrate properties of an encoded bitstream.
struct aom_codec_ctx encoder
#define AV_LOG_INFO
Standard information.
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
Libavcodec external API header.
aom_superblock_size_t superblock_size
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
const AVProfile ff_av1_profiles[]
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
main external API structure.
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
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
static enum AVPixelFormat av1_pix_fmts[]
int qmin
minimum quantizer
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
static av_cold int av1_init(AVCodecContext *avctx)
#define AV_PIX_FMT_YUV420P10
static void coded_frame_add(void *list, struct FrameListData *cx_frame)
Describe the class of an AVClass context structure.
static const AVProfile profiles[]
#define FF_PROFILE_AV1_PROFESSIONAL
enum AVColorSpace colorspace
YUV colorspace type.
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
int avcodec_parameters_from_context(AVCodecParameters *par, const AVCodecContext *codec)
Fill the parameters struct based on the values from the supplied codec context.
#define FF_PROFILE_AV1_MAIN
uint32_t flags
flags for this frame
offset must point to two consecutive integers
static av_cold void dump_enc_cfg(AVCodecContext *avctx, const struct aom_codec_enc_cfg *cfg)
float qcompress
amount of qscale change between easy & hard scenes (0.0-1.0)
int enable_intra_edge_filter
#define AV_PIX_FMT_GBRP12
int have_sse
true if we have pending sse[]
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV444P12
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
Narrow or limited range content.
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
static enum AVPixelFormat av1_pix_fmts_with_gray[]
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
IEC 61966-2-1 (sRGB or sYCC)
common internal api header.
static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
common internal and external API header
static int aom_encode(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
AVCPBProperties * ff_add_cpb_side_data(AVCodecContext *avctx)
Add a CPB properties side data to an encoding context.
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
Portion of struct vpx_codec_cx_pkt from vpx_encoder.h.
int avg_bitrate
Average bitrate of the stream, in bits per second.
unsigned long duration
duration to show frame (in timebase units)
int av_base64_decode(uint8_t *out, const char *in_str, int out_size)
Decode a base64-encoded string.
int enable_interinter_wedge
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
static const AVCodecDefault defaults[]
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key, ignoring the suffix of the found key string.
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
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
int depth
Number of bits in the component.
#define AVERROR_EXTERNAL
Generic error in an external library.
AVPixelFormat
Pixel format.
static double val(void *priv, double ch)
This structure stores compressed data.
AVCodecParameters * par_in
Parameters of the input stream.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
static av_cold int aom_free(AVCodecContext *avctx)
#define FF_PROFILE_AV1_HIGH
int64_t rc_max_rate
maximum bitrate
int keyint_min
minimum GOP size