26 #define AOM_DISABLE_CTRL_TYPECHECKS 1 
   27 #include <aom/aom_encoder.h> 
   28 #include <aom/aomcx.h> 
  102     [AOME_SET_CPUUSED]          = 
"AOME_SET_CPUUSED",
 
  103     [AOME_SET_CQ_LEVEL]         = 
"AOME_SET_CQ_LEVEL",
 
  104     [AOME_SET_ENABLEAUTOALTREF] = 
"AOME_SET_ENABLEAUTOALTREF",
 
  105     [AOME_SET_ARNR_MAXFRAMES]   = 
"AOME_SET_ARNR_MAXFRAMES",
 
  106     [AOME_SET_ARNR_STRENGTH]    = 
"AOME_SET_ARNR_STRENGTH",
 
  107     [AOME_SET_STATIC_THRESHOLD] = 
"AOME_SET_STATIC_THRESHOLD",
 
  108     [AV1E_SET_COLOR_RANGE]      = 
"AV1E_SET_COLOR_RANGE",
 
  109     [AV1E_SET_COLOR_PRIMARIES]  = 
"AV1E_SET_COLOR_PRIMARIES",
 
  110     [AV1E_SET_MATRIX_COEFFICIENTS] = 
"AV1E_SET_MATRIX_COEFFICIENTS",
 
  111     [AV1E_SET_TRANSFER_CHARACTERISTICS] = 
"AV1E_SET_TRANSFER_CHARACTERISTICS",
 
  112     [AV1E_SET_AQ_MODE]          = 
"AV1E_SET_AQ_MODE",
 
  113     [AV1E_SET_FRAME_PARALLEL_DECODING] = 
"AV1E_SET_FRAME_PARALLEL_DECODING",
 
  114     [AV1E_SET_SUPERBLOCK_SIZE]  = 
"AV1E_SET_SUPERBLOCK_SIZE",
 
  115     [AV1E_SET_TILE_COLUMNS]     = 
"AV1E_SET_TILE_COLUMNS",
 
  116     [AV1E_SET_TILE_ROWS]        = 
"AV1E_SET_TILE_ROWS",
 
  117     [AV1E_SET_ENABLE_RESTORATION] = 
"AV1E_SET_ENABLE_RESTORATION",
 
  118 #ifdef AOM_CTRL_AV1E_SET_ROW_MT 
  119     [AV1E_SET_ROW_MT]           = 
"AV1E_SET_ROW_MT",
 
  121 #ifdef AOM_CTRL_AV1E_SET_DENOISE_NOISE_LEVEL 
  122     [AV1E_SET_DENOISE_NOISE_LEVEL] =  
"AV1E_SET_DENOISE_NOISE_LEVEL",
 
  124 #ifdef AOM_CTRL_AV1E_SET_DENOISE_BLOCK_SIZE 
  125     [AV1E_SET_DENOISE_BLOCK_SIZE] =   
"AV1E_SET_DENOISE_BLOCK_SIZE",
 
  127 #ifdef AOM_CTRL_AV1E_SET_MAX_REFERENCE_FRAMES 
  128     [AV1E_SET_MAX_REFERENCE_FRAMES] = 
"AV1E_SET_MAX_REFERENCE_FRAMES",
 
  130 #ifdef AOM_CTRL_AV1E_SET_ENABLE_GLOBAL_MOTION 
  131     [AV1E_SET_ENABLE_GLOBAL_MOTION] = 
"AV1E_SET_ENABLE_GLOBAL_MOTION",
 
  133 #ifdef AOM_CTRL_AV1E_SET_ENABLE_INTRABC 
  134     [AV1E_SET_ENABLE_INTRABC]   = 
"AV1E_SET_ENABLE_INTRABC",
 
  136     [AV1E_SET_ENABLE_CDEF]      = 
"AV1E_SET_ENABLE_CDEF",
 
  137     [AOME_SET_TUNING]           = 
"AOME_SET_TUNING",
 
  143     const char *
error  = aom_codec_error(&
ctx->encoder);
 
  144     const char *detail = aom_codec_error_detail(&
ctx->encoder);
 
  152                                  const struct aom_codec_enc_cfg *cfg)
 
  159                          "  %*s%u\n  %*s%u\n  %*s%u\n  %*s%u\n  %*s%u\n" 
  161                          "  %*s{%u/%u}\n  %*s%u\n  %*s%d\n  %*s%u\n",
 
  162            width, 
