1
mirror of https://code.videolan.org/videolan/vlc synced 2024-10-03 01:31:53 +02:00

avcodec: video: also store the pic reference in opaque_ref

The future vaapi va module will create AVFrame from hwframes_ctx with a
frame->buf[0] set internally by avcodec. If this is the case, don't
override it and use opaque_ref (an user field) to keep the reference on
the VLC picture_t.
This commit is contained in:
Thomas Guillem 2021-07-09 11:16:21 +02:00
parent 03b9c4bcd9
commit fe63b86f3b

View File

@ -1402,13 +1402,19 @@ static int lavc_va_GetFrame(struct AVCodecContext *ctx, AVFrame *frame)
return -1;
}
frame->buf[0] = av_buffer_create(NULL, 0, lavc_ReleaseFrame, pic, 0);
if (unlikely(frame->buf[0] == NULL))
AVBufferRef *buf = av_buffer_create(NULL, 0, lavc_ReleaseFrame, pic, 0);
if (unlikely(buf == NULL))
{
lavc_ReleaseFrame(pic, NULL);
return -1;
}
/* frame->buf[0] must be valid but can be previously set by the VA module. */
if (frame->buf[0] == NULL)
frame->buf[0] = buf;
else
frame->opaque_ref = buf;
frame->opaque = pic;
return 0;
}