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

Merge branch 'master' into Switch-to-posix-compaatible-sched_yield

This commit is contained in:
9000h 2019-10-28 15:51:49 +01:00 committed by GitHub
commit 1bf5a841e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 10557 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 # Makefile for a Video Disk Recorder plugin
# #
# $Id: 2a41981a57e5e83036463c6a08c84b86ed9d2be3 $ # $Id: 2a41981a57e5e83036463c6a08c84b86ed9d2be3 $
# The official name of this plugin. # The official name of this plugin.
@ -11,13 +11,13 @@
### Configuration (edit this for your needs) ### Configuration (edit this for your needs)
# comment out if not needed # 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 VAAPI is enabled the drivername is softhdvaapi
# if CUVID is enabled the drivername is softhdcuvid # if CUVID is enabled the drivername is softhdcuvid
#VAAPI=1 #VAAPI=1
CUVID=1 CUVID=1
# use libplacebo - available for both drivers # use libplacebo - available for both drivers
#LIBPLACEBO=1 #LIBPLACEBO=1
# use YADIF deint - only available with cuvid # use YADIF deint - only available with cuvid
@ -92,7 +92,7 @@ TMPDIR ?= /tmp
### The compiler options: ### The compiler options:
export CFLAGS = $(call PKGCFG,cflags) export CFLAGS = $(call PKGCFG,cflags)
export CXXFLAGS = $(call PKGCFG,cxxflags) export CXXFLAGS = $(call PKGCFG,cxxflags)
ifeq ($(CFLAGS),) ifeq ($(CFLAGS),)
@ -136,16 +136,16 @@ endif
ifeq ($(OPENGL),1) ifeq ($(OPENGL),1)
CONFIG += -DUSE_GLX CONFIG += -DUSE_GLX
_CFLAGS += $(shell pkg-config --cflags gl glu glew) _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) _CFLAGS += $(shell pkg-config --cflags freetype2)
LIBS += $(shell pkg-config --libs freetype2) LIBS += $(shell pkg-config --libs freetype2)
endif endif
ifeq ($(VAAPI),1) ifeq ($(VAAPI),1)
CONFIG += -DVAAPI CONFIG += -DVAAPI
#LIBPLACEBO=1 #LIBPLACEBO=1
PLUGIN = softhdvaapi PLUGIN = softhdvaapi
LIBS += -lEGL LIBS += -lEGL
endif endif
ifeq ($(LIBPLACEBO),1) ifeq ($(LIBPLACEBO),1)
@ -155,7 +155,7 @@ endif
ifeq ($(CUVID),1) ifeq ($(CUVID),1)
CONFIG += -DUSE_PIP # PIP support CONFIG += -DUSE_PIP # PIP support
CONFIG += -DCUVID # enable CUVID decoder CONFIG += -DCUVID # enable CUVID decoder
LIBS += -lEGL -lGL LIBS += -lEGL -lGL
ifeq ($(YADIF),1) ifeq ($(YADIF),1)
CONFIG += -DYADIF # Yadif only with CUVID CONFIG += -DYADIF # Yadif only with CUVID
endif 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)) #ifneq (exists, $(shell pkg-config libswresample && echo exists))
# $(warning ******************************************************************) # $(warning ******************************************************************)
@ -182,7 +182,7 @@ SOFILE = libvdr-$(PLUGIN).so
#endif #endif
# #
# Test and set config for libavutil # Test and set config for libavutil
# #
ifneq (exists, $(shell pkg-config libavutil && echo exists)) ifneq (exists, $(shell pkg-config libavutil && echo exists))
$(warning ******************************************************************) $(warning ******************************************************************)
@ -193,7 +193,7 @@ _CFLAGS += $(shell pkg-config --cflags libavutil)
LIBS += $(shell pkg-config --libs 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)) ifneq (exists, $(shell pkg-config libswscale && echo exists))
$(warning ******************************************************************) $(warning ******************************************************************)
@ -233,10 +233,10 @@ endif
#_CFLAGS += $(shell pkg-config --cflags libavcodec x11 x11-xcb xcb xcb-icccm) #_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) #LIBS += -lrt $(shell pkg-config --libs libavcodec x11 x11-xcb xcb xcb-icccm)
_CFLAGS += $(shell pkg-config --cflags x11 x11-xcb xcb xcb-icccm) _CFLAGS += $(shell pkg-config --cflags x11 x11-xcb xcb xcb-icccm)
LIBS += -lrt $(shell pkg-config --libs x11 x11-xcb xcb xcb-icccm) LIBS += -lrt $(shell pkg-config --libs x11 x11-xcb xcb xcb-icccm)
_CFLAGS += -I/usr/local/cuda/include _CFLAGS += -I/usr/local/cuda/include
_CFLAGS += -I./opengl -I./ _CFLAGS += -I./opengl -I./
LIBS += -L/usr/lib64 LIBS += -L/usr/lib64
@ -247,10 +247,10 @@ LIBS += -lplacebo -lglut
endif endif
ifeq ($(CUVID),1) 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 endif
LIBS += -lGLEW -lGLU -ldl LIBS += -lGLEW -lGLU -ldl
### Includes and Defines (add further entries here): ### Includes and Defines (add further entries here):
INCLUDES += INCLUDES +=
@ -261,16 +261,16 @@ DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -D_GNU_SOURCE $(CONFIG) \
### Make it standard ### Make it standard
override CXXFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \ override CXXFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \
-g -Wextra -Winit-self -Werror=overloaded-virtual -std=c++0x -g -Wextra -Winit-self -Werror=overloaded-virtual -std=c++0x
override CFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \ override CFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \
-g -W -Wextra -Winit-self -Wdeclaration-after-statement -g -W -Wextra -Winit-self -Wdeclaration-after-statement
### The object files (add further files here): ### 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) ifeq ($(OPENGLOSD),1)
OBJS += openglosd.o OBJS += openglosd.o
endif endif
SRCS = $(wildcard $(OBJS:.o=.c)) softhdcuvid.cpp SRCS = $(wildcard $(OBJS:.o=.c)) softhdcuvid.cpp
@ -290,11 +290,11 @@ $(DEPFILE): Makefile
### Internationalization (I18N): ### Internationalization (I18N):
PODIR = po PODIR = po
I18Npo = $(wildcard $(PODIR)/*.po) I18Npo = $(wildcard $(PODIR)/*.po)
I18Nmo = $(addsuffix .mo, $(foreach file, $(I18Npo), $(basename $(file)))) I18Nmo = $(addsuffix .mo, $(foreach file, $(I18Npo), $(basename $(file))))
I18Nmsgs = $(addprefix $(DESTDIR)$(LOCDIR)/, $(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo, $(notdir $(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 %.mo: %.po
msgfmt -c -o $@ $< msgfmt -c -o $@ $<
@ -322,7 +322,7 @@ $(OBJS): Makefile
$(SOFILE): $(OBJS) shaders.h $(SOFILE): $(OBJS) shaders.h
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) $(LIBS) -o $@ $(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) $(LIBS) -o $@
install-lib: $(SOFILE) install-lib: $(SOFILE)
install -D $^ $(DESTDIR)$(LIBDIR)/$^.$(APIVERSION) install -D $^ $(DESTDIR)$(LIBDIR)/$^.$(APIVERSION)
@ -343,13 +343,11 @@ clean:
## Private Targets: ## Private Targets:
HDRS= $(wildcard *.h) HDRS= $(wildcard *.h)
indent: indent:
for i in $(SRCS) $(HDRS); do \ for i in $(SRCS) $(HDRS); do \
indent $$i; \ indent $$i; \
unexpand -a $$i | sed -e s/constconst/const/ > $$i.up; \
mv $$i.up $$i; \
done done
video_test: video.c Makefile 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 /// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as /// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the /// published by the Free Software Foundation, either version 3 of the
/// License. /// License.
/// ///
/// This program is distributed in the hope that it will be useful, /// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of /// 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 Affero General Public License for more details. /// GNU Affero General Public License for more details.
/// ///
/// $Id: da055758af70cfdb9ab1989d5fcfb218c5d6a366 $ /// $Id: da055758af70cfdb9ab1989d5fcfb218c5d6a366 $
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// @addtogroup Audio /// @addtogroup Audio
/// @{ /// @{
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Prototypes // Prototypes
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
extern void AudioEnqueue(const void *, int); ///< buffer audio samples extern void AudioEnqueue(const void *, int); ///< buffer audio samples
extern void AudioFlushBuffers(void); ///< flush audio buffers extern void AudioFlushBuffers(void); ///< flush audio buffers
extern void AudioPoller(void); ///< poll audio events/handling extern void AudioPoller(void); ///< poll audio events/handling
extern int AudioFreeBytes(void); ///< free bytes in audio output extern int AudioFreeBytes(void); ///< free bytes in audio output
extern int AudioUsedBytes(void); ///< used bytes in audio output extern int AudioUsedBytes(void); ///< used bytes in audio output
extern int64_t AudioGetDelay(void); ///< get current audio delay extern int64_t AudioGetDelay(void); ///< get current audio delay
extern void AudioSetClock(int64_t); ///< set audio clock base extern void AudioSetClock(int64_t); ///< set audio clock base
extern int64_t AudioGetClock(); ///< get current audio clock extern int64_t AudioGetClock(); ///< get current audio clock
extern void AudioSetVolume(int); ///< set volume extern void AudioSetVolume(int); ///< set volume
extern int AudioSetup(int *, int *, int); ///< setup audio output extern int AudioSetup(int *, int *, int); ///< setup audio output
extern void AudioPlay(void); ///< play audio extern void AudioPlay(void); ///< play audio
extern void AudioPause(void); ///< pause audio extern void AudioPause(void); ///< pause audio
extern void AudioSetBufferTime(int); ///< set audio buffer time extern void AudioSetBufferTime(int); ///< set audio buffer time
extern void AudioSetSoftvol(int); ///< enable/disable softvol extern void AudioSetSoftvol(int); ///< enable/disable softvol
extern void AudioSetNormalize(int, int); ///< set normalize parameters extern void AudioSetNormalize(int, int); ///< set normalize parameters
extern void AudioSetCompression(int, int); ///< set compression parameters extern void AudioSetCompression(int, int); ///< set compression parameters
extern void AudioSetStereoDescent(int); ///< set stereo loudness descent 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 /// set pass-through device
extern void AudioSetPassthroughDevice(const char *); extern void AudioSetPassthroughDevice(const char *);
extern void AudioSetChannel(const char *); ///< set mixer channel extern void AudioSetChannel(const char *); ///< set mixer channel
extern void AudioSetAutoAES(int); ///< set automatic AES flag handling extern void AudioSetAutoAES(int); ///< set automatic AES flag handling
extern void AudioInit(void); ///< setup audio module extern void AudioInit(void); ///< setup audio module
extern void AudioExit(void); ///< cleanup and exit audio module extern void AudioExit(void); ///< cleanup and exit audio module
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Variables // Variables
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
extern char AudioAlsaDriverBroken; ///< disable broken driver message extern char AudioAlsaDriverBroken; ///< disable broken driver message
extern char AudioAlsaNoCloseOpen; ///< disable alsa close/open fix extern char AudioAlsaNoCloseOpen; ///< disable alsa close/open fix
extern char AudioAlsaCloseOpenDelay; ///< enable alsa close/open delay 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 /// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as /// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the /// published by the Free Software Foundation, either version 3 of the
/// License. /// License.
/// ///
/// This program is distributed in the hope that it will be useful, /// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of /// 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 Affero General Public License for more details. /// GNU Affero General Public License for more details.
/// ///
/// $Id: bdb4d18dbe371e497d039e45faa7c134b019860a $ /// $Id: bdb4d18dbe371e497d039e45faa7c134b019860a $
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// @addtogroup Codec /// @addtogroup Codec
/// @{ /// @{
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Defines // Defines
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
#define CodecPCM 0x01 ///< PCM bit mask #define CodecPCM 0x01 ///< PCM bit mask
#define CodecMPA 0x02 ///< MPA bit mask (planned) #define CodecMPA 0x02 ///< MPA bit mask (planned)
#define CodecAC3 0x04 ///< AC-3 bit mask #define CodecAC3 0x04 ///< AC-3 bit mask
#define CodecEAC3 0x08 ///< E-AC-3 bit mask #define CodecEAC3 0x08 ///< E-AC-3 bit mask
#define CodecDTS 0x10 ///< DTS bit mask (planned) #define CodecDTS 0x10 ///< DTS bit mask (planned)
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000
enum HWAccelID { enum HWAccelID
HWACCEL_NONE = 0, {
HWACCEL_AUTO, HWACCEL_NONE = 0,
HWACCEL_VDPAU, HWACCEL_AUTO,
HWACCEL_DXVA2, HWACCEL_VDPAU,
HWACCEL_VDA, HWACCEL_DXVA2,
HWACCEL_VIDEOTOOLBOX, HWACCEL_VDA,
HWACCEL_QSV, HWACCEL_VIDEOTOOLBOX,
HWACCEL_VAAPI, HWACCEL_QSV,
HWACCEL_CUVID, HWACCEL_VAAPI,
HWACCEL_CUVID,
}; };
extern AVBufferRef *hw_device_ctx; extern AVBufferRef *hw_device_ctx;
/// ///
/// Video decoder structure. /// Video decoder structure.
/// ///
struct _video_decoder_ struct _video_decoder_
{ {
VideoHwDecoder *HwDecoder; ///< video hardware 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
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 */ int filter; // flag for deint filter
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; /* hwaccel options */
// For HDR side-data caching enum HWAccelID hwaccel_id;
double cached_hdr_peak; char *hwaccel_device;
// From VO enum AVPixelFormat hwaccel_output_format;
struct mp_hwdec_devices *hwdec_devs;
/* 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. /// Video decoder typedef.
@ -111,14 +111,14 @@ extern const char *X11DisplayName;
extern AVBufferRef *HwDeviceContext; extern AVBufferRef *HwDeviceContext;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Variables // Variables
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
/// Flag prefer fast xhannel switch /// Flag prefer fast xhannel switch
extern char CodecUsePossibleDefectFrames; extern char CodecUsePossibleDefectFrames;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Prototypes // Prototypes
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
/// Allocate a new video decoder context. /// Allocate a new video decoder context.

297
common.h
View File

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

View File

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

View File

@ -1,3 +1,4 @@
/* /*
* Copyright 1993-2013 NVIDIA Corporation. All rights reserved. * Copyright 1993-2013 NVIDIA Corporation. All rights reserved.
* *
@ -16,88 +17,91 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef __cuda_cuda_h__ // check to see if CUDA_H is included above #ifdef __cuda_cuda_h__ // check to see if CUDA_H is included above
// Error Code string definitions here // Error Code string definitions here
typedef struct typedef struct
{ {
char const *error_string; char const *error_string;
unsigned int error_id; unsigned int error_id;
} s_CudaErrorStr; } s_CudaErrorStr;
/** /**
* Error codes * Error codes
*/ */
s_CudaErrorStr sCudaDrvErrorString[] = s_CudaErrorStr sCudaDrvErrorString[] = {
{
/** /**
* The API call returned with no errors. In the case of query calls, this * 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 * can also mean that the operation being queried is complete (see
* ::cuEventQuery() and ::cuStreamQuery()). * ::cuEventQuery() and ::cuStreamQuery()).
*/ */
{ "CUDA_SUCCESS", 0 }, {"CUDA_SUCCESS", 0},
/** /**
* This indicates that one or more of the parameters passed to the API call * This indicates that one or more of the parameters passed to the API call
* is not within an acceptable range of values. * 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 * The API call failed because it was unable to allocate enough memory to
* perform the requested operation. * 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 * This indicates that the CUDA driver has not been initialized with
* ::cuInit() or that initialization has failed. * ::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. * 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 * This indicates profiling APIs are called while application is running
* in visual profiler mode. * in visual profiler mode.
*/ */
{ "CUDA_ERROR_PROFILER_DISABLED", 5 }, {"CUDA_ERROR_PROFILER_DISABLED", 5},
/** /**
* This indicates profiling has not been initialized for this context. * This indicates profiling has not been initialized for this context.
* Call cuProfilerInitialize() to resolve this. * 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 * This indicates profiler has already been started and probably
* cuProfilerStart() is incorrectly called. * 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 * This indicates profiler has already been stopped and probably
* cuProfilerStop() is incorrectly called. * 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 * This indicates that no CUDA-capable devices were detected by the installed
* CUDA driver. * 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 * This indicates that the device ordinal supplied by the user does not
* correspond to a valid CUDA device. * 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 * This indicates that the device kernel image is invalid. This can also
* indicate an invalid CUDA module. * 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 * 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). * mixes different API versions (i.e. 3010 context with 3020 API calls).
* See ::cuCtxGetApiVersion() for more details. * 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 * 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 * 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(). * 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. * 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. * 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 * This indicates that the specified array is currently mapped and thus
* cannot be destroyed. * cannot be destroyed.
*/ */
{ "CUDA_ERROR_ARRAY_IS_MAPPED", 207 }, {"CUDA_ERROR_ARRAY_IS_MAPPED", 207},
/** /**
* This indicates that the resource is already mapped. * 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 * 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 * options for a particular CUDA source file that do not include the
* corresponding device configuration. * 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. * 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. * 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 * This indicates that a mapped resource is not available for access as an
* array. * 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 * This indicates that a mapped resource is not available for access as a
* pointer. * 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 * This indicates that an uncorrectable ECC error was detected during
* execution. * execution.
*/ */
{ "CUDA_ERROR_ECC_UNCORRECTABLE", 214 }, {"CUDA_ERROR_ECC_UNCORRECTABLE", 214},
/** /**
* This indicates that the ::CUlimit passed to the API call is not * This indicates that the ::CUlimit passed to the API call is not
* supported by the active device. * 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 * 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 * only be bound to a single CPU thread at a time but is already
* bound to a CPU thread. * 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 * This indicates that peer access is not supported across the given
* devices. * devices.
*/ */
{ "CUDA_ERROR_PEER_ACCESS_UNSUPPORTED", 217 }, {"CUDA_ERROR_PEER_ACCESS_UNSUPPORTED", 217},
/** /**
* This indicates that a PTX JIT compilation failed. * 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. * 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 * This indicates that an uncorrectable NVLink error was detected during the
* execution. * execution.
*/ */
{ "CUDA_ERROR_NVLINK_UNCORRECTABLE", 220 }, {"CUDA_ERROR_NVLINK_UNCORRECTABLE", 220},
/** /**
* This indicates that the PTX JIT compiler library was not found. * 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. * 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. * 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. * 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. * 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. * 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 * This indicates that a resource handle passed to the API call was not
* valid. Resource handles are opaque types like ::CUstream and ::CUevent. * 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 * This indicates that a named symbol was not found. Examples of symbols
* are global/constant variable names, texture names }, and surface names. * 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 * 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 * differently than ::CUDA_SUCCESS (which indicates completion). Calls that
* may return this value include ::cuEventQuery() and ::cuStreamQuery(). * 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 * 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 * will return the same error. To continue using CUDA, the process must be terminated
* and relaunched. * 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 * 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 * when a 32-bit int is expected) is equivalent to passing too many
* arguments and can also result in this error. * 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 * 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 * this context are invalid and must be reconstructed if the program is to
* continue using CUDA. * continue using CUDA.
*/ */
{ "CUDA_ERROR_LAUNCH_TIMEOUT", 702 }, {"CUDA_ERROR_LAUNCH_TIMEOUT", 702},
/** /**
* This error indicates a kernel launch that uses an incompatible texturing * This error indicates a kernel launch that uses an incompatible texturing
* mode. * mode.
*/ */
{ "CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING", 703 }, {"CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING", 703},
/** /**
* This error indicates that a call to ::cuCtxEnablePeerAccess() is * This error indicates that a call to ::cuCtxEnablePeerAccess() is
* trying to re-enable peer access to a context which has already * trying to re-enable peer access to a context which has already
* had peer access to it enabled. * 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 * This error indicates that ::cuCtxDisablePeerAccess() is
* trying to disable peer access which has not been enabled yet * trying to disable peer access which has not been enabled yet
* via ::cuCtxEnablePeerAccess(). * 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 * This error indicates that the primary context for the specified device
* has already been initialized. * 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 * This error indicates that the context current to the calling thread
* has been destroyed using ::cuCtxDestroy }, or is a primary context which * has been destroyed using ::cuCtxDestroy }, or is a primary context which
* has not yet been initialized. * 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 * 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 * memory allocations from this context are invalid and must be
* reconstructed if the program is to continue using CUDA. * 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 * This error indicates that the hardware resources required to enable
* peer access have been exhausted for one or more of the devices * peer access have been exhausted for one or more of the devices
* passed to ::cuCtxEnablePeerAccess(). * 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() * This error indicates that the memory range passed to ::cuMemHostRegister()
* has already been registered. * 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() * This error indicates that the pointer passed to ::cuMemHostUnregister()
* does not correspond to any currently registered memory region. * 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. * 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 * will return the same error. To continue using CUDA, the process must be terminated
* and relaunched. * and relaunched.
*/ */
{ "CUDA_ERROR_HARDWARE_STACK_ERROR", 714 }, {"CUDA_ERROR_HARDWARE_STACK_ERROR", 714},
/** /**
* While executing a kernel, the device encountered an illegal instruction. * 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 * will return the same error. To continue using CUDA, the process must be terminated
* and relaunched. * and relaunched.
*/ */
{ "CUDA_ERROR_ILLEGAL_INSTRUCTION", 715 }, {"CUDA_ERROR_ILLEGAL_INSTRUCTION", 715},
/** /**
* While executing a kernel, the device encountered a load or store instruction * 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 * will return the same error. To continue using CUDA, the process must be terminated
* and relaunched. * and relaunched.
*/ */
{ "CUDA_ERROR_MISALIGNED_ADDRESS", 716 }, {"CUDA_ERROR_MISALIGNED_ADDRESS", 716},
/** /**
* While executing a kernel, the device encountered an instruction * 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 * will return the same error. To continue using CUDA, the process must be terminated
* and relaunched. * 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. * 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 * will return the same error. To continue using CUDA, the process must be terminated
* and relaunched. * and relaunched.
*/ */
{ "CUDA_ERROR_INVALID_PC", 718 }, {"CUDA_ERROR_INVALID_PC", 718},
/** /**
* An exception occurred on the device while executing a kernel. Common * 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 * memory allocations from this context are invalid and must be
* reconstructed if the program is to continue using CUDA. * 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 * 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 * or ::cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags times the number of multiprocessors
* as specified by the device attribute ::CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT. * 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. * 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 * This error indicates that the attempted operation is not supported
* on the current system or device. * 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. * This indicates that an unknown internal error has occurred.
*/ */
{ "CUDA_ERROR_UNKNOWN", 999 }, {"CUDA_ERROR_UNKNOWN", 999},
{ NULL, -1 } {NULL, -1}
}; };
// This is just a linear search through the array, since the error_id's are not // 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; int index = 0;
while (sCudaDrvErrorString[index].error_id != error_id && while (sCudaDrvErrorString[index].error_id != error_id && (int)sCudaDrvErrorString[index].error_id != -1) {
(int)sCudaDrvErrorString[index].error_id != -1)
{
index++; index++;
} }
@ -459,5 +455,4 @@ static inline const char *getCudaDrvErrorString(CUresult error_id)
#endif // __cuda_cuda_h__ #endif // __cuda_cuda_h__
#endif #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 /// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as /// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the /// published by the Free Software Foundation, either version 3 of the
/// License. /// License.
/// ///
/// This program is distributed in the hope that it will be useful, /// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of /// 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 Affero General Public License for more details. /// GNU Affero General Public License for more details.
/// ///
/// $Id: 59e1684aaa6678ecdebb6ce0df6ce5b5f461dd6e $ /// $Id: 59e1684aaa6678ecdebb6ce0df6ce5b5f461dd6e $
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// @addtogroup iatomic /// @addtogroup iatomic
@ -27,8 +27,8 @@
+ __GNUC_MINOR__ * 100 \ + __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__) + __GNUC_PATCHLEVEL__)
// gcc before 4.7 didn't support atomic builtins, // gcc before 4.7 didn't support atomic builtins,
// use alsa atomic functions. // use alsa atomic functions.
#if GCC_VERSION < 40700 #if GCC_VERSION < 40700
#include <alsa/iatomic.h> #include <alsa/iatomic.h>
@ -36,58 +36,58 @@
#else #else
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Defines // Defines
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Declares // Declares
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// ///
/// atomic type, 24 bit useable, /// atomic type, 24 bit useable,
/// ///
typedef volatile int atomic_t; typedef volatile int atomic_t;
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Prototypes // Prototypes
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Inlines // Inlines
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// ///
/// Set atomic value. /// Set atomic value.
/// ///
#define atomic_set(ptr, val) \ #define atomic_set(ptr, val) \
__atomic_store_n(ptr, val, __ATOMIC_SEQ_CST) __atomic_store_n(ptr, val, __ATOMIC_SEQ_CST)
/// ///
/// Read atomic value. /// Read atomic value.
/// ///
#define atomic_read(ptr) \ #define atomic_read(ptr) \
__atomic_load_n(ptr, __ATOMIC_SEQ_CST) __atomic_load_n(ptr, __ATOMIC_SEQ_CST)
/// ///
/// Increment atomic value. /// Increment atomic value.
/// ///
#define atomic_inc(ptr) \ #define atomic_inc(ptr) \
__atomic_add_fetch(ptr, 1, __ATOMIC_SEQ_CST) __atomic_add_fetch(ptr, 1, __ATOMIC_SEQ_CST)
/// ///
/// Decrement atomic value. /// Decrement atomic value.
/// ///
#define atomic_dec(ptr) \ #define atomic_dec(ptr) \
__atomic_sub_fetch(ptr, 1, __ATOMIC_SEQ_CST) __atomic_sub_fetch(ptr, 1, __ATOMIC_SEQ_CST)
/// ///
/// Add to atomic value. /// Add to atomic value.
/// ///
#define atomic_add(val, ptr) \ #define atomic_add(val, ptr) \
__atomic_add_fetch(ptr, val, __ATOMIC_SEQ_CST) __atomic_add_fetch(ptr, val, __ATOMIC_SEQ_CST)
/// ///
/// Subtract from atomic value. /// Subtract from atomic value.
/// ///
#define atomic_sub(val, ptr) \ #define atomic_sub(val, ptr) \
__atomic_sub_fetch(ptr, val, __ATOMIC_SEQ_CST) __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): /// Contributor(s):
/// Copied from uwm. /// Copied from uwm.
/// ///
/// License: AGPLv3 /// License: AGPLv3
/// ///
/// This program is free software: you can redistribute it and/or modify /// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as /// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the /// published by the Free Software Foundation, either version 3 of the
/// License. /// License.
/// ///
/// This program is distributed in the hope that it will be useful, /// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of /// 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 Affero General Public License for more details. /// GNU Affero General Public License for more details.
/// ///
/// $Id: f5ff4b300aa33eb721d658c0c9374c8499b67318 $ /// $Id: f5ff4b300aa33eb721d658c0c9374c8499b67318 $
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// @addtogroup misc /// @addtogroup misc
@ -26,37 +26,37 @@
#include <syslog.h> #include <syslog.h>
#include <stdarg.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, ...) static inline void Syslog(const int, const char *format, ...)
__attribute__ ((format(printf, 2, 3))); __attribute__((format(printf, 2, 3)));
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Inlines // Inlines
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#ifdef DEBUG #ifdef DEBUG
#define DebugLevel 4 /// private debug level #define DebugLevel 4 /// private debug level
#else #else
#define DebugLevel 0 /// private debug level #define DebugLevel 0 /// private debug level
#endif #endif
/** /**
@ -70,11 +70,11 @@ static inline void Syslog(const int, const char *format, ...)
static inline void Syslog(const int level, const char *format, ...) static inline void Syslog(const int level, const char *format, ...)
{ {
if (SysLogLevel > level || DebugLevel > level) { if (SysLogLevel > level || DebugLevel > level) {
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);
vsyslog(LOG_ERR, format, ap); vsyslog(LOG_ERR, format, ap);
va_end(ap); va_end(ap);
} }
} }
@ -104,7 +104,7 @@ static inline void Syslog(const int level, const char *format, ...)
#ifdef DEBUG #ifdef DEBUG
#define Debug(level, fmt...) Syslog(level, fmt) #define Debug(level, fmt...) Syslog(level, fmt)
#else #else
#define Debug(level, fmt...) /* disabled */ #define Debug(level, fmt...) /* disabled */
#endif #endif
#ifndef AV_NOPTS_VALUE #ifndef AV_NOPTS_VALUE
@ -122,12 +122,11 @@ static inline const char *Timestamp2String(int64_t ts)
static int idx; static int idx;
if (ts == (int64_t) AV_NOPTS_VALUE) { if (ts == (int64_t) AV_NOPTS_VALUE) {
return "--:--:--.---"; return "--:--:--.---";
} }
idx = (idx + 1) % 3; idx = (idx + 1) % 3;
snprintf(buf[idx], sizeof(buf[idx]), "%2d:%02d:%02d.%03d", snprintf(buf[idx], sizeof(buf[idx]), "%2d:%02d:%02d.%03d", (int)(ts / (90 * 3600000)),
(int)(ts / (90 * 3600000)), (int)((ts / (90 * 60000)) % 60), (int)((ts / (90 * 60000)) % 60), (int)((ts / (90 * 1000)) % 60), (int)((ts / 90) % 1000));
(int)((ts / (90 * 1000)) % 60), (int)((ts / 90) % 1000));
return buf[idx]; return buf[idx];
} }
@ -148,24 +147,25 @@ static inline uint32_t GetMsTicks(void)
struct timeval tval; struct timeval tval;
if (gettimeofday(&tval, NULL) < 0) { if (gettimeofday(&tval, NULL) < 0) {
return 0; return 0;
} }
return (tval.tv_sec * 1000) + (tval.tv_usec / 1000); return (tval.tv_sec * 1000) + (tval.tv_usec / 1000);
#endif #endif
} }
static inline uint64_t GetusTicks(void) static inline uint64_t GetusTicks(void)
{ {
#ifdef CLOCK_MONOTONIC #ifdef CLOCK_MONOTONIC
struct timespec tspec; struct timespec tspec;
clock_gettime(CLOCK_MONOTONIC, &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 #else
struct timeval tval; struct timeval tval;
if (gettimeofday(&tval, NULL) < 0) { if (gettimeofday(&tval, NULL) < 0) {
return 0; return 0;
} }
return (tval.tv_sec * 1000) + (tval.tv_usec / 1000); return (tval.tv_sec * 1000) + (tval.tv_usec / 1000);
#endif #endif

View File

@ -616,6 +616,7 @@ void cOglFb::BindWrite(void) {
} }
void cOglFb::Unbind(void) { void cOglFb::Unbind(void) {
glFinish();
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
} }

View File

@ -17,25 +17,21 @@
#include FT_STROKER_H #include FT_STROKER_H
#undef __FTERRORS_H__ #undef __FTERRORS_H__
#define FT_ERRORDEF( e, v, s ) { e, s }, #define FT_ERRORDEF( e, v, s ) { e, s },
#define FT_ERROR_START_LIST { #define FT_ERROR_START_LIST {
#define FT_ERROR_END_LIST { 0, 0 } }; #define FT_ERROR_END_LIST { 0, 0 } };
const struct { const struct
int code; {
const char* message; int code;
const char *message;
} FT_Errors[] = } FT_Errors[] =
#include FT_ERRORS_H #include FT_ERRORS_H
#include <memory> #include <memory>
#include <queue> #include <queue>
#include <vdr/plugin.h> #include <vdr/plugin.h>
#include <vdr/osd.h> #include <vdr/osd.h>
#include <vdr/thread.h> #include <vdr/thread.h>
#include "softhddev.h" #include "softhddev.h"
extern "C" extern "C"
{ {
#include <stdint.h> #include <stdint.h>
@ -49,7 +45,8 @@ extern "C"
extern "C" pthread_mutex_t OSDMutex; extern "C" pthread_mutex_t OSDMutex;
struct sOglImage { struct sOglImage
{
GLuint texture; GLuint texture;
GLint width; GLint width;
GLint height; GLint height;
@ -60,69 +57,97 @@ struct sOglImage {
* Helpers * Helpers
****************************************************************************************/ ****************************************************************************************/
void ConvertColor(const GLint &colARGB, glm::vec4 &col); void ConvertColor(const GLint & colARGB, glm::vec4 & col);
/**************************************************************************************** /****************************************************************************************
* cShader * cShader
****************************************************************************************/ ****************************************************************************************/
enum eShaderType { enum eShaderType
{
stRect, stRect,
stTexture, stTexture,
stText, stText,
stCount stCount
}; };
class cShader { class cShader
private: {
private:
eShaderType type; eShaderType type;
GLuint id; GLuint id;
bool Compile(const char *vertexCode, const char *fragmentCode); bool Compile(const char *vertexCode, const char *fragmentCode);
bool CheckCompileErrors(GLuint object, bool program = false); bool CheckCompileErrors(GLuint object, bool program = false);
public: public:
cShader(void) {}; cShader(void)
virtual ~cShader(void) {}; {
};
virtual ~ cShader(void)
{
};
bool Load(eShaderType type); bool Load(eShaderType type);
void Use(void); void Use(void);
void SetFloat (const GLchar *name, GLfloat value); void SetFloat(const GLchar * name, GLfloat value);
void SetInteger (const GLchar *name, GLint value); void SetInteger(const GLchar * name, GLint value);
void SetVector2f (const GLchar *name, GLfloat x, GLfloat y); void SetVector2f(const GLchar * name, GLfloat x, GLfloat y);
void SetVector3f (const GLchar *name, GLfloat x, GLfloat y, GLfloat z); 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 SetVector4f(const GLchar * name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void SetMatrix4 (const GLchar *name, const glm::mat4 &matrix); void SetMatrix4(const GLchar * name, const glm::mat4 & matrix);
}; };
/**************************************************************************************** /****************************************************************************************
* cOglGlyph * cOglGlyph
****************************************************************************************/ ****************************************************************************************/
class cOglGlyph : public cListObject { class cOglGlyph:public cListObject
private: {
struct tKerning { private:
public: struct tKerning
tKerning(uint prevSym, GLfloat kerning = 0.0f) { {
this->prevSym = prevSym; public:
this->kerning = kerning; tKerning(uint prevSym, GLfloat kerning = 0.0f) {
} this->prevSym = prevSym;
uint prevSym; this->kerning = kerning;
GLfloat kerning; }
uint prevSym;
GLfloat kerning;
}; };
uint charCode; uint charCode;
int bearingLeft; int bearingLeft;
int bearingTop; int bearingTop;
int width; int width;
int height; int height;
int advanceX; int advanceX;
cVector<tKerning> kerningCache;
cVector < tKerning > kerningCache;
GLuint texture; GLuint texture;
void LoadTexture(FT_BitmapGlyph ftGlyph); void LoadTexture(FT_BitmapGlyph ftGlyph);
public:
public:
cOglGlyph(uint charCode, FT_BitmapGlyph ftGlyph); cOglGlyph(uint charCode, FT_BitmapGlyph ftGlyph);
virtual ~cOglGlyph(); virtual ~ cOglGlyph();
uint CharCode(void) { return charCode; } uint CharCode(void)
int AdvanceX(void) { return advanceX; } {
int BearingLeft(void) const { return bearingLeft; } return charCode;
int BearingTop(void) const { return bearingTop; } }
int Width(void) const { return width; } int AdvanceX(void)
int Height(void) const { return height; } {
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); int GetKerningCache(uint prevSym);
void SetKerningCache(uint prevSym, int kerning); void SetKerningCache(uint prevSym, int kerning);
void BindTexture(void); void BindTexture(void);
@ -131,8 +156,9 @@ public:
/**************************************************************************************** /****************************************************************************************
* cOglFont * cOglFont
****************************************************************************************/ ****************************************************************************************/
class cOglFont : public cListObject { class cOglFont:public cListObject
private: {
private:
static bool initiated; static bool initiated;
cString name; cString name;
int size; int size;
@ -140,41 +166,57 @@ private:
int bottom; int bottom;
static FT_Library ftLib; static FT_Library ftLib;
FT_Face face; FT_Face face;
static cList<cOglFont> *fonts; static cList < cOglFont > *fonts;
mutable cList<cOglGlyph> glyphCache; mutable cList < cOglGlyph > glyphCache;
cOglFont(const char *fontName, int charHeight); cOglFont(const char *fontName, int charHeight);
static void Init(void); static void Init(void);
public: public:
virtual ~cOglFont(void); virtual ~ cOglFont(void);
static cOglFont *Get(const char *name, int charHeight); static cOglFont *Get(const char *name, int charHeight);
static void Cleanup(void); static void Cleanup(void);
const char *Name(void) { return *name; }; const char *Name(void)
int Size(void) { return size; }; {
int Bottom(void) {return bottom; }; return *name;
int Height(void) {return height; }; };
cOglGlyph* Glyph(uint charCode) const; int Size(void)
int Kerning(cOglGlyph *glyph, uint prevSym) const; {
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 * cOglFb
* Framebuffer Object - OpenGL part of a Pixmap * Framebuffer Object - OpenGL part of a Pixmap
****************************************************************************************/ ****************************************************************************************/
class cOglFb { class cOglFb
protected: {
protected:
bool initiated; bool initiated;
// GLuint fb; // GLuint fb;
// GLuint texture; // GLuint texture;
GLint width, height; GLint width, height;
GLint viewPortWidth, viewPortHeight; GLint viewPortWidth, viewPortHeight;
bool scrollable; bool scrollable;
public: public:
GLuint fb; GLuint fb;
GLuint texture; GLuint texture;
cOglFb(GLint width, GLint height, GLint viewPortWidth, GLint viewPortHeight); cOglFb(GLint width, GLint height, GLint viewPortWidth, GLint viewPortHeight);
virtual ~cOglFb(void); virtual ~ cOglFb(void);
bool Initiated(void) { return initiated; } bool Initiated(void)
{
return initiated;
}
virtual bool Init(void); virtual bool Init(void);
void Bind(void); void Bind(void);
void BindRead(void); void BindRead(void);
@ -182,27 +224,43 @@ public:
virtual void Unbind(void); virtual void Unbind(void);
bool BindTexture(void); bool BindTexture(void);
void Blit(GLint destX1, GLint destY1, GLint destX2, GLint destY2); void Blit(GLint destX1, GLint destY1, GLint destX2, GLint destY2);
GLint Width(void) { return width; }; GLint Width(void)
GLint Height(void) { return height; }; {
bool Scrollable(void) { return scrollable; }; return width;
GLint ViewportWidth(void) { return viewPortWidth; }; };
GLint ViewportHeight(void) { return viewPortHeight; }; GLint Height(void)
{
return height;
};
bool Scrollable(void)
{
return scrollable;
};
GLint ViewportWidth(void)
{
return viewPortWidth;
};
GLint ViewportHeight(void)
{
return viewPortHeight;
};
}; };
/**************************************************************************************** /****************************************************************************************
* cOglOutputFb * cOglOutputFb
* Output Framebuffer Object - holds Vdpau Output Surface which is our "output framebuffer" * Output Framebuffer Object - holds Vdpau Output Surface which is our "output framebuffer"
****************************************************************************************/ ****************************************************************************************/
class cOglOutputFb : public cOglFb { class cOglOutputFb:public cOglFb
protected: {
protected:
bool initiated; bool initiated;
private: private:
GLvdpauSurfaceNV surface; GLvdpauSurfaceNV surface;
public: public:
GLuint fb; GLuint fb;
GLuint texture; GLuint texture;
cOglOutputFb(GLint width, GLint height); cOglOutputFb(GLint width, GLint height);
virtual ~cOglOutputFb(void); virtual ~ cOglOutputFb(void);
virtual bool Init(void); virtual bool Init(void);
virtual void BindWrite(void); virtual void BindWrite(void);
virtual void Unbind(void); virtual void Unbind(void);
@ -212,7 +270,8 @@ public:
* cOglVb * cOglVb
* Vertex Buffer - OpenGl Vertices for the different drawing commands * Vertex Buffer - OpenGl Vertices for the different drawing commands
****************************************************************************************/ ****************************************************************************************/
enum eVertexBufferType { enum eVertexBufferType
{
vbRect, vbRect,
vbEllipse, vbEllipse,
vbSlope, vbSlope,
@ -221,8 +280,9 @@ enum eVertexBufferType {
vbCount vbCount
}; };
class cOglVb { class cOglVb
private: {
private:
eVertexBufferType type; eVertexBufferType type;
eShaderType shader; eShaderType shader;
GLuint vao; GLuint vao;
@ -231,9 +291,9 @@ private:
int sizeVertex2; int sizeVertex2;
int numVertices; int numVertices;
GLuint drawMode; GLuint drawMode;
public: public:
cOglVb(int type); cOglVb(int type);
virtual ~cOglVb(void); virtual ~ cOglVb(void);
bool Init(void); bool Init(void);
void Bind(void); void Bind(void);
void Unbind(void); void Unbind(void);
@ -243,184 +303,271 @@ public:
void SetShaderColor(GLint color); void SetShaderColor(GLint color);
void SetShaderAlpha(GLint alpha); void SetShaderAlpha(GLint alpha);
void SetShaderProjectionMatrix(GLint width, GLint height); 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); void DrawArrays(int count = 0);
}; };
/**************************************************************************************** /****************************************************************************************
* cOpenGLCmd * cOpenGLCmd
****************************************************************************************/ ****************************************************************************************/
class cOglCmd { class cOglCmd
protected: {
cOglFb *fb; protected:
public: cOglFb * fb;
cOglCmd(cOglFb *fb) { this->fb = fb; }; public:
virtual ~cOglCmd(void) {}; cOglCmd(cOglFb * fb)
virtual const char* Description(void) = 0; {
this->fb = fb;
};
virtual ~ cOglCmd(void)
{
};
virtual const char *Description(void) = 0;
virtual bool Execute(void) = 0; virtual bool Execute(void) = 0;
}; };
class cOglCmdInitOutputFb : public cOglCmd { class cOglCmdInitOutputFb:public cOglCmd
private: {
cOglOutputFb *oFb; private:
public: cOglOutputFb * oFb;
cOglCmdInitOutputFb(cOglOutputFb *oFb); public:
virtual ~cOglCmdInitOutputFb(void) {}; cOglCmdInitOutputFb(cOglOutputFb * oFb);
virtual const char* Description(void) { return "InitOutputFramebuffer"; } virtual ~ cOglCmdInitOutputFb(void)
{
};
virtual const char *Description(void)
{
return "InitOutputFramebuffer";
}
virtual bool Execute(void); virtual bool Execute(void);
}; };
class cOglCmdInitFb : public cOglCmd { class cOglCmdInitFb:public cOglCmd
private: {
cCondWait *wait; private:
public: cCondWait * wait;
cOglCmdInitFb(cOglFb *fb, cCondWait *wait = NULL); public:
virtual ~cOglCmdInitFb(void) {}; cOglCmdInitFb(cOglFb * fb, cCondWait * wait = NULL);
virtual const char* Description(void) { return "InitFramebuffer"; } virtual ~ cOglCmdInitFb(void)
{
};
virtual const char *Description(void)
{
return "InitFramebuffer";
}
virtual bool Execute(void); virtual bool Execute(void);
}; };
class cOglCmdDeleteFb : public cOglCmd { class cOglCmdDeleteFb:public cOglCmd
public: {
cOglCmdDeleteFb(cOglFb *fb); public:
virtual ~cOglCmdDeleteFb(void) {}; cOglCmdDeleteFb(cOglFb * fb);
virtual const char* Description(void) { return "DeleteFramebuffer"; } virtual ~ cOglCmdDeleteFb(void)
{
};
virtual const char *Description(void)
{
return "DeleteFramebuffer";
}
virtual bool Execute(void); virtual bool Execute(void);
}; };
class cOglCmdRenderFbToBufferFb : public cOglCmd { class cOglCmdRenderFbToBufferFb:public cOglCmd
private: {
cOglFb *buffer; private:
cOglFb * buffer;
GLfloat x, y; GLfloat x, y;
GLfloat drawPortX, drawPortY; GLfloat drawPortX, drawPortY;
GLint transparency; GLint transparency;
public: public:
cOglCmdRenderFbToBufferFb(cOglFb *fb, cOglFb *buffer, GLint x, GLint y, GLint transparency, GLint drawPortX, GLint drawPortY); cOglCmdRenderFbToBufferFb(cOglFb * fb, cOglFb * buffer, GLint x, GLint y, GLint transparency, GLint drawPortX,
virtual ~cOglCmdRenderFbToBufferFb(void) {}; GLint drawPortY);
virtual const char* Description(void) { return "Render Framebuffer to Buffer"; } virtual ~ cOglCmdRenderFbToBufferFb(void)
{
};
virtual const char *Description(void)
{
return "Render Framebuffer to Buffer";
}
virtual bool Execute(void); virtual bool Execute(void);
}; };
class cOglCmdCopyBufferToOutputFb : public cOglCmd { class cOglCmdCopyBufferToOutputFb:public cOglCmd
private: {
cOglOutputFb *oFb; private:
cOglOutputFb * oFb;
GLint x, y; GLint x, y;
public: public:
cOglCmdCopyBufferToOutputFb(cOglFb *fb, cOglOutputFb *oFb, GLint x, GLint y); cOglCmdCopyBufferToOutputFb(cOglFb * fb, cOglOutputFb * oFb, GLint x, GLint y);
virtual ~cOglCmdCopyBufferToOutputFb(void) {}; virtual ~ cOglCmdCopyBufferToOutputFb(void)
virtual const char* Description(void) { return "Copy buffer to OutputFramebuffer"; } {
};
virtual const char *Description(void)
{
return "Copy buffer to OutputFramebuffer";
}
virtual bool Execute(void); virtual bool Execute(void);
}; };
class cOglCmdFill : public cOglCmd { class cOglCmdFill:public cOglCmd
private: {
private:
GLint color; GLint color;
public: public:
cOglCmdFill(cOglFb *fb, GLint color); cOglCmdFill(cOglFb * fb, GLint color);
virtual ~cOglCmdFill(void) {}; virtual ~ cOglCmdFill(void)
virtual const char* Description(void) { return "Fill"; } {
};
virtual const char *Description(void)
{
return "Fill";
}
virtual bool Execute(void); virtual bool Execute(void);
}; };
class cOglCmdDrawRectangle : public cOglCmd { class cOglCmdDrawRectangle:public cOglCmd
private: {
private:
GLint x, y; GLint x, y;
GLint width, height; GLint width, height;
GLint color; GLint color;
public: public:
cOglCmdDrawRectangle(cOglFb *fb, GLint x, GLint y, GLint width, GLint height, GLint color); cOglCmdDrawRectangle(cOglFb * fb, GLint x, GLint y, GLint width, GLint height, GLint color);
virtual ~cOglCmdDrawRectangle(void) {}; virtual ~ cOglCmdDrawRectangle(void)
virtual const char* Description(void) { return "DrawRectangle"; } {
};
virtual const char *Description(void)
{
return "DrawRectangle";
}
virtual bool Execute(void); virtual bool Execute(void);
}; };
class cOglCmdDrawEllipse : public cOglCmd { class cOglCmdDrawEllipse:public cOglCmd
private: {
private:
GLint x, y; GLint x, y;
GLint width, height; GLint width, height;
GLint color; GLint color;
GLint quadrants; GLint quadrants;
GLfloat *CreateVerticesFull(int &numVertices); GLfloat *CreateVerticesFull(int &numVertices);
GLfloat *CreateVerticesQuadrant(int &numVertices); GLfloat *CreateVerticesQuadrant(int &numVertices);
GLfloat *CreateVerticesHalf(int &numVertices); GLfloat *CreateVerticesHalf(int &numVertices);
public: public:
cOglCmdDrawEllipse(cOglFb *fb, GLint x, GLint y, GLint width, GLint height, GLint color, GLint quadrants); cOglCmdDrawEllipse(cOglFb * fb, GLint x, GLint y, GLint width, GLint height, GLint color, GLint quadrants);
virtual ~cOglCmdDrawEllipse(void) {}; virtual ~ cOglCmdDrawEllipse(void)
virtual const char* Description(void) { return "DrawEllipse"; } {
};
virtual const char *Description(void)
{
return "DrawEllipse";
}
virtual bool Execute(void); virtual bool Execute(void);
}; };
class cOglCmdDrawSlope : public cOglCmd { class cOglCmdDrawSlope:public cOglCmd
private: {
private:
GLint x, y; GLint x, y;
GLint width, height; GLint width, height;
GLint color; GLint color;
GLint type; GLint type;
public: public:
cOglCmdDrawSlope(cOglFb *fb, GLint x, GLint y, GLint width, GLint height, GLint color, GLint type); cOglCmdDrawSlope(cOglFb * fb, GLint x, GLint y, GLint width, GLint height, GLint color, GLint type);
virtual ~cOglCmdDrawSlope(void) {}; virtual ~ cOglCmdDrawSlope(void)
virtual const char* Description(void) { return "DrawSlope"; } {
};
virtual const char *Description(void)
{
return "DrawSlope";
}
virtual bool Execute(void); virtual bool Execute(void);
}; };
class cOglCmdDrawText : public cOglCmd { class cOglCmdDrawText:public cOglCmd
private: {
private:
GLint x, y; GLint x, y;
GLint limitX; GLint limitX;
GLint colorText; GLint colorText;
cString fontName; cString fontName;
int fontSize; int fontSize;
unsigned int *symbols; unsigned int *symbols;
public: public:
cOglCmdDrawText(cOglFb *fb, GLint x, GLint y, unsigned int *symbols, GLint limitX, const char *name, int fontSize, tColor colorText); cOglCmdDrawText(cOglFb * fb, GLint x, GLint y, unsigned int *symbols, GLint limitX, const char *name,
virtual ~cOglCmdDrawText(void); int fontSize, tColor colorText);
virtual const char* Description(void) { return "DrawText"; } virtual ~ cOglCmdDrawText(void);
virtual const char *Description(void)
{
return "DrawText";
}
virtual bool Execute(void); virtual bool Execute(void);
}; };
class cOglCmdDrawImage : public cOglCmd { class cOglCmdDrawImage:public cOglCmd
private: {
tColor *argb; private:
tColor * argb;
GLint x, y, width, height; GLint x, y, width, height;
bool overlay; bool overlay;
GLfloat scaleX, scaleY; GLfloat scaleX, scaleY;
public: 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); cOglCmdDrawImage(cOglFb * fb, tColor * argb, GLint width, GLint height, GLint x, GLint y, bool overlay =
virtual ~cOglCmdDrawImage(void); true, double scaleX = 1.0f, double scaleY = 1.0f);
virtual const char* Description(void) { return "Draw Image"; } virtual ~ cOglCmdDrawImage(void);
virtual const char *Description(void)
{
return "Draw Image";
}
virtual bool Execute(void); virtual bool Execute(void);
}; };
class cOglCmdDrawTexture : public cOglCmd { class cOglCmdDrawTexture:public cOglCmd
private: {
sOglImage *imageRef; private:
sOglImage * imageRef;
GLint x, y; GLint x, y;
public: public:
cOglCmdDrawTexture(cOglFb *fb, sOglImage *imageRef, GLint x, GLint y); cOglCmdDrawTexture(cOglFb * fb, sOglImage * imageRef, GLint x, GLint y);
virtual ~cOglCmdDrawTexture(void) {}; virtual ~ cOglCmdDrawTexture(void)
virtual const char* Description(void) { return "Draw Texture"; } {
};
virtual const char *Description(void)
{
return "Draw Texture";
}
virtual bool Execute(void); virtual bool Execute(void);
}; };
class cOglCmdStoreImage : public cOglCmd { class cOglCmdStoreImage:public cOglCmd
private: {
sOglImage *imageRef; private:
sOglImage * imageRef;
tColor *data; tColor *data;
public: public:
cOglCmdStoreImage(sOglImage *imageRef, tColor *argb); cOglCmdStoreImage(sOglImage * imageRef, tColor * argb);
virtual ~cOglCmdStoreImage(void); virtual ~ cOglCmdStoreImage(void);
virtual const char* Description(void) { return "Store Image"; } virtual const char *Description(void)
{
return "Store Image";
}
virtual bool Execute(void); virtual bool Execute(void);
}; };
class cOglCmdDropImage : public cOglCmd { class cOglCmdDropImage:public cOglCmd
private: {
sOglImage *imageRef; private:
sOglImage * imageRef;
cCondWait *wait; cCondWait *wait;
public: public:
cOglCmdDropImage(sOglImage *imageRef, cCondWait *wait); cOglCmdDropImage(sOglImage * imageRef, cCondWait * wait);
virtual ~cOglCmdDropImage(void) {}; virtual ~ cOglCmdDropImage(void)
virtual const char* Description(void) { return "Drop Image"; } {
};
virtual const char *Description(void)
{
return "Drop Image";
}
virtual bool Execute(void); virtual bool Execute(void);
}; };
@ -430,12 +577,13 @@ public:
#define OGL_MAX_OSDIMAGES 256 #define OGL_MAX_OSDIMAGES 256
#define OGL_CMDQUEUE_SIZE 100 #define OGL_CMDQUEUE_SIZE 100
class cOglThread : public cThread { class cOglThread:public cThread
private: {
cCondWait *startWait; private:
cCondWait * startWait;
cCondWait *wait; cCondWait *wait;
bool stalled; bool stalled;
std::queue<cOglCmd*> commands; std::queue < cOglCmd * >commands;
GLint maxTextureSize; GLint maxTextureSize;
sOglImage imageCache[OGL_MAX_OSDIMAGES]; sOglImage imageCache[OGL_MAX_OSDIMAGES];
long memCached; long memCached;
@ -449,73 +597,96 @@ private:
void Cleanup(void); void Cleanup(void);
int GetFreeSlot(void); int GetFreeSlot(void);
void ClearSlot(int slot); void ClearSlot(int slot);
protected: protected:
virtual void Action(void); virtual void Action(void);
public: public:
cOglThread(cCondWait *startWait, int maxCacheSize); cOglThread(cCondWait * startWait, int maxCacheSize);
virtual ~cOglThread(); virtual ~ cOglThread();
void Stop(void); void Stop(void);
void DoCmd(cOglCmd* cmd); void DoCmd(cOglCmd * cmd);
int StoreImage(const cImage &image); int StoreImage(const cImage & image);
void DropImageData(int imageHandle); void DropImageData(int imageHandle);
sOglImage *GetImageRef(int slot); sOglImage *GetImageRef(int slot);
int MaxTextureSize(void) { return maxTextureSize; }; int MaxTextureSize(void)
{
return maxTextureSize;
};
}; };
/**************************************************************************************** /****************************************************************************************
* cOglPixmap * cOglPixmap
****************************************************************************************/ ****************************************************************************************/
class cOglPixmap : public cPixmap { class cOglPixmap:public cPixmap
private: {
cOglFb *fb; private:
std::shared_ptr<cOglThread> oglThread; cOglFb * fb;
std::shared_ptr < cOglThread > oglThread;
bool dirty; bool dirty;
public: public:
cOglPixmap(std::shared_ptr<cOglThread> oglThread, int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null); cOglPixmap(std::shared_ptr < cOglThread > oglThread, int Layer, const cRect & ViewPort, const cRect & DrawPort =
virtual ~cOglPixmap(void); cRect::Null);
cOglFb *Fb(void) { return fb; }; virtual ~ cOglPixmap(void);
int X(void) { return ViewPort().X(); }; cOglFb *Fb(void)
int Y(void) { return ViewPort().Y(); }; {
virtual bool IsDirty(void) { return dirty; } return fb;
virtual void SetDirty(bool dirty = true) { this->dirty = dirty; } };
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 SetAlpha(int Alpha);
virtual void SetTile(bool Tile); virtual void SetTile(bool Tile);
virtual void SetViewPort(const cRect &Rect); virtual void SetViewPort(const cRect & Rect);
virtual void SetDrawPortPoint(const cPoint &Point, bool Dirty = true); virtual void SetDrawPortPoint(const cPoint & Point, bool Dirty = true);
virtual void Clear(void); virtual void Clear(void);
virtual void Fill(tColor Color); virtual void Fill(tColor Color);
virtual void DrawImage(const cPoint &Point, const cImage &Image); virtual void DrawImage(const cPoint & Point, const cImage & Image);
virtual void DrawImage(const cPoint &Point, int ImageHandle); virtual void DrawImage(const cPoint & Point, int ImageHandle);
virtual void DrawPixel(const cPoint &Point, tColor Color); 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 DrawBitmap(const cPoint & Point, const cBitmap & Bitmap, tColor ColorFg = 0, tColor ColorBg =
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); 0, bool Overlay = false);
virtual void DrawRectangle(const cRect &Rect, tColor Color); virtual void DrawText(const cPoint & Point, const char *s, tColor ColorFg, tColor ColorBg, const cFont * Font,
virtual void DrawEllipse(const cRect &Rect, tColor Color, int Quadrants = 0); int Width = 0, int Height = 0, int Alignment = taDefault);
virtual void DrawSlope(const cRect &Rect, tColor Color, int Type); virtual void DrawRectangle(const cRect & Rect, tColor Color);
virtual void Render(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest); virtual void DrawEllipse(const cRect & Rect, tColor Color, int Quadrants = 0);
virtual void Copy(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest); virtual void DrawSlope(const cRect & Rect, tColor Color, int Type);
virtual void Scroll(const cPoint &Dest, const cRect &Source = cRect::Null); virtual void Render(const cPixmap * Pixmap, const cRect & Source, const cPoint & Dest);
virtual void Pan(const cPoint &Dest, const cRect &Source = cRect::Null); 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 * cOglOsd
******************************************************************************/ ******************************************************************************/
class cOglOsd : public cOsd { class cOglOsd:public cOsd
private: {
cOglFb *bFb; private:
std::shared_ptr<cOglThread> oglThread; cOglFb * bFb;
cVector<cOglPixmap *> oglPixmaps; std::shared_ptr < cOglThread > oglThread;
cVector < cOglPixmap * >oglPixmaps;
bool isSubtitleOsd; bool isSubtitleOsd;
protected: protected:
public: public:
cOglOsd(int Left, int Top, uint Level, std::shared_ptr<cOglThread> oglThread); cOglOsd(int Left, int Top, uint Level, std::shared_ptr < cOglThread > oglThread);
virtual ~cOglOsd(); virtual ~ cOglOsd();
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas); virtual eOsdError SetAreas(const tArea * Areas, int NumAreas);
virtual cPixmap *CreatePixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null); virtual cPixmap *CreatePixmap(int Layer, const cRect & ViewPort, const cRect & DrawPort = cRect::Null);
virtual void DestroyPixmap(cPixmap *Pixmap); virtual void DestroyPixmap(cPixmap * Pixmap);
virtual void Flush(void); 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; static cOglOutputFb *oFb;
}; };

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: VDR \n" "Project-Id-Version: VDR \n"
"Report-Msgid-Bugs-To: <see README>\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" "PO-Revision-Date: blabla\n"
"Last-Translator: blabla\n" "Last-Translator: blabla\n"
"Language-Team: blabla\n" "Language-Team: blabla\n"
@ -792,7 +792,13 @@ msgstr ""
msgid "[softhddev] ready%s\n" msgid "[softhddev] ready%s\n"
msgstr "" 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 "" msgstr ""
msgid "video/glx: no v-sync\n" msgid "video/glx: no v-sync\n"
@ -891,21 +897,6 @@ msgstr ""
msgid "Failed rendering frame!\n" msgid "Failed rendering frame!\n"
msgstr "" 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 #, c-format
msgid "video/vdpau: output buffer full, dropping frame (%d/%d)\n" msgid "video/vdpau: output buffer full, dropping frame (%d/%d)\n"
msgstr "" msgstr ""
@ -924,9 +915,6 @@ msgstr ""
msgid "video: decoder buffer empty, duping frame (%d/%d) %d v-buf\n" msgid "video: decoder buffer empty, duping frame (%d/%d) %d v-buf\n"
msgstr "" msgstr ""
msgid "Failed creating vulkan swapchain!"
msgstr ""
msgid "video: fatal i/o error\n" msgid "video: fatal i/o error\n"
msgstr "" msgstr ""
@ -934,12 +922,6 @@ msgstr ""
msgid "video/event: No symbol for %d\n" msgid "video/event: No symbol for %d\n"
msgstr "" msgstr ""
msgid "video: can't lock thread\n"
msgstr ""
msgid "video: can't unlock thread\n"
msgstr ""
msgid "Cant get memory for PLACEBO struct" msgid "Cant get memory for PLACEBO struct"
msgstr "" msgstr ""
@ -952,6 +934,9 @@ msgstr ""
msgid "Failed to create Vulkan Device" msgid "Failed to create Vulkan Device"
msgstr "" msgstr ""
msgid "Failed creating vulkan swapchain!"
msgstr ""
msgid "Failed initializing libplacebo renderer\n" msgid "Failed initializing libplacebo renderer\n"
msgstr "" 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 /// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as /// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the /// published by the Free Software Foundation, either version 3 of the
/// License. /// License.
/// ///
/// This program is distributed in the hope that it will be useful, /// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of /// 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 Affero General Public License for more details. /// 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> #include <stdio.h>
@ -36,15 +36,15 @@
/// ring buffer structure /// ring buffer structure
struct _ring_buffer_ struct _ring_buffer_
{ {
char *Buffer; ///< ring buffer data char *Buffer; ///< ring buffer data
const char *BufferEnd; ///< end of buffer const char *BufferEnd; ///< end of buffer
size_t Size; ///< bytes in buffer (for faster calc) size_t Size; ///< bytes in buffer (for faster calc)
const char *ReadPointer; ///< only used by reader const char *ReadPointer; ///< only used by reader
char *WritePointer; ///< only used by writer char *WritePointer; ///< only used by writer
/// The only thing modified by both /// 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; RingBuffer *rb;
if (!(rb = malloc(sizeof(*rb)))) { // allocate structure if (!(rb = malloc(sizeof(*rb)))) { // allocate structure
return rb; return rb;
} }
if (!(rb->Buffer = malloc(size))) { // allocate buffer if (!(rb->Buffer = malloc(size))) { // allocate buffer
free(rb); free(rb);
return NULL; return NULL;
} }
rb->Size = size; rb->Size = size;
@ -108,25 +108,25 @@ size_t RingBufferWriteAdvance(RingBuffer * rb, size_t cnt)
size_t n; size_t n;
n = rb->Size - atomic_read(&rb->Filled); n = rb->Size - atomic_read(&rb->Filled);
if (cnt > n) { // not enough space if (cnt > n) { // not enough space
cnt = n; cnt = n;
} }
// //
// Hitting end of buffer? // Hitting end of buffer?
// //
n = rb->BufferEnd - rb->WritePointer; n = rb->BufferEnd - rb->WritePointer;
if (n > cnt) { // don't cross the end if (n > cnt) { // don't cross the end
rb->WritePointer += cnt; rb->WritePointer += cnt;
} else { // reached or cross the end } else { // reached or cross the end
rb->WritePointer = rb->Buffer; rb->WritePointer = rb->Buffer;
if (n < cnt) { if (n < cnt) {
n = cnt - n; n = cnt - n;
rb->WritePointer += n; rb->WritePointer += n;
} }
} }
// //
// Only atomic modification! // Only atomic modification!
// //
atomic_add(cnt, &rb->Filled); atomic_add(cnt, &rb->Filled);
return cnt; return cnt;
@ -147,29 +147,29 @@ size_t RingBufferWrite(RingBuffer * rb, const void *buf, size_t cnt)
size_t n; size_t n;
n = rb->Size - atomic_read(&rb->Filled); n = rb->Size - atomic_read(&rb->Filled);
if (cnt > n) { // not enough space if (cnt > n) { // not enough space
cnt = n; cnt = n;
} }
// //
// Hitting end of buffer? // Hitting end of buffer?
// //
n = rb->BufferEnd - rb->WritePointer; n = rb->BufferEnd - rb->WritePointer;
if (n > cnt) { // don't cross the end if (n > cnt) { // don't cross the end
memcpy(rb->WritePointer, buf, cnt); memcpy(rb->WritePointer, buf, cnt);
rb->WritePointer += cnt; rb->WritePointer += cnt;
} else { // reached or cross the end } else { // reached or cross the end
memcpy(rb->WritePointer, buf, n); memcpy(rb->WritePointer, buf, n);
rb->WritePointer = rb->Buffer; rb->WritePointer = rb->Buffer;
if (n < cnt) { if (n < cnt) {
buf += n; buf += n;
n = cnt - n; n = cnt - n;
memcpy(rb->WritePointer, buf, n); memcpy(rb->WritePointer, buf, n);
rb->WritePointer += n; rb->WritePointer += n;
} }
} }
// //
// Only atomic modification! // Only atomic modification!
// //
atomic_add(cnt, &rb->Filled); atomic_add(cnt, &rb->Filled);
return cnt; return cnt;
@ -189,17 +189,17 @@ size_t RingBufferGetWritePointer(RingBuffer * rb, void **wp)
size_t n; size_t n;
size_t cnt; size_t cnt;
// Total free bytes available in ring buffer // Total free bytes available in ring buffer
cnt = rb->Size - atomic_read(&rb->Filled); cnt = rb->Size - atomic_read(&rb->Filled);
*wp = rb->WritePointer; *wp = rb->WritePointer;
// //
// Hitting end of buffer? // Hitting end of buffer?
// //
n = rb->BufferEnd - rb->WritePointer; n = rb->BufferEnd - rb->WritePointer;
if (n <= cnt) { // reached or cross the end if (n <= cnt) { // reached or cross the end
return n; return n;
} }
return cnt; return cnt;
} }
@ -217,25 +217,25 @@ size_t RingBufferReadAdvance(RingBuffer * rb, size_t cnt)
size_t n; size_t n;
n = atomic_read(&rb->Filled); n = atomic_read(&rb->Filled);
if (cnt > n) { // not enough filled if (cnt > n) { // not enough filled
cnt = n; cnt = n;
} }
// //
// Hitting end of buffer? // Hitting end of buffer?
// //
n = rb->BufferEnd - rb->ReadPointer; n = rb->BufferEnd - rb->ReadPointer;
if (n > cnt) { // don't cross the end if (n > cnt) { // don't cross the end
rb->ReadPointer += cnt; rb->ReadPointer += cnt;
} else { // reached or cross the end } else { // reached or cross the end
rb->ReadPointer = rb->Buffer; rb->ReadPointer = rb->Buffer;
if (n < cnt) { if (n < cnt) {
n = cnt - n; n = cnt - n;
rb->ReadPointer += n; rb->ReadPointer += n;
} }
} }
// //
// Only atomic modification! // Only atomic modification!
// //
atomic_sub(cnt, &rb->Filled); atomic_sub(cnt, &rb->Filled);
return cnt; return cnt;
@ -255,29 +255,29 @@ size_t RingBufferRead(RingBuffer * rb, void *buf, size_t cnt)
size_t n; size_t n;
n = atomic_read(&rb->Filled); n = atomic_read(&rb->Filled);
if (cnt > n) { // not enough filled if (cnt > n) { // not enough filled
cnt = n; cnt = n;
} }
// //
// Hitting end of buffer? // Hitting end of buffer?
// //
n = rb->BufferEnd - rb->ReadPointer; n = rb->BufferEnd - rb->ReadPointer;
if (n > cnt) { // don't cross the end if (n > cnt) { // don't cross the end
memcpy(buf, rb->ReadPointer, cnt); memcpy(buf, rb->ReadPointer, cnt);
rb->ReadPointer += cnt; rb->ReadPointer += cnt;
} else { // reached or cross the end } else { // reached or cross the end
memcpy(buf, rb->ReadPointer, n); memcpy(buf, rb->ReadPointer, n);
rb->ReadPointer = rb->Buffer; rb->ReadPointer = rb->Buffer;
if (n < cnt) { if (n < cnt) {
buf += n; buf += n;
n = cnt - n; n = cnt - n;
memcpy(buf, rb->ReadPointer, n); memcpy(buf, rb->ReadPointer, n);
rb->ReadPointer += n; rb->ReadPointer += n;
} }
} }
// //
// Only atomic modification! // Only atomic modification!
// //
atomic_sub(cnt, &rb->Filled); atomic_sub(cnt, &rb->Filled);
return cnt; return cnt;
@ -297,17 +297,17 @@ size_t RingBufferGetReadPointer(RingBuffer * rb, const void **rp)
size_t n; size_t n;
size_t cnt; size_t cnt;
// Total used bytes in ring buffer // Total used bytes in ring buffer
cnt = atomic_read(&rb->Filled); cnt = atomic_read(&rb->Filled);
*rp = rb->ReadPointer; *rp = rb->ReadPointer;
// //
// Hitting end of buffer? // Hitting end of buffer?
// //
n = rb->BufferEnd - rb->ReadPointer; n = rb->BufferEnd - rb->ReadPointer;
if (n <= cnt) { // reached or cross the end if (n <= cnt) { // reached or cross the end
return n; return n;
} }
return cnt; 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 /// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as /// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the /// published by the Free Software Foundation, either version 3 of the
/// License. /// License.
/// ///
/// This program is distributed in the hope that it will be useful, /// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of /// 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 Affero General Public License for more details. /// GNU Affero General Public License for more details.
/// ///
/// $Id: 8a2b4c171f1024afb8b8a7a7add631b7ebe2d45e $ /// $Id: 8a2b4c171f1024afb8b8a7a7add631b7ebe2d45e $
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ringbuffer /// @addtogroup Ringbuffer

932
shaders.h
View File

@ -1,465 +1,467 @@
// shader // shader
#ifdef CUVID #ifdef CUVID
char vertex_osd[] = {"\ char vertex_osd[] = { "\
#version 330\n\ #version 330\n\
in vec2 vertex_position;\n\ in vec2 vertex_position;\n\
in vec2 vertex_texcoord0;\n\ in vec2 vertex_texcoord0;\n\
out vec2 texcoord0;\n\ out vec2 texcoord0;\n\
void main() {\n\ void main() {\n\
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\ gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
texcoord0 = vertex_texcoord0;\n\ texcoord0 = vertex_texcoord0;\n\
}\n"}; }\n" };
char fragment_osd[] = {"\ char fragment_osd[] = { "\
#version 330\n\ #version 330\n\
#define texture1D texture\n\ #define texture1D texture\n\
precision mediump float; \ precision mediump float; \
layout(location = 0) out vec4 out_color;\n\ layout(location = 0) out vec4 out_color;\n\
in vec2 texcoord0;\n\ in vec2 texcoord0;\n\
uniform sampler2D texture0;\n\ uniform sampler2D texture0;\n\
void main() {\n\ void main() {\n\
vec4 color; \n\ vec4 color; \n\
color = vec4(texture(texture0, texcoord0));\n\ color = vec4(texture(texture0, texcoord0));\n\
out_color = color;\n\ out_color = color;\n\
}\n"}; }\n" };
char vertex[] = {"\ char vertex[] = { "\
#version 310 es\n\ #version 310 es\n\
in vec2 vertex_position;\n\ in vec2 vertex_position;\n\
in vec2 vertex_texcoord0;\n\ in vec2 vertex_texcoord0;\n\
out vec2 texcoord0;\n\ out vec2 texcoord0;\n\
in vec2 vertex_texcoord1;\n\ in vec2 vertex_texcoord1;\n\
out vec2 texcoord1;\n\ out vec2 texcoord1;\n\
void main() {\n\ void main() {\n\
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\ gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
texcoord0 = vertex_texcoord0;\n\ texcoord0 = vertex_texcoord0;\n\
texcoord1 = vertex_texcoord1;\n\ texcoord1 = vertex_texcoord1;\n\
}\n"}; }\n" };
char fragment[] = {"\ char fragment[] = { "\
#version 310 es\n\ #version 310 es\n\
#define texture1D texture\n\ #define texture1D texture\n\
#define texture3D texture\n\ #define texture3D texture\n\
precision mediump float; \ precision mediump float; \
layout(location = 0) out vec4 out_color;\n\ layout(location = 0) out vec4 out_color;\n\
in vec2 texcoord0;\n\ in vec2 texcoord0;\n\
in vec2 texcoord1;\n\ in vec2 texcoord1;\n\
uniform mat3 colormatrix;\n\ uniform mat3 colormatrix;\n\
uniform vec3 colormatrix_c;\n\ uniform vec3 colormatrix_c;\n\
uniform sampler2D texture0;\n\ uniform sampler2D texture0;\n\
uniform sampler2D texture1;\n\ uniform sampler2D texture1;\n\
void main() {\n\ void main() {\n\
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\ vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r;\n\ color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r;\n\
color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg;\n\ color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg;\n\
// color conversion\n\ // color conversion\n\
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\ color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\
color.a = 1.0;\n\ color.a = 1.0;\n\
// color mapping\n\ // color mapping\n\
out_color = color;\n\ out_color = color;\n\
}\n"}; }\n" };
char fragment_bt2100[] = {"\ char fragment_bt2100[] = { "\
#version 310 es\n \ #version 310 es\n \
#define texture1D texture\n\ #define texture1D texture\n\
#define texture3D texture\n\ #define texture3D texture\n\
precision mediump float; \ precision mediump float; \
layout(location = 0) out vec4 out_color;\n\ layout(location = 0) out vec4 out_color;\n\
in vec2 texcoord0;\n\ in vec2 texcoord0;\n\
in vec2 texcoord1;\n\ in vec2 texcoord1;\n\
uniform mat3 colormatrix;\n\ uniform mat3 colormatrix;\n\
uniform vec3 colormatrix_c;\n\ uniform vec3 colormatrix_c;\n\
uniform mat3 cms_matrix;\n\ uniform mat3 cms_matrix;\n\
uniform sampler2D texture0;\n\ uniform sampler2D texture0;\n\
uniform sampler2D texture1;\n\ uniform sampler2D texture1;\n\
//#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))\n\ //#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))\n\
void main() {\n\ void main() {\n\
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\ vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
color.r = 1.003906 * vec4(texture(texture0, texcoord0)).r;\n\ color.r = 1.003906 * vec4(texture(texture0, texcoord0)).r;\n\
color.gb = 1.003906 * vec4(texture(texture1, texcoord1)).rg;\n\ color.gb = 1.003906 * vec4(texture(texture1, texcoord1)).rg;\n\
// color conversion\n\ // color conversion\n\
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\ color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\
color.a = 1.0;\n\ color.a = 1.0;\n\
// color mapping\n\ // color mapping\n\
color.rgb = clamp(color.rgb, 0.0, 1.0);\n\ color.rgb = clamp(color.rgb, 0.0, 1.0);\n\
color.rgb = pow(color.rgb, vec3(2.4));\n\ color.rgb = pow(color.rgb, vec3(2.4));\n\
color.rgb = cms_matrix * color.rgb;\n\ color.rgb = cms_matrix * color.rgb;\n\
color.rgb = clamp(color.rgb, 0.0, 1.0);\n\ color.rgb = clamp(color.rgb, 0.0, 1.0);\n\
color.rgb = pow(color.rgb, vec3(1.0/2.4));\n\ color.rgb = pow(color.rgb, vec3(1.0/2.4));\n\
out_color = color;\n\ out_color = color;\n\
}\n"}; }\n" };
#else
#else char vertex_osd[] = { "\
char vertex_osd[] = {"\ \n\
\n\ in vec2 vertex_position;\n\
in vec2 vertex_position;\n\ in vec2 vertex_texcoord0;\n\
in vec2 vertex_texcoord0;\n\ out vec2 texcoord0;\n\
out vec2 texcoord0;\n\ void main() {\n\
void main() {\n\ gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\ texcoord0 = vertex_texcoord0;\n\
texcoord0 = vertex_texcoord0;\n\ }\n" };
}\n"};
char fragment_osd[] = { "\
char fragment_osd[] = {"\ \n\
\n\ #define texture1D texture\n\
#define texture1D texture\n\ precision mediump float; \
precision mediump float; \ layout(location = 0) out vec4 out_color;\n\
layout(location = 0) out vec4 out_color;\n\ in vec2 texcoord0;\n\
in vec2 texcoord0;\n\ uniform sampler2D texture0;\n\
uniform sampler2D texture0;\n\ void main() {\n\
void main() {\n\ vec4 color; \n\
vec4 color; \n\ color = vec4(texture(texture0, texcoord0));\n\
color = vec4(texture(texture0, texcoord0));\n\ out_color = color;\n\
out_color = color;\n\ }\n" };
}\n"};
char vertex[] = { "\
char vertex[] = {"\ \n\
\n\ in vec2 vertex_position;\n\
in vec2 vertex_position;\n\ in vec2 vertex_texcoord0;\n\
in vec2 vertex_texcoord0;\n\ out vec2 texcoord0;\n\
out vec2 texcoord0;\n\ in vec2 vertex_texcoord1;\n\
in vec2 vertex_texcoord1;\n\ out vec2 texcoord1;\n\
out vec2 texcoord1;\n\ void main() {\n\
void main() {\n\ gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\ texcoord0 = vertex_texcoord0;\n\
texcoord0 = vertex_texcoord0;\n\ texcoord1 = vertex_texcoord1;\n\
texcoord1 = vertex_texcoord1;\n\ }\n" };
}\n"};
char fragment[] = { "\
char fragment[] = {"\ \n\
\n\ #define texture1D texture\n\
#define texture1D texture\n\ #define texture3D texture\n\
#define texture3D texture\n\ precision mediump float; \
precision mediump float; \ layout(location = 0) out vec4 out_color;\n\
layout(location = 0) out vec4 out_color;\n\ in vec2 texcoord0;\n\
in vec2 texcoord0;\n\ in vec2 texcoord1;\n\
in vec2 texcoord1;\n\ uniform mat3 colormatrix;\n\
uniform mat3 colormatrix;\n\ uniform vec3 colormatrix_c;\n\
uniform vec3 colormatrix_c;\n\ uniform sampler2D texture0;\n\
uniform sampler2D texture0;\n\ uniform sampler2D texture1;\n\
uniform sampler2D texture1;\n\ //#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))\n\
//#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))\n\ void main() {\n\
void main() {\n\ vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\ color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r;\n\
color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r;\n\ color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg;\n\
color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg;\n\ // color conversion\n\
// color conversion\n\ color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\ color.a = 1.0;\n\
color.a = 1.0;\n\ // color mapping\n\
// color mapping\n\ out_color = color;\n\
out_color = color;\n\ }\n" };
}\n"};
char fragment_bt2100[] = { "\
char fragment_bt2100[] = {"\ \n \
\n \ #define texture1D texture\n\
#define texture1D texture\n\ #define texture3D texture\n\
#define texture3D texture\n\ precision mediump float; \
precision mediump float; \ layout(location = 0) out vec4 out_color;\n\
layout(location = 0) out vec4 out_color;\n\ in vec2 texcoord0;\n\
in vec2 texcoord0;\n\ in vec2 texcoord1;\n\
in vec2 texcoord1;\n\ uniform mat3 colormatrix;\n\
uniform mat3 colormatrix;\n\ uniform vec3 colormatrix_c;\n\
uniform vec3 colormatrix_c;\n\ uniform mat3 cms_matrix;\n\
uniform mat3 cms_matrix;\n\ uniform sampler2D texture0;\n\
uniform sampler2D texture0;\n\ uniform sampler2D texture1;\n\
uniform sampler2D texture1;\n\ //#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))\n\
//#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))\n\ void main() {\n\
void main() {\n\ vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\ color.r = 1.003906 * vec4(texture(texture0, texcoord0)).r;\n\
color.r = 1.003906 * vec4(texture(texture0, texcoord0)).r;\n\ color.gb = 1.003906 * vec4(texture(texture1, texcoord1)).rg;\n\
color.gb = 1.003906 * vec4(texture(texture1, texcoord1)).rg;\n\ // color conversion\n\
// color conversion\n\ color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\ color.a = 1.0;\n\
color.a = 1.0;\n\ // color mapping\n\
// color mapping\n\ color.rgb = clamp(color.rgb, 0.0, 1.0);\n\
color.rgb = clamp(color.rgb, 0.0, 1.0);\n\ color.rgb = pow(color.rgb, vec3(2.4));\n\
color.rgb = pow(color.rgb, vec3(2.4));\n\ color.rgb = cms_matrix * color.rgb;\n\
color.rgb = cms_matrix * color.rgb;\n\ color.rgb = clamp(color.rgb, 0.0, 1.0);\n\
color.rgb = clamp(color.rgb, 0.0, 1.0);\n\ color.rgb = pow(color.rgb, vec3(1.0/2.4));\n\
color.rgb = pow(color.rgb, vec3(1.0/2.4));\n\ out_color = color;\n\
out_color = color;\n\ }\n" };
}\n"}; #endif
#endif
/* Color conversion matrix: RGB = m * YUV + c /* Color conversion matrix: RGB = m * YUV + c
* m is in row-major matrix, with m[row][col], e.g.: * m is in row-major matrix, with m[row][col], e.g.:
* [ a11 a12 a13 ] float m[3][3] = { { a11, a12, a13 }, * [ a11 a12 a13 ] float m[3][3] = { { a11, a12, a13 },
* [ a21 a22 a23 ] { a21, a22, a23 }, * [ a21 a22 a23 ] { a21, a22, a23 },
* [ a31 a32 a33 ] { a31, a32, a33 } }; * [ a31 a32 a33 ] { a31, a32, a33 } };
* This is accessed as e.g.: m[2-1][1-1] = a21 * 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, * 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: * while each column contains all the coefficients for one of Y, U, V:
* m[r,g,b][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 * 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. * 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. * The matrix might also be used for other conversions and colorspaces.
*/ */
struct mp_cmat { struct mp_cmat
GLfloat m[3][3]; // colormatrix {
GLfloat c[3]; //colormatrix_c GLfloat m[3][3]; // colormatrix
}; GLfloat c[3]; //colormatrix_c
};
struct mp_mat {
GLfloat m[3][3]; 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 = {\ // YUV input limited range (16-235 for luma, 16-240 for chroma)
{{ 1.164384, 1.164384, 1.164384 },\ // ITU-R BT.601 (SD)
{ 0.00000, -0.391762, 2.017232 },\ struct mp_cmat yuv_bt601 = { {{1.164384, 1.164384, 1.164384},
{ 1.596027, -0.812968 , 0.000000 }},\ {0.00000, -0.391762, 2.017232},
{-0.874202, 0.531668, -1.085631 } }; {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 },\ // ITU-R BT.709 (HD)
{ 0.00000, -0.213249, 2.112402 },\ struct mp_cmat yuv_bt709 = { {{1.164384, 1.164384, 1.164384},
{ 1.792741, -0.532909 , 0.000000 }},\ {0.00000, -0.213249, 2.112402},
{-0.972945, 0.301483, -1.133402 } }; {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 },\ // ITU-R BT.2020 non-constant luminance system
{ 0.00000, -0.187326, 2.141772 },\ struct mp_cmat yuv_bt2020ncl = { {{1.164384, 1.164384, 1.164384},
{ 1.678674, -0.650424 , 0.000000 }},\ {0.00000, -0.187326, 2.141772},
{-0.915688, 0.347459, -1.148145 } }; {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 },\ // ITU-R BT.2020 constant luminance system
{ 0.00000, 0.000000, 1.138393 },\ struct mp_cmat yuv_bt2020cl = { {{0.0000, 1.164384, 0.000000},
{ 1.138393, 0.000000 , 0.000000 }},\ {0.00000, 0.000000, 1.138393},
{-0.571429, -0.073059, -0.571429 } }; {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},\ float cms_matrix[3][3] = { {1.660497, -0.124547, -0.018154},
{-0.072840, -0.008348, 1.118751}}; {-0.587657, 1.132895, -0.100597},
{-0.072840, -0.008348, 1.118751}
struct gl_vao_entry { };
// used for shader / glBindAttribLocation
const char *name; struct gl_vao_entry
// glVertexAttribPointer() arguments {
int num_elems; // size (number of elements) // used for shader / glBindAttribLocation
GLenum type; const char *name;
bool normalized; // glVertexAttribPointer() arguments
int offset; int num_elems; // size (number of elements)
}; GLenum type;
bool normalized;
struct vertex_pt { int offset;
float x, y; };
};
struct vertex_pt
struct vertex_pi { {
GLint x, y; float x, y;
}; };
#define TEXUNIT_VIDEO_NUM 6 struct vertex_pi
{
GLint x, y;
struct vertex { };
struct vertex_pt position;
struct vertex_pt texcoord[TEXUNIT_VIDEO_NUM]; #define TEXUNIT_VIDEO_NUM 6
};
struct vertex
static const struct gl_vao_entry vertex_vao[] = { {
{"position", 2, GL_FLOAT, false, offsetof(struct vertex, position)}, struct vertex_pt position;
{"texcoord0", 2, GL_FLOAT, false, offsetof(struct vertex, texcoord[0])}, struct vertex_pt texcoord[TEXUNIT_VIDEO_NUM];
{"texcoord1", 2, GL_FLOAT, false, offsetof(struct vertex, texcoord[1])}, };
{0}
}; 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])},
static void compile_attach_shader(GLuint program, {"texcoord1", 2, GL_FLOAT, false, offsetof(struct vertex, texcoord[1])},
GLenum type, const char *source) {0}
{ };
GLuint shader;
GLint status, log_length; static void compile_attach_shader(GLuint program, GLenum type, const char *source)
char log[4000]; {
GLsizei len; GLuint shader;
shader = glCreateShader(type); GLint status, log_length;
glShaderSource(shader, 1, &source, NULL); char log[4000];
glCompileShader(shader); GLsizei len;
status = 0;
glGetShaderiv(shader, GL_COMPILE_STATUS, &status); shader = glCreateShader(type);
log_length = 0; glShaderSource(shader, 1, &source, NULL);
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_length); glCompileShader(shader);
glGetShaderInfoLog(shader,4000,&len,log); status = 0;
GlxCheck(); glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
Debug(3,"compile Status %d loglen %d >%s<\n",status,log_length,log); log_length = 0;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_length);
glAttachShader(program, shader); glGetShaderInfoLog(shader, 4000, &len, log);
glDeleteShader(shader); GlxCheck();
} Debug(3, "compile Status %d loglen %d >%s<\n", status, log_length, log);
static void link_shader(GLuint program) glAttachShader(program, shader);
{ glDeleteShader(shader);
GLint status,log_length; }
glLinkProgram(program); static void link_shader(GLuint program)
status = 0; {
glGetProgramiv(program, GL_LINK_STATUS, &status); GLint status, log_length;
log_length = 0;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &log_length); glLinkProgram(program);
Debug(3,"Link Status %d loglen %d\n",status,log_length); status = 0;
} glGetProgramiv(program, GL_LINK_STATUS, &status);
log_length = 0;
static GLuint sc_generate_osd(GLuint gl_prog) { glGetProgramiv(program, GL_INFO_LOG_LENGTH, &log_length);
Debug(3, "Link Status %d loglen %d\n", status, log_length);
Debug(3,"vor create osd\n"); }
gl_prog = glCreateProgram();
Debug(3,"vor compile vertex osd\n"); static GLuint sc_generate_osd(GLuint gl_prog)
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); Debug(3, "vor create osd\n");
glBindAttribLocation(gl_prog,0,"vertex_position"); gl_prog = glCreateProgram();
glBindAttribLocation(gl_prog,1,"vertex_texcoord0"); Debug(3, "vor compile vertex osd\n");
compile_attach_shader(gl_prog, GL_VERTEX_SHADER, vertex_osd);
link_shader(gl_prog); Debug(3, "vor compile fragment osd \n");
return gl_prog; compile_attach_shader(gl_prog, GL_FRAGMENT_SHADER, fragment_osd);
} glBindAttribLocation(gl_prog, 0, "vertex_position");
glBindAttribLocation(gl_prog, 1, "vertex_texcoord0");
static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace) { link_shader(gl_prog);
return gl_prog;
char vname[80]; }
int n;
GLint cmsLoc; static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace)
float *m,*c,*cms; {
char *frag;
char vname[80];
switch (colorspace) { int n;
case AVCOL_SPC_RGB: GLint cmsLoc;
m = &yuv_bt601.m[0][0]; float *m, *c, *cms;
c = &yuv_bt601.c[0]; char *frag;
frag = fragment;
Debug(3,"BT601 Colorspace used\n"); switch (colorspace) {
break; case AVCOL_SPC_RGB:
case AVCOL_SPC_BT709: m = &yuv_bt601.m[0][0];
case AVCOL_SPC_UNSPECIFIED: // comes with UHD c = &yuv_bt601.c[0];
m = &yuv_bt709.m[0][0]; frag = fragment;
c = &yuv_bt709.c[0]; Debug(3, "BT601 Colorspace used\n");
frag = fragment; break;
Debug(3,"BT709 Colorspace used\n"); case AVCOL_SPC_BT709:
break; case AVCOL_SPC_UNSPECIFIED: // comes with UHD
case AVCOL_SPC_BT2020_NCL: m = &yuv_bt709.m[0][0];
m = &yuv_bt2020ncl.m[0][0]; c = &yuv_bt709.c[0];
c = &yuv_bt2020ncl.c[0]; frag = fragment;
cms = &cms_matrix[0][0]; Debug(3, "BT709 Colorspace used\n");
frag = fragment_bt2100; break;
Debug(3,"BT2020NCL Colorspace used\n"); case AVCOL_SPC_BT2020_NCL:
break; m = &yuv_bt2020ncl.m[0][0];
default: // fallback c = &yuv_bt2020ncl.c[0];
m = &yuv_bt709.m[0][0]; cms = &cms_matrix[0][0];
c = &yuv_bt709.c[0]; frag = fragment_bt2100;
frag = fragment; Debug(3, "BT2020NCL Colorspace used\n");
Debug(3,"default BT709 Colorspace used %d\n",colorspace); break;
break; default: // fallback
} m = &yuv_bt709.m[0][0];
c = &yuv_bt709.c[0];
Debug(3,"vor create\n"); frag = fragment;
gl_prog = glCreateProgram(); Debug(3, "default BT709 Colorspace used %d\n", colorspace);
Debug(3,"vor compile vertex\n"); break;
compile_attach_shader(gl_prog, GL_VERTEX_SHADER, vertex); }
Debug(3,"vor compile fragment\n");
compile_attach_shader(gl_prog, GL_FRAGMENT_SHADER, frag); Debug(3, "vor create\n");
glBindAttribLocation(gl_prog,0,"vertex_position"); gl_prog = glCreateProgram();
Debug(3, "vor compile vertex\n");
for (n=0;n<6;n++) { compile_attach_shader(gl_prog, GL_VERTEX_SHADER, vertex);
sprintf(vname,"vertex_texcoord%1d",n); Debug(3, "vor compile fragment\n");
glBindAttribLocation(gl_prog,n+1,vname); compile_attach_shader(gl_prog, GL_FRAGMENT_SHADER, frag);
} glBindAttribLocation(gl_prog, 0, "vertex_position");
link_shader(gl_prog); for (n = 0; n < 6; n++) {
sprintf(vname, "vertex_texcoord%1d", n);
gl_colormatrix = glGetUniformLocation(gl_prog,"colormatrix"); glBindAttribLocation(gl_prog, n + 1, vname);
Debug(3,"get uniform colormatrix %d \n",gl_colormatrix); }
if (gl_colormatrix != -1)
glProgramUniformMatrix3fv(gl_prog,gl_colormatrix,1,0,m); link_shader(gl_prog);
GlxCheck();
Debug(3,"nach set colormatrix\n"); gl_colormatrix = glGetUniformLocation(gl_prog, "colormatrix");
Debug(3, "get uniform colormatrix %d \n", gl_colormatrix);
gl_colormatrix_c = glGetUniformLocation(gl_prog,"colormatrix_c"); if (gl_colormatrix != -1)
Debug(3,"get uniform colormatrix_c %d %f\n",gl_colormatrix_c,*c); glProgramUniformMatrix3fv(gl_prog, gl_colormatrix, 1, 0, m);
if (gl_colormatrix_c != -1) GlxCheck();
glProgramUniform3fv(gl_prog,gl_colormatrix_c,1,c); Debug(3, "nach set colormatrix\n");
GlxCheck();
gl_colormatrix_c = glGetUniformLocation(gl_prog, "colormatrix_c");
if (colorspace == AVCOL_SPC_BT2020_NCL) { Debug(3, "get uniform colormatrix_c %d %f\n", gl_colormatrix_c, *c);
cmsLoc = glGetUniformLocation(gl_prog,"cms_matrix"); if (gl_colormatrix_c != -1)
if (cmsLoc != -1) glProgramUniform3fv(gl_prog, gl_colormatrix_c, 1, c);
glProgramUniformMatrix3fv(gl_prog,cmsLoc,1,0,cms); GlxCheck();
GlxCheck();
} if (colorspace == AVCOL_SPC_BT2020_NCL) {
cmsLoc = glGetUniformLocation(gl_prog, "cms_matrix");
return gl_prog; if (cmsLoc != -1)
} glProgramUniformMatrix3fv(gl_prog, cmsLoc, 1, 0, cms);
GlxCheck();
static void render_pass_quad(int flip, float xcrop, float ycrop) }
{
struct vertex va[4]; return gl_prog;
int n; }
const struct gl_vao_entry *e;
// uhhhh what a hack static void render_pass_quad(int flip, float xcrop, float ycrop)
if (!flip ) { {
va[0].position.x = (float) -1.0; struct vertex va[4];
va[0].position.y = (float) 1.0; int n;
va[1].position.x = (float) -1.0; const struct gl_vao_entry *e;
va[1].position.y = (float) -1.0;
va[2].position.x = (float) 1.0; // uhhhh what a hack
va[2].position.y = (float) 1.0; if (!flip) {
va[3].position.x = (float) 1.0; va[0].position.x = (float)-1.0;
va[3].position.y = (float) -1.0; va[0].position.y = (float)1.0;
} else { va[1].position.x = (float)-1.0;
va[0].position.x = (float) -1.0; va[1].position.y = (float)-1.0;
va[0].position.y = (float) -1.0; va[2].position.x = (float)1.0;
va[1].position.x = (float) -1.0; va[2].position.y = (float)1.0;
va[1].position.y = (float) 1.0; va[3].position.x = (float)1.0;
va[2].position.x = (float) 1.0; va[3].position.y = (float)-1.0;
va[2].position.y = (float) -1.0; } else {
va[3].position.x = (float) 1.0; va[0].position.x = (float)-1.0;
va[3].position.y = (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[0].texcoord[0].x = (float) 0.0 + xcrop; va[2].position.x = (float)1.0;
va[0].texcoord[0].y = (float) 0.0 + ycrop; // abgeschnitten von links oben va[2].position.y = (float)-1.0;
va[0].texcoord[1].x = (float) 0.0 + xcrop; va[3].position.x = (float)1.0;
va[0].texcoord[1].y = (float) 0.0 + ycrop; // abgeschnitten von links oben va[3].position.y = (float)1.0;
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[0].texcoord[0].x = (float)0.0 + xcrop;
va[1].texcoord[1].y = (float) 1.0 - ycrop; // abgeschnitten links unten 1.0 - Wert va[0].texcoord[0].y = (float)0.0 + ycrop; // abgeschnitten von links oben
va[2].texcoord[0].x = (float) 1.0 - xcrop; va[0].texcoord[1].x = (float)0.0 + xcrop;
va[2].texcoord[0].y = (float) 0.0 + ycrop; // abgeschnitten von rechts oben va[0].texcoord[1].y = (float)0.0 + ycrop; // abgeschnitten von links oben
va[2].texcoord[1].x = (float) 1.0 - xcrop; va[1].texcoord[0].x = (float)0.0 + xcrop;
va[2].texcoord[1].y = (float) 0.0 + ycrop; // abgeschnitten von rechts oben va[1].texcoord[0].y = (float)1.0 - ycrop; // abgeschnitten links unten 1.0 - Wert
va[3].texcoord[0].x = (float) 1.0 - xcrop; va[1].texcoord[1].x = (float)0.0 + xcrop;
va[3].texcoord[0].y = (float) 1.0 - ycrop; // abgeschnitten von rechts unten 1.0 - wert va[1].texcoord[1].y = (float)1.0 - ycrop; // abgeschnitten links unten 1.0 - Wert
va[3].texcoord[1].x = (float) 1.0 - xcrop; va[2].texcoord[0].x = (float)1.0 - xcrop;
va[3].texcoord[1].y = (float) 1.0 - ycrop; // abgeschnitten von rechts unten 1.0 - wert 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;
glBindBuffer(GL_ARRAY_BUFFER, vao_buffer); va[3].texcoord[0].y = (float)1.0 - ycrop; // abgeschnitten von rechts unten 1.0 - wert
glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(struct vertex), va, GL_DYNAMIC_DRAW); va[3].texcoord[1].x = (float)1.0 - xcrop;
glBindBuffer(GL_ARRAY_BUFFER, 0); va[3].texcoord[1].y = (float)1.0 - ycrop; // abgeschnitten von rechts unten 1.0 - wert
// enable attribs glBindBuffer(GL_ARRAY_BUFFER, vao_buffer);
glBindBuffer(GL_ARRAY_BUFFER, vao_buffer); glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(struct vertex), va, GL_DYNAMIC_DRAW);
for ( n = 0; vertex_vao[n].name; n++) { glBindBuffer(GL_ARRAY_BUFFER, 0);
e = &vertex_vao[n];
glEnableVertexAttribArray(n); // enable attribs
glVertexAttribPointer(n, e->num_elems, e->type, e->normalized, glBindBuffer(GL_ARRAY_BUFFER, vao_buffer);
sizeof(struct vertex), (void *)(intptr_t)e->offset); for (n = 0; vertex_vao[n].name; n++) {
} e = &vertex_vao[n];
glBindBuffer(GL_ARRAY_BUFFER, 0); glEnableVertexAttribArray(n);
glVertexAttribPointer(n, e->num_elems, e->type, e->normalized, sizeof(struct vertex),
// draw quad (void *)(intptr_t) e->offset);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); }
for ( n = 0; vertex_vao[n].name; n++) glBindBuffer(GL_ARRAY_BUFFER, 0);
glDisableVertexAttribArray(n);
} // 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 /// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as /// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the /// published by the Free Software Foundation, either version 3 of the
/// License. /// License.
/// ///
/// This program is distributed in the hope that it will be useful, /// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of /// 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 Affero General Public License for more details. /// GNU Affero General Public License for more details.
/// ///
/// $Id: efb2e251dd7082138ec21609478d2402be8208cf $ /// $Id: efb2e251dd7082138ec21609478d2402be8208cf $
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus #ifdef __cplusplus
@ -25,8 +25,7 @@ extern "C"
{ {
#endif #endif
/// C callback feed key press /// C callback feed key press
extern void FeedKeyPress(const char *, const char *, int, int, extern void FeedKeyPress(const char *, const char *, int, int, const char *);
const char *);
/// C plugin get osd size and ascpect /// C plugin get osd size and ascpect
extern void GetOsdSize(int *, int *, double *); extern void GetOsdSize(int *, int *, double *);
@ -34,8 +33,7 @@ extern "C"
/// C plugin close osd /// C plugin close osd
extern void OsdClose(void); extern void OsdClose(void);
/// C plugin draw osd pixmap /// C plugin draw osd pixmap
extern void OsdDrawARGB(int, int, int, int, int, const uint8_t *, int, extern void OsdDrawARGB(int, int, int, int, int, const uint8_t *, int, int);
int);
/// C plugin play audio packet /// C plugin play audio packet
extern int PlayAudio(const uint8_t *, int, uint8_t); extern int PlayAudio(const uint8_t *, int, uint8_t);
@ -111,7 +109,7 @@ extern "C"
/// Pip play video packet /// Pip play video packet
extern int PipPlayVideo(const uint8_t *, int); extern int PipPlayVideo(const uint8_t *, int);
extern const char *X11DisplayName; ///< x11 display name extern const char *X11DisplayName; ///< x11 display name
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #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 /// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as /// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the /// published by the Free Software Foundation, either version 3 of the
/// License. /// License.
/// ///
/// This program is distributed in the hope that it will be useful, /// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of /// 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 Affero General Public License for more details. /// 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 /// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as /// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the /// published by the Free Software Foundation, either version 3 of the
/// License. /// License.
/// ///
/// This program is distributed in the hope that it will be useful, /// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of /// 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 Affero General Public License for more details. /// GNU Affero General Public License for more details.
/// ///
/// $Id: c7c2d5e8b724515d7c767668aab717b27f4e4068 $ /// $Id: c7c2d5e8b724515d7c767668aab717b27f4e4068 $
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#pragma once #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 /// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as /// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the /// published by the Free Software Foundation, either version 3 of the
/// License. /// License.
/// ///
/// This program is distributed in the hope that it will be useful, /// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of /// 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 Affero General Public License for more details. /// GNU Affero General Public License for more details.
/// ///
/// $Id: 83cd827a8744e8c80c8adba6cb87653b0ad58c45 $ /// $Id: 83cd827a8744e8c80c8adba6cb87653b0ad58c45 $
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// @addtogroup Video /// @addtogroup Video
@ -27,7 +27,7 @@
#include <GL/glx.h> #include <GL/glx.h>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Typedefs // Typedefs
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
/// Video hardware decoder typedef /// Video hardware decoder typedef
@ -37,16 +37,16 @@ typedef struct _video_hw_decoder_ VideoHwDecoder;
typedef struct __video_stream__ VideoStream; typedef struct __video_stream__ VideoStream;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Variables // Variables
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
extern signed char VideoHardwareDecoder; ///< flag use hardware decoder extern signed char VideoHardwareDecoder; ///< flag use hardware decoder
extern char VideoIgnoreRepeatPict; ///< disable repeat pict warning extern char VideoIgnoreRepeatPict; ///< disable repeat pict warning
extern int VideoAudioDelay; ///< audio/video delay extern int VideoAudioDelay; ///< audio/video delay
extern char ConfigStartX11Server; ///< flag start the x11 server extern char ConfigStartX11Server; ///< flag start the x11 server
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Prototypes // Prototypes
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
/// Allocate new video hardware decoder. /// Allocate new video hardware decoder.
@ -62,20 +62,17 @@ extern unsigned VideoGetSurface(VideoHwDecoder *, const AVCodecContext *);
extern void VideoReleaseSurface(VideoHwDecoder *, unsigned); extern void VideoReleaseSurface(VideoHwDecoder *, unsigned);
/// Callback to negotiate the PixelFormat. /// Callback to negotiate the PixelFormat.
extern enum AVPixelFormat Video_get_format(VideoHwDecoder *, AVCodecContext *, extern enum AVPixelFormat Video_get_format(VideoHwDecoder *, AVCodecContext *, const enum AVPixelFormat *);
const enum AVPixelFormat *);
/// Render a ffmpeg frame. /// Render a ffmpeg frame.
extern void VideoRenderFrame(VideoHwDecoder *, const AVCodecContext *, extern void VideoRenderFrame(VideoHwDecoder *, const AVCodecContext *, const AVFrame *);
const AVFrame *);
/// Get hwaccel context for ffmpeg. /// Get hwaccel context for ffmpeg.
extern void *VideoGetHwAccelContext(VideoHwDecoder *); extern void *VideoGetHwAccelContext(VideoHwDecoder *);
#ifdef AVCODEC_VDPAU_H #ifdef AVCODEC_VDPAU_H
/// Draw vdpau render state. /// Draw vdpau render state.
extern void VideoDrawRenderState(VideoHwDecoder *, extern void VideoDrawRenderState(VideoHwDecoder *, struct vdpau_render_state *);
struct vdpau_render_state *);
#endif #endif
#ifdef USE_OPENGLOSD #ifdef USE_OPENGLOSD
@ -189,8 +186,7 @@ extern void VideoSetAutoCrop(int, int, int);
extern void VideoOsdClear(void); extern void VideoOsdClear(void);
/// Draw an OSD ARGB image. /// Draw an OSD ARGB image.
extern void VideoOsdDrawARGB(int, int, int, int, int, const uint8_t *, int, extern void VideoOsdDrawARGB(int, int, int, int, int, const uint8_t *, int, int);
int);
/// Get OSD size. /// Get OSD size.
extern void VideoGetOsdSize(int *, int *); extern void VideoGetOsdSize(int *, int *);
@ -228,11 +224,11 @@ extern void VideoGetStats(VideoHwDecoder *, int *, int *, int *, int *, float *)
/// Get video stream size /// Get video stream size
extern void VideoGetVideoSize(VideoHwDecoder *, int *, int *, int *, int *); extern void VideoGetVideoSize(VideoHwDecoder *, int *, int *, int *, int *);
extern void VideoOsdInit(void); ///< Setup osd. extern void VideoOsdInit(void); ///< Setup osd.
extern void VideoOsdExit(void); ///< Cleanup osd. extern void VideoOsdExit(void); ///< Cleanup osd.
extern void VideoInit(const char *); ///< Setup video module. extern void VideoInit(const char *); ///< Setup video module.
extern void VideoExit(void); ///< Cleanup and exit video module. extern void VideoExit(void); ///< Cleanup and exit video module.
/// Poll video input buffers. /// Poll video input buffers.
extern int VideoPollInput(VideoStream *); extern int VideoPollInput(VideoStream *);
@ -248,13 +244,14 @@ extern void SetDPMSatBlackScreen(int);
/// Raise the frontend window /// Raise the frontend window
extern int VideoRaiseWindow(void); extern int VideoRaiseWindow(void);
#ifdef USE_OPENGLOSD #ifdef USE_OPENGLOSD
extern void ActivateOsd(GLuint,int,int,int,int); extern void ActivateOsd(GLuint, int, int, int, int);
#endif #endif
#if 0 #if 0
long int gettid() long int gettid()
{ {
return (long int)syscall(224); return (long int)syscall(224);
} }
#endif #endif