"g_usage:",           cfg->g_usage,
 
  163            width, 
"g_threads:",         cfg->g_threads,
 
  164            width, 
"g_profile:",         cfg->g_profile,
 
  165            width, 
"g_w:",               cfg->g_w,
 
  166            width, 
"g_h:",               cfg->g_h,
 
  167            width, 
"g_bit_depth:",       cfg->g_bit_depth,
 
  168            width, 
"g_input_bit_depth:", cfg->g_input_bit_depth,
 
  169            width, 
"g_timebase:",        cfg->g_timebase.num, cfg->g_timebase.den,
 
  170            width, 
"g_error_resilient:", cfg->g_error_resilient,
 
  171            width, 
"g_pass:",            cfg->g_pass,
 
  172            width, 
"g_lag_in_frames:",   cfg->g_lag_in_frames);
 
  175            width, 
"rc_dropframe_thresh:", cfg->rc_dropframe_thresh,
 
  176            width, 
"rc_end_usage:",        cfg->rc_end_usage,
 
  177            width, 
"rc_twopass_stats_in:", cfg->rc_twopass_stats_in.buf, cfg->rc_twopass_stats_in.sz,
 
  178            width, 
"rc_target_bitrate:",   cfg->rc_target_bitrate);
 
  181            width, 
"rc_min_quantizer:", cfg->rc_min_quantizer,
 
  182            width, 
"rc_max_quantizer:", cfg->rc_max_quantizer);
 
  185            width, 
"rc_undershoot_pct:", cfg->rc_undershoot_pct,
 
  186            width, 
"rc_overshoot_pct:",  cfg->rc_overshoot_pct);
 
  188                          "  %*s%u\n  %*s%u\n  %*s%u\n",
 
  189            width, 
"rc_buf_sz:",         cfg->rc_buf_sz,
 
  190            width, 
"rc_buf_initial_sz:", cfg->rc_buf_initial_sz,
 
  191            width, 
"rc_buf_optimal_sz:", cfg->rc_buf_optimal_sz);
 
  192     av_log(avctx, 
level, 
"2 pass rate control settings\n" 
  193                          "  %*s%u\n  %*s%u\n  %*s%u\n",
 
  194            width, 
"rc_2pass_vbr_bias_pct:",       cfg->rc_2pass_vbr_bias_pct,
 
  195            width, 
"rc_2pass_vbr_minsection_pct:", cfg->rc_2pass_vbr_minsection_pct,
 
  196            width, 
"rc_2pass_vbr_maxsection_pct:", cfg->rc_2pass_vbr_maxsection_pct);
 
  198                          "  %*s%d\n  %*s%u\n  %*s%u\n",
 
  199            width, 
"kf_mode:",     cfg->kf_mode,
 
  200            width, 
"kf_min_dist:", cfg->kf_min_dist,
 
  201            width, 
"kf_max_dist:", cfg->kf_max_dist);
 
  204            width, 
"tile_width_count:",  cfg->tile_width_count,
 
  205            width, 
"tile_height_count:", cfg->tile_height_count);
 
  238                                 aome_enc_control_id 
id,
 
  240                                 enum aome_enc_control_id 
id,
 
  252     res = aom_codec_control(&
ctx->encoder, 
id, 
val);
 
  253     if (res != AOM_CODEC_OK) {
 
  267     aom_codec_destroy(&
ctx->encoder);
 
  276                        struct aom_codec_enc_cfg *enccfg, aom_codec_flags_t *
flags,
 
  277                        aom_img_fmt_t *img_fmt)
 
  280     enccfg->g_bit_depth = enccfg->g_input_bit_depth = 8;
 
  284         *img_fmt = AOM_IMG_FMT_I420;
 
  288         *img_fmt = AOM_IMG_FMT_I422;
 
  292         *img_fmt = AOM_IMG_FMT_I444;
 
  296         if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
 
  297             enccfg->g_bit_depth = enccfg->g_input_bit_depth =
 
  301             *img_fmt = AOM_IMG_FMT_I42016;
 
  302             *
