Commit aab3940c authored by Steve Lhomme's avatar Steve Lhomme

nvdec: clean CudaCall error check

parent 0dc94770
......@@ -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 )
......
......@@ -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)
{
......
......@@ -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 ||
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment