vlc | branch: master | Steve Lhomme <[email protected]> | Wed Sep 18 09:57:12 2019 +0200| [aab3940cc426c73399685bb4f1417698bdacf637] | committer: Steve Lhomme
nvdec: clean CudaCall error check > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=aab3940cc426c73399685bb4f1417698bdacf637 --- modules/hw/nvdec/chroma.c | 14 +------------- modules/hw/nvdec/nvdec.c | 19 +++---------------- modules/hw/nvdec/nvdec_fmt.h | 12 ++++++++++++ modules/hw/nvdec/nvdec_gl.c | 18 ++---------------- 4 files changed, 18 insertions(+), 45 deletions(-) diff --git a/modules/hw/nvdec/chroma.c b/modules/hw/nvdec/chroma.c index b963d6602b..e41413dd39 100644 --- a/modules/hw/nvdec/chroma.c +++ b/modules/hw/nvdec/chroma.c @@ -47,19 +47,7 @@ typedef struct vlc_decoder_device *device; } nvdec_filter_sys_t; -static inline int CudaCall(filter_t *p_filter, decoder_device_nvdec_t *devsys, CUresult result, const char *psz_func) -{ - if (unlikely(result != CUDA_SUCCESS)) { - const char *psz_err, *psz_err_str; - devsys->cudaFunctions->cuGetErrorName(result, &psz_err); - devsys->cudaFunctions->cuGetErrorString(result, &psz_err_str); - msg_Err(p_filter, "%s failed: %s (%s)", psz_func, psz_err_str, psz_err); - return VLC_EGENERIC; - } - return VLC_SUCCESS; -} - -#define CALL_CUDA(func, ...) CudaCall(p_filter, devsys, devsys->cudaFunctions->func(__VA_ARGS__), #func) +#define CALL_CUDA(func, ...) CudaCheckErr(VLC_OBJECT(p_filter), devsys->cudaFunctions, devsys->cudaFunctions->func(__VA_ARGS__), #func) static picture_t * FilterCUDAToCPU( filter_t *p_filter, picture_t *src ) diff --git a/modules/hw/nvdec/nvdec.c b/modules/hw/nvdec/nvdec.c index 14651e3a5e..00cab2ed46 100644 --- a/modules/hw/nvdec/nvdec.c +++ b/modules/hw/nvdec/nvdec.c @@ -102,22 +102,9 @@ typedef struct nvdec_ctx { picture_pool_t *out_pool; } nvdec_ctx_t; -static inline int CudaCall(decoder_t *p_dec, CUresult result, const char *psz_func) -{ - if (unlikely(result != CUDA_SUCCESS)) { - const char *psz_err, *psz_err_str; - nvdec_ctx_t *p_sys = p_dec->p_sys; - p_sys->cudaFunctions->cuGetErrorName(result, &psz_err); - p_sys->cudaFunctions->cuGetErrorString(result, &psz_err_str); - msg_Err(p_dec, "%s failed: %s (%s)", psz_func, psz_err_str, psz_err); - return VLC_EGENERIC; - } - return VLC_SUCCESS; -} - -#define CALL_CUDA_DEC(func, ...) CudaCall(p_dec, p_sys->cudaFunctions->func(__VA_ARGS__), #func) -#define CALL_CUDA_DEV(func, ...) CudaCall(device, p_sys->cudaFunctions->func(__VA_ARGS__), #func) -#define CALL_CUVID(func, ...) CudaCall(p_dec, p_sys->cuvidFunctions->func(__VA_ARGS__), #func) +#define CALL_CUDA_DEC(func, ...) CudaCheckErr(VLC_OBJECT(p_dec), p_sys->cudaFunctions, p_sys->cudaFunctions->func(__VA_ARGS__), #func) +#define CALL_CUDA_DEV(func, ...) CudaCheckErr(VLC_OBJECT(device), p_sys->cudaFunctions, p_sys->cudaFunctions->func(__VA_ARGS__), #func) +#define CALL_CUVID(func, ...) CudaCheckErr(VLC_OBJECT(p_dec), p_sys->cudaFunctions, p_sys->cuvidFunctions->func(__VA_ARGS__), #func) static vlc_fourcc_t MapSurfaceChroma(cudaVideoChromaFormat chroma, unsigned bitDepth) { diff --git a/modules/hw/nvdec/nvdec_fmt.h b/modules/hw/nvdec/nvdec_fmt.h index 9ac0bb947a..3db633e2a5 100644 --- a/modules/hw/nvdec/nvdec_fmt.h +++ b/modules/hw/nvdec/nvdec_fmt.h @@ -32,6 +32,18 @@ typedef struct { } decoder_device_nvdec_t; +static inline int CudaCheckErr(vlc_object_t *obj, CudaFunctions *cudaFunctions, CUresult result, const char *psz_func) +{ + if (unlikely(result != CUDA_SUCCESS)) { + const char *psz_err, *psz_err_str; + cudaFunctions->cuGetErrorName(result, &psz_err); + cudaFunctions->cuGetErrorString(result, &psz_err_str); + msg_Err(obj, "%s failed: %s (%s)", psz_func, psz_err_str, psz_err); + return VLC_EGENERIC; + } + return VLC_SUCCESS; +} + static inline bool is_nvdec_opaque(vlc_fourcc_t fourcc) { return fourcc == VLC_CODEC_NVDEC_OPAQUE || diff --git a/modules/hw/nvdec/nvdec_gl.c b/modules/hw/nvdec/nvdec_gl.c index 96fdf801e0..9c16122a3b 100644 --- a/modules/hw/nvdec/nvdec_gl.c +++ b/modules/hw/nvdec/nvdec_gl.c @@ -32,7 +32,7 @@ #include <ffnvcodec/dynlink_loader.h> -#include "../../hw/nvdec/nvdec_fmt.h" +#include "nvdec_fmt.h" #include "../../video_output/opengl/internal.h" #include <GL/glext.h> @@ -56,21 +56,7 @@ typedef struct { CUarray mappedArray[PICTURE_PLANE_MAX]; } converter_sys_t; -static inline int CudaCall(const opengl_tex_converter_t *tc, CUresult result, const char *psz_func) -{ - if (unlikely(result != CUDA_SUCCESS)) { - const char *psz_err, *psz_err_str; - vlc_decoder_device *device = tc->dec_device; - decoder_device_nvdec_t *devsys = device->opaque; - devsys->cudaFunctions->cuGetErrorName(result, &psz_err); - devsys->cudaFunctions->cuGetErrorString(result, &psz_err_str); - msg_Err((vlc_object_t *)&tc->obj, "%s failed: %s (%s)", psz_func, psz_err_str, psz_err); - return VLC_EGENERIC; - } - return VLC_SUCCESS; -} - -#define CALL_CUDA(func, ...) CudaCall(tc, devsys->cudaFunctions->func(__VA_ARGS__), #func) +#define CALL_CUDA(func, ...) CudaCheckErr((vlc_object_t*)&tc->obj, devsys->cudaFunctions, devsys->cudaFunctions->func(__VA_ARGS__), #func) static int tc_nvdec_gl_allocate_texture(const opengl_tex_converter_t *tc, GLuint *textures, const GLsizei *tex_width, const GLsizei *tex_height) _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
