mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-16 05:43:54 +03:00
[PR #11435] Use more accurate rounding in GetFixedOutputSize #12897
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/jellyfin/jellyfin/pull/11435
State: closed
Merged: Yes
Changes
The current method of rounding to an integer for calculating output size may suffer from accuracy loss, resulting in the output size not being exact. This used to be a non-issue until we introduced trickplay, which requires the generated images to have an exact width to make tiles.
For example, for a video with a width of 1432 pixels and a required output width of 480 pixels, the calculated
scale * inputWidthwill become479.99999999999994, which is smaller than the requested480. Our logic will then pick the smaller value, which is cast into an integer. The casting simply discards all decimal parts, making it479. Then, in the next part of rounding, we round it to an even number, which makes it smaller and the produced width becomes478.This PR also forces the trickplay manager to generate images with even width because a lot of filters may have trouble sampling a frame with odd width.
Issues
Fixes #11409