fix(ffmpeg/vulkan): close CBS context in Vulkan encoder teardown - #727
Merged
Merged
Conversation
The Vulkan H.264/H.265/AV1 encoders initialize a CBS context (enc->cbs) during init but never close it in their close functions. This leaks CBS internal state including cloned SPS/VPS/PPS structs (~1 MB for H.264, ~8 MB for H.265 per encoder session). Add ff_cbs_fragment_free() and ff_cbs_close() calls to all three Vulkan encoder close functions.
|
21 tasks
Member
|
Can you submit this patch to FFmpeg as well? |
Contributor
Author
|
I can't create PR's in FFmpeg project, created the issue https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/23794 |
21 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
FFmpeg's Vulkan H.264/H.265/AV1 encoders never call
ff_cbs_close(&enc->cbs)in their close functions, leaking CBS internal state (~1 MB H.264, ~8 MB H.265) per encoder session. This causes unbounded memory growth in applications that repeatedly create/destroy encoder contexts.Fix adds
ff_cbs_fragment_free()andff_cbs_close()to all three Vulkan encoder close functions.Verified with heaptrack:
Issues Fixed or Closed
Type of Change
Checklist
AI Usage