mirror of
https://github.com/jojo61/vdr-plugin-softhdcuvid.git
synced 2023-10-10 13:37:41 +02:00
openglosd integrated
This commit is contained in:
parent
cbdc46effe
commit
d5d680216e
10
Makefile
10
Makefile
@ -107,7 +107,13 @@ ifeq ($(OPENGL),1)
|
||||
CONFIG += -DUSE_GLX
|
||||
_CFLAGS += $(shell pkg-config --cflags gl glu glew)
|
||||
LIBS += $(shell pkg-config --libs gl glu glew)
|
||||
CONFIG += -DUSE_OPENGLOSD
|
||||
_CFLAGS += $(shell pkg-config --cflags glew)
|
||||
LIBS += $(shell pkg-config --libs glew)
|
||||
_CFLAGS += $(shell pkg-config --cflags freetype2)
|
||||
LIBS += $(shell pkg-config --libs freetype2)
|
||||
endif
|
||||
|
||||
#
|
||||
# Test that libswresample is available
|
||||
#
|
||||
@ -189,14 +195,14 @@ DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -D_GNU_SOURCE $(CONFIG) \
|
||||
### Make it standard
|
||||
|
||||
override CXXFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \
|
||||
-g -Wextra -Winit-self -Werror=overloaded-virtual
|
||||
-g -Wextra -Winit-self -Werror=overloaded-virtual -std=c++0x
|
||||
override CFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \
|
||||
-g -W -Wextra -Winit-self -Wdeclaration-after-statement
|
||||
|
||||
|
||||
### The object files (add further files here):
|
||||
|
||||
OBJS = $(PLUGIN).o softhddev.o video.o audio.o codec.o ringbuffer.o
|
||||
OBJS = $(PLUGIN).o softhddev.o video.o audio.o codec.o ringbuffer.o openglosd.o
|
||||
|
||||
SRCS = $(wildcard $(OBJS:.o=.c)) $(PLUGIN).cpp
|
||||
|
||||
|
2027
openglosd.cpp
Normal file
2027
openglosd.cpp
Normal file
File diff suppressed because it is too large
Load Diff
514
openglosd.h
Normal file
514
openglosd.h
Normal file
@ -0,0 +1,514 @@
|
||||
#ifndef __SOFTHDDEVICE_OPENGLOSD_H
|
||||
#define __SOFTHDDEVICE_OPENGLOSD_H
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include <GL/freeglut.h>
|
||||
#include <GL/gl.h>
|
||||
|
||||
#define GLM_FORCE_RADIANS
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include <math.h>
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_LCD_FILTER_H
|
||||
#include FT_STROKER_H
|
||||
|
||||
#undef __FTERRORS_H__
|
||||
#define FT_ERRORDEF( e, v, s ) { e, s },
|
||||
#define FT_ERROR_START_LIST {
|
||||
#define FT_ERROR_END_LIST { 0, 0 } };
|
||||
const struct {
|
||||
int code;
|
||||
const char* message;
|
||||
} FT_Errors[] =
|
||||
#include FT_ERRORS_H
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include <queue>
|
||||
|
||||
#include <vdr/plugin.h>
|
||||
#include <vdr/osd.h>
|
||||
#include <vdr/thread.h>
|
||||
|
||||
#include "softhddev.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <stdint.h>
|
||||
#include <libavcodec/avcodec.h>
|
||||
|
||||
#include "audio.h"
|
||||
#include "video.h"
|
||||
#include "codec.h"
|
||||
}
|
||||
|
||||
struct sOglImage {
|
||||
GLuint texture;
|
||||
GLint width;
|
||||
GLint height;
|
||||
bool used;
|
||||
};
|
||||
|
||||
/****************************************************************************************
|
||||
* Helpers
|
||||
****************************************************************************************/
|
||||
|
||||
void ConvertColor(const GLint &colARGB, glm::vec4 &col);
|
||||
|
||||
/****************************************************************************************
|
||||
* cShader
|
||||
****************************************************************************************/
|
||||
enum eShaderType {
|
||||
stRect,
|
||||
stTexture,
|
||||
stText,
|
||||
stCount
|
||||
};
|
||||
|
||||
class cShader {
|
||||
private:
|
||||
eShaderType type;
|
||||
GLuint id;
|
||||
bool Compile(const char *vertexCode, const char *fragmentCode);
|
||||
bool CheckCompileErrors(GLuint object, bool program = false);
|
||||
public:
|
||||
cShader(void) {};
|
||||
virtual ~cShader(void) {};
|
||||
bool Load(eShaderType type);
|
||||
void Use(void);
|
||||
void SetFloat (const GLchar *name, GLfloat value);
|
||||
void SetInteger (const GLchar *name, GLint value);
|
||||
void SetVector2f (const GLchar *name, GLfloat x, GLfloat y);
|
||||
void SetVector3f (const GLchar *name, GLfloat x, GLfloat y, GLfloat z);
|
||||
void SetVector4f (const GLchar *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
|
||||
void SetMatrix4 (const GLchar *name, const glm::mat4 &matrix);
|
||||
};
|
||||
|
||||
/****************************************************************************************
|
||||
* cOglGlyph
|
||||
****************************************************************************************/
|
||||
class cOglGlyph : public cListObject {
|
||||
private:
|
||||
struct tKerning {
|
||||
public:
|
||||
tKerning(uint prevSym, GLfloat kerning = 0.0f) {
|
||||
this->prevSym = prevSym;
|
||||
this->kerning = kerning;
|
||||
}
|
||||
uint prevSym;
|
||||
GLfloat kerning;
|
||||
};
|
||||
uint charCode;
|
||||
int bearingLeft;
|
||||
int bearingTop;
|
||||
int width;
|
||||
int height;
|
||||
int advanceX;
|
||||
cVector<tKerning> kerningCache;
|
||||
GLuint texture;
|
||||
void LoadTexture(FT_BitmapGlyph ftGlyph);
|
||||
public:
|
||||
cOglGlyph(uint charCode, FT_BitmapGlyph ftGlyph);
|
||||
virtual ~cOglGlyph();
|
||||
uint CharCode(void) { return charCode; }
|
||||
int AdvanceX(void) { return advanceX; }
|
||||
int BearingLeft(void) const { return bearingLeft; }
|
||||
int BearingTop(void) const { return bearingTop; }
|
||||
int Width(void) const { return width; }
|
||||
int Height(void) const { return height; }
|
||||
int GetKerningCache(uint prevSym);
|
||||
void SetKerningCache(uint prevSym, int kerning);
|
||||
void BindTexture(void);
|
||||
};
|
||||
|
||||
/****************************************************************************************
|
||||
* cOglFont
|
||||
****************************************************************************************/
|
||||
class cOglFont : public cListObject {
|
||||
private:
|
||||
static bool initiated;
|
||||
cString name;
|
||||
int size;
|
||||
int height;
|
||||
int bottom;
|
||||
static FT_Library ftLib;
|
||||
FT_Face face;
|
||||
static cList<cOglFont> *fonts;
|
||||
mutable cList<cOglGlyph> glyphCache;
|
||||
cOglFont(const char *fontName, int charHeight);
|
||||
static void Init(void);
|
||||
public:
|
||||
virtual ~cOglFont(void);
|
||||
static cOglFont *Get(const char *name, int charHeight);
|
||||
static void Cleanup(void);
|
||||
const char *Name(void) { return *name; };
|
||||
int Size(void) { return size; };
|
||||
int Bottom(void) {return bottom; };
|
||||
int Height(void) {return height; };
|
||||
cOglGlyph* Glyph(uint charCode) const;
|
||||
int Kerning(cOglGlyph *glyph, uint prevSym) const;
|
||||
};
|
||||
|
||||
/****************************************************************************************
|
||||
* cOglFb
|
||||
* Framebuffer Object - OpenGL part of a Pixmap
|
||||
****************************************************************************************/
|
||||
class cOglFb {
|
||||
protected:
|
||||
bool initiated;
|
||||
// GLuint fb;
|
||||
// GLuint texture;
|
||||
GLint width, height;
|
||||
GLint viewPortWidth, viewPortHeight;
|
||||
bool scrollable;
|
||||
public:
|
||||
GLuint fb;
|
||||
GLuint texture;
|
||||
cOglFb(GLint width, GLint height, GLint viewPortWidth, GLint viewPortHeight);
|
||||
virtual ~cOglFb(void);
|
||||
bool Initiated(void) { return initiated; }
|
||||
virtual bool Init(void);
|
||||
void Bind(void);
|
||||
void BindRead(void);
|
||||
virtual void BindWrite(void);
|
||||
virtual void Unbind(void);
|
||||
bool BindTexture(void);
|
||||
void Blit(GLint destX1, GLint destY1, GLint destX2, GLint destY2);
|
||||
GLint Width(void) { return width; };
|
||||
GLint Height(void) { return height; };
|
||||
bool Scrollable(void) { return scrollable; };
|
||||
GLint ViewportWidth(void) { return viewPortWidth; };
|
||||
GLint ViewportHeight(void) { return viewPortHeight; };
|
||||
};
|
||||
|
||||
/****************************************************************************************
|
||||
* cOglOutputFb
|
||||
* Output Framebuffer Object - holds Vdpau Output Surface which is our "output framebuffer"
|
||||
****************************************************************************************/
|
||||
class cOglOutputFb : public cOglFb {
|
||||
private:
|
||||
GLvdpauSurfaceNV surface;
|
||||
public:
|
||||
cOglOutputFb(GLint width, GLint height);
|
||||
virtual ~cOglOutputFb(void);
|
||||
virtual bool Init(void);
|
||||
virtual void BindWrite(void);
|
||||
virtual void Unbind(void);
|
||||
};
|
||||
|
||||
/****************************************************************************************
|
||||
* cOglVb
|
||||
* Vertex Buffer - OpenGl Vertices for the different drawing commands
|
||||
****************************************************************************************/
|
||||
enum eVertexBufferType {
|
||||
vbRect,
|
||||
vbEllipse,
|
||||
vbSlope,
|
||||
vbTexture,
|
||||
vbText,
|
||||
vbCount
|
||||
};
|
||||
|
||||
class cOglVb {
|
||||
private:
|
||||
eVertexBufferType type;
|
||||
eShaderType shader;
|
||||
GLuint vao;
|
||||
GLuint vbo;
|
||||
int sizeVertex1;
|
||||
int sizeVertex2;
|
||||
int numVertices;
|
||||
GLuint drawMode;
|
||||
public:
|
||||
cOglVb(int type);
|
||||
virtual ~cOglVb(void);
|
||||
bool Init(void);
|
||||
void Bind(void);
|
||||
void Unbind(void);
|
||||
void ActivateShader(void);
|
||||
void EnableBlending(void);
|
||||
void DisableBlending(void);
|
||||
void SetShaderColor(GLint color);
|
||||
void SetShaderAlpha(GLint alpha);
|
||||
void SetShaderProjectionMatrix(GLint width, GLint height);
|
||||
void SetVertexData(GLfloat *vertices, int count = 0);
|
||||
void DrawArrays(int count = 0);
|
||||
};
|
||||
|
||||
/****************************************************************************************
|
||||
* cOpenGLCmd
|
||||
****************************************************************************************/
|
||||
class cOglCmd {
|
||||
protected:
|
||||
cOglFb *fb;
|
||||
public:
|
||||
cOglCmd(cOglFb *fb) { this->fb = fb; };
|
||||
virtual ~cOglCmd(void) {};
|
||||
virtual const char* Description(void) = 0;
|
||||
virtual bool Execute(void) = 0;
|
||||
};
|
||||
|
||||
class cOglCmdInitOutputFb : public cOglCmd {
|
||||
private:
|
||||
cOglOutputFb *oFb;
|
||||
public:
|
||||
cOglCmdInitOutputFb(cOglOutputFb *oFb);
|
||||
virtual ~cOglCmdInitOutputFb(void) {};
|
||||
virtual const char* Description(void) { return "InitOutputFramebuffer"; }
|
||||
virtual bool Execute(void);
|
||||
};
|
||||
|
||||
class cOglCmdInitFb : public cOglCmd {
|
||||
private:
|
||||
cCondWait *wait;
|
||||
public:
|
||||
cOglCmdInitFb(cOglFb *fb, cCondWait *wait = NULL);
|
||||
virtual ~cOglCmdInitFb(void) {};
|
||||
virtual const char* Description(void) { return "InitFramebuffer"; }
|
||||
virtual bool Execute(void);
|
||||
};
|
||||
|
||||
class cOglCmdDeleteFb : public cOglCmd {
|
||||
public:
|
||||
cOglCmdDeleteFb(cOglFb *fb);
|
||||
virtual ~cOglCmdDeleteFb(void) {};
|
||||
virtual const char* Description(void) { return "DeleteFramebuffer"; }
|
||||
virtual bool Execute(void);
|
||||
};
|
||||
|
||||
class cOglCmdRenderFbToBufferFb : public cOglCmd {
|
||||
private:
|
||||
cOglFb *buffer;
|
||||
GLfloat x, y;
|
||||
GLfloat drawPortX, drawPortY;
|
||||
GLint transparency;
|
||||
public:
|
||||
cOglCmdRenderFbToBufferFb(cOglFb *fb, cOglFb *buffer, GLint x, GLint y, GLint transparency, GLint drawPortX, GLint drawPortY);
|
||||
virtual ~cOglCmdRenderFbToBufferFb(void) {};
|
||||
virtual const char* Description(void) { return "Render Framebuffer to Buffer"; }
|
||||
virtual bool Execute(void);
|
||||
};
|
||||
|
||||
class cOglCmdCopyBufferToOutputFb : public cOglCmd {
|
||||
private:
|
||||
cOglOutputFb *oFb;
|
||||
GLint x, y;
|
||||
public:
|
||||
cOglCmdCopyBufferToOutputFb(cOglFb *fb, cOglOutputFb *oFb, GLint x, GLint y);
|
||||
virtual ~cOglCmdCopyBufferToOutputFb(void) {};
|
||||
virtual const char* Description(void) { return "Copy buffer to OutputFramebuffer"; }
|
||||
virtual bool Execute(void);
|
||||
};
|
||||
|
||||
class cOglCmdFill : public cOglCmd {
|
||||
private:
|
||||
GLint color;
|
||||
public:
|
||||
cOglCmdFill(cOglFb *fb, GLint color);
|
||||
virtual ~cOglCmdFill(void) {};
|
||||
virtual const char* Description(void) { return "Fill"; }
|
||||
virtual bool Execute(void);
|
||||
};
|
||||
|
||||
class cOglCmdDrawRectangle : public cOglCmd {
|
||||
private:
|
||||
GLint x, y;
|
||||
GLint width, height;
|
||||
GLint color;
|
||||
public:
|
||||
cOglCmdDrawRectangle(cOglFb *fb, GLint x, GLint y, GLint width, GLint height, GLint color);
|
||||
virtual ~cOglCmdDrawRectangle(void) {};
|
||||
virtual const char* Description(void) { return "DrawRectangle"; }
|
||||
virtual bool Execute(void);
|
||||
};
|
||||
|
||||
class cOglCmdDrawEllipse : public cOglCmd {
|
||||
private:
|
||||
GLint x, y;
|
||||
GLint width, height;
|
||||
GLint color;
|
||||
GLint quadrants;
|
||||
GLfloat *CreateVerticesFull(int &numVertices);
|
||||
GLfloat *CreateVerticesQuadrant(int &numVertices);
|
||||
GLfloat *CreateVerticesHalf(int &numVertices);
|
||||
public:
|
||||
cOglCmdDrawEllipse(cOglFb *fb, GLint x, GLint y, GLint width, GLint height, GLint color, GLint quadrants);
|
||||
virtual ~cOglCmdDrawEllipse(void) {};
|
||||
virtual const char* Description(void) { return "DrawEllipse"; }
|
||||
virtual bool Execute(void);
|
||||
};
|
||||
|
||||
class cOglCmdDrawSlope : public cOglCmd {
|
||||
private:
|
||||
GLint x, y;
|
||||
GLint width, height;
|
||||
GLint color;
|
||||
GLint type;
|
||||
public:
|
||||
cOglCmdDrawSlope(cOglFb *fb, GLint x, GLint y, GLint width, GLint height, GLint color, GLint type);
|
||||
virtual ~cOglCmdDrawSlope(void) {};
|
||||
virtual const char* Description(void) { return "DrawSlope"; }
|
||||
virtual bool Execute(void);
|
||||
};
|
||||
|
||||
class cOglCmdDrawText : public cOglCmd {
|
||||
private:
|
||||
GLint x, y;
|
||||
GLint limitX;
|
||||
GLint colorText;
|
||||
cString fontName;
|
||||
int fontSize;
|
||||
unsigned int *symbols;
|
||||
public:
|
||||
cOglCmdDrawText(cOglFb *fb, GLint x, GLint y, unsigned int *symbols, GLint limitX, const char *name, int fontSize, tColor colorText);
|
||||
virtual ~cOglCmdDrawText(void);
|
||||
virtual const char* Description(void) { return "DrawText"; }
|
||||
virtual bool Execute(void);
|
||||
};
|
||||
|
||||
class cOglCmdDrawImage : public cOglCmd {
|
||||
private:
|
||||
tColor *argb;
|
||||
GLint x, y, width, height;
|
||||
bool overlay;
|
||||
GLfloat scaleX, scaleY;
|
||||
public:
|
||||
cOglCmdDrawImage(cOglFb *fb, tColor *argb, GLint width, GLint height, GLint x, GLint y, bool overlay = true, double scaleX = 1.0f, double scaleY = 1.0f);
|
||||
virtual ~cOglCmdDrawImage(void);
|
||||
virtual const char* Description(void) { return "Draw Image"; }
|
||||
virtual bool Execute(void);
|
||||
};
|
||||
|
||||
class cOglCmdDrawTexture : public cOglCmd {
|
||||
private:
|
||||
sOglImage *imageRef;
|
||||
GLint x, y;
|
||||
public:
|
||||
cOglCmdDrawTexture(cOglFb *fb, sOglImage *imageRef, GLint x, GLint y);
|
||||
virtual ~cOglCmdDrawTexture(void) {};
|
||||
virtual const char* Description(void) { return "Draw Texture"; }
|
||||
virtual bool Execute(void);
|
||||
};
|
||||
|
||||
class cOglCmdStoreImage : public cOglCmd {
|
||||
private:
|
||||
sOglImage *imageRef;
|
||||
tColor *data;
|
||||
public:
|
||||
cOglCmdStoreImage(sOglImage *imageRef, tColor *argb);
|
||||
virtual ~cOglCmdStoreImage(void);
|
||||
virtual const char* Description(void) { return "Store Image"; }
|
||||
virtual bool Execute(void);
|
||||
};
|
||||
|
||||
class cOglCmdDropImage : public cOglCmd {
|
||||
private:
|
||||
sOglImage *imageRef;
|
||||
cCondWait *wait;
|
||||
public:
|
||||
cOglCmdDropImage(sOglImage *imageRef, cCondWait *wait);
|
||||
virtual ~cOglCmdDropImage(void) {};
|
||||
virtual const char* Description(void) { return "Drop Image"; }
|
||||
virtual bool Execute(void);
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* cOglThread
|
||||
******************************************************************************/
|
||||
#define OGL_MAX_OSDIMAGES 256
|
||||
#define OGL_CMDQUEUE_SIZE 100
|
||||
|
||||
class cOglThread : public cThread {
|
||||
private:
|
||||
cCondWait *startWait;
|
||||
cCondWait *wait;
|
||||
bool stalled;
|
||||
std::queue<cOglCmd*> commands;
|
||||
GLint maxTextureSize;
|
||||
sOglImage imageCache[OGL_MAX_OSDIMAGES];
|
||||
long memCached;
|
||||
long maxCacheSize;
|
||||
bool InitOpenGL(void);
|
||||
bool InitShaders(void);
|
||||
void DeleteShaders(void);
|
||||
bool InitVdpauInterop(void);
|
||||
bool InitVertexBuffers(void);
|
||||
void DeleteVertexBuffers(void);
|
||||
void Cleanup(void);
|
||||
int GetFreeSlot(void);
|
||||
void ClearSlot(int slot);
|
||||
protected:
|
||||
virtual void Action(void);
|
||||
public:
|
||||
cOglThread(cCondWait *startWait, int maxCacheSize);
|
||||
virtual ~cOglThread();
|
||||
void Stop(void);
|
||||
void DoCmd(cOglCmd* cmd);
|
||||
int StoreImage(const cImage &image);
|
||||
void DropImageData(int imageHandle);
|
||||
sOglImage *GetImageRef(int slot);
|
||||
int MaxTextureSize(void) { return maxTextureSize; };
|
||||
};
|
||||
|
||||
/****************************************************************************************
|
||||
* cOglPixmap
|
||||
****************************************************************************************/
|
||||
class cOglPixmap : public cPixmap {
|
||||
private:
|
||||
cOglFb *fb;
|
||||
std::shared_ptr<cOglThread> oglThread;
|
||||
bool dirty;
|
||||
public:
|
||||
cOglPixmap(std::shared_ptr<cOglThread> oglThread, int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null);
|
||||
virtual ~cOglPixmap(void);
|
||||
cOglFb *Fb(void) { return fb; };
|
||||
int X(void) { return ViewPort().X(); };
|
||||
int Y(void) { return ViewPort().Y(); };
|
||||
virtual bool IsDirty(void) { return dirty; }
|
||||
virtual void SetDirty(bool dirty = true) { this->dirty = dirty; }
|
||||
virtual void SetAlpha(int Alpha);
|
||||
virtual void SetTile(bool Tile);
|
||||
virtual void SetViewPort(const cRect &Rect);
|
||||
virtual void SetDrawPortPoint(const cPoint &Point, bool Dirty = true);
|
||||
virtual void Clear(void);
|
||||
virtual void Fill(tColor Color);
|
||||
virtual void DrawImage(const cPoint &Point, const cImage &Image);
|
||||
virtual void DrawImage(const cPoint &Point, int ImageHandle);
|
||||
virtual void DrawPixel(const cPoint &Point, tColor Color);
|
||||
virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0, bool Overlay = false);
|
||||
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);
|
||||
virtual void DrawRectangle(const cRect &Rect, tColor Color);
|
||||
virtual void DrawEllipse(const cRect &Rect, tColor Color, int Quadrants = 0);
|
||||
virtual void DrawSlope(const cRect &Rect, tColor Color, int Type);
|
||||
virtual void Render(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest);
|
||||
virtual void Copy(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest);
|
||||
virtual void Scroll(const cPoint &Dest, const cRect &Source = cRect::Null);
|
||||
virtual void Pan(const cPoint &Dest, const cRect &Source = cRect::Null);
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* cOglOsd
|
||||
******************************************************************************/
|
||||
class cOglOsd : public cOsd {
|
||||
private:
|
||||
cOglFb *bFb;
|
||||
std::shared_ptr<cOglThread> oglThread;
|
||||
cVector<cOglPixmap *> oglPixmaps;
|
||||
bool isSubtitleOsd;
|
||||
protected:
|
||||
public:
|
||||
cOglOsd(int Left, int Top, uint Level, std::shared_ptr<cOglThread> oglThread);
|
||||
virtual ~cOglOsd();
|
||||
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas);
|
||||
virtual cPixmap *CreatePixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null);
|
||||
virtual void DestroyPixmap(cPixmap *Pixmap);
|
||||
virtual void Flush(void);
|
||||
virtual void DrawScaledBitmap(int x, int y, const cBitmap &Bitmap, double FactorX, double FactorY, bool AntiAlias = false);
|
||||
static cOglOutputFb *oFb;
|
||||
};
|
||||
|
||||
#endif //__SOFTHDDEVICE_OPENGLOSD_H
|
223
softhdcuvid.cpp
223
softhdcuvid.cpp
@ -17,7 +17,7 @@
|
||||
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
/// GNU Affero General Public License for more details.
|
||||
///
|
||||
/// $Id: 70994d77440d1a19d3b6204a50e578c950008b8a $
|
||||
/// $Id: fa6a877682f47297580ff5f502425fc7948cb2fa $
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define __STDC_CONSTANT_MACROS ///< needed for ffmpeg UINT64_C
|
||||
@ -37,14 +37,19 @@
|
||||
#include "softhddevice.h"
|
||||
#include "softhddevice_service.h"
|
||||
|
||||
#ifdef USE_OPENGLOSD
|
||||
#include "openglosd.h"
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <stdint.h>
|
||||
#include <libavcodec/avcodec.h>
|
||||
|
||||
#ifndef USE_OPENGLOSD
|
||||
#include "audio.h"
|
||||
#include "video.h"
|
||||
#include "codec.h"
|
||||
#endif
|
||||
}
|
||||
|
||||
#if APIVERSNUM >= 20301
|
||||
@ -67,7 +72,7 @@ static const char *const VERSION = "0.6.1rc1"
|
||||
|
||||
/// vdr-plugin description.
|
||||
static const char *const DESCRIPTION =
|
||||
trNOOP("A software and GPU emulated UHD device");
|
||||
trNOOP("A software and GPU emulated HD device");
|
||||
|
||||
/// vdr-plugin text of main menu entry
|
||||
static const char *MAINMENUENTRY = trNOOP("SoftUHD");
|
||||
@ -176,6 +181,10 @@ static int ConfigPipAltVideoHeight = 50; ///< config pip alt. video height in %
|
||||
static char ConfigEnableDPMSatBlackScreen; ///< Enable DPMS(Screensaver) while displaying black screen(radio)
|
||||
#endif
|
||||
|
||||
#ifdef USE_OPENGLOSD
|
||||
static int ConfigMaxSizeGPUImageCache = 128; ///< maximum size of GPU mem to be used for image caching
|
||||
#endif
|
||||
|
||||
static volatile int DoMakePrimary; ///< switch primary device to this
|
||||
|
||||
#define SUSPEND_EXTERNAL -1 ///< play external suspend mode
|
||||
@ -620,6 +629,44 @@ void cSoftOsd::Flush(void)
|
||||
Dirty = 0;
|
||||
}
|
||||
|
||||
#ifdef USE_OPENGLOSD
|
||||
//Dummy OSD for OpenGL OSD if no X Server is available
|
||||
class cDummyOsd : public cOsd {
|
||||
public:
|
||||
cDummyOsd(int Left, int Top, uint Level) : cOsd(Left, Top, Level) {}
|
||||
virtual ~cDummyOsd() {}
|
||||
virtual cPixmap *CreatePixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null) {
|
||||
(void)Layer; (void)ViewPort; (void)DrawPort;
|
||||
return NULL;
|
||||
}
|
||||
virtual void DestroyPixmap(cPixmap *Pixmap) { (void)Pixmap; }
|
||||
virtual void DrawImage(const cPoint &Point, const cImage &Image) { (void)Point; (void)Image; }
|
||||
virtual void DrawImage(const cPoint &Point, int ImageHandle) { (void) Point; (void)ImageHandle; }
|
||||
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas) { (void)Areas; (void)NumAreas; return oeOk; }
|
||||
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas) { (void)Areas; (void)NumAreas; return oeOk; }
|
||||
virtual void SaveRegion(int x1, int y1, int x2, int y2) { (void)x1; (void)y1; (void)x2; (void)y2; }
|
||||
virtual void RestoreRegion(void) {}
|
||||
virtual eOsdError SetPalette(const cPalette &Palette, int Area) { (void)Palette; (void)Area; return oeOk; }
|
||||
virtual void DrawPixel(int x, int y, tColor Color) { (void)x; (void)y; (void)Color; }
|
||||
virtual void DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0, bool ReplacePalette = false, bool Overlay = false) {
|
||||
(void)x; (void)y; (void)Bitmap; (void)ColorFg; (void)ColorBg; (void)ReplacePalette; (void)Overlay;
|
||||
}
|
||||
virtual void DrawText(int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width = 0, int Height = 0, int Alignment = taDefault) {
|
||||
(void)x; (void)y; (void)s; (void)ColorFg; (void)ColorBg; (void)Font; (void)Width; (void)Height; (void)Alignment;
|
||||
}
|
||||
virtual void DrawRectangle(int x1, int y1, int x2, int y2, tColor Color) {
|
||||
(void)x1; (void)y1; (void)x2; (void)y2; (void)Color;
|
||||
}
|
||||
virtual void DrawEllipse(int x1, int y1, int x2, int y2, tColor Color, int Quadrants = 0) {
|
||||
(void)x1; (void)y1; (void)x2; (void)y2; (void)Color; (void)Quadrants;
|
||||
}
|
||||
virtual void DrawSlope(int x1, int y1, int x2, int y2, tColor Color, int Type) {
|
||||
(void)x1; (void)y1; (void)x2; (void)y2; (void)Color; (void)Type;
|
||||
}
|
||||
virtual void Flush(void) {}
|
||||
};
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// OSD provider
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -631,15 +678,45 @@ class cSoftOsdProvider:public cOsdProvider
|
||||
{
|
||||
private:
|
||||
static cOsd *Osd; ///< single OSD
|
||||
#ifdef USE_OPENGLOSD
|
||||
static std::shared_ptr<cOglThread> oglThread;
|
||||
static bool StartOpenGlThread(void);
|
||||
protected:
|
||||
virtual int StoreImageData(const cImage &Image);
|
||||
virtual void DropImageData(int ImageHandle);
|
||||
#endif
|
||||
public:
|
||||
virtual cOsd * CreateOsd(int, int, uint);
|
||||
virtual bool ProvidesTrueColor(void);
|
||||
#ifdef USE_OPENGLOSD
|
||||
static void StopOpenGlThread(void);
|
||||
static const cImage *GetImageData(int ImageHandle);
|
||||
static void OsdSizeChanged(void);
|
||||
#endif
|
||||
cSoftOsdProvider(void); ///< OSD provider constructor
|
||||
//virtual ~cSoftOsdProvider(); ///< OSD provider destructor
|
||||
virtual ~cSoftOsdProvider(); ///< OSD provider destructor
|
||||
};
|
||||
|
||||
cOsd *cSoftOsdProvider::Osd; ///< single osd
|
||||
|
||||
#ifdef USE_OPENGLOSD
|
||||
std::shared_ptr<cOglThread> cSoftOsdProvider::oglThread; ///< openGL worker Thread
|
||||
|
||||
int cSoftOsdProvider::StoreImageData(const cImage &Image)
|
||||
{
|
||||
if (StartOpenGlThread()) {
|
||||
int imgHandle = oglThread->StoreImage(Image);
|
||||
return imgHandle;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cSoftOsdProvider::DropImageData(int ImageHandle)
|
||||
{
|
||||
if (StartOpenGlThread())
|
||||
oglThread->DropImageData(ImageHandle);
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
** Create a new OSD.
|
||||
**
|
||||
@ -649,11 +726,17 @@ cOsd *cSoftOsdProvider::Osd; ///< single osd
|
||||
*/
|
||||
cOsd *cSoftOsdProvider::CreateOsd(int left, int top, uint level)
|
||||
{
|
||||
#ifdef OSD_DEBUG
|
||||
#ifdef USE_OPENGLOSD
|
||||
dsyslog("[softhddev]%s: left %d, top %d, level %d, using OpenGL OSD support\n", __FUNCTION__, left, top, level);
|
||||
if (StartOpenGlThread())
|
||||
return Osd = new cOglOsd(left, top, level, oglThread);
|
||||
//return dummy osd if shd is detached
|
||||
dsyslog("[softhddev]OpenGl Thread not started successfully, using Dummy OSD");
|
||||
return Osd = new cDummyOsd(left, top, 999);
|
||||
#else
|
||||
dsyslog("[softhddev]%s: %d, %d, %d\n", __FUNCTION__, left, top, level);
|
||||
#endif
|
||||
|
||||
return Osd = new cSoftOsd(left, top, level);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -666,6 +749,53 @@ bool cSoftOsdProvider::ProvidesTrueColor(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef USE_OPENGLOSD
|
||||
const cImage *cSoftOsdProvider::GetImageData(int ImageHandle) {
|
||||
return cOsdProvider::GetImageData(ImageHandle);
|
||||
}
|
||||
|
||||
void cSoftOsdProvider::OsdSizeChanged(void) {
|
||||
//cleanup OpenGl Context
|
||||
cSoftOsdProvider::StopOpenGlThread();
|
||||
cOsdProvider::UpdateOsdSize();
|
||||
}
|
||||
|
||||
|
||||
bool cSoftOsdProvider::StartOpenGlThread(void) {
|
||||
//only try to start worker thread if shd is attached
|
||||
//otherwise glutInit() crashes
|
||||
if (SuspendMode != NOT_SUSPENDED) {
|
||||
dsyslog("[softhddev]detached - OpenGl Worker Thread not tried to start");
|
||||
return false;
|
||||
}
|
||||
if (oglThread.get()) {
|
||||
if (oglThread->Active()) {
|
||||
return true;
|
||||
}
|
||||
oglThread.reset();
|
||||
}
|
||||
cCondWait wait;
|
||||
dsyslog("[softhddev]Trying to start OpenGL Worker Thread");
|
||||
oglThread.reset(new cOglThread(&wait, ConfigMaxSizeGPUImageCache));
|
||||
wait.Wait();
|
||||
if (oglThread->Active()) {
|
||||
dsyslog("[softhddev]OpenGL Worker Thread successfully started");
|
||||
return true;
|
||||
}
|
||||
dsyslog("[softhddev]openGL Thread NOT successfully started");
|
||||
return false;
|
||||
}
|
||||
|
||||
void cSoftOsdProvider::StopOpenGlThread(void) {
|
||||
dsyslog("[softhddev]stopping OpenGL Worker Thread ");
|
||||
if (oglThread) {
|
||||
oglThread->Stop();
|
||||
}
|
||||
oglThread.reset();
|
||||
dsyslog("[softhddev]OpenGL Worker Thread stopped");
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Create cOsdProvider class.
|
||||
*/
|
||||
@ -675,15 +805,25 @@ cSoftOsdProvider::cSoftOsdProvider(void)
|
||||
#ifdef OSD_DEBUG
|
||||
dsyslog("[softhddev]%s:\n", __FUNCTION__);
|
||||
#endif
|
||||
#ifdef USE_OPENGLOSD
|
||||
StopOpenGlThread();
|
||||
VideoSetVideoEventCallback(&OsdSizeChanged);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
** Destroy cOsdProvider class.
|
||||
*/
|
||||
cSoftOsdProvider::~cSoftOsdProvider()
|
||||
{
|
||||
#ifdef OSD_DEBUG
|
||||
dsyslog("[softhddev]%s:\n", __FUNCTION__);
|
||||
#endif
|
||||
#ifdef USE_OPENGLOSD
|
||||
StopOpenGlThread();
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// cMenuSetupPage
|
||||
@ -778,6 +918,10 @@ class cMenuSetupSoft:public cMenuSetupPage
|
||||
#ifdef USE_SCREENSAVER
|
||||
int EnableDPMSatBlackScreen;
|
||||
#endif
|
||||
|
||||
#ifdef USE_OPENGLOSD
|
||||
int MaxSizeGPUImageCache;
|
||||
#endif
|
||||
/// @}
|
||||
private:
|
||||
inline cOsdItem * CollapsedItem(const char *, int &, const char * = NULL);
|
||||
@ -854,7 +998,7 @@ void cMenuSetupSoft::Create(void)
|
||||
"None", "PCM", "AC-3", "PCM + AC-3"
|
||||
};
|
||||
static const char *const resolution[RESOLUTIONS] = {
|
||||
"576i", "720p", "fake 1080i", "1080i", "UHD"
|
||||
"576i", "720p", "fake 1080i", "1080i" ,"UHD"
|
||||
};
|
||||
int current;
|
||||
int i;
|
||||
@ -880,6 +1024,9 @@ void cMenuSetupSoft::Create(void)
|
||||
Add(new cMenuEditIntItem(tr("Osd width"), &OsdWidth, 0, 4096));
|
||||
Add(new cMenuEditIntItem(tr("Osd height"), &OsdHeight, 0, 4096));
|
||||
}
|
||||
#ifdef USE_OPENGLOSD
|
||||
Add(new cMenuEditIntItem(tr("GPU mem used for image caching (MB)"), &MaxSizeGPUImageCache, 0, 4000));
|
||||
#endif
|
||||
//
|
||||
// suspend
|
||||
//
|
||||
@ -905,7 +1052,7 @@ void cMenuSetupSoft::Create(void)
|
||||
&Video4to3DisplayFormat, 3, video_display_formats_4_3));
|
||||
Add(new cMenuEditStraItem(trVDR("16:9+other video display format"),
|
||||
&VideoOtherDisplayFormat, 3, video_display_formats_16_9));
|
||||
#if 0
|
||||
|
||||
// FIXME: switch config gray/color configuration
|
||||
Add(new cMenuEditIntItem(tr("Video background color (RGB)"),
|
||||
(int *)&Background, 0, 0x00FFFFFF));
|
||||
@ -915,14 +1062,13 @@ void cMenuSetupSoft::Create(void)
|
||||
&StudioLevels, trVDR("no"), trVDR("yes")));
|
||||
Add(new cMenuEditBoolItem(tr("60hz display mode"), &_60HzMode,
|
||||
trVDR("no"), trVDR("yes")));
|
||||
#endif
|
||||
Add(new cMenuEditBoolItem(tr("Soft start a/v sync"), &SoftStartSync,
|
||||
trVDR("no"), trVDR("yes")));
|
||||
Add(new cMenuEditBoolItem(tr("Black during channel switch"),
|
||||
&BlackPicture, trVDR("no"), trVDR("yes")));
|
||||
Add(new cMenuEditBoolItem(tr("Clear decoder on channel switch"),
|
||||
&ClearOnSwitch, trVDR("no"), trVDR("yes")));
|
||||
#if 0
|
||||
|
||||
Add(new cMenuEditIntItem(tr("Brightness (-1000..1000) (vdpau)"),
|
||||
&Brightness, -1000, 1000, tr("min"), tr("max")));
|
||||
Add(new cMenuEditIntItem(tr("Contrast (0..10000) (vdpau)"), &Contrast,
|
||||
@ -974,7 +1120,6 @@ void cMenuSetupSoft::Create(void)
|
||||
&AutoCropDelay, 0, 200));
|
||||
Add(new cMenuEditIntItem(tr("Autocrop tolerance (pixel)"),
|
||||
&AutoCropTolerance, 0, 32));
|
||||
#endif
|
||||
}
|
||||
//
|
||||
// audio
|
||||
@ -1224,6 +1369,10 @@ cMenuSetupSoft::cMenuSetupSoft(void)
|
||||
EnableDPMSatBlackScreen = ConfigEnableDPMSatBlackScreen;
|
||||
#endif
|
||||
|
||||
#ifdef USE_OPENGLOSD
|
||||
MaxSizeGPUImageCache = ConfigMaxSizeGPUImageCache;
|
||||
#endif
|
||||
|
||||
Create();
|
||||
}
|
||||
|
||||
@ -1400,6 +1549,11 @@ void cMenuSetupSoft::Store(void)
|
||||
EnableDPMSatBlackScreen);
|
||||
SetDPMSatBlackScreen(ConfigEnableDPMSatBlackScreen);
|
||||
#endif
|
||||
|
||||
#ifdef USE_OPENGLOSD
|
||||
SetupStore("MaxSizeGPUImageCache", ConfigMaxSizeGPUImageCache =
|
||||
MaxSizeGPUImageCache);
|
||||
#endif
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -2196,6 +2350,10 @@ eOSState cSoftHdMenu::ProcessKey(eKeys key)
|
||||
ConfigSuspendX11);
|
||||
SuspendMode = SUSPEND_NORMAL;
|
||||
}
|
||||
#ifdef USE_OPENGLOSD
|
||||
dsyslog("[softhddev]stopping Ogl Thread osUser1");
|
||||
cSoftOsdProvider::StopOpenGlThread();
|
||||
#endif
|
||||
if (ShutdownHandler.GetUserInactiveTime()) {
|
||||
dsyslog("[softhddev]%s: set user inactive\n",
|
||||
__FUNCTION__);
|
||||
@ -2339,6 +2497,10 @@ void cSoftHdDevice::MakePrimaryDevice(bool on)
|
||||
} else if (SuspendMode == NOT_SUSPENDED) {
|
||||
Suspend(1, 1, 0);
|
||||
SuspendMode = SUSPEND_DETACHED;
|
||||
#ifdef USE_OPENGLOSD
|
||||
dsyslog("[softhddev]stopping Ogl Thread MakePrimaryDevice");
|
||||
cSoftOsdProvider::StopOpenGlThread();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -2402,6 +2564,10 @@ bool cSoftHdDevice::SetPlayMode(ePlayMode play_mode)
|
||||
// FIXME: what if already suspended?
|
||||
Suspend(1, 1, 0);
|
||||
SuspendMode = SUSPEND_EXTERNAL;
|
||||
#ifdef USE_OPENGLOSD
|
||||
dsyslog("[softhddev]stopping Ogl Thread pmExtern_THIS_SHOULD_BE_AVOIDED");
|
||||
cSoftOsdProvider::StopOpenGlThread();
|
||||
#endif
|
||||
return true;
|
||||
default:
|
||||
dsyslog("[softhddev] playmode not implemented... %d\n", play_mode);
|
||||
@ -2862,7 +3028,6 @@ const char *cPluginSoftHdDevice::CommandLineHelp(void)
|
||||
bool cPluginSoftHdDevice::ProcessArgs(int argc, char *argv[])
|
||||
{
|
||||
//dsyslog("[softhddev]%s:\n", __FUNCTION__);
|
||||
|
||||
return::ProcessArgs(argc, argv);
|
||||
}
|
||||
|
||||
@ -2944,6 +3109,10 @@ void cPluginSoftHdDevice::Housekeeping(void)
|
||||
cControl::Attach();
|
||||
Suspend(ConfigSuspendClose, ConfigSuspendClose, ConfigSuspendX11);
|
||||
SuspendMode = SUSPEND_NORMAL;
|
||||
#ifdef USE_OPENGLOSD
|
||||
dsyslog("[softhddev]stopping Ogl Thread Housekeeping");
|
||||
cSoftOsdProvider::StopOpenGlThread();
|
||||
#endif
|
||||
}
|
||||
|
||||
::Housekeeping();
|
||||
@ -3302,6 +3471,13 @@ bool cPluginSoftHdDevice::SetupParse(const char *name, const char *value)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_OPENGLOSD
|
||||
if (!strcasecmp(name, "MaxSizeGPUImageCache")) {
|
||||
ConfigMaxSizeGPUImageCache = atoi(value);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3316,14 +3492,6 @@ bool cPluginSoftHdDevice::Service(const char *id, void *data)
|
||||
{
|
||||
//dsyslog("[softhddev]%s: id %s\n", __FUNCTION__, id);
|
||||
|
||||
if (strcmp(id, OSD_3DMODE_SERVICE) == 0) {
|
||||
SoftHDDevice_Osd3DModeService_v1_0_t *r;
|
||||
|
||||
r = (SoftHDDevice_Osd3DModeService_v1_0_t *) data;
|
||||
VideoSetOsd3DMode(r->Mode);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3386,9 +3554,6 @@ static const char *SVDRPHelpText[] = {
|
||||
" NOT_SUSPENDED == 0 (910)\n"
|
||||
" SUSPEND_NORMAL == 1 (911)\n"
|
||||
" SUSPEND_DETACHED == 2 (912)\n",
|
||||
"3DOF\n" "\040 3D OSD off.\n",
|
||||
"3DTB\n" "\040 3D OSD Top and Bottom.\n",
|
||||
"3DSB\n" "\040 3D OSD Side by Side.\n",
|
||||
"RAIS\n" "\040 Raise softhddevice window\n\n"
|
||||
" If Xserver is not started by softhddevice, the window which\n"
|
||||
" contains the softhddevice frontend will be raised to the front.\n",
|
||||
@ -3440,6 +3605,10 @@ cString cPluginSoftHdDevice::SVDRPCommand(const char *command,
|
||||
cControl::Attach();
|
||||
Suspend(ConfigSuspendClose, ConfigSuspendClose, ConfigSuspendX11);
|
||||
SuspendMode = SUSPEND_NORMAL;
|
||||
#ifdef USE_OPENGLOSD
|
||||
dsyslog("[softhddev]stopping Ogl Thread svdrp STAT");
|
||||
cSoftOsdProvider::StopOpenGlThread();
|
||||
#endif
|
||||
return "SoftHdDevice is suspended";
|
||||
}
|
||||
if (!strcasecmp(command, "RESU")) {
|
||||
@ -3470,6 +3639,10 @@ cString cPluginSoftHdDevice::SVDRPCommand(const char *command,
|
||||
cControl::Attach();
|
||||
Suspend(1, 1, 0);
|
||||
SuspendMode = SUSPEND_DETACHED;
|
||||
#ifdef USE_OPENGLOSD
|
||||
dsyslog("[softhddev]stopping Ogl Thread svdrp DETA");
|
||||
cSoftOsdProvider::StopOpenGlThread();
|
||||
#endif
|
||||
return "SoftHdDevice is detached";
|
||||
}
|
||||
if (!strcasecmp(command, "ATTA")) {
|
||||
|
136
video.c
136
video.c
@ -438,7 +438,9 @@ static int OsdDirtyX; ///< osd dirty area x
|
||||
static int OsdDirtyY; ///< osd dirty area y
|
||||
static int OsdDirtyWidth; ///< osd dirty area width
|
||||
static int OsdDirtyHeight; ///< osd dirty area height
|
||||
|
||||
#ifdef USE_OPENGLOSD
|
||||
static void (*VideoEventCallback)(void) = NULL; /// callback function to notify VDR about Video Events
|
||||
#endif
|
||||
static int64_t VideoDeltaPTS; ///< FIXME: fix pts
|
||||
|
||||
#ifdef USE_SCREENSAVER
|
||||
@ -458,7 +460,7 @@ static GLXContext GlxThreadContext; ///< our gl context for the thread
|
||||
static XVisualInfo *GlxVisualInfo; ///< our gl visual
|
||||
|
||||
static GLuint OsdGlTextures[2]; ///< gl texture for OSD
|
||||
static int OsdIndex; ///< index into OsdGlTextures
|
||||
static int OsdIndex=0; ///< index into OsdGlTextures
|
||||
static void GlxSetupWindow(xcb_window_t window, int width, int height, GLXContext context);
|
||||
|
||||
|
||||
@ -810,7 +812,8 @@ static inline void GlxRenderTexture(GLuint texture, int x, int y, int width,
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f); // no color
|
||||
// glColor4f(1.0f, 1.0f, 1.0f, 1.0f); // no color
|
||||
#ifndef USE_OPENGLOSD
|
||||
glBegin(GL_QUADS); {
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex2i(x + width, y + height);
|
||||
@ -822,6 +825,19 @@ static inline void GlxRenderTexture(GLuint texture, int x, int y, int width,
|
||||
glVertex2i(x + width, y);
|
||||
}
|
||||
glEnd();
|
||||
#else
|
||||
glBegin(GL_QUADS); {
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex2i(x+width , y );
|
||||
glTexCoord2f(0.0f, 1.0f);
|
||||
glVertex2i(x, y );
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
glVertex2i(x, y+height);
|
||||
glTexCoord2f(1.0f, 0.0f);
|
||||
glVertex2i(x+width , y+height);
|
||||
}
|
||||
glEnd();
|
||||
#endif
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
@ -885,6 +901,7 @@ static void GlxOsdInit(int width, int height)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
|
||||
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
@ -1290,6 +1307,7 @@ static void GlxInit(void)
|
||||
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Cleanup GLX.
|
||||
///
|
||||
@ -1620,9 +1638,12 @@ static int CuvidDecoderN; ///< number of decoder streams
|
||||
|
||||
GLuint vao_buffer; //
|
||||
//GLuint vao_vao[4]; //
|
||||
GLuint gl_shader=0,gl_prog = 0; // shader programm
|
||||
GLuint gl_shader=0,gl_prog = 0,gl_fbo=0; // shader programm
|
||||
GLint gl_colormatrix,gl_colormatrix_c;
|
||||
|
||||
GLuint OSDfb=0;
|
||||
GLuint OSDtexture;
|
||||
GLXContext OSDcontext;
|
||||
int OSDx,OSDy,OSDxsize,OSDysize;
|
||||
|
||||
static struct timespec CuvidFrameTime; ///< time of last display
|
||||
|
||||
@ -3065,7 +3086,6 @@ static void CuvidAdvanceDecoderFrame(CuvidDecoder * decoder)
|
||||
// need 2 frames for progressive
|
||||
// need 4 frames for interlaced
|
||||
filled = atomic_read(&decoder->SurfacesFilled);
|
||||
//JOJO if (filled <= 1 + 2 * decoder->Interlaced) {
|
||||
if (filled <= 1 + 2 * decoder->Interlaced) {
|
||||
// keep use of last surface
|
||||
++decoder->FramesDuped;
|
||||
@ -3096,33 +3116,6 @@ static void CuvidDisplayFrame(void)
|
||||
static unsigned int Count;
|
||||
int filled;
|
||||
CuvidDecoder *decoder;
|
||||
#if 0
|
||||
|
||||
//
|
||||
// wait for surface no longer visible (blocks max ~5ms)
|
||||
//
|
||||
status =
|
||||
CuvidPresentationQueueBlockUntilSurfaceIdle(CuvidQueue,
|
||||
CuvidSurfacesRb[CuvidOutputSurfaceIndex], &first_time);
|
||||
if (status != VDP_STATUS_OK) {
|
||||
Error(_("video/cuvid: can't block queue: %s\n"),
|
||||
CuvidGetErrorString(status));
|
||||
}
|
||||
|
||||
// check if surface was displayed for more than 1 frame
|
||||
// FIXME: 21 only correct for 50Hz
|
||||
if (last_time && first_time > last_time + 21 * 1000 * 1000) {
|
||||
// FIXME: ignore still-frame, trick-speed
|
||||
Debug(3, "video/cuvid: %" PRId64 " display time %" PRId64 "\n", first_time / 1000, (first_time - last_time) / 1000);
|
||||
// FIXME: can be more than 1 frame long shown
|
||||
for (i = 0; i < CuvidDecoderN; ++i) {
|
||||
CuvidDecoders[i]->FramesMissed++;
|
||||
CuvidMessage(2, _("video/cuvid: missed frame (%d/%d)\n"),
|
||||
CuvidDecoders[i]->FramesMissed,
|
||||
CuvidDecoders[i]->FrameCounter);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
glXMakeCurrent(XlibDisplay, VideoWindow, GlxSharedContext);
|
||||
|
||||
@ -3155,9 +3148,13 @@ static void CuvidDisplayFrame(void)
|
||||
// add osd to surface
|
||||
//
|
||||
if (OsdShown) {
|
||||
#ifndef USE_OPENGLOSD
|
||||
glXMakeCurrent(XlibDisplay, VideoWindow, GlxThreadContext);
|
||||
// GlxRenderTexture(OsdGlTextures[OsdIndex], decoder->OutputX, decoder->OutputY, decoder->OutputWidth, decoder->OutputHeight);
|
||||
GlxRenderTexture(OsdGlTextures[OsdIndex], 0,0, VideoWindowWidth, VideoWindowHeight);
|
||||
GlxRenderTexture(OsdGlTextures[OsdIndex], 0,0, VideoWindowWidth, VideoWindowHeight);
|
||||
#else
|
||||
glXMakeCurrent(XlibDisplay, VideoWindow, GlxContext );
|
||||
GlxRenderTexture(OSDtexture, OSDx, OSDy, OSDxsize, OSDysize);
|
||||
#endif
|
||||
glXMakeCurrent(XlibDisplay, VideoWindow, GlxSharedContext);
|
||||
// FIXME: toggle osd
|
||||
}
|
||||
@ -3854,6 +3851,7 @@ static const VideoModule NoopModule = {
|
||||
void VideoOsdClear(void)
|
||||
{
|
||||
VideoThreadLock();
|
||||
|
||||
VideoUsedModule->OsdClear();
|
||||
|
||||
OsdDirtyX = OsdWidth; // reset dirty area
|
||||
@ -3909,6 +3907,19 @@ void VideoOsdDrawARGB(int xi, int yi, int width, int height, int pitch,
|
||||
VideoThreadUnlock();
|
||||
}
|
||||
|
||||
#ifdef USE_OPENGLOSD
|
||||
void ActivateOsd(GLuint texture, int x, int y, int xsize, int ysize) {
|
||||
OsdShown = 1;
|
||||
OSDtexture = texture;
|
||||
OSDx = x;
|
||||
OSDy = y;
|
||||
OSDxsize = xsize;
|
||||
OSDysize = ysize;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// Get OSD size.
|
||||
///
|
||||
@ -4148,7 +4159,12 @@ void VideoPollEvent(void)
|
||||
VideoEvent();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_OPENGLOSD
|
||||
void VideoSetVideoEventCallback(void (*videoEventCallback)(void))
|
||||
{
|
||||
VideoEventCallback = videoEventCallback;
|
||||
}
|
||||
#endif
|
||||
//----------------------------------------------------------------------------
|
||||
// Thread
|
||||
//----------------------------------------------------------------------------
|
||||
@ -5110,7 +5126,10 @@ void VideoSetVideoMode( __attribute__ ((unused))
|
||||
if ((unsigned)width == VideoWindowWidth && (unsigned)height == VideoWindowHeight) {
|
||||
return; // same size nothing todo
|
||||
}
|
||||
|
||||
#ifdef USE_OPENGLOSD
|
||||
if (VideoEventCallback)
|
||||
VideoEventCallback();
|
||||
#endif
|
||||
VideoOsdExit();
|
||||
|
||||
VideoThreadLock();
|
||||
@ -5487,11 +5506,13 @@ void VideoInit(const char *display_name)
|
||||
if (VideoWindowWidth) {
|
||||
VideoWindowHeight = (VideoWindowWidth * 9) / 16;
|
||||
} else { // default to fullscreen
|
||||
// VideoWindowHeight = screen->height_in_pixels;
|
||||
// VideoWindowWidth = screen->width_in_pixels;
|
||||
VideoWindowHeight = screen->height_in_pixels;
|
||||
VideoWindowWidth = screen->width_in_pixels;
|
||||
//***********************************************************************************************
|
||||
VideoWindowHeight = 1080;
|
||||
VideoWindowWidth = 1920;
|
||||
// if (strcmp(":0.0",display_name) == 0) {
|
||||
// VideoWindowHeight = 1080;
|
||||
// VideoWindowWidth = 1920;
|
||||
// }
|
||||
}
|
||||
}
|
||||
if (!VideoWindowWidth) {
|
||||
@ -5631,4 +5652,37 @@ void VideoExit(void)
|
||||
|
||||
}
|
||||
|
||||
int GlxInitopengl() {
|
||||
|
||||
while (GlxSharedContext == NULL) {
|
||||
sleep(1); // wait until Init from video thread is ready
|
||||
// printf("GlxConext %p\n",GlxSharedContext);
|
||||
}
|
||||
OSDcontext = glXCreateContext(XlibDisplay, GlxVisualInfo, GlxSharedContext,GL_TRUE);
|
||||
if (!OSDcontext) {
|
||||
Debug(3,"video/osd: can't create glx context\n");
|
||||
return 0;
|
||||
}
|
||||
glXMakeCurrent(XlibDisplay, VideoWindow, OSDcontext);
|
||||
glViewport(0, 0, VideoWindowWidth, VideoWindowHeight);
|
||||
glDepthRange(-1.0, 1.0);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
glClearDepth(1.0);
|
||||
GlxCheck();
|
||||
if (glewInit())
|
||||
Fatal(_("glewinit failed\n"));
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(0.0, VideoWindowWidth, VideoWindowHeight, 0.0, -1.0, 1.0);
|
||||
GlxCheck();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
glDisable(GL_DEPTH_TEST); // setup 2d drawing
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
|
12
video.h
12
video.h
@ -23,6 +23,9 @@
|
||||
/// @addtogroup Video
|
||||
/// @{
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glx.h>
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Typedefs
|
||||
//----------------------------------------------------------------------------
|
||||
@ -75,6 +78,11 @@ extern void *VideoGetHwAccelContext(VideoHwDecoder *);
|
||||
extern void VideoDrawRenderState(VideoHwDecoder *,
|
||||
struct vdpau_render_state *);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_OPENGLOSD
|
||||
/// Set callback funktion to notify VDR about VideoEvents
|
||||
extern void VideoSetVideoEventCallback(void (*)(void));
|
||||
#endif
|
||||
|
||||
/// Poll video events.
|
||||
@ -227,7 +235,9 @@ extern void SetDPMSatBlackScreen(int);
|
||||
|
||||
/// Raise the frontend window
|
||||
extern int VideoRaiseWindow(void);
|
||||
|
||||
#ifdef USE_OPENGLOSD
|
||||
extern void ActivateOsd(GLuint,int,int,int,int);
|
||||
#endif
|
||||
#if 0
|
||||
long int gettid()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user