| 150 | } |
| 151 | |
| 152 | pub fn set_controls(ctx: *mut aom_codec_ctx_t, cfg: &aom_codec_enc_cfg) -> ResultType<()> { |
| 153 | use aom_tune_content::*; |
| 154 | use aome_enc_control_id::*; |
| 155 | macro_rules! call_ctl { |
| 156 | ($ctx:expr, $av1e:expr, $arg:expr) => {{ |
| 157 | call_aom_allow_err!(aom_codec_control($ctx, $av1e as i32, $arg)); |
| 158 | }}; |
| 159 | } |
| 160 | |
| 161 | call_ctl!(ctx, AOME_SET_CPUUSED, get_cpu_speed(cfg.g_w, cfg.g_h)); |
| 162 | call_ctl!(ctx, AV1E_SET_ENABLE_CDEF, 1); |
| 163 | call_ctl!(ctx, AV1E_SET_ENABLE_TPL_MODEL, 0); |
| 164 | call_ctl!(ctx, AV1E_SET_DELTAQ_MODE, 0); |
| 165 | call_ctl!(ctx, AV1E_SET_ENABLE_ORDER_HINT, 0); |
| 166 | call_ctl!(ctx, AV1E_SET_AQ_MODE, 3); |
| 167 | call_ctl!(ctx, AOME_SET_MAX_INTRA_BITRATE_PCT, 300); |
| 168 | call_ctl!(ctx, AV1E_SET_COEFF_COST_UPD_FREQ, 3); |
| 169 | call_ctl!(ctx, AV1E_SET_MODE_COST_UPD_FREQ, 3); |
| 170 | call_ctl!(ctx, AV1E_SET_MV_COST_UPD_FREQ, 3); |
| 171 | // kScreensharing |
| 172 | call_ctl!(ctx, AV1E_SET_TUNE_CONTENT, AOM_CONTENT_SCREEN); |
| 173 | call_ctl!(ctx, AV1E_SET_ENABLE_PALETTE, 1); |
| 174 | let tile_set = if cfg.g_threads == 4 && cfg.g_w == 640 && (cfg.g_h == 360 || cfg.g_h == 480) |
| 175 | { |
| 176 | AV1E_SET_TILE_ROWS |
| 177 | } else { |
| 178 | AV1E_SET_TILE_COLUMNS |
| 179 | }; |
| 180 | // Failed on android |
| 181 | call_ctl!(ctx, tile_set, (cfg.g_threads as f64 * 1.0f64).log2().ceil()); |
| 182 | call_ctl!(ctx, AV1E_SET_ROW_MT, 1); |
| 183 | call_ctl!(ctx, AV1E_SET_ENABLE_OBMC, 0); |
| 184 | call_ctl!(ctx, AV1E_SET_NOISE_SENSITIVITY, 0); |
| 185 | call_ctl!(ctx, AV1E_SET_ENABLE_WARPED_MOTION, 0); |
| 186 | call_ctl!(ctx, AV1E_SET_ENABLE_GLOBAL_MOTION, 0); |
| 187 | call_ctl!(ctx, AV1E_SET_ENABLE_REF_FRAME_MVS, 0); |
| 188 | call_ctl!( |
| 189 | ctx, |
| 190 | AV1E_SET_SUPERBLOCK_SIZE, |
| 191 | get_super_block_size(cfg.g_w, cfg.g_h, cfg.g_threads) |
| 192 | ); |
| 193 | call_ctl!(ctx, AV1E_SET_ENABLE_CFL_INTRA, 0); |
| 194 | call_ctl!(ctx, AV1E_SET_ENABLE_SMOOTH_INTRA, 0); |
| 195 | call_ctl!(ctx, AV1E_SET_ENABLE_ANGLE_DELTA, 0); |
| 196 | call_ctl!(ctx, AV1E_SET_ENABLE_FILTER_INTRA, 0); |
| 197 | call_ctl!(ctx, AV1E_SET_INTRA_DEFAULT_TX_ONLY, 1); |
| 198 | call_ctl!(ctx, AV1E_SET_DISABLE_TRELLIS_QUANT, 1); |
| 199 | call_ctl!(ctx, AV1E_SET_ENABLE_DIST_WTD_COMP, 0); |
| 200 | call_ctl!(ctx, AV1E_SET_ENABLE_DIFF_WTD_COMP, 0); |
| 201 | call_ctl!(ctx, AV1E_SET_ENABLE_DUAL_FILTER, 0); |
| 202 | call_ctl!(ctx, AV1E_SET_ENABLE_INTERINTRA_COMP, 0); |
| 203 | call_ctl!(ctx, AV1E_SET_ENABLE_INTERINTRA_WEDGE, 0); |
| 204 | call_ctl!(ctx, AV1E_SET_ENABLE_INTRA_EDGE_FILTER, 0); |
| 205 | call_ctl!(ctx, AV1E_SET_ENABLE_INTRABC, 0); |
| 206 | call_ctl!(ctx, AV1E_SET_ENABLE_MASKED_COMP, 0); |
| 207 | call_ctl!(ctx, AV1E_SET_ENABLE_PAETH_INTRA, 0); |
| 208 | call_ctl!(ctx, AV1E_SET_ENABLE_QM, 0); |
| 209 | call_ctl!(ctx, AV1E_SET_ENABLE_RECT_PARTITIONS, 0); |