1
0
mirror of https://github.com/jojo61/vdr-plugin-softhdcuvid.git synced 2023-10-10 13:37:41 +02:00

Merge pull request #9 from dnehring7/master

Reindent all sources to common coding style (second try). This makes it easier for future patches.
This commit is contained in:
jojo61 2019-10-27 10:48:39 +01:00 committed by GitHub
commit 01a564cf3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 10556 additions and 10663 deletions

37
.indent.pro vendored Normal file
View File

@ -0,0 +1,37 @@
--blank-lines-before-block-comments
--blank-lines-after-declarations
--blank-lines-after-procedures
--no-blank-lines-after-commas
--braces-on-if-line
--no-blank-before-sizeof
--comment-indentation41
--declaration-comment-column41
--no-comment-delimiters-on-blank-lines
--swallow-optional-blank-lines
--dont-format-comments
--parameter-indentation4
--indent-level4
--line-comments-indentation0
--cuddle-else
--cuddle-do-while
--brace-indent0
--case-brace-indentation0
//--start-left-side-of-comments
--leave-preprocessor-space
//--continuation-indentation8
--case-indentation4
--else-endif-column0
--no-space-after-casts
--declaration-indentation1
--dont-line-up-parentheses
--no-space-after-function-call-names
--space-special-semicolon
--tab-size4
--no-tabs
--line-length119
--comment-line-length119
--honour-newlines
--dont-break-procedure-type
--break-before-boolean-operator
--continuation-indentation4
--ignore-newlines

View File

