MCPcopy Create free account
hub / github.com/Recordscript/recordscript / enc_cfg

Function enc_cfg

libs/scrap/src/common/aom.rs:98–150  ·  view source on GitHub ↗
(
        i: *const aom_codec_iface,
        cfg: AomEncoderConfig,
        i444: bool,
    )

Source from the content-addressed store, hash-verified

96 }
97
98 pub fn enc_cfg(
99 i: *const aom_codec_iface,
100 cfg: AomEncoderConfig,
101 i444: bool,
102 ) -> ResultType<aom_codec_enc_cfg> {
103 let mut c = unsafe { std::mem::MaybeUninit::zeroed().assume_init() };
104 call_aom!(aom_codec_enc_config_default(i, &mut c, kUsageProfile));
105
106 // Overwrite default config with input encoder settings & RTC-relevant values.
107 c.g_w = cfg.width;
108 c.g_h = cfg.height;
109 c.g_threads = codec_thread_num(64) as _;
110 c.g_timebase.num = 1;
111 c.g_timebase.den = kRtpTicksPerSecond;
112 c.g_input_bit_depth = kBitDepth;
113 if let Some(keyframe_interval) = cfg.keyframe_interval {
114 c.kf_min_dist = 0;
115 c.kf_max_dist = keyframe_interval as _;
116 } else {
117 c.kf_mode = aom_kf_mode::AOM_KF_DISABLED;
118 }
119 let (q_min, q_max, b) = AomEncoder::convert_quality(cfg.quality);
120 if q_min > 0 && q_min < q_max && q_max < 64 {
121 c.rc_min_quantizer = q_min;
122 c.rc_max_quantizer = q_max;
123 } else {
124 c.rc_min_quantizer = DEFAULT_Q_MIN;
125 c.rc_max_quantizer = DEFAULT_Q_MAX;
126 }
127 let base_bitrate = base_bitrate(cfg.width as _, cfg.height as _);
128 let bitrate = base_bitrate * b / 100;
129 if bitrate > 0 {
130 c.rc_target_bitrate = bitrate;
131 } else {
132 c.rc_target_bitrate = base_bitrate;
133 }
134 c.rc_undershoot_pct = 50;
135 c.rc_overshoot_pct = 50;
136 c.rc_buf_initial_sz = 600;
137 c.rc_buf_optimal_sz = 600;
138 c.rc_buf_sz = 1000;
139 c.g_usage = kUsageProfile;
140 c.g_error_resilient = 0;
141 // Low-latency settings.
142 c.rc_end_usage = aom_rc_mode::AOM_CBR; // Constant Bit Rate (CBR) mode
143 c.g_pass = aom_enc_pass::AOM_RC_ONE_PASS; // One-pass rate control
144 c.g_lag_in_frames = kLagInFrames; // No look ahead when lag equals 0.
145
146 // https://aomedia.googlesource.com/aom/+/refs/tags/v3.6.0/av1/common/enums.h#82
147 c.g_profile = if i444 { 1 } else { 0 };
148
149 Ok(c)
150 }
151
152 pub fn set_controls(ctx: *mut aom_codec_ctx_t, cfg: &aom_codec_enc_cfg) -> ResultType<()> {
153 use aom_tune_content::*;

Callers 1

newMethod · 0.85

Calls 2

codec_thread_numFunction · 0.85
base_bitrateFunction · 0.85

Tested by

no test coverage detected