From 5d57e9b1be2d0a60247a3d170b93a81d2c775012 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 26 Sep 2017 18:00:46 +0200 Subject: video: drop old cuda/cuvid hwaccel Just use FFmpeg 3.3 (or whatever it was) to get Cuvid support. --- video/decode/hw_cuda.c | 111 ------------------------------------------------- video/decode/lavc.h | 3 -- video/decode/vd_lavc.c | 9 +--- 3 files changed, 1 insertion(+), 122 deletions(-) delete mode 100644 video/decode/hw_cuda.c (limited to 'video') diff --git a/video/decode/hw_cuda.c b/video/decode/hw_cuda.c deleted file mode 100644 index 64ee08d427..0000000000 --- a/video/decode/hw_cuda.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * This file is part of mpv. - * - * Copyright (c) 2016 Philip Langdale - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -// This define and typedef prevent hwcontext_cuda.h trying to include cuda.h -#define CUDA_VERSION 7050 -typedef void * CUcontext; - -#include -#include - -#include "common/av_common.h" -#include "video/fmt-conversion.h" -#include "video/decode/lavc.h" - -#if !NEW_CUDA_HWACCEL - -static int probe(struct lavc_ctx *ctx, struct vd_lavc_hwdec *hwdec, - const char *codec) -{ - if (!hwdec_devices_load(ctx->hwdec_devs, HWDEC_CUDA)) - return HWDEC_ERR_NO_CTX; - return 0; -} - -static int init(struct lavc_ctx *ctx) -{ - ctx->hwdec_priv = hwdec_devices_get(ctx->hwdec_devs, HWDEC_CUDA); - return 0; -} - -static int init_decoder(struct lavc_ctx *ctx, int w, int h) -{ - AVCodecContext *avctx = ctx->avctx; - struct mp_hwdec_ctx *hwctx = ctx->hwdec_priv; - - MP_VERBOSE(ctx, "Using old cuda API.\n"); - - if (avctx->hw_frames_ctx) { - MP_ERR(ctx, "hw_frames_ctx already initialised!\n"); - return -1; - } - - avctx->hw_frames_ctx = av_hwframe_ctx_alloc(hwctx->av_device_ref); - if (!avctx->hw_frames_ctx) { - MP_ERR(ctx, "av_hwframe_ctx_alloc failed\n"); - goto error; - } - - AVHWFramesContext *hwframe_ctx = (void* )avctx->hw_frames_ctx->data; - hwframe_ctx->format = AV_PIX_FMT_CUDA; - - // This is proper use of the hw_frames_ctx API, but it does not work - // (appaears to work but fails e.g. with 10 bit). The cuvid wrapper - // does non-standard things, and it's a messy situation. This whole - // file is actually used only with older libavcodec versions. - /* - hwframe_ctx->width = w; - hwframe_ctx->height = h; - hwframe_ctx->sw_format = avctx->sw_pix_fmt; - - if (av_hwframe_ctx_init(avctx->hw_frames_ctx) < 0) - goto error; - */ - - return 0; - - error: - av_buffer_unref(&avctx->hw_frames_ctx); - return -1; -} - -static void uninit(struct lavc_ctx *ctx) -{ - ctx->hwdec_priv = NULL; -} - -static struct mp_image *process_image(struct lavc_ctx *ctx, struct mp_image *img) -{ - if (img->imgfmt == IMGFMT_CUDA) - img->params.hw_subfmt = pixfmt2imgfmt(ctx->avctx->sw_pix_fmt); - return img; -} - -const struct vd_lavc_hwdec mp_vd_lavc_cuda_old = { - .type = HWDEC_CUDA, - .image_format = IMGFMT_CUDA, - .lavc_suffix = "_cuvid", - .probe = probe, - .init = init, - .uninit = uninit, - .init_decoder = init_decoder, - .process_image = process_image, -}; - -#endif diff --git a/video/decode/lavc.h b/video/decode/lavc.h index 08d4dc1615..ff819d751b 100644 --- a/video/decode/lavc.h +++ b/video/decode/lavc.h @@ -145,7 +145,4 @@ int hwdec_get_max_refs(struct lavc_ctx *ctx); int hwdec_setup_hw_frames_ctx(struct lavc_ctx *ctx, AVBufferRef *device_ctx, int av_sw_format, int initial_pool_size); -#define NEW_CUDA_HWACCEL \ - (HAVE_CUDA_HWACCEL && LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 94, 100)) - #endif diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index d861ff2182..1275a67300 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -143,7 +143,6 @@ extern const struct vd_lavc_hwdec mp_vd_lavc_dxva2; extern const struct vd_lavc_hwdec mp_vd_lavc_dxva2_copy; extern const struct vd_lavc_hwdec mp_vd_lavc_d3d11va; extern const struct vd_lavc_hwdec mp_vd_lavc_d3d11va_copy; -extern const struct vd_lavc_hwdec mp_vd_lavc_cuda_old; #if HAVE_RPI static const struct vd_lavc_hwdec mp_vd_lavc_rpi = { @@ -166,15 +165,13 @@ static const struct vd_lavc_hwdec mp_vd_lavc_mediacodec = { }; #endif -#if NEW_CUDA_HWACCEL +#if HAVE_CUDA_HWACCEL static const struct vd_lavc_hwdec mp_vd_lavc_cuda = { .type = HWDEC_CUDA, .image_format = IMGFMT_CUDA, .lavc_suffix = "_cuvid", .generic_hwaccel = true, }; -#endif -#if HAVE_CUDA_HWACCEL static const struct vd_lavc_hwdec mp_vd_lavc_cuda_copy = { .type = HWDEC_CUDA_COPY, .lavc_suffix = "_cuvid", @@ -282,11 +279,7 @@ static const struct vd_lavc_hwdec *const hwdec_list[] = { &mp_vd_lavc_mediacodec, #endif #if HAVE_CUDA_HWACCEL - #if NEW_CUDA_HWACCEL &mp_vd_lavc_cuda, - #else - &mp_vd_lavc_cuda_old, - #endif &mp_vd_lavc_cuda_copy, #endif &mp_vd_lavc_crystalhd, -- cgit v1.2.3