@ -1,6 +1,6 @@
#
# Makefile for a Video Disk Recorder plugin
#
#
# $Id: 2a41981a57e5e83036463c6a08c84b86ed9d2be3 $
# The official name of this plugin.
@ -11,13 +11,13 @@
### Configuration (edit this for your needs)
# comment out if not needed
# what kind of driver do we make -
# what kind of driver do we make -
# if VAAPI is enabled the drivername is softhdvaapi
# if CUVID is enabled the drivername is softhdcuvid
#VAAPI=1
CUVID=1
# use libplacebo - available for both drivers
# use libplacebo - available for both drivers
#LIBPLACEBO=1
# use YADIF deint - only available with cuvid
@ -92,7 +92,7 @@ TMPDIR ?= /tmp
### The compiler options:
export CFLAGS = $(call PKGCFG,cflags)
export CFLAGS = $(call PKGCFG,cflags)
export CXXFLAGS = $(call PKGCFG,cxxflags)
ifeq ($(CFLAGS),)
@ -136,16 +136,16 @@ endif
ifeq ($(OPENGL),1)
CONFIG += -DUSE_GLX
_CFLAGS += $(shell pkg-config --cflags gl glu glew)
#LIBS += $(shell pkg-config --libs glu glew)
#LIBS += $(shell pkg-config --libs glu glew)
_CFLAGS += $(shell pkg-config --cflags freetype2)
LIBS += $(shell pkg-config --libs freetype2)
endif
ifeq ($(VAAPI),1)
CONFIG += -DVAAPI
CONFIG += -DVAAPI
#LIBPLACEBO=1
PLUGIN = softhdvaapi
LIBS += -lEGL
LIBS += -lEGL
endif
ifeq ($(LIBPLACEBO),1)
@ -155,7 +155,7 @@ endif
ifeq ($(CUVID),1)
CONFIG += -DUSE_PIP # PIP support
CONFIG += -DCUVID # enable CUVID decoder
LIBS += -lEGL -lGL
LIBS += -lEGL -lGL
ifeq ($(YADIF),1)
CONFIG += -DYADIF # Yadif only with CUVID
endif
@ -173,7 +173,7 @@ SOFILE = libvdr-$(PLUGIN).so
#
# Test that libswresample is available
# Test that libswresample is available
#
#ifneq (exists, $(shell pkg-config libswresample && echo exists))
# $(warning ******************************************************************)
@ -182,7 +182,7 @@ SOFILE = libvdr-$(PLUGIN).so
#endif
#
# Test and set config for libavutil
# Test and set config for libavutil
#
ifneq (exists, $(shell pkg-config libavutil && echo exists))
$(warning ******************************************************************)
@ -193,7 +193,7 @@ _CFLAGS += $(shell pkg-config --cflags libavutil)
LIBS += $(shell pkg-config --libs libavutil)
#
# Test and set config for libswscale
# Test and set config for libswscale
#
ifneq (exists, $(shell pkg-config libswscale && echo exists))
$(warning ******************************************************************)
@ -233,10 +233,10 @@ endif
#_CFLAGS += $(shell pkg-config --cflags libavcodec x11 x11-xcb xcb xcb-icccm)
#LIBS += -lrt $(shell pkg-config --libs libavcodec 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)
_CFLAGS += $(shell pkg-config --cflags 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/usr/local/cuda/include
_CFLAGS += -I./opengl -I./
LIBS += -L/usr/lib64
@ -247,10 +247,10 @@ LIBS += -lplacebo -lglut
endif
ifeq ($(CUVID),1)
LIBS += -lcuda -L/usr/local/cuda/targets/x86_64-linux/lib -lcudart -lnvcuvid
LIBS += -lcuda -L/usr/local/cuda/targets/x86_64-linux/lib -lcudart -lnvcuvid
endif
LIBS += -lGLEW -lGLU -ldl
LIBS += -lGLEW -lGLU -ldl
### Includes and Defines (add further entries here):
INCLUDES +=
@ -261,16 +261,16 @@ DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -D_GNU_SOURCE $(CONFIG) \
### Make it standard
override CXXFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \
-g -Wextra -Winit-self -Werror=overloaded-virtual -std=c++0x
override CFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \
-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 = softhdcuvid.o softhddev.o video.o audio.o codec.o ringbuffer.o
OBJS = softhdcuvid.o softhddev.o video.o audio.o codec.o ringbuffer.o
ifeq ($(OPENGLOSD),1)
OBJS += openglosd.o
OBJS += openglosd.o
endif
SRCS = $(wildcard $(OBJS:.o=.c)) softhdcuvid.cpp
@ -290,11 +290,11 @@ $(DEPFILE): Makefile
### Internationalization (I18N):
PODIR = po
I18Npo = $(wildcard $(PODIR)/*.po)
I18Nmo = $(addsuffix .mo, $(foreach file, $(I18Npo), $(basename $(file))))
PODIR = po
I18Npo = $(wildcard $(PODIR)/*.po)
I18Nmo = $(addsuffix .mo, $(foreach file, $(I18Npo), $(basename $(file))))
I18Nmsgs = $(addprefix $(DESTDIR)$(LOCDIR)/, $(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo, $(notdir $(foreach file, $(I18Npo), $(basename $(file))))))
I18Npot = $(PODIR)/$(PLUGIN).pot
I18Npot = $(PODIR)/$(PLUGIN).pot
%.mo: %.po
msgfmt -c -o $@ $<
@ -322,7 +322,7 @@ $(OBJS): Makefile
$(SOFILE): $(OBJS) shaders.h
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) $(LIBS) -o $@
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) $(LIBS) -o $@
install-lib: $(SOFILE)
install -D $^ $(DESTDIR)$(LIBDIR)/$^.$(APIVERSION)
@ -343,13 +343,11 @@ clean:
## Private Targets:
HDRS= $(wildcard *.h)
HDRS= $(wildcard *.h)
indent:
for i in $(SRCS) $(HDRS); do \
indent $$i; \
unexpand -a $$i | sed -e s/constconst/const/ > $$i.up; \
mv $$i.up $$i; \
done
video_test: video.c Makefile

2807
audio.c

File diff suppressed because it is too large Load Diff

80
audio.h
View File

@ -1,67 +1,67 @@
///
/// @file audio.h @brief Audio module headerfile
/// @file audio.h @brief Audio module headerfile
///
/// Copyright (c) 2009 - 2014 by Johns. All Rights Reserved.
/// Copyright (c) 2009 - 2014 by Johns. All Rights Reserved.
///
/// Contributor(s):
/// Contributor(s):
///
/// License: AGPLv3
/// License: AGPLv3
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
///
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
///
/// $Id: da055758af70cfdb9ab1989d5fcfb218c5d6a366 $
/// $Id: da055758af70cfdb9ab1989d5fcfb218c5d6a366 $
//////////////////////////////////////////////////////////////////////////////
/// @addtogroup Audio
/// @{
//----------------------------------------------------------------------------
// Prototypes
// Prototypes
//----------------------------------------------------------------------------
extern void AudioEnqueue(const void *, int); ///< buffer audio samples
extern void AudioFlushBuffers(void); ///< flush audio buffers
extern void AudioPoller(void); ///< poll audio events/handling
extern int AudioFreeBytes(void); ///< free bytes in audio output
extern int AudioUsedBytes(void); ///< used bytes in audio output
extern int64_t AudioGetDelay(void); ///< get current audio delay
extern void AudioSetClock(int64_t); ///< set audio clock base
extern int64_t AudioGetClock(); ///< get current audio clock
extern void AudioSetVolume(int); ///< set volume
extern int AudioSetup(int *, int *, int); ///< setup audio output
extern void AudioEnqueue(const void *, int); ///< buffer audio samples
extern void AudioFlushBuffers(void); ///< flush audio buffers
extern void AudioPoller(void); ///< poll audio events/handling
extern int AudioFreeBytes(void); ///< free bytes in audio output
extern int AudioUsedBytes(void); ///< used bytes in audio output
extern int64_t AudioGetDelay(void); ///< get current audio delay
extern void AudioSetClock(int64_t); ///< set audio clock base
extern int64_t AudioGetClock(); ///< get current audio clock
extern void AudioSetVolume(int); ///< set volume
extern int AudioSetup(int *, int *, int); ///< setup audio output
extern void AudioPlay(void); ///< play audio
extern void AudioPause(void); ///< pause audio
extern void AudioPlay(void); ///< play audio
extern void AudioPause(void); ///< pause audio
extern void AudioSetBufferTime(int); ///< set audio buffer time
extern void AudioSetSoftvol(int); ///< enable/disable softvol
extern void AudioSetNormalize(int, int); ///< set normalize parameters
extern void AudioSetCompression(int, int); ///< set compression parameters
extern void AudioSetStereoDescent(int); ///< set stereo loudness descent
extern void AudioSetBufferTime(int); ///< set audio buffer time
extern void AudioSetSoftvol(int); ///< enable/disable softvol
extern void AudioSetNormalize(int, int); ///< set normalize parameters
extern void AudioSetCompression(int, int); ///< set compression parameters
extern void AudioSetStereoDescent(int); ///< set stereo loudness descent
extern void AudioSetDevice(const char *); ///< set PCM audio device
extern void AudioSetDevice(const char *); ///< set PCM audio device
/// set pass-through device
extern void AudioSetPassthroughDevice(const char *);
extern void AudioSetChannel(const char *); ///< set mixer channel
extern void AudioSetAutoAES(int); ///< set automatic AES flag handling
extern void AudioInit(void); ///< setup audio module
extern void AudioExit(void); ///< cleanup and exit audio module
extern void AudioSetChannel(const char *); ///< set mixer channel
extern void AudioSetAutoAES(int); ///< set automatic AES flag handling
extern void AudioInit(void); ///< setup audio module
extern void AudioExit(void); ///< cleanup and exit audio module
//----------------------------------------------------------------------------
// Variables
// Variables
//----------------------------------------------------------------------------
extern char AudioAlsaDriverBroken; ///< disable broken driver message
extern char AudioAlsaNoCloseOpen; ///< disable alsa close/open fix
extern char AudioAlsaCloseOpenDelay; ///< enable alsa close/open delay fix
extern char AudioAlsaDriverBroken; ///< disable broken driver message
extern char AudioAlsaNoCloseOpen; ///< disable alsa close/open fix
extern char AudioAlsaCloseOpenDelay; ///< enable alsa close/open delay fix
/// @}

1735
codec.c

File diff suppressed because it is too large Load Diff

128
codec.h
View File

@ -1,97 +1,97 @@
///
/// @file codec.h @brief Codec module headerfile
/// @file codec.h @brief Codec module headerfile
///
/// Copyright (c) 2009 - 2013, 2015 by Johns. All Rights Reserved.
/// Copyright (c) 2009 - 2013, 2015 by Johns. All Rights Reserved.
///
/// Contributor(s):
/// Contributor(s):
///
/// License: AGPLv3
/// License: AGPLv3
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
///
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
///
/// $Id: bdb4d18dbe371e497d039e45faa7c134b019860a $
/// $Id: bdb4d18dbe371e497d039e45faa7c134b019860a $
//////////////////////////////////////////////////////////////////////////////
/// @addtogroup Codec
/// @{
//----------------------------------------------------------------------------
// Defines
// Defines
//----------------------------------------------------------------------------
#define CodecPCM 0x01 ///< PCM bit mask
#define CodecMPA 0x02 ///< MPA bit mask (planned)
#define CodecAC3 0x04 ///< AC-3 bit mask
#define CodecEAC3 0x08 ///< E-AC-3 bit mask
#define CodecDTS 0x10 ///< DTS bit mask (planned)
#define CodecPCM 0x01 ///< PCM bit mask
#define CodecMPA 0x02 ///< MPA bit mask (planned)
#define CodecAC3 0x04 ///< AC-3 bit mask
#define CodecEAC3 0x08 ///< E-AC-3 bit mask
#define CodecDTS 0x10 ///< DTS bit mask (planned)
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000
enum HWAccelID {
HWACCEL_NONE = 0,
HWACCEL_AUTO,
HWACCEL_VDPAU,
HWACCEL_DXVA2,
HWACCEL_VDA,
HWACCEL_VIDEOTOOLBOX,
HWACCEL_QSV,
HWACCEL_VAAPI,
HWACCEL_CUVID,
enum HWAccelID
{
HWACCEL_NONE = 0,
HWACCEL_AUTO,
HWACCEL_VDPAU,
HWACCEL_DXVA2,
HWACCEL_VDA,
HWACCEL_VIDEOTOOLBOX,
HWACCEL_QSV,
HWACCEL_VAAPI,
HWACCEL_CUVID,
};
extern AVBufferRef *hw_device_ctx;
///
/// Video decoder structure.
/// Video decoder structure.
///
struct _video_decoder_
{
VideoHwDecoder *HwDecoder; ///< video hardware decoder
int GetFormatDone; ///< flag get format called!
AVCodec *VideoCodec; ///< video codec
AVCodecContext *VideoCtx; ///< video codec context
//#ifdef FFMPEG_WORKAROUND_ARTIFACTS
int FirstKeyFrame; ///< flag first frame
//#endif
// AVFrame *Frame; ///< decoded video frame
VideoHwDecoder *HwDecoder; ///< video hardware decoder
int filter; // flag for deint filter
int GetFormatDone; ///< flag get format called!
AVCodec *VideoCodec; ///< video codec
AVCodecContext *VideoCtx; ///< video codec context
//#ifdef FFMPEG_WORKAROUND_ARTIFACTS
int FirstKeyFrame; ///< flag first frame
//#endif
// AVFrame *Frame; ///< decoded video frame
/* hwaccel options */
enum HWAccelID hwaccel_id;
char *hwaccel_device;
enum AVPixelFormat hwaccel_output_format;
/* hwaccel context */
enum HWAccelID active_hwaccel_id;
void *hwaccel_ctx;
void (*hwaccel_uninit)(AVCodecContext *s);
int (*hwaccel_get_buffer)(AVCodecContext *s, AVFrame *frame, int flags);
int (*hwaccel_retrieve_data)(AVCodecContext *s, AVFrame *frame);
enum AVPixelFormat hwaccel_pix_fmt;
enum AVPixelFormat hwaccel_retrieved_pix_fmt;
AVBufferRef *hw_frames_ctx;
int filter; // flag for deint filter
void *hwdec_priv;
// For HDR side-data caching
double cached_hdr_peak;
// From VO
struct mp_hwdec_devices *hwdec_devs;
/* hwaccel options */
enum HWAccelID hwaccel_id;
char *hwaccel_device;
enum AVPixelFormat hwaccel_output_format;
/* hwaccel context */
enum HWAccelID active_hwaccel_id;
void *hwaccel_ctx;
void (*hwaccel_uninit)(AVCodecContext * s);
int (*hwaccel_get_buffer)(AVCodecContext * s, AVFrame * frame, int flags);
int (*hwaccel_retrieve_data)(AVCodecContext * s, AVFrame * frame);
enum AVPixelFormat hwaccel_pix_fmt;
enum AVPixelFormat hwaccel_retrieved_pix_fmt;
AVBufferRef *hw_frames_ctx;
void *hwdec_priv;
// For HDR side-data caching
double cached_hdr_peak;
// From VO
struct mp_hwdec_devices *hwdec_devs;
};
//----------------------------------------------------------------------------
// Typedefs
// Typedefs
//----------------------------------------------------------------------------
/// Video decoder typedef.
@ -111,14 +111,14 @@ extern const char *X11DisplayName;
extern AVBufferRef *HwDeviceContext;
//----------------------------------------------------------------------------
// Variables
// Variables
//----------------------------------------------------------------------------
/// Flag prefer fast xhannel switch
extern char CodecUsePossibleDefectFrames;
//----------------------------------------------------------------------------
// Prototypes
// Prototypes
//----------------------------------------------------------------------------
/// Allocate a new video decoder context.

297
common.h
View File

@ -1,3 +1,4 @@
/*
* This file is part of mpv.
*
@ -8,7 +9,7 @@
*
* mpv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
@ -52,22 +53,23 @@
struct GL;
typedef struct GL GL;
enum {
MPGL_CAP_ROW_LENGTH = (1 << 4), // GL_[UN]PACK_ROW_LENGTH
MPGL_CAP_FB = (1 << 5),
MPGL_CAP_VAO = (1 << 6),
MPGL_CAP_TEX_RG = (1 << 10), // GL_ARB_texture_rg / GL 3.x
MPGL_CAP_VDPAU = (1 << 11), // GL_NV_vdpau_interop
MPGL_CAP_APPLE_RGB_422 = (1 << 12), // GL_APPLE_rgb_422
MPGL_CAP_1D_TEX = (1 << 14),
MPGL_CAP_3D_TEX = (1 << 15),
MPGL_CAP_DEBUG = (1 << 16),
MPGL_CAP_DXINTEROP = (1 << 17), // WGL_NV_DX_interop
MPGL_CAP_EXT16 = (1 << 18), // GL_EXT_texture_norm16
MPGL_CAP_ARB_FLOAT = (1 << 19), // GL_ARB_texture_float
MPGL_CAP_EXT_CR_HFLOAT = (1 << 20), // GL_EXT_color_buffer_half_float
enum
{
MPGL_CAP_ROW_LENGTH = (1 << 4), // GL_[UN]PACK_ROW_LENGTH
MPGL_CAP_FB = (1 << 5),
MPGL_CAP_VAO = (1 << 6),
MPGL_CAP_TEX_RG = (1 << 10), // GL_ARB_texture_rg / GL 3.x
MPGL_CAP_VDPAU = (1 << 11), // GL_NV_vdpau_interop
MPGL_CAP_APPLE_RGB_422 = (1 << 12), // GL_APPLE_rgb_422
MPGL_CAP_1D_TEX = (1 << 14),
MPGL_CAP_3D_TEX = (1 << 15),
MPGL_CAP_DEBUG = (1 << 16),
MPGL_CAP_DXINTEROP = (1 << 17), // WGL_NV_DX_interop
MPGL_CAP_EXT16 = (1 << 18), // GL_EXT_texture_norm16
MPGL_CAP_ARB_FLOAT = (1 << 19), // GL_ARB_texture_float
MPGL_CAP_EXT_CR_HFLOAT = (1 << 20), // GL_EXT_color_buffer_half_float
MPGL_CAP_SW = (1 << 30), // indirect or sw renderer
MPGL_CAP_SW = (1 << 30), // indirect or sw renderer
};
// E.g. 310 means 3.1
@ -78,167 +80,146 @@ enum {
#define MPGL_VER_P(ver) MPGL_VER_GET_MAJOR(ver), MPGL_VER_GET_MINOR(ver)
void mpgl_load_functions(GL *gl, void *(*getProcAddress)(const GLubyte *),
const char *ext2, struct mp_log *log);
void mpgl_load_functions2(GL *gl, void *(*get_fn)(void *ctx, const char *n),
void *fn_ctx, const char *ext2, struct mp_log *log);
void mpgl_load_functions(GL * gl, void *(*getProcAddress)(const GLubyte *), const char *ext2, struct mp_log *log);
void mpgl_load_functions2(GL * gl, void *(*get_fn)(void *ctx, const char *n), void *fn_ctx, const char *ext2,
struct mp_log *log);
typedef void (GLAPIENTRY *MP_GLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum,
GLsizei, const GLchar *,const void *);
typedef void (GLAPIENTRY * MP_GLDEBUGPROC) (GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *, const void *);
//function pointers loaded from the OpenGL library
struct GL {
int version; // MPGL_VER() mangled (e.g. 210 for 2.1)
int es; // es version (e.g. 300), 0 for desktop GL
int glsl_version; // e.g. 130 for GLSL 1.30
char *extensions; // Equivalent to GL_EXTENSIONS
int mpgl_caps; // Bitfield of MPGL_CAP_* constants
bool debug_context; // use of e.g. GLX_CONTEXT_DEBUG_BIT_ARB
GLuint main_fb; // framebuffer to render to (normally 0)
struct GL
{
int version; // MPGL_VER() mangled (e.g. 210 for 2.1)
int es; // es version (e.g. 300), 0 for desktop GL
int glsl_version; // e.g. 130 for GLSL 1.30
char *extensions; // Equivalent to GL_EXTENSIONS
int mpgl_caps; // Bitfield of MPGL_CAP_* constants
bool debug_context; // use of e.g. GLX_CONTEXT_DEBUG_BIT_ARB
GLuint main_fb; // framebuffer to render to (normally 0)
void (GLAPIENTRY *Viewport)(GLint, GLint, GLsizei, GLsizei);
void (GLAPIENTRY *Clear)(GLbitfield);
void (GLAPIENTRY *GenTextures)(GLsizei, GLuint *);
void (GLAPIENTRY *DeleteTextures)(GLsizei, const GLuint *);
void (GLAPIENTRY *ClearColor)(GLclampf, GLclampf, GLclampf, GLclampf);
void (GLAPIENTRY *Enable)(GLenum);
void (GLAPIENTRY *Disable)(GLenum);
const GLubyte *(GLAPIENTRY * GetString)(GLenum);
void (GLAPIENTRY *BlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum);
void (GLAPIENTRY *Flush)(void);
void (GLAPIENTRY *Finish)(void);
void (GLAPIENTRY *PixelStorei)(GLenum, GLint);
void (GLAPIENTRY *TexImage1D)(GLenum, GLint, GLint, GLsizei, GLint,
GLenum, GLenum, const GLvoid *);
void (GLAPIENTRY *TexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei,
GLint, GLenum, GLenum, const GLvoid *);
void (GLAPIENTRY *TexSubImage2D)(GLenum, GLint, GLint, GLint,
GLsizei, GLsizei, GLenum, GLenum,
const GLvoid *);
void (GLAPIENTRY *TexParameteri)(GLenum, GLenum, GLint);
void (GLAPIENTRY *GetIntegerv)(GLenum, GLint *);
void (GLAPIENTRY *ReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum,
GLenum, GLvoid *);
void (GLAPIENTRY *ReadBuffer)(GLenum);
void (GLAPIENTRY *DrawArrays)(GLenum, GLint, GLsizei);
GLenum (GLAPIENTRY *GetError)(void);
void (GLAPIENTRY *GetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *);
void (GLAPIENTRY *Scissor)(GLint, GLint, GLsizei, GLsizei);
void (GLAPIENTRY * Viewport) (GLint, GLint, GLsizei, GLsizei);
void (GLAPIENTRY * Clear) (GLbitfield);
void (GLAPIENTRY * GenTextures) (GLsizei, GLuint *);
void (GLAPIENTRY * DeleteTextures) (GLsizei, const GLuint *);
void (GLAPIENTRY * ClearColor) (GLclampf, GLclampf, GLclampf, GLclampf);
void (GLAPIENTRY * Enable) (GLenum);
void (GLAPIENTRY * Disable) (GLenum);
const GLubyte *(GLAPIENTRY * GetString) (GLenum);
void (GLAPIENTRY * BlendFuncSeparate) (GLenum, GLenum, GLenum, GLenum);
void (GLAPIENTRY * Flush) (void);
void (GLAPIENTRY * Finish) (void);
void (GLAPIENTRY * PixelStorei) (GLenum, GLint);
void (GLAPIENTRY * TexImage1D) (GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
void (GLAPIENTRY * TexImage2D) (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
void (GLAPIENTRY * TexSubImage2D) (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
void (GLAPIENTRY * TexParameteri) (GLenum, GLenum, GLint);
void (GLAPIENTRY * GetIntegerv) (GLenum, GLint *);
void (GLAPIENTRY * ReadPixels) (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *);
void (GLAPIENTRY * ReadBuffer) (GLenum);
void (GLAPIENTRY * DrawArrays) (GLenum, GLint, GLsizei);
GLenum(GLAPIENTRY * GetError) (void);
void (GLAPIENTRY * GetTexLevelParameteriv) (GLenum, GLint, GLenum, GLint *);
void (GLAPIENTRY * Scissor) (GLint, GLint, GLsizei, GLsizei);
void (GLAPIENTRY *GenBuffers)(GLsizei, GLuint *);
void (GLAPIENTRY *DeleteBuffers)(GLsizei, const GLuint *);
void (GLAPIENTRY *BindBuffer)(GLenum, GLuint);
void (GLAPIENTRY *BindBufferBase)(GLenum, GLuint, GLuint);
GLvoid * (GLAPIENTRY *MapBufferRange)(GLenum, GLintptr, GLsizeiptr,
GLbitfield);
GLboolean (GLAPIENTRY *UnmapBuffer)(GLenum);
void (GLAPIENTRY *BufferData)(GLenum, intptr_t, const GLvoid *, GLenum);
void (GLAPIENTRY *ActiveTexture)(GLenum);
void (GLAPIENTRY *BindTexture)(GLenum, GLuint);
int (GLAPIENTRY *SwapInterval)(int);
void (GLAPIENTRY *TexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei,
GLsizei, GLint, GLenum, GLenum,
const GLvoid *);
void (GLAPIENTRY * GenBuffers) (GLsizei, GLuint *);
void (GLAPIENTRY * DeleteBuffers) (GLsizei, const GLuint *);
void (GLAPIENTRY * BindBuffer) (GLenum, GLuint);
void (GLAPIENTRY * BindBufferBase) (GLenum, GLuint, GLuint);
GLvoid *(GLAPIENTRY * MapBufferRange) (GLenum, GLintptr, GLsizeiptr, GLbitfield);
GLboolean(GLAPIENTRY * UnmapBuffer) (GLenum);
void (GLAPIENTRY * BufferData) (GLenum, intptr_t, const GLvoid *, GLenum);
void (GLAPIENTRY * ActiveTexture) (GLenum);
void (GLAPIENTRY * BindTexture) (GLenum, GLuint);
int (GLAPIENTRY * SwapInterval) (int);
void (GLAPIENTRY * TexImage3D) (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum,
const GLvoid *);
void (GLAPIENTRY *GenVertexArrays)(GLsizei, GLuint *);
void (GLAPIENTRY *BindVertexArray)(GLuint);
GLint (GLAPIENTRY *GetAttribLocation)(GLuint, const GLchar *);
void (GLAPIENTRY *EnableVertexAttribArray)(GLuint);
void (GLAPIENTRY *DisableVertexAttribArray)(GLuint);
void (GLAPIENTRY *VertexAttribPointer)(GLuint, GLint, GLenum, GLboolean,
GLsizei, const GLvoid *);
void (GLAPIENTRY *DeleteVertexArrays)(GLsizei, const GLuint *);
void (GLAPIENTRY *UseProgram)(GLuint);
GLint (GLAPIENTRY *GetUniformLocation)(GLuint, const GLchar *);
void (GLAPIENTRY *CompileShader)(GLuint);
GLuint (GLAPIENTRY *CreateProgram)(void);
GLuint (GLAPIENTRY *CreateShader)(GLenum);
void (GLAPIENTRY *ShaderSource)(GLuint, GLsizei, const GLchar **,
const GLint *);
void (GLAPIENTRY *LinkProgram)(GLuint);
void (GLAPIENTRY *AttachShader)(GLuint, GLuint);
void (GLAPIENTRY *DeleteShader)(GLuint);
void (GLAPIENTRY *DeleteProgram)(GLuint);
void (GLAPIENTRY *GetShaderInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *);
void (GLAPIENTRY *GetShaderiv)(GLuint, GLenum, GLint *);
void (GLAPIENTRY *GetProgramInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *);
void (GLAPIENTRY *GetProgramiv)(GLenum, GLenum, GLint *);
const GLubyte* (GLAPIENTRY *GetStringi)(GLenum, GLuint);
void (GLAPIENTRY *BindAttribLocation)(GLuint, GLuint, const GLchar *);
void (GLAPIENTRY *BindFramebuffer)(GLenum, GLuint);
void (GLAPIENTRY *GenFramebuffers)(GLsizei, GLuint *);
void (GLAPIENTRY *DeleteFramebuffers)(GLsizei, const GLuint *);
GLenum (GLAPIENTRY *CheckFramebufferStatus)(GLenum);
void (GLAPIENTRY *FramebufferTexture2D)(GLenum, GLenum, GLenum, GLuint,
GLint);
void (GLAPIENTRY *BlitFramebuffer)(GLint, GLint, GLint, GLint, GLint, GLint,
GLint, GLint, GLbitfield, GLenum);
void (GLAPIENTRY *GetFramebufferAttachmentParameteriv)(GLenum, GLenum,
GLenum, GLint *);
void (GLAPIENTRY * GenVertexArrays) (GLsizei, GLuint *);
void (GLAPIENTRY * BindVertexArray) (GLuint);
GLint(GLAPIENTRY * GetAttribLocation) (GLuint, const GLchar *);
void (GLAPIENTRY * EnableVertexAttribArray) (GLuint);
void (GLAPIENTRY * DisableVertexAttribArray) (GLuint);
void (GLAPIENTRY * VertexAttribPointer) (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *);
void (GLAPIENTRY * DeleteVertexArrays) (GLsizei, const GLuint *);
void (GLAPIENTRY * UseProgram) (GLuint);
GLint(GLAPIENTRY * GetUniformLocation) (GLuint, const GLchar *);
void (GLAPIENTRY * CompileShader) (GLuint);
GLuint(GLAPIENTRY * CreateProgram) (void);
GLuint(GLAPIENTRY * CreateShader) (GLenum);
void (GLAPIENTRY * ShaderSource) (GLuint, GLsizei, const GLchar **, const GLint *);
void (GLAPIENTRY * LinkProgram) (GLuint);
void (GLAPIENTRY * AttachShader) (GLuint, GLuint);
void (GLAPIENTRY * DeleteShader) (GLuint);
void (GLAPIENTRY * DeleteProgram) (GLuint);
void (GLAPIENTRY * GetShaderInfoLog) (GLuint, GLsizei, GLsizei *, GLchar *);
void (GLAPIENTRY * GetShaderiv) (GLuint, GLenum, GLint *);
void (GLAPIENTRY * GetProgramInfoLog) (GLuint, GLsizei, GLsizei *, GLchar *);
void (GLAPIENTRY * GetProgramiv) (GLenum, GLenum, GLint *);
const GLubyte *(GLAPIENTRY * GetStringi) (GLenum, GLuint);
void (GLAPIENTRY * BindAttribLocation) (GLuint, GLuint, const GLchar *);
void (GLAPIENTRY * BindFramebuffer) (GLenum, GLuint);
void (GLAPIENTRY * GenFramebuffers) (GLsizei, GLuint *);
void (GLAPIENTRY * DeleteFramebuffers) (GLsizei, const GLuint *);
GLenum(GLAPIENTRY * CheckFramebufferStatus) (GLenum);
void (GLAPIENTRY * FramebufferTexture2D) (GLenum, GLenum, GLenum, GLuint, GLint);
void (GLAPIENTRY * BlitFramebuffer) (GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum);
void (GLAPIENTRY * GetFramebufferAttachmentParameteriv) (GLenum, GLenum, GLenum, GLint *);
void (GLAPIENTRY *Uniform1f)(GLint, GLfloat);
void (GLAPIENTRY *Uniform2f)(GLint, GLfloat, GLfloat);
void (GLAPIENTRY *Uniform3f)(GLint, GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY *Uniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY *Uniform1i)(GLint, GLint);
void (GLAPIENTRY *UniformMatrix2fv)(GLint, GLsizei, GLboolean,
const GLfloat *);
void (GLAPIENTRY *UniformMatrix3fv)(GLint, GLsizei, GLboolean,
const GLfloat *);
void (GLAPIENTRY * Uniform1f) (GLint, GLfloat);
void (GLAPIENTRY * Uniform2f) (GLint, GLfloat, GLfloat);
void (GLAPIENTRY * Uniform3f) (GLint, GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY * Uniform4f) (GLint, GLfloat, GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY * Uniform1i) (GLint, GLint);
void (GLAPIENTRY * UniformMatrix2fv) (GLint, GLsizei, GLboolean, const GLfloat *);
void (GLAPIENTRY * UniformMatrix3fv) (GLint, GLsizei, GLboolean, const GLfloat *);
void (GLAPIENTRY *InvalidateFramebuffer)(GLenum, GLsizei, const GLenum *);
void (GLAPIENTRY * InvalidateFramebuffer) (GLenum, GLsizei, const GLenum *);
GLsync (GLAPIENTRY *FenceSync)(GLenum, GLbitfield);
GLenum (GLAPIENTRY *ClientWaitSync)(GLsync, GLbitfield, GLuint64);
void (GLAPIENTRY *DeleteSync)(GLsync sync);
GLsync(GLAPIENTRY * FenceSync) (GLenum, GLbitfield);
GLenum(GLAPIENTRY * ClientWaitSync) (GLsync, GLbitfield, GLuint64);
void (GLAPIENTRY * DeleteSync) (GLsync sync);
void (GLAPIENTRY *GenQueries)(GLsizei, GLuint *);
void (GLAPIENTRY *DeleteQueries)(GLsizei, const GLuint *);
void (GLAPIENTRY *BeginQuery)(GLenum, GLuint);
void (GLAPIENTRY *EndQuery)(GLenum);
void (GLAPIENTRY *QueryCounter)(GLuint, GLenum);
GLboolean (GLAPIENTRY *IsQuery)(GLuint);
void (GLAPIENTRY *GetQueryObjectiv)(GLuint, GLenum, GLint *);
void (GLAPIENTRY *GetQueryObjecti64v)(GLuint, GLenum, GLint64 *);
void (GLAPIENTRY *GetQueryObjectuiv)(GLuint, GLenum, GLuint *);
void (GLAPIENTRY *GetQueryObjectui64v)(GLuint, GLenum, GLuint64 *);
void (GLAPIENTRY * GenQueries) (GLsizei, GLuint *);
void (GLAPIENTRY * DeleteQueries) (GLsizei, const GLuint *);
void (GLAPIENTRY * BeginQuery) (GLenum, GLuint);
void (GLAPIENTRY * EndQuery) (GLenum);
void (GLAPIENTRY * QueryCounter) (GLuint, GLenum);
GLboolean(GLAPIENTRY * IsQuery) (GLuint);
void (GLAPIENTRY * GetQueryObjectiv) (GLuint, GLenum, GLint *);
void (GLAPIENTRY * GetQueryObjecti64v) (GLuint, GLenum, GLint64 *);
void (GLAPIENTRY * GetQueryObjectuiv) (GLuint, GLenum, GLuint *);
void (GLAPIENTRY * GetQueryObjectui64v) (GLuint, GLenum, GLuint64 *);
void (GLAPIENTRY *VDPAUInitNV)(const GLvoid *, const GLvoid *);
void (GLAPIENTRY *VDPAUFiniNV)(void);
GLvdpauSurfaceNV (GLAPIENTRY *VDPAURegisterOutputSurfaceNV)
(GLvoid *, GLenum, GLsizei, const GLuint *);
GLvdpauSurfaceNV (GLAPIENTRY *VDPAURegisterVideoSurfaceNV)
(GLvoid *, GLenum, GLsizei, const GLuint *);
void (GLAPIENTRY *VDPAUUnregisterSurfaceNV)(GLvdpauSurfaceNV);
void (GLAPIENTRY *VDPAUSurfaceAccessNV)(GLvdpauSurfaceNV, GLenum);
void (GLAPIENTRY *VDPAUMapSurfacesNV)(GLsizei, const GLvdpauSurfaceNV *);
void (GLAPIENTRY *VDPAUUnmapSurfacesNV)(GLsizei, const GLvdpauSurfaceNV *);
void (GLAPIENTRY * VDPAUInitNV) (const GLvoid *, const GLvoid *);
void (GLAPIENTRY * VDPAUFiniNV) (void);
GLvdpauSurfaceNV(GLAPIENTRY * VDPAURegisterOutputSurfaceNV)
(GLvoid *, GLenum, GLsizei, const GLuint *);
GLvdpauSurfaceNV(GLAPIENTRY * VDPAURegisterVideoSurfaceNV)
(GLvoid *, GLenum, GLsizei, const GLuint *);
void (GLAPIENTRY * VDPAUUnregisterSurfaceNV) (GLvdpauSurfaceNV);
void (GLAPIENTRY * VDPAUSurfaceAccessNV) (GLvdpauSurfaceNV, GLenum);
void (GLAPIENTRY * VDPAUMapSurfacesNV) (GLsizei, const GLvdpauSurfaceNV *);
void (GLAPIENTRY * VDPAUUnmapSurfacesNV) (GLsizei, const GLvdpauSurfaceNV *);
#if HAVE_GL_WIN32
// The HANDLE type might not be present on non-Win32
BOOL (GLAPIENTRY *DXSetResourceShareHandleNV)(void *dxObject,
HANDLE shareHandle);
HANDLE (GLAPIENTRY *DXOpenDeviceNV)(void *dxDevice);
BOOL (GLAPIENTRY *DXCloseDeviceNV)(HANDLE hDevice);
HANDLE (GLAPIENTRY *DXRegisterObjectNV)(HANDLE hDevice, void *dxObject,
GLuint name, GLenum type, GLenum access);
BOOL (GLAPIENTRY *DXUnregisterObjectNV)(HANDLE hDevice, HANDLE hObject);
BOOL (GLAPIENTRY *DXLockObjectsNV)(HANDLE hDevice, GLint count,
HANDLE *hObjects);
BOOL (GLAPIENTRY *DXUnlockObjectsNV)(HANDLE hDevice, GLint count,
HANDLE *hObjects);
BOOL(GLAPIENTRY * DXSetResourceShareHandleNV) (void *dxObject, HANDLE shareHandle);
HANDLE(GLAPIENTRY * DXOpenDeviceNV) (void *dxDevice);
BOOL(GLAPIENTRY * DXCloseDeviceNV) (HANDLE hDevice);
HANDLE(GLAPIENTRY * DXRegisterObjectNV) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
BOOL(GLAPIENTRY * DXUnregisterObjectNV) (HANDLE hDevice, HANDLE hObject);
BOOL(GLAPIENTRY * DXLockObjectsNV) (HANDLE hDevice, GLint count, HANDLE * hObjects);
BOOL(GLAPIENTRY * DXUnlockObjectsNV) (HANDLE hDevice, GLint count, HANDLE * hObjects);
#endif
GLint (GLAPIENTRY *GetVideoSync)(GLuint *);
GLint (GLAPIENTRY *WaitVideoSync)(GLint, GLint, unsigned int *);
GLint(GLAPIENTRY * GetVideoSync) (GLuint *);
GLint(GLAPIENTRY * WaitVideoSync) (GLint, GLint, unsigned int *);
void (GLAPIENTRY *GetTranslatedShaderSourceANGLE)(GLuint, GLsizei,
GLsizei*, GLchar* source);
void (GLAPIENTRY * GetTranslatedShaderSourceANGLE) (GLuint, GLsizei, GLsizei *, GLchar * source);
void (GLAPIENTRY *DebugMessageCallback)(MP_GLDEBUGPROC callback,
const void *userParam);
void (GLAPIENTRY * DebugMessageCallback) (MP_GLDEBUGPROC callback, const void *userParam);
void *(GLAPIENTRY *MPGetNativeDisplay)(const char *name);
void *(GLAPIENTRY * MPGetNativeDisplay) (const char *name);
};
#endif /* MPLAYER_GL_COMMON_H */

View File

@ -1,3 +1,4 @@
/*
* This file is part of libplacebo.
*
@ -8,7 +9,7 @@
*
* libplacebo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
@ -39,5 +40,4 @@
#define PL_HAVE_SHADERC 0
#define PL_HAVE_VULKAN 1
#endif // LIBPLACEBO_CONTEXT_H_

View File

@ -1,3 +1,4 @@
/*
* Copyright 1993-2013 NVIDIA Corporation. All rights reserved.
*
@ -16,88 +17,91 @@
#include <string.h>
#include <stdlib.h>
#ifdef __cuda_cuda_h__ // check to see if CUDA_H is included above
#ifdef __cuda_cuda_h__ // check to see if CUDA_H is included above
// Error Code string definitions here
typedef struct
{
char const *error_string;
unsigned int error_id;
unsigned int error_id;
} s_CudaErrorStr;
/**
* Error codes
*/
s_CudaErrorStr sCudaDrvErrorString[] =
{
s_CudaErrorStr sCudaDrvErrorString[] = {
/**
* The API call returned with no errors. In the case of query calls, this
* can also mean that the operation being queried is complete (see
* ::cuEventQuery() and ::cuStreamQuery()).
*/
{ "CUDA_SUCCESS", 0 },
{"CUDA_SUCCESS", 0},
/**
* This indicates that one or more of the parameters passed to the API call
* is not within an acceptable range of values.
*/
{ "CUDA_ERROR_INVALID_VALUE", 1 },
{"CUDA_ERROR_INVALID_VALUE", 1},
/**
* The API call failed because it was unable to allocate enough memory to
* perform the requested operation.
*/
{ "CUDA_ERROR_OUT_OF_MEMORY", 2 },
{"CUDA_ERROR_OUT_OF_MEMORY", 2},
/**
* This indicates that the CUDA driver has not been initialized with
* ::cuInit() or that initialization has failed.
*/
{ "CUDA_ERROR_NOT_INITIALIZED", 3 },
{"CUDA_ERROR_NOT_INITIALIZED", 3},
/**
* This indicates that the CUDA driver is in the process of shutting down.
*/
{ "CUDA_ERROR_DEINITIALIZED", 4 },
{"CUDA_ERROR_DEINITIALIZED", 4},
/**
* This indicates profiling APIs are called while application is running
* in visual profiler mode.
*/
{ "CUDA_ERROR_PROFILER_DISABLED", 5 },
{"CUDA_ERROR_PROFILER_DISABLED", 5},
/**
* This indicates profiling has not been initialized for this context.
* Call cuProfilerInitialize() to resolve this.
*/
{ "CUDA_ERROR_PROFILER_NOT_INITIALIZED", 6 },
{"CUDA_ERROR_PROFILER_NOT_INITIALIZED", 6},
/**
* This indicates profiler has already been started and probably
* cuProfilerStart() is incorrectly called.
*/
{ "CUDA_ERROR_PROFILER_ALREADY_STARTED", 7 },
{"CUDA_ERROR_PROFILER_ALREADY_STARTED", 7},
/**
* This indicates profiler has already been stopped and probably
* cuProfilerStop() is incorrectly called.
*/
{ "CUDA_ERROR_PROFILER_ALREADY_STOPPED", 8 },
{"CUDA_ERROR_PROFILER_ALREADY_STOPPED", 8},
/**
* This indicates that no CUDA-capable devices were detected by the installed
* CUDA driver.
*/
{ "CUDA_ERROR_NO_DEVICE (no CUDA-capable devices were detected)", 100 },
{"CUDA_ERROR_NO_DEVICE (no CUDA-capable devices were detected)", 100},
/**
* This indicates that the device ordinal supplied by the user does not
* correspond to a valid CUDA device.
*/
{ "CUDA_ERROR_INVALID_DEVICE (device specified is not a valid CUDA device)", 101 },
{"CUDA_ERROR_INVALID_DEVICE (device specified is not a valid CUDA device)", 101},
/**
* This indicates that the device kernel image is invalid. This can also
* indicate an invalid CUDA module.
*/
{ "CUDA_ERROR_INVALID_IMAGE", 200 },
{"CUDA_ERROR_INVALID_IMAGE", 200},
/**
* This most frequently indicates that there is no context bound to the
@ -107,7 +111,7 @@ s_CudaErrorStr sCudaDrvErrorString[] =
* mixes different API versions (i.e. 3010 context with 3020 API calls).
* See ::cuCtxGetApiVersion() for more details.
*/
{ "CUDA_ERROR_INVALID_CONTEXT", 201 },
{"CUDA_ERROR_INVALID_CONTEXT", 201},
/**
* This indicated that the context being supplied as a parameter to the
@ -116,28 +120,28 @@ s_CudaErrorStr sCudaDrvErrorString[] =
* This error return is deprecated as of CUDA 3.2. It is no longer an
* error to attempt to push the active context via ::cuCtxPushCurrent().
*/
{ "CUDA_ERROR_CONTEXT_ALREADY_CURRENT", 202 },
{"CUDA_ERROR_CONTEXT_ALREADY_CURRENT", 202},
/**
* This indicates that a map or register operation has failed.
*/
{ "CUDA_ERROR_MAP_FAILED", 205 },
{"CUDA_ERROR_MAP_FAILED", 205},
/**
* This indicates that an unmap or unregister operation has failed.
*/
{ "CUDA_ERROR_UNMAP_FAILED", 206 },
{"CUDA_ERROR_UNMAP_FAILED", 206},
/**
* This indicates that the specified array is currently mapped and thus
* cannot be destroyed.
*/
{ "CUDA_ERROR_ARRAY_IS_MAPPED", 207 },
{"CUDA_ERROR_ARRAY_IS_MAPPED", 207},
/**
* This indicates that the resource is already mapped.
*/
{ "CUDA_ERROR_ALREADY_MAPPED", 208 },
{"CUDA_ERROR_ALREADY_MAPPED", 208},
/**
* This indicates that there is no kernel image available that is suitable
@ -145,115 +149,112 @@ s_CudaErrorStr sCudaDrvErrorString[] =
* options for a particular CUDA source file that do not include the
* corresponding device configuration.
*/
{ "CUDA_ERROR_NO_BINARY_FOR_GPU", 209 },
{"CUDA_ERROR_NO_BINARY_FOR_GPU", 209},
/**
* This indicates that a resource has already been acquired.
*/
{ "CUDA_ERROR_ALREADY_ACQUIRED", 210 },
{"CUDA_ERROR_ALREADY_ACQUIRED", 210},
/**
* This indicates that a resource is not mapped.
*/
{ "CUDA_ERROR_NOT_MAPPED", 211 },
{"CUDA_ERROR_NOT_MAPPED", 211},
/**
* This indicates that a mapped resource is not available for access as an
* array.
*/
{ "CUDA_ERROR_NOT_MAPPED_AS_ARRAY", 212 },
{"CUDA_ERROR_NOT_MAPPED_AS_ARRAY", 212},
/**
* This indicates that a mapped resource is not available for access as a
* pointer.
*/
{ "CUDA_ERROR_NOT_MAPPED_AS_POINTER", 213 },
{"CUDA_ERROR_NOT_MAPPED_AS_POINTER", 213},
/**
* This indicates that an uncorrectable ECC error was detected during
* execution.
*/
{ "CUDA_ERROR_ECC_UNCORRECTABLE", 214 },
{"CUDA_ERROR_ECC_UNCORRECTABLE", 214},
/**
* This indicates that the ::CUlimit passed to the API call is not
* supported by the active device.
*/
{ "CUDA_ERROR_UNSUPPORTED_LIMIT", 215 },
{"CUDA_ERROR_UNSUPPORTED_LIMIT", 215},
/**
* This indicates that the ::CUcontext passed to the API call can
* only be bound to a single CPU thread at a time but is already
* bound to a CPU thread.
*/
{ "CUDA_ERROR_CONTEXT_ALREADY_IN_USE", 216 },
{"CUDA_ERROR_CONTEXT_ALREADY_IN_USE", 216},
/**
* This indicates that peer access is not supported across the given
* devices.
*/
{ "CUDA_ERROR_PEER_ACCESS_UNSUPPORTED", 217 },
{"CUDA_ERROR_PEER_ACCESS_UNSUPPORTED", 217},
/**
* This indicates that a PTX JIT compilation failed.
*/
{ "CUDA_ERROR_INVALID_PTX", 218 },
{"CUDA_ERROR_INVALID_PTX", 218},
/**
* This indicates an error with OpenGL or DirectX context.
*/
{ "CUDA_ERROR_INVALID_GRAPHICS_CONTEXT", 219 },
{"CUDA_ERROR_INVALID_GRAPHICS_CONTEXT", 219},
/**
* This indicates that an uncorrectable NVLink error was detected during the
* execution.
*/
{ "CUDA_ERROR_NVLINK_UNCORRECTABLE", 220 },
{"CUDA_ERROR_NVLINK_UNCORRECTABLE", 220},
/**
* This indicates that the PTX JIT compiler library was not found.
*/
{ "CUDA_ERROR_JIT_COMPILER_NOT_FOUND", 221 },
{"CUDA_ERROR_JIT_COMPILER_NOT_FOUND", 221},
/**
* This indicates that the device kernel source is invalid.
*/
{ "CUDA_ERROR_INVALID_SOURCE", 300 },
{"CUDA_ERROR_INVALID_SOURCE", 300},
/**
* This indicates that the file specified was not found.
*/
{ "CUDA_ERROR_FILE_NOT_FOUND", 301 },
{"CUDA_ERROR_FILE_NOT_FOUND", 301},
/**
* This indicates that a link to a shared object failed to resolve.
*/
{ "CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND", 302 },
{"CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND", 302},
/**
* This indicates that initialization of a shared object failed.
*/
{ "CUDA_ERROR_SHARED_OBJECT_INIT_FAILED", 303 },
{"CUDA_ERROR_SHARED_OBJECT_INIT_FAILED", 303},
/**
* This indicates that an OS call failed.
*/
{ "CUDA_ERROR_OPERATING_SYSTEM", 304 },
{"CUDA_ERROR_OPERATING_SYSTEM", 304},
/**
* This indicates that a resource handle passed to the API call was not
* valid. Resource handles are opaque types like ::CUstream and ::CUevent.
*/
{ "CUDA_ERROR_INVALID_HANDLE", 400 },
{"CUDA_ERROR_INVALID_HANDLE", 400},
/**
* This indicates that a named symbol was not found. Examples of symbols
* are global/constant variable names, texture names }, and surface names.
*/
{ "CUDA_ERROR_NOT_FOUND", 500 },
{"CUDA_ERROR_NOT_FOUND", 500},
/**
* This indicates that asynchronous operations issued previously have not
@ -261,8 +262,7 @@ s_CudaErrorStr sCudaDrvErrorString[] =
* differently than ::CUDA_SUCCESS (which indicates completion). Calls that
* may return this value include ::cuEventQuery() and ::cuStreamQuery().
*/
{ "CUDA_ERROR_NOT_READY", 600 },
{"CUDA_ERROR_NOT_READY", 600},
/**
* While executing a kernel, the device encountered a
@ -271,7 +271,7 @@ s_CudaErrorStr sCudaDrvErrorString[] =
* will return the same error. To continue using CUDA, the process must be terminated
* and relaunched.
*/
{ "CUDA_ERROR_ILLEGAL_ADDRESS", 700 },
{"CUDA_ERROR_ILLEGAL_ADDRESS", 700},
/**
* This indicates that a launch did not occur because it did not have
@ -282,7 +282,7 @@ s_CudaErrorStr sCudaDrvErrorString[] =
* when a 32-bit int is expected) is equivalent to passing too many
* arguments and can also result in this error.
*/
{ "CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES", 701 },
{"CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES", 701},
/**
* This indicates that the device kernel took too long to execute. This can
@ -293,40 +293,40 @@ s_CudaErrorStr sCudaDrvErrorString[] =
* this context are invalid and must be reconstructed if the program is to
* continue using CUDA.
*/
{ "CUDA_ERROR_LAUNCH_TIMEOUT", 702 },
{"CUDA_ERROR_LAUNCH_TIMEOUT", 702},
/**
* This error indicates a kernel launch that uses an incompatible texturing
* mode.
*/
{ "CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING", 703 },
{"CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING", 703},
/**
* This error indicates that a call to ::cuCtxEnablePeerAccess() is
* trying to re-enable peer access to a context which has already
* had peer access to it enabled.
*/
{ "CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED", 704 },
{"CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED", 704},
/**
* This error indicates that ::cuCtxDisablePeerAccess() is
* trying to disable peer access which has not been enabled yet
* via ::cuCtxEnablePeerAccess().
*/
{ "CUDA_ERROR_PEER_ACCESS_NOT_ENABLED", 705 },
{"CUDA_ERROR_PEER_ACCESS_NOT_ENABLED", 705},
/**
* This error indicates that the primary context for the specified device
* has already been initialized.
*/
{ "CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE", 708 },
{"CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE", 708},
/**
* This error indicates that the context current to the calling thread
* has been destroyed using ::cuCtxDestroy }, or is a primary context which
* has not yet been initialized.
*/
{ "CUDA_ERROR_CONTEXT_IS_DESTROYED", 709 },
{"CUDA_ERROR_CONTEXT_IS_DESTROYED", 709},
/**
* A device-side assert triggered during kernel execution. The context
@ -334,26 +334,26 @@ s_CudaErrorStr sCudaDrvErrorString[] =
* memory allocations from this context are invalid and must be
* reconstructed if the program is to continue using CUDA.
*/
{ "CUDA_ERROR_ASSERT", 710 },
{"CUDA_ERROR_ASSERT", 710},
/**
* This error indicates that the hardware resources required to enable
* peer access have been exhausted for one or more of the devices
* passed to ::cuCtxEnablePeerAccess().
*/
{ "CUDA_ERROR_TOO_MANY_PEERS", 711 },
{"CUDA_ERROR_TOO_MANY_PEERS", 711},
/**
* This error indicates that the memory range passed to ::cuMemHostRegister()
* has already been registered.
*/
{ "CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED", 712 },
{"CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED", 712},
/**
* This error indicates that the pointer passed to ::cuMemHostUnregister()
* does not correspond to any currently registered memory region.
*/
{ "CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED", 713 },
{"CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED", 713},
/**
* While executing a kernel, the device encountered a stack error.
@ -362,7 +362,7 @@ s_CudaErrorStr sCudaDrvErrorString[] =
* will return the same error. To continue using CUDA, the process must be terminated
* and relaunched.
*/
{ "CUDA_ERROR_HARDWARE_STACK_ERROR", 714 },
{"CUDA_ERROR_HARDWARE_STACK_ERROR", 714},
/**
* While executing a kernel, the device encountered an illegal instruction.
@ -370,7 +370,7 @@ s_CudaErrorStr sCudaDrvErrorString[] =
* will return the same error. To continue using CUDA, the process must be terminated
* and relaunched.
*/
{ "CUDA_ERROR_ILLEGAL_INSTRUCTION", 715 },
{"CUDA_ERROR_ILLEGAL_INSTRUCTION", 715},
/**
* While executing a kernel, the device encountered a load or store instruction
@ -379,7 +379,7 @@ s_CudaErrorStr sCudaDrvErrorString[] =
* will return the same error. To continue using CUDA, the process must be terminated
* and relaunched.
*/
{ "CUDA_ERROR_MISALIGNED_ADDRESS", 716 },
{"CUDA_ERROR_MISALIGNED_ADDRESS", 716},
/**
* While executing a kernel, the device encountered an instruction
@ -390,7 +390,7 @@ s_CudaErrorStr sCudaDrvErrorString[] =
* will return the same error. To continue using CUDA, the process must be terminated
* and relaunched.
*/
{ "CUDA_ERROR_INVALID_ADDRESS_SPACE", 717 },
{"CUDA_ERROR_INVALID_ADDRESS_SPACE", 717},
/**
* While executing a kernel, the device program counter wrapped its address space.
@ -398,7 +398,7 @@ s_CudaErrorStr sCudaDrvErrorString[] =
* will return the same error. To continue using CUDA, the process must be terminated
* and relaunched.
*/
{ "CUDA_ERROR_INVALID_PC", 718 },
{"CUDA_ERROR_INVALID_PC", 718},
/**
* An exception occurred on the device while executing a kernel. Common
@ -408,7 +408,7 @@ s_CudaErrorStr sCudaDrvErrorString[] =
* memory allocations from this context are invalid and must be
* reconstructed if the program is to continue using CUDA.
*/
{ "CUDA_ERROR_LAUNCH_FAILED", 719 },
{"CUDA_ERROR_LAUNCH_FAILED", 719},
/**
* This error indicates that the number of blocks launched per grid for a kernel that was
@ -417,26 +417,24 @@ s_CudaErrorStr sCudaDrvErrorString[] =
* or ::cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags times the number of multiprocessors
* as specified by the device attribute ::CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT.
*/
{ "CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE", 720 },
{"CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE", 720},
/**
* This error indicates that the attempted operation is not permitted.
*/
{ "CUDA_ERROR_NOT_PERMITTED", 800 },
{"CUDA_ERROR_NOT_PERMITTED", 800},
/**
* This error indicates that the attempted operation is not supported
* on the current system or device.
*/
{ "CUDA_ERROR_NOT_SUPPORTED", 801 },
{"CUDA_ERROR_NOT_SUPPORTED", 801},
/**
* This indicates that an unknown internal error has occurred.
*/
{ "CUDA_ERROR_UNKNOWN", 999 },
{ NULL, -1 }
{"CUDA_ERROR_UNKNOWN", 999},
{NULL, -1}
};
// This is just a linear search through the array, since the error_id's are not
@ -445,9 +443,7 @@ static inline const char *getCudaDrvErrorString(CUresult error_id)
{
int index = 0;
while (sCudaDrvErrorString[index].error_id != error_id &&
(int)sCudaDrvErrorString[index].error_id != -1)
{
while (sCudaDrvErrorString[index].error_id != error_id && (int)sCudaDrvErrorString[index].error_id != -1) {
index++;
}
@ -459,5 +455,4 @@ static inline const char *getCudaDrvErrorString(CUresult error_id)
#endif // __cuda_cuda_h__
#endif

View File

@ -1,23 +1,23 @@
///
/// @file iatomic.h @brief Misc function header file
/// @file iatomic.h @brief Misc function header file
///
/// Copyright (c) 2014 by Johns. All Rights Reserved.
/// Copyright (c) 2014 by Johns. All Rights Reserved.
///
/// Contributor(s):
/// Contributor(s):
///
/// License: AGPLv3
/// License: AGPLv3
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
///
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
///
/// $Id: 59e1684aaa6678ecdebb6ce0df6ce5b5f461dd6e $
/// $Id: 59e1684aaa6678ecdebb6ce0df6ce5b5f461dd6e $
//////////////////////////////////////////////////////////////////////////////
/// @addtogroup iatomic
@ -27,8 +27,8 @@
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)
// gcc before 4.7 didn't support atomic builtins,
// use alsa atomic functions.
// gcc before 4.7 didn't support atomic builtins,
// use alsa atomic functions.
#if GCC_VERSION < 40700
#include <alsa/iatomic.h>
@ -36,58 +36,58 @@
#else
//////////////////////////////////////////////////////////////////////////////
// Defines
// Defines
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Declares
// Declares
//////////////////////////////////////////////////////////////////////////////
///
/// atomic type, 24 bit useable,
/// atomic type, 24 bit useable,
///
typedef volatile int atomic_t;
//////////////////////////////////////////////////////////////////////////////
// Prototypes
// Prototypes
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Inlines
// Inlines
//////////////////////////////////////////////////////////////////////////////
///
/// Set atomic value.
/// Set atomic value.
///
#define atomic_set(ptr, val) \
__atomic_store_n(ptr, val, __ATOMIC_SEQ_CST)
///
/// Read atomic value.
/// Read atomic value.
///
#define atomic_read(ptr) \
__atomic_load_n(ptr, __ATOMIC_SEQ_CST)
///
/// Increment atomic value.
/// Increment atomic value.
///
#define atomic_inc(ptr) \
__atomic_add_fetch(ptr, 1, __ATOMIC_SEQ_CST)
///
/// Decrement atomic value.
/// Decrement atomic value.
///
#define atomic_dec(ptr) \
__atomic_sub_fetch(ptr, 1, __ATOMIC_SEQ_CST)
///
/// Add to atomic value.
/// Add to atomic value.
///
#define atomic_add(val, ptr) \
__atomic_add_fetch(ptr, val, __ATOMIC_SEQ_CST)
///
/// Subtract from atomic value.
/// Subtract from atomic value.
///
#define atomic_sub(val, ptr) \
__atomic_sub_fetch(ptr, val, __ATOMIC_SEQ_CST)

74
misc.h
View File

@ -1,24 +1,24 @@
///
/// @file misc.h @brief Misc function header file
/// @file misc.h @brief Misc function header file
///
/// Copyright (c) 2009 - 2012 by Lutz Sammer. All Rights Reserved.
/// Copyright (c) 2009 - 2012 by Lutz Sammer. All Rights Reserved.
///
/// Contributor(s):
/// Copied from uwm.
/// Contributor(s):
/// Copied from uwm.
///
/// License: AGPLv3
/// License: AGPLv3
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
///
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
///
/// $Id: f5ff4b300aa33eb721d658c0c9374c8499b67318 $
/// $Id: f5ff4b300aa33eb721d658c0c9374c8499b67318 $
//////////////////////////////////////////////////////////////////////////////
/// @addtogroup misc
@ -26,37 +26,37 @@
#include <syslog.h>
#include <stdarg.h>
#include <time.h> // clock_gettime
#include <time.h> // clock_gettime
//////////////////////////////////////////////////////////////////////////////
// Defines
// Defines
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Declares
// Declares
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Variables
// Variables
//////////////////////////////////////////////////////////////////////////////
extern int SysLogLevel; ///< how much information wanted
extern int SysLogLevel; ///< how much information wanted
//////////////////////////////////////////////////////////////////////////////
// Prototypes
// Prototypes
//////////////////////////////////////////////////////////////////////////////
static inline void Syslog(const int, const char *format, ...)
__attribute__ ((format(printf, 2, 3)));
__attribute__((format(printf, 2, 3)));
//////////////////////////////////////////////////////////////////////////////
// Inlines
// Inlines
//////////////////////////////////////////////////////////////////////////////
#ifdef DEBUG
#define DebugLevel 4 /// private debug level
#define DebugLevel 4 /// private debug level
#else
#define DebugLevel 0 /// private debug level
#define DebugLevel 0 /// private debug level
#endif
/**
@ -70,11 +70,11 @@ static inline void Syslog(const int, const char *format, ...)
static inline void Syslog(const int level, const char *format, ...)
{
if (SysLogLevel > level || DebugLevel > level) {
va_list ap;
va_list ap;
va_start(ap, format);
vsyslog(LOG_ERR, format, ap);
va_end(ap);
va_start(ap, format);
vsyslog(LOG_ERR, format, ap);
va_end(ap);
}
}
@ -104,7 +104,7 @@ static inline void Syslog(const int level, const char *format, ...)
#ifdef DEBUG
#define Debug(level, fmt...) Syslog(level, fmt)
#else
#define Debug(level, fmt...) /* disabled */
#define Debug(level, fmt...) /* disabled */
#endif
#ifndef AV_NOPTS_VALUE
@ -122,12 +122,11 @@ static inline const char *Timestamp2String(int64_t ts)
static int idx;
if (ts == (int64_t) AV_NOPTS_VALUE) {
return "--:--:--.---";
return "--:--:--.---";
}
idx = (idx + 1) % 3;
snprintf(buf[idx], sizeof(buf[idx]), "%2d:%02d:%02d.%03d",
(int)(ts / (90 * 3600000)), (int)((ts / (90 * 60000)) % 60),
(int)((ts / (90 * 1000)) % 60), (int)((ts / 90) % 1000));
snprintf(buf[idx], sizeof(buf[idx]), "%2d:%02d:%02d.%03d", (int)(ts / (90 * 3600000)),
(int)((ts / (90 * 60000)) % 60), (int)((ts / (90 * 1000)) % 60), (int)((ts / 90) % 1000));
return buf[idx];
}
@ -148,24 +147,25 @@ static inline uint32_t GetMsTicks(void)
struct timeval tval;
if (gettimeofday(&tval, NULL) < 0) {
return 0;
return 0;
}
return (tval.tv_sec * 1000) + (tval.tv_usec / 1000);
#endif
}
static inline uint64_t GetusTicks(void)
{
#ifdef CLOCK_MONOTONIC
struct timespec tspec;
clock_gettime(CLOCK_MONOTONIC, &tspec);
return (uint64_t) (tspec.tv_sec * 1000000) + (tspec.tv_nsec) ;
return (uint64_t) (tspec.tv_sec * 1000000) + (tspec.tv_nsec);
#else
struct timeval tval;
if (gettimeofday(&tval, NULL) < 0) {
return 0;
return 0;
}
return (tval.tv_sec * 1000) + (tval.tv_usec / 1000);
#endif

View File

@ -17,25 +17,21 @@
#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;
#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>
@ -49,7 +45,8 @@ extern "C"
extern "C" pthread_mutex_t OSDMutex;
struct sOglImage {
struct sOglImage
{
GLuint texture;
GLint width;
GLint height;
@ -60,69 +57,97 @@ struct sOglImage {
* Helpers
****************************************************************************************/
void ConvertColor(const GLint &colARGB, glm::vec4 &col);
void ConvertColor(const GLint & colARGB, glm::vec4 & col);
/****************************************************************************************
* cShader
****************************************************************************************/
enum eShaderType {
enum eShaderType
{
stRect,
stTexture,
stText,
stCount
};
class cShader {
private:
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) {};
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);
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;
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;
int advanceX;
cVector < tKerning > kerningCache;
GLuint texture;
void LoadTexture(FT_BitmapGlyph ftGlyph);
public:
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; }
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);
@ -131,8 +156,9 @@ public:
/****************************************************************************************
* cOglFont
****************************************************************************************/
class cOglFont : public cListObject {
private:
class cOglFont:public cListObject
{
private:
static bool initiated;
cString name;
int size;
@ -140,41 +166,57 @@ private:
int bottom;
static FT_Library ftLib;
FT_Face face;
static cList<cOglFont> *fonts;
mutable cList<cOglGlyph> glyphCache;
cOglFont(const char *fontName, int charHeight);
static cList < cOglFont > *fonts;
mutable cList < cOglGlyph > glyphCache;
cOglFont(const char *fontName, int charHeight);
static void Init(void);
public:
virtual ~cOglFont(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;
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:
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; }
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);
@ -182,27 +224,43 @@ public:
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; };
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 {
protected:
class cOglOutputFb:public cOglFb
{
protected:
bool initiated;
private:
GLvdpauSurfaceNV surface;
public:
GLuint fb;
GLuint texture;
cOglOutputFb(GLint width, GLint height);
virtual ~cOglOutputFb(void);
private:
GLvdpauSurfaceNV surface;
public:
GLuint fb;
GLuint texture;
cOglOutputFb(GLint width, GLint height);
virtual ~ cOglOutputFb(void);
virtual bool Init(void);
virtual void BindWrite(void);
virtual void Unbind(void);
@ -212,7 +270,8 @@ public:
* cOglVb
* Vertex Buffer - OpenGl Vertices for the different drawing commands
****************************************************************************************/
enum eVertexBufferType {
enum eVertexBufferType
{
vbRect,
vbEllipse,
vbSlope,
@ -221,8 +280,9 @@ enum eVertexBufferType {
vbCount
};
class cOglVb {
private:
class cOglVb
{
private:
eVertexBufferType type;
eShaderType shader;
GLuint vao;
@ -231,9 +291,9 @@ private:
int sizeVertex2;
int numVertices;
GLuint drawMode;
public:
cOglVb(int type);
virtual ~cOglVb(void);
public:
cOglVb(int type);
virtual ~ cOglVb(void);
bool Init(void);
void Bind(void);
void Unbind(void);
@ -243,184 +303,271 @@ public:
void SetShaderColor(GLint color);
void SetShaderAlpha(GLint alpha);
void SetShaderProjectionMatrix(GLint width, GLint height);
void SetVertexData(GLfloat *vertices, int count = 0);
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;
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"; }
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"; }
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"; }
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;
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"; }
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;
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"; }
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:
class cOglCmdFill:public cOglCmd
{
private:
GLint color;
public:
cOglCmdFill(cOglFb *fb, GLint color);
virtual ~cOglCmdFill(void) {};
virtual const char* Description(void) { return "Fill"; }
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:
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"; }
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:
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"; }
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:
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"; }
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:
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"; }
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;
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"; }
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;
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"; }
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;
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"; }
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;
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"; }
public:
cOglCmdDropImage(sOglImage * imageRef, cCondWait * wait);
virtual ~ cOglCmdDropImage(void)
{
};
virtual const char *Description(void)
{
return "Drop Image";
}
virtual bool Execute(void);
};
@ -430,12 +577,13 @@ public:
#define OGL_MAX_OSDIMAGES 256
#define OGL_CMDQUEUE_SIZE 100
class cOglThread : public cThread {
private:
cCondWait *startWait;
class cOglThread:public cThread
{
private:
cCondWait * startWait;
cCondWait *wait;
bool stalled;
std::queue<cOglCmd*> commands;
std::queue < cOglCmd * >commands;
GLint maxTextureSize;
sOglImage imageCache[OGL_MAX_OSDIMAGES];
long memCached;
@ -449,73 +597,96 @@ private:
void Cleanup(void);
int GetFreeSlot(void);
void ClearSlot(int slot);
protected:
virtual void Action(void);
public:
cOglThread(cCondWait *startWait, int maxCacheSize);
virtual ~cOglThread();
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 DoCmd(cOglCmd * cmd);
int StoreImage(const cImage & image);
void DropImageData(int imageHandle);
sOglImage *GetImageRef(int slot);
int MaxTextureSize(void) { return maxTextureSize; };
int MaxTextureSize(void)
{
return maxTextureSize;
};
};
/****************************************************************************************
* cOglPixmap
****************************************************************************************/
class cOglPixmap : public cPixmap {
private:
cOglFb *fb;
std::shared_ptr<cOglThread> oglThread;
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; }
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 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);
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;
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);
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);
virtual void DrawScaledBitmap(int x, int y, const cBitmap & Bitmap, double FactorX, double FactorY,
bool AntiAlias = false);
static cOglOutputFb *oFb;
};

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: VDR \n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2019-10-04 14:23+0200\n"
"POT-Creation-Date: 2019-10-26 18:41+0200\n"
"PO-Revision-Date: blabla\n"
"Last-Translator: blabla\n"
"Language-Team: blabla\n"
@ -792,7 +792,13 @@ msgstr ""
msgid "[softhddev] ready%s\n"
msgstr ""
msgid "video/egl: GlxSetupWindow can't make egl context current\n"
msgid "video: can't lock thread\n"
msgstr ""
msgid "video: can't unlock thread\n"
msgstr ""
msgid "video/egl: GlxSetupWindow can't make egl/glx context current\n"
msgstr ""
msgid "video/glx: no v-sync\n"
@ -891,21 +897,6 @@ msgstr ""
msgid "Failed rendering frame!\n"
msgstr ""
#, c-format
msgid "video/vdpau: can't get video surface parameters: %s\n"
msgstr ""
msgid "video/vdpau: out of memory\n"
msgstr ""
#, c-format
msgid "video/vdpau: unsupported chroma type %d\n"
msgstr ""
#, c-format
msgid "video/vdpau: can't get video surface bits: %s\n"
msgstr ""
#, c-format
msgid "video/vdpau: output buffer full, dropping frame (%d/%d)\n"
msgstr ""
@ -924,9 +915,6 @@ msgstr ""
msgid "video: decoder buffer empty, duping frame (%d/%d) %d v-buf\n"
msgstr ""
msgid "Failed creating vulkan swapchain!"
msgstr ""
msgid "video: fatal i/o error\n"
msgstr ""
@ -934,12 +922,6 @@ msgstr ""
msgid "video/event: No symbol for %d\n"
msgstr ""
msgid "video: can't lock thread\n"
msgstr ""
msgid "video: can't unlock thread\n"
msgstr ""
msgid "Cant get memory for PLACEBO struct"
msgstr ""
@ -952,6 +934,9 @@ msgstr ""
msgid "Failed to create Vulkan Device"
msgstr ""
msgid "Failed creating vulkan swapchain!"
msgstr ""
msgid "Failed initializing libplacebo renderer\n"
msgstr ""

View File

@ -1,29 +1,29 @@
///
/// @file ringbuffer.c @brief Ringbuffer module
/// @file ringbuffer.c @brief Ringbuffer module
///
/// Copyright (c) 2009, 2011, 2014 by Johns. All Rights Reserved.
/// Copyright (c) 2009, 2011, 2014 by Johns. All Rights Reserved.
///
/// Contributor(s):
/// Contributor(s):
///
/// License: AGPLv3
/// License: AGPLv3
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
///
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
///
/// $Id: c9497b197ce7e7a6ba397944edc7ccb161152efd $
/// $Id: c9497b197ce7e7a6ba397944edc7ccb161152efd $
//////////////////////////////////////////////////////////////////////////////
///
/// @defgroup Ringbuffer The ring buffer module.
/// @defgroup Ringbuffer The ring buffer module.
///
/// Lock free ring buffer with only one writer and one reader.
/// Lock free ring buffer with only one writer and one reader.
///
#include <stdio.h>
@ -36,15 +36,15 @@
/// ring buffer structure
struct _ring_buffer_
{
char *Buffer; ///< ring buffer data
const char *BufferEnd; ///< end of buffer
size_t Size; ///< bytes in buffer (for faster calc)
char *Buffer; ///< ring buffer data
const char *BufferEnd; ///< end of buffer
size_t Size; ///< bytes in buffer (for faster calc)
const char *ReadPointer; ///< only used by reader
char *WritePointer; ///< only used by writer
const char *ReadPointer; ///< only used by reader
char *WritePointer; ///< only used by writer
/// The only thing modified by both
atomic_t Filled; ///< how many of the buffer is used
atomic_t Filled; ///< how many of the buffer is used
};
/**
@ -71,12 +71,12 @@ RingBuffer *RingBufferNew(size_t size)
{
RingBuffer *rb;
if (!(rb = malloc(sizeof(*rb)))) { // allocate structure
return rb;
if (!(rb = malloc(sizeof(*rb)))) { // allocate structure
return rb;
}
if (!(rb->Buffer = malloc(size))) { // allocate buffer
free(rb);
return NULL;
if (!(rb->Buffer = malloc(size))) { // allocate buffer
free(rb);
return NULL;
}
rb->Size = size;
@ -108,25 +108,25 @@ size_t RingBufferWriteAdvance(RingBuffer * rb, size_t cnt)
size_t n;
n = rb->Size - atomic_read(&rb->Filled);
if (cnt > n) { // not enough space
cnt = n;
if (cnt > n) { // not enough space
cnt = n;
}
//
// Hitting end of buffer?
// Hitting end of buffer?
//
n = rb->BufferEnd - rb->WritePointer;
if (n > cnt) { // don't cross the end
rb->WritePointer += cnt;
} else { // reached or cross the end
rb->WritePointer = rb->Buffer;
if (n < cnt) {
n = cnt - n;
rb->WritePointer += n;
}
if (n > cnt) { // don't cross the end
rb->WritePointer += cnt;
} else { // reached or cross the end
rb->WritePointer = rb->Buffer;
if (n < cnt) {
n = cnt - n;
rb->WritePointer += n;
}
}
//
// Only atomic modification!
// Only atomic modification!
//
atomic_add(cnt, &rb->Filled);
return cnt;
@ -147,29 +147,29 @@ size_t RingBufferWrite(RingBuffer * rb, const void *buf, size_t cnt)
size_t n;
n = rb->Size - atomic_read(&rb->Filled);
if (cnt > n) { // not enough space
cnt = n;
if (cnt > n) { // not enough space
cnt = n;
}
//
// Hitting end of buffer?
// Hitting end of buffer?
//
n = rb->BufferEnd - rb->WritePointer;
if (n > cnt) { // don't cross the end
memcpy(rb->WritePointer, buf, cnt);
rb->WritePointer += cnt;
} else { // reached or cross the end
memcpy(rb->WritePointer, buf, n);
rb->WritePointer = rb->Buffer;
if (n < cnt) {
buf += n;
n = cnt - n;
memcpy(rb->WritePointer, buf, n);
rb->WritePointer += n;
}
if (n > cnt) { // don't cross the end
memcpy(rb->WritePointer, buf, cnt);
rb->WritePointer += cnt;
} else { // reached or cross the end
memcpy(rb->WritePointer, buf, n);
rb->WritePointer = rb->Buffer;
if (n < cnt) {
buf += n;
n = cnt - n;
memcpy(rb->WritePointer, buf, n);
rb->WritePointer += n;
}
}
//
// Only atomic modification!
// Only atomic modification!
//
atomic_add(cnt, &rb->Filled);
return cnt;
@ -189,17 +189,17 @@ size_t RingBufferGetWritePointer(RingBuffer * rb, void **wp)
size_t n;
size_t cnt;
// Total free bytes available in ring buffer
// Total free bytes available in ring buffer
cnt = rb->Size - atomic_read(&rb->Filled);
*wp = rb->WritePointer;
//
// Hitting end of buffer?
// Hitting end of buffer?
//
n = rb->BufferEnd - rb->WritePointer;
if (n <= cnt) { // reached or cross the end
return n;
if (n <= cnt) { // reached or cross the end
return n;
}
return cnt;
}
@ -217,25 +217,25 @@ size_t RingBufferReadAdvance(RingBuffer * rb, size_t cnt)
size_t n;
n = atomic_read(&rb->Filled);
if (cnt > n) { // not enough filled
cnt = n;
if (cnt > n) { // not enough filled
cnt = n;
}
//
// Hitting end of buffer?
// Hitting end of buffer?
//
n = rb->BufferEnd - rb->ReadPointer;
if (n > cnt) { // don't cross the end
rb->ReadPointer += cnt;
} else { // reached or cross the end
rb->ReadPointer = rb->Buffer;
if (n < cnt) {
n = cnt - n;
rb->ReadPointer += n;
}
if (n > cnt) { // don't cross the end
rb->ReadPointer += cnt;
} else { // reached or cross the end
rb->ReadPointer = rb->Buffer;
if (n < cnt) {
n = cnt - n;
rb->ReadPointer += n;
}
}
//
// Only atomic modification!
// Only atomic modification!
//
atomic_sub(cnt, &rb->Filled);
return cnt;
@ -255,29 +255,29 @@ size_t RingBufferRead(RingBuffer * rb, void *buf, size_t cnt)
size_t n;
n = atomic_read(&rb->Filled);
if (cnt > n) { // not enough filled
cnt = n;
if (cnt > n) { // not enough filled
cnt = n;
}
//
// Hitting end of buffer?
// Hitting end of buffer?
//
n = rb->BufferEnd - rb->ReadPointer;
if (n > cnt) { // don't cross the end
memcpy(buf, rb->ReadPointer, cnt);
rb->ReadPointer += cnt;
} else { // reached or cross the end
memcpy(buf, rb->ReadPointer, n);
rb->ReadPointer = rb->Buffer;
if (n < cnt) {
buf += n;
n = cnt - n;
memcpy(buf, rb->ReadPointer, n);
rb->ReadPointer += n;
}
if (n > cnt) { // don't cross the end
memcpy(buf, rb->ReadPointer, cnt);
rb->ReadPointer += cnt;
} else { // reached or cross the end
memcpy(buf, rb->ReadPointer, n);
rb->ReadPointer = rb->Buffer;
if (n < cnt) {
buf += n;
n = cnt - n;
memcpy(buf, rb->ReadPointer, n);
rb->ReadPointer += n;
}
}
//
// Only atomic modification!
// Only atomic modification!
//
atomic_sub(cnt, &rb->Filled);
return cnt;
@ -297,17 +297,17 @@ size_t RingBufferGetReadPointer(RingBuffer * rb, const void **rp)
size_t n;
size_t cnt;
// Total used bytes in ring buffer
// Total used bytes in ring buffer
cnt = atomic_read(&rb->Filled);
*rp = rb->ReadPointer;
//
// Hitting end of buffer?
// Hitting end of buffer?
//
n = rb->BufferEnd - rb->ReadPointer;
if (n <= cnt) { // reached or cross the end
return n;
if (n <= cnt) { // reached or cross the end
return n;
}
return cnt;
}

View File

@ -1,23 +1,23 @@
///
/// @file ringbuffer.h @brief Ringbuffer module header file
/// @file ringbuffer.h @brief Ringbuffer module header file
///
/// Copyright (c) 2009, 2011 by Johns. All Rights Reserved.
/// Copyright (c) 2009, 2011 by Johns. All Rights Reserved.
///
/// Contributor(s):
/// Contributor(s):
///
/// License: AGPLv3
/// License: AGPLv3
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
///
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
///
/// $Id: 8a2b4c171f1024afb8b8a7a7add631b7ebe2d45e $
/// $Id: 8a2b4c171f1024afb8b8a7a7add631b7ebe2d45e $
//////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ringbuffer

932
shaders.h
View File

@ -1,465 +1,467 @@
// shader
#ifdef CUVID
char vertex_osd[] = {"\
#version 330\n\
in vec2 vertex_position;\n\
in vec2 vertex_texcoord0;\n\
out vec2 texcoord0;\n\
void main() {\n\
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
texcoord0 = vertex_texcoord0;\n\
}\n"};
char fragment_osd[] = {"\
#version 330\n\
#define texture1D texture\n\
precision mediump float; \
layout(location = 0) out vec4 out_color;\n\
in vec2 texcoord0;\n\
uniform sampler2D texture0;\n\
void main() {\n\
vec4 color; \n\
color = vec4(texture(texture0, texcoord0));\n\
out_color = color;\n\
}\n"};
char vertex[] = {"\
#version 310 es\n\
in vec2 vertex_position;\n\
in vec2 vertex_texcoord0;\n\
out vec2 texcoord0;\n\
in vec2 vertex_texcoord1;\n\
out vec2 texcoord1;\n\
void main() {\n\
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
texcoord0 = vertex_texcoord0;\n\
texcoord1 = vertex_texcoord1;\n\
}\n"};
char fragment[] = {"\
#version 310 es\n\
#define texture1D texture\n\
#define texture3D texture\n\
precision mediump float; \
layout(location = 0) out vec4 out_color;\n\
in vec2 texcoord0;\n\
in vec2 texcoord1;\n\
uniform mat3 colormatrix;\n\
uniform vec3 colormatrix_c;\n\
uniform sampler2D texture0;\n\
uniform sampler2D texture1;\n\
void main() {\n\
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r;\n\
color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg;\n\
// color conversion\n\
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\
color.a = 1.0;\n\
// color mapping\n\
out_color = color;\n\
}\n"};
char fragment_bt2100[] = {"\
#version 310 es\n \
#define texture1D texture\n\
#define texture3D texture\n\
precision mediump float; \
layout(location = 0) out vec4 out_color;\n\
in vec2 texcoord0;\n\
in vec2 texcoord1;\n\
uniform mat3 colormatrix;\n\
uniform vec3 colormatrix_c;\n\
uniform mat3 cms_matrix;\n\
uniform sampler2D texture0;\n\
uniform sampler2D texture1;\n\
//#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))\n\
void main() {\n\
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
color.r = 1.003906 * vec4(texture(texture0, texcoord0)).r;\n\
color.gb = 1.003906 * vec4(texture(texture1, texcoord1)).rg;\n\
// color conversion\n\
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\
color.a = 1.0;\n\
// color mapping\n\
color.rgb = clamp(color.rgb, 0.0, 1.0);\n\
color.rgb = pow(color.rgb, vec3(2.4));\n\
color.rgb = cms_matrix * color.rgb;\n\
color.rgb = clamp(color.rgb, 0.0, 1.0);\n\
color.rgb = pow(color.rgb, vec3(1.0/2.4));\n\
out_color = color;\n\
}\n"};
#else
char vertex_osd[] = {"\
\n\
in vec2 vertex_position;\n\
in vec2 vertex_texcoord0;\n\
out vec2 texcoord0;\n\
void main() {\n\
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
texcoord0 = vertex_texcoord0;\n\
}\n"};
char fragment_osd[] = {"\
\n\
#define texture1D texture\n\
precision mediump float; \
layout(location = 0) out vec4 out_color;\n\
in vec2 texcoord0;\n\
uniform sampler2D texture0;\n\
void main() {\n\
vec4 color; \n\
color = vec4(texture(texture0, texcoord0));\n\
out_color = color;\n\
}\n"};
char vertex[] = {"\
\n\
in vec2 vertex_position;\n\
in vec2 vertex_texcoord0;\n\
out vec2 texcoord0;\n\
in vec2 vertex_texcoord1;\n\
out vec2 texcoord1;\n\
void main() {\n\
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
texcoord0 = vertex_texcoord0;\n\
texcoord1 = vertex_texcoord1;\n\
}\n"};
char fragment[] = {"\
\n\
#define texture1D texture\n\
#define texture3D texture\n\
precision mediump float; \
layout(location = 0) out vec4 out_color;\n\
in vec2 texcoord0;\n\
in vec2 texcoord1;\n\
uniform mat3 colormatrix;\n\
uniform vec3 colormatrix_c;\n\
uniform sampler2D texture0;\n\
uniform sampler2D texture1;\n\
//#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))\n\
void main() {\n\
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r;\n\
color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg;\n\
// color conversion\n\
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\
color.a = 1.0;\n\
// color mapping\n\
out_color = color;\n\
}\n"};
char fragment_bt2100[] = {"\
\n \
#define texture1D texture\n\
#define texture3D texture\n\
precision mediump float; \
layout(location = 0) out vec4 out_color;\n\
in vec2 texcoord0;\n\
in vec2 texcoord1;\n\
uniform mat3 colormatrix;\n\
uniform vec3 colormatrix_c;\n\
uniform mat3 cms_matrix;\n\
uniform sampler2D texture0;\n\
uniform sampler2D texture1;\n\
//#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))\n\
void main() {\n\
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
color.r = 1.003906 * vec4(texture(texture0, texcoord0)).r;\n\
color.gb = 1.003906 * vec4(texture(texture1, texcoord1)).rg;\n\
// color conversion\n\
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\
color.a = 1.0;\n\
// color mapping\n\
color.rgb = clamp(color.rgb, 0.0, 1.0);\n\
color.rgb = pow(color.rgb, vec3(2.4));\n\
color.rgb = cms_matrix * color.rgb;\n\
color.rgb = clamp(color.rgb, 0.0, 1.0);\n\
color.rgb = pow(color.rgb, vec3(1.0/2.4));\n\
out_color = color;\n\
}\n"};
#endif
/* Color conversion matrix: RGB = m * YUV + c
* m is in row-major matrix, with m[row][col], e.g.:
* [ a11 a12 a13 ] float m[3][3] = { { a11, a12, a13 },
* [ a21 a22 a23 ] { a21, a22, a23 },
* [ a31 a32 a33 ] { a31, a32, a33 } };
* This is accessed as e.g.: m[2-1][1-1] = a21
* In particular, each row contains all the coefficients for one of R, G, B,
* while each column contains all the coefficients for one of Y, U, V:
* m[r,g,b][y,u,v] = ...
* The matrix could also be viewed as group of 3 vectors, e.g. the 1st column
* is the Y vector (1, 1, 1), the 2nd is the U vector, the 3rd the V vector.
* The matrix might also be used for other conversions and colorspaces.
*/
struct mp_cmat {
GLfloat m[3][3]; // colormatrix
GLfloat c[3]; //colormatrix_c
};
struct mp_mat {
GLfloat m[3][3];
};
// YUV input limited range (16-235 for luma, 16-240 for chroma)
// ITU-R BT.601 (SD)
struct mp_cmat yuv_bt601 = {\
{{ 1.164384, 1.164384, 1.164384 },\
{ 0.00000, -0.391762, 2.017232 },\
{ 1.596027, -0.812968 , 0.000000 }},\
{-0.874202, 0.531668, -1.085631 } };
// ITU-R BT.709 (HD)
struct mp_cmat yuv_bt709 = {\
{{ 1.164384, 1.164384, 1.164384 },\
{ 0.00000, -0.213249, 2.112402 },\
{ 1.792741, -0.532909 , 0.000000 }},\
{-0.972945, 0.301483, -1.133402 } };
// ITU-R BT.2020 non-constant luminance system
struct mp_cmat yuv_bt2020ncl = {\
{{ 1.164384, 1.164384, 1.164384 },\
{ 0.00000, -0.187326, 2.141772 },\
{ 1.678674, -0.650424 , 0.000000 }},\
{-0.915688, 0.347459, -1.148145 } };
// ITU-R BT.2020 constant luminance system
struct mp_cmat yuv_bt2020cl = {\
{{ 0.0000, 1.164384, 0.000000 },\
{ 0.00000, 0.000000, 1.138393 },\
{ 1.138393, 0.000000 , 0.000000 }},\
{-0.571429, -0.073059, -0.571429 } };
float cms_matrix[3][3] = \
{{ 1.660497, -0.124547, -0.018154},\
{-0.587657, 1.132895, -0.100597},\
{-0.072840, -0.008348, 1.118751}};
struct gl_vao_entry {
// used for shader / glBindAttribLocation
const char *name;
// glVertexAttribPointer() arguments
int num_elems; // size (number of elements)
GLenum type;
bool normalized;
int offset;
};
struct vertex_pt {
float x, y;
};
struct vertex_pi {
GLint x, y;
};
#define TEXUNIT_VIDEO_NUM 6
struct vertex {
struct vertex_pt position;
struct vertex_pt texcoord[TEXUNIT_VIDEO_NUM];
};
static const struct gl_vao_entry vertex_vao[] = {
{"position", 2, GL_FLOAT, false, offsetof(struct vertex, position)},
{"texcoord0", 2, GL_FLOAT, false, offsetof(struct vertex, texcoord[0])},
{"texcoord1", 2, GL_FLOAT, false, offsetof(struct vertex, texcoord[1])},
{0}
};
static void compile_attach_shader(GLuint program,
GLenum type, const char *source)
{
GLuint shader;
GLint status, log_length;
char log[4000];
GLsizei len;
shader = glCreateShader(type);
glShaderSource(shader, 1, &source, NULL);
glCompileShader(shader);
status = 0;
glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
log_length = 0;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_length);
glGetShaderInfoLog(shader,4000,&len,log);
GlxCheck();
Debug(3,"compile Status %d loglen %d >%s<\n",status,log_length,log);
glAttachShader(program, shader);
glDeleteShader(shader);
}
static void link_shader(GLuint program)
{
GLint status,log_length;
glLinkProgram(program);
status = 0;
glGetProgramiv(program, GL_LINK_STATUS, &status);
log_length = 0;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &log_length);
Debug(3,"Link Status %d loglen %d\n",status,log_length);
}
static GLuint sc_generate_osd(GLuint gl_prog) {
Debug(3,"vor create osd\n");
gl_prog = glCreateProgram();
Debug(3,"vor compile vertex osd\n");
compile_attach_shader(gl_prog, GL_VERTEX_SHADER, vertex_osd);
Debug(3,"vor compile fragment osd \n");
compile_attach_shader(gl_prog, GL_FRAGMENT_SHADER, fragment_osd);
glBindAttribLocation(gl_prog,0,"vertex_position");
glBindAttribLocation(gl_prog,1,"vertex_texcoord0");
link_shader(gl_prog);
return gl_prog;
}
static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace) {
char vname[80];
int n;
GLint cmsLoc;
float *m,*c,*cms;
char *frag;
switch (colorspace) {
case AVCOL_SPC_RGB:
m = &yuv_bt601.m[0][0];
c = &yuv_bt601.c[0];
frag = fragment;
Debug(3,"BT601 Colorspace used\n");
break;
case AVCOL_SPC_BT709:
case AVCOL_SPC_UNSPECIFIED: // comes with UHD
m = &yuv_bt709.m[0][0];
c = &yuv_bt709.c[0];
frag = fragment;
Debug(3,"BT709 Colorspace used\n");
break;
case AVCOL_SPC_BT2020_NCL:
m = &yuv_bt2020ncl.m[0][0];
c = &yuv_bt2020ncl.c[0];
cms = &cms_matrix[0][0];
frag = fragment_bt2100;
Debug(3,"BT2020NCL Colorspace used\n");
break;
default: // fallback
m = &yuv_bt709.m[0][0];
c = &yuv_bt709.c[0];
frag = fragment;
Debug(3,"default BT709 Colorspace used %d\n",colorspace);
break;
}
Debug(3,"vor create\n");
gl_prog = glCreateProgram();
Debug(3,"vor compile vertex\n");
compile_attach_shader(gl_prog, GL_VERTEX_SHADER, vertex);
Debug(3,"vor compile fragment\n");
compile_attach_shader(gl_prog, GL_FRAGMENT_SHADER, frag);
glBindAttribLocation(gl_prog,0,"vertex_position");
for (n=0;n<6;n++) {
sprintf(vname,"vertex_texcoord%1d",n);
glBindAttribLocation(gl_prog,n+1,vname);
}
link_shader(gl_prog);
gl_colormatrix = glGetUniformLocation(gl_prog,"colormatrix");
Debug(3,"get uniform colormatrix %d \n",gl_colormatrix);
if (gl_colormatrix != -1)
glProgramUniformMatrix3fv(gl_prog,gl_colormatrix,1,0,m);
GlxCheck();
Debug(3,"nach set colormatrix\n");
gl_colormatrix_c = glGetUniformLocation(gl_prog,"colormatrix_c");
Debug(3,"get uniform colormatrix_c %d %f\n",gl_colormatrix_c,*c);
if (gl_colormatrix_c != -1)
glProgramUniform3fv(gl_prog,gl_colormatrix_c,1,c);
GlxCheck();
if (colorspace == AVCOL_SPC_BT2020_NCL) {
cmsLoc = glGetUniformLocation(gl_prog,"cms_matrix");
if (cmsLoc != -1)
glProgramUniformMatrix3fv(gl_prog,cmsLoc,1,0,cms);
GlxCheck();
}
return gl_prog;
}
static void render_pass_quad(int flip, float xcrop, float ycrop)
{
struct vertex va[4];
int n;
const struct gl_vao_entry *e;
// uhhhh what a hack
if (!flip ) {
va[0].position.x = (float) -1.0;
va[0].position.y = (float) 1.0;
va[1].position.x = (float) -1.0;
va[1].position.y = (float) -1.0;
va[2].position.x = (float) 1.0;
va[2].position.y = (float) 1.0;
va[3].position.x = (float) 1.0;
va[3].position.y = (float) -1.0;
} else {
va[0].position.x = (float) -1.0;
va[0].position.y = (float) -1.0;
va[1].position.x = (float) -1.0;
va[1].position.y = (float) 1.0;
va[2].position.x = (float) 1.0;
va[2].position.y = (float) -1.0;
va[3].position.x = (float) 1.0;
va[3].position.y = (float) 1.0;
}
va[0].texcoord[0].x = (float) 0.0 + xcrop;
va[0].texcoord[0].y = (float) 0.0 + ycrop; // abgeschnitten von links oben
va[0].texcoord[1].x = (float) 0.0 + xcrop;
va[0].texcoord[1].y = (float) 0.0 + ycrop; // abgeschnitten von links oben
va[1].texcoord[0].x = (float) 0.0 + xcrop;
va[1].texcoord[0].y = (float) 1.0 - ycrop; // abgeschnitten links unten 1.0 - Wert
va[1].texcoord[1].x = (float) 0.0 + xcrop;
va[1].texcoord[1].y = (float) 1.0 - ycrop; // abgeschnitten links unten 1.0 - Wert
va[2].texcoord[0].x = (float) 1.0 - xcrop;
va[2].texcoord[0].y = (float) 0.0 + ycrop; // abgeschnitten von rechts oben
va[2].texcoord[1].x = (float) 1.0 - xcrop;
va[2].texcoord[1].y = (float) 0.0 + ycrop; // abgeschnitten von rechts oben
va[3].texcoord[0].x = (float) 1.0 - xcrop;
va[3].texcoord[0].y = (float) 1.0 - ycrop; // abgeschnitten von rechts unten 1.0 - wert
va[3].texcoord[1].x = (float) 1.0 - xcrop;
va[3].texcoord[1].y = (float) 1.0 - ycrop; // abgeschnitten von rechts unten 1.0 - wert
glBindBuffer(GL_ARRAY_BUFFER, vao_buffer);
glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(struct vertex), va, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
// enable attribs
glBindBuffer(GL_ARRAY_BUFFER, vao_buffer);
for ( n = 0; vertex_vao[n].name; n++) {
e = &vertex_vao[n];
glEnableVertexAttribArray(n);
glVertexAttribPointer(n, e->num_elems, e->type, e->normalized,
sizeof(struct vertex), (void *)(intptr_t)e->offset);
}
glBindBuffer(GL_ARRAY_BUFFER, 0);
// draw quad
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
for ( n = 0; vertex_vao[n].name; n++)
glDisableVertexAttribArray(n);
}
// shader
#ifdef CUVID
char vertex_osd[] = { "\
#version 330\n\
in vec2 vertex_position;\n\
in vec2 vertex_texcoord0;\n\
out vec2 texcoord0;\n\
void main() {\n\
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
texcoord0 = vertex_texcoord0;\n\
}\n" };
char fragment_osd[] = { "\
#version 330\n\
#define texture1D texture\n\
precision mediump float; \
layout(location = 0) out vec4 out_color;\n\
in vec2 texcoord0;\n\
uniform sampler2D texture0;\n\
void main() {\n\
vec4 color; \n\
color = vec4(texture(texture0, texcoord0));\n\
out_color = color;\n\
}\n" };
char vertex[] = { "\
#version 310 es\n\
in vec2 vertex_position;\n\
in vec2 vertex_texcoord0;\n\
out vec2 texcoord0;\n\
in vec2 vertex_texcoord1;\n\
out vec2 texcoord1;\n\
void main() {\n\
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
texcoord0 = vertex_texcoord0;\n\
texcoord1 = vertex_texcoord1;\n\
}\n" };
char fragment[] = { "\
#version 310 es\n\
#define texture1D texture\n\
#define texture3D texture\n\
precision mediump float; \
layout(location = 0) out vec4 out_color;\n\
in vec2 texcoord0;\n\
in vec2 texcoord1;\n\
uniform mat3 colormatrix;\n\
uniform vec3 colormatrix_c;\n\
uniform sampler2D texture0;\n\
uniform sampler2D texture1;\n\
void main() {\n\
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r;\n\
color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg;\n\
// color conversion\n\
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\
color.a = 1.0;\n\
// color mapping\n\
out_color = color;\n\
}\n" };
char fragment_bt2100[] = { "\
#version 310 es\n \
#define texture1D texture\n\
#define texture3D texture\n\
precision mediump float; \
layout(location = 0) out vec4 out_color;\n\
in vec2 texcoord0;\n\
in vec2 texcoord1;\n\
uniform mat3 colormatrix;\n\
uniform vec3 colormatrix_c;\n\
uniform mat3 cms_matrix;\n\
uniform sampler2D texture0;\n\
uniform sampler2D texture1;\n\
//#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))\n\
void main() {\n\
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
color.r = 1.003906 * vec4(texture(texture0, texcoord0)).r;\n\
color.gb = 1.003906 * vec4(texture(texture1, texcoord1)).rg;\n\
// color conversion\n\
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\
color.a = 1.0;\n\
// color mapping\n\
color.rgb = clamp(color.rgb, 0.0, 1.0);\n\
color.rgb = pow(color.rgb, vec3(2.4));\n\
color.rgb = cms_matrix * color.rgb;\n\
color.rgb = clamp(color.rgb, 0.0, 1.0);\n\
color.rgb = pow(color.rgb, vec3(1.0/2.4));\n\
out_color = color;\n\
}\n" };
#else
char vertex_osd[] = { "\
\n\
in vec2 vertex_position;\n\
in vec2 vertex_texcoord0;\n\
out vec2 texcoord0;\n\
void main() {\n\
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
texcoord0 = vertex_texcoord0;\n\
}\n" };
char fragment_osd[] = { "\
\n\
#define texture1D texture\n\
precision mediump float; \
layout(location = 0) out vec4 out_color;\n\
in vec2 texcoord0;\n\
uniform sampler2D texture0;\n\
void main() {\n\
vec4 color; \n\
color = vec4(texture(texture0, texcoord0));\n\
out_color = color;\n\
}\n" };
char vertex[] = { "\
\n\
in vec2 vertex_position;\n\
in vec2 vertex_texcoord0;\n\
out vec2 texcoord0;\n\
in vec2 vertex_texcoord1;\n\
out vec2 texcoord1;\n\
void main() {\n\
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
texcoord0 = vertex_texcoord0;\n\
texcoord1 = vertex_texcoord1;\n\
}\n" };
char fragment[] = { "\
\n\
#define texture1D texture\n\
#define texture3D texture\n\
precision mediump float; \
layout(location = 0) out vec4 out_color;\n\
in vec2 texcoord0;\n\
in vec2 texcoord1;\n\
uniform mat3 colormatrix;\n\
uniform vec3 colormatrix_c;\n\
uniform sampler2D texture0;\n\
uniform sampler2D texture1;\n\
//#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))\n\
void main() {\n\
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r;\n\
color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg;\n\
// color conversion\n\
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\
color.a = 1.0;\n\
// color mapping\n\
out_color = color;\n\
}\n" };
char fragment_bt2100[] = { "\
\n \
#define texture1D texture\n\
#define texture3D texture\n\
precision mediump float; \
layout(location = 0) out vec4 out_color;\n\
in vec2 texcoord0;\n\
in vec2 texcoord1;\n\
uniform mat3 colormatrix;\n\
uniform vec3 colormatrix_c;\n\
uniform mat3 cms_matrix;\n\
uniform sampler2D texture0;\n\
uniform sampler2D texture1;\n\
//#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))\n\
void main() {\n\
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
color.r = 1.003906 * vec4(texture(texture0, texcoord0)).r;\n\
color.gb = 1.003906 * vec4(texture(texture1, texcoord1)).rg;\n\
// color conversion\n\
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\
color.a = 1.0;\n\
// color mapping\n\
color.rgb = clamp(color.rgb, 0.0, 1.0);\n\
color.rgb = pow(color.rgb, vec3(2.4));\n\
color.rgb = cms_matrix * color.rgb;\n\
color.rgb = clamp(color.rgb, 0.0, 1.0);\n\
color.rgb = pow(color.rgb, vec3(1.0/2.4));\n\
out_color = color;\n\
}\n" };
#endif
/* Color conversion matrix: RGB = m * YUV + c
* m is in row-major matrix, with m[row][col], e.g.:
* [ a11 a12 a13 ] float m[3][3] = { { a11, a12, a13 },
* [ a21 a22 a23 ] { a21, a22, a23 },
* [ a31 a32 a33 ] { a31, a32, a33 } };
* This is accessed as e.g.: m[2-1][1-1] = a21
* In particular, each row contains all the coefficients for one of R, G, B,
* while each column contains all the coefficients for one of Y, U, V:
* m[r,g,b][y,u,v] = ...
* The matrix could also be viewed as group of 3 vectors, e.g. the 1st column
* is the Y vector (1, 1, 1), the 2nd is the U vector, the 3rd the V vector.
* The matrix might also be used for other conversions and colorspaces.
*/
struct mp_cmat
{
GLfloat m[3][3]; // colormatrix
GLfloat c[3]; //colormatrix_c
};
struct mp_mat
{
GLfloat m[3][3];
};
// YUV input limited range (16-235 for luma, 16-240 for chroma)
// ITU-R BT.601 (SD)
struct mp_cmat yuv_bt601 = { {{1.164384, 1.164384, 1.164384},
{0.00000, -0.391762, 2.017232},
{1.596027, -0.812968, 0.000000}},
{-0.874202, 0.531668, -1.085631}
};
// ITU-R BT.709 (HD)
struct mp_cmat yuv_bt709 = { {{1.164384, 1.164384, 1.164384},
{0.00000, -0.213249, 2.112402},
{1.792741, -0.532909, 0.000000}},
{-0.972945, 0.301483, -1.133402}
};
// ITU-R BT.2020 non-constant luminance system
struct mp_cmat yuv_bt2020ncl = { {{1.164384, 1.164384, 1.164384},
{0.00000, -0.187326, 2.141772},
{1.678674, -0.650424, 0.000000}},
{-0.915688, 0.347459, -1.148145}
};
// ITU-R BT.2020 constant luminance system
struct mp_cmat yuv_bt2020cl = { {{0.0000, 1.164384, 0.000000},
{0.00000, 0.000000, 1.138393},
{1.138393, 0.000000, 0.000000}},
{-0.571429, -0.073059, -0.571429}
};
float cms_matrix[3][3] = { {1.660497, -0.124547, -0.018154},
{-0.587657, 1.132895, -0.100597},
{-0.072840, -0.008348, 1.118751}
};
struct gl_vao_entry
{
// used for shader / glBindAttribLocation
const char *name;
// glVertexAttribPointer() arguments
int num_elems; // size (number of elements)
GLenum type;
bool normalized;
int offset;
};
struct vertex_pt
{
float x, y;
};
struct vertex_pi
{
GLint x, y;
};
#define TEXUNIT_VIDEO_NUM 6
struct vertex
{
struct vertex_pt position;
struct vertex_pt texcoord[TEXUNIT_VIDEO_NUM];
};
static const struct gl_vao_entry vertex_vao[] = {
{"position", 2, GL_FLOAT, false, offsetof(struct vertex, position)},
{"texcoord0", 2, GL_FLOAT, false, offsetof(struct vertex, texcoord[0])},
{"texcoord1", 2, GL_FLOAT, false, offsetof(struct vertex, texcoord[1])},
{0}
};
static void compile_attach_shader(GLuint program, GLenum type, const char *source)
{
GLuint shader;
GLint status, log_length;
char log[4000];
GLsizei len;
shader = glCreateShader(type);
glShaderSource(shader, 1, &source, NULL);
glCompileShader(shader);
status = 0;
glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
log_length = 0;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_length);
glGetShaderInfoLog(shader, 4000, &len, log);
GlxCheck();
Debug(3, "compile Status %d loglen %d >%s<\n", status, log_length, log);
glAttachShader(program, shader);
glDeleteShader(shader);
}
static void link_shader(GLuint program)
{
GLint status, log_length;
glLinkProgram(program);
status = 0;
glGetProgramiv(program, GL_LINK_STATUS, &status);
log_length = 0;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &log_length);
Debug(3, "Link Status %d loglen %d\n", status, log_length);
}
static GLuint sc_generate_osd(GLuint gl_prog)
{
Debug(3, "vor create osd\n");
gl_prog = glCreateProgram();
Debug(3, "vor compile vertex osd\n");
compile_attach_shader(gl_prog, GL_VERTEX_SHADER, vertex_osd);
Debug(3, "vor compile fragment osd \n");
compile_attach_shader(gl_prog, GL_FRAGMENT_SHADER, fragment_osd);
glBindAttribLocation(gl_prog, 0, "vertex_position");
glBindAttribLocation(gl_prog, 1, "vertex_texcoord0");
link_shader(gl_prog);
return gl_prog;
}
static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace)
{
char vname[80];
int n;
GLint cmsLoc;
float *m, *c, *cms;
char *frag;
switch (colorspace) {
case AVCOL_SPC_RGB:
m = &yuv_bt601.m[0][0];
c = &yuv_bt601.c[0];
frag = fragment;
Debug(3, "BT601 Colorspace used\n");
break;
case AVCOL_SPC_BT709:
case AVCOL_SPC_UNSPECIFIED: // comes with UHD
m = &yuv_bt709.m[0][0];
c = &yuv_bt709.c[0];
frag = fragment;
Debug(3, "BT709 Colorspace used\n");
break;
case AVCOL_SPC_BT2020_NCL:
m = &yuv_bt2020ncl.m[0][0];
c = &yuv_bt2020ncl.c[0];
cms = &cms_matrix[0][0];
frag = fragment_bt2100;
Debug(3, "BT2020NCL Colorspace used\n");
break;
default: // fallback
m = &yuv_bt709.m[0][0];
c = &yuv_bt709.c[0];
frag = fragment;
Debug(3, "default BT709 Colorspace used %d\n", colorspace);
break;
}
Debug(3, "vor create\n");
gl_prog = glCreateProgram();
Debug(3, "vor compile vertex\n");
compile_attach_shader(gl_prog, GL_VERTEX_SHADER, vertex);
Debug(3, "vor compile fragment\n");
compile_attach_shader(gl_prog, GL_FRAGMENT_SHADER, frag);
glBindAttribLocation(gl_prog, 0, "vertex_position");
for (n = 0; n < 6; n++) {
sprintf(vname, "vertex_texcoord%1d", n);
glBindAttribLocation(gl_prog, n + 1, vname);
}
link_shader(gl_prog);
gl_colormatrix = glGetUniformLocation(gl_prog, "colormatrix");
Debug(3, "get uniform colormatrix %d \n", gl_colormatrix);
if (gl_colormatrix != -1)
glProgramUniformMatrix3fv(gl_prog, gl_colormatrix, 1, 0, m);
GlxCheck();
Debug(3, "nach set colormatrix\n");
gl_colormatrix_c = glGetUniformLocation(gl_prog, "colormatrix_c");
Debug(3, "get uniform colormatrix_c %d %f\n", gl_colormatrix_c, *c);
if (gl_colormatrix_c != -1)
glProgramUniform3fv(gl_prog, gl_colormatrix_c, 1, c);
GlxCheck();
if (colorspace == AVCOL_SPC_BT2020_NCL) {
cmsLoc = glGetUniformLocation(gl_prog, "cms_matrix");
if (cmsLoc != -1)
glProgramUniformMatrix3fv(gl_prog, cmsLoc, 1, 0, cms);
GlxCheck();
}
return gl_prog;
}
static void render_pass_quad(int flip, float xcrop, float ycrop)
{
struct vertex va[4];
int n;
const struct gl_vao_entry *e;
// uhhhh what a hack
if (!flip) {
va[0].position.x = (float)-1.0;
va[0].position.y = (float)1.0;
va[1].position.x = (float)-1.0;
va[1].position.y = (float)-1.0;
va[2].position.x = (float)1.0;
va[2].position.y = (float)1.0;
va[3].position.x = (float)1.0;
va[3].position.y = (float)-1.0;
} else {
va[0].position.x = (float)-1.0;
va[0].position.y = (float)-1.0;
va[1].position.x = (float)-1.0;
va[1].position.y = (float)1.0;
va[2].position.x = (float)1.0;
va[2].position.y = (float)-1.0;
va[3].position.x = (float)1.0;
va[3].position.y = (float)1.0;
}
va[0].texcoord[0].x = (float)0.0 + xcrop;
va[0].texcoord[0].y = (float)0.0 + ycrop; // abgeschnitten von links oben
va[0].texcoord[1].x = (float)0.0 + xcrop;
va[0].texcoord[1].y = (float)0.0 + ycrop; // abgeschnitten von links oben
va[1].texcoord[0].x = (float)0.0 + xcrop;
va[1].texcoord[0].y = (float)1.0 - ycrop; // abgeschnitten links unten 1.0 - Wert
va[1].texcoord[1].x = (float)0.0 + xcrop;
va[1].texcoord[1].y = (float)1.0 - ycrop; // abgeschnitten links unten 1.0 - Wert
va[2].texcoord[0].x = (float)1.0 - xcrop;
va[2].texcoord[0].y = (float)0.0 + ycrop; // abgeschnitten von rechts oben
va[2].texcoord[1].x = (float)1.0 - xcrop;
va[2].texcoord[1].y = (float)0.0 + ycrop; // abgeschnitten von rechts oben
va[3].texcoord[0].x = (float)1.0 - xcrop;
va[3].texcoord[0].y = (float)1.0 - ycrop; // abgeschnitten von rechts unten 1.0 - wert
va[3].texcoord[1].x = (float)1.0 - xcrop;
va[3].texcoord[1].y = (float)1.0 - ycrop; // abgeschnitten von rechts unten 1.0 - wert
glBindBuffer(GL_ARRAY_BUFFER, vao_buffer);
glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(struct vertex), va, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
// enable attribs
glBindBuffer(GL_ARRAY_BUFFER, vao_buffer);
for (n = 0; vertex_vao[n].name; n++) {
e = &vertex_vao[n];
glEnableVertexAttribArray(n);
glVertexAttribPointer(n, e->num_elems, e->type, e->normalized, sizeof(struct vertex),
(void *)(intptr_t) e->offset);
}
glBindBuffer(GL_ARRAY_BUFFER, 0);
// draw quad
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
for (n = 0; vertex_vao[n].name; n++)
glDisableVertexAttribArray(n);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +1,23 @@
///
/// @file softhddev.h @brief software HD device plugin header file.
/// @file softhddev.h @brief software HD device plugin header file.
///
/// Copyright (c) 2011 - 2015 by Johns. All Rights Reserved.
/// Copyright (c) 2011 - 2015 by Johns. All Rights Reserved.
///
/// Contributor(s):
/// Contributor(s):
///
/// License: AGPLv3
/// License: AGPLv3
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
///
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
///
/// $Id: efb2e251dd7082138ec21609478d2402be8208cf $
/// $Id: efb2e251dd7082138ec21609478d2402be8208cf $
//////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
@ -25,8 +25,7 @@ extern "C"
{
#endif
/// C callback feed key press
extern void FeedKeyPress(const char *, const char *, int, int,
const char *);
extern void FeedKeyPress(const char *, const char *, int, int, const char *);
/// C plugin get osd size and ascpect
extern void GetOsdSize(int *, int *, double *);
@ -34,8 +33,7 @@ extern "C"
/// C plugin close osd
extern void OsdClose(void);
/// C plugin draw osd pixmap
extern void OsdDrawARGB(int, int, int, int, int, const uint8_t *, int,
int);
extern void OsdDrawARGB(int, int, int, int, int, const uint8_t *, int, int);
/// C plugin play audio packet
extern int PlayAudio(const uint8_t *, int, uint8_t);
@ -111,7 +109,7 @@ extern "C"
/// Pip play video packet
extern int PipPlayVideo(const uint8_t *, int);
extern const char *X11DisplayName; ///< x11 display name
extern const char *X11DisplayName; ///< x11 display name
#ifdef __cplusplus
}
#endif

View File

@ -1,21 +1,21 @@
///
/// @file softhddevice.h @brief software HD device plugin header file.
/// @file softhddevice.h @brief software HD device plugin header file.
///
/// Copyright (c) 2011, 2014 by Johns. All Rights Reserved.
/// Copyright (c) 2011, 2014 by Johns. All Rights Reserved.
///
/// Contributor(s):
/// Contributor(s):
///
/// License: AGPLv3
/// License: AGPLv3
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
///
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
///
/// $Id: 3bc44809950ec019529638cad9223a85d4ab5576 $
/// $Id: 3bc44809950ec019529638cad9223a85d4ab5576 $
//////////////////////////////////////////////////////////////////////////////

View File

@ -1,23 +1,23 @@
///
/// @file softhddev_service.h @brief software HD device service header file.
/// @file softhddev_service.h @brief software HD device service header file.
///
/// Copyright (c) 2012 by durchflieger. All Rights Reserved.
/// Copyright (c) 2012 by durchflieger. All Rights Reserved.
///
/// Contributor(s):
/// Contributor(s):
///
/// License: AGPLv3
/// License: AGPLv3
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
///
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
///
/// $Id: c7c2d5e8b724515d7c767668aab717b27f4e4068 $
/// $Id: c7c2d5e8b724515d7c767668aab717b27f4e4068 $
//////////////////////////////////////////////////////////////////////////////
#pragma once

7326
video.c

File diff suppressed because it is too large Load Diff

65
video.h
View File

@ -1,23 +1,23 @@
///
/// @file video.h @brief Video module header file
/// @file video.h @brief Video module header file
///
/// Copyright (c) 2009 - 2015 by Johns. All Rights Reserved.
/// Copyright (c) 2009 - 2015 by Johns. All Rights Reserved.
///
/// Contributor(s):
/// Contributor(s):
///
/// License: AGPLv3
/// License: AGPLv3
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
///
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
///
/// $Id: 83cd827a8744e8c80c8adba6cb87653b0ad58c45 $
/// $Id: 83cd827a8744e8c80c8adba6cb87653b0ad58c45 $
//////////////////////////////////////////////////////////////////////////////
/// @addtogroup Video
@ -27,7 +27,7 @@
#include <GL/glx.h>
//----------------------------------------------------------------------------
// Typedefs
// Typedefs
//----------------------------------------------------------------------------
/// Video hardware decoder typedef
@ -37,16 +37,16 @@ typedef struct _video_hw_decoder_ VideoHwDecoder;
typedef struct __video_stream__ VideoStream;
//----------------------------------------------------------------------------
// Variables
// Variables
//----------------------------------------------------------------------------
extern signed char VideoHardwareDecoder; ///< flag use hardware decoder
extern char VideoIgnoreRepeatPict; ///< disable repeat pict warning
extern int VideoAudioDelay; ///< audio/video delay
extern char ConfigStartX11Server; ///< flag start the x11 server
extern signed char VideoHardwareDecoder; ///< flag use hardware decoder
extern char VideoIgnoreRepeatPict; ///< disable repeat pict warning
extern int VideoAudioDelay; ///< audio/video delay
extern char ConfigStartX11Server; ///< flag start the x11 server
//----------------------------------------------------------------------------
// Prototypes
// Prototypes
//----------------------------------------------------------------------------
/// Allocate new video hardware decoder.
@ -62,20 +62,17 @@ extern unsigned VideoGetSurface(VideoHwDecoder *, const AVCodecContext *);
extern void VideoReleaseSurface(VideoHwDecoder *, unsigned);
/// Callback to negotiate the PixelFormat.
extern enum AVPixelFormat Video_get_format(VideoHwDecoder *, AVCodecContext *,
const enum AVPixelFormat *);
extern enum AVPixelFormat Video_get_format(VideoHwDecoder *, AVCodecContext *, const enum AVPixelFormat *);
/// Render a ffmpeg frame.
extern void VideoRenderFrame(VideoHwDecoder *, const AVCodecContext *,
const AVFrame *);
extern void VideoRenderFrame(VideoHwDecoder *, const AVCodecContext *, const AVFrame *);
/// Get hwaccel context for ffmpeg.
extern void *VideoGetHwAccelContext(VideoHwDecoder *);
#ifdef AVCODEC_VDPAU_H
/// Draw vdpau render state.
extern void VideoDrawRenderState(VideoHwDecoder *,
struct vdpau_render_state *);
extern void VideoDrawRenderState(VideoHwDecoder *, struct vdpau_render_state *);
#endif
#ifdef USE_OPENGLOSD
@ -189,8 +186,7 @@ extern void VideoSetAutoCrop(int, int, int);
extern void VideoOsdClear(void);
/// Draw an OSD ARGB image.
extern void VideoOsdDrawARGB(int, int, int, int, int, const uint8_t *, int,
int);
extern void VideoOsdDrawARGB(int, int, int, int, int, const uint8_t *, int, int);
/// Get OSD size.
extern void VideoGetOsdSize(int *, int *);
@ -228,11 +224,11 @@ extern void VideoGetStats(VideoHwDecoder *, int *, int *, int *, int *, float *)
/// Get video stream size
extern void VideoGetVideoSize(VideoHwDecoder *, int *, int *, int *, int *);
extern void VideoOsdInit(void); ///< Setup osd.
extern void VideoOsdExit(void); ///< Cleanup osd.
extern void VideoOsdInit(void); ///< Setup osd.
extern void VideoOsdExit(void); ///< Cleanup osd.
extern void VideoInit(const char *); ///< Setup video module.
extern void VideoExit(void); ///< Cleanup and exit video module.
extern void VideoInit(const char *); ///< Setup video module.
extern void VideoExit(void); ///< Cleanup and exit video module.
/// Poll video input buffers.
extern int VideoPollInput(VideoStream *);
@ -248,13 +244,14 @@ extern void SetDPMSatBlackScreen(int);
/// Raise the frontend window
extern int VideoRaiseWindow(void);
#ifdef USE_OPENGLOSD
extern void ActivateOsd(GLuint,int,int,int,int);
extern void ActivateOsd(GLuint, int, int, int, int);
#endif
#if 0
long int gettid()
{
return (long int)syscall(224);
return (long int)syscall(224);
}
#endif