Skip to content

Commit

Permalink
hwdec_vaapi: don't jump over variable init in try_format_upload
Browse files Browse the repository at this point in the history
  • Loading branch information
kasper93 committed Dec 10, 2024
1 parent 63e6dfb commit db70ae6
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions video/out/hwdec/hwdec_vaapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,19 +442,20 @@ static void try_format_pixfmt(struct ra_hwdec *hw, enum AVPixelFormat pixfmt)

static bool try_format_upload(void *priv, enum mp_imgfmt src_fmt, enum mp_imgfmt dst_fmt)
{
struct priv_owner *p = priv;

if (IMGFMT_IS_HWACCEL(src_fmt))
return true;

bool ret = false;
struct mp_image *src = NULL;
struct mp_image *dst = NULL;
AVBufferRef *hw_pool = NULL;
VADRMPRIMESurfaceDescriptor desc = {0};

struct mp_image *src = mp_image_alloc(src_fmt, 16, 16);
if (!src)
if (!(src = mp_image_alloc(src_fmt, 16, 16)))
goto end;

AVBufferRef *hw_pool = av_hwframe_ctx_alloc(p->ctx->av_device_ref);
if (!hw_pool)
struct priv_owner *p = priv;
if (!(hw_pool = av_hwframe_ctx_alloc(p->ctx->av_device_ref)))
goto end;

if (!mp_update_av_hw_frames_pool(&hw_pool, p->ctx->av_device_ref, IMGFMT_VAAPI,
Expand All @@ -463,17 +464,13 @@ static bool try_format_upload(void *priv, enum mp_imgfmt src_fmt, enum mp_imgfmt
goto end;
}

struct mp_image *dst = mp_av_pool_image_hw_upload(hw_pool, src);
if (!dst)
if (!(dst = mp_av_pool_image_hw_upload(hw_pool, src)))
goto end;

VADisplay *display = p->display;
VADRMPRIMESurfaceDescriptor desc = {0};
VASurfaceID id = va_surface_id(dst);

uint32_t flags = p->dmabuf_interop.composed_layers ?
VA_EXPORT_SURFACE_COMPOSED_LAYERS : VA_EXPORT_SURFACE_SEPARATE_LAYERS;
VAStatus status = vaExportSurfaceHandle(display, id, VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2,
VAStatus status = vaExportSurfaceHandle(p->display, va_surface_id(dst),
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2,
flags | VA_EXPORT_SURFACE_READ_ONLY, &desc);

if (status != VA_STATUS_SUCCESS)
Expand Down

0 comments on commit db70ae6

Please sign in to comment.