avcodec/d3d12va_decode: check existance before assigning a new index

Fixes #10759.

It can happen in H.264, MPEG2, VC1 that the current frame resource
memory is already in ref_resource. For example, for a interlaced frame,
the same curr memory is passed twice. For the second time it could possibly
reference itself. When this happens the curr is already given an index and
in ref_resources. When the reference frame index is required, we should check
the existance in the ref_resources first before assigning a new index for it.

Signed-off-by: Tong Wu <tong1.wu@intel.com>
This commit is contained in:
Tong Wu 2024-01-11 14:31:20 +08:00 committed by Haihao Xiang
parent ac06190a5a
commit 8b41e9cfbe
1 changed files with 7 additions and 7 deletions

View File

@ -62,14 +62,14 @@ unsigned ff_d3d12va_get_surface_index(const AVCodecContext *avctx,
if (!res)
goto fail;
if (!curr) {
for (i = 0; i < ctx->max_num_ref; i++) {
if (ctx->ref_resources[i] && res == ctx->ref_resources[i]) {
ctx->used_mask |= 1 << i;
return i;
}
for (i = 0; i < ctx->max_num_ref; i++) {
if (ctx->ref_resources[i] && res == ctx->ref_resources[i]) {
ctx->used_mask |= 1 << i;
return i;
}
} else {
}
if (curr) {
for (i = 0; i < ctx->max_num_ref; i++) {
if (!((ctx->used_mask >> i) & 0x1)) {
ctx->ref_resources[i] = res;