[WIP] VSE: Only free ffmpeg codec context #118112

Draft
Richard Antalik wants to merge 1 commits from iss/blender:ffmpeg-free-1 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.

1 Commits

Author SHA1 Message Date
Richard Antalik 0f392a9a50 [WIP] VSE: Only free ffmpeg codec context
buildbot/vexp-code-patch-lint 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-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
`AVCodecContext` can use a large amount of memory. With large amount of strips
this can add up to 100GB in normal use case. Whole `ImBufAnim` struct was freed
to release memory resources, but penalty for that is, that whole ffmpeg decoding
state had to be re-initialized, which causes delay when decoding after freeing.

Free only `AVCodecContext` struct, to release majority of memory used and
decrease delay when image is decoded after freeing.

Table with experimental data (last 2 columns are improvements over worst case):

|Method			|  Render time	| Mem usage	| Time  |  Mem	|
|-----------------------|---------------|---------------|-------|-------|
|No freeing:		|		|24.5G		|	|1x	|
|Free `ImBufAnim`:	|122.3ms	|		|1x	|	|
|Flush buffers:		|21ms		|18G		|5.8x	|1.36x	|
|Free codecCtx:		|68.8ms		|2.6G		|1.7x	|9.42x	|

For experiment modified gold edit was used.
2024-02-11 20:09:16 +01:00