[vlc-commits] [Git][videolan/vlc][master] codec: vaapi: handle non preallocated pools
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sat Oct 12 11:23:31 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
a17de886 by François Cartegnie at 2024-10-12T11:09:33+00:00
codec: vaapi: handle non preallocated pools
refs #28817 #28822
On newer ffmpeg, the initial_pool_size might not be set when
querying AVHWFramesContext.
Quoting avcodec_get_hw_frames_parameters()
"If the hwaccel does not require pre-allocation, the field is left to 0,
and the decoder will allocate new surfaces on demand during decoding."
- - - - -
1 changed file:
- modules/codec/avcodec/vaapi.c
Changes:
=====================================
modules/codec/avcodec/vaapi.c
=====================================
@@ -54,6 +54,7 @@ struct vaapi_vctx
VADisplay va_dpy;
AVBufferRef *hwframes_ref;
vlc_sem_t pool_sem;
+ bool dynamic_pool;
};
typedef struct {
@@ -71,7 +72,7 @@ static void vaapi_dec_pic_context_destroy(picture_context_t *context)
av_frame_free(&pic_ctx->avframe);
- if (!pic_ctx->cloned)
+ if (!pic_ctx->cloned && !vaapi_vctx->dynamic_pool)
vlc_sem_post(&vaapi_vctx->pool_sem);
free(pic_ctx);
@@ -105,20 +106,23 @@ static int Get(vlc_va_t *va, picture_t *pic, AVCodecContext *ctx, AVFrame *frame
vlc_video_context_GetPrivate(vctx, VLC_VIDEO_CONTEXT_VAAPI);
/* If all frames are out, wait for a frame to be released. */
- vlc_sem_wait(&vaapi_vctx->pool_sem);
+ if(!vaapi_vctx->dynamic_pool)
+ vlc_sem_wait(&vaapi_vctx->pool_sem);
int ret = av_hwframe_get_buffer(ctx->hw_frames_ctx, frame, 0);
if (ret)
{
msg_Err(va, "vaapi_va: av_hwframe_get_buffer failed: %d\n", ret);
- vlc_sem_post(&vaapi_vctx->pool_sem);
+ if(!vaapi_vctx->dynamic_pool)
+ vlc_sem_post(&vaapi_vctx->pool_sem);
return ret;
}
vaapi_dec_pic_context *vaapi_pic_ctx = malloc(sizeof(*vaapi_pic_ctx));
if (unlikely(vaapi_pic_ctx == NULL))
{
- vlc_sem_post(&vaapi_vctx->pool_sem);
+ if(!vaapi_vctx->dynamic_pool)
+ vlc_sem_post(&vaapi_vctx->pool_sem);
return VLC_ENOMEM;
}
@@ -266,6 +270,7 @@ static int Create(vlc_va_t *va, AVCodecContext *ctx, enum AVPixelFormat hwfmt,
vaapi_vctx->va_dpy = va_dpy;
vaapi_vctx->hwframes_ref = hwframes_ref;
vlc_sem_init(&vaapi_vctx->pool_sem, hwframes_ctx->initial_pool_size);
+ vaapi_vctx->dynamic_pool = hwframes_ctx->initial_pool_size < 1;
msg_Info(va, "Using %s", vaQueryVendorString(va_dpy));
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/a17de8866ce9902a68bad4038a3c8d0a389b3cb1
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/a17de8866ce9902a68bad4038a3c8d0a389b3cb1
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list