Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Docs/Parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ Do note however, that there is no error checking for duplicate keys and only for
| **PsyBiasQMBias** | --psy-bias-qm-bias | [0-1] | 0 | Increase QM level in frames of higher temporal layer |
| **PsyBiasSharpnessRounding** | --psy-bias-sharpness-rounding | [1-256] | -2 | Quantization rounding [-2: `64` in every `--tune` but `--tune 3`, which is `48`] |
| **PsyBiasOptimizeB** | --psy-bias-optimize-b | [-2,0-2,4] | 0 | Optimize quantization using full distortion calculation. Slow. [0: Disabled, 1: Use slow method to optimize eob, and then proceed with normal optimization, 4: Disable normal optimization, and only use slow method to optimize eob, 2: Disable normal optimization, and use slow method to optimize eob and adjust coefficients, -2: Disable normal optimization] |
| **PsyBiasDG** | --psy-bias-dg | [0-1] | 0 | Psy Bias Dynamic GoP. |
| **TexturePsyBiasOptimizeB** | --texture-psy-bias-optimize-b | [-2,0-2,4] | inherits `--psy-bias-optimize-b` | Optimize quantization using full distortion calculation in low variance region. Using `--texture-variance-thr` |
| **HighQualityEncodePsyBias** | --high-quality-encode-psy-bias | [0-1] | 0 | Bias various features for high quality encoding. Check below for more description. [Default to `1` when `--crf [<= 24.00]`, and either `--lineart-psy-bias` or `--texture-psy-bias` are set; Default to `0` otherwise] |
| **HighFidelityEncodePsyBias** | --high-fidelity-encode-psy-bias | [0-1] | 0 | Bias various features for high fidelity encoding. Check below for more description. [Default to `1` when `--crf [<= 16.00]`, and either `--lineart-psy-bias` or `--texture-psy-bias` are set; Default to `0` otherwise] |
Expand All @@ -142,7 +143,6 @@ Try not to deviate too much from the default threshold, which is `16000` as of e
| :-- | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :-- |
| [global] `--scm 0` | ◯ | ◯ | ◯ | ◯ | ◯ | ◯ | ◯ | Can be overridden |
| [global] `--noise-level-thr` default to `20000` | ✕ | ◯ | ◯ | ◯ | ◯ | ◯ | ◯ | Applied when `--crf [> 30.00]`; Can be overridden |
| [pd] `--startup-mg-size` adjustment | ✕ | ✕ | ✕ | ✕ | ◯ | ◯ | ◯ | Can be overridden |
| [me] `--psy-bias-disable-warped-motion 1` | ✕ | ✕ | ◯ | ◯ | ◯ | ◯ | ◯ | Can be overridden |
| [me] `--psy-bias-disable-me-8x8 1` | ✕ | ✕ | ◯ | ◯ | ◯ | ◯ | ◯ | Can be overridden |
| [rc] `--balancing-q-bias 1` | ◯ | ◯ | ◯ | ◯ | ◯ | ◯ | ◯ | Can be overridden |
Expand Down Expand Up @@ -260,7 +260,6 @@ However, apart from this, both parameters have various features such as boosting

#### `--high-quality-encode-psy-bias` Features

* `--hierarchical-levels`: Default changed from `5` to `4`. Can be overridden.
* `delta_q_res`: Changed `--balancing-q-bias 1`'s default from `4` to `1`.
* `bypass_md_stage_2`: Disabled in `--preset 2` and `1`.
* variance cand elimination (`--texture-psy-bias [>= 3]`): Change it from applying only in frames of higher temporals layers to applying to frames of all temporal levels including base frames.
Expand Down
13 changes: 12 additions & 1 deletion Source/Lib/Codec/pd_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,19 @@ static void calc_mini_gop_activity(

const bool cond3 = MIN(sub_layer_mv_in_out_count1, sub_layer_mv_in_out_count2) > 40 && MAX(sub_layer_mv_in_out_count1, sub_layer_mv_in_out_count2) > 55;

if (cond1 && (cond2 || cond3)) {
// aka: Apparently cplx is incremented when SAD is higher than given threshold
// aka: in_out_count is whether the vectors point towards the centre and NOT whether vectors point outside the screen
// aka: it technically can detect zoom, but in the case of anime, it's very unreliable due to the random lineart vectors.
// aka: TO BE IMPLEMENTED
// aka: Break 32 into 2 16 when top_layer_dist, sub_layer_dist0, and sub_layer_dist1 all bigger than LOW_DIST_TH
// aka: OR either sub_layer_dist0 or sub_layer_dist1 bigger than HIGH_DIST_TH
// aka: CONSIDER further breaking 16 into 2 8 if certain TH is reached
fprintf(stderr, "\n%u / perc_active %u %u %u / cond1 %u\n", enc_ctx->intra_period_position, top_layer_perc_active, sub_layer0_perc_active, sub_layer1_perc_active, cond1);
fprintf(stderr, "%u / dist %llu %llu %llu / perc_cplx %u %u %u / cond2 %u\n", enc_ctx->intra_period_position, top_layer_dist, sub_layer_dist0, sub_layer_dist1,
top_layer_perc_cplx, sub_layer0_perc_cplx, sub_layer1_perc_cplx, cond2);
fprintf(stderr, "%u / mv_in_out_count %d %d %d / cond3 %u\n", enc_ctx->intra_period_position, top_layer_mv_in_out_count, sub_layer_mv_in_out_count1, sub_layer_mv_in_out_count2, cond3);

if (cond1 && (cond2 || cond3)) {
ctx->mini_gop_activity_array[top_layer_idx] = TRUE;
ctx->mini_gop_activity_array[sub_layer_idx0] = FALSE;
ctx->mini_gop_activity_array[sub_layer_idx1] = FALSE;
Expand Down
12 changes: 6 additions & 6 deletions Source/Lib/Globals/enc_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -3967,10 +3967,10 @@ static void set_param_based_on_input(SequenceControlSet *scs)
}

// `-psy-bias`s PD
if (scs->static_config.startup_mg_size == 0) {
if (scs->static_config.lineart_psy_bias >= 5.0)
scs->static_config.startup_mg_size = CLIP3(2, 4, scs->static_config.hierarchical_levels - 1);
}
// if (scs->static_config.startup_mg_size == 0) {
// if (scs->static_config.lineart_psy_bias >= 5.0)
// scs->static_config.startup_mg_size = CLIP3(2, 4, scs->static_config.hierarchical_levels - 1);
// }

// `-psy-bias`s RC
if (scs->static_config.balancing_q_bias == UINT8_DEFAULT) {
Expand Down Expand Up @@ -4865,8 +4865,8 @@ static void copy_api_from_app(
? 4
: 5;

if (scs->static_config.high_quality_encode_psy_bias)
scs->static_config.hierarchical_levels = AOMMIN(scs->static_config.hierarchical_levels, 4);
// if (scs->static_config.high_quality_encode_psy_bias)
// scs->static_config.hierarchical_levels = AOMMIN(scs->static_config.hierarchical_levels, 4);
}
if (scs->static_config.pass == ENC_SINGLE_PASS && scs->static_config.pred_structure == SVT_AV1_PRED_LOW_DELAY_B) {
if (scs->static_config.hierarchical_levels != 2) {
Expand Down