flags |= AOM_CODEC_USE_HIGHBITDEPTH;
 
  308         if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
 
  309             enccfg->g_bit_depth = enccfg->g_input_bit_depth =
 
  312             *img_fmt = AOM_IMG_FMT_I42216;
 
  313             *
flags |= AOM_CODEC_USE_HIGHBITDEPTH;
 
  319         if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
 
  320             enccfg->g_bit_depth = enccfg->g_input_bit_depth =
 
  324             *img_fmt = AOM_IMG_FMT_I44416;
 
  325             *
flags |= AOM_CODEC_USE_HIGHBITDEPTH;
 
  338     aom_color_range_t aom_cr;
 
  354     int sb_dim   = (
dim + sb_size - 1) / sb_size;
 
  355     int tile_dim = (sb_dim + (1 << tiles_log2) - 1) >> tiles_log2;
 
  357     return (sb_dim + tile_dim - 1) / tile_dim;
 
  361                          struct aom_codec_enc_cfg *enccfg)
 
  364     int sb_128x128_possible, sb_size, sb_width, sb_height;
 
  365     int uniform_rows, uniform_cols;
 
  366     int uniform_64x64_possible, uniform_128x128_possible;
 
  367     int tile_size, rounding, 
i;
 
  369     if (
ctx->tile_cols_log2 >= 0)
 
  370         ctx->tile_cols = 1 << 
ctx->tile_cols_log2;
 
  371     if (
ctx->tile_rows_log2 >= 0)
 
  372         ctx->tile_rows = 1 << 
ctx->tile_rows_log2;
 
  374     if (
ctx->tile_cols == 0) {
 
  377         if (
ctx->tile_cols > 1) {
 
  379                    "columns to fill width.\n", 
ctx->tile_cols);
 
  383     if (
ctx->tile_rows == 0) {
 
  386                      ctx->tile_cols - 1) / 
ctx->tile_cols, 128);
 
  390         if (
ctx->tile_rows > 1) {
 
  392                    "rows to fill area.\n", 
ctx->tile_rows);
 
  397     if ((avctx->
width  + 63) / 64 < 
ctx->tile_cols ||
 
  398         (avctx->
height + 63) / 64 < 
ctx->tile_rows) {
 
  400                "large enough to fit specified tile arrangement.\n");
 
  406                "not allow more than %dx%d tiles.\n",
 
  412                "not allow tiles of width greater than %d.\n",
 
  417     ctx->superblock_size = AOM_SUPERBLOCK_SIZE_DYNAMIC;
 
  419     if (
ctx->tile_cols == 1 && 
ctx->tile_rows == 1) {
 
  424     sb_128x128_possible =
 
  425         (avctx->
width  + 127) / 128 >= 
ctx->tile_cols &&
 
  426         (avctx->
height + 127) / 128 >= 
ctx->tile_rows;
 
  428     ctx->tile_cols_log2 = 
ctx->tile_cols == 1 ? 0 :
 
  430     ctx->tile_rows_log2 = 
ctx->tile_rows == 1 ? 0 :
 
  434                                         64, 
ctx->tile_cols_log2);
 
  436                                         64, 
ctx->tile_rows_log2);
 
  438            "-> %dx%d tiles.\n", uniform_cols, uniform_rows);
 
  439     uniform_64x64_possible = uniform_cols == 
ctx->tile_cols &&
 
  440                              uniform_rows == 
ctx->tile_rows;
 
  442     if (sb_128x128_possible) {
 
  444                                             128, 
ctx->tile_cols_log2);
 
  446                                             128, 
ctx->tile_rows_log2);
 
  448                "-> %dx%d tiles.\n", uniform_cols, uniform_rows);
 
  449         uniform_128x128_possible = uniform_cols == 
ctx->tile_cols &&
 
  450                                    uniform_rows == 
