diff options
Diffstat (limited to 'video')
35 files changed, 473 insertions, 237 deletions
diff --git a/video/filter/refqueue.c b/video/filter/refqueue.c index f5124087c6..031feb8c96 100644 --- a/video/filter/refqueue.c +++ b/video/filter/refqueue.c @@ -119,10 +119,10 @@ bool mp_refqueue_is_top_field(struct mp_refqueue *q) { if (!mp_refqueue_has_output(q)) return false; - + bool tff = q->field_parity == MP_FIELD_PARITY_TFF; bool bff = q->field_parity == MP_FIELD_PARITY_BFF; - bool ret = (!!(q->queue[q->pos]->fields & MP_IMGFIELD_TOP_FIRST) ^ q->second_field + bool ret = (!!(q->queue[q->pos]->fields & MP_IMGFIELD_TOP_FIRST) ^ q->second_field && !tff && !bff); // Default parity ret = ret || (tff && !q->second_field); // Check if top field is forced ret = ret || (bff && q->second_field); // Check if bottom field is forced diff --git a/video/filter/vf_gpu_vulkan.c b/video/filter/vf_gpu_vulkan.c index 81a84becfa..d477fd153a 100644 --- a/video/filter/vf_gpu_vulkan.c +++ b/video/filter/vf_gpu_vulkan.c @@ -79,7 +79,7 @@ static struct offscreen_ctx *vk_offscreen_ctx_create(struct mpv_global *global, goto error; struct vulkan_opts *vk_opts = mp_get_config_group(NULL, global, &vulkan_conf); - vk->vulkan = mppl_create_vulkan(vk_opts, vk->vkinst, vk->pllog, NULL); + vk->vulkan = mppl_create_vulkan(vk_opts, vk->vkinst, vk->pllog, VK_NULL_HANDLE); talloc_free(vk_opts); if (!vk->vulkan) goto error; diff --git a/video/filter/vf_vapoursynth.c b/video/filter/vf_vapoursynth.c index 0b798c8daf..597ef5cbf2 100644 --- a/video/filter/vf_vapoursynth.c +++ b/video/filter/vf_vapoursynth.c @@ -193,8 +193,9 @@ static void copy_mp_to_vs_frame_props_map(struct priv *p, VSMap *map, p->vsapi->propSetInt(map, "_ColorSpace", pl_system_to_av(params->repr.sys), 0); if (params->chroma_location) { + // 0=left, 1=center, 2=topleft, 3=top, 4=bottomleft, 5=bottom. p->vsapi->propSetInt(map, "_ChromaLocation", - params->chroma_location == PL_CHROMA_CENTER, 0); + params->chroma_location - 1, 0); } char pict_type = 0; switch (img->pict_type) { @@ -208,6 +209,10 @@ static void copy_mp_to_vs_frame_props_map(struct priv *p, VSMap *map, if (img->fields & MP_IMGFIELD_INTERLACED) field = img->fields & MP_IMGFIELD_TOP_FIRST ? 2 : 1; p->vsapi->propSetInt(map, "_FieldBased", field, 0); + + // Don't increase the reference count. It is not intended to be read externally, + // and we know it will be alive when we retrieve it. + p->vsapi->propSetData(map, "_MP_IMAGE", (const char *)img, sizeof(*img), 0); } static int set_vs_frame_props(struct priv *p, VSFrameRef *frame, @@ -230,11 +235,13 @@ static VSFrameRef *alloc_vs_frame(struct priv *p, struct mp_image_params *fmt) } static struct mp_image map_vs_frame(struct priv *p, const VSFrameRef *ref, - bool w) + bool w, struct mp_image *ref_image) { const VSFormat *fmt = p->vsapi->getFrameFormat(ref); struct mp_image img = {0}; + if (ref_image) + img = *ref_image; mp_image_setfmt(&img, mp_from_vs(fmt->id)); mp_image_set_size(&img, p->vsapi->getFrameWidth(ref, 0), p->vsapi->getFrameHeight(ref, 0)); @@ -269,13 +276,19 @@ static void VS_CC vs_frame_done(void *userData, const VSFrameRef *f, int n, struct mp_image *res = NULL; if (f) { - struct mp_image img = map_vs_frame(p, f, false); - struct mp_image dummy = {.params = p->fmt_in}; - if (p->fmt_in.w != img.w || p->fmt_in.h != img.h) - dummy.params.crop = (struct mp_rect){0, 0, img.w, img.h}; - mp_image_copy_attributes(&img, &dummy); - img.pkt_duration = -1; const VSMap *map = p->vsapi->getFramePropsRO(f); + if (!map) + MP_ERR(p, "Failed to get frame properties!"); + struct mp_image *mpi = NULL; + if (map) { + mpi = (void *)p->vsapi->propGetData(map, "_MP_IMAGE", 0, NULL); + if (!mpi) + MP_ERR(p, "Failed to get mp_image attributes!"); + } + struct mp_image img = map_vs_frame(p, f, false, mpi); + img.pkt_duration = -1; + if (mpi && (mpi->params.w != img.w || mpi->params.h != img.h)) + img.params.crop = (struct mp_rect){0, 0, img.w, img.h}; if (map) { int err1, err2; int num = p->vsapi->propGetInt(map, "_DurationNum", 0, &err1); @@ -490,7 +503,7 @@ static const VSFrameRef *VS_CC infiltGetFrame(int frameno, int activationReason, p->vsapi->setFilterError("Could not allocate VS frame", frameCtx); break; } - struct mp_image vsframe = map_vs_frame(p, ret, true); + struct mp_image vsframe = map_vs_frame(p, ret, true, NULL); mp_image_clear(&vsframe, 0, 0, p->fmt_in.w, p->fmt_in.h); struct mp_image dummy = {0}; mp_image_set_params(&dummy, &p->fmt_in); @@ -538,7 +551,7 @@ static const VSFrameRef *VS_CC infiltGetFrame(int frameno, int activationReason, } mp_mutex_unlock(&p->lock); - struct mp_image vsframe = map_vs_frame(p, ret, true); + struct mp_image vsframe = map_vs_frame(p, ret, true, NULL); mp_image_copy(&vsframe, img); int res = 1e6; int dur = img->pkt_duration * res + 0.5; diff --git a/video/image_writer.c b/video/image_writer.c index cc795735ef..3c2d57a80f 100644 --- a/video/image_writer.c +++ b/video/image_writer.c @@ -19,7 +19,6 @@ #include <stdlib.h> #include <string.h> #include <inttypes.h> -#include <unistd.h> #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> @@ -221,7 +220,7 @@ static bool write_lavc(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp } if (avcodec_open2(avctx, codec, NULL) < 0) { - print_open_fail: + print_open_fail: MP_ERR(ctx, "Could not open libavcodec encoder for saving images\n"); goto error_exit; } @@ -261,11 +260,11 @@ error_exit: static void write_jpeg_error_exit(j_common_ptr cinfo) { - // NOTE: do not write error message, too much effort to connect the libjpeg - // log callbacks with mplayer's log function mp_msp() + // NOTE: do not write error message, too much effort to connect the libjpeg + // log callbacks with mplayer's log function mp_msp() - // Return control to the setjmp point - longjmp(*(jmp_buf*)cinfo->client_data, 1); + // Return control to the setjmp point + longjmp(*(jmp_buf*)cinfo->client_data, 1); } static bool write_jpeg(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp) @@ -309,7 +308,7 @@ static bool write_jpeg(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp JSAMPROW row_pointer[1]; row_pointer[0] = image->planes[0] + (ptrdiff_t)cinfo.next_scanline * image->stride[0]; - jpeg_write_scanlines(&cinfo, row_pointer,1); + jpeg_write_scanlines(&cinfo, row_pointer, 1); } jpeg_finish_compress(&cinfo); diff --git a/video/mp_image.c b/video/mp_image.c index 609fb17bf0..35b302d328 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -1116,10 +1116,8 @@ struct mp_image *mp_image_from_av_frame(struct AVFrame *src) sd = av_frame_get_side_data(src, AV_FRAME_DATA_DOVI_RPU_BUFFER); if (sd) { -#ifdef PL_HAVE_LIBDOVI pl_hdr_metadata_from_dovi_rpu(&dst->params.color.hdr, sd->buf->data, sd->buf->size); -#endif } #endif diff --git a/video/out/cocoa_cb_common.swift b/video/out/cocoa_cb_common.swift index 38c47a19a2..b2910dba85 100644 --- a/video/out/cocoa_cb_common.swift +++ b/video/out/cocoa_cb_common.swift @@ -120,7 +120,55 @@ class CocoaCB: Common, EventSubscriber { } libmpv.setRenderICCProfile(colorSpace) - layer?.colorspace = colorSpace.cgColorSpace + layer?.colorspace = getColorSpace() + } + + func getColorSpace() -> CGColorSpace? { + guard let colorSpace = window?.screen?.colorSpace?.cgColorSpace else { + log.warning("Couldn't retrieve ICC Profile, no color space available") + return nil + } + + let outputCsp = Int(option.mac.cocoa_cb_output_csp) + + switch outputCsp { + case MAC_CSP_AUTO: return colorSpace + case MAC_CSP_DISPLAY_P3: return CGColorSpace(name: CGColorSpace.displayP3) + case MAC_CSP_DISPLAY_P3_HLG: return CGColorSpace(name: CGColorSpace.displayP3_HLG) + case MAC_CSP_DISPLAY_P3_PQ: return CGColorSpace(name: CGColorSpace.displayP3_PQ) + case MAC_CSP_DCI_P3: return CGColorSpace(name: CGColorSpace.dcip3) + case MAC_CSP_BT_2020: return CGColorSpace(name: CGColorSpace.itur_2020) + case MAC_CSP_BT_709: return CGColorSpace(name: CGColorSpace.itur_709) + case MAC_CSP_SRGB: return CGColorSpace(name: CGColorSpace.sRGB) + case MAC_CSP_SRGB_LINEAR: return CGColorSpace(name: CGColorSpace.linearSRGB) + case MAC_CSP_RGB_LINEAR: return CGColorSpace(name: CGColorSpace.genericRGBLinear) + case MAC_CSP_ADOBE: return CGColorSpace(name: CGColorSpace.adobeRGB1998) + default: break + } + +#if HAVE_MACOS_11_FEATURES + if #available(macOS 11.0, *) { + switch outputCsp { + case MAC_CSP_BT_2100_HLG: return CGColorSpace(name: CGColorSpace.itur_2100_HLG) + case MAC_CSP_BT_2100_PQ: return CGColorSpace(name: CGColorSpace.itur_2100_PQ) + default: break + } + } +#endif + +#if HAVE_MACOS_12_FEATURES + if #available(macOS 12.0, *) { + switch outputCsp { + case MAC_CSP_DISPLAY_P3_LINEAR: return CGColorSpace(name: CGColorSpace.linearDisplayP3) + case MAC_CSP_BT_2020_LINEAR: return CGColorSpace(name: CGColorSpace.linearITUR_2020) + default: break + } + } +#endif + + log.warning("Couldn't retrieve configured color space, falling back to auto") + + return colorSpace } override func windowDidEndAnimation() { diff --git a/video/out/drm_atomic.c b/video/out/drm_atomic.c index 5754504e98..c1a15fa75f 100644 --- a/video/out/drm_atomic.c +++ b/video/out/drm_atomic.c @@ -43,7 +43,7 @@ int drm_object_create_properties(struct mp_log *log, int fd, return 0; - fail: +fail: drm_object_free_properties(object); return -1; } @@ -68,43 +68,43 @@ void drm_object_free_properties(struct drm_object *object) int drm_object_get_property(struct drm_object *object, char *name, uint64_t *value) { - for (int i = 0; i < object->props->count_props; i++) { - if (strcasecmp(name, object->props_info[i]->name) == 0) { - *value = object->props->prop_values[i]; - return 0; - } - } - - return -EINVAL; + for (int i = 0; i < object->props->count_props; i++) { + if (strcasecmp(name, object->props_info[i]->name) == 0) { + *value = object->props->prop_values[i]; + return 0; + } + } + + return -EINVAL; } drmModePropertyBlobPtr drm_object_get_property_blob(struct drm_object *object, char *name) { - uint64_t blob_id; + uint64_t blob_id; - if (!drm_object_get_property(object, name, &blob_id)) { - return drmModeGetPropertyBlob(object->fd, blob_id); - } + if (!drm_object_get_property(object, name, &blob_id)) { + return drmModeGetPropertyBlob(object->fd, blob_id); + } - return NULL; + return NULL; } int drm_object_set_property(drmModeAtomicReq *request, struct drm_object *object, char *name, uint64_t value) { - for (int i = 0; i < object->props->count_props; i++) { - if (strcasecmp(name, object->props_info[i]->name) == 0) { - if (object->props_info[i]->flags & DRM_MODE_PROP_IMMUTABLE) { - /* Do not try to set immutable values, as this might cause the - * atomic commit operation to fail. */ - return -EINVAL; - } - return drmModeAtomicAddProperty(request, object->id, - object->props_info[i]->prop_id, value); - } - } - - return -EINVAL; + for (int i = 0; i < object->props->count_props; i++) { + if (strcasecmp(name, object->props_info[i]->name) == 0) { + if (object->props_info[i]->flags & DRM_MODE_PROP_IMMUTABLE) { + /* Do not try to set immutable values, as this might cause the + * atomic commit operation to fail. */ + return -EINVAL; + } + return drmModeAtomicAddProperty(request, object->id, + object->props_info[i]->prop_id, value); + } + } + + return -EINVAL; } struct drm_object *drm_object_create(struct mp_log *log, int fd, diff --git a/video/out/drm_common.c b/video/out/drm_common.c index e47de7df86..0f65a8426a 100644 --- a/video/out/drm_common.c +++ b/video/out/drm_common.c @@ -583,7 +583,7 @@ static bool setup_crtc(struct vo_drm_state *drm, const drmModeRes *res) drm->connector->connector_id); return false; - success: +success: MP_VERBOSE(drm, "Selected Encoder %u with CRTC %u\n", drm->encoder->encoder_id, drm->crtc_id); return true; diff --git a/video/out/drm_prime.c b/video/out/drm_prime.c index 9335fa8e02..581eb717bb 100644 --- a/video/out/drm_prime.c +++ b/video/out/drm_prime.c @@ -86,13 +86,13 @@ int drm_prime_create_framebuffer(struct mp_log *log, int fd, for (int plane = 0; plane < AV_DRM_MAX_PLANES; plane++) { drm_prime_add_handle_ref(handle_refs, framebuffer->gem_handles[plane]); } - } + } - return 0; + return 0; fail: - memset(framebuffer, 0, sizeof(*framebuffer)); - return -1; + memset(framebuffer, 0, sizeof(*framebuffer)); + return -1; } void drm_prime_destroy_framebuffer(struct mp_log *log, int fd, @@ -129,9 +129,11 @@ void drm_prime_add_handle_ref(struct drm_prime_handle_refs *handle_refs, { if (handle) { if (handle > handle_refs->size) { - handle_refs->size = handle; MP_TARRAY_GROW(handle_refs->ctx, handle_refs->handle_ref_count, - handle_refs->size); + handle - 1); + uint32_t *p = handle_refs->handle_ref_count; + memset(&p[handle_refs->size], 0, (handle - handle_refs->size) * sizeof(p[0])); + handle_refs->size = handle; } handle_refs->handle_ref_count[handle - 1]++; } diff --git a/video/out/gpu/lcms.h b/video/out/gpu/lcms.h index d0b0fe5b89..30a6c54e83 100644 --- a/video/out/gpu/lcms.h +++ b/video/out/gpu/lcms.h @@ -44,6 +44,8 @@ bool gl_lcms_has_changed(struct gl_lcms *p, enum pl_color_primaries prim, static inline bool gl_parse_3dlut_size(const char *arg, int *p1, int *p2, int *p3) { + if (!arg) + return false; if (!strcmp(arg, "auto")) { *p1 = *p2 = *p3 = 0; return true; diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c index 1478ec4687..4d8e197229 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -965,8 +965,8 @@ static void init_video(struct gl_video *p) static struct dr_buffer *gl_find_dr_buffer(struct gl_video *p, uint8_t *ptr) { - for (int i = 0; i < p->num_dr_buffers; i++) { - struct dr_buffer *buffer = &p->dr_buffers[i]; + for (int i = 0; i < p->num_dr_buffers; i++) { + struct dr_buffer *buffer = &p->dr_buffers[i]; uint8_t *bufptr = buffer->buf->data; size_t size = buffer->buf->params.size; if (ptr >= bufptr && ptr < bufptr + size) diff --git a/video/out/hwdec/dmabuf_interop_wl.c b/video/out/hwdec/dmabuf_interop_wl.c index 606a0aa601..78baf146f0 100644 --- a/video/out/hwdec/dmabuf_interop_wl.c +++ b/video/out/hwdec/dmabuf_interop_wl.c @@ -46,7 +46,7 @@ static bool map(struct ra_hwdec_mapper *mapper, return false; } else if (!ra_compatible_format(mapper->ra, drm_format, mapper_p->desc.objects[0].format_modifier)) { - MP_VERBOSE(mapper, "Mapped surface with format %s; drm format '%s(%016lx)' " + MP_VERBOSE(mapper, "Mapped surface with format %s; drm format '%s(%016" PRIx64 ")' " "is not supported by compositor.\n", mp_imgfmt_to_name(mapper->src->params.hw_subfmt), mp_tag_str(drm_format), @@ -54,7 +54,7 @@ static bool map(struct ra_hwdec_mapper *mapper, return false; } - MP_VERBOSE(mapper, "Supported Wayland display format %s: '%s(%016lx)'\n", + MP_VERBOSE(mapper, "Supported Wayland display format %s: '%s(%016" PRIx64 ")'\n", mp_imgfmt_to_name(mapper->src->params.hw_subfmt), mp_tag_str(drm_format), mapper_p->desc.objects[0].format_modifier); diff --git a/video/out/hwdec/hwdec_cuda.c b/video/out/hwdec/hwdec_cuda.c index 57e4fb40e3..8987cf3407 100644 --- a/video/out/hwdec/hwdec_cuda.c +++ b/video/out/hwdec/hwdec_cuda.c @@ -57,12 +57,12 @@ int check_cu(const struct ra_hwdec *hw, CUresult err, const char *func) #define CHECK_CU(x) check_cu(hw, (x), #x) -static const cuda_interop_init interop_inits[] = { +static const struct cuda_interop_fn *interop_fns[] = { #if HAVE_GL - cuda_gl_init, + &cuda_gl_fn, #endif #if HAVE_VULKAN - cuda_vk_init, + &cuda_vk_fn, #endif NULL }; @@ -73,25 +73,36 @@ static int cuda_init(struct ra_hwdec *hw) CUcontext dummy; int ret = 0; struct cuda_hw_priv *p = hw->priv; - CudaFunctions *cu; + CudaFunctions *cu = NULL; int level = hw->probing ? MSGL_V : MSGL_ERR; - - ret = cuda_load_functions(&p->cu, NULL); - if (ret != 0) { - MP_MSG(hw, level, "Failed to load CUDA symbols\n"); - return -1; - } - cu = p->cu; - - ret = CHECK_CU(cu->cuInit(0)); - if (ret < 0) - return -1; + bool initialized = false; // Initialise CUDA context from backend. - for (int i = 0; interop_inits[i]; i++) { - if (interop_inits[i](hw)) { - break; + // Note that the interop check doesn't require the CUDA backend to be initialized. + // This is important because cuInit wakes up the dgpu (even if the cuda hwdec won't be used!) + // Doing this allows us to check if CUDA should be used without waking up the dgpu, avoiding + // a few seconds of delay and improving battery life for laptops! + for (int i = 0; interop_fns[i]; i++) { + if (!interop_fns[i]->check(hw)) + continue; + + if (!initialized) { + ret = cuda_load_functions(&p->cu, NULL); + if (ret != 0) { + MP_MSG(hw, level, "Failed to load CUDA symbols\n"); + return -1; + } + + cu = p->cu; + ret = CHECK_CU(cu->cuInit(0)); + if (ret < 0) + return -1; + + initialized = true; } + + if (interop_fns[i]->init(hw)) + break; } if (!p->ext_init || !p->ext_uninit) { diff --git a/video/out/hwdec/hwdec_cuda.h b/video/out/hwdec/hwdec_cuda.h index 9c55053d59..6e671b364e 100644 --- a/video/out/hwdec/hwdec_cuda.h +++ b/video/out/hwdec/hwdec_cuda.h @@ -50,10 +50,13 @@ struct cuda_mapper_priv { void *ext[4]; }; -typedef bool (*cuda_interop_init)(const struct ra_hwdec *hw); +struct cuda_interop_fn { + bool (*check)(const struct ra_hwdec *hw); + bool (*init)(const struct ra_hwdec *hw); +}; -bool cuda_gl_init(const struct ra_hwdec *hw); +extern struct cuda_interop_fn cuda_gl_fn; -bool cuda_vk_init(const struct ra_hwdec *hw); +extern struct cuda_interop_fn cuda_vk_fn; int check_cu(const struct ra_hwdec *hw, CUresult err, const char *func); diff --git a/video/out/hwdec/hwdec_cuda_gl.c b/video/out/hwdec/hwdec_cuda_gl.c index f20540ed4d..4c2535232f 100644 --- a/video/out/hwdec/hwdec_cuda_gl.c +++ b/video/out/hwdec/hwdec_cuda_gl.c @@ -25,7 +25,6 @@ #include <libavutil/hwcontext.h> #include <libavutil/hwcontext_cuda.h> -#include <unistd.h> #define CHECK_CU(x) check_cu((mapper)->owner, (x), #x) @@ -106,22 +105,24 @@ static void cuda_ext_gl_uninit(const struct ra_hwdec_mapper *mapper, int n) #undef CHECK_CU #define CHECK_CU(x) check_cu(hw, (x), #x) -bool cuda_gl_init(const struct ra_hwdec *hw) { - int ret = 0; - struct cuda_hw_priv *p = hw->priv; - CudaFunctions *cu = p->cu; +static bool cuda_gl_check(const struct ra_hwdec *hw) { + if (!ra_is_gl(hw->ra_ctx->ra)) + return false; // This is not an OpenGL RA. - if (ra_is_gl(hw->ra_ctx->ra)) { - GL *gl = ra_gl_get(hw->ra_ctx->ra); - if (gl->version < 210 && gl->es < 300) { - MP_VERBOSE(hw, "need OpenGL >= 2.1 or OpenGL-ES >= 3.0\n"); - return false; - } - } else { - // This is not an OpenGL RA. + GL *gl = ra_gl_get(hw->ra_ctx->ra); + if (gl->version < 210 && gl->es < 300) { + MP_VERBOSE(hw, "need OpenGL >= 2.1 or OpenGL-ES >= 3.0\n"); return false; } + return true; +} + +static bool cuda_gl_init(const struct ra_hwdec *hw) { + int ret = 0; + struct cuda_hw_priv *p = hw->priv; + CudaFunctions *cu = p->cu; + CUdevice display_dev; unsigned int device_count; ret = CHECK_CU(cu->cuGLGetDevices(&device_count, &display_dev, 1, @@ -172,3 +173,8 @@ bool cuda_gl_init(const struct ra_hwdec *hw) { return true; } + +struct cuda_interop_fn cuda_gl_fn = { + .check = cuda_gl_check, + .init = cuda_gl_init +}; diff --git a/video/out/hwdec/hwdec_cuda_vk.c b/video/out/hwdec/hwdec_cuda_vk.c index b9f8caa815..e744ff628a 100644 --- a/video/out/hwdec/hwdec_cuda_vk.c +++ b/video/out/hwdec/hwdec_cuda_vk.c @@ -24,7 +24,8 @@ #include <libavutil/hwcontext.h> #include <libavutil/hwcontext_cuda.h> #include <libplacebo/vulkan.h> -#include <unistd.h> + +#include "osdep/io.h" #if HAVE_WIN32_DESKTOP #include <versionhelpers.h> @@ -147,8 +148,8 @@ static bool cuda_ext_vk_init(struct ra_hwdec_mapper *mapper, if (evk->vk_sem.sem == VK_NULL_HANDLE) { ret = -1; goto error; - } - // The returned FD or Handle is owned by the caller (us). + } + // The returned FD or Handle is owned by the caller (us). CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC w_desc = { #if HAVE_WIN32_DESKTOP @@ -233,8 +234,8 @@ static bool cuda_ext_vk_wait(const struct ra_hwdec_mapper *mapper, int n) .value = evk->vk_sem.value } } - }; - ret = CHECK_CU(cu->cuWaitExternalSemaphoresAsync(&evk->cuda_sem, + }; + ret = CHECK_CU(cu->cuWaitExternalSemaphoresAsync(&evk->cuda_sem, &wp, 1, 0)); return ret == 0; } @@ -272,27 +273,30 @@ static bool cuda_ext_vk_signal(const struct ra_hwdec_mapper *mapper, int n) #undef CHECK_CU #define CHECK_CU(x) check_cu(hw, (x), #x) -bool cuda_vk_init(const struct ra_hwdec *hw) { +static bool cuda_vk_check(const struct ra_hwdec *hw) { + pl_gpu gpu = ra_pl_get(hw->ra_ctx->ra); + if (gpu == NULL) + return false; // This is not a Vulkan RA. + + if (!(gpu->export_caps.tex & HANDLE_TYPE)) { + MP_VERBOSE(hw, "CUDA hwdec with Vulkan requires exportable texture memory of type 0x%X.\n", + HANDLE_TYPE); + return false; + } else if (!(gpu->export_caps.sync & HANDLE_TYPE)) { + MP_VERBOSE(hw, "CUDA hwdec with Vulkan requires exportable semaphores of type 0x%X.\n", + HANDLE_TYPE); + return false; + } + + return true; +} + +static bool cuda_vk_init(const struct ra_hwdec *hw) { int ret = 0; int level = hw->probing ? MSGL_V : MSGL_ERR; struct cuda_hw_priv *p = hw->priv; CudaFunctions *cu = p->cu; - pl_gpu gpu = ra_pl_get(hw->ra_ctx->ra); - if (gpu != NULL) { - if (!(gpu->export_caps.tex & HANDLE_TYPE)) { - MP_VERBOSE(hw, "CUDA hwdec with Vulkan requires exportable texture memory of type 0x%X.\n", - HANDLE_TYPE); - return false; - } else if (!(gpu->export_caps.sync & HANDLE_TYPE)) { - MP_VERBOSE(hw, "CUDA hwdec with Vulkan requires exportable semaphores of type 0x%X.\n", - HANDLE_TYPE); - return false; - } - } else { - // This is not a Vulkan RA. - return false; - } if (!cu->cuImportExternalMemory) { MP_MSG(hw, level, "CUDA hwdec with Vulkan requires driver version 410.48 or newer.\n"); @@ -342,3 +346,7 @@ bool cuda_vk_init(const struct ra_hwdec *hw) { return true; } +struct cuda_interop_fn cuda_vk_fn = { + .check = cuda_vk_check, + .init = cuda_vk_init +}; diff --git a/video/out/hwdec/hwdec_drmprime_overlay.c b/video/out/hwdec/hwdec_drmprime_overlay.c index 6b6aae60f0..f5c4b1a4cb 100644 --- a/video/out/hwdec/hwdec_drmprime_overlay.c +++ b/video/out/hwdec/hwdec_drmprime_overlay.c @@ -88,7 +88,7 @@ static void set_current_frame(struct ra_hwdec *hw, struct drm_frame *frame) } } -static void scale_dst_rect(struct ra_hwdec *hw, int source_w, int source_h ,struct mp_rect *src, struct mp_rect *dst) +static void scale_dst_rect(struct ra_hwdec *hw, int source_w, int source_h, struct mp_rect *src, struct mp_rect *dst) { struct priv *p = hw->priv; diff --git a/video/out/hwdec/hwdec_vaapi.c b/video/out/hwdec/hwdec_vaapi.c index 34b6e52b3c..6080ce9e05 100644 --- a/video/out/hwdec/hwdec_vaapi.c +++ b/video/out/hwdec/hwdec_vaapi.c @@ -18,7 +18,6 @@ #include <stddef.h> #include <string.h> #include <assert.h> -#include <unistd.h> #include <libavutil/hwcontext.h> #include <libavutil/hwcontext_vaapi.h> @@ -242,7 +241,7 @@ static int mapper_init(struct ra_hwdec_mapper *mapper) if (mapper->ra->num_formats && !ra_get_imgfmt_desc(mapper->ra, mapper->dst_params.imgfmt, &desc)) - return -1; + return -1; p->num_planes = desc.num_planes; mp_image_set_params(&p->layout, &mapper->dst_params); diff --git a/video/out/mac/common.swift b/video/out/mac/common.swift index 50a508e872..9fd7dbc9ea 100644 --- a/video/out/mac/comm |