ffmpeg: cache swscale contexts instead of re-creating them #118130

Merged
Aras Pranckevicius merged 4 commits from aras_p/blender:ffmpeg_swscale_cache into main 2024-02-15 10:35:13 +01:00

4 Commits

Author SHA1 Message Date
Aras Pranckevicius 7782025ea8 Merge branch 'main' into ffmpeg_swscale_cache
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
2024-02-13 11:16:54 +02:00
Aras Pranckevicius 808be4c910 Format 2024-02-13 11:16:23 +02:00
Aras Pranckevicius 89d5801d6b ffmpeg: ensure swscale context cache does not get too large
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
Do not go above 32 unused contexts being kept alive. When exceeding
that, remove the oldest used ones.
2024-02-13 11:07:59 +02:00
Aras Pranckevicius 0ac48647bb ffmpeg: cache swscale contexts instead of re-creating them
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
ffmpeg's libswscale is used to do RGB<->YUV conversions on movie reading
and writing. The "context" for the scale operation was being created
and destroyed for each movie clip / animation. Now, maintain a cache
of the scale contexts instead.

E.g. in Gold edit, it only ever needs two contexts (one for reading
source movie clips since they are all exactly the same resolution
and format; and one for rendering the resulting movie).

During playback, on some of the "slow" frames (camera cuts) this
saves 10-20ms (Windows, Ryzen 5950X). Rendering whole movie goes
from 390sec to 376sec.
2024-02-12 11:33:54 +02:00