History

hwdec_vaapi: don't jump over variable init in try_format_upload

Kacper Michajłow committed 1 year ago

Commit db70ae61 parent 63e6dfb1 file · +10 −13Browse files

Unified · Split

video/out/hwdec/hwdec_vaapi.c+10−13
@@ -442,19 +442,20 @@ err: · 441 unmodified lines
442442
443443 static bool try_format_upload(void *priv, enum mp_imgfmt src_fmt, enum mp_imgfmt dst_fmt)
444444 {
445− struct priv_owner *p = priv;
446−
447445 if (IMGFMT_IS_HWACCEL(src_fmt))
448446 return true;
449447
450448 bool ret = false;
449+ struct mp_image *src = NULL;
450+ struct mp_image *dst = NULL;
451+ AVBufferRef *hw_pool = NULL;
452+ VADRMPRIMESurfaceDescriptor desc = {0};
451453
452− struct mp_image *src = mp_image_alloc(src_fmt, 16, 16);
453− if (!src)
454+ if (!(src = mp_image_alloc(src_fmt, 16, 16)))
454455 goto end;
455456
456− AVBufferRef *hw_pool = av_hwframe_ctx_alloc(p->ctx->av_device_ref);
457− if (!hw_pool)
457+ struct priv_owner *p = priv;
458+ if (!(hw_pool = av_hwframe_ctx_alloc(p->ctx->av_device_ref)))
458459 goto end;
459460
460461 if (!mp_update_av_hw_frames_pool(&hw_pool, p->ctx->av_device_ref, IMGFMT_VAAPI,
@@ -463,17 +464,13 @@ static bool try_format_upload(void *priv, enum mp_imgfmt src_fmt, enum mp_imgfmt · 2 unmodified lines
463464 goto end;
464465 }
465466
466− struct mp_image *dst = mp_av_pool_image_hw_upload(hw_pool, src);
467− if (!dst)
467+ if (!(dst = mp_av_pool_image_hw_upload(hw_pool, src)))
468468 goto end;
469469
470− VADisplay *display = p->display;
471− VADRMPRIMESurfaceDescriptor desc = {0};
472− VASurfaceID id = va_surface_id(dst);
473−
474470 uint32_t flags = p->dmabuf_interop.composed_layers ?
475471 VA_EXPORT_SURFACE_COMPOSED_LAYERS : VA_EXPORT_SURFACE_SEPARATE_LAYERS;
476− VAStatus status = vaExportSurfaceHandle(display, id, VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2,
472+ VAStatus status = vaExportSurfaceHandle(p->display, va_surface_id(dst),
473+ VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2,
477474 flags | VA_EXPORT_SURFACE_READ_ONLY, &desc);
478475
479476 if (status != VA_STATUS_SUCCESS)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t