Rename reserved param aom_codec_enc_config_default Rename the 'reserved' parameter of aom_codec_enc_config_default() to 'usage'. Declare all the usage parameters and struct members to have the unsigned int type for consistency. This eliminates the int cast and the > INT_MAX check in aom_codec_enc_config_default(). Remove the internal type aom_codec_enc_cfg_map_t because its usage field is always set equal to cfg.g_usage. Use aom_codec_enc_cfg_t directly. Change-Id: I65326cfd4851e0980f97e2c1de7699d34c7c5364
diff --git a/aom/aom_encoder.h b/aom/aom_encoder.h index 23019ba..50246b4 100644 --- a/aom/aom_encoder.h +++ b/aom/aom_encoder.h
@@ -973,9 +973,9 @@ aom_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf, \ AOM_ENCODER_ABI_VERSION) -/*!\brief Get a default configuration +/*!\brief Get the default configuration for a usage. * - * Initializes a encoder configuration structure with default values. Supports + * Initializes an encoder configuration structure with default values. Supports * the notion of "usages" so that an algorithm may offer different default * settings depending on the user's intended goal. This function \ref SHOULD * be called by all applications to initialize the configuration structure @@ -983,7 +983,9 @@ * * \param[in] iface Pointer to the algorithm interface to use. * \param[out] cfg Configuration buffer to populate. - * \param[in] reserved Must set to 0. + * \param[in] usage Algorithm specific usage value. For AV1, must be + * set to AOM_USAGE_GOOD_QUALITY (0) or + * AOM_USAGE_REALTIME (1). * * \retval #AOM_CODEC_OK * The configuration was populated. @@ -994,7 +996,7 @@ */ aom_codec_err_t aom_codec_enc_config_default(aom_codec_iface_t *iface, aom_codec_enc_cfg_t *cfg, - unsigned int reserved); + unsigned int usage); /*!\brief Set or change configuration *
diff --git a/aom/internal/aom_codec_internal.h b/aom/internal/aom_codec_internal.h index 21c0dc6..4c43048 100644 --- a/aom/internal/aom_codec_internal.h +++ b/aom/internal/aom_codec_internal.h
@@ -262,21 +262,6 @@ typedef aom_codec_err_t (*aom_codec_enc_mr_get_mem_loc_fn_t)( const aom_codec_enc_cfg_t *cfg, void **mem_loc); -/*!\brief usage configuration mapping - * - * This structure stores the mapping between usage identifiers and - * configuration structures. Each algorithm provides a list of these - * mappings. This list is searched by the aom_codec_enc_config_default() - * wrapper function to determine which config to return. The special value - * {-1, {0}} is used to indicate end-of-list, and must be present. At least - * one mapping must be present, in addition to the end-of-list. - * - */ -typedef const struct aom_codec_enc_cfg_map { - int usage; - aom_codec_enc_cfg_t cfg; -} aom_codec_enc_cfg_map_t; - /*!\brief Decoder algorithm interface interface * * All decoders \ref MUST expose a variable of this type. @@ -297,10 +282,9 @@ aom_codec_set_fb_fn_t set_fb_fn; /**< \copydoc ::aom_codec_set_fb_fn_t */ } dec; struct aom_codec_enc_iface { - int cfg_map_count; - aom_codec_enc_cfg_map_t - *cfg_maps; /**< \copydoc ::aom_codec_enc_cfg_map_t */ - aom_codec_encode_fn_t encode; /**< \copydoc ::aom_codec_encode_fn_t */ + int cfg_count; + const aom_codec_enc_cfg_t *cfgs; /**< \copydoc ::aom_codec_enc_cfg_t */ + aom_codec_encode_fn_t encode; /**< \copydoc ::aom_codec_encode_fn_t */ aom_codec_get_cx_data_fn_t get_cx_data; /**< \copydoc ::aom_codec_get_cx_data_fn_t */ aom_codec_enc_config_set_fn_t
diff --git a/aom/src/aom_encoder.c b/aom/src/aom_encoder.c index 6a4791a..06888c5 100644 --- a/aom/src/aom_encoder.c +++ b/aom/src/aom_encoder.c
@@ -146,23 +146,20 @@ aom_codec_err_t aom_codec_enc_config_default(aom_codec_iface_t *iface, aom_codec_enc_cfg_t *cfg, - unsigned int reserved) { + unsigned int usage) { aom_codec_err_t res; - aom_codec_enc_cfg_map_t *map; int i; - if (!iface || !cfg || reserved > INT_MAX) + if (!iface || !cfg) res = AOM_CODEC_INVALID_PARAM; else if (!(iface->caps & AOM_CODEC_CAP_ENCODER)) res = AOM_CODEC_INCAPABLE; else { res = AOM_CODEC_INVALID_PARAM; - for (i = 0; i < iface->enc.cfg_map_count; ++i) { - map = iface->enc.cfg_maps + i; - if (map->usage == (int)reserved) { - *cfg = map->cfg; - cfg->g_usage = reserved; + for (i = 0; i < iface->enc.cfg_count; ++i) { + if (iface->enc.cfgs[i].g_usage == usage) { + *cfg = iface->enc.cfgs[i]; res = AOM_CODEC_OK; break; }
diff --git a/apps/aomenc.h b/apps/aomenc.h index ba7bf0a..a38258b 100644 --- a/apps/aomenc.h +++ b/apps/aomenc.h
@@ -38,7 +38,7 @@ const struct AvxInterface *codec; int passes; int pass; - int usage; + unsigned int usage; ColorInputType color_type; int quiet; int verbose;
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c index c9515cf..1524249 100644 --- a/av1/av1_cx_iface.c +++ b/av1/av1_cx_iface.c
@@ -2756,149 +2756,147 @@ { -1, NULL }, }; -static aom_codec_enc_cfg_map_t encoder_usage_cfg_map[] = { - { 0, - { - // NOLINT - AOM_USAGE_GOOD_QUALITY, // g_usage - non-realtime usage - 0, // g_threads - 0, // g_profile +static const aom_codec_enc_cfg_t encoder_usage_cfg[] = { + { + // NOLINT + AOM_USAGE_GOOD_QUALITY, // g_usage - non-realtime usage + 0, // g_threads + 0, // g_profile - 320, // g_width - 240, // g_height - 0, // g_limit - 0, // g_forced_max_frame_width - 0, // g_forced_max_frame_height - AOM_BITS_8, // g_bit_depth - 8, // g_input_bit_depth + 320, // g_width + 240, // g_height + 0, // g_limit + 0, // g_forced_max_frame_width + 0, // g_forced_max_frame_height + AOM_BITS_8, // g_bit_depth + 8, // g_input_bit_depth - { 1, 30 }, // g_timebase + { 1, 30 }, // g_timebase - 0, // g_error_resilient + 0, // g_error_resilient - AOM_RC_ONE_PASS, // g_pass + AOM_RC_ONE_PASS, // g_pass - 19, // g_lag_in_frames + 19, // g_lag_in_frames - 0, // rc_dropframe_thresh - RESIZE_NONE, // rc_resize_mode - SCALE_NUMERATOR, // rc_resize_denominator - SCALE_NUMERATOR, // rc_resize_kf_denominator + 0, // rc_dropframe_thresh + RESIZE_NONE, // rc_resize_mode + SCALE_NUMERATOR, // rc_resize_denominator + SCALE_NUMERATOR, // rc_resize_kf_denominator - SUPERRES_NONE, // rc_superres_mode - SCALE_NUMERATOR, // rc_superres_denominator - SCALE_NUMERATOR, // rc_superres_kf_denominator - 63, // rc_superres_qthresh - 32, // rc_superres_kf_qthresh + SUPERRES_NONE, // rc_superres_mode + SCALE_NUMERATOR, // rc_superres_denominator + SCALE_NUMERATOR, // rc_superres_kf_denominator + 63, // rc_superres_qthresh + 32, // rc_superres_kf_qthresh - AOM_VBR, // rc_end_usage - { NULL, 0 }, // rc_twopass_stats_in - { NULL, 0 }, // rc_firstpass_mb_stats_in - 256, // rc_target_bandwidth - 0, // rc_min_quantizer - 63, // rc_max_quantizer - 25, // rc_undershoot_pct - 25, // rc_overshoot_pct + AOM_VBR, // rc_end_usage + { NULL, 0 }, // rc_twopass_stats_in + { NULL, 0 }, // rc_firstpass_mb_stats_in + 256, // rc_target_bandwidth + 0, // rc_min_quantizer + 63, // rc_max_quantizer + 25, // rc_undershoot_pct + 25, // rc_overshoot_pct - 6000, // rc_max_buffer_size - 4000, // rc_buffer_initial_size - 5000, // rc_buffer_optimal_size + 6000, // rc_max_buffer_size + 4000, // rc_buffer_initial_size + 5000, // rc_buffer_optimal_size - 50, // rc_two_pass_vbrbias - 0, // rc_two_pass_vbrmin_section - 2000, // rc_two_pass_vbrmax_section + 50, // rc_two_pass_vbrbias + 0, // rc_two_pass_vbrmin_section + 2000, // rc_two_pass_vbrmax_section - // keyframing settings (kf) - 0, // fwd_kf_enabled - AOM_KF_AUTO, // g_kfmode - 0, // kf_min_dist - 9999, // kf_max_dist - 0, // sframe_dist - 1, // sframe_mode - 0, // large_scale_tile - 0, // monochrome - 0, // full_still_picture_hdr - 0, // save_as_annexb - 0, // tile_width_count - 0, // tile_height_count - { 0 }, // tile_widths - { 0 }, // tile_heights - 0, // use_fixed_qp_offsets - { -1, -1, -1, -1, -1 }, // fixed_qp_offsets - { 0, 128, 128, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // cfg - } }, - { 1, - { - // NOLINT - AOM_USAGE_REALTIME, // g_usage - real-time usage - 0, // g_threads - 0, // g_profile + // keyframing settings (kf) + 0, // fwd_kf_enabled + AOM_KF_AUTO, // g_kfmode + 0, // kf_min_dist + 9999, // kf_max_dist + 0, // sframe_dist + 1, // sframe_mode + 0, // large_scale_tile + 0, // monochrome + 0, // full_still_picture_hdr + 0, // save_as_annexb + 0, // tile_width_count + 0, // tile_height_count + { 0 }, // tile_widths + { 0 }, // tile_heights + 0, // use_fixed_qp_offsets + { -1, -1, -1, -1, -1 }, // fixed_qp_offsets + { 0, 128, 128, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // cfg + }, + { + // NOLINT + AOM_USAGE_REALTIME, // g_usage - real-time usage + 0, // g_threads + 0, // g_profile - 320, // g_width - 240, // g_height - 0, // g_limit - 0, // g_forced_max_frame_width - 0, // g_forced_max_frame_height - AOM_BITS_8, // g_bit_depth - 8, // g_input_bit_depth + 320, // g_width + 240, // g_height + 0, // g_limit + 0, // g_forced_max_frame_width + 0, // g_forced_max_frame_height + AOM_BITS_8, // g_bit_depth + 8, // g_input_bit_depth - { 1, 30 }, // g_timebase + { 1, 30 }, // g_timebase - 0, // g_error_resilient + 0, // g_error_resilient - AOM_RC_ONE_PASS, // g_pass + AOM_RC_ONE_PASS, // g_pass - 1, // g_lag_in_frames + 1, // g_lag_in_frames - 0, // rc_dropframe_thresh - RESIZE_NONE, // rc_resize_mode - SCALE_NUMERATOR, // rc_resize_denominator - SCALE_NUMERATOR, // rc_resize_kf_denominator + 0, // rc_dropframe_thresh + RESIZE_NONE, // rc_resize_mode + SCALE_NUMERATOR, // rc_resize_denominator + SCALE_NUMERATOR, // rc_resize_kf_denominator - 0, // rc_superres_mode - SCALE_NUMERATOR, // rc_superres_denominator - SCALE_NUMERATOR, // rc_superres_kf_denominator - 63, // rc_superres_qthresh - 32, // rc_superres_kf_qthresh + 0, // rc_superres_mode + SCALE_NUMERATOR, // rc_superres_denominator + SCALE_NUMERATOR, // rc_superres_kf_denominator + 63, // rc_superres_qthresh + 32, // rc_superres_kf_qthresh - AOM_CBR, // rc_end_usage - { NULL, 0 }, // rc_twopass_stats_in - { NULL, 0 }, // rc_firstpass_mb_stats_in - 256, // rc_target_bandwidth - 0, // rc_min_quantizer - 63, // rc_max_quantizer - 25, // rc_undershoot_pct - 25, // rc_overshoot_pct + AOM_CBR, // rc_end_usage + { NULL, 0 }, // rc_twopass_stats_in + { NULL, 0 }, // rc_firstpass_mb_stats_in + 256, // rc_target_bandwidth + 0, // rc_min_quantizer + 63, // rc_max_quantizer + 25, // rc_undershoot_pct + 25, // rc_overshoot_pct - 6000, // rc_max_buffer_size - 4000, // rc_buffer_initial_size - 5000, // rc_buffer_optimal_size + 6000, // rc_max_buffer_size + 4000, // rc_buffer_initial_size + 5000, // rc_buffer_optimal_size - 50, // rc_two_pass_vbrbias - 0, // rc_two_pass_vbrmin_section - 2000, // rc_two_pass_vbrmax_section + 50, // rc_two_pass_vbrbias + 0, // rc_two_pass_vbrmin_section + 2000, // rc_two_pass_vbrmax_section - // keyframing settings (kf) - 0, // fwd_kf_enabled - AOM_KF_AUTO, // g_kfmode - 0, // kf_min_dist - 9999, // kf_max_dist - 0, // sframe_dist - 1, // sframe_mode - 0, // large_scale_tile - 0, // monochrome - 0, // full_still_picture_hdr - 0, // save_as_annexb - 0, // tile_width_count - 0, // tile_height_count - { 0 }, // tile_widths - { 0 }, // tile_heights - 0, // use_fixed_qp_offsets - { -1, -1, -1, -1, -1 }, // fixed_qp_offsets - { 0, 128, 128, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // cfg - } }, + // keyframing settings (kf) + 0, // fwd_kf_enabled + AOM_KF_AUTO, // g_kfmode + 0, // kf_min_dist + 9999, // kf_max_dist + 0, // sframe_dist + 1, // sframe_mode + 0, // large_scale_tile + 0, // monochrome + 0, // full_still_picture_hdr + 0, // save_as_annexb + 0, // tile_width_count + 0, // tile_height_count + { 0 }, // tile_widths + { 0 }, // tile_heights + 0, // use_fixed_qp_offsets + { -1, -1, -1, -1, -1 }, // fixed_qp_offsets + { 0, 128, 128, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // cfg + }, }; #ifndef VERSION_STRING @@ -2922,8 +2920,8 @@ }, { // NOLINT - 2, // 2 cfg map - encoder_usage_cfg_map, // aom_codec_enc_cfg_map_t + 2, // 2 cfg + encoder_usage_cfg, // aom_codec_enc_cfg_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
diff --git a/av1/av1_dx_iface.c b/av1/av1_dx_iface.c index be38929..15a9ed2 100644 --- a/av1/av1_dx_iface.c +++ b/av1/av1_dx_iface.c
@@ -1421,7 +1421,7 @@ { // NOLINT 0, - NULL, // aom_codec_enc_cfg_map_t + NULL, // aom_codec_enc_cfg_t NULL, // aom_codec_encode_fn_t NULL, // aom_codec_get_cx_data_fn_t NULL, // aom_codec_enc_config_set_fn_t
diff --git a/test/codec_factory.h b/test/codec_factory.h index 7ba1a01..801b894 100644 --- a/test/codec_factory.h +++ b/test/codec_factory.h
@@ -46,7 +46,7 @@ TwopassStatsStore *stats) const = 0; virtual aom_codec_err_t DefaultEncoderConfig(aom_codec_enc_cfg_t *cfg, - int usage) const = 0; + unsigned int usage) const = 0; }; /* Provide CodecTestWith<n>Params classes for a variable number of parameters @@ -148,7 +148,7 @@ } virtual aom_codec_err_t DefaultEncoderConfig(aom_codec_enc_cfg_t *cfg, - int usage) const { + unsigned int usage) const { #if CONFIG_AV1_ENCODER return aom_codec_enc_config_default(aom_codec_av1_cx(), cfg, usage); #else