mirror of
https://github.com/jojo61/vdr-plugin-softhdcuvid.git
synced 2023-10-10 13:37:41 +02:00
commit
3de7a17105
38
codec.c
38
codec.c
@ -234,20 +234,6 @@ void CodecVideoOpen(VideoDecoder *decoder, int codec_id) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#ifdef RASPI
|
|
||||||
switch (codec_id) {
|
|
||||||
case AV_CODEC_ID_MPEG2VIDEO:
|
|
||||||
name = "mpeg2_v4l2m2m";
|
|
||||||
break;
|
|
||||||
case AV_CODEC_ID_H264:
|
|
||||||
name = "h264_v4l2m2m";
|
|
||||||
// name = "h264_mmal";
|
|
||||||
break;
|
|
||||||
case AV_CODEC_ID_HEVC:
|
|
||||||
name = "hevc_v4l2m2m";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
if (name && (video_codec = avcodec_find_decoder_by_name(name))) {
|
if (name && (video_codec = avcodec_find_decoder_by_name(name))) {
|
||||||
Debug(3, "codec: decoder found\n");
|
Debug(3, "codec: decoder found\n");
|
||||||
@ -264,16 +250,10 @@ void CodecVideoOpen(VideoDecoder *decoder, int codec_id) {
|
|||||||
Fatal(_("codec: can't allocate video codec context\n"));
|
Fatal(_("codec: can't allocate video codec context\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef RASPI
|
|
||||||
if (!HwDeviceContext) {
|
if (!HwDeviceContext) {
|
||||||
Fatal("codec: no hw device context to be used");
|
Fatal("codec: no hw device context to be used");
|
||||||
}
|
}
|
||||||
decoder->VideoCtx->hw_device_ctx = av_buffer_ref(HwDeviceContext);
|
decoder->VideoCtx->hw_device_ctx = av_buffer_ref(HwDeviceContext);
|
||||||
#else
|
|
||||||
decoder->VideoCtx->pix_fmt = AV_PIX_FMT_DRM_PRIME; /* request a DRM frame */
|
|
||||||
// decoder->VideoCtx->pix_fmt = AV_PIX_FMT_MMAL; /* request a DRM frame
|
|
||||||
//*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// FIXME: for software decoder use all cpus, otherwise 1
|
// FIXME: for software decoder use all cpus, otherwise 1
|
||||||
decoder->VideoCtx->thread_count = 1;
|
decoder->VideoCtx->thread_count = 1;
|
||||||
@ -288,7 +268,7 @@ void CodecVideoOpen(VideoDecoder *decoder, int codec_id) {
|
|||||||
#ifdef YADIF
|
#ifdef YADIF
|
||||||
deint = 2;
|
deint = 2;
|
||||||
#endif
|
#endif
|
||||||
#if defined VAAPI && !defined RASPI
|
#if defined VAAPI
|
||||||
// decoder->VideoCtx->extra_hw_frames = 8; // VIDEO_SURFACES_MAX +1
|
// decoder->VideoCtx->extra_hw_frames = 8; // VIDEO_SURFACES_MAX +1
|
||||||
if (video_codec->capabilities & (AV_CODEC_CAP_AUTO_THREADS)) {
|
if (video_codec->capabilities & (AV_CODEC_CAP_AUTO_THREADS)) {
|
||||||
Debug(3, "codec: auto threads enabled");
|
Debug(3, "codec: auto threads enabled");
|
||||||
@ -319,20 +299,6 @@ void CodecVideoOpen(VideoDecoder *decoder, int codec_id) {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef RASPI
|
|
||||||
decoder->VideoCtx->codec_id = codec_id;
|
|
||||||
decoder->VideoCtx->flags |= AV_CODEC_FLAG_BITEXACT;
|
|
||||||
if (video_codec->capabilities & AV_CODEC_CAP_FRAME_THREADS || AV_CODEC_CAP_SLICE_THREADS) {
|
|
||||||
Debug(3, "codec: supports frame threads");
|
|
||||||
decoder->VideoCtx->thread_count = 4;
|
|
||||||
// decoder->VideoCtx->thread_type |= FF_THREAD_FRAME;
|
|
||||||
}
|
|
||||||
if (video_codec->capabilities & AV_CODEC_CAP_SLICE_THREADS) {
|
|
||||||
Debug(3, "codec: supports slice threads");
|
|
||||||
decoder->VideoCtx->thread_type |= FF_THREAD_SLICE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CUVID
|
#ifdef CUVID
|
||||||
if (strcmp(decoder->VideoCodec->long_name,
|
if (strcmp(decoder->VideoCodec->long_name,
|
||||||
"Nvidia CUVID MPEG2VIDEO decoder") == 0) { // deinterlace for mpeg2 is somehow broken
|
"Nvidia CUVID MPEG2VIDEO decoder") == 0) { // deinterlace for mpeg2 is somehow broken
|
||||||
@ -401,7 +367,7 @@ void CodecVideoOpen(VideoDecoder *decoder, int codec_id) {
|
|||||||
|
|
||||||
// reset buggy ffmpeg/libav flag
|
// reset buggy ffmpeg/libav flag
|
||||||
decoder->GetFormatDone = 0;
|
decoder->GetFormatDone = 0;
|
||||||
#if defined(YADIF) || defined(RASPI)
|
#if defined(YADIF)
|
||||||
decoder->filter = 0;
|
decoder->filter = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
8
drm.c
8
drm.c
@ -206,11 +206,7 @@ static int FindDevice(VideoRender *render) {
|
|||||||
int i, ii = 0;
|
int i, ii = 0;
|
||||||
char connectorstr[10];
|
char connectorstr[10];
|
||||||
int found = 0;
|
int found = 0;
|
||||||
#ifdef RASPI
|
|
||||||
render->fd_drm = open("/dev/dri/card1", O_RDWR);
|
|
||||||
#else
|
|
||||||
render->fd_drm = open("/dev/dri/card0", O_RDWR);
|
render->fd_drm = open("/dev/dri/card0", O_RDWR);
|
||||||
#endif
|
|
||||||
if (render->fd_drm < 0) {
|
if (render->fd_drm < 0) {
|
||||||
fprintf(stderr, "FindDevice: cannot open /dev/dri/card0: %m\n");
|
fprintf(stderr, "FindDevice: cannot open /dev/dri/card0: %m\n");
|
||||||
return -errno;
|
return -errno;
|
||||||
@ -372,11 +368,7 @@ static int FindDevice(VideoRender *render) {
|
|||||||
for (k = 0; k < plane->count_formats; k++) {
|
for (k = 0; k < plane->count_formats; k++) {
|
||||||
if (encoder->possible_crtcs & plane->possible_crtcs) {
|
if (encoder->possible_crtcs & plane->possible_crtcs) {
|
||||||
switch (plane->formats[k]) {
|
switch (plane->formats[k]) {
|
||||||
#ifdef RASPI
|
|
||||||
case DRM_FORMAT_ARGB8888:
|
|
||||||
#else
|
|
||||||
case DRM_FORMAT_XRGB2101010:
|
case DRM_FORMAT_XRGB2101010:
|
||||||
#endif
|
|
||||||
if (!render->video_plane) {
|
if (!render->video_plane) {
|
||||||
render->video_plane = plane->plane_id;
|
render->video_plane = plane->plane_id;
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,8 @@ void ConvertColor(const GLint &colARGB, glm::vec4 &col) {
|
|||||||
#ifdef CUVID
|
#ifdef CUVID
|
||||||
const char *glversion = "#version 330 core ";
|
const char *glversion = "#version 330 core ";
|
||||||
#else
|
#else
|
||||||
#ifdef RASPI
|
|
||||||
const char *glversion = "#version 300 es";
|
|
||||||
#else
|
|
||||||
const char *glversion = "#version 300 es ";
|
const char *glversion = "#version 300 es ";
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
const char *rectVertexShader = "%s\n \
|
const char *rectVertexShader = "%s\n \
|
||||||
\
|
\
|
||||||
|
@ -4,12 +4,8 @@
|
|||||||
#ifdef CUVID
|
#ifdef CUVID
|
||||||
const char *gl_version = "#version 330";
|
const char *gl_version = "#version 330";
|
||||||
#else
|
#else
|
||||||
#ifdef RASPI
|
|
||||||
const char *gl_version = "#version 300 es";
|
|
||||||
#else
|
|
||||||
const char *gl_version = "#version 300 es ";
|
const char *gl_version = "#version 300 es ";
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Color conversion matrix: RGB = m * YUV + c
|
/* Color conversion matrix: RGB = m * YUV + c
|
||||||
* m is in row-major matrix, with m[row][col], e.g.:
|
* m is in row-major matrix, with m[row][col], e.g.:
|
||||||
|
@ -642,33 +642,84 @@ void cSoftOsd::Flush(void) {
|
|||||||
|
|
||||||
#ifdef USE_OPENGLOSD
|
#ifdef USE_OPENGLOSD
|
||||||
|
|
||||||
//Dummy Pixmap for skins
|
// Dummy Pixmap for skins
|
||||||
class cDummyPixmap : public cPixmap {
|
class cDummyPixmap : public cPixmap {
|
||||||
public:
|
public:
|
||||||
cDummyPixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null) : cPixmap(Layer, ViewPort, DrawPort) {}
|
cDummyPixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null)
|
||||||
|
: cPixmap(Layer, ViewPort, DrawPort) {}
|
||||||
virtual ~cDummyPixmap(void) {}
|
virtual ~cDummyPixmap(void) {}
|
||||||
virtual void Clear(void) {}
|
virtual void Clear(void) {}
|
||||||
virtual void Fill(tColor Color) { (void)Color; }
|
virtual void Fill(tColor Color) { (void)Color; }
|
||||||
virtual void DrawImage(const cPoint &Point, const cImage &Image) { (void)Point; (void)Image; }
|
virtual void DrawImage(const cPoint &Point, const cImage &Image) {
|
||||||
virtual void DrawImage(const cPoint &Point, int ImageHandle) { (void)Point; (void)ImageHandle; }
|
(void)Point;
|
||||||
virtual void DrawPixel(const cPoint &Point, tColor Color) { (void)Point; (void)Color; }
|
(void)Image;
|
||||||
virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0, bool Overlay = false) {
|
}
|
||||||
(void) Point; (void)Bitmap; (void)ColorFg; (void)ColorBg; (void)Overlay; }
|
virtual void DrawImage(const cPoint &Point, int ImageHandle) {
|
||||||
virtual void DrawText(const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width = 0, int Height = 0, int Alignment = taDefault) {
|
(void)Point;
|
||||||
(void)Point; (void)s; (void)ColorFg; (void) ColorBg; (void) Font; (void)Width; (void)Height; (void)Alignment; }
|
(void)ImageHandle;
|
||||||
virtual void DrawRectangle(const cRect &Rect, tColor Color) { (void)Rect; (void)Color; }
|
}
|
||||||
virtual void DrawEllipse(const cRect &Rect, tColor Color, int Quadrants = 0) { (void)Rect; (void)Color; (void)Quadrants; }
|
virtual void DrawPixel(const cPoint &Point, tColor Color) {
|
||||||
virtual void DrawSlope(const cRect &Rect, tColor Color, int Type) { (void)Rect; (void)Color; (void)Type; }
|
(void)Point;
|
||||||
virtual void Render(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest) { (void)Pixmap; (void)Source; (void)Dest; }
|
(void)Color;
|
||||||
virtual void Copy(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest) { (void)Pixmap; (void)Source; (void)Dest; }
|
}
|
||||||
virtual void Scroll(const cPoint &Dest, const cRect &Source = cRect::Null) { (void)Dest; (void)Source; }
|
virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0,
|
||||||
virtual void Pan(const cPoint &Dest, const cRect &Source = cRect::Null) { (void)Dest; (void)Source; }
|
bool Overlay = false) {
|
||||||
|
(void)Point;
|
||||||
|
(void)Bitmap;
|
||||||
|
(void)ColorFg;
|
||||||
|
(void)ColorBg;
|
||||||
|
(void)Overlay;
|
||||||
|
}
|
||||||
|
virtual void DrawText(const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font,
|
||||||
|
int Width = 0, int Height = 0, int Alignment = taDefault) {
|
||||||
|
(void)Point;
|
||||||
|
(void)s;
|
||||||
|
(void)ColorFg;
|
||||||
|
(void)ColorBg;
|
||||||
|
(void)Font;
|
||||||
|
(void)Width;
|
||||||
|
(void)Height;
|
||||||
|
(void)Alignment;
|
||||||
|
}
|
||||||
|
virtual void DrawRectangle(const cRect &Rect, tColor Color) {
|
||||||
|
(void)Rect;
|
||||||
|
(void)Color;
|
||||||
|
}
|
||||||
|
virtual void DrawEllipse(const cRect &Rect, tColor Color, int Quadrants = 0) {
|
||||||
|
(void)Rect;
|
||||||
|
(void)Color;
|
||||||
|
(void)Quadrants;
|
||||||
|
}
|
||||||
|
virtual void DrawSlope(const cRect &Rect, tColor Color, int Type) {
|
||||||
|
(void)Rect;
|
||||||
|
(void)Color;
|
||||||
|
(void)Type;
|
||||||
|
}
|
||||||
|
virtual void Render(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest) {
|
||||||
|
(void)Pixmap;
|
||||||
|
(void)Source;
|
||||||
|
(void)Dest;
|
||||||
|
}
|
||||||
|
virtual void Copy(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest) {
|
||||||
|
(void)Pixmap;
|
||||||
|
(void)Source;
|
||||||
|
(void)Dest;
|
||||||
|
}
|
||||||
|
virtual void Scroll(const cPoint &Dest, const cRect &Source = cRect::Null) {
|
||||||
|
(void)Dest;
|
||||||
|
(void)Source;
|
||||||
|
}
|
||||||
|
virtual void Pan(const cPoint &Dest, const cRect &Source = cRect::Null) {
|
||||||
|
(void)Dest;
|
||||||
|
(void)Source;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Dummy OSD for OpenGL OSD if no X Server is available
|
// Dummy OSD for OpenGL OSD if no X Server is available
|
||||||
class cDummyOsd : public cOsd {
|
class cDummyOsd : public cOsd {
|
||||||
private:
|
private:
|
||||||
cDummyPixmap *p;
|
cDummyPixmap *p;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cDummyOsd(int Left, int Top, uint Level) : cOsd(Left, Top, Level) {}
|
cDummyOsd(int Left, int Top, uint Level) : cOsd(Left, Top, Level) {}
|
||||||
virtual ~cDummyOsd() {}
|
virtual ~cDummyOsd() {}
|
||||||
|
102
video.c
102
video.c
@ -155,15 +155,12 @@ typedef enum {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef VAAPI
|
#ifdef VAAPI
|
||||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57,74,100)
|
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 74, 100)
|
||||||
#include <libavcodec/vaapi.h>
|
#include <libavcodec/vaapi.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <libavutil/hwcontext_vaapi.h>
|
||||||
#include <libdrm/drm_fourcc.h>
|
#include <libdrm/drm_fourcc.h>
|
||||||
#include <va/va_drmcommon.h>
|
#include <va/va_drmcommon.h>
|
||||||
#ifdef RASPI
|
|
||||||
#include <libavutil/hwcontext_drm.h>
|
|
||||||
#endif
|
|
||||||
#include <libavutil/hwcontext_vaapi.h>
|
|
||||||
#define TO_AVHW_DEVICE_CTX(x) ((AVHWDeviceContext *)x->data)
|
#define TO_AVHW_DEVICE_CTX(x) ((AVHWDeviceContext *)x->data)
|
||||||
#define TO_AVHW_FRAMES_CTX(x) ((AVHWFramesContext *)x->data)
|
#define TO_AVHW_FRAMES_CTX(x) ((AVHWFramesContext *)x->data)
|
||||||
#define TO_VAAPI_DEVICE_CTX(x) ((AVVAAPIDeviceContext *)TO_AVHW_DEVICE_CTX(x)->hwctx)
|
#define TO_VAAPI_DEVICE_CTX(x) ((AVVAAPIDeviceContext *)TO_AVHW_DEVICE_CTX(x)->hwctx)
|
||||||
@ -341,7 +338,7 @@ typedef struct {
|
|||||||
|
|
||||||
#define NUM_SHADERS 5 // Number of supported user shaders with placebo
|
#define NUM_SHADERS 5 // Number of supported user shaders with placebo
|
||||||
|
|
||||||
#if defined VAAPI && !defined RASPI
|
#if defined VAAPI
|
||||||
#define PIXEL_FORMAT AV_PIX_FMT_VAAPI
|
#define PIXEL_FORMAT AV_PIX_FMT_VAAPI
|
||||||
#define SWAP_BUFFER_SIZE 3
|
#define SWAP_BUFFER_SIZE 3
|
||||||
#endif
|
#endif
|
||||||
@ -349,21 +346,13 @@ typedef struct {
|
|||||||
#define PIXEL_FORMAT AV_PIX_FMT_CUDA
|
#define PIXEL_FORMAT AV_PIX_FMT_CUDA
|
||||||
#define SWAP_BUFFER_SIZE 3
|
#define SWAP_BUFFER_SIZE 3
|
||||||
#endif
|
#endif
|
||||||
#if defined RASPI
|
|
||||||
#define PIXEL_FORMAT AV_PIX_FMT_MMAL
|
|
||||||
#define SWAP_BUFFER_SIZE 3
|
|
||||||
#endif
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// Variables
|
// Variables
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
AVBufferRef *HwDeviceContext; ///< ffmpeg HW device context
|
AVBufferRef *HwDeviceContext; ///< ffmpeg HW device context
|
||||||
char VideoIgnoreRepeatPict; ///< disable repeat pict warning
|
char VideoIgnoreRepeatPict; ///< disable repeat pict warning
|
||||||
|
|
||||||
#ifdef RASPI
|
|
||||||
int Planes = 3;
|
|
||||||
#else
|
|
||||||
int Planes = 2;
|
int Planes = 2;
|
||||||
#endif
|
|
||||||
|
|
||||||
unsigned char *posd;
|
unsigned char *posd;
|
||||||
|
|
||||||
@ -1866,7 +1855,6 @@ static bool create_context_cb(EGLDisplay display, int es_version, EGLContext *ou
|
|||||||
EGL_NONE};
|
EGL_NONE};
|
||||||
EGLint num_configs = 0;
|
EGLint num_configs = 0;
|
||||||
|
|
||||||
#ifndef RASPI
|
|
||||||
attribs = attributes10;
|
attribs = attributes10;
|
||||||
*bpp = 10;
|
*bpp = 10;
|
||||||
if (!eglChooseConfig(display, attributes10, NULL, 0,
|
if (!eglChooseConfig(display, attributes10, NULL, 0,
|
||||||
@ -1879,9 +1867,7 @@ static bool create_context_cb(EGLDisplay display, int es_version, EGLContext *ou
|
|||||||
&num_configs)) { // try 8 Bit
|
&num_configs)) { // try 8 Bit
|
||||||
num_configs = 0;
|
num_configs = 0;
|
||||||
}
|
}
|
||||||
} else
|
} else if (num_configs == 0) {
|
||||||
#endif
|
|
||||||
if (num_configs == 0) {
|
|
||||||
EglCheck();
|
EglCheck();
|
||||||
Debug(3, " 10 Bit egl Failed\n");
|
Debug(3, " 10 Bit egl Failed\n");
|
||||||
attribs = attributes8;
|
attribs = attributes8;
|
||||||
@ -2014,22 +2000,20 @@ static CuvidDecoder *CuvidNewHwDecoder(VideoStream *stream) {
|
|||||||
Fatal("codec: can't allocate HW video codec context err %04x", i);
|
Fatal("codec: can't allocate HW video codec context err %04x", i);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(VAAPI) && !defined(RASPI)
|
#if defined(VAAPI)
|
||||||
// if ((i = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI,
|
// if ((i = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI,
|
||||||
// ":0.0" , NULL, 0)) != 0 ) {
|
// ":0.0" , NULL, 0)) != 0 ) {
|
||||||
if ((i = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI, "/dev/dri/renderD128", NULL, 0)) != 0) {
|
if ((i = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI, "/dev/dri/renderD128", NULL, 0)) != 0) {
|
||||||
Fatal("codec: can't allocate HW video codec context err %04x", i);
|
Fatal("codec: can't allocate HW video codec context err %04x", i);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef RASPI
|
|
||||||
HwDeviceContext = av_buffer_ref(hw_device_ctx);
|
HwDeviceContext = av_buffer_ref(hw_device_ctx);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!(decoder = calloc(1, sizeof(*decoder)))) {
|
if (!(decoder = calloc(1, sizeof(*decoder)))) {
|
||||||
Error(_("video/cuvid: out of memory\n"));
|
Error(_("video/cuvid: out of memory\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#if defined(VAAPI) && !defined(RASPI)
|
#if defined(VAAPI)
|
||||||
VaDisplay = TO_VAAPI_DEVICE_CTX(HwDeviceContext)->display;
|
VaDisplay = TO_VAAPI_DEVICE_CTX(HwDeviceContext)->display;
|
||||||
decoder->VaDisplay = VaDisplay;
|
decoder->VaDisplay = VaDisplay;
|
||||||
#endif
|
#endif
|
||||||
@ -2495,21 +2479,12 @@ void createTextureDst(CuvidDecoder *decoder, int anz, unsigned int size_x, unsig
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
#ifdef RASPI
|
|
||||||
if (PixFmt == AV_PIX_FMT_NV12)
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, n == 0 ? size_x : size_x / 2, n == 0 ? size_y : size_y / 2, 0,
|
|
||||||
GL_RED, GL_UNSIGNED_BYTE, NULL);
|
|
||||||
else
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_R16, n == 0 ? size_x : size_x / 2, n == 0 ? size_y : size_y / 2, 0,
|
|
||||||
GL_RED, GL_UNSIGNED_SHORT, NULL);
|
|
||||||
#else
|
|
||||||
if (PixFmt == AV_PIX_FMT_NV12)
|
if (PixFmt == AV_PIX_FMT_NV12)
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, n == 0 ? GL_R8 : GL_RG8, n == 0 ? size_x : size_x / 2,
|
glTexImage2D(GL_TEXTURE_2D, 0, n == 0 ? GL_R8 : GL_RG8, n == 0 ? size_x : size_x / 2,
|
||||||
n == 0 ? size_y : size_y / 2, 0, n == 0 ? GL_RED : GL_RG, GL_UNSIGNED_BYTE, NULL);
|
n == 0 ? size_y : size_y / 2, 0, n == 0 ? GL_RED : GL_RG, GL_UNSIGNED_BYTE, NULL);
|
||||||
else
|
else
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, n == 0 ? GL_R16 : GL_RG16, n == 0 ? size_x : size_x / 2,
|
glTexImage2D(GL_TEXTURE_2D, 0, n == 0 ? GL_R16 : GL_RG16, n == 0 ? size_x : size_x / 2,
|
||||||
n == 0 ? size_y : size_y / 2, 0, n == 0 ? GL_RED : GL_RG, GL_UNSIGNED_SHORT, NULL);
|
n == 0 ? size_y : size_y / 2, 0, n == 0 ? GL_RED : GL_RG, GL_UNSIGNED_SHORT, NULL);
|
||||||
#endif
|
|
||||||
SDK_CHECK_ERROR_GL();
|
SDK_CHECK_ERROR_GL();
|
||||||
// register this texture with CUDA
|
// register this texture with CUDA
|
||||||
#ifdef CUVID
|
#ifdef CUVID
|
||||||
@ -2555,7 +2530,7 @@ void generateVAAPIImage(CuvidDecoder *decoder, VASurfaceID index, const AVFrame
|
|||||||
|
|
||||||
uint64_t first_time;
|
uint64_t first_time;
|
||||||
|
|
||||||
#if defined(VAAPI) && !defined(RASPI)
|
#if defined(VAAPI)
|
||||||
VADRMPRIMESurfaceDescriptor desc;
|
VADRMPRIMESurfaceDescriptor desc;
|
||||||
|
|
||||||
vaSyncSurface(decoder->VaDisplay, (VASurfaceID)(uintptr_t)frame->data[3]);
|
vaSyncSurface(decoder->VaDisplay, (VASurfaceID)(uintptr_t)frame->data[3]);
|
||||||
@ -2569,12 +2544,6 @@ void generateVAAPIImage(CuvidDecoder *decoder, VASurfaceID index, const AVFrame
|
|||||||
}
|
}
|
||||||
// vaSyncSurface(decoder->VaDisplay, (VASurfaceID) (uintptr_t)
|
// vaSyncSurface(decoder->VaDisplay, (VASurfaceID) (uintptr_t)
|
||||||
// frame->data[3]);
|
// frame->data[3]);
|
||||||
#endif
|
|
||||||
#ifdef RASPI
|
|
||||||
AVDRMFrameDescriptor desc;
|
|
||||||
|
|
||||||
memcpy(&desc, frame->data[0], sizeof(desc));
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, eglSharedContext);
|
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, eglSharedContext);
|
||||||
@ -2585,7 +2554,7 @@ void generateVAAPIImage(CuvidDecoder *decoder, VASurfaceID index, const AVFrame
|
|||||||
uint num_attribs = 0;
|
uint num_attribs = 0;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
#if defined(VAAPI) && !defined(RASPI)
|
#if defined(VAAPI)
|
||||||
ADD_ATTRIB(EGL_LINUX_DRM_FOURCC_EXT, desc.layers[n].drm_format);
|
ADD_ATTRIB(EGL_LINUX_DRM_FOURCC_EXT, desc.layers[n].drm_format);
|
||||||
ADD_ATTRIB(EGL_WIDTH, n == 0 ? image_width : image_width / 2);
|
ADD_ATTRIB(EGL_WIDTH, n == 0 ? image_width : image_width / 2);
|
||||||
ADD_ATTRIB(EGL_HEIGHT, n == 0 ? image_height : image_height / 2);
|
ADD_ATTRIB(EGL_HEIGHT, n == 0 ? image_height : image_height / 2);
|
||||||
@ -3060,18 +3029,10 @@ int get_RGB(CuvidDecoder *decoder) {
|
|||||||
glUniform1i(texLoc, 0);
|
glUniform1i(texLoc, 0);
|
||||||
texLoc = glGetUniformLocation(gl_prog, "texture1");
|
texLoc = glGetUniformLocation(gl_prog, "texture1");
|
||||||
glUniform1i(texLoc, 1);
|
glUniform1i(texLoc, 1);
|
||||||
#ifdef RASPI
|
|
||||||
texLoc = glGetUniformLocation(gl_prog, "texture2");
|
|
||||||
glUniform1i(texLoc, 2);
|
|
||||||
#endif
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 0]);
|
glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 0]);
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 1]);
|
glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 1]);
|
||||||
#ifdef RASPI
|
|
||||||
glActiveTexture(GL_TEXTURE2);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 2]);
|
|
||||||
#endif
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, fb);
|
glBindFramebuffer(GL_FRAMEBUFFER, fb);
|
||||||
|
|
||||||
render_pass_quad(1, 0.0, 0.0);
|
render_pass_quad(1, 0.0, 0.0);
|
||||||
@ -3124,7 +3085,7 @@ int get_RGB(CuvidDecoder *decoder) {
|
|||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
}
|
}
|
||||||
glFlush();
|
glFlush();
|
||||||
//Debug(3, "Read pixels %d %d\n", width, height);
|
// Debug(3, "Read pixels %d %d\n", width, height);
|
||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||||
@ -3499,34 +3460,12 @@ static void CuvidRenderFrame(CuvidDecoder *decoder, const AVCodecContext *video_
|
|||||||
if (frame->color_trc == AVCOL_TRC_RESERVED0) // cuvid decoder failure with SD channels
|
if (frame->color_trc == AVCOL_TRC_RESERVED0) // cuvid decoder failure with SD channels
|
||||||
frame->color_trc = AVCOL_TRC_SMPTE170M;
|
frame->color_trc = AVCOL_TRC_SMPTE170M;
|
||||||
|
|
||||||
// printf("Patched colorspace %d Primaries %d TRC
|
// printf("Patched colorspace %d Primaries %d TRC
|
||||||
// %d\n",frame->colorspace,frame->color_primaries,frame->color_trc);
|
// %d\n",frame->colorspace,frame->color_primaries,frame->color_trc);
|
||||||
#ifdef RASPI
|
|
||||||
//
|
|
||||||
// Check image, format, size
|
|
||||||
//
|
|
||||||
if ( // decoder->PixFmt != video_ctx->pix_fmt
|
|
||||||
video_ctx->width != decoder->InputWidth
|
|
||||||
// || decoder->ColorSpace != color
|
|
||||||
|| video_ctx->height != decoder->InputHeight) {
|
|
||||||
Debug(3, "fmt %02d:%02d width %d:%d hight %d:%d\n", decoder->ColorSpace, frame->colorspace, video_ctx->width,
|
|
||||||
decoder->InputWidth, video_ctx->height, decoder->InputHeight);
|
|
||||||
decoder->PixFmt = AV_PIX_FMT_NV12;
|
|
||||||
decoder->InputWidth = video_ctx->width;
|
|
||||||
decoder->InputHeight = video_ctx->height;
|
|
||||||
CuvidCleanup(decoder);
|
|
||||||
decoder->SurfacesNeeded = VIDEO_SURFACES_MAX + 1;
|
|
||||||
CuvidSetupOutput(decoder);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
//
|
//
|
||||||
// Copy data from frame to image
|
// Copy data from frame to image
|
||||||
//
|
//
|
||||||
#ifdef RASPI
|
|
||||||
if (video_ctx->pix_fmt == 0) {
|
|
||||||
#else
|
|
||||||
if (video_ctx->pix_fmt == PIXEL_FORMAT) {
|
if (video_ctx->pix_fmt == PIXEL_FORMAT) {
|
||||||
#endif
|
|
||||||
int w = decoder->InputWidth;
|
int w = decoder->InputWidth;
|
||||||
int h = decoder->InputHeight;
|
int h = decoder->InputHeight;
|
||||||
|
|
||||||
@ -3821,19 +3760,11 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev
|
|||||||
glUniform1i(texLoc, 0);
|
glUniform1i(texLoc, 0);
|
||||||
texLoc = glGetUniformLocation(gl_prog, "texture1");
|
texLoc = glGetUniformLocation(gl_prog, "texture1");
|
||||||
glUniform1i(texLoc, 1);
|
glUniform1i(texLoc, 1);
|
||||||
#ifdef RASPI
|
|
||||||
texLoc = glGetUniformLocation(gl_prog, "texture2");
|
|
||||||
glUniform1i(texLoc, 2);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 0]);
|
glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 0]);
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 1]);
|
glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 1]);
|
||||||
#ifdef RASPI
|
|
||||||
glActiveTexture(GL_TEXTURE2);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 2]);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
render_pass_quad(0, xcropf, ycropf);
|
render_pass_quad(0, xcropf, ycropf);
|
||||||
|
|
||||||
@ -7022,14 +6953,13 @@ void VideoInit(const char *display_name) {
|
|||||||
if (!display_name && !(display_name = getenv("DISPLAY"))) {
|
if (!display_name && !(display_name = getenv("DISPLAY"))) {
|
||||||
// if no environment variable, use :0.0 as default display name
|
// if no environment variable, use :0.0 as default display name
|
||||||
display_name = ":0.0";
|
display_name = ":0.0";
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!getenv("DISPLAY")) {
|
if (!getenv("DISPLAY")) {
|
||||||
//force set DISPLAY environment variable, otherwise nvidia driver
|
// force set DISPLAY environment variable, otherwise nvidia driver
|
||||||
//has problems at libplace-swapchain-init
|
// has problems at libplace-swapchain-init
|
||||||
Debug(3, "video: setting ENV DISPLAY=%s\n",display_name);
|
Debug(3, "video: setting ENV DISPLAY=%s\n", display_name);
|
||||||
setenv("DISPLAY",display_name,0);
|
setenv("DISPLAY", display_name, 0);
|
||||||
//Debug(3, "video: ENV:(%s)\n",getenv("DISPLAY"));
|
// Debug(3, "video: ENV:(%s)\n",getenv("DISPLAY"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(XlibDisplay = XOpenDisplay(display_name))) {
|
if (!(XlibDisplay = XOpenDisplay(display_name))) {
|
||||||
|
Loading…
Reference in New Issue
Block a user