gianni-rosato / svt-av1-psy

The Scalable Video Technology for AV1 (SVT-AV1 Encoder and Decoder) with perceptual enhancements for psychovisually optimal AV1 encoding
https://svt-av1-psy.com
BSD 3-Clause Clear License
259 stars 20 forks source link

[BUG] Sigmoidal QM curve for tune 3 seems to be missing parantheses #95

Closed WhitePeter closed 2 weeks ago

WhitePeter commented 2 weeks ago

Just a passerby here. I cannot help but wonder if there are some parentheses missing?

Taking into account operator precedence the formula as it stands now is equivalent to 2 + exp(0.01 * qindex), so the / 1 part is redundant. Having only a passing knowledge about sigmoidal curves I am not sure if it should be 2 / (1 + exp(0.01 * qindex)) but it looks like it.

Originally posted by @WhitePeter in 119dab2


Please see above code comment. If I am mistaken just disregard my post.

gianni-rosato commented 2 weeks ago

Hi there,

Thanks for the issue report. We will look into this as soon as possible.

Clybius commented 2 weeks ago

Hello! Thanks for writing in the bug report, you've got a great eye for spotting this! Will push the fix ASAP into the testing branch.

The following graphs are representations of the functions before/after. The y-axis represents the resulting QM value, and the x-axis represents the given base_qindex.

Previous, incorrect curve. The red line indicates the luma formula, and the orange line indicates the chroma formula. The chroma formula has since been removed due to the introduction of a separate qm param, chroma-qm-min, and its default of 8. Screenshot_20241109_103006

New, updated and correct curve. Screenshot_20241109_103910

Interactive Desmos for learning how qm-min/max interact across qindexes.

For a given CRF before/after this patch, the bitrate may slightly rise (about a 6% increase, will likely vary depending on your source and CRF), though it does seem to improve detail as a result of both the formula change and the slightly increased allocation of bitrate.

If there are any unexpected results, feel free to let us know!

WhitePeter commented 2 weeks ago

Ahh, gotta love open source. Went out for a walk and came back to find this addressed already, on a weekend no less. Great!

gianni-rosato commented 2 weeks ago

Your attention to detail is impressive, I'm surprised this was discovered in the first place! Thank you!

WhitePeter commented 2 weeks ago

Right back at you. If it weren't for the detailed changelog I wouldn't have looked.

BlueSwordM commented 2 weeks ago

@WhitePeter Thanks a lot for the help :)