diff options
Diffstat (limited to 'third_party/aom/av1/av1_cx_iface.c')
-rw-r--r-- | third_party/aom/av1/av1_cx_iface.c | 160 |
1 files changed, 103 insertions, 57 deletions
diff --git a/third_party/aom/av1/av1_cx_iface.c b/third_party/aom/av1/av1_cx_iface.c index 3bc4804c9..3295f618a 100644 --- a/third_party/aom/av1/av1_cx_iface.c +++ b/third_party/aom/av1/av1_cx_iface.c @@ -14,28 +14,29 @@ #include "config/aom_config.h" #include "config/aom_version.h" -#include "aom/aom_encoder.h" #include "aom_ports/aom_once.h" +#include "aom_ports/mem_ops.h" #include "aom_ports/system_state.h" + +#include "aom/aom_encoder.h" #include "aom/internal/aom_codec_internal.h" -#include "av1/encoder/encoder.h" -#include "aom/aomcx.h" -#include "av1/encoder/firstpass.h" + #include "av1/av1_iface_common.h" #include "av1/encoder/bitstream.h" -#include "aom_ports/mem_ops.h" +#include "av1/encoder/encoder.h" +#include "av1/encoder/firstpass.h" #define MAG_SIZE (4) #define MAX_NUM_ENHANCEMENT_LAYERS 3 struct av1_extracfg { int cpu_used; // available cpu percentage in 1/16 - int dev_sf; unsigned int enable_auto_alt_ref; unsigned int enable_auto_bwd_ref; unsigned int noise_sensitivity; unsigned int sharpness; unsigned int static_thresh; + unsigned int row_mt; unsigned int tile_columns; // log2 number of tile columns unsigned int tile_rows; // log2 number of tile rows unsigned int arnr_max_frames; @@ -98,37 +99,40 @@ struct av1_extracfg { float noise_level; int noise_block_size; #endif + + unsigned int chroma_subsampling_x; + unsigned int chroma_subsampling_y; }; static struct av1_extracfg default_extra_cfg = { - 0, // cpu_used - 0, // dev_sf - 1, // enable_auto_alt_ref - 0, // enable_auto_bwd_ref - 0, // noise_sensitivity - 0, // sharpness - 0, // static_thresh - 0, // tile_columns - 0, // tile_rows - 7, // arnr_max_frames - 5, // arnr_strength - 0, // min_gf_interval; 0 -> default decision - 0, // max_gf_interval; 0 -> default decision - AOM_TUNE_PSNR, // tuning - 10, // cq_level - 0, // rc_max_intra_bitrate_pct - 0, // rc_max_inter_bitrate_pct - 0, // gf_cbr_boost_pct - 0, // lossless - 1, // enable_cdef - 1, // enable_restoration - 0, // disable_trellis_quant - 0, // enable_qm - DEFAULT_QM_Y, // qm_y - DEFAULT_QM_U, // qm_u - DEFAULT_QM_V, // qm_v - DEFAULT_QM_FIRST, // qm_min - DEFAULT_QM_LAST, // qm_max + 0, // cpu_used + 1, // enable_auto_alt_ref + 0, // enable_auto_bwd_ref + 0, // noise_sensitivity + CONFIG_SHARP_SETTINGS, // sharpness + 0, // static_thresh + 0, // row_mt + 0, // tile_columns + 0, // tile_rows + 7, // arnr_max_frames + 5, // arnr_strength + 0, // min_gf_interval; 0 -> default decision + 0, // max_gf_interval; 0 -> default decision + AOM_TUNE_PSNR, // tuning + 10, // cq_level + 0, // rc_max_intra_bitrate_pct + 0, // rc_max_inter_bitrate_pct + 0, // gf_cbr_boost_pct + 0, // lossless + !CONFIG_SHARP_SETTINGS, // enable_cdef + 1, // enable_restoration + 0, // disable_trellis_quant + 0, // enable_qm + DEFAULT_QM_Y, // qm_y + DEFAULT_QM_U, // qm_u + DEFAULT_QM_V, // qm_v + DEFAULT_QM_FIRST, // qm_min + DEFAULT_QM_LAST, // qm_max #if CONFIG_DIST_8X8 0, #endif @@ -150,7 +154,7 @@ static struct av1_extracfg default_extra_cfg = { 0, // render width 0, // render height AOM_SUPERBLOCK_SIZE_DYNAMIC, // superblock_size - 0, // Single tile decoding is off by default. + 1, // this depends on large_scale_tile. 0, // error_resilient_mode off by default. 0, // s_frame_mode off by default. 0, // film_grain_test_vector @@ -168,6 +172,8 @@ static struct av1_extracfg default_extra_cfg = { 0, // noise_level 32, // noise_block_size #endif + 0, // chroma_subsampling_x + 0, // chroma_subsampling_y }; struct aom_codec_alg_priv { @@ -251,10 +257,7 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx, RANGE_CHECK_HI(extra_cfg, min_gf_interval, MAX_LAG_BUFFERS - 1); RANGE_CHECK_HI(extra_cfg, max_gf_interval, MAX_LAG_BUFFERS - 1); if (extra_cfg->max_gf_interval > 0) { - RANGE_CHECK(extra_cfg, max_gf_interval, 2, (MAX_LAG_BUFFERS - 1)); - } - if (extra_cfg->min_gf_interval > 0 && extra_cfg->max_gf_interval > 0) { - RANGE_CHECK(extra_cfg, max_gf_interval, extra_cfg->min_gf_interval, + RANGE_CHECK(extra_cfg, max_gf_interval, MAX(2, extra_cfg->min_gf_interval), (MAX_LAG_BUFFERS - 1)); } @@ -284,13 +287,14 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx, RANGE_CHECK_HI(extra_cfg, enable_auto_alt_ref, 2); RANGE_CHECK_HI(extra_cfg, enable_auto_bwd_ref, 2); RANGE_CHECK(extra_cfg, cpu_used, 0, 8); - RANGE_CHECK(extra_cfg, dev_sf, 0, UINT8_MAX); RANGE_CHECK_HI(extra_cfg, noise_sensitivity, 6); RANGE_CHECK(extra_cfg, superblock_size, AOM_SUPERBLOCK_SIZE_64X64, AOM_SUPERBLOCK_SIZE_DYNAMIC); RANGE_CHECK_HI(cfg, large_scale_tile, 1); RANGE_CHECK_HI(extra_cfg, single_tile_decoding, 1); + RANGE_CHECK_HI(extra_cfg, row_mt, 1); + RANGE_CHECK_HI(extra_cfg, tile_columns, 6); RANGE_CHECK_HI(extra_cfg, tile_rows, 6); @@ -372,6 +376,9 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx, #endif } + RANGE_CHECK_HI(extra_cfg, chroma_subsampling_x, 1); + RANGE_CHECK_HI(extra_cfg, chroma_subsampling_y, 1); + return AOM_CODEC_OK; } @@ -581,7 +588,6 @@ static aom_codec_err_t set_encoder_config( oxcf->sframe_mode = cfg->sframe_mode; oxcf->sframe_enabled = cfg->sframe_dist != 0; oxcf->speed = extra_cfg->cpu_used; - oxcf->dev_sf = extra_cfg->dev_sf; oxcf->enable_auto_arf = extra_cfg->enable_auto_alt_ref; oxcf->enable_auto_brf = extra_cfg->enable_auto_bwd_ref; oxcf->noise_sensitivity = extra_cfg->noise_sensitivity; @@ -637,6 +643,8 @@ static aom_codec_err_t set_encoder_config( oxcf->superblock_size = AOM_SUPERBLOCK_SIZE_64X64; } + oxcf->row_mt = extra_cfg->row_mt; + oxcf->tile_columns = extra_cfg->tile_columns; oxcf->tile_rows = extra_cfg->tile_rows; @@ -692,6 +700,24 @@ static aom_codec_err_t set_encoder_config( oxcf->frame_periodic_boost = extra_cfg->frame_periodic_boost; oxcf->motion_vector_unit_test = extra_cfg->motion_vector_unit_test; + +#if CONFIG_REDUCED_ENCODER_BORDER + if (oxcf->superres_mode != SUPERRES_NONE || + oxcf->resize_mode != RESIZE_NONE) { + warn( + "Superres / resize cannot be used with CONFIG_REDUCED_ENCODER_BORDER. " + "Disabling superres/resize.\n"); + // return AOM_CODEC_INVALID_PARAM; + disable_superres(oxcf); + oxcf->resize_mode = RESIZE_NONE; + oxcf->resize_scale_denominator = SCALE_NUMERATOR; + oxcf->resize_kf_scale_denominator = SCALE_NUMERATOR; + } +#endif // CONFIG_REDUCED_ENCODER_BORDER + + oxcf->chroma_subsampling_x = extra_cfg->chroma_subsampling_x; + oxcf->chroma_subsampling_y = extra_cfg->chroma_subsampling_y; + return AOM_CODEC_OK; } @@ -731,6 +757,10 @@ static aom_codec_err_t encoder_set_config(aom_codec_alg_priv_t *ctx, return res; } +static aom_fixed_buf_t *encoder_get_global_headers(aom_codec_alg_priv_t *ctx) { + return av1_get_global_headers(ctx->cpi); +} + static aom_codec_err_t ctrl_get_quantizer(aom_codec_alg_priv_t *ctx, va_list args) { int *const arg = va_arg(args, int *); @@ -765,12 +795,6 @@ static aom_codec_err_t ctrl_set_cpuused(aom_codec_alg_priv_t *ctx, return update_extra_cfg(ctx, &extra_cfg); } -static aom_codec_err_t ctrl_set_devsf(aom_codec_alg_priv_t *ctx, va_list args) { - struct av1_extracfg extra_cfg = ctx->extra_cfg; - extra_cfg.dev_sf = CAST(AOME_SET_DEVSF, args); - return update_extra_cfg(ctx, &extra_cfg); -} - static aom_codec_err_t ctrl_set_enable_auto_alt_ref(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; @@ -806,6 +830,13 @@ static aom_codec_err_t ctrl_set_static_thresh(aom_codec_alg_priv_t *ctx, return update_extra_cfg(ctx, &extra_cfg); } +static aom_codec_err_t ctrl_set_row_mt(aom_codec_alg_priv_t *ctx, + va_list args) { + struct av1_extracfg extra_cfg = ctx->extra_cfg; + extra_cfg.row_mt = CAST(AV1E_SET_ROW_MT, args); + return update_extra_cfg(ctx, &extra_cfg); +} + static aom_codec_err_t ctrl_set_tile_columns(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; @@ -1669,6 +1700,20 @@ static aom_codec_err_t ctrl_set_superblock_size(aom_codec_alg_priv_t *ctx, return update_extra_cfg(ctx, &extra_cfg); } +static aom_codec_err_t ctrl_set_chroma_subsampling_x(aom_codec_alg_priv_t *ctx, + va_list args) { + struct av1_extracfg extra_cfg = ctx->extra_cfg; + extra_cfg.chroma_subsampling_x = CAST(AV1E_SET_CHROMA_SUBSAMPLING_X, args); + return update_extra_cfg(ctx, &extra_cfg); +} + +static aom_codec_err_t ctrl_set_chroma_subsampling_y(aom_codec_alg_priv_t *ctx, + va_list args) { + struct av1_extracfg extra_cfg = ctx->extra_cfg; + extra_cfg.chroma_subsampling_y = CAST(AV1E_SET_CHROMA_SUBSAMPLING_Y, args); + return update_extra_cfg(ctx, &extra_cfg); +} + static aom_codec_ctrl_fn_map_t encoder_ctrl_maps[] = { { AV1_COPY_REFERENCE, ctrl_copy_reference }, { AOME_USE_REFERENCE, ctrl_use_reference }, @@ -1681,11 +1726,11 @@ static aom_codec_ctrl_fn_map_t encoder_ctrl_maps[] = { { AOME_SET_SCALEMODE, ctrl_set_scale_mode }, { AOME_SET_SPATIAL_LAYER_ID, ctrl_set_spatial_layer_id }, { AOME_SET_CPUUSED, ctrl_set_cpuused }, - { AOME_SET_DEVSF, ctrl_set_devsf }, { AOME_SET_ENABLEAUTOALTREF, ctrl_set_enable_auto_alt_ref }, { AOME_SET_ENABLEAUTOBWDREF, ctrl_set_enable_auto_bwd_ref }, { AOME_SET_SHARPNESS, ctrl_set_sharpness }, { AOME_SET_STATIC_THRESHOLD, ctrl_set_static_thresh }, + { AV1E_SET_ROW_MT, ctrl_set_row_mt }, { AV1E_SET_TILE_COLUMNS, ctrl_set_tile_columns }, { AV1E_SET_TILE_ROWS, ctrl_set_tile_rows }, { AOME_SET_ARNR_MAXFRAMES, ctrl_set_arnr_max_frames }, @@ -1754,7 +1799,8 @@ static aom_codec_ctrl_fn_map_t encoder_ctrl_maps[] = { { AV1E_GET_ACTIVEMAP, ctrl_get_active_map }, { AV1_GET_NEW_FRAME_IMAGE, ctrl_get_new_frame_image }, { AV1_COPY_NEW_FRAME_IMAGE, ctrl_copy_new_frame_image }, - + { AV1E_SET_CHROMA_SUBSAMPLING_X, ctrl_set_chroma_subsampling_x }, + { AV1E_SET_CHROMA_SUBSAMPLING_Y, ctrl_set_chroma_subsampling_y }, { -1, NULL }, }; @@ -1850,13 +1896,13 @@ CODEC_INTERFACE(aom_codec_av1_cx) = { }, { // NOLINT - 1, // 1 cfg map - encoder_usage_cfg_map, // aom_codec_enc_cfg_map_t - encoder_encode, // aom_codec_encode_fn_t - encoder_get_cxdata, // aom_codec_get_cx_data_fn_t - encoder_set_config, // aom_codec_enc_config_set_fn_t - NULL, // aom_codec_get_global_headers_fn_t - encoder_get_preview, // aom_codec_get_preview_frame_fn_t - NULL // aom_codec_enc_mr_get_mem_loc_fn_t + 1, // 1 cfg map + encoder_usage_cfg_map, // aom_codec_enc_cfg_map_t + encoder_encode, // aom_codec_encode_fn_t + encoder_get_cxdata, // aom_codec_get_cx_data_fn_t + encoder_set_config, // aom_codec_enc_config_set_fn_t + encoder_get_global_headers, // aom_codec_get_global_headers_fn_t + encoder_get_preview, // aom_codec_get_preview_frame_fn_t + NULL // aom_codec_enc_mr_get_mem_loc_fn_t } }; |