Skip to content

Commit

Permalink
vabackend: Treat surfaceCount == 1 the same as surfaceCount == 0
Browse files Browse the repository at this point in the history
When Chrome(ium) wants dynamic surface allocation it starts with an initial
count of 0, and that is handled today. On the other hand, recent versions of
ffmpeg have switched to preferring dynamic allocation but they start with a
surfaceCount of 1. If we treat this as a legitimate static request, we cannot
do any decoding in practice, as you always need more than 1 surface.

So, treat a surfaceCount of 1 the same as 0, and use our same dynamic
allocation work-around.
  • Loading branch information
philipl committed May 10, 2024
1 parent b810245 commit 8a69f9a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/vabackend.c
Original file line number Diff line number Diff line change
Expand Up @@ -1043,12 +1043,12 @@ static VAStatus nvCreateContext(
cfg->bitDepth = surface->bitDepth;
}

if (drv->surfaceCount == 0 && num_render_targets == 0) {
LOG("0 surfaces have been passed to vaCreateContext, this might cause errors. Setting surface count to 32");
if (drv->surfaceCount <= 1 && num_render_targets == 0) {
LOG("0/1 surfaces have been passed to vaCreateContext, this might cause errors. Setting surface count to 32");
num_render_targets = 32;
}

int surfaceCount = drv->surfaceCount != 0 ? drv->surfaceCount : num_render_targets;
int surfaceCount = drv->surfaceCount > 1 ? drv->surfaceCount : num_render_targets;
if (surfaceCount > 32) {
LOG("Application requested %d surface(s), limiting to 32. This may cause issues.", surfaceCount);
surfaceCount = 32;
Expand Down

0 comments on commit 8a69f9a

Please sign in to comment.