mirror of
https://github.com/jojo61/vdr-plugin-softhdcuvid.git
synced 2023-10-10 13:37:41 +02:00
Switch to ffnvcodec headers
This commit is contained in:
parent
04e1b8732d
commit
84501d314e
3
Makefile
3
Makefile
@ -252,7 +252,6 @@ endif
|
|||||||
_CFLAGS += $(shell pkg-config --cflags x11 x11-xcb xcb xcb-icccm)
|
_CFLAGS += $(shell pkg-config --cflags x11 x11-xcb xcb xcb-icccm)
|
||||||
LIBS += -lrt $(shell pkg-config --libs x11 x11-xcb xcb xcb-icccm)
|
LIBS += -lrt $(shell pkg-config --libs x11 x11-xcb xcb xcb-icccm)
|
||||||
|
|
||||||
_CFLAGS += -I/usr/local/cuda/include
|
|
||||||
_CFLAGS += -I./opengl -I./
|
_CFLAGS += -I./opengl -I./
|
||||||
|
|
||||||
LIBS += -L/usr/lib64
|
LIBS += -L/usr/lib64
|
||||||
@ -263,7 +262,7 @@ LIBS += -lplacebo
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CUVID),1)
|
ifeq ($(CUVID),1)
|
||||||
LIBS += -lcuda -L/usr/local/cuda/targets/x86_64-linux/lib -lcudart -lnvcuvid
|
LIBS += -lcuda -lnvcuvid
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LIBS += -lGLEW -lGLU -ldl -lglut
|
LIBS += -lGLEW -lGLU -ldl -lglut
|
||||||
|
@ -17,8 +17,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef __cuda_cuda_h__ // check to see if CUDA_H is included above
|
|
||||||
|
|
||||||
// Error Code string definitions here
|
// Error Code string definitions here
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -453,6 +451,4 @@ static inline const char *getCudaDrvErrorString(CUresult error_id)
|
|||||||
return (const char *)"CUDA_ERROR not found!";
|
return (const char *)"CUDA_ERROR not found!";
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __cuda_cuda_h__
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
53
video.c
53
video.c
@ -132,11 +132,6 @@ typedef enum
|
|||||||
|
|
||||||
#ifdef USE_GLX
|
#ifdef USE_GLX
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
// #include <GL/gl.h> // For GL_COLOR_BUFFER_BIT
|
|
||||||
// #include <GL/glext.h> // For GL_COLOR_BUFFER_BIT
|
|
||||||
// #include <GL/glxew.h>
|
|
||||||
// #include <GL/glx.h>
|
|
||||||
// only for gluErrorString
|
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/freeglut_ext.h>
|
#include <GL/freeglut_ext.h>
|
||||||
@ -146,11 +141,8 @@ typedef enum
|
|||||||
#include <libavutil/pixdesc.h>
|
#include <libavutil/pixdesc.h>
|
||||||
|
|
||||||
#ifdef CUVID
|
#ifdef CUVID
|
||||||
// #include <GL/gl.h> // For GL_COLOR_BUFFER_BIT
|
#include <ffnvcodec/dynlink_cuda.h>
|
||||||
// #include <GL/glext.h> // For GL_COLOR_BUFFER_BIT
|
#include <ffnvcodec/dynlink_loader.h>
|
||||||
#include <cuda.h>
|
|
||||||
#include <cuda_runtime_api.h>
|
|
||||||
#include <cudaGL.h>
|
|
||||||
#include <libavutil/hwcontext_cuda.h>
|
#include <libavutil/hwcontext_cuda.h>
|
||||||
#include "drvapi_error_string.h"
|
#include "drvapi_error_string.h"
|
||||||
#define __DEVICE_TYPES_H__
|
#define __DEVICE_TYPES_H__
|
||||||
@ -1422,6 +1414,7 @@ typedef struct _cuvid_decoder_
|
|||||||
|
|
||||||
static CuvidDecoder *CuvidDecoders[2]; ///< open decoder streams
|
static CuvidDecoder *CuvidDecoders[2]; ///< open decoder streams
|
||||||
static int CuvidDecoderN; ///< number of decoder streams
|
static int CuvidDecoderN; ///< number of decoder streams
|
||||||
|
static CudaFunctions *cu;
|
||||||
|
|
||||||
#ifdef PLACEBO
|
#ifdef PLACEBO
|
||||||
typedef struct priv
|
typedef struct priv
|
||||||
@ -1514,8 +1507,7 @@ int CuvidMessage(int level, const char *format, ...)
|
|||||||
static inline void __checkCudaErrors(CUresult err, const char *file, const int line)
|
static inline void __checkCudaErrors(CUresult err, const char *file, const int line)
|
||||||
{
|
{
|
||||||
if (CUDA_SUCCESS != err) {
|
if (CUDA_SUCCESS != err) {
|
||||||
CuvidMessage(2, "checkCudaErrors() Driver API error = %04d \"%s\" from file <%s>, line %i.\n", err,
|
CuvidMessage(2, "checkCudaErrors() Driver API error = %04d >%s< from file <%s>, line %i.\n", err, getCudaDrvErrorString(err), file, line);
|
||||||
getCudaDrvErrorString(err), file, line);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1592,7 +1584,7 @@ static void CuvidDestroySurfaces(CuvidDecoder * decoder)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#ifdef CUVID
|
#ifdef CUVID
|
||||||
checkCudaErrors(cuGraphicsUnregisterResource(decoder->cu_res[i][j]));
|
checkCudaErrors(cu->cuGraphicsUnregisterResource(decoder->cu_res[i][j]));
|
||||||
#endif
|
#endif
|
||||||
#ifdef VAAPI
|
#ifdef VAAPI
|
||||||
if (decoder->images[i*Planes+j]) {
|
if (decoder->images[i*Planes+j]) {
|
||||||
@ -2209,7 +2201,7 @@ void generateCUDAImage(CuvidDecoder * decoder, int index, const AVFrame * frame,
|
|||||||
.WidthInBytes = image_width * bytes,
|
.WidthInBytes = image_width * bytes,
|
||||||
.Height = n == 0 ? image_height : image_height / 2,
|
.Height = n == 0 ? image_height : image_height / 2,
|
||||||
};
|
};
|
||||||
checkCudaErrors(cuMemcpy2D(&cpy));
|
checkCudaErrors(cu->cuMemcpy2D(&cpy));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2294,7 +2286,7 @@ void createTextureDst(CuvidDecoder * decoder, int anz, unsigned int size_x, unsi
|
|||||||
.size = decoder->pl_images[i].planes[n].texture->shared_mem.size, // image_width * image_height * bytes,
|
.size = decoder->pl_images[i].planes[n].texture->shared_mem.size, // image_width * image_height * bytes,
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
};
|
};
|
||||||
checkCudaErrors(cuImportExternalMemory(&decoder->ebuf[i * 2 + n].mem, &ext_desc)); // Import Memory segment
|
checkCudaErrors(cu->cuImportExternalMemory(&decoder->ebuf[i * 2 + n].mem, &ext_desc)); // Import Memory segment
|
||||||
CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC tex_desc = {
|
CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC tex_desc = {
|
||||||
.offset = decoder->pl_images[i].planes[n].texture->shared_mem.offset,
|
.offset = decoder->pl_images[i].planes[n].texture->shared_mem.offset,
|
||||||
.arrayDesc = {
|
.arrayDesc = {
|
||||||
@ -2307,9 +2299,9 @@ void createTextureDst(CuvidDecoder * decoder, int anz, unsigned int size_x, unsi
|
|||||||
},
|
},
|
||||||
.numLevels = 1,
|
.numLevels = 1,
|
||||||
};
|
};
|
||||||
checkCudaErrors(cuExternalMemoryGetMappedMipmappedArray(&decoder->ebuf[i * 2 + n].mma,
|
checkCudaErrors(cu->cuExternalMemoryGetMappedMipmappedArray(&decoder->ebuf[i * 2 + n].mma,
|
||||||
decoder->ebuf[i * 2 + n].mem, &tex_desc));
|
decoder->ebuf[i * 2 + n].mem, &tex_desc));
|
||||||
checkCudaErrors(cuMipmappedArrayGetLevel(&decoder->cu_array[i][n], decoder->ebuf[i * 2 + n].mma, 0));
|
checkCudaErrors(cu->cuMipmappedArrayGetLevel(&decoder->cu_array[i][n], decoder->ebuf[i * 2 + n].mma, 0));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
// make image
|
// make image
|
||||||
@ -2457,12 +2449,12 @@ void createTextureDst(CuvidDecoder * decoder, int anz, unsigned int size_x, unsi
|
|||||||
SDK_CHECK_ERROR_GL();
|
SDK_CHECK_ERROR_GL();
|
||||||
// register this texture with CUDA
|
// register this texture with CUDA
|
||||||
#ifdef CUVID
|
#ifdef CUVID
|
||||||
checkCudaErrors(cuGraphicsGLRegisterImage(&decoder->cu_res[i][n], decoder->gl_textures[i * Planes + n],
|
checkCudaErrors(cu->cuGraphicsGLRegisterImage(&decoder->cu_res[i][n], decoder->gl_textures[i * Planes + n],
|
||||||
GL_TEXTURE_2D, CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD));
|
GL_TEXTURE_2D, CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD));
|
||||||
checkCudaErrors(cuGraphicsMapResources(1, &decoder->cu_res[i][n], 0));
|
checkCudaErrors(cu->cuGraphicsMapResources(1, &decoder->cu_res[i][n], 0));
|
||||||
checkCudaErrors(cuGraphicsSubResourceGetMappedArray(&decoder->cu_array[i][n], decoder->cu_res[i][n], 0,
|
checkCudaErrors(cu->cuGraphicsSubResourceGetMappedArray(&decoder->cu_array[i][n], decoder->cu_res[i][n], 0,
|
||||||
0));
|
0));
|
||||||
checkCudaErrors(cuGraphicsUnmapResources(1, &decoder->cu_res[i][n], 0));
|
checkCudaErrors(cu->cuGraphicsUnmapResources(1, &decoder->cu_res[i][n], 0));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3093,7 +3085,7 @@ int get_RGB(CuvidDecoder * decoder)
|
|||||||
glDeleteFramebuffers(1, &fb);
|
glDeleteFramebuffers(1, &fb);
|
||||||
glDeleteTextures(1, &texture);
|
glDeleteTextures(1, &texture);
|
||||||
|
|
||||||
#else
|
#else // Placebo
|
||||||
faktorx = (float)width / (float)VideoWindowWidth;
|
faktorx = (float)width / (float)VideoWindowWidth;
|
||||||
faktory = (float)height / (float)VideoWindowHeight;
|
faktory = (float)height / (float)VideoWindowHeight;
|
||||||
fmt = pl_find_named_fmt(p->gpu, "bgra8");
|
fmt = pl_find_named_fmt(p->gpu, "bgra8");
|
||||||
@ -3479,7 +3471,7 @@ Debug(3,"fmt %02d:%02d width %d:%d hight %d:%d\n",decoder->ColorSpace,frame->co
|
|||||||
///
|
///
|
||||||
static void *CuvidGetHwAccelContext(CuvidDecoder * decoder)
|
static void *CuvidGetHwAccelContext(CuvidDecoder * decoder)
|
||||||
{
|
{
|
||||||
unsigned int version;
|
unsigned int version,ret;
|
||||||
|
|
||||||
Debug(3, "Initializing cuvid hwaccel thread ID:%ld\n", (long int)syscall(186));
|
Debug(3, "Initializing cuvid hwaccel thread ID:%ld\n", (long int)syscall(186));
|
||||||
// turn NULL;
|
// turn NULL;
|
||||||
@ -3489,15 +3481,22 @@ static void *CuvidGetHwAccelContext(CuvidDecoder * decoder)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkCudaErrors(cuInit(0));
|
if (!cu) {
|
||||||
|
ret = cuda_load_functions(&cu, NULL);
|
||||||
|
if (ret < 0) {
|
||||||
|
Error(_("Could not dynamically load CUDA\n"));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checkCudaErrors(cu->cuInit(0));
|
||||||
|
|
||||||
checkCudaErrors(cuCtxCreate(&decoder->cuda_ctx, (unsigned int)CU_CTX_SCHED_BLOCKING_SYNC, (CUdevice) 0));
|
checkCudaErrors(cu->cuCtxCreate(&decoder->cuda_ctx, (unsigned int)CU_CTX_SCHED_BLOCKING_SYNC, (CUdevice) 0));
|
||||||
|
|
||||||
if (decoder->cuda_ctx == NULL)
|
if (decoder->cuda_ctx == NULL)
|
||||||
Fatal(_("Kein Cuda device gefunden"));
|
Fatal(_("Kein Cuda device gefunden"));
|
||||||
|
|
||||||
cuCtxGetApiVersion(decoder->cuda_ctx, &version);
|
// cu->cuCtxGetApiVersion(decoder->cuda_ctx, &version);
|
||||||
Debug(3, "***********CUDA API Version %d\n", version);
|
// Debug(3, "***********CUDA API Version %d\n", version);
|
||||||
#endif
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user