ctx->tile_rows;
 
  453         uniform_128x128_possible = 0;
 
  456     ctx->uniform_tiles = 1;
 
  457     if (uniform_64x64_possible && uniform_128x128_possible) {
 
  459                "superblocks (tile_cols_log2 = %d, tile_rows_log2 = %d).\n",
 
  460                ctx->tile_cols_log2, 
ctx->tile_rows_log2);
 
  463     if (uniform_64x64_possible && !sb_128x128_possible) {
 
  465                "superblocks (tile_cols_log2 = %d, tile_rows_log2 = %d).\n",
 
  466                ctx->tile_cols_log2, 
ctx->tile_rows_log2);
 
  467         ctx->superblock_size = AOM_SUPERBLOCK_SIZE_64X64;
 
  470     if (uniform_128x128_possible) {
 
  472                "superblocks (tile_cols_log2 = %d, tile_rows_log2 = %d).\n",
 
  473                ctx->tile_cols_log2, 
ctx->tile_rows_log2);
 
  474         ctx->superblock_size = AOM_SUPERBLOCK_SIZE_128X128;
 
  477     ctx->uniform_tiles = 0;
 
  479     if (sb_128x128_possible) {
 
  481         ctx->superblock_size = AOM_SUPERBLOCK_SIZE_128X128;
 
  484         ctx->superblock_size = AOM_SUPERBLOCK_SIZE_64X64;
 
  487            "superblocks (tile_cols = %d, tile_rows = %d).\n",
 
  488            sb_size, sb_size, 
ctx->tile_cols, 
ctx->tile_rows);
 
  490     enccfg->tile_width_count  = 
ctx->tile_cols;
 
  491     enccfg->tile_height_count = 
ctx->tile_rows;
 
  493     sb_width  = (avctx->
width  + sb_size - 1) / sb_size;
 
  494     sb_height = (avctx->
height + sb_size - 1) / sb_size;
 
  496     tile_size = sb_width / 
ctx->tile_cols;
 
  497     rounding  = sb_width % 
ctx->tile_cols;
 
  498     for (
i = 0; 
i < 
ctx->tile_cols; 
i++) {
 
  499         enccfg->tile_widths[
i] = tile_size +
 
  501              i > 
ctx->tile_cols - 1 - (rounding + 1) / 2);
 
  504     tile_size = sb_height / 
ctx->tile_rows;
 
  505     rounding  = sb_height % 
ctx->tile_rows;
 
  506     for (
i = 0; 
i < 
ctx->tile_rows; 
i++) {
 
  507         enccfg->tile_heights[
i] = tile_size +
 
  509              i > 
ctx->tile_rows - 1 - (rounding + 1) / 2);
 
  516                             const struct aom_codec_iface *iface)
 
  519     struct aom_codec_enc_cfg enccfg = { 0 };
 
  520 #ifdef AOM_FRAME_IS_INTRAONLY 
  521     aom_codec_flags_t 
flags =
 
  524     aom_codec_flags_t 
flags = 0;
 
  528     aom_img_fmt_t img_fmt;
 
  529     aom_codec_caps_t codec_caps = aom_codec_get_caps(iface);
 
  534     if ((res = aom_codec_enc_config_default(iface, &enccfg, 0)) != AOM_CODEC_OK) {
 
  536                aom_codec_err_to_string(res));
 
  551     enccfg.g_w            = avctx->
width;
 
  552     enccfg.g_h            = avctx->
height;
 
  558     enccfg.g_usage        = 
ctx->usage;
 
  560     if (
ctx->lag_in_frames >= 0)
 
  561         enccfg.g_lag_in_frames = 
ctx->lag_in_frames;
 
  564         enccfg.g_pass = AOM_RC_FIRST_PASS;
 
  566         enccfg.g_pass = AOM_RC_LAST_PASS;
 
  568         enccfg.g_pass = AOM_RC_ONE_PASS;
 
  572         enccfg.rc_end_usage = AOM_CBR;
 
  573     } 
else if (
ctx->crf >= 0) {
 
  574         enccfg.rc_end_usage = AOM_CQ;
 
  576             enccfg.rc_end_usage = AOM_Q;
 
  582     } 
else if (enccfg.rc_end_usage != AOM_Q) {
 
  583         enccfg.rc_end_usage = AOM_Q;
 
  586                "Neither bitrate nor constrained quality specified, using default CRF of %d\n",
 
  590     if (avctx->
qmin >= 0)
 
  591         enccfg.rc_min_quantizer = avctx->
qmin;
 
  592     if (avctx->
qmax >= 0)
 
  593         enccfg.rc_max_quantizer = avctx->
qmax;
 
  595     if (enccfg.rc_end_usage == AOM_CQ || enccfg.rc_end_usage == AOM_Q) {
 
  596         if (
ctx->crf < enccfg.rc_min_quantizer || 
ctx->crf > enccfg.rc_max_quantizer) {
 
  598                    "CQ level %d must be between minimum and maximum quantizer value (%d-%d)\n",
 
  599                    ctx->crf, enccfg.rc_min_quantizer, enccfg.rc_max_quantizer);
 
  604     enccfg.rc_dropframe_thresh = 
ctx->drop_threshold;
 
  608     if (
ctx->minsection_pct >= 0)
 
  609         enccfg.rc_2pass_vbr_minsection_pct = 
ctx->minsection_pct;
 
  611         enccfg.rc_2pass_vbr_minsection_pct =
 
  613     if (
ctx->maxsection_pct >= 0)
 
  614         enccfg.rc_2pass_vbr_maxsection_pct = 
ctx->maxsection_pct;
 
  616         enccfg.rc_2pass_vbr_maxsection_pct =
 
  623         enccfg.rc_buf_initial_sz =
 
  625     enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
 
  627     if (
ctx->rc_undershoot_pct >= 0)
 
  628         enccfg.rc_undershoot_pct = 
ctx->rc_undershoot_pct;
 
  629     if (
ctx->rc_overshoot_pct >= 0)
 
  630         enccfg.rc_overshoot_pct = 
ctx->rc_overshoot_pct;
 
  636         enccfg.kf_max_dist = avctx->
gop_size;
 
  638     if (enccfg.g_pass == AOM_RC_FIRST_PASS)
 
  639         enccfg.g_lag_in_frames = 0;
 
  640     else if (enccfg.g_pass == AOM_RC_LAST_PASS) {
 
  641         int decode_size, 
ret;
 
  648         ctx->twopass_stats.sz = strlen(avctx->
stats_in) * 3 / 4;
 
  653                    ctx->twopass_stats.sz);
 
  654             ctx->twopass_stats.sz = 0;
 
  658                                        ctx->twopass_stats.sz);
 
  659         if (decode_size < 0) {
 
  664         ctx->twopass_stats.sz      = decode_size;
 
  665         enccfg.rc_twopass_stats_in = 
ctx->twopass_stats;
 
  672         enccfg.g_profile = avctx->
profile;
 
  674     enccfg.g_error_resilient = 
ctx->error_resilient;
 
  682     res = aom_codec_enc_init(&
ctx->encoder, iface, &enccfg, 
flags);
 
  683     if (res != AOM_CODEC_OK) {
 
  691     if (
ctx->auto_alt_ref >= 0)
 
  693     if (
ctx->arnr_max_frames >= 0)
 
  695     if (
ctx->arnr_strength >= 0)
 
  697     if (
ctx->enable_cdef >= 0)
 
  699     if (
ctx->enable_restoration >= 0)
 
  700         codecctl_int(avctx, AV1E_SET_ENABLE_RESTORATION, 
ctx->enable_restoration);
 
  711     if (
ctx->aq_mode >= 0)
 
  713     if (
ctx->frame_parallel >= 0)
 
  714         codecctl_int(avctx, AV1E_SET_FRAME_PARALLEL_DECODING, 
ctx->frame_parallel);
 
  718     if (
ctx->uniform_tiles) {
 
  723 #ifdef AOM_CTRL_AV1E_SET_DENOISE_NOISE_LEVEL 
  724     if (
ctx->denoise_noise_level >= 0)
 
  725         codecctl_int(avctx, AV1E_SET_DENOISE_NOISE_LEVEL, 
ctx->denoise_noise_level);
 
  727 #ifdef AOM_CTRL_AV1E_SET_DENOISE_BLOCK_SIZE 
  728     if (
ctx->denoise_block_size >= 0)
 
  729         codecctl_int(avctx, AV1E_SET_DENOISE_BLOCK_SIZE, 
ctx->denoise_block_size);
 
  731 #ifdef AOM_CTRL_AV1E_SET_ENABLE_GLOBAL_MOTION 
  732     if (
ctx->enable_global_motion >= 0)
 
  733         codecctl_int(avctx, AV1E_SET_ENABLE_GLOBAL_MOTION, 
ctx->enable_global_motion);
 
  735 #ifdef AOM_CTRL_AV1E_SET_MAX_REFERENCE_FRAMES 
  736     if (avctx->
refs >= 3) {
 
  740 #ifdef AOM_CTRL_AV1E_SET_ROW_MT 
  741     if (
ctx->row_mt >= 0)
 
  744 #ifdef AOM_CTRL_AV1E_SET_ENABLE_INTRABC 
  745     if (
ctx->enable_intrabc >= 0)
 
  750     aom_img_wrap(&
ctx->rawimg, img_fmt, avctx->
width, avctx->
height, 1,
 
  753     if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH)
 
  754         ctx->rawimg.bit_depth = enccfg.g_bit_depth;
 
  766                    "not found. This is a bug, please report it.\n");
 
  782     if (enccfg.rc_end_usage == AOM_CBR ||
 
  783         enccfg.g_pass != AOM_RC_ONE_PASS) {
 
  795                              const struct aom_codec_cx_pkt *
src)
 
  797     dst->
pts      = 
src->data.frame.pts;
 
  800     dst->
sz       = 
src->data.frame.sz;
 
  801     dst->
buf      = 
src->data.frame.buf;
 
  802 #ifdef AOM_FRAME_IS_INTRAONLY 
  809         memcpy(dst->
sse, 
ctx->sse, 
sizeof(dst->
sse));
 
  836     if (!!(cx_frame->
flags & AOM_FRAME_IS_KEY)) {
 
  838 #ifdef AOM_FRAME_IS_INTRAONLY 
  840     } 
else if (cx_frame->
flags & AOM_FRAME_IS_INTRAONLY) {
 
  847                                    cx_frame->
have_sse ? 3 : 0, pict_type);
 
  851         for (
i = 0; 
i < 3; ++
i) {
 
  862                    "failed to send input packet\n");
 
  869                    "failed to receive output packet\n");
 
  887     const struct aom_codec_cx_pkt *
pkt;
 
  888     const void *iter = 
NULL;
 
  891     if (
ctx->coded_frame_list) {
 
  897         ctx->coded_frame_list = cx_frame->
next;
 
  903     while ((
pkt = aom_codec_get_cx_data(&
ctx->encoder, &iter))) {
 
  905         case AOM_CODEC_CX_FRAME_PKT:
 
  922                            "Frame queue element alloc failed\n");
 
  928                 if (!cx_frame->
buf) {
 
  939         case AOM_CODEC_STATS_PKT:
 
  941             struct aom_fixed_buf *
stats = &
ctx->twopass_stats;
 
  945                                    pkt->
data.twopass_stats.sz)) < 0) {
 
  955 #ifdef AOM_FRAME_IS_INTRAONLY 
  956         case AOM_CODEC_PSNR_PKT:
 
  967         case AOM_CODEC_CUSTOM_PKT:
 
  980     struct aom_image *rawimg = 
NULL;
 
  981     int64_t timestamp = 0;
 
  983     aom_enc_frame_flags_t 
flags = 0;
 
  986         rawimg                      = &
ctx->rawimg;
 
  987         rawimg->planes[AOM_PLANE_Y] = 
frame->data[0];
 
  988         rawimg->planes[AOM_PLANE_U] = 
frame->data[1];
 
  989         rawimg->planes[AOM_PLANE_V] = 
frame->data[2];
 
  990         rawimg->stride[AOM_PLANE_Y] = 
frame->linesize[0];
 
  991         rawimg->stride[AOM_PLANE_U] = 
frame->linesize[1];
 
  992         rawimg->stride[AOM_PLANE_V] = 
frame->linesize[2];
 
  993         timestamp                   = 
frame->pts;
 
  994         switch (
frame->color_range) {
 
  996             rawimg->range = AOM_CR_STUDIO_RANGE;
 
  999             rawimg->range = AOM_CR_FULL_RANGE;
 
 1004             flags |= AOM_EFLAG_FORCE_KF;
 
 1007     res = aom_codec_encode(&
ctx->encoder, rawimg, timestamp,
 
 1009     if (res != AOM_CODEC_OK) {
 
 1025                          ctx->twopass_stats.sz);
 
 1028     *got_packet = !!coded_size;
 
 1054     aom_codec_caps_t codec_caps = aom_codec_get_caps(aom_codec_av1_cx());
 
 1055     if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH)
 
 1060     if (aom_codec_version_major() < 2)
 
 1066     return aom_init(avctx, aom_codec_av1_cx());
 
 1069 #define OFFSET(x) offsetof(AOMContext, x) 
 1070 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM 
 1073     { 
"auto-alt-ref",    
"Enable use of alternate reference " 
 1075     { 
"lag-in-frames",   
"Number of frames to look ahead at for " 
 1077     { 
"arnr-max-frames", 
"altref noise reduction max frame count", 
OFFSET(arnr_max_frames), 
AV_OPT_TYPE_INT, {.i64 = -1},      -1,      INT_MAX, 
VE},
 
 1078     { 
"arnr-strength",   
"altref noise reduction filter strength", 
OFFSET(arnr_strength),   
AV_OPT_TYPE_INT, {.i64 = -1},      -1,      6,       
VE},
 
 1079     { 
"aq-mode",         
"adaptive quantization mode",             
OFFSET(aq_mode),         
AV_OPT_TYPE_INT, {.i64 = -1},      -1,      4, 
VE, 
"aq_mode"},
 
 1081     { 
"variance",        
"Variance based Aq",   0, 
AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, 
VE, 
"aq_mode"},
 
 1082     { 
"complexity",      
"Complexity based Aq", 0, 
AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, 
VE, 
"aq_mode"},
 
 1084     { 
"error-resilience", 
"Error resilience configuration", 
OFFSET(error_resilient), 
AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, 
VE, 
"er"},
 
 1085     { 
"default",         
"Improve resiliency against losses of whole frames", 0, 
AV_OPT_TYPE_CONST, {.i64 = AOM_ERROR_RESILIENT_DEFAULT}, 0, 0, 
VE, 
"er"},
 
 1086     { 
"crf",              
"Select the quality for constant quality mode", offsetof(AOMContext, crf), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, 
VE },
 
 1087     { 
"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 },
 
 1088     { 
"drop-threshold",   
"Frame drop threshold", offsetof(AOMContext, drop_threshold), 
AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, 
VE },
 
 1089     { 
"denoise-noise-level", 
"Amount of noise to be removed", 
OFFSET(denoise_noise_level), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, 
VE},
 
 1090     { 
"denoise-block-size", 
"Denoise block size ", 
OFFSET(denoise_block_size), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, 
VE},
 
 1091     { 
"undershoot-pct",   
"Datarate undershoot (min) target (%)", 
OFFSET(rc_undershoot_pct), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 100, 
VE},
 
 1092     { 
"overshoot-pct",    
"Datarate overshoot (max) target (%)", 
OFFSET(rc_overshoot_pct), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1000, 
VE},
 
 1093     { 
"minsection-pct",   
"GOP min bitrate (% of target)", 
OFFSET(minsection_pct), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 100, 
VE},
 
 1094     { 
"maxsection-pct",   
"GOP max bitrate (% of target)", 
OFFSET(maxsection_pct), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 5000, 
VE},
 
 1095     { 
"frame-parallel",   
"Enable frame parallel decodability features", 
OFFSET(frame_parallel),  
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, 
VE},
 
 1097     { 
"tile-columns",     
"Log2 of number of tile columns to use", 
OFFSET(tile_cols_log2), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, 
VE},
 
 1098     { 
"tile-rows",        
"Log2 of number of tile rows to use",    
OFFSET(tile_rows_log2), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, 
VE},
 
 1101     { 
"enable-global-motion",  
"Enable global motion",             
OFFSET(enable_global_motion), 
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, 
VE},
 
 1102     { 
"enable-intrabc",  
"Enable intra block copy prediction mode", 
OFFSET(enable_intrabc), 
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, 
VE},
 
 1103     { 
"enable-restoration", 
"Enable Loop Restoration filtering", 
OFFSET(enable_restoration), 
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, 
VE},
 
 1104     { 
"usage",           
"Quality and compression efficiency vs speed trade-off", 
OFFSET(
usage), 
AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, 
VE, 
"usage"},
 
 1107     { 
"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"},
 
 1118     { 
"keyint_min",       
"-1" },
 
 1130     .
name           = 
"libaom-av1",
 
 1134     .priv_data_size = 
sizeof(AOMContext),
 
 1143     .wrapper_name   = 
"libaom",