mirror of
https://github.com/jojo61/vdr-plugin-softhdcuvid.git
synced 2025-03-01 10:39:28 +00:00
Compare commits
63 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
5875e10479 | ||
|
a6e65d953e | ||
|
fecb81486d | ||
|
f756334187 | ||
|
14ba527a45 | ||
|
ec09dbfb25 | ||
|
34b1fccb28 | ||
|
5586618c6e | ||
|
4dbf2dcc84 | ||
|
74a2285af0 | ||
|
b2bff4ebd0 | ||
|
84501d314e | ||
|
04e1b8732d | ||
|
3e649a5cea | ||
|
feb7479ff8 | ||
|
3590eadbaa | ||
|
6c0f80979f | ||
|
189d8cfa53 | ||
|
73b355c52d | ||
|
3d23288bdc | ||
|
b1a642e64a | ||
|
1b7bfd2087 | ||
|
03e69b5e26 | ||
|
a5b81f8de1 | ||
|
2485929c2b | ||
|
b9fed82109 | ||
|
49db402de6 | ||
|
7ce842b989 | ||
|
9d0417045e | ||
|
f7449c8d3a | ||
|
5ef6597340 | ||
|
c06b891c2b | ||
|
26945ef9d2 | ||
|
e0239a549e | ||
|
431e37e93f | ||
|
4b5b27382a | ||
|
2ec7a250a3 | ||
|
1674600882 | ||
|
269c396a2c | ||
|
ce3813a9e9 | ||
|
53314a17f5 | ||
|
e4e6a81f54 | ||
|
70b67f4466 | ||
|
2f0b1d0df9 | ||
|
dfe70f4f96 | ||
|
fe3681f6eb | ||
|
50299f178f | ||
|
6ea4f5076b | ||
|
3cb66dd3de | ||
|
68fa4fe4dc | ||
|
463109fcb6 | ||
|
d1bc51edb8 | ||
|
67832ac333 | ||
|
1274e673ec | ||
|
4334894515 | ||
|
d2dedb40dd | ||
|
3bed988b14 | ||
|
f17e58c7c5 | ||
|
5cd68b6eed | ||
|
1a56d620ac | ||
|
695a6495dd | ||
|
780c594ba2 | ||
|
8838d4c754 |
156
Makefile
156
Makefile
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Makefile for a Video Disk Recorder plugin
|
||||
#
|
||||
#
|
||||
# $Id: 2a41981a57e5e83036463c6a08c84b86ed9d2be3 $
|
||||
|
||||
# The official name of this plugin.
|
||||
@@ -9,32 +9,65 @@
|
||||
|
||||
|
||||
### Configuration (edit this for your needs)
|
||||
# comment out if not needed
|
||||
# config as needed
|
||||
|
||||
# what kind of driver do we make -
|
||||
# if VAAPI is enabled the drivername is softhdvaapi
|
||||
# if CUVID is enabled the drivername is softhdcuvid
|
||||
#VAAPI=1
|
||||
CUVID=1
|
||||
# what kind of decoder do we make -
|
||||
# if VAAPI is enabled the pluginname is softhdvaapi
|
||||
# if CUVID is enabled the pluginname is softhdcuvid
|
||||
# if DRM is enabled the pluginname is softhddrm
|
||||
VAAPI ?= 0
|
||||
CUVID ?= 0
|
||||
|
||||
# use libplacebo - available for both drivers
|
||||
#LIBPLACEBO=1
|
||||
# if you enable DRM then the plugin will only run without X server
|
||||
# only valid for VAAPI
|
||||
# does not work with libplacebo
|
||||
DRM ?= 0
|
||||
|
||||
|
||||
# use libplacebo - available for both decoders but not for DRM
|
||||
LIBPLACEBO ?= 1
|
||||
|
||||
# use YADIF deint - only available with cuvid
|
||||
#YADIF=1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CONFIG := #-DDEBUG # remove # to enable debug output
|
||||
|
||||
|
||||
#--------------------- no more config needed past this point--------------------------------
|
||||
|
||||
# sanitize selections --------
|
||||
ifneq "$(MAKECMDGOALS)" "clean"
|
||||
|
||||
ifeq ($(VAAPI),0)
|
||||
ifeq ($(CUVID),0)
|
||||
ifeq ($(DRM),0)
|
||||
$(error Please define a plugin in the Makefile)
|
||||
exit 1;
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(CUVID),1)
|
||||
ifeq ($(DRM),1)
|
||||
$(error Missmatch in Plugin selection)
|
||||
exit 1;
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(CUVID),1)
|
||||
ifeq ($(VAAPI),1)
|
||||
$(error Missmatch in Plugin selection)
|
||||
exit 1;
|
||||
endif
|
||||
endif
|
||||
|
||||
endif
|
||||
#--------------------------
|
||||
|
||||
PLUGIN = softhdcuvid
|
||||
|
||||
# support OPENGLOSD always needed
|
||||
@@ -60,7 +93,6 @@ SWRESAMPLE = 1
|
||||
#AVRESAMPLE = 1
|
||||
#endif
|
||||
|
||||
CONFIG := #-DDEBUG #-DOSD_DEBUG # enable debug output+functions
|
||||
CONFIG += -DHAVE_GL # needed for mpv libs
|
||||
#CONFIG += -DSTILL_DEBUG=2 # still picture debug verbose level
|
||||
CONFIG += -DAV_INFO -DAV_INFO_TIME=3000 # info/debug a/v sync
|
||||
@@ -92,7 +124,7 @@ TMPDIR ?= /tmp
|
||||
|
||||
### The compiler options:
|
||||
|
||||
export CFLAGS = $(call PKGCFG,cflags)
|
||||
export CFLAGS = $(call PKGCFG,cflags)
|
||||
export CXXFLAGS = $(call PKGCFG,cxxflags)
|
||||
|
||||
ifeq ($(CFLAGS),)
|
||||
@@ -112,7 +144,33 @@ APIVERSION = $(call PKGCFG,apiversion)
|
||||
|
||||
|
||||
|
||||
### Parse softhddevice config
|
||||
### Parse config
|
||||
ifeq ($(VAAPI),1)
|
||||
CONFIG += -DVAAPI
|
||||
#LIBPLACEBO=1
|
||||
PLUGIN = softhdvaapi
|
||||
LIBS += -lEGL
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(DRM),1)
|
||||
PLUGIN = softhddrm
|
||||
CONFIG += -DUSE_DRM -DVAAPI
|
||||
LIBPLACEBO=0
|
||||
_CFLAGS += $(shell pkg-config --cflags libdrm)
|
||||
LIBS += -lgbm -ldrm
|
||||
LIBS += -lEGL
|
||||
endif
|
||||
|
||||
ifeq ($(CUVID),1)
|
||||
CONFIG += -DUSE_PIP # PIP support
|
||||
CONFIG += -DCUVID # enable CUVID decoder
|
||||
LIBS += -lEGL -lGL
|
||||
ifeq ($(YADIF),1)
|
||||
CONFIG += -DYADIF # Yadif only with CUVID
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(ALSA),1)
|
||||
CONFIG += -DUSE_ALSA
|
||||
@@ -136,33 +194,15 @@ endif
|
||||
ifeq ($(OPENGL),1)
|
||||
CONFIG += -DUSE_GLX
|
||||
_CFLAGS += $(shell pkg-config --cflags gl glu glew)
|
||||
#LIBS += $(shell pkg-config --libs glu glew)
|
||||
#LIBS += $(shell pkg-config --libs glu glew)
|
||||
_CFLAGS += $(shell pkg-config --cflags freetype2)
|
||||
LIBS += $(shell pkg-config --libs freetype2)
|
||||
endif
|
||||
|
||||
ifeq ($(VAAPI),1)
|
||||
CONFIG += -DVAAPI
|
||||
#LIBPLACEBO=1
|
||||
PLUGIN = softhdvaapi
|
||||
LIBS += -lEGL
|
||||
endif
|
||||
|
||||
ifeq ($(LIBPLACEBO),1)
|
||||
CONFIG += -DPLACEBO
|
||||
endif
|
||||
|
||||
ifeq ($(CUVID),1)
|
||||
CONFIG += -DUSE_PIP # PIP support
|
||||
CONFIG += -DCUVID # enable CUVID decoder
|
||||
LIBS += -lEGL -lGL
|
||||
ifeq ($(YADIF),1)
|
||||
CONFIG += -DYADIF # Yadif only with CUVID
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
|
||||
|
||||
ARCHIVE = $(PLUGIN)-$(VERSION)
|
||||
PACKAGE = vdr-$(ARCHIVE)
|
||||
@@ -173,7 +213,7 @@ SOFILE = libvdr-$(PLUGIN).so
|
||||
|
||||
|
||||
#
|
||||
# Test that libswresample is available
|
||||
# Test that libswresample is available
|
||||
#
|
||||
#ifneq (exists, $(shell pkg-config libswresample && echo exists))
|
||||
# $(warning ******************************************************************)
|
||||
@@ -182,7 +222,7 @@ SOFILE = libvdr-$(PLUGIN).so
|
||||
#endif
|
||||
|
||||
#
|
||||
# Test and set config for libavutil
|
||||
# Test and set config for libavutil
|
||||
#
|
||||
ifneq (exists, $(shell pkg-config libavutil && echo exists))
|
||||
$(warning ******************************************************************)
|
||||
@@ -193,7 +233,7 @@ _CFLAGS += $(shell pkg-config --cflags libavutil)
|
||||
LIBS += $(shell pkg-config --libs libavutil)
|
||||
|
||||
#
|
||||
# Test and set config for libswscale
|
||||
# Test and set config for libswscale
|
||||
#
|
||||
ifneq (exists, $(shell pkg-config libswscale && echo exists))
|
||||
$(warning ******************************************************************)
|
||||
@@ -233,24 +273,22 @@ endif
|
||||
|
||||
#_CFLAGS += $(shell pkg-config --cflags libavcodec x11 x11-xcb xcb xcb-icccm)
|
||||
#LIBS += -lrt $(shell pkg-config --libs libavcodec x11 x11-xcb xcb xcb-icccm)
|
||||
_CFLAGS += $(shell pkg-config --cflags x11 x11-xcb xcb xcb-icccm)
|
||||
LIBS += -lrt $(shell pkg-config --libs x11 x11-xcb xcb xcb-icccm)
|
||||
_CFLAGS += $(shell pkg-config --cflags x11 x11-xcb xcb xcb-icccm)
|
||||
LIBS += -lrt $(shell pkg-config --libs x11 x11-xcb xcb xcb-icccm)
|
||||
|
||||
_CFLAGS += -I/usr/local/cuda/include
|
||||
_CFLAGS += -I./opengl -I./
|
||||
|
||||
LIBS += -L/usr/lib64
|
||||
LIBS += -L/usr/local/cuda/lib64
|
||||
|
||||
ifeq ($(LIBPLACEBO),1)
|
||||
LIBS += -lplacebo
|
||||
endif
|
||||
|
||||
ifeq ($(CUVID),1)
|
||||
LIBS += -lcuda -L/usr/local/cuda/targets/x86_64-linux/lib -lcudart -lnvcuvid
|
||||
LIBS += -lcuda -lnvcuvid
|
||||
endif
|
||||
|
||||
LIBS += -lGLEW -lGLU -ldl -lglut
|
||||
LIBS += -lGLEW -lGLU -ldl -lglut
|
||||
### Includes and Defines (add further entries here):
|
||||
|
||||
INCLUDES +=
|
||||
@@ -261,19 +299,19 @@ DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -D_GNU_SOURCE $(CONFIG) \
|
||||
### Make it standard
|
||||
|
||||
override CXXFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \
|
||||
-g -Wextra -Winit-self -Werror=overloaded-virtual -std=c++0x
|
||||
override CFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \
|
||||
-g -W -Wextra -Winit-self -Werror=overloaded-virtual -Wno-unused-parameter
|
||||
override CFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \
|
||||
-g -W -Wextra -Winit-self -Wdeclaration-after-statement
|
||||
|
||||
|
||||
### The object files (add further files here):
|
||||
|
||||
OBJS = softhdcuvid.o softhddev.o video.o audio.o codec.o ringbuffer.o
|
||||
OBJS = softhdcuvid.o softhddev.o video.o audio.o codec.o ringbuffer.o
|
||||
ifeq ($(OPENGLOSD),1)
|
||||
OBJS += openglosd.o
|
||||
OBJS += openglosd.o
|
||||
endif
|
||||
|
||||
SRCS = $(wildcard $(OBJS:.o=.c)) softhdcuvid.cpp
|
||||
SRCS = $(wildcard $(OBJS:.o=.c)) *.cpp
|
||||
|
||||
### The main target:
|
||||
|
||||
@@ -290,11 +328,11 @@ $(DEPFILE): Makefile
|
||||
|
||||
### Internationalization (I18N):
|
||||
|
||||
PODIR = po
|
||||
I18Npo = $(wildcard $(PODIR)/*.po)
|
||||
I18Nmo = $(addsuffix .mo, $(foreach file, $(I18Npo), $(basename $(file))))
|
||||
PODIR = po
|
||||
I18Npo = $(wildcard $(PODIR)/*.po)
|
||||
I18Nmo = $(addsuffix .mo, $(foreach file, $(I18Npo), $(basename $(file))))
|
||||
I18Nmsgs = $(addprefix $(DESTDIR)$(LOCDIR)/, $(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo, $(notdir $(foreach file, $(I18Npo), $(basename $(file))))))
|
||||
I18Npot = $(PODIR)/$(PLUGIN).pot
|
||||
I18Npot = $(PODIR)/$(PLUGIN).pot
|
||||
|
||||
%.mo: %.po
|
||||
msgfmt -c -o $@ $<
|
||||
@@ -322,7 +360,7 @@ $(OBJS): Makefile
|
||||
|
||||
|
||||
$(SOFILE): $(OBJS) shaders.h
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) $(LIBS) -o $@
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) $(LIBS) -o $@
|
||||
|
||||
install-lib: $(SOFILE)
|
||||
install -D $^ $(DESTDIR)$(LIBDIR)/$^.$(APIVERSION)
|
||||
@@ -343,11 +381,13 @@ clean:
|
||||
|
||||
## Private Targets:
|
||||
|
||||
HDRS= $(wildcard *.h)
|
||||
HDRS= $(wildcard *.h)
|
||||
|
||||
indent:
|
||||
for i in $(SRCS) $(HDRS); do \
|
||||
indent $$i; \
|
||||
unexpand -a $$i | sed -e s/constconst/const/ > $$i.up; \
|
||||
mv $$i.up $$i; \
|
||||
done
|
||||
|
||||
video_test: video.c Makefile
|
||||
|
91
README.md
91
README.md
@@ -23,8 +23,8 @@ $Id: 5267da021a68b4a727b479417334bfbe67bbba14 $
|
||||
|
||||
A software and GPU emulated UHD output device plugin for VDR.
|
||||
|
||||
o Video decoder CPU / VDPAU
|
||||
o Video output opengl
|
||||
o Video decoder CUVID or VAAPI
|
||||
o Video output opengl or DRM
|
||||
o Audio FFMpeg / Alsa / Analog
|
||||
o Audio FFMpeg / Alsa / Digital
|
||||
o Audio FFMpeg / OSS / Analog
|
||||
@@ -32,9 +32,10 @@ A software and GPU emulated UHD output device plugin for VDR.
|
||||
o Software volume, compression, normalize and channel resample
|
||||
o VDR ScaleVideo API
|
||||
o CUDA deinterlacer
|
||||
o Autocrop
|
||||
o Suspend / Dettach
|
||||
o PIP (Picture-in-Picture) (not working yet)
|
||||
o Support for ambilight
|
||||
o Support for Screencopy
|
||||
o PIP (Picture-in-Picture) (only for CUVID)
|
||||
|
||||
|
||||
To compile you must have the 'requires' installed.
|
||||
@@ -47,34 +48,21 @@ Current Status NVIDIA:
|
||||
The CUDA driver supports HEVC with 8 Bit and 10 Bit up to UHD resolution. Opengl is able to output also 10 Bit, but NVIDIA does not support to output 10 Bit via HDMI.
|
||||
Only via DisplayPort you can get 10 Bit output to a compatible screen. This is a restriction from NVIDIA.
|
||||
|
||||
Current Status with VAAPI
|
||||
You need libplacebo.
|
||||
It is still beta and I tested it with Intel VAAPI. If you have problmes with the shaders then copy the drirc file in your home directory as .drirc
|
||||
AMD VAAPI is broken by AMD and will not work currently. The vaapi_deinterlace is broken and the amdgpu driver is instable. I have not testet with amdgpupro
|
||||
Current Status with VAAPI:
|
||||
I tested it with Intel VAAPI. If you have problmes with the shaders then copy the drirc file in your home directory as .drirc
|
||||
AMD VAAPI is broken by AMD and will not work currently.
|
||||
|
||||
You have to adapt the Makefile to your needs. I use FFMPEG 4.0
|
||||
The Makefile expects the CUDA SDK in /usr/local/cuda. Currently it is tested with CUDA 10
|
||||
|
||||
Unfortunatly older FFMEGs has a bug with deinterlacing cuda frames. Best to get the latest FFMPEG Version.
|
||||
|
||||
Otherwise you have to patch the file in libavcodec/cuviddec.c
|
||||
Somewhere near line 860 and 1066 depending on your release:
|
||||
old:
|
||||
ctx->frame_queue = av_fifo_alloc(ctx->nb_surfaces * sizeof(CuvidParsedFrame));
|
||||
|
||||
new:
|
||||
ctx->frame_queue = av_fifo_alloc((ctx->nb_surfaces + 2 ) * sizeof(CuvidParsedFrame));
|
||||
|
||||
This Version supports building with libplacebo. https://github.com/haasn/libplacebo
|
||||
You have to enable it in the Makefile and install libplacebo yourself.
|
||||
At the moment this is Work in progress.
|
||||
|
||||
It also needs the NVIDIA driver 410.48 or newer as well as CUDA 10.
|
||||
|
||||
In the settings you can enable a correction for Colorblindness. First you have to decide what kind of colorblindness to use. And then the faktor of correction. If the faktor is negativ than the selected type of colorblindness is simulated. If the faktor is positiv then the colors are enhanced to try to correct the deficiency.
|
||||
I recommend to use libplacebo. It has much better scaler and does colorconversion for HDR the correct way.
|
||||
|
||||
Also you can enable a Scaler Test feature. When enabled then the screen is split.On the left half you will see the scaler defined by Scaler Test and on the right side you will see the scaler defined at the Resolution setting. There is as small black line between the halfs to remaind you that Scaler Test is activ.
|
||||
|
||||
If your FFMEG supports it then you can enable YADIF in the Makefile and select btween the buildin NVIDIA CUDA deinterlacer and the YADIF cuda deinterlacer.
|
||||
If your FFMEG supports it then you can enable YADIF in the Makefile and select between the buildin NVIDIA CUDA deinterlacer and the YADIF cuda deinterlacer.
|
||||
|
||||
Good luck
|
||||
jojo61
|
||||
@@ -82,7 +70,17 @@ jojo61
|
||||
Quickstart:
|
||||
-----------
|
||||
|
||||
Just type make and use.
|
||||
You have to adapt the Makefile. There are 3 possible Version that you can build:
|
||||
|
||||
softhdcuvid
|
||||
This is for NVIDA cards and uses cuvid as decoder. It uses xcb for output and needs a X Server to run.
|
||||
|
||||
softhdvaapi
|
||||
This is for INTEL cards and uses Vaapi as decoder. It uses xcb for output and needs a X Server to run.
|
||||
|
||||
softhddrm
|
||||
This is for INTEL cards and also uses Vaapi as decoder. It uses the DRM API for output and
|
||||
runs without X Server. There are several commandline options to select the resolution and refresh rate.
|
||||
|
||||
Install:
|
||||
--------
|
||||
@@ -98,6 +96,29 @@ Install:
|
||||
|
||||
You have to start vdr with -P 'softhdcuvid -d :0.0 ..<more option>.. '
|
||||
|
||||
Beginners Guide for libplacebo:
|
||||
-------------------------------
|
||||
When using libplacebo you will find several config options.
|
||||
|
||||
First of all you need to set the right scaler for each resolution:
|
||||
Best you beginn with setting all to "bilinear". If that works ok for you, you can try to change them
|
||||
for more advanced scaler. I use ewa_robidouxsharp on my GTX1050, but your mileage may vary.
|
||||
Unfortunatly on INTEL not all scalers may work or crash.
|
||||
|
||||
You can enable a Scaler Test feature. When enabled then the screen is split.On the left half you will
|
||||
see the scaler defined by Scaler Test and on the right side you will see the scaler defined at the
|
||||
Resolution setting. There is as small black line between the halfs to remaind you that Scaler Test
|
||||
is activ.
|
||||
|
||||
Then you should set the Monitor Colorspace to "sRGB". This guarantees you the best colors on your screen.
|
||||
At the moment all calculations internaly are done in RGB space and all cards output also RGB.
|
||||
|
||||
If you are colorblind you could try to remedy this with the Colorblind Settings. Realy only needed
|
||||
in rare cases.
|
||||
|
||||
All other settings can be in their default state.
|
||||
|
||||
|
||||
|
||||
Setup: environment
|
||||
------
|
||||
@@ -356,25 +377,7 @@ Running:
|
||||
|
||||
Known Bugs:
|
||||
-----------
|
||||
SD Stream not working very well
|
||||
RESUME starts wirh black screen (channelswitch needed)
|
||||
|
||||
Requires:
|
||||
---------
|
||||
media-video/vdr (version >=1.7.xx)
|
||||
Video Disk Recorder - turns a pc into a powerful set top box
|
||||
for DVB.
|
||||
http://www.tvdr.de/
|
||||
|
||||
media-video/ffmpeg (version >=0.7)
|
||||
Complete solution to record, convert and stream audio and
|
||||
video. Includes libavcodec and libswresample.
|
||||
http://ffmpeg.org
|
||||
media-libs/alsa-lib
|
||||
Advanced Linux Sound Architecture Library
|
||||
http://www.alsa-project.org
|
||||
or
|
||||
kernel support for oss/oss4 or alsa oss emulation
|
||||
SD Streams not working very well on vaapi
|
||||
|
||||
|
||||
|
||||
Optional:
|
||||
|
80
audio.c
80
audio.c
@@ -86,6 +86,8 @@
|
||||
#define __USE_GNU
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/resource.h>
|
||||
#ifndef HAVE_PTHREAD_NAME
|
||||
/// only available with newer glibc
|
||||
#define pthread_setname_np(thread, name)
|
||||
@@ -688,7 +690,7 @@ static int AudioRingAdd(unsigned sample_rate, int channels, int passthrough)
|
||||
AudioRing[AudioRingWrite].InChannels = channels;
|
||||
AudioRing[AudioRingWrite].HwSampleRate = sample_rate;
|
||||
AudioRing[AudioRingWrite].HwChannels = AudioChannelMatrix[u][channels];
|
||||
AudioRing[AudioRingWrite].PTS = INT64_C(0x8000000000000000);
|
||||
AudioRing[AudioRingWrite].PTS = AV_NOPTS_VALUE;
|
||||
RingBufferReset(AudioRing[AudioRingWrite].RingBuffer);
|
||||
|
||||
Debug(3, "audio: %d ring buffer prepared\n", atomic_read(&AudioRingFilled) + 1);
|
||||
@@ -1156,7 +1158,7 @@ static int64_t AlsaGetDelay(void)
|
||||
//Debug(3, "audio/alsa: %ld frames delay ok, but not running\n", delay);
|
||||
#endif
|
||||
}
|
||||
//Debug(3, "audio/alsa: %ld frames hw delay\n", delay);
|
||||
Debug(4, "audio/alsa: %ld frames hw delay\n", delay);
|
||||
|
||||
// delay can be negative, when underrun occur
|
||||
if (delay < 0) {
|
||||
@@ -1291,7 +1293,6 @@ static int AlsaSetup(int *freq, int *channels, int passthrough)
|
||||
Info(_("audio/alsa: start delay %ums\n"), (AudioStartThreshold * 1000)
|
||||
/ (*freq * *channels * AudioBytesProSample));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1989,7 +1990,7 @@ static int AudioNextRing(void)
|
||||
|
||||
// stop, if not enough in next buffer
|
||||
used = RingBufferUsedBytes(AudioRing[AudioRingRead].RingBuffer);
|
||||
if (AudioStartThreshold * 10 < used || (AudioVideoIsReady && AudioStartThreshold < used)) {
|
||||
if (AudioStartThreshold * 4 < used || (AudioVideoIsReady && AudioStartThreshold < used)) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@@ -2004,6 +2005,7 @@ static void *AudioPlayHandlerThread(void *dummy)
|
||||
{
|
||||
Debug(3, "audio: play thread started\n");
|
||||
prctl(PR_SET_NAME, "cuvid audio", 0, 0, 0);
|
||||
|
||||
for (;;) {
|
||||
// check if we should stop the thread
|
||||
if (AudioThreadStop) {
|
||||
@@ -2020,9 +2022,9 @@ static void *AudioPlayHandlerThread(void *dummy)
|
||||
} while (!AudioRunning);
|
||||
pthread_mutex_unlock(&AudioMutex);
|
||||
|
||||
Debug(3, "audio: ----> %dms start\n", (AudioUsedBytes() * 1000)
|
||||
Debug(3, "audio: ----> %dms %d start\n", (AudioUsedBytes() * 1000)
|
||||
/ (!AudioRing[AudioRingWrite].HwSampleRate + !AudioRing[AudioRingWrite].HwChannels +
|
||||
AudioRing[AudioRingWrite].HwSampleRate * AudioRing[AudioRingWrite].HwChannels * AudioBytesProSample));
|
||||
AudioRing[AudioRingWrite].HwSampleRate * AudioRing[AudioRingWrite].HwChannels * AudioBytesProSample),AudioUsedBytes());
|
||||
|
||||
do {
|
||||
int filled;
|
||||
@@ -2056,10 +2058,8 @@ static void *AudioPlayHandlerThread(void *dummy)
|
||||
AudioUsedModule->FlushBuffers();
|
||||
atomic_sub(flush, &AudioRingFilled);
|
||||
if (AudioNextRing()) {
|
||||
Debug(3, "audio: HandlerThread break after flush\n");
|
||||
break;
|
||||
}
|
||||
Debug(3, "audio: continue after flush\n");
|
||||
}
|
||||
// try to play some samples
|
||||
err = 0;
|
||||
@@ -2252,7 +2252,7 @@ void AudioEnqueue(const void *samples, int count)
|
||||
AudioNormalizer(buffer, count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
n = RingBufferWrite(AudioRing[AudioRingWrite].RingBuffer, buffer, count);
|
||||
if (n != (size_t)count) {
|
||||
Error(_("audio: can't place %d samples in ring buffer\n"), count);
|
||||
@@ -2284,18 +2284,18 @@ void AudioEnqueue(const void *samples, int count)
|
||||
}
|
||||
// forced start or enough video + audio buffered
|
||||
// for some exotic channels * 4 too small
|
||||
if (AudioStartThreshold * 10 < n || (AudioVideoIsReady
|
||||
if (AudioStartThreshold * 4 < n || (AudioVideoIsReady
|
||||
// if ((AudioVideoIsReady
|
||||
&& AudioStartThreshold < n)) {
|
||||
// restart play-back
|
||||
// no lock needed, can wakeup next time
|
||||
AudioRunning = 1;
|
||||
pthread_cond_signal(&AudioStartCond);
|
||||
Debug(3, "Start on AudioEnque\n");
|
||||
Debug(3, "Start on AudioEnque Threshold %d n %d\n",AudioStartThreshold,n);
|
||||
}
|
||||
}
|
||||
// Update audio clock (stupid gcc developers thinks INT64_C is unsigned)
|
||||
if (AudioRing[AudioRingWrite].PTS != (int64_t) INT64_C(0x8000000000000000)) {
|
||||
if (AudioRing[AudioRingWrite].PTS != (int64_t) AV_NOPTS_VALUE) {
|
||||
AudioRing[AudioRingWrite].PTS += ((int64_t) count * 90 * 1000)
|
||||
/ (AudioRing[AudioRingWrite].HwSampleRate * AudioRing[AudioRingWrite].HwChannels * AudioBytesProSample);
|
||||
}
|
||||
@@ -2311,13 +2311,13 @@ void AudioVideoReady(int64_t pts)
|
||||
int64_t audio_pts;
|
||||
size_t used;
|
||||
|
||||
if (pts == (int64_t) INT64_C(0x8000000000000000)) {
|
||||
if (pts == (int64_t) AV_NOPTS_VALUE) {
|
||||
Debug(3, "audio: a/v start, no valid video\n");
|
||||
return;
|
||||
}
|
||||
// no valid audio known
|
||||
if (!AudioRing[AudioRingWrite].HwSampleRate || !AudioRing[AudioRingWrite].HwChannels
|
||||
|| AudioRing[AudioRingWrite].PTS == (int64_t) INT64_C(0x8000000000000000)) {
|
||||
|| AudioRing[AudioRingWrite].PTS == (int64_t) AV_NOPTS_VALUE) {
|
||||
Debug(3, "audio: a/v start, no valid audio\n");
|
||||
AudioVideoIsReady = 1;
|
||||
return;
|
||||
@@ -2325,7 +2325,7 @@ void AudioVideoReady(int64_t pts)
|
||||
// Audio.PTS = next written sample time stamp
|
||||
|
||||
used = RingBufferUsedBytes(AudioRing[AudioRingWrite].RingBuffer);
|
||||
audio_pts =
|
||||
audio_pts =
|
||||
AudioRing[AudioRingWrite].PTS -
|
||||
(used * 90 * 1000) / (AudioRing[AudioRingWrite].HwSampleRate * AudioRing[AudioRingWrite].HwChannels *
|
||||
AudioBytesProSample);
|
||||
@@ -2337,12 +2337,11 @@ void AudioVideoReady(int64_t pts)
|
||||
|
||||
if (!AudioRunning) {
|
||||
int skip;
|
||||
|
||||
// buffer ~15 video frames
|
||||
// FIXME: HDTV can use smaller video buffer
|
||||
skip = pts - 15 * 20 * 90 - AudioBufferTime * 90 - audio_pts + VideoAudioDelay;
|
||||
skip = pts - 0 * 20 * 90 - AudioBufferTime * 90 - audio_pts + VideoAudioDelay;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "%dms %dms %dms\n", (int)(pts - audio_pts) / 90, VideoAudioDelay / 90, skip / 90);
|
||||
// fprintf(stderr, "a/v-diff %dms a/v-delay %dms skip %dms Audiobuffer %d\n", (int)(pts - audio_pts) / 90, VideoAudioDelay / 90, skip / 90,AudioBufferTime);
|
||||
#endif
|
||||
// guard against old PTS
|
||||
if (skip > 0 && skip < 4000 * 90) {
|
||||
@@ -2353,9 +2352,9 @@ void AudioVideoReady(int64_t pts)
|
||||
AudioSkip = skip - used;
|
||||
skip = used;
|
||||
}
|
||||
Debug(3, "audio: sync advance %dms %d/%zd\n",
|
||||
Debug(3, "audio: sync advance %dms %d/%zd Rest %d\n",
|
||||
(skip * 1000) / (AudioRing[AudioRingWrite].HwSampleRate * AudioRing[AudioRingWrite].HwChannels *
|
||||
AudioBytesProSample), skip, used);
|
||||
AudioBytesProSample), skip, used, AudioSkip);
|
||||
RingBufferReadAdvance(AudioRing[AudioRingWrite].RingBuffer, skip);
|
||||
|
||||
used = RingBufferUsedBytes(AudioRing[AudioRingWrite].RingBuffer);
|
||||
@@ -2363,7 +2362,6 @@ void AudioVideoReady(int64_t pts)
|
||||
Debug(3, "No audio skip -> should skip %d\n", skip / 90);
|
||||
}
|
||||
// FIXME: skip<0 we need bigger audio buffer
|
||||
|
||||
// enough video + audio buffered
|
||||
if (AudioStartThreshold < used) {
|
||||
AudioRunning = 1;
|
||||
@@ -2373,38 +2371,7 @@ void AudioVideoReady(int64_t pts)
|
||||
}
|
||||
|
||||
AudioVideoIsReady = 1;
|
||||
#if 0
|
||||
if (AudioRing[AudioRingWrite].HwSampleRate && AudioRing[AudioRingWrite].HwChannels) {
|
||||
if (pts != (int64_t) INT64_C(0x8000000000000000)
|
||||
&& AudioRing[AudioRingWrite].PTS != (int64_t) INT64_C(0x8000000000000000)) {
|
||||
Debug(3, "audio: a/v %d %s\n", (int)(pts - AudioRing[AudioRingWrite].PTS) / 90,
|
||||
AudioRunning ? "running" : "stopped");
|
||||
}
|
||||
Debug(3, "audio: start %4zdms %s|%s video ready\n",
|
||||
(RingBufferUsedBytes(AudioRing[AudioRingWrite].RingBuffer) * 1000)
|
||||
/ (AudioRing[AudioRingWrite].HwSampleRate * AudioRing[AudioRingWrite].HwChannels * AudioBytesProSample),
|
||||
Timestamp2String(pts), Timestamp2String(AudioRing[AudioRingWrite].PTS));
|
||||
|
||||
if (!AudioRunning) {
|
||||
size_t used;
|
||||
|
||||
used = RingBufferUsedBytes(AudioRing[AudioRingWrite].RingBuffer);
|
||||
// enough video + audio buffered
|
||||
if (AudioStartThreshold < used) {
|
||||
// too much audio buffered, skip it
|
||||
if (AudioStartThreshold < used) {
|
||||
Debug(3, "audio: start %4zdms skip video ready\n", ((used - AudioStartThreshold) * 1000)
|
||||
/ (AudioRing[AudioRingWrite].HwSampleRate * AudioRing[AudioRingWrite].HwChannels *
|
||||
AudioBytesProSample));
|
||||
RingBufferReadAdvance(AudioRing[AudioRingWrite].RingBuffer, used - AudioStartThreshold);
|
||||
}
|
||||
AudioRunning = 1;
|
||||
pthread_cond_signal(&AudioStartCond);
|
||||
}
|
||||
}
|
||||
}
|
||||
AudioVideoIsReady = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2439,7 +2406,7 @@ void AudioFlushBuffers(void)
|
||||
AudioRing[AudioRingWrite].HwChannels = AudioRing[old].HwChannels;
|
||||
AudioRing[AudioRingWrite].InSampleRate = AudioRing[old].InSampleRate;
|
||||
AudioRing[AudioRingWrite].InChannels = AudioRing[old].InChannels;
|
||||
AudioRing[AudioRingWrite].PTS = INT64_C(0x8000000000000000);
|
||||
AudioRing[AudioRingWrite].PTS = AV_NOPTS_VALUE;
|
||||
RingBufferReadAdvance(AudioRing[AudioRingWrite].RingBuffer,
|
||||
RingBufferUsedBytes(AudioRing[AudioRingWrite].RingBuffer));
|
||||
Debug(3, "audio: reset video ready\n");
|
||||
@@ -2512,7 +2479,7 @@ int64_t AudioGetDelay(void)
|
||||
pts += ((int64_t) RingBufferUsedBytes(AudioRing[AudioRingRead].RingBuffer)
|
||||
* 90 * 1000) / (AudioRing[AudioRingRead].HwSampleRate * AudioRing[AudioRingRead].HwChannels *
|
||||
AudioBytesProSample);
|
||||
Debug(4, "audio: hw+sw delay %zd %" PRId64 "ms\n", RingBufferUsedBytes(AudioRing[AudioRingRead].RingBuffer),
|
||||
Debug(4,"audio: hw+sw delay %zd %" PRId64 "ms\n", RingBufferUsedBytes(AudioRing[AudioRingRead].RingBuffer),
|
||||
pts / 90);
|
||||
|
||||
return pts;
|
||||
@@ -2529,6 +2496,7 @@ void AudioSetClock(int64_t pts)
|
||||
Debug(4, "audio: set clock %s -> %s pts\n", Timestamp2String(AudioRing[AudioRingWrite].PTS),
|
||||
Timestamp2String(pts));
|
||||
}
|
||||
// printf("Audiosetclock pts %#012" PRIx64 " %d\n",pts,RingBufferUsedBytes(AudioRing[AudioRingWrite].RingBuffer));
|
||||
AudioRing[AudioRingWrite].PTS = pts;
|
||||
}
|
||||
|
||||
@@ -2540,7 +2508,7 @@ void AudioSetClock(int64_t pts)
|
||||
int64_t AudioGetClock(void)
|
||||
{
|
||||
// (cast) needed for the evil gcc
|
||||
if (AudioRing[AudioRingRead].PTS != (int64_t) INT64_C(0x8000000000000000)) {
|
||||
if (AudioRing[AudioRingRead].PTS != (int64_t) AV_NOPTS_VALUE) {
|
||||
int64_t delay;
|
||||
|
||||
// delay zero, if no valid time stamp
|
||||
@@ -2551,7 +2519,7 @@ int64_t AudioGetClock(void)
|
||||
return AudioRing[AudioRingRead].PTS + 0 * 90 - delay;
|
||||
}
|
||||
}
|
||||
return INT64_C(0x8000000000000000);
|
||||
return AV_NOPTS_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
609
drm.c
Normal file
609
drm.c
Normal file
@@ -0,0 +1,609 @@
|
||||
#include <unistd.h>
|
||||
#include <gbm.h>
|
||||
#include <sys/mman.h>
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
#include <drm_fourcc.h>
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
|
||||
#define DRM_DEBUG
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// DRM
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
struct _Drm_Render_
|
||||
{
|
||||
int fd_drm;
|
||||
drmModeModeInfo mode;
|
||||
drmModeCrtc *saved_crtc;
|
||||
// drmEventContext ev;
|
||||
int bpp;
|
||||
uint32_t connector_id, crtc_id, video_plane;
|
||||
uint32_t hdr_metadata;
|
||||
uint32_t mmWidth,mmHeight; // Size in mm
|
||||
uint32_t hdr_blob_id;
|
||||
|
||||
};
|
||||
typedef struct _Drm_Render_ VideoRender;
|
||||
|
||||
struct {
|
||||
struct gbm_device *dev;
|
||||
struct gbm_surface *surface;
|
||||
} gbm;
|
||||
|
||||
VideoRender *render;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Helper functions
|
||||
//----------------------------------------------------------------------------
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||
#endif
|
||||
struct type_name {
|
||||
unsigned int type;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
static const char *util_lookup_type_name(unsigned int type,
|
||||
const struct type_name *table,
|
||||
unsigned int count)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
if (table[i].type == type)
|
||||
return table[i].name;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const struct type_name connector_type_names[] = {
|
||||
{ DRM_MODE_CONNECTOR_Unknown, "unknown" },
|
||||
{ DRM_MODE_CONNECTOR_VGA, "VGA" },
|
||||
{ DRM_MODE_CONNECTOR_DVII, "DVI-I" },
|
||||
{ DRM_MODE_CONNECTOR_DVID, "DVI-D" },
|
||||
{ DRM_MODE_CONNECTOR_DVIA, "DVI-A" },
|
||||
{ DRM_MODE_CONNECTOR_Composite, "composite" },
|
||||
{ DRM_MODE_CONNECTOR_SVIDEO, "s-video" },
|
||||
{ DRM_MODE_CONNECTOR_LVDS, "LVDS" },
|
||||
{ DRM_MODE_CONNECTOR_Component, "component" },
|
||||
{ DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN" },
|
||||
{ DRM_MODE_CONNECTOR_DisplayPort, "DP" },
|
||||
{ DRM_MODE_CONNECTOR_HDMIA, "HDMI-A" },
|
||||
{ DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" },
|
||||
{ DRM_MODE_CONNECTOR_TV, "TV" },
|
||||
{ DRM_MODE_CONNECTOR_eDP, "eDP" },
|
||||
{ DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" },
|
||||
{ DRM_MODE_CONNECTOR_DSI, "DSI" },
|
||||
{ DRM_MODE_CONNECTOR_DPI, "DPI" },
|
||||
};
|
||||
|
||||
const char *util_lookup_connector_type_name(unsigned int type)
|
||||
{
|
||||
return util_lookup_type_name(type, connector_type_names,
|
||||
ARRAY_SIZE(connector_type_names));
|
||||
}
|
||||
|
||||
static uint64_t GetPropertyValue(int fd_drm, uint32_t objectID,
|
||||
uint32_t objectType, const char *propName)
|
||||
{
|
||||
uint32_t i;
|
||||
int found = 0;
|
||||
uint64_t value = 0;
|
||||
drmModePropertyPtr Prop;
|
||||
drmModeObjectPropertiesPtr objectProps =
|
||||
drmModeObjectGetProperties(fd_drm, objectID, objectType);
|
||||
|
||||
for (i = 0; i < objectProps->count_props; i++) {
|
||||
if ((Prop = drmModeGetProperty(fd_drm, objectProps->props[i])) == NULL)
|
||||
fprintf(stderr, "GetPropertyValue: Unable to query property.\n");
|
||||
|
||||
if (strcmp(propName, Prop->name) == 0) {
|
||||
value = objectProps->prop_values[i];
|
||||
found = 1;
|
||||
}
|
||||
|
||||
drmModeFreeProperty(Prop);
|
||||
|
||||
if (found)
|
||||
break;
|
||||
}
|
||||
|
||||
drmModeFreeObjectProperties(objectProps);
|
||||
|
||||
#ifdef DRM_DEBUG
|
||||
if (!found)
|
||||
fprintf(stderr, "GetPropertyValue: Unable to find value for property \'%s\'.\n",
|
||||
propName);
|
||||
#endif
|
||||
return value;
|
||||
}
|
||||
static uint32_t GetPropertyID(int fd_drm, uint32_t objectID,
|
||||
uint32_t objectType, const char *propName)
|
||||
{
|
||||
uint32_t i;
|
||||
int found = 0;
|
||||
uint32_t value = -1;
|
||||
drmModePropertyPtr Prop;
|
||||
drmModeObjectPropertiesPtr objectProps =
|
||||
drmModeObjectGetProperties(fd_drm, objectID, objectType);
|
||||
|
||||
for (i = 0; i < objectProps->count_props; i++) {
|
||||
if ((Prop = drmModeGetProperty(fd_drm, objectProps->props[i])) == NULL)
|
||||
fprintf(stderr, "GetPropertyValue: Unable to query property.\n");
|
||||
|
||||
if (strcmp(propName, Prop->name) == 0) {
|
||||
value = objectProps->props[i];
|
||||
found = 1;
|
||||
}
|
||||
drmModeFreeProperty(Prop);
|
||||
if (found)
|
||||
break;
|
||||
}
|
||||
drmModeFreeObjectProperties(objectProps);
|
||||
|
||||
#ifdef DRM_DEBUG
|
||||
if (!found)
|
||||
Debug(3,"GetPropertyValue: Unable to find ID for property \'%s\'.\n",propName);
|
||||
#endif
|
||||
return value;
|
||||
}
|
||||
|
||||
static int SetPropertyRequest(drmModeAtomicReqPtr ModeReq, int fd_drm,
|
||||
uint32_t objectID, uint32_t objectType,
|
||||
const char *propName, uint64_t value)
|
||||
{
|
||||
uint32_t i;
|
||||
uint64_t id = 0;
|
||||
drmModePropertyPtr Prop;
|
||||
drmModeObjectPropertiesPtr objectProps =
|
||||
drmModeObjectGetProperties(fd_drm, objectID, objectType);
|
||||
|
||||
for (i = 0; i < objectProps->count_props; i++) {
|
||||
if ((Prop = drmModeGetProperty(fd_drm, objectProps->props[i])) == NULL)
|
||||
printf( "SetPropertyRequest: Unable to query property.\n");
|
||||
|
||||
if (strcmp(propName, Prop->name) == 0) {
|
||||
id = Prop->prop_id;
|
||||
drmModeFreeProperty(Prop);
|
||||
break;
|
||||
}
|
||||
|
||||
drmModeFreeProperty(Prop);
|
||||
}
|
||||
|
||||
drmModeFreeObjectProperties(objectProps);
|
||||
|
||||
if (id == 0)
|
||||
printf( "SetPropertyRequest: Unable to find value for property \'%s\'.\n",
|
||||
propName);
|
||||
|
||||
return drmModeAtomicAddProperty(ModeReq, objectID, id, value);
|
||||
}
|
||||
|
||||
static void CuvidSetVideoMode(void);
|
||||
void set_video_mode(int width, int height)
|
||||
{
|
||||
drmModeConnector *connector;
|
||||
drmModeModeInfo *mode;
|
||||
int ii;
|
||||
if (height != 1080 && height != 2160)
|
||||
return;
|
||||
connector = drmModeGetConnector(render->fd_drm, render->connector_id);
|
||||
for (ii = 0; ii < connector->count_modes; ii++) {
|
||||
mode = &connector->modes[ii];
|
||||
printf("Mode %d %dx%d Rate %d\n",ii,mode->hdisplay,mode->vdisplay,mode->vrefresh);
|
||||
if (width == mode->hdisplay &&
|
||||
height == mode->vdisplay &&
|
||||
mode->vrefresh == DRMRefresh &&
|
||||
render->mode.hdisplay != width &&
|
||||
render->mode.vdisplay != height &&
|
||||
!(mode->flags & DRM_MODE_FLAG_INTERLACE)) {
|
||||
memcpy(&render->mode, mode, sizeof(drmModeModeInfo));
|
||||
VideoWindowWidth = mode->hdisplay;
|
||||
VideoWindowHeight = mode->vdisplay;
|
||||
eglDestroySurface (eglDisplay, eglSurface);
|
||||
EglCheck();
|
||||
gbm_surface_destroy (gbm.surface);
|
||||
InitBo(render->bpp);
|
||||
CuvidSetVideoMode();
|
||||
Debug(3,"Set new mode %d:%d\n",mode->hdisplay,mode->vdisplay);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int FindDevice(VideoRender * render)
|
||||
{
|
||||
drmVersion *version;
|
||||
drmModeRes *resources;
|
||||
drmModeConnector *connector;
|
||||
drmModeEncoder *encoder = 0;
|
||||
drmModeModeInfo *mode;
|
||||
drmModePlane *plane;
|
||||
drmModePlaneRes *plane_res;
|
||||
drmModeObjectPropertiesPtr props;
|
||||
uint32_t j, k;
|
||||
uint64_t has_dumb;
|
||||
uint64_t has_prime;
|
||||
int i,ii=0;
|
||||
char connectorstr[10];
|
||||
int found = 0;
|
||||
#ifdef RASPI
|
||||
render->fd_drm = open("/dev/dri/card1", O_RDWR);
|
||||
#else
|
||||
render->fd_drm = open("/dev/dri/card0", O_RDWR);
|
||||
#endif
|
||||
if (render->fd_drm < 0) {
|
||||
fprintf(stderr, "FindDevice: cannot open /dev/dri/card0: %m\n");
|
||||
return -errno;
|
||||
}
|
||||
drmSetMaster(render->fd_drm);
|
||||
|
||||
version = drmGetVersion(render->fd_drm);
|
||||
fprintf(stderr, "FindDevice: open /dev/dri/card0: %s\n", version->name);
|
||||
|
||||
// check capability
|
||||
if (drmGetCap(render->fd_drm, DRM_CAP_DUMB_BUFFER, &has_dumb) < 0 || has_dumb == 0)
|
||||
fprintf(stderr, "FindDevice: drmGetCap DRM_CAP_DUMB_BUFFER failed or doesn't have dumb buffer\n");
|
||||
|
||||
if (drmSetClientCap(render->fd_drm, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1) != 0)
|
||||
fprintf(stderr, "FindDevice: DRM_CLIENT_CAP_UNIVERSAL_PLANES not available.\n");
|
||||
|
||||
if (drmSetClientCap(render->fd_drm, DRM_CLIENT_CAP_ATOMIC, 1) != 0)
|
||||
fprintf(stderr, "FindDevice: DRM_CLIENT_CAP_ATOMIC not available.\n");
|
||||
|
||||
if (drmGetCap(render->fd_drm, DRM_CAP_PRIME, &has_prime) < 0)
|
||||
fprintf(stderr, "FindDevice: DRM_CAP_PRIME not available.\n");
|
||||
|
||||
if (drmGetCap(render->fd_drm, DRM_PRIME_CAP_EXPORT, &has_prime) < 0)
|
||||
fprintf(stderr, "FindDevice: DRM_PRIME_CAP_EXPORT not available.\n");
|
||||
|
||||
if (drmGetCap(render->fd_drm, DRM_PRIME_CAP_IMPORT, &has_prime) < 0)
|
||||
fprintf(stderr, "FindDevice: DRM_PRIME_CAP_IMPORT not available.\n");
|
||||
|
||||
if ((resources = drmModeGetResources(render->fd_drm)) == NULL){
|
||||
fprintf(stderr, "FindDevice: cannot retrieve DRM resources (%d): %m\n", errno);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
Debug(3,"[FindDevice] DRM have %i connectors, %i crtcs, %i encoders\n",
|
||||
resources->count_connectors, resources->count_crtcs,
|
||||
resources->count_encoders);
|
||||
#endif
|
||||
|
||||
// find all available connectors
|
||||
for (i = 0; i < resources->count_connectors; i++) {
|
||||
connector = drmModeGetConnector(render->fd_drm, resources->connectors[i]);
|
||||
if (!connector) {
|
||||
fprintf(stderr, "FindDevice: cannot retrieve DRM connector (%d): %m\n", errno);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
sprintf(connectorstr,"%s-%u",util_lookup_connector_type_name(connector->connector_type),connector->connector_type_id);
|
||||
printf("Connector >%s< is %sconnected\n",connectorstr,connector->connection == DRM_MODE_CONNECTED?"":"not ");
|
||||
if (DRMConnector && strcmp(DRMConnector,connectorstr))
|
||||
continue;
|
||||
|
||||
if (connector->connection == DRM_MODE_CONNECTED && connector->count_modes > 0) {
|
||||
float aspect = (float)connector->mmWidth / (float)connector->mmHeight;
|
||||
if ((aspect > 1.70) && (aspect < 1.85)) {
|
||||
render->mmHeight = 90;
|
||||
render->mmWidth = 160;
|
||||
} else {
|
||||
render->mmHeight = connector->mmHeight;
|
||||
render->mmWidth = connector->mmWidth;
|
||||
}
|
||||
render->connector_id = connector->connector_id;
|
||||
// FIXME: use default encoder/crtc pair
|
||||
if ((encoder = drmModeGetEncoder(render->fd_drm, connector->encoder_id)) == NULL){
|
||||
fprintf(stderr, "FindDevice: cannot retrieve encoder (%d): %m\n", errno);
|
||||
return -errno;
|
||||
}
|
||||
render->crtc_id = encoder->crtc_id;
|
||||
|
||||
render->hdr_metadata = GetPropertyID(render->fd_drm, connector->connector_id,
|
||||
DRM_MODE_OBJECT_CONNECTOR, "HDR_OUTPUT_METADATA");
|
||||
printf("ID %d of METADATA in Connector %d connected %d\n",render->hdr_metadata,connector->connector_id,connector->connection);
|
||||
|
||||
memcpy(&render->mode, &connector->modes[0], sizeof(drmModeModeInfo)); // set fallback
|
||||
// search Modes for Connector
|
||||
for (ii = 0; ii < connector->count_modes; ii++) {
|
||||
mode = &connector->modes[ii];
|
||||
|
||||
printf("Mode %d %dx%d Rate %d\n",ii,mode->hdisplay,mode->vdisplay,mode->vrefresh);
|
||||
|
||||
if (VideoWindowWidth && VideoWindowHeight) { // preset by command line
|
||||
if (VideoWindowWidth == mode->hdisplay &&
|
||||
VideoWindowHeight == mode->vdisplay &&
|
||||
mode->vrefresh == DRMRefresh &&
|
||||
!(mode->flags & DRM_MODE_FLAG_INTERLACE)) {
|
||||
memcpy(&render->mode, mode, sizeof(drmModeModeInfo));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!(mode->flags & DRM_MODE_FLAG_INTERLACE)) {
|
||||
memcpy(&render->mode, mode, sizeof(drmModeModeInfo));
|
||||
VideoWindowWidth = mode->hdisplay;
|
||||
VideoWindowHeight = mode->vdisplay;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
found = 1;
|
||||
i = resources->count_connectors; // uuuuhh
|
||||
}
|
||||
VideoWindowWidth = render->mode.hdisplay;
|
||||
VideoWindowHeight = render->mode.vdisplay;
|
||||
if (found)
|
||||
printf("Use Mode %d %dx%d Rate %d\n",ii,render->mode.hdisplay,render->mode.vdisplay,render->mode.vrefresh);
|
||||
drmModeFreeConnector(connector);
|
||||
}
|
||||
if (!found) {
|
||||
Debug(3,"Requested Connector not found or not connected\n");
|
||||
printf("Requested Connector not found or not connected\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// find first plane
|
||||
if ((plane_res = drmModeGetPlaneResources(render->fd_drm)) == NULL)
|
||||
fprintf(stderr, "FindDevice: cannot retrieve PlaneResources (%d): %m\n", errno);
|
||||
|
||||
for (j = 0; j < plane_res->count_planes; j++) {
|
||||
plane = drmModeGetPlane(render->fd_drm, plane_res->planes[j]);
|
||||
|
||||
if (plane == NULL)
|
||||
fprintf(stderr, "FindDevice: cannot query DRM-KMS plane %d\n", j);
|
||||
|
||||
for (i = 0; i < resources->count_crtcs; i++) {
|
||||
if (plane->possible_crtcs & (1 << i))
|
||||
break;
|
||||
}
|
||||
|
||||
uint64_t type = GetPropertyValue(render->fd_drm, plane_res->planes[j],
|
||||
DRM_MODE_OBJECT_PLANE, "type");
|
||||
uint64_t zpos = 0;
|
||||
|
||||
#ifdef DRM_DEBUG // If more then 2 crtcs this must rewriten!!!
|
||||
printf("[FindDevice] Plane id %i crtc_id %i possible_crtcs %i possible CRTC %i type %s\n",
|
||||
plane->plane_id, plane->crtc_id, plane->possible_crtcs, resources->crtcs[i],
|
||||
(type == DRM_PLANE_TYPE_PRIMARY) ? "primary plane" :
|
||||
(type == DRM_PLANE_TYPE_OVERLAY) ? "overlay plane" :
|
||||
(type == DRM_PLANE_TYPE_CURSOR) ? "cursor plane" : "No plane type");
|
||||
#endif
|
||||
|
||||
// test pixel format and plane caps
|
||||
for (k = 0; k < plane->count_formats; k++) {
|
||||
if (encoder->possible_crtcs & plane->possible_crtcs) {
|
||||
switch (plane->formats[k]) {
|
||||
#ifdef RASPI
|
||||
case DRM_FORMAT_ARGB8888:
|
||||
#else
|
||||
case DRM_FORMAT_XRGB2101010:
|
||||
#endif
|
||||
if (!render->video_plane) {
|
||||
render->video_plane = plane->plane_id;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
drmModeFreePlane(plane);
|
||||
}
|
||||
|
||||
drmModeFreePlaneResources(plane_res);
|
||||
|
||||
drmModeFreeEncoder(encoder);
|
||||
drmModeFreeResources(resources);
|
||||
|
||||
#ifdef DRM_DEBUG
|
||||
printf("[FindDevice] DRM setup CRTC: %i video_plane: %i \n",
|
||||
render->crtc_id, render->video_plane);
|
||||
#endif
|
||||
|
||||
// save actual modesetting
|
||||
render->saved_crtc = drmModeGetCrtc(render->fd_drm, render->crtc_id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
///
|
||||
/// Initialize video output module.
|
||||
///
|
||||
void VideoInitDrm()
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (!(render = calloc(1, sizeof(*render)))) {
|
||||
Fatal(_("video/DRM: out of memory\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (FindDevice(render)){
|
||||
Fatal(_( "VideoInit: FindDevice() failed\n"));
|
||||
}
|
||||
|
||||
gbm.dev = gbm_create_device (render->fd_drm);
|
||||
assert (gbm.dev != NULL);
|
||||
|
||||
PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL;
|
||||
get_platform_display =
|
||||
(void *) eglGetProcAddress("eglGetPlatformDisplay");
|
||||
assert(get_platform_display != NULL);
|
||||
|
||||
eglDisplay = get_platform_display(EGL_PLATFORM_GBM_KHR, gbm.dev, NULL);
|
||||
|
||||
assert (eglDisplay != NULL);
|
||||
// return;
|
||||
|
||||
drmModeAtomicReqPtr ModeReq;
|
||||
const uint32_t flags = DRM_MODE_ATOMIC_ALLOW_MODESET;
|
||||
uint32_t modeID = 0;
|
||||
|
||||
if (drmModeCreatePropertyBlob(render->fd_drm, &render->mode, sizeof(render->mode), &modeID) != 0) {
|
||||
fprintf(stderr, "Failed to create mode property.\n");
|
||||
return;
|
||||
}
|
||||
if (!(ModeReq = drmModeAtomicAlloc())) {
|
||||
fprintf(stderr, "cannot allocate atomic request (%d): %m\n", errno);
|
||||
return;
|
||||
}
|
||||
printf("set CRTC %d of Connector %d aktiv\n",render->crtc_id,render->connector_id);
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
|
||||
DRM_MODE_OBJECT_CRTC, "MODE_ID", modeID);
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id,
|
||||
DRM_MODE_OBJECT_CONNECTOR, "CRTC_ID", render->crtc_id);
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
|
||||
DRM_MODE_OBJECT_CRTC, "ACTIVE", 1);
|
||||
|
||||
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
|
||||
fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno);
|
||||
|
||||
if (drmModeDestroyPropertyBlob(render->fd_drm, modeID) != 0)
|
||||
fprintf(stderr, "cannot destroy property blob (%d): %m\n", errno);
|
||||
|
||||
drmModeAtomicFree(ModeReq);
|
||||
|
||||
}
|
||||
|
||||
void get_drm_aspect(int *num,int *den)
|
||||
{
|
||||
Debug(3,"mmHeight %d mmWidth %d VideoHeight %d VideoWidth %d\n",render->mmHeight,render->mmWidth,VideoWindowHeight,VideoWindowWidth);
|
||||
*num = VideoWindowWidth * render->mmHeight;
|
||||
*den = VideoWindowHeight * render->mmWidth;
|
||||
}
|
||||
|
||||
struct gbm_bo *bo = NULL, *next_bo=NULL;
|
||||
struct drm_fb *fb;
|
||||
static int m_need_modeset = 0;
|
||||
static int old_color=-1,old_trc=-1;
|
||||
|
||||
void InitBo(int bpp) {
|
||||
// create the GBM and EGL surface
|
||||
render->bpp = bpp;
|
||||
gbm.surface = gbm_surface_create (gbm.dev, VideoWindowWidth,VideoWindowHeight,
|
||||
bpp==10?GBM_FORMAT_XRGB2101010:GBM_FORMAT_ARGB8888,
|
||||
GBM_BO_USE_SCANOUT|GBM_BO_USE_RENDERING);
|
||||
assert(gbm.surface != NULL);
|
||||
eglSurface = eglCreateWindowSurface (eglDisplay, eglConfig, gbm.surface, NULL);
|
||||
assert(eglSurface != NULL);
|
||||
|
||||
}
|
||||
|
||||
static struct gbm_bo *previous_bo = NULL;
|
||||
static uint32_t previous_fb;
|
||||
|
||||
static void drm_swap_buffers () {
|
||||
|
||||
uint32_t fb;
|
||||
|
||||
eglSwapBuffers (eglDisplay, eglSurface);
|
||||
struct gbm_bo *bo = gbm_surface_lock_front_buffer (gbm.surface);
|
||||
#if 1
|
||||
if (bo == NULL)
|
||||
bo = gbm_surface_lock_front_buffer (gbm.surface);
|
||||
#endif
|
||||
assert (bo != NULL);
|
||||
uint32_t handle = gbm_bo_get_handle (bo).u32;
|
||||
uint32_t pitch = gbm_bo_get_stride (bo);
|
||||
|
||||
|
||||
drmModeAddFB (render->fd_drm, VideoWindowWidth,VideoWindowHeight,render->bpp==10? 30:24, 32, pitch, handle, &fb);
|
||||
// drmModeSetCrtc (render->fd_drm, render->crtc_id, fb, 0, 0, &render->connector_id, 1, &render->mode);
|
||||
|
||||
if (m_need_modeset) {
|
||||
drmModeAtomicReqPtr ModeReq;
|
||||
const uint32_t flags = DRM_MODE_ATOMIC_ALLOW_MODESET;
|
||||
uint32_t modeID = 0;
|
||||
|
||||
if (drmModeCreatePropertyBlob(render->fd_drm, &render->mode, sizeof(render->mode), &modeID) != 0) {
|
||||
fprintf(stderr, "Failed to create mode property.\n");
|
||||
return;
|
||||
}
|
||||
if (!(ModeReq = drmModeAtomicAlloc())) {
|
||||
fprintf(stderr, "cannot allocate atomic request (%d): %m\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
// Need to disable the CRTC in order to submit the HDR data....
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
|
||||
DRM_MODE_OBJECT_CRTC, "ACTIVE", 0);
|
||||
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
|
||||
fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno);
|
||||
sleep(2);
|
||||
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id,
|
||||
DRM_MODE_OBJECT_CONNECTOR, "Colorspace",old_color==AVCOL_PRI_BT2020?9:2 );
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
|
||||
DRM_MODE_OBJECT_CRTC, "MODE_ID", modeID);
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id,
|
||||
DRM_MODE_OBJECT_CONNECTOR, "CRTC_ID", render->crtc_id);
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
|
||||
DRM_MODE_OBJECT_CRTC, "ACTIVE", 1);
|
||||
|
||||
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
|
||||
fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno);
|
||||
|
||||
if (drmModeDestroyPropertyBlob(render->fd_drm, modeID) != 0)
|
||||
fprintf(stderr, "cannot destroy prperty blob (%d): %m\n", errno);
|
||||
|
||||
drmModeAtomicFree(ModeReq);
|
||||
m_need_modeset = 0;
|
||||
}
|
||||
drmModeSetCrtc (render->fd_drm, render->crtc_id, fb, 0, 0, &render->connector_id, 1, &render->mode);
|
||||
|
||||
if (previous_bo) {
|
||||
drmModeRmFB (render->fd_drm, previous_fb);
|
||||
gbm_surface_release_buffer (gbm.surface, previous_bo);
|
||||
}
|
||||
previous_bo = bo;
|
||||
previous_fb = fb;
|
||||
|
||||
}
|
||||
|
||||
static void drm_clean_up () {
|
||||
// set the previous crtc
|
||||
|
||||
if (!render)
|
||||
return;
|
||||
Debug(3,"drm clean up\n");
|
||||
|
||||
if (previous_bo) {
|
||||
drmModeRmFB (render->fd_drm, previous_fb);
|
||||
gbm_surface_release_buffer (gbm.surface, previous_bo);
|
||||
}
|
||||
|
||||
drmModeSetCrtc (render->fd_drm, render->saved_crtc->crtc_id, render->saved_crtc->buffer_id,
|
||||
render->saved_crtc->x, render->saved_crtc->y, &render->connector_id, 1, &render->saved_crtc->mode);
|
||||
drmModeFreeCrtc (render->saved_crtc);
|
||||
|
||||
if (render->hdr_blob_id)
|
||||
drmModeDestroyPropertyBlob(render->fd_drm, render->hdr_blob_id);
|
||||
render->hdr_blob_id = 0;
|
||||
|
||||
eglDestroySurface (eglDisplay, eglSurface);
|
||||
EglCheck();
|
||||
gbm_surface_destroy (gbm.surface);
|
||||
eglDestroyContext (eglDisplay, eglContext);
|
||||
EglCheck();
|
||||
eglDestroyContext (eglDisplay, eglSharedContext);
|
||||
EglCheck();
|
||||
eglSharedContext = NULL;
|
||||
|
||||
eglTerminate (eglDisplay);
|
||||
EglCheck();
|
||||
|
||||
gbm_device_destroy (gbm.dev);
|
||||
drmDropMaster(render->fd_drm);
|
||||
close (render->fd_drm);
|
||||
eglDisplay = NULL;
|
||||
free(render);
|
||||
|
||||
}
|
@@ -17,8 +17,6 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cuda_cuda_h__ // check to see if CUDA_H is included above
|
||||
|
||||
// Error Code string definitions here
|
||||
typedef struct
|
||||
{
|
||||
@@ -453,6 +451,4 @@ static inline const char *getCudaDrvErrorString(CUresult error_id)
|
||||
return (const char *)"CUDA_ERROR not found!";
|
||||
}
|
||||
|
||||
#endif // __cuda_cuda_h__
|
||||
|
||||
#endif
|
||||
|
493
hdr.c
Normal file
493
hdr.c
Normal file
@@ -0,0 +1,493 @@
|
||||
#include <libavutil/mastering_display_metadata.h>
|
||||
|
||||
/**
|
||||
* struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
|
||||
*
|
||||
* HDR Metadata Infoframe as per CTA 861.G spec. This is expected
|
||||
* to match exactly with the spec.
|
||||
*
|
||||
* Userspace is expected to pass the metadata information as per
|
||||
* the format described in this structure.
|
||||
*/
|
||||
struct hdr_metadata_infoframe {
|
||||
/**
|
||||
* @eotf: Electro-Optical Transfer Function (EOTF)
|
||||
* used in the stream.
|
||||
*/
|
||||
__u8 eotf;
|
||||
/**
|
||||
* @metadata_type: Static_Metadata_Descriptor_ID.
|
||||
*/
|
||||
__u8 metadata_type;
|
||||
/**
|
||||
* @display_primaries: Color Primaries of the Data.
|
||||
* These are coded as unsigned 16-bit values in units of
|
||||
* 0.00002, where 0x0000 represents zero and 0xC350
|
||||
* represents 1.0000.
|
||||
* @display_primaries.x: X cordinate of color primary.
|
||||
* @display_primaries.y: Y cordinate of color primary.
|
||||
*/
|
||||
struct {
|
||||
__u16 x, y;
|
||||
} display_primaries[3];
|
||||
/**
|
||||
* @white_point: White Point of Colorspace Data.
|
||||
* These are coded as unsigned 16-bit values in units of
|
||||
* 0.00002, where 0x0000 represents zero and 0xC350
|
||||
* represents 1.0000.
|
||||
* @white_point.x: X cordinate of whitepoint of color primary.
|
||||
* @white_point.y: Y cordinate of whitepoint of color primary.
|
||||
*/
|
||||
struct {
|
||||
__u16 x, y;
|
||||
} white_point;
|
||||
/**
|
||||
* @max_display_mastering_luminance: Max Mastering Display Luminance.
|
||||
* This value is coded as an unsigned 16-bit value in units of 1 cd/m2,
|
||||
* where 0x0001 represents 1 cd/m2 and 0xFFFF represents 65535 cd/m2.
|
||||
*/
|
||||
__u16 max_display_mastering_luminance;
|
||||
/**
|
||||
* @min_display_mastering_luminance: Min Mastering Display Luminance.
|
||||
* This value is coded as an unsigned 16-bit value in units of
|
||||
* 0.0001 cd/m2, where 0x0001 represents 0.0001 cd/m2 and 0xFFFF
|
||||
* represents 6.5535 cd/m2.
|
||||
*/
|
||||
__u16 min_display_mastering_luminance;
|
||||
/**
|
||||
* @max_cll: Max Content Light Level.
|
||||
* This value is coded as an unsigned 16-bit value in units of 1 cd/m2,
|
||||
* where 0x0001 represents 1 cd/m2 and 0xFFFF represents 65535 cd/m2.
|
||||
*/
|
||||
__u16 max_cll;
|
||||
/**
|
||||
* @max_fall: Max Frame Average Light Level.
|
||||
* This value is coded as an unsigned 16-bit value in units of 1 cd/m2,
|
||||
* where 0x0001 represents 1 cd/m2 and 0xFFFF represents 65535 cd/m2.
|
||||
*/
|
||||
__u16 max_fall;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct hdr_output_metadata - HDR output metadata
|
||||
*
|
||||
* Metadata Information to be passed from userspace
|
||||
*/
|
||||
struct hdr_output_metadata {
|
||||
/**
|
||||
* @metadata_type: Static_Metadata_Descriptor_ID.
|
||||
*/
|
||||
__u32 metadata_type;
|
||||
/**
|
||||
* @hdmi_metadata_type1: HDR Metadata Infoframe.
|
||||
*/
|
||||
union {
|
||||
struct hdr_metadata_infoframe hdmi_metadata_type1;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
enum hdr_metadata_eotf {
|
||||
EOTF_TRADITIONAL_GAMMA_SDR,
|
||||
EOTF_TRADITIONAL_GAMMA_HDR,
|
||||
EOTF_ST2084,
|
||||
EOTF_HLG,
|
||||
};
|
||||
|
||||
|
||||
enum metadata_id {
|
||||
METADATA_TYPE1,
|
||||
};
|
||||
|
||||
void
|
||||
weston_hdr_metadata(void *data,
|
||||
uint16_t display_primary_r_x,
|
||||
uint16_t display_primary_r_y,
|
||||
uint16_t display_primary_g_x,
|
||||
uint16_t display_primary_g_y,
|
||||
uint16_t display_primary_b_x,
|
||||
uint16_t display_primary_b_y,
|
||||
uint16_t white_point_x,
|
||||
uint16_t white_point_y,
|
||||
uint16_t min_luminance,
|
||||
uint16_t max_luminance,
|
||||
uint16_t max_cll,
|
||||
uint16_t max_fall,
|
||||
enum hdr_metadata_eotf eotf)
|
||||
{
|
||||
uint8_t *data8;
|
||||
uint16_t *data16;
|
||||
|
||||
data8 = data;
|
||||
|
||||
*data8++ = eotf;
|
||||
*data8++ = METADATA_TYPE1;
|
||||
|
||||
data16 = (void*)data8;
|
||||
|
||||
*data16++ = display_primary_r_x;
|
||||
*data16++ = display_primary_r_y;
|
||||
*data16++ = display_primary_g_x;
|
||||
*data16++ = display_primary_g_y;
|
||||
*data16++ = display_primary_b_x;
|
||||
*data16++ = display_primary_b_y;
|
||||
*data16++ = white_point_x;
|
||||
*data16++ = white_point_y;
|
||||
|
||||
*data16++ = max_luminance;
|
||||
*data16++ = min_luminance;
|
||||
*data16++ = max_cll;
|
||||
*data16++ = max_fall;
|
||||
}
|
||||
|
||||
struct weston_vector {
|
||||
float f[4];
|
||||
};
|
||||
|
||||
struct weston_colorspace {
|
||||
struct weston_vector r, g, b;
|
||||
struct weston_vector whitepoint;
|
||||
const char *name;
|
||||
const char *whitepoint_name;
|
||||
};
|
||||
|
||||
struct weston_colorspace hdr10;
|
||||
|
||||
static const struct weston_colorspace bt470m = {
|
||||
.r = {{ 0.670f, 0.330f, }},
|
||||
.g = {{ 0.210f, 0.710f, }},
|
||||
.b = {{ 0.140f, 0.080f, }},
|
||||
.whitepoint = {{ 0.3101f, 0.3162f, }},
|
||||
.name = "BT.470 M",
|
||||
.whitepoint_name = "C",
|
||||
};
|
||||
|
||||
static const struct weston_colorspace bt470bg = {
|
||||
.r = {{ 0.640f, 0.330f, }},
|
||||
.g = {{ 0.290f, 0.600f, }},
|
||||
.b = {{ 0.150f, 0.060f, }},
|
||||
.whitepoint = {{ 0.3127f, 0.3290f, }},
|
||||
.name = "BT.470 B/G",
|
||||
.whitepoint_name = "D65",
|
||||
};
|
||||
|
||||
static const struct weston_colorspace smpte170m = {
|
||||
.r = {{ 0.630f, 0.340f, }},
|
||||
.g = {{ 0.310f, 0.595f, }},
|
||||
.b = {{ 0.155f, 0.070f, }},
|
||||
.whitepoint = {{ 0.3127f, 0.3290f, }},
|
||||
.name = "SMPTE 170M",
|
||||
.whitepoint_name = "D65",
|
||||
};
|
||||
|
||||
static const struct weston_colorspace smpte240m = {
|
||||
.r = {{ 0.630f, 0.340f, }},
|
||||
.g = {{ 0.310f, 0.595f, }},
|
||||
.b = {{ 0.155f, 0.070f, }},
|
||||
.whitepoint = {{ 0.3127f, 0.3290f, }},
|
||||
.name = "SMPTE 240M",
|
||||
.whitepoint_name = "D65",
|
||||
};
|
||||
|
||||
static const struct weston_colorspace bt709 = {
|
||||
.r = {{ 0.640f, 0.330f, }},
|
||||
.g = {{ 0.300f, 0.600f, }},
|
||||
.b = {{ 0.150f, 0.060f, }},
|
||||
.whitepoint = {{ 0.3127f, 0.3290f, }},
|
||||
.name = "BT.709",
|
||||
.whitepoint_name = "D65",
|
||||
};
|
||||
|
||||
static const struct weston_colorspace bt2020 = {
|
||||
.r = {{ 0.708f, 0.292f, }},
|
||||
.g = {{ 0.170f, 0.797f, }},
|
||||
.b = {{ 0.131f, 0.046f, }},
|
||||
.whitepoint = {{ 0.3127f, 0.3290f, }},
|
||||
.name = "BT.2020",
|
||||
.whitepoint_name = "D65",
|
||||
};
|
||||
|
||||
static const struct weston_colorspace srgb = {
|
||||
.r = {{ 0.640f, 0.330f, }},
|
||||
.g = {{ 0.300f, 0.600f, }},
|
||||
.b = {{ 0.150f, 0.060f, }},
|
||||
.whitepoint = {{ 0.3127f, 0.3290f, }},
|
||||
.name = "sRGB",
|
||||
.whitepoint_name = "D65",
|
||||
};
|
||||
|
||||
static const struct weston_colorspace adobergb = {
|
||||
.r = {{ 0.640f, 0.330f, }},
|
||||
.g = {{ 0.210f, 0.710f, }},
|
||||
.b = {{ 0.150f, 0.060f, }},
|
||||
.whitepoint = {{ 0.3127f, 0.3290f, }},
|
||||
.name = "AdobeRGB",
|
||||
.whitepoint_name = "D65",
|
||||
};
|
||||
|
||||
static const struct weston_colorspace dci_p3 = {
|
||||
.r = {{ 0.680f, 0.320f, }},
|
||||
.g = {{ 0.265f, 0.690f, }},
|
||||
.b = {{ 0.150f, 0.060f, }},
|
||||
.whitepoint = {{ 0.3127f, 0.3290f, }},
|
||||
.name = "DCI-P3 D65",
|
||||
.whitepoint_name = "D65",
|
||||
};
|
||||
|
||||
static const struct weston_colorspace prophotorgb = {
|
||||
.r = {{ 0.7347f, 0.2653f, }},
|
||||
.g = {{ 0.1596f, 0.8404f, }},
|
||||
.b = {{ 0.0366f, 0.0001f, }},
|
||||
.whitepoint = {{ .3457, .3585 }},
|
||||
.name = "ProPhoto RGB",
|
||||
.whitepoint_name = "D50",
|
||||
};
|
||||
|
||||
static const struct weston_colorspace ciergb = {
|
||||
.r = {{ 0.7347f, 0.2653f, }},
|
||||
.g = {{ 0.2738f, 0.7174f, }},
|
||||
.b = {{ 0.1666f, 0.0089f, }},
|
||||
.whitepoint = {{ 1.0f / 3.0f, 1.0f / 3.0f, }},
|
||||
.name = "CIE RGB",
|
||||
.whitepoint_name = "E",
|
||||
};
|
||||
|
||||
static const struct weston_colorspace ciexyz = {
|
||||
.r = {{ 1.0f, 0.0f, }},
|
||||
.g = {{ 0.0f, 1.0f, }},
|
||||
.b = {{ 0.0f, 0.0f, }},
|
||||
.whitepoint = {{ 1.0f / 3.0f, 1.0f / 3.0f, }},
|
||||
.name = "CIE XYZ",
|
||||
.whitepoint_name = "E",
|
||||
};
|
||||
|
||||
const struct weston_colorspace ap0 = {
|
||||
.r = {{ 0.7347f, 0.2653f, }},
|
||||
.g = {{ 0.0000f, 1.0000f, }},
|
||||
.b = {{ 0.0001f, -0.0770f, }},
|
||||
.whitepoint = {{ .32168f, .33767f, }},
|
||||
.name = "ACES primaries #0",
|
||||
.whitepoint_name = "D60",
|
||||
};
|
||||
|
||||
const struct weston_colorspace ap1 = {
|
||||
.r = {{ 0.713f, 0.393f, }},
|
||||
.g = {{ 0.165f, 0.830f, }},
|
||||
.b = {{ 0.128f, 0.044f, }},
|
||||
.whitepoint = {{ 0.32168f, 0.33767f, }},
|
||||
.name = "ACES primaries #1",
|
||||
.whitepoint_name = "D60",
|
||||
};
|
||||
|
||||
static const struct weston_colorspace * const colorspaces[] = {
|
||||
&bt470m,
|
||||
&bt470bg,
|
||||
&smpte170m,
|
||||
&smpte240m,
|
||||
&bt709,
|
||||
&bt2020,
|
||||
&srgb,
|
||||
&adobergb,
|
||||
&dci_p3,
|
||||
&prophotorgb,
|
||||
&ciergb,
|
||||
&ciexyz,
|
||||
&ap0,
|
||||
&ap1,
|
||||
};
|
||||
#define ARRAY_LENGTH(a) (sizeof(a) / sizeof(a)[0])
|
||||
const struct weston_colorspace *
|
||||
weston_colorspace_lookup(const char *name)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < ARRAY_LENGTH(colorspaces); i++) {
|
||||
const struct weston_colorspace *c = colorspaces[i];
|
||||
|
||||
if (!strcmp(c->name, name))
|
||||
return c;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int cleanup=0;
|
||||
|
||||
|
||||
static uint16_t encode_xyy(float xyy)
|
||||
{
|
||||
return xyy * 50000;
|
||||
}
|
||||
static AVMasteringDisplayMetadata md_save = {0};
|
||||
static AVContentLightMetadata ld_save = {0};
|
||||
static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSideData *sd2)
|
||||
{
|
||||
drmModeAtomicReqPtr ModeReq;
|
||||
struct weston_colorspace *cs;
|
||||
enum hdr_metadata_eotf eotf;
|
||||
struct hdr_output_metadata data;
|
||||
int ret,MaxCLL=1500,MaxFALL=400;
|
||||
int max_lum=4000,min_lum=0050;
|
||||
struct AVMasteringDisplayMetadata *md = NULL;
|
||||
struct AVContentLightMetadata *ld = NULL;
|
||||
|
||||
if (render->hdr_metadata == -1) { // Metadata not supported
|
||||
return;
|
||||
}
|
||||
|
||||
// clean up FFMEPG stuff
|
||||
if (trc == AVCOL_TRC_BT2020_10)
|
||||
trc = AVCOL_TRC_ARIB_STD_B67;
|
||||
if (trc == AVCOL_TRC_UNSPECIFIED)
|
||||
trc = AVCOL_TRC_BT709;
|
||||
if (color == AVCOL_PRI_UNSPECIFIED)
|
||||
color = AVCOL_PRI_BT709;
|
||||
|
||||
if ((old_color == color && old_trc == trc && !sd1 && !sd2) || !render->hdr_metadata)
|
||||
return; // nothing to do
|
||||
|
||||
if (sd1)
|
||||
md = sd1->data;
|
||||
|
||||
if (sd2)
|
||||
ld = sd2->data;
|
||||
|
||||
if (md && !memcmp(md,&md_save,sizeof(md_save)))
|
||||
if (ld && !memcmp(ld,&ld_save,sizeof(ld_save))) {
|
||||
return;
|
||||
}
|
||||
else if (ld && !memcmp(ld,&ld_save,sizeof(ld_save))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ld)
|
||||
memcpy(&ld_save,ld,sizeof(ld_save));
|
||||
if (md)
|
||||
memcpy(&md_save,md,sizeof(md_save));
|
||||
|
||||
Debug(3,"Update HDR to TRC %d color %d\n",trc,color);
|
||||
|
||||
if (trc == AVCOL_TRC_BT2020_10)
|
||||
trc = AVCOL_TRC_ARIB_STD_B67;
|
||||
|
||||
old_color = color;
|
||||
old_trc = trc;
|
||||
|
||||
if (render->hdr_blob_id)
|
||||
drmModeDestroyPropertyBlob(render->fd_drm, render->hdr_blob_id);
|
||||
|
||||
switch(trc) {
|
||||
case AVCOL_TRC_BT709: // 1
|
||||
case AVCOL_TRC_UNSPECIFIED: // 2
|
||||
eotf = EOTF_TRADITIONAL_GAMMA_SDR;
|
||||
break;
|
||||
case AVCOL_TRC_BT2020_10: // 14
|
||||
case AVCOL_TRC_BT2020_12:
|
||||
case AVCOL_TRC_ARIB_STD_B67: // 18 HLG
|
||||
eotf = EOTF_HLG;
|
||||
break;
|
||||
case AVCOL_TRC_SMPTE2084: // 16
|
||||
eotf = EOTF_ST2084;
|
||||
break;
|
||||
default:
|
||||
eotf = EOTF_TRADITIONAL_GAMMA_SDR;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (color) {
|
||||
case AVCOL_PRI_BT709: // 1
|
||||
case AVCOL_PRI_UNSPECIFIED: // 2
|
||||
cs = weston_colorspace_lookup("BT.709");
|
||||
break;
|
||||
case AVCOL_PRI_BT2020: // 9
|
||||
cs = weston_colorspace_lookup("BT.2020");
|
||||
break;
|
||||
case AVCOL_PRI_BT470BG: // 5
|
||||
cs = weston_colorspace_lookup("BT.470 B/G"); // BT.601
|
||||
break;
|
||||
default:
|
||||
cs = weston_colorspace_lookup("BT.709");
|
||||
break;
|
||||
}
|
||||
|
||||
if (md) { // we got Metadata
|
||||
if (md->has_primaries) {
|
||||
Debug(3,"Mastering Display Metadata,\n has_primaries:%d has_luminance:%d \n"
|
||||
"r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f) \n"
|
||||
"min_luminance=%f, max_luminance=%f\n",
|
||||
md->has_primaries, md->has_luminance,
|
||||
av_q2d(md->display_primaries[0][0]),
|
||||
av_q2d(md->display_primaries[0][1]),
|
||||
av_q2d(md->display_primaries[1][0]),
|
||||
av_q2d(md->display_primaries[1][1]),
|
||||
av_q2d(md->display_primaries[2][0]),
|
||||
av_q2d(md->display_primaries[2][1]),
|
||||
av_q2d(md->white_point[0]), av_q2d(md->white_point[1]),
|
||||
av_q2d(md->min_luminance), av_q2d(md->max_luminance));
|
||||
|
||||
cs = &hdr10;
|
||||
cs->r.f[0] = (float)md->display_primaries[0][0].num / (float)md->display_primaries[0][0].den;
|
||||
cs->r.f[1] = (float)md->display_primaries[0][1].num / (float)md->display_primaries[0][1].den;
|
||||
cs->g.f[0] = (float)md->display_primaries[1][0].num / (float)md->display_primaries[1][0].den;
|
||||
cs->g.f[1] = (float)md->display_primaries[1][1].num / (float)md->display_primaries[1][1].den;
|
||||
cs->b.f[0] = (float)md->display_primaries[2][0].num / (float)md->display_primaries[2][0].den;
|
||||
cs->b.f[1] = (float)md->display_primaries[2][1].num / (float)md->display_primaries[2][1].den;
|
||||
cs->whitepoint.f[0] = (float)md->white_point[0].num / (float)md->white_point[0].den;
|
||||
cs->whitepoint.f[1] = (float)md->white_point[1].num / (float)md->white_point[1].den;
|
||||
}
|
||||
if (md->has_luminance) {
|
||||
max_lum = av_q2d(md->max_luminance);
|
||||
min_lum = av_q2d(md->min_luminance) * 10000 ;
|
||||
printf("max_lum %d min_lum %d\n",max_lum,min_lum);
|
||||
}
|
||||
}
|
||||
if (ld) {
|
||||
Debug(3,"Has MaxCLL %d MaxFALL %d\n",ld->MaxCLL,ld->MaxFALL);
|
||||
MaxCLL = ld->MaxCLL;
|
||||
MaxFALL = ld->MaxFALL;
|
||||
}
|
||||
data.metadata_type = 7; // ????????????????????????
|
||||
weston_hdr_metadata(&data.hdmi_metadata_type1,
|
||||
encode_xyy(cs->r.f[0]),
|
||||
encode_xyy(cs->r.f[1]),
|
||||
encode_xyy(cs->g.f[0]),
|
||||
encode_xyy(cs->g.f[1]),
|
||||
encode_xyy(cs->b.f[0]),
|
||||
encode_xyy(cs->b.f[1]),
|
||||
encode_xyy(cs->whitepoint.f[0]),
|
||||
encode_xyy(cs->whitepoint.f[1]),
|
||||
max_lum, // max_display_mastering_luminance
|
||||
min_lum, // min_display_mastering_luminance
|
||||
MaxCLL, // Maximum Content Light Level (MaxCLL)
|
||||
MaxFALL, // Maximum Frame-Average Light Level (MaxFALL)
|
||||
eotf);
|
||||
|
||||
|
||||
|
||||
ret = drmModeCreatePropertyBlob(render->fd_drm, &data, sizeof(data), &render->hdr_blob_id);
|
||||
if (ret) {
|
||||
printf("DRM: HDR metadata: failed blob create \n");
|
||||
render->hdr_blob_id = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
ret = drmModeConnectorSetProperty(render->fd_drm, render->connector_id,
|
||||
render->hdr_metadata, render->hdr_blob_id);
|
||||
if (ret) {
|
||||
printf("DRM: HDR metadata: failed property set %d\n",ret);
|
||||
|
||||
if (render->hdr_blob_id)
|
||||
drmModeDestroyPropertyBlob(render->fd_drm, render->hdr_blob_id);
|
||||
render->hdr_blob_id = 0;
|
||||
return;
|
||||
}
|
||||
m_need_modeset = 1;
|
||||
|
||||
Debug(3,"DRM: HDR metadata: prop set\n");
|
||||
|
||||
}
|
||||
|
281
openglosd.cpp
281
openglosd.cpp
@@ -21,107 +21,17 @@ void ConvertColor(const GLint &colARGB, glm::vec4 &col) {
|
||||
****************************************************************************************/
|
||||
|
||||
#ifdef CUVID
|
||||
const char *rectVertexShader =
|
||||
"#version 330 core \n\
|
||||
\
|
||||
layout (location = 0) in vec2 position; \
|
||||
out vec4 rectCol; \
|
||||
uniform vec4 inColor; \
|
||||
uniform mat4 projection; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
gl_Position = projection * vec4(position.x, position.y, 0.0, 1.0); \
|
||||
rectCol = inColor; \
|
||||
} \
|
||||
";
|
||||
|
||||
const char *rectFragmentShader =
|
||||
"#version 330 core \n\
|
||||
\
|
||||
in vec4 rectCol; \
|
||||
out vec4 color; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
color = rectCol; \
|
||||
} \
|
||||
";
|
||||
|
||||
const char *textureVertexShader =
|
||||
"#version 330 core \n\
|
||||
\
|
||||
layout (location = 0) in vec2 position; \
|
||||
layout (location = 1) in vec2 texCoords; \
|
||||
\
|
||||
out vec2 TexCoords; \
|
||||
out vec4 alphaValue;\
|
||||
\
|
||||
uniform mat4 projection; \
|
||||
uniform vec4 alpha; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
gl_Position = projection * vec4(position.x, position.y, 0.0, 1.0); \
|
||||
TexCoords = texCoords; \
|
||||
alphaValue = alpha; \
|
||||
} \
|
||||
";
|
||||
|
||||
const char *textureFragmentShader =
|
||||
"#version 330 core \n\
|
||||
in vec2 TexCoords; \
|
||||
in vec4 alphaValue; \
|
||||
out vec4 color; \
|
||||
\
|
||||
uniform sampler2D screenTexture; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
color = texture(screenTexture, TexCoords) * alphaValue; \
|
||||
} \
|
||||
";
|
||||
|
||||
const char *textVertexShader =
|
||||
"#version 330 core \n\
|
||||
\
|
||||
layout (location = 0) in vec2 position; \
|
||||
layout (location = 1) in vec2 texCoords; \
|
||||
\
|
||||
out vec2 TexCoords; \
|
||||
out vec4 textColor; \
|
||||
\
|
||||
uniform mat4 projection; \
|
||||
uniform vec4 inColor; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
gl_Position = projection * vec4(position.x, position.y, 0.0, 1.0); \
|
||||
TexCoords = texCoords; \
|
||||
textColor = inColor; \
|
||||
} \
|
||||
";
|
||||
|
||||
const char *textFragmentShader =
|
||||
"#version 330 core \n\
|
||||
in vec2 TexCoords; \
|
||||
in vec4 textColor; \
|
||||
\
|
||||
out vec4 color; \
|
||||
\
|
||||
uniform sampler2D glyphTexture; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
vec4 sampled = vec4(1.0, 1.0, 1.0, texture(glyphTexture, TexCoords).r); \
|
||||
color = textColor * sampled; \
|
||||
} \
|
||||
";
|
||||
|
||||
const char *glversion = "#version 330 core ";
|
||||
#else
|
||||
#ifdef RASPI
|
||||
const char *glversion = "#version 300 es";
|
||||
#else
|
||||
const char *glversion = "#version 300 es ";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
const char *rectVertexShader =
|
||||
"\n \
|
||||
"%s\n \
|
||||
\
|
||||
layout (location = 0) in vec2 position; \
|
||||
out vec4 rectCol; \
|
||||
@@ -136,7 +46,7 @@ void main() \
|
||||
";
|
||||
|
||||
const char *rectFragmentShader =
|
||||
"\n \
|
||||
"%s\n \
|
||||
\
|
||||
precision mediump float; \
|
||||
in vec4 rectCol; \
|
||||
@@ -149,7 +59,7 @@ void main() \
|
||||
";
|
||||
|
||||
const char *textureVertexShader =
|
||||
"\n \
|
||||
"%s\n \
|
||||
\
|
||||
layout (location = 0) in vec2 position; \
|
||||
layout (location = 1) in vec2 texCoords; \
|
||||
@@ -169,7 +79,7 @@ void main() \
|
||||
";
|
||||
|
||||
const char *textureFragmentShader =
|
||||
"\n \
|
||||
"%s\n \
|
||||
precision mediump float; \
|
||||
in vec2 TexCoords; \
|
||||
in vec4 alphaValue; \
|
||||
@@ -184,7 +94,7 @@ void main() \
|
||||
";
|
||||
|
||||
const char *textVertexShader =
|
||||
"\n \
|
||||
"%s\n \
|
||||
\
|
||||
layout (location = 0) in vec2 position; \
|
||||
layout (location = 1) in vec2 texCoords; \
|
||||
@@ -204,7 +114,7 @@ void main() \
|
||||
";
|
||||
|
||||
const char *textFragmentShader =
|
||||
"\n \
|
||||
"%s\n \
|
||||
precision mediump float; \
|
||||
in vec2 TexCoords; \
|
||||
in vec4 textColor; \
|
||||
@@ -219,7 +129,19 @@ void main() \
|
||||
color = textColor * sampled; \
|
||||
} \
|
||||
";
|
||||
#endif
|
||||
|
||||
///
|
||||
/// GLX check error.
|
||||
///
|
||||
#define GlxCheck(void)\
|
||||
{\
|
||||
GLenum err;\
|
||||
\
|
||||
if ((err = glGetError()) != GL_NO_ERROR) {\
|
||||
esyslog( "video/glx: error %s:%d %d '%s'\n",__FILE__,__LINE__, err, gluErrorString(err));\
|
||||
}\
|
||||
}
|
||||
|
||||
static cShader *Shaders[stCount];
|
||||
|
||||
void cShader::Use(void) {
|
||||
@@ -288,20 +210,27 @@ void cShader::SetMatrix4(const GLchar *name, const glm::mat4 &matrix) {
|
||||
|
||||
bool cShader::Compile(const char *vertexCode, const char *fragmentCode) {
|
||||
GLuint sVertex, sFragment;
|
||||
char *buffer = (char *)malloc(1000);
|
||||
// Vertex Shader
|
||||
sVertex = glCreateShader(GL_VERTEX_SHADER);
|
||||
glShaderSource(sVertex, 1, &vertexCode, NULL);
|
||||
sprintf(buffer,vertexCode,glversion);
|
||||
glShaderSource(sVertex, 1, (const GLchar**) &buffer, NULL);
|
||||
glCompileShader(sVertex);
|
||||
// esyslog("[softhddev]:SHADER:VERTEX %s\n",vertexCode);
|
||||
if (!CheckCompileErrors(sVertex))
|
||||
if (!CheckCompileErrors(sVertex)) {
|
||||
free(buffer);
|
||||
return false;
|
||||
}
|
||||
// Fragment Shader
|
||||
sFragment = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
glShaderSource(sFragment, 1, &fragmentCode, NULL);
|
||||
sprintf(buffer,fragmentCode,glversion);
|
||||
glShaderSource(sFragment, 1, (const GLchar**)&buffer, NULL);
|
||||
glCompileShader(sFragment);
|
||||
// esyslog("[softhddev]:SHADER:FRAGMENT %s\n",fragmentCode);
|
||||
if (!CheckCompileErrors(sFragment))
|
||||
if (!CheckCompileErrors(sFragment)) {
|
||||
free(buffer);
|
||||
return false;
|
||||
}
|
||||
// link Program
|
||||
id = glCreateProgram();
|
||||
glAttachShader(id, sVertex);
|
||||
@@ -312,6 +241,7 @@ bool cShader::Compile(const char *vertexCode, const char *fragmentCode) {
|
||||
// Delete the shaders as they're linked into our program now and no longer necessery
|
||||
glDeleteShader(sVertex);
|
||||
glDeleteShader(sFragment);
|
||||
free(buffer);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -322,14 +252,14 @@ bool cShader::CheckCompileErrors(GLuint object, bool program) {
|
||||
glGetShaderiv(object, GL_COMPILE_STATUS, &success);
|
||||
if (!success) {
|
||||
glGetShaderInfoLog(object, 1024, NULL, infoLog);
|
||||
esyslog("[softhddev]:SHADER: Compile-time error: Type: %d - \n%s\n", type, infoLog);
|
||||
esyslog("\n[softhddev]:SHADER: Compile-time error: Type: %d - \n>%s<\n", type, infoLog);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
glGetProgramiv(object, GL_LINK_STATUS, &success);
|
||||
if (!success) {
|
||||
glGetProgramInfoLog(object, 1024, NULL, infoLog);
|
||||
esyslog("[softhddev]:SHADER: Link-time error: Type: %d - \n%s\n", type, infoLog);
|
||||
esyslog("[softhddev]:SHADER: Link-time error: Type: %d - \n>%s<\n", type, infoLog);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -340,7 +270,7 @@ bool cShader::CheckCompileErrors(GLuint object, bool program) {
|
||||
/****************************************************************************************
|
||||
* cOglGlyph
|
||||
****************************************************************************************/
|
||||
cOglGlyph::cOglGlyph(uint charCode, FT_BitmapGlyph ftGlyph) {
|
||||
cOglGlyph::cOglGlyph(FT_ULong charCode, FT_BitmapGlyph ftGlyph) {
|
||||
this->charCode = charCode;
|
||||
bearingLeft = ftGlyph->left;
|
||||
bearingTop = ftGlyph->top;
|
||||
@@ -354,7 +284,7 @@ cOglGlyph::~cOglGlyph(void) {
|
||||
|
||||
}
|
||||
|
||||
int cOglGlyph::GetKerningCache(uint prevSym) {
|
||||
int cOglGlyph::GetKerningCache(FT_ULong prevSym) {
|
||||
for (int i = kerningCache.Size(); --i > 0; ) {
|
||||
if (kerningCache[i].prevSym == prevSym)
|
||||
return kerningCache[i].kerning;
|
||||
@@ -362,7 +292,7 @@ int cOglGlyph::GetKerningCache(uint prevSym) {
|
||||
return KERNING_UNKNOWN;
|
||||
}
|
||||
|
||||
void cOglGlyph::SetKerningCache(uint prevSym, int kerning) {
|
||||
void cOglGlyph::SetKerningCache(FT_ULong prevSym, int kerning) {
|
||||
kerningCache.Append(tKerning(prevSym, kerning));
|
||||
}
|
||||
|
||||
@@ -398,7 +328,10 @@ void cOglGlyph::LoadTexture(FT_BitmapGlyph ftGlyph) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
extern "C" void GlxInitopengl();
|
||||
extern "C" void GlxDrawopengl();
|
||||
extern "C" void GlxDestroy();
|
||||
extern "C" void makejpg(uint8_t *data, int width, int height);
|
||||
/****************************************************************************************
|
||||
* cOglFont
|
||||
****************************************************************************************/
|
||||
@@ -439,9 +372,12 @@ cOglFont *cOglFont::Get(const char *name, int charHeight) {
|
||||
}
|
||||
|
||||
void cOglFont::Init(void) {
|
||||
fonts = new cList<cOglFont>;
|
||||
if (FT_Init_FreeType(&ftLib))
|
||||
|
||||
if (FT_Init_FreeType(&ftLib)) {
|
||||
esyslog("[softhddev]failed to initialize FreeType library!");
|
||||
return;
|
||||
}
|
||||
fonts = new cList<cOglFont>;
|
||||
initiated = true;
|
||||
}
|
||||
|
||||
@@ -454,7 +390,7 @@ void cOglFont::Cleanup(void) {
|
||||
esyslog("failed to deinitialize FreeType library!");
|
||||
}
|
||||
|
||||
cOglGlyph* cOglFont::Glyph(uint charCode) const {
|
||||
cOglGlyph* cOglFont::Glyph(FT_ULong charCode) const {
|
||||
// Non-breaking space:
|
||||
if (charCode == 0xA0)
|
||||
charCode = 0x20;
|
||||
@@ -517,7 +453,7 @@ cOglGlyph* cOglFont::Glyph(uint charCode) const {
|
||||
return Glyph;
|
||||
}
|
||||
|
||||
int cOglFont::Kerning(cOglGlyph *glyph, uint prevSym) const {
|
||||
int cOglFont::Kerning(cOglGlyph *glyph, FT_ULong prevSym) const {
|
||||
int kerning = 0;
|
||||
if (glyph && prevSym) {
|
||||
kerning = glyph->GetKerningCache(prevSym);
|
||||
@@ -540,6 +476,7 @@ cOglFb::cOglFb(GLint width, GLint height, GLint viewPortWidth, GLint viewPortHei
|
||||
initiated = false;
|
||||
fb = 0;
|
||||
texture = 0;
|
||||
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
this->viewPortWidth = viewPortWidth;
|
||||
@@ -560,8 +497,7 @@ cOglFb::~cOglFb(void) {
|
||||
|
||||
bool cOglFb::Init(void) {
|
||||
initiated = true;
|
||||
|
||||
glGenTextures(1, &texture);
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
@@ -835,6 +771,7 @@ cOglCmdRenderFbToBufferFb::cOglCmdRenderFbToBufferFb(cOglFb *fb, cOglFb *buffer,
|
||||
this->drawPortX = (GLfloat)drawPortX;
|
||||
this->drawPortY = (GLfloat)drawPortY;
|
||||
this->transparency = transparency;
|
||||
|
||||
}
|
||||
|
||||
bool cOglCmdRenderFbToBufferFb::Execute(void) {
|
||||
@@ -845,15 +782,15 @@ bool cOglCmdRenderFbToBufferFb::Execute(void) {
|
||||
GLfloat texY1 = drawPortY / (GLfloat)fb->Height();
|
||||
GLfloat texX2 = texX1 + 1.0f;
|
||||
GLfloat texY2 = texY1 + 1.0f;
|
||||
|
||||
|
||||
if (fb->Scrollable()) {
|
||||
GLfloat pageHeight = (GLfloat)fb->ViewportHeight() / (GLfloat)fb->Height();
|
||||
texX1 = abs(drawPortX) / (GLfloat)fb->Width();
|
||||
texY1 = 1.0f - pageHeight - abs(drawPortY) / (GLfloat)fb->Height();
|
||||
texX2 = texX1 + (GLfloat)fb->ViewportWidth() / (GLfloat)fb->Width();
|
||||
// x2 = x + fb->Width();
|
||||
texY2 = texY1 + pageHeight;
|
||||
}
|
||||
|
||||
GLfloat quadVertices[] = {
|
||||
// Pos // TexCoords
|
||||
x , y , texX1, texY2, //left top
|
||||
@@ -870,9 +807,11 @@ bool cOglCmdRenderFbToBufferFb::Execute(void) {
|
||||
VertexBuffers[vbTexture]->SetShaderProjectionMatrix(buffer->Width(), buffer->Height());
|
||||
|
||||
buffer->Bind();
|
||||
|
||||
if (!fb->BindTexture())
|
||||
return false;
|
||||
VertexBuffers[vbTexture]->Bind();
|
||||
|
||||
VertexBuffers[vbTexture]->Bind();
|
||||
VertexBuffers[vbTexture]->SetVertexData(quadVertices);
|
||||
VertexBuffers[vbTexture]->DrawArrays();
|
||||
VertexBuffers[vbTexture]->Unbind();
|
||||
@@ -891,26 +830,18 @@ cOglCmdCopyBufferToOutputFb::cOglCmdCopyBufferToOutputFb(cOglFb *fb, cOglOutputF
|
||||
extern unsigned char *posd;
|
||||
|
||||
bool cOglCmdCopyBufferToOutputFb::Execute(void) {
|
||||
int i;
|
||||
|
||||
pthread_mutex_lock(&OSDMutex);
|
||||
fb->BindRead();
|
||||
oFb->BindWrite();
|
||||
// glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
//#ifdef PLACEBO
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
if (posd)
|
||||
glReadPixels(0, 0 ,fb->Width(), fb->Height(),GL_RGBA,GL_UNSIGNED_BYTE,posd);
|
||||
//#else
|
||||
#if 0
|
||||
fb->Blit(x, y + fb->Height(), x + fb->Width(), y);
|
||||
glFlush();
|
||||
#endif
|
||||
ActivateOsd(oFb->texture,x, y, fb->Width() ,fb->Height());
|
||||
oFb->Unbind();
|
||||
pthread_mutex_unlock(&OSDMutex);
|
||||
glFlush();
|
||||
|
||||
pthread_mutex_unlock(&OSDMutex);
|
||||
ActivateOsd(oFb->texture,x, y, fb->Width() ,fb->Height());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1245,6 +1176,7 @@ cOglCmdDrawText::cOglCmdDrawText( cOglFb *fb, GLint x, GLint y, unsigned int *sy
|
||||
this->colorText = colorText;
|
||||
this->fontSize = fontSize;
|
||||
this->symbols = symbols;
|
||||
this->fontName = name;
|
||||
}
|
||||
|
||||
cOglCmdDrawText::~cOglCmdDrawText(void) {
|
||||
@@ -1266,19 +1198,20 @@ bool cOglCmdDrawText::Execute(void) {
|
||||
int xGlyph = x;
|
||||
int fontHeight = f->Height();
|
||||
int bottom = f->Bottom();
|
||||
uint sym = 0;
|
||||
uint prevSym = 0;
|
||||
FT_ULong sym = 0;
|
||||
FT_ULong prevSym = 0;
|
||||
int kerning = 0;
|
||||
|
||||
for (int i = 0; symbols[i]; i++) {
|
||||
sym = symbols[i];
|
||||
cOglGlyph *g = f->Glyph(sym);
|
||||
if (!g) {
|
||||
esyslog("[softhddev]ERROR: could not load glyph %x", sym);
|
||||
esyslog("[softhddev]ERROR: could not load glyph %lx", sym);
|
||||
}
|
||||
|
||||
if ( limitX && xGlyph + g->AdvanceX() > limitX )
|
||||
if ( limitX && xGlyph + g->AdvanceX() > limitX ) {
|
||||
break;
|
||||
}
|
||||
|
||||
kerning = f->Kerning(g, prevSym);
|
||||
prevSym = sym;
|
||||
@@ -1307,7 +1240,6 @@ bool cOglCmdDrawText::Execute(void) {
|
||||
if ( xGlyph > fb->Width() - 1 )
|
||||
break;
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
VertexBuffers[vbText]->Unbind();
|
||||
fb->Unbind();
|
||||
@@ -1324,6 +1256,7 @@ cOglCmdDrawImage::cOglCmdDrawImage(cOglFb *fb, tColor *argb, GLint width, GLint
|
||||
this->overlay = overlay;
|
||||
this->scaleX = scaleX;
|
||||
this->scaleY = scaleY;
|
||||
|
||||
}
|
||||
|
||||
cOglCmdDrawImage::~cOglCmdDrawImage(void) {
|
||||
@@ -1332,7 +1265,11 @@ cOglCmdDrawImage::~cOglCmdDrawImage(void) {
|
||||
|
||||
bool cOglCmdDrawImage::Execute(void) {
|
||||
GLuint texture;
|
||||
|
||||
#ifdef USE_DRM
|
||||
// pthread_mutex_lock(&OSDMutex);
|
||||
GlxDrawopengl(); // here we need the Shared Context for upload
|
||||
GlxCheck();
|
||||
#endif
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glTexImage2D(
|
||||
@@ -1351,7 +1288,12 @@ bool cOglCmdDrawImage::Execute(void) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
glFlush();
|
||||
#ifdef USE_DRM
|
||||
GlxInitopengl(); // Reset Context
|
||||
GlxCheck();
|
||||
// pthread_mutex_unlock(&OSDMutex);
|
||||
#endif
|
||||
|
||||
GLfloat x1 = x; //left
|
||||
GLfloat y1 = y; //top
|
||||
@@ -1441,7 +1383,11 @@ cOglCmdStoreImage::~cOglCmdStoreImage(void) {
|
||||
}
|
||||
|
||||
bool cOglCmdStoreImage::Execute(void) {
|
||||
|
||||
#ifdef USE_DRM
|
||||
// pthread_mutex_lock(&OSDMutex);
|
||||
GlxDrawopengl(); // here we need the Shared Context for upload
|
||||
GlxCheck();
|
||||
#endif
|
||||
glGenTextures(1, &imageRef->texture);
|
||||
glBindTexture(GL_TEXTURE_2D, imageRef->texture);
|
||||
glTexImage2D(
|
||||
@@ -1460,7 +1406,12 @@ bool cOglCmdStoreImage::Execute(void) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
glFlush();
|
||||
#ifdef USE_DRM
|
||||
GlxInitopengl(); // Reset Context
|
||||
GlxCheck();
|
||||
// pthread_mutex_lock(&OSDMutex);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1483,6 +1434,7 @@ bool cOglCmdDropImage::Execute(void) {
|
||||
cOglThread::cOglThread(cCondWait *startWait, int maxCacheSize) : cThread("oglThread") {
|
||||
stalled = false;
|
||||
memCached = 0;
|
||||
|
||||
this->maxCacheSize = maxCacheSize * 1024 * 1024;
|
||||
this->startWait = startWait;
|
||||
wait = new cCondWait();
|
||||
@@ -1495,6 +1447,7 @@ cOglThread::cOglThread(cCondWait *startWait, int maxCacheSize) : cThread("oglThr
|
||||
}
|
||||
|
||||
Start();
|
||||
|
||||
}
|
||||
|
||||
cOglThread::~cOglThread() {
|
||||
@@ -1532,6 +1485,10 @@ void cOglThread::DoCmd(cOglCmd* cmd) {
|
||||
}
|
||||
|
||||
int cOglThread::StoreImage(const cImage &image) {
|
||||
|
||||
if (!maxCacheSize) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (image.Width() > maxTextureSize || image.Height() > maxTextureSize) {
|
||||
esyslog("[softhddev] cannot store image of %dpx x %dpx "
|
||||
@@ -1693,13 +1650,12 @@ void cOglThread::Action(void) {
|
||||
dsyslog("[softhddev]OpenGL Worker Thread Ended");
|
||||
}
|
||||
|
||||
extern "C" int GlxInitopengl();
|
||||
|
||||
|
||||
|
||||
|
||||
bool cOglThread::InitOpenGL(void) {
|
||||
|
||||
#ifdef USE_DRM
|
||||
GlxInitopengl();
|
||||
#else
|
||||
const char *displayName = X11DisplayName;
|
||||
if (!displayName) {
|
||||
displayName = getenv("DISPLAY");
|
||||
@@ -1732,7 +1688,8 @@ bool cOglThread::InitOpenGL(void) {
|
||||
esyslog("[softhddev]glewInit failed, aborting\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
VertexBuffers[vbText]->EnableBlending();
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
return true;
|
||||
@@ -1794,8 +1751,11 @@ void cOglThread::Cleanup(void) {
|
||||
DeleteShaders();
|
||||
// glVDPAUFiniNV();
|
||||
cOglFont::Cleanup();
|
||||
#ifndef USE_DRM
|
||||
glutExit();
|
||||
|
||||
#else
|
||||
GlxDestroy();
|
||||
#endif
|
||||
pthread_mutex_unlock(&OSDMutex);
|
||||
}
|
||||
|
||||
@@ -1868,7 +1828,6 @@ void cOglPixmap::DrawImage(const cPoint &Point, const cImage &Image) {
|
||||
memcpy(argb, Image.Data(), sizeof(tColor) * Image.Width() * Image.Height());
|
||||
|
||||
oglThread->DoCmd(new cOglCmdDrawImage(fb, argb, Image.Width(), Image.Height(), Point.X(), Point.Y()));
|
||||
|
||||
SetDirty();
|
||||
MarkDrawPortDirty(cRect(Point, cSize(Image.Width(), Image.Height())).Intersected(DrawPort().Size()));
|
||||
}
|
||||
@@ -1876,6 +1835,7 @@ void cOglPixmap::DrawImage(const cPoint &Point, const cImage &Image) {
|
||||
void cOglPixmap::DrawImage(const cPoint &Point, int ImageHandle) {
|
||||
if (!oglThread->Active())
|
||||
return;
|
||||
|
||||
if (ImageHandle < 0 && oglThread->GetImageRef(ImageHandle)) {
|
||||
sOglImage *img = oglThread->GetImageRef(ImageHandle);
|
||||
oglThread->DoCmd(new cOglCmdDrawTexture(fb, img, Point.X(), Point.Y()));
|
||||
@@ -1916,6 +1876,7 @@ void cOglPixmap::DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor C
|
||||
(index == 0 ? ColorBg : index == 1 ? ColorFg :
|
||||
Bitmap.Color(index)) : Bitmap.Color(index));
|
||||
}
|
||||
|
||||
oglThread->DoCmd(new cOglCmdDrawImage(fb, argb, Bitmap.Width(), Bitmap.Height(), Point.X(), Point.Y(), Overlay));
|
||||
SetDirty();
|
||||
MarkDrawPortDirty(cRect(Point, cSize(Bitmap.Width(), Bitmap.Height())).Intersected(DrawPort().Size()));
|
||||
@@ -1934,7 +1895,6 @@ void cOglPixmap::DrawText(const cPoint &Point, const char *s, tColor ColorFg, tC
|
||||
Utf8ToArray(s, symbols, len + 1);
|
||||
else
|
||||
symbols[0] = 0;
|
||||
|
||||
int x = Point.X();
|
||||
int y = Point.Y();
|
||||
int w = Font->Width(s);
|
||||
@@ -2037,17 +1997,18 @@ cOglOsd::cOglOsd(int Left, int Top, uint Level, std::shared_ptr<cOglThread> oglT
|
||||
int osdWidth = 0;
|
||||
int osdHeight = 0;
|
||||
|
||||
pthread_mutex_lock(&OSDMutex);
|
||||
// pthread_mutex_lock(&OSDMutex);
|
||||
VideoGetOsdSize(&osdWidth, &osdHeight);
|
||||
// osdWidth = 1920;
|
||||
// osdHeight = 1080;
|
||||
|
||||
dsyslog("[softhddev]cOglOsd osdLeft %d osdTop %d screenWidth %d screenHeight %d", Left, Top, osdWidth, osdHeight);
|
||||
|
||||
#if 0
|
||||
if (posd)
|
||||
free(posd);
|
||||
posd = MALLOC(unsigned char, osdWidth * osdHeight * 4);
|
||||
|
||||
posd = (unsigned char *)calloc( osdWidth * osdHeight * 4, 1 );
|
||||
#endif
|
||||
// create output framebuffer
|
||||
|
||||
if (!oFb) {
|
||||
@@ -2055,17 +2016,13 @@ cOglOsd::cOglOsd(int Left, int Top, uint Level, std::shared_ptr<cOglThread> oglT
|
||||
oglThread->DoCmd(new cOglCmdInitOutputFb(oFb));
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&OSDMutex);
|
||||
// pthread_mutex_unlock(&OSDMutex);
|
||||
}
|
||||
|
||||
cOglOsd::~cOglOsd() {
|
||||
OsdClose();
|
||||
SetActive(false);
|
||||
|
||||
if (posd)
|
||||
free(posd);
|
||||
posd = 0;
|
||||
|
||||
oglThread->DoCmd(new cOglCmdDeleteFb(bFb));
|
||||
}
|
||||
|
||||
@@ -2125,6 +2082,7 @@ void cOglOsd::DestroyPixmap(cPixmap *Pixmap) {
|
||||
return;
|
||||
if (!Pixmap)
|
||||
return;
|
||||
|
||||
LOCK_PIXMAPS;
|
||||
int start = 1;
|
||||
if (isSubtitleOsd)
|
||||
@@ -2166,7 +2124,7 @@ void cOglOsd::Flush(void) {
|
||||
oglThread->DoCmd(new cOglCmdRenderFbToBufferFb( oglPixmaps[i]->Fb(),
|
||||
bFb,
|
||||
oglPixmaps[i]->ViewPort().X(),
|
||||
(!isSubtitleOsd) ? oglPixmaps[i]->ViewPort().Y() : 0,
|
||||
(!isSubtitleOsd) ? oglPixmaps[i]->ViewPort().Y() : 0,
|
||||
oglPixmaps[i]->Alpha(),
|
||||
oglPixmaps[i]->DrawPort().X(),
|
||||
oglPixmaps[i]->DrawPort().Y()));
|
||||
@@ -2187,3 +2145,4 @@ void cOglOsd::DrawScaledBitmap(int x, int y, const cBitmap &Bitmap, double Facto
|
||||
int yNew = y - oglPixmaps[0]->ViewPort().Y();
|
||||
oglPixmaps[0]->DrawBitmap(cPoint(x, yNew), Bitmap);
|
||||
}
|
||||
|
||||
|
18
openglosd.h
18
openglosd.h
@@ -103,14 +103,14 @@ class cOglGlyph:public cListObject
|
||||
struct tKerning
|
||||
{
|
||||
public:
|
||||
tKerning(uint prevSym, GLfloat kerning = 0.0f) {
|
||||
tKerning(FT_ULong prevSym, GLfloat kerning = 0.0f) {
|
||||
this->prevSym = prevSym;
|
||||
this->kerning = kerning;
|
||||
}
|
||||
uint prevSym;
|
||||
FT_ULong prevSym;
|
||||
GLfloat kerning;
|
||||
};
|
||||
uint charCode;
|
||||
FT_ULong charCode;
|
||||
int bearingLeft;
|
||||
int bearingTop;
|
||||
int width;
|
||||
@@ -122,9 +122,9 @@ class cOglGlyph:public cListObject
|
||||
void LoadTexture(FT_BitmapGlyph ftGlyph);
|
||||
|
||||
public:
|
||||
cOglGlyph(uint charCode, FT_BitmapGlyph ftGlyph);
|
||||
cOglGlyph(FT_ULong charCode, FT_BitmapGlyph ftGlyph);
|
||||
virtual ~ cOglGlyph();
|
||||
uint CharCode(void)
|
||||
FT_ULong CharCode(void)
|
||||
{
|
||||
return charCode;
|
||||
}
|
||||
@@ -148,8 +148,8 @@ class cOglGlyph:public cListObject
|
||||
{
|
||||
return height;
|
||||
}
|
||||
int GetKerningCache(uint prevSym);
|
||||
void SetKerningCache(uint prevSym, int kerning);
|
||||
int GetKerningCache(FT_ULong prevSym);
|
||||
void SetKerningCache(FT_ULong prevSym, int kerning);
|
||||
void BindTexture(void);
|
||||
};
|
||||
|
||||
@@ -190,8 +190,8 @@ class cOglFont:public cListObject
|
||||
{
|
||||
return height;
|
||||
};
|
||||
cOglGlyph *Glyph(uint charCode) const;
|
||||
int Kerning(cOglGlyph * glyph, uint prevSym) const;
|
||||
cOglGlyph *Glyph(FT_ULong charCode) const;
|
||||
int Kerning(cOglGlyph * glyph, FT_ULong prevSym) const;
|
||||
};
|
||||
|
||||
/****************************************************************************************
|
||||
|
312
patches/HDR-for-LSPCON.patch
Normal file
312
patches/HDR-for-LSPCON.patch
Normal file
@@ -0,0 +1,312 @@
|
||||
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
|
||||
index 8358152e403e..573ab6ea1a6e 100644
|
||||
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
|
||||
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
|
||||
@@ -1274,6 +1274,7 @@ struct intel_lspcon {
|
||||
bool active;
|
||||
enum drm_lspcon_mode mode;
|
||||
enum lspcon_vendor vendor;
|
||||
+ bool hdr_supported;
|
||||
};
|
||||
|
||||
struct intel_digital_port {
|
||||
diff --git a/drivers/gpu/drm/i915/display/intel_lspcon.c b/drivers/gpu/drm/i915/display/intel_lspcon.c
|
||||
index f8f1308643a9..a1d0127b7f57 100644
|
||||
--- a/drivers/gpu/drm/i915/display/intel_lspcon.c
|
||||
+++ b/drivers/gpu/drm/i915/display/intel_lspcon.c
|
||||
@@ -35,6 +35,8 @@
|
||||
#define LSPCON_VENDOR_PARADE_OUI 0x001CF8
|
||||
#define LSPCON_VENDOR_MCA_OUI 0x0060AD
|
||||
|
||||
+#define DPCD_MCA_LSPCON_HDR_STATUS 0x70003
|
||||
+
|
||||
/* AUX addresses to write MCA AVI IF */
|
||||
#define LSPCON_MCA_AVI_IF_WRITE_OFFSET 0x5C0
|
||||
#define LSPCON_MCA_AVI_IF_CTRL 0x5DF
|
||||
@@ -104,6 +106,31 @@ static bool lspcon_detect_vendor(struct intel_lspcon *lspcon)
|
||||
return true;
|
||||
}
|
||||
|
||||
+static bool lspcon_detect_hdr_capability(struct intel_lspcon *lspcon)
|
||||
+{
|
||||
+ struct intel_dp *dp = lspcon_to_intel_dp(lspcon);
|
||||
+ u8 hdr_caps;
|
||||
+ int ret;
|
||||
+
|
||||
+ /* Enable HDR for MCA based LSPCON devices */
|
||||
+ if (lspcon->vendor == LSPCON_VENDOR_MCA)
|
||||
+ ret = drm_dp_dpcd_read(&dp->aux, DPCD_MCA_LSPCON_HDR_STATUS,
|
||||
+ &hdr_caps, 1);
|
||||
+ else
|
||||
+ return false;
|
||||
+
|
||||
+ if (ret < 0) {
|
||||
+ DRM_DEBUG_KMS("hdr capability detection failed\n");
|
||||
+ lspcon->hdr_supported = false;
|
||||
+ return false;
|
||||
+ } else if (hdr_caps & 0x1) {
|
||||
+ DRM_DEBUG_KMS("lspcon capable of HDR\n");
|
||||
+ lspcon->hdr_supported = true;
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
static enum drm_lspcon_mode lspcon_get_current_mode(struct intel_lspcon *lspcon)
|
||||
{
|
||||
enum drm_lspcon_mode current_mode;
|
||||
@@ -581,6 +608,11 @@ bool lspcon_init(struct intel_digital_port *intel_dig_port)
|
||||
return false;
|
||||
}
|
||||
|
||||
+ if (!lspcon_detect_hdr_capability(lspcon)) {
|
||||
+ DRM_ERROR("LSPCON hdr detection failed\n");
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
connector->ycbcr_420_allowed = true;
|
||||
lspcon->active = true;
|
||||
DRM_DEBUG_KMS("Success: LSPCON init\n");
|
||||
--
|
||||
diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
|
||||
index b54ccbb5aad5..051e30ad80e7 100644
|
||||
--- a/drivers/gpu/drm/i915/display/intel_hdmi.c
|
||||
+++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
|
||||
@@ -576,6 +576,16 @@ static u32 hsw_infoframes_enabled(struct intel_encoder *encoder,
|
||||
return val & mask;
|
||||
}
|
||||
|
||||
+void lspcon_drm_write_infoframe(struct intel_encoder *encoder,
|
||||
+ const struct intel_crtc_state *crtc_state,
|
||||
+ unsigned int type,
|
||||
+ const void *frame, ssize_t len)
|
||||
+{
|
||||
+ DRM_DEBUG_KMS("Update HDR metadata for lspcon\n");
|
||||
+ /* It uses the legacy hsw implementation for the same */
|
||||
+ hsw_write_infoframe(encoder, crtc_state, type, frame, len);
|
||||
+}
|
||||
+
|
||||
static const u8 infoframe_type_to_idx[] = {
|
||||
HDMI_PACKET_TYPE_GENERAL_CONTROL,
|
||||
HDMI_PACKET_TYPE_GAMUT_METADATA,
|
||||
diff --git a/drivers/gpu/drm/i915/display/intel_lspcon.c b/drivers/gpu/drm/i915/display/intel_lspcon.c
|
||||
index a1d0127b7f57..51ad5f02e700 100644
|
||||
--- a/drivers/gpu/drm/i915/display/intel_lspcon.c
|
||||
+++ b/drivers/gpu/drm/i915/display/intel_lspcon.c
|
||||
@@ -460,27 +460,41 @@ void lspcon_write_infoframe(struct intel_encoder *encoder,
|
||||
unsigned int type,
|
||||
const void *frame, ssize_t len)
|
||||
{
|
||||
- bool ret;
|
||||
+ bool ret = true;
|
||||
struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
|
||||
struct intel_lspcon *lspcon = enc_to_intel_lspcon(&encoder->base);
|
||||
|
||||
- /* LSPCON only needs AVI IF */
|
||||
- if (type != HDMI_INFOFRAME_TYPE_AVI)
|
||||
+ if (!(type == HDMI_INFOFRAME_TYPE_AVI ||
|
||||
+ type == HDMI_PACKET_TYPE_GAMUT_METADATA))
|
||||
return;
|
||||
|
||||
- if (lspcon->vendor == LSPCON_VENDOR_MCA)
|
||||
- ret = _lspcon_write_avi_infoframe_mca(&intel_dp->aux,
|
||||
- frame, len);
|
||||
- else
|
||||
- ret = _lspcon_write_avi_infoframe_parade(&intel_dp->aux,
|
||||
- frame, len);
|
||||
+ /*
|
||||
+ * Supporting HDR on MCA LSPCON
|
||||
+ * Todo: Add support for Parade later
|
||||
+ */
|
||||
+ if (type == HDMI_PACKET_TYPE_GAMUT_METADATA &&
|
||||
+ lspcon->vendor != LSPCON_VENDOR_MCA)
|
||||
+ return;
|
||||
+
|
||||
+ if (lspcon->vendor == LSPCON_VENDOR_MCA) {
|
||||
+ if (type == HDMI_INFOFRAME_TYPE_AVI)
|
||||
+ ret = _lspcon_write_avi_infoframe_mca(&intel_dp->aux,
|
||||
+ frame, len);
|
||||
+ else if (type == HDMI_PACKET_TYPE_GAMUT_METADATA)
|
||||
+ lspcon_drm_write_infoframe(encoder, crtc_state,
|
||||
+ HDMI_PACKET_TYPE_GAMUT_METADATA,
|
||||
+ frame, VIDEO_DIP_DATA_SIZE);
|
||||
+ } else {
|
||||
+ ret = _lspcon_write_avi_infoframe_parade(&intel_dp->aux, frame,
|
||||
+ len);
|
||||
+ }
|
||||
|
||||
if (!ret) {
|
||||
- DRM_ERROR("Failed to write AVI infoframes\n");
|
||||
+ DRM_ERROR("Failed to write infoframes\n");
|
||||
return;
|
||||
}
|
||||
|
||||
- DRM_DEBUG_DRIVER("AVI infoframes updated successfully\n");
|
||||
+ DRM_DEBUG_DRIVER("Infoframes updated successfully\n");
|
||||
}
|
||||
|
||||
void lspcon_read_infoframe(struct intel_encoder *encoder,
|
||||
diff --git a/drivers/gpu/drm/i915/display/intel_lspcon.h b/drivers/gpu/drm/i915/display/intel_lspcon.h
|
||||
index 37cfddf8a9c5..65878904f672 100644
|
||||
--- a/drivers/gpu/drm/i915/display/intel_lspcon.h
|
||||
+++ b/drivers/gpu/drm/i915/display/intel_lspcon.h
|
||||
@@ -35,4 +35,8 @@ u32 lspcon_infoframes_enabled(struct intel_encoder *encoder,
|
||||
void lspcon_ycbcr420_config(struct drm_connector *connector,
|
||||
struct intel_crtc_state *crtc_state);
|
||||
|
||||
+void lspcon_drm_write_infoframe(struct intel_encoder *encoder,
|
||||
+ const struct intel_crtc_state *crtc_state,
|
||||
+ unsigned int type,
|
||||
+ const void *frame, ssize_t len);
|
||||
#endif /* __INTEL_LSPCON_H__ */
|
||||
--
|
||||
diff --git a/drivers/gpu/drm/i915/display/intel_lspcon.c b/drivers/gpu/drm/i915/display/intel_lspcon.c
|
||||
index 51ad5f02e700..c32452360eeb 100644
|
||||
--- a/drivers/gpu/drm/i915/display/intel_lspcon.c
|
||||
+++ b/drivers/gpu/drm/i915/display/intel_lspcon.c
|
||||
@@ -627,6 +627,11 @@ bool lspcon_init(struct intel_digital_port *intel_dig_port)
|
||||
return false;
|
||||
}
|
||||
|
||||
+ if (lspcon->vendor == LSPCON_VENDOR_MCA && lspcon->hdr_supported)
|
||||
+ drm_object_attach_property(&connector->base,
|
||||
+ connector->dev->mode_config.hdr_output_metadata_property,
|
||||
+ 0);
|
||||
+
|
||||
connector->ycbcr_420_allowed = true;
|
||||
lspcon->active = true;
|
||||
DRM_DEBUG_KMS("Success: LSPCON init\n");
|
||||
--
|
||||
diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
|
||||
index d0a937fb0c56..e78b3a1626fd 100644
|
||||
--- a/drivers/gpu/drm/drm_atomic_state_helper.c
|
||||
+++ b/drivers/gpu/drm/drm_atomic_state_helper.c
|
||||
@@ -416,6 +416,7 @@ __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector,
|
||||
|
||||
if (state->hdr_output_metadata)
|
||||
drm_property_blob_get(state->hdr_output_metadata);
|
||||
+ state->hdr_metadata_changed = false;
|
||||
|
||||
/* Don't copy over a writeback job, they are used only once */
|
||||
state->writeback_job = NULL;
|
||||
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
|
||||
index 0d466d3b0809..5beabcd42d30 100644
|
||||
--- a/drivers/gpu/drm/drm_atomic_uapi.c
|
||||
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
|
||||
@@ -734,6 +734,7 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
|
||||
val,
|
||||
sizeof(struct hdr_output_metadata), -1,
|
||||
&replaced);
|
||||
+ state->hdr_metadata_changed |= replaced;
|
||||
return ret;
|
||||
} else if (property == config->aspect_ratio_property) {
|
||||
state->picture_aspect_ratio = val;
|
||||
diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c
|
||||
index 9ba794cb9b4f..dee3a593564c 100644
|
||||
--- a/drivers/gpu/drm/i915/display/intel_ddi.c
|
||||
+++ b/drivers/gpu/drm/i915/display/intel_ddi.c
|
||||
@@ -3851,6 +3851,8 @@ static void intel_enable_ddi_dp(struct intel_encoder *encoder,
|
||||
{
|
||||
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
|
||||
struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
|
||||
+ struct intel_lspcon *lspcon =
|
||||
+ enc_to_intel_lspcon(&encoder->base);
|
||||
enum port port = encoder->port;
|
||||
|
||||
if (port == PORT_A && INTEL_GEN(dev_priv) < 9)
|
||||
@@ -3860,6 +3862,12 @@ static void intel_enable_ddi_dp(struct intel_encoder *encoder,
|
||||
intel_psr_enable(intel_dp, crtc_state);
|
||||
intel_dp_vsc_enable(intel_dp, crtc_state, conn_state);
|
||||
intel_dp_hdr_metadata_enable(intel_dp, crtc_state, conn_state);
|
||||
+
|
||||
+ /* Set the infoframe for NON modeset cases as well */
|
||||
+ if (lspcon->active && lspcon->hdr_supported &&
|
||||
+ conn_state->hdr_metadata_changed)
|
||||
+ intel_dp_setup_hdr_metadata_infoframe_sdp(intel_dp, crtc_state,
|
||||
+ conn_state);
|
||||
intel_edp_drrs_enable(intel_dp, crtc_state);
|
||||
|
||||
if (crtc_state->has_audio)
|
||||
diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
|
||||
index 5eeafa45831a..cc616fd31d8b 100644
|
||||
--- a/drivers/gpu/drm/i915/display/intel_dp.c
|
||||
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
|
||||
@@ -4651,7 +4651,7 @@ intel_dp_setup_vsc_sdp(struct intel_dp *intel_dp,
|
||||
crtc_state, DP_SDP_VSC, &vsc_sdp, sizeof(vsc_sdp));
|
||||
}
|
||||
|
||||
-static void
|
||||
+void
|
||||
intel_dp_setup_hdr_metadata_infoframe_sdp(struct intel_dp *intel_dp,
|
||||
const struct intel_crtc_state *crtc_state,
|
||||
const struct drm_connector_state *conn_state)
|
||||
diff --git a/drivers/gpu/drm/i915/display/intel_lspcon.h b/drivers/gpu/drm/i915/display/intel_lspcon.h
|
||||
index 65878904f672..3404cff8c337 100644
|
||||
--- a/drivers/gpu/drm/i915/display/intel_lspcon.h
|
||||
+++ b/drivers/gpu/drm/i915/display/intel_lspcon.h
|
||||
@@ -14,6 +14,7 @@ struct intel_crtc_state;
|
||||
struct intel_digital_port;
|
||||
struct intel_encoder;
|
||||
struct intel_lspcon;
|
||||
+struct intel_dp;
|
||||
|
||||
bool lspcon_init(struct intel_digital_port *intel_dig_port);
|
||||
void lspcon_resume(struct intel_lspcon *lspcon);
|
||||
@@ -39,4 +40,7 @@ void lspcon_drm_write_infoframe(struct intel_encoder *encoder,
|
||||
const struct intel_crtc_state *crtc_state,
|
||||
unsigned int type,
|
||||
const void *frame, ssize_t len);
|
||||
+void intel_dp_setup_hdr_metadata_infoframe_sdp(struct intel_dp *intel_dp,
|
||||
+ const struct intel_crtc_state *crtc_state,
|
||||
+ const struct drm_connector_state *conn_state);
|
||||
#endif /* __INTEL_LSPCON_H__ */
|
||||
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
|
||||
index 5f8c3389d46f..1f0b4fcf0bd3 100644
|
||||
--- a/include/drm/drm_connector.h
|
||||
+++ b/include/drm/drm_connector.h
|
||||
@@ -661,6 +661,7 @@ struct drm_connector_state {
|
||||
* DRM blob property for HDR output metadata
|
||||
*/
|
||||
struct drm_property_blob *hdr_output_metadata;
|
||||
+ u8 hdr_metadata_changed : 1;
|
||||
};
|
||||
|
||||
/**
|
||||
--
|
||||
diff --git a/drivers/gpu/drm/i915/display/intel_lspcon.c b/drivers/gpu/drm/i915/display/intel_lspcon.c
|
||||
index c32452360eeb..8565bf73c4cd 100644
|
||||
--- a/drivers/gpu/drm/i915/display/intel_lspcon.c
|
||||
+++ b/drivers/gpu/drm/i915/display/intel_lspcon.c
|
||||
@@ -505,6 +505,11 @@ void lspcon_read_infoframe(struct intel_encoder *encoder,
|
||||
/* FIXME implement this */
|
||||
}
|
||||
|
||||
+/* HDMI HDR Colorspace Spec Definitions */
|
||||
+#define NORMAL_COLORIMETRY_MASK 0x3
|
||||
+#define EXTENDED_COLORIMETRY_MASK 0x7
|
||||
+#define HDMI_COLORIMETRY_BT2020_YCC ((3 << 0) | (6 << 2) | (0 << 5))
|
||||
+
|
||||
void lspcon_set_infoframes(struct intel_encoder *encoder,
|
||||
bool enable,
|
||||
const struct intel_crtc_state *crtc_state,
|
||||
@@ -549,6 +554,19 @@ void lspcon_set_infoframes(struct intel_encoder *encoder,
|
||||
HDMI_QUANTIZATION_RANGE_LIMITED :
|
||||
HDMI_QUANTIZATION_RANGE_FULL);
|
||||
|
||||
+ /*
|
||||
+ * Set BT2020 colorspace if driving HDR data
|
||||
+ * ToDo: Make this generic and expose all colorspaces for lspcon
|
||||
+ */
|
||||
+ if (lspcon->active && conn_state->hdr_metadata_changed) {
|
||||
+ frame.avi.colorimetry =
|
||||
+ HDMI_COLORIMETRY_BT2020_YCC &
|
||||
+ NORMAL_COLORIMETRY_MASK;
|
||||
+ frame.avi.extended_colorimetry =
|
||||
+ (HDMI_COLORIMETRY_BT2020_YCC >> 2) &
|
||||
+ EXTENDED_COLORIMETRY_MASK;
|
||||
+ }
|
||||
+
|
||||
ret = hdmi_infoframe_pack(&frame, buf, sizeof(buf));
|
||||
if (ret < 0) {
|
||||
DRM_ERROR("Failed to pack AVI IF\n");
|
||||
--
|
38
patches/UHD-10Bit.patch
Normal file
38
patches/UHD-10Bit.patch
Normal file
@@ -0,0 +1,38 @@
|
||||
diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
|
||||
index cc616fd31d8b..f2d1d7bd87d3 100644
|
||||
--- a/drivers/gpu/drm/i915/display/intel_dp.c
|
||||
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
|
||||
@@ -616,8 +616,10 @@ intel_dp_mode_valid(struct drm_connector *connector,
|
||||
{
|
||||
struct intel_dp *intel_dp = intel_attached_dp(connector);
|
||||
struct intel_connector *intel_connector = to_intel_connector(connector);
|
||||
+ struct intel_encoder *intel_encoder = intel_attached_encoder(connector);
|
||||
struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
|
||||
struct drm_i915_private *dev_priv = to_i915(connector->dev);
|
||||
+ struct intel_lspcon *lspcon = enc_to_intel_lspcon(&intel_encoder->base);
|
||||
int target_clock = mode->clock;
|
||||
int max_rate, mode_rate, max_lanes, max_link_clock;
|
||||
int max_dotclk;
|
||||
@@ -639,6 +641,21 @@ intel_dp_mode_valid(struct drm_connector *connector,
|
||||
target_clock = fixed_mode->clock;
|
||||
}
|
||||
|
||||
+ /*
|
||||
+ * Reducing Blanking to incorporate DP and HDMI timing/link bandwidth
|
||||
+ * limitations for CEA modes (4k@60 at 10 bpp). DP can drive 17.28Gbs
|
||||
+ * while 4k modes (VIC97 etc) at 10 bpp required 17.8 Gbps. This will
|
||||
+ * cause mode to blank out. Reduced Htotal by shortening the back porch
|
||||
+ * and front porch within permissible limits.
|
||||
+ */
|
||||
+ if (lspcon->active && lspcon->hdr_supported &&
|
||||
+ mode->clock > 570000) {
|
||||
+ mode->clock = 570000;
|
||||
+ mode->htotal -= 180;
|
||||
+ mode->hsync_start -= 72;
|
||||
+ mode->hsync_end -= 72;
|
||||
+ }
|
||||
+
|
||||
max_link_clock = intel_dp_max_link_rate(intel_dp);
|
||||
max_lanes = intel_dp_max_lane_count(intel_dp);
|
||||
|
||||
--
|
14
patches/vdr-plugin-skinnopacity-osd.diff.txt
Normal file
14
patches/vdr-plugin-skinnopacity-osd.diff.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
--- helpers.c.orig 2019-11-19 20:02:37.851039110 +0100
|
||||
+++ helpers.c 2019-11-19 20:02:03.733164221 +0100
|
||||
@@ -5,9 +5,9 @@
|
||||
#include <vdr/skins.h>
|
||||
|
||||
cOsd *CreateOsd(int Left, int Top, int Width, int Height) {
|
||||
- cOsd *osd = cOsdProvider::NewOsd(Left, Top);
|
||||
+ cOsd *osd = cOsdProvider::NewOsd(cOsd::OsdLeft() + Left,cOsd::OsdTop() + Top);
|
||||
if (osd) {
|
||||
- tArea Area = { 0, 0, Width, Height, 32 };
|
||||
+ tArea Area = { 0, 0, Width - 1, Height - 1, 32 };
|
||||
if (osd->SetAreas(&Area, 1) == oeOk) {
|
||||
return osd;
|
||||
}
|
392
shaders.h
392
shaders.h
@@ -1,185 +1,16 @@
|
||||
// shader
|
||||
#define SHADER_LENGTH 10000
|
||||
|
||||
#ifdef CUVID
|
||||
char vertex_osd[] = { "\
|
||||
#version 330\n\
|
||||
in vec2 vertex_position;\n\
|
||||
in vec2 vertex_texcoord0;\n\
|
||||
out vec2 texcoord0;\n\
|
||||
void main() {\n\
|
||||
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
|
||||
texcoord0 = vertex_texcoord0;\n\
|
||||
}\n" };
|
||||
|
||||
char fragment_osd[] = { "\
|
||||
#version 330\n\
|
||||
#define texture1D texture\n\
|
||||
precision mediump float; \
|
||||
layout(location = 0) out vec4 out_color;\n\
|
||||
in vec2 texcoord0;\n\
|
||||
uniform sampler2D texture0;\n\
|
||||
void main() {\n\
|
||||
vec4 color; \n\
|
||||
color = vec4(texture(texture0, texcoord0));\n\
|
||||
out_color = color;\n\
|
||||
}\n" };
|
||||
|
||||
char vertex[] = { "\
|
||||
#version 310 es\n\
|
||||
in vec2 vertex_position;\n\
|
||||
in vec2 vertex_texcoord0;\n\
|
||||
out vec2 texcoord0;\n\
|
||||
in vec2 vertex_texcoord1;\n\
|
||||
out vec2 texcoord1;\n\
|
||||
void main() {\n\
|
||||
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
|
||||
texcoord0 = vertex_texcoord0;\n\
|
||||
texcoord1 = vertex_texcoord1;\n\
|
||||
}\n" };
|
||||
|
||||
char fragment[] = { "\
|
||||
#version 310 es\n\
|
||||
#define texture1D texture\n\
|
||||
#define texture3D texture\n\
|
||||
precision mediump float; \
|
||||
layout(location = 0) out vec4 out_color;\n\
|
||||
in vec2 texcoord0;\n\
|
||||
in vec2 texcoord1;\n\
|
||||
uniform mat3 colormatrix;\n\
|
||||
uniform vec3 colormatrix_c;\n\
|
||||
uniform sampler2D texture0;\n\
|
||||
uniform sampler2D texture1;\n\
|
||||
void main() {\n\
|
||||
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
|
||||
color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r;\n\
|
||||
color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg;\n\
|
||||
// color conversion\n\
|
||||
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\
|
||||
color.a = 1.0;\n\
|
||||
// color mapping\n\
|
||||
out_color = color;\n\
|
||||
}\n" };
|
||||
|
||||
char fragment_bt2100[] = { "\
|
||||
#version 310 es\n \
|
||||
#define texture1D texture\n\
|
||||
#define texture3D texture\n\
|
||||
precision mediump float; \
|
||||
layout(location = 0) out vec4 out_color;\n\
|
||||
in vec2 texcoord0;\n\
|
||||
in vec2 texcoord1;\n\
|
||||
uniform mat3 colormatrix;\n\
|
||||
uniform vec3 colormatrix_c;\n\
|
||||
uniform mat3 cms_matrix;\n\
|
||||
uniform sampler2D texture0;\n\
|
||||
uniform sampler2D texture1;\n\
|
||||
//#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))\n\
|
||||
void main() {\n\
|
||||
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
|
||||
color.r = 1.003906 * vec4(texture(texture0, texcoord0)).r;\n\
|
||||
color.gb = 1.003906 * vec4(texture(texture1, texcoord1)).rg;\n\
|
||||
// color conversion\n\
|
||||
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\
|
||||
color.a = 1.0;\n\
|
||||
// color mapping\n\
|
||||
color.rgb = clamp(color.rgb, 0.0, 1.0);\n\
|
||||
color.rgb = pow(color.rgb, vec3(2.4));\n\
|
||||
color.rgb = cms_matrix * color.rgb;\n\
|
||||
color.rgb = clamp(color.rgb, 0.0, 1.0);\n\
|
||||
color.rgb = pow(color.rgb, vec3(1.0/2.4));\n\
|
||||
out_color = color;\n\
|
||||
}\n" };
|
||||
|
||||
const char *gl_version = "#version 330";
|
||||
#else
|
||||
char vertex_osd[] = { "\
|
||||
\n\
|
||||
in vec2 vertex_position;\n\
|
||||
in vec2 vertex_texcoord0;\n\
|
||||
out vec2 texcoord0;\n\
|
||||
void main() {\n\
|
||||
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
|
||||
texcoord0 = vertex_texcoord0;\n\
|
||||
}\n" };
|
||||
|
||||
char fragment_osd[] = { "\
|
||||
\n\
|
||||
#define texture1D texture\n\
|
||||
precision mediump float; \
|
||||
layout(location = 0) out vec4 out_color;\n\
|
||||
in vec2 texcoord0;\n\
|
||||
uniform sampler2D texture0;\n\
|
||||
void main() {\n\
|
||||
vec4 color; \n\
|
||||
color = vec4(texture(texture0, texcoord0));\n\
|
||||
out_color = color;\n\
|
||||
}\n" };
|
||||
|
||||
char vertex[] = { "\
|
||||
\n\
|
||||
in vec2 vertex_position;\n\
|
||||
in vec2 vertex_texcoord0;\n\
|
||||
out vec2 texcoord0;\n\
|
||||
in vec2 vertex_texcoord1;\n\
|
||||
out vec2 texcoord1;\n\
|
||||
void main() {\n\
|
||||
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
|
||||
texcoord0 = vertex_texcoord0;\n\
|
||||
texcoord1 = vertex_texcoord1;\n\
|
||||
}\n" };
|
||||
|
||||
char fragment[] = { "\
|
||||
\n\
|
||||
#define texture1D texture\n\
|
||||
#define texture3D texture\n\
|
||||
precision mediump float; \
|
||||
layout(location = 0) out vec4 out_color;\n\
|
||||
in vec2 texcoord0;\n\
|
||||
in vec2 texcoord1;\n\
|
||||
uniform mat3 colormatrix;\n\
|
||||
uniform vec3 colormatrix_c;\n\
|
||||
uniform sampler2D texture0;\n\
|
||||
uniform sampler2D texture1;\n\
|
||||
//#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))\n\
|
||||
void main() {\n\
|
||||
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
|
||||
color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r;\n\
|
||||
color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg;\n\
|
||||
// color conversion\n\
|
||||
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\
|
||||
color.a = 1.0;\n\
|
||||
// color mapping\n\
|
||||
out_color = color;\n\
|
||||
}\n" };
|
||||
|
||||
char fragment_bt2100[] = { "\
|
||||
\n \
|
||||
#define texture1D texture\n\
|
||||
#define texture3D texture\n\
|
||||
precision mediump float; \
|
||||
layout(location = 0) out vec4 out_color;\n\
|
||||
in vec2 texcoord0;\n\
|
||||
in vec2 texcoord1;\n\
|
||||
uniform mat3 colormatrix;\n\
|
||||
uniform vec3 colormatrix_c;\n\
|
||||
uniform mat3 cms_matrix;\n\
|
||||
uniform sampler2D texture0;\n\
|
||||
uniform sampler2D texture1;\n\
|
||||
//#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))\n\
|
||||
void main() {\n\
|
||||
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
|
||||
color.r = 1.003906 * vec4(texture(texture0, texcoord0)).r;\n\
|
||||
color.gb = 1.003906 * vec4(texture(texture1, texcoord1)).rg;\n\
|
||||
// color conversion\n\
|
||||
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\
|
||||
color.a = 1.0;\n\
|
||||
// color mapping\n\
|
||||
color.rgb = clamp(color.rgb, 0.0, 1.0);\n\
|
||||
color.rgb = pow(color.rgb, vec3(2.4));\n\
|
||||
color.rgb = cms_matrix * color.rgb;\n\
|
||||
color.rgb = clamp(color.rgb, 0.0, 1.0);\n\
|
||||
color.rgb = pow(color.rgb, vec3(1.0/2.4));\n\
|
||||
out_color = color;\n\
|
||||
}\n" };
|
||||
#ifdef RASPI
|
||||
const char *gl_version = "#version 300 es";
|
||||
#else
|
||||
const char *gl_version = "#version 300 es ";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Color conversion matrix: RGB = m * YUV + c
|
||||
* m is in row-major matrix, with m[row][col], e.g.:
|
||||
@@ -239,6 +70,18 @@ float cms_matrix[3][3] = { {1.660497, -0.124547, -0.018154},
|
||||
{-0.072840, -0.008348, 1.118751}
|
||||
};
|
||||
|
||||
// Common constants for SMPTE ST.2084 (PQ)
|
||||
static const float PQ_M1 = 2610./4096 * 1./4,
|
||||
PQ_M2 = 2523./4096 * 128,
|
||||
PQ_C1 = 3424./4096,
|
||||
PQ_C2 = 2413./4096 * 32,
|
||||
PQ_C3 = 2392./4096 * 32;
|
||||
|
||||
// Common constants for ARIB STD-B67 (HLG)
|
||||
static const float HLG_A = 0.17883277,
|
||||
HLG_B = 0.28466892,
|
||||
HLG_C = 0.55991073;
|
||||
|
||||
struct gl_vao_entry
|
||||
{
|
||||
// used for shader / glBindAttribLocation
|
||||
@@ -275,15 +118,54 @@ static const struct gl_vao_entry vertex_vao[] = {
|
||||
{0}
|
||||
};
|
||||
|
||||
#define GLSL(...) pl_shader_append(__VA_ARGS__)
|
||||
#define GLSLV(...) pl_shader_append_v(__VA_ARGS__)
|
||||
|
||||
char sh[SHADER_LENGTH];
|
||||
char shv[SHADER_LENGTH];
|
||||
|
||||
GL_init() {
|
||||
sh[0] = 0;
|
||||
}
|
||||
GLV_init() {
|
||||
shv[0] = 0;
|
||||
}
|
||||
pl_shader_append(const char *fmt, ...) {
|
||||
char temp[1000];
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsprintf(temp,fmt,ap);
|
||||
va_end(ap);
|
||||
|
||||
if (strlen(sh) + strlen(temp) > SHADER_LENGTH)
|
||||
Fatal(_("Shaderlenght fault\n"));
|
||||
strcat(sh,temp);
|
||||
|
||||
}
|
||||
|
||||
pl_shader_append_v(const char *fmt, ...) {
|
||||
char temp[1000];
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsprintf(temp,fmt,ap);
|
||||
va_end(ap);
|
||||
|
||||
if (strlen(shv) + strlen(temp) > SHADER_LENGTH)
|
||||
Fatal(_("Shaderlenght fault\n"));
|
||||
strcat(shv,temp);
|
||||
|
||||
}
|
||||
static void compile_attach_shader(GLuint program, GLenum type, const char *source)
|
||||
{
|
||||
GLuint shader;
|
||||
GLint status, log_length;
|
||||
GLint status=1234, log_length;
|
||||
char log[4000];
|
||||
GLsizei len;
|
||||
|
||||
shader = glCreateShader(type);
|
||||
glShaderSource(shader, 1, &source, NULL);
|
||||
glShaderSource(shader, 1, (const GLchar **)&source, NULL); // &buffer, NULL);
|
||||
glCompileShader(shader);
|
||||
status = 0;
|
||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
|
||||
@@ -295,6 +177,7 @@ static void compile_attach_shader(GLuint program, GLenum type, const char *sourc
|
||||
|
||||
glAttachShader(program, shader);
|
||||
glDeleteShader(shader);
|
||||
|
||||
}
|
||||
|
||||
static void link_shader(GLuint program)
|
||||
@@ -314,14 +197,43 @@ static GLuint sc_generate_osd(GLuint gl_prog)
|
||||
|
||||
Debug(3, "vor create osd\n");
|
||||
gl_prog = glCreateProgram();
|
||||
|
||||
GL_init();
|
||||
GLSL("%s\n",gl_version);
|
||||
GLSL("in vec2 vertex_position;\n");
|
||||
GLSL("in vec2 vertex_texcoord0;\n");
|
||||
GLSL("out vec2 texcoord0;\n");
|
||||
GLSL("void main() {\n");
|
||||
GLSL("gl_Position = vec4(vertex_position, 1.0, 1.0);\n");
|
||||
GLSL("texcoord0 = vertex_texcoord0;\n");
|
||||
GLSL("}\n");
|
||||
|
||||
Debug(3, "vor compile vertex osd\n");
|
||||
compile_attach_shader(gl_prog, GL_VERTEX_SHADER, vertex_osd);
|
||||
compile_attach_shader(gl_prog, GL_VERTEX_SHADER, sh); // vertex_osd);
|
||||
GL_init();
|
||||
GLSL("%s\n",gl_version);
|
||||
GLSL("#define texture1D texture\n");
|
||||
GLSL("precision mediump float; \n");
|
||||
GLSL("layout(location = 0) out vec4 out_color;\n");
|
||||
GLSL("in vec2 texcoord0;\n");
|
||||
GLSL("uniform sampler2D texture0;\n");
|
||||
GLSL("void main() {\n");
|
||||
GLSL("vec4 color; \n");
|
||||
GLSL("color = vec4(texture(texture0, texcoord0));\n");
|
||||
#ifdef GAMMA
|
||||
GLSL("// delinearize gamma \n");
|
||||
GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n"); // delinearize gamma
|
||||
GLSL("color.rgb = pow(color.rgb, vec3(2.4)); \n");
|
||||
#endif
|
||||
GLSL("out_color = color;\n");
|
||||
GLSL("}\n");
|
||||
Debug(3, "vor compile fragment osd \n");
|
||||
compile_attach_shader(gl_prog, GL_FRAGMENT_SHADER, fragment_osd);
|
||||
compile_attach_shader(gl_prog, GL_FRAGMENT_SHADER, sh); //fragment_osd);
|
||||
glBindAttribLocation(gl_prog, 0, "vertex_position");
|
||||
glBindAttribLocation(gl_prog, 1, "vertex_texcoord0");
|
||||
|
||||
link_shader(gl_prog);
|
||||
|
||||
return gl_prog;
|
||||
}
|
||||
|
||||
@@ -333,42 +245,138 @@ static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace)
|
||||
GLint cmsLoc;
|
||||
float *m, *c, *cms;
|
||||
char *frag;
|
||||
|
||||
|
||||
GL_init();
|
||||
GLSL("%s\n",gl_version);
|
||||
GLSL("in vec2 vertex_position; \n");
|
||||
GLSL("in vec2 vertex_texcoord0; \n");
|
||||
GLSL("out vec2 texcoord0; \n");
|
||||
GLSL("in vec2 vertex_texcoord1; \n");
|
||||
GLSL("out vec2 texcoord1; \n");
|
||||
if (Planes == 3) {
|
||||
GLSL("in vec2 vertex_texcoord2; \n");
|
||||
GLSL("out vec2 texcoord2; \n");
|
||||
}
|
||||
GLSL("void main() { \n");
|
||||
GLSL("gl_Position = vec4(vertex_position, 1.0, 1.0);\n");
|
||||
GLSL("texcoord0 = vertex_texcoord0; \n");
|
||||
GLSL("texcoord1 = vertex_texcoord1; \n");
|
||||
if (Planes == 3) {
|
||||
GLSL("texcoord2 = vertex_texcoord1; \n"); // texcoord1 ist hier richtig
|
||||
}
|
||||
GLSL("} \n");
|
||||
|
||||
Debug(3, "vor create\n");
|
||||
gl_prog = glCreateProgram();
|
||||
Debug(3, "vor compile vertex\n");
|
||||
// printf("%s",sh);
|
||||
compile_attach_shader(gl_prog, GL_VERTEX_SHADER, sh );
|
||||
|
||||
|
||||
switch (colorspace) {
|
||||
case AVCOL_SPC_RGB:
|
||||
m = &yuv_bt601.m[0][0];
|
||||
c = &yuv_bt601.c[0];
|
||||
frag = fragment;
|
||||
Debug(3, "BT601 Colorspace used\n");
|
||||
break;
|
||||
case AVCOL_SPC_BT709:
|
||||
case AVCOL_SPC_UNSPECIFIED: // comes with UHD
|
||||
m = &yuv_bt709.m[0][0];
|
||||
c = &yuv_bt709.c[0];
|
||||
frag = fragment;
|
||||
Debug(3, "BT709 Colorspace used\n");
|
||||
break;
|
||||
case AVCOL_SPC_BT2020_NCL:
|
||||
m = &yuv_bt2020ncl.m[0][0];
|
||||
c = &yuv_bt2020ncl.c[0];
|
||||
cms = &cms_matrix[0][0];
|
||||
frag = fragment_bt2100;
|
||||
Debug(3, "BT2020NCL Colorspace used\n");
|
||||
break;
|
||||
default: // fallback
|
||||
m = &yuv_bt709.m[0][0];
|
||||
c = &yuv_bt709.c[0];
|
||||
frag = fragment;
|
||||
Debug(3, "default BT709 Colorspace used %d\n", colorspace);
|
||||
break;
|
||||
}
|
||||
|
||||
GL_init();
|
||||
|
||||
GLSL("%s\n",gl_version);
|
||||
GLSL("precision mediump float; \n");
|
||||
GLSL("layout(location = 0) out vec4 out_color;\n");
|
||||
GLSL("in vec2 texcoord0; \n");
|
||||
GLSL("in vec2 texcoord1; \n");
|
||||
if (Planes == 3)
|
||||
GLSL("in vec2 texcoord2; \n");
|
||||
GLSL("uniform mat3 colormatrix; \n");
|
||||
GLSL("uniform vec3 colormatrix_c; \n");
|
||||
if (colorspace == AVCOL_SPC_BT2020_NCL)
|
||||
GLSL("uniform mat3 cms_matrix;\n");
|
||||
GLSL("uniform sampler2D texture0; \n");
|
||||
GLSL("uniform sampler2D texture1; \n");
|
||||
if (Planes == 3)
|
||||
GLSL("uniform sampler2D texture2; \n");
|
||||
GLSL("void main() { \n");
|
||||
GLSL("vec4 color; \n");
|
||||
|
||||
if (colorspace == AVCOL_SPC_BT2020_NCL) {
|
||||
GLSL("color.r = 1.003906 * vec4(texture(texture0, texcoord0)).r; \n");
|
||||
if (Planes == 3) {
|
||||
GLSL("color.g = 1.003906 * vec4(texture(texture1, texcoord1)).r; \n");
|
||||
GLSL("color.b = 1.003906 * vec4(texture(texture2, texcoord2)).r; \n");
|
||||
} else {
|
||||
GLSL("color.gb = 1.003906 * vec4(texture(texture1, texcoord1)).rg;\n");
|
||||
}
|
||||
GLSL("// color conversion\n");
|
||||
GLSL("color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c; \n");
|
||||
GLSL("color.a = 1.0; \n");
|
||||
|
||||
Debug(3, "vor create\n");
|
||||
gl_prog = glCreateProgram();
|
||||
Debug(3, "vor compile vertex\n");
|
||||
compile_attach_shader(gl_prog, GL_VERTEX_SHADER, vertex);
|
||||
GLSL("// pl_shader_linearize \n");
|
||||
GLSL("color.rgb = max(color.rgb, 0.0); \n");
|
||||
// GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n");
|
||||
// GLSL("color.rgb = pow(color.rgb, vec3(2.4)); \n");
|
||||
// GLSL("color.rgb = mix(vec3(4.0) * color.rgb * color.rgb,exp((color.rgb - vec3(%f)) * vec3(1.0/%f)) + vec3(%f),bvec3(lessThan(vec3(0.5), color.rgb)));\n",HLG_C, HLG_A, HLG_B);
|
||||
GLSL("color.rgb = mix(vec3(4.0) * color.rgb * color.rgb,exp((color.rgb - vec3(0.55991073)) * vec3(1.0/0.17883277)) + vec3(0.28466892), bvec3(lessThan(vec3(0.5), color.rgb)));\n");
|
||||
GLSL("// color mapping \n");
|
||||
GLSL("color.rgb = cms_matrix * color.rgb; \n");
|
||||
#ifndef GAMMA
|
||||
GLSL("// pl_shader_delinearize \n");
|
||||
GLSL("color.rgb = max(color.rgb, 0.0); \n");
|
||||
// GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n");
|
||||
// GLSL("color.rgb = pow(color.rgb, vec3(1.0/2.4)); \n");
|
||||
GLSL("color.rgb = mix(vec3(0.5) * sqrt(color.rgb), vec3(0.17883277) * log(color.rgb - vec3(0.28466892)) + vec3(0.55991073), bvec3(lessThan(vec3(1.0), color.rgb))); \n");
|
||||
|
||||
#endif
|
||||
GLSL("out_color = color; \n");
|
||||
GLSL("} \n");
|
||||
}
|
||||
else {
|
||||
|
||||
GLSL("color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r; \n");
|
||||
if (Planes == 3) {
|
||||
GLSL("color.g = 1.000000 * vec4(texture(texture1, texcoord1)).r;\n");
|
||||
GLSL("color.b = 1.000000 * vec4(texture(texture2, texcoord2)).r;\n");
|
||||
} else {
|
||||
GLSL("color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg; \n");
|
||||
}
|
||||
GLSL("// color conversion \n");
|
||||
GLSL("color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c; \n");
|
||||
GLSL("color.a = 1.0; \n");
|
||||
|
||||
GLSL("// linearize gamma \n");
|
||||
GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n"); // linearize gamma
|
||||
GLSL("color.rgb = pow(color.rgb, vec3(2.4)); \n");
|
||||
#ifndef GAMMA
|
||||
GLSL("// delinearize gamma to sRGB \n");
|
||||
GLSL("color.rgb = max(color.rgb, 0.0); \n");
|
||||
GLSL("color.rgb = mix(color.rgb * vec3(12.92), vec3(1.055) * pow(color.rgb, vec3(1.0/2.4)) - vec3(0.055), bvec3(lessThanEqual(vec3(0.0031308), color.rgb))); \n");
|
||||
#endif
|
||||
GLSL("// color mapping \n");
|
||||
GLSL("out_color = color; \n");
|
||||
GLSL("} \n");
|
||||
}
|
||||
//printf(">%s<",sh);
|
||||
Debug(3, "vor compile fragment\n");
|
||||
compile_attach_shader(gl_prog, GL_FRAGMENT_SHADER, frag);
|
||||
compile_attach_shader(gl_prog, GL_FRAGMENT_SHADER, sh);
|
||||
glBindAttribLocation(gl_prog, 0, "vertex_position");
|
||||
|
||||
for (n = 0; n < 6; n++) {
|
||||
|
91
shaders.txt
91
shaders.txt
@@ -1,91 +0,0 @@
|
||||
Pro 7 1080i
|
||||
|
||||
[vo/opengl] [ 1] color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r;
|
||||
[vo/opengl] [ 2] color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg;
|
||||
[vo/opengl] [ 3] // color conversion
|
||||
[vo/opengl] [ 4] color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;
|
||||
[vo/opengl] [ 5] color.a = 1.0;
|
||||
[vo/opengl] [ 6] // color mapping
|
||||
|
||||
UHD 10 Bit
|
||||
[vo/opengl] [ 1] color.r = 1.003906 * vec4(texture(texture0, texcoord0)).r;
|
||||
[vo/opengl] [ 2] color.gb = 1.003906 * vec4(texture(texture1, texcoord1)).rg;
|
||||
[vo/opengl] [ 3] // color conversion
|
||||
[vo/opengl] [ 4] color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;
|
||||
[vo/opengl] [ 5] color.a = 1.0;
|
||||
[vo/opengl] [ 6] // color mapping
|
||||
|
||||
|
||||
HEVC 8 Bit
|
||||
[vo/opengl] [ 1] color.r = 1.003906 * vec4(texture(texture0, texcoord0)).r;
|
||||
[vo/opengl] [ 2] color.gb = 1.003906 * vec4(texture(texture1, texcoord1)).rg;
|
||||
[vo/opengl] [ 3] // color conversion
|
||||
[vo/opengl] [ 4] color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;
|
||||
[vo/opengl] [ 5] color.a = 1.0;
|
||||
[vo/opengl] [ 6] // color mapping
|
||||
|
||||
ZDF 720p
|
||||
[vo/opengl] [ 1] color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r;
|
||||
[vo/opengl] [ 2] color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg;
|
||||
[vo/opengl] [ 3] // color conversion
|
||||
[vo/opengl] [ 4] color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;
|
||||
[vo/opengl] [ 5] color.a = 1.0;
|
||||
[vo/opengl] [ 6] // color mapping
|
||||
|
||||
VERTEX
|
||||
#version 330
|
||||
in vec2 vertex_position;
|
||||
in vec2 vertex_texcoord0;
|
||||
out vec2 texcoord0;
|
||||
in vec2 vertex_texcoord1;
|
||||
out vec2 texcoord1;
|
||||
in vec2 vertex_texcoord2;
|
||||
out vec2 texcoord2;
|
||||
in vec2 vertex_texcoord3;
|
||||
out vec2 texcoord3;
|
||||
in vec2 vertex_texcoord4;
|
||||
out vec2 texcoord4;
|
||||
in vec2 vertex_texcoord5;
|
||||
out vec2 texcoord5;
|
||||
void main() {
|
||||
gl_Position = vec4(vertex_position, 1.0, 1.0);
|
||||
texcoord0 = vertex_texcoord0;
|
||||
texcoord1 = vertex_texcoord1;
|
||||
texcoord2 = vertex_texcoord2;
|
||||
texcoord3 = vertex_texcoord3;
|
||||
texcoord4 = vertex_texcoord4;
|
||||
texcoord5 = vertex_texcoord5;
|
||||
}
|
||||
|
||||
FRAGMENT
|
||||
#version 330
|
||||
#define texture1D texture
|
||||
#define texture3D texture
|
||||
out vec4 out_color;
|
||||
in vec2 texcoord0;
|
||||
in vec2 texcoord1;
|
||||
in vec2 texcoord2;
|
||||
in vec2 texcoord3;
|
||||
in vec2 texcoord4;
|
||||
in vec2 texcoord5;
|
||||
uniform mat3 colormatrix;
|
||||
uniform vec3 colormatrix_c;
|
||||
uniform sampler2D texture0;
|
||||
uniform vec2 texture_size0;
|
||||
uniform mat2 texture_rot0;
|
||||
uniform vec2 pixel_size0;
|
||||
uniform sampler2D texture1;
|
||||
uniform vec2 texture_size1;
|
||||
uniform mat2 texture_rot1;
|
||||
uniform vec2 pixel_size1;
|
||||
#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))
|
||||
void main() {
|
||||
vec4 color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r;
|
||||
color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg;
|
||||
// color conversion
|
||||
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;
|
||||
color.a = 1.0;
|
||||
// color mapping
|
||||
out_color = color;
|
||||
}
|
198
softhdcuvid.cpp
198
softhdcuvid.cpp
@@ -61,7 +61,7 @@ extern "C"
|
||||
/// vdr-plugin version number.
|
||||
/// Makefile extracts the version number for generating the file name
|
||||
/// for the distribution archive.
|
||||
static const char *const VERSION = "2.1.0"
|
||||
static const char *const VERSION = "3.1.0"
|
||||
#ifdef GIT_REV
|
||||
"-GIT" GIT_REV
|
||||
#endif
|
||||
@@ -213,109 +213,108 @@ class cSoftRemote:public cRemote, private cThread
|
||||
public:
|
||||
|
||||
/**
|
||||
** Soft device remote class constructor.
|
||||
** Soft device remote class constructor.
|
||||
**
|
||||
** @param name remote name
|
||||
** @param name remote name
|
||||
*/
|
||||
cSoftRemote(void) : cRemote("XKeySym")
|
||||
cSoftRemote(void):cRemote("XKeySym")
|
||||
{
|
||||
Start();
|
||||
Start();
|
||||
}
|
||||
|
||||
virtual ~cSoftRemote()
|
||||
virtual ~ cSoftRemote()
|
||||
{
|
||||
Cancel(3);
|
||||
Cancel(3);
|
||||
}
|
||||
|
||||
/**
|
||||
** Receive keycode.
|
||||
** Receive keycode.
|
||||
**
|
||||
** @param code key code
|
||||
** @param code key code
|
||||
*/
|
||||
void Receive(const char *code) {
|
||||
cMutexLock MutexLock(&mutex);
|
||||
Command = code;
|
||||
keyReceived.Broadcast();
|
||||
void Receive(const char *code)
|
||||
{
|
||||
cMutexLock MutexLock(&mutex);
|
||||
|
||||
Command = code;
|
||||
keyReceived.Broadcast();
|
||||
}
|
||||
};
|
||||
|
||||
void cSoftRemote::Action(void)
|
||||
{
|
||||
// see also VDR's cKbdRemote::Action()
|
||||
cTimeMs FirstTime;
|
||||
cTimeMs LastTime;
|
||||
cString FirstCommand = "";
|
||||
cString LastCommand = "";
|
||||
bool Delayed = false;
|
||||
bool Repeat = false;
|
||||
// see also VDR's cKbdRemote::Action()
|
||||
cTimeMs FirstTime;
|
||||
cTimeMs LastTime;
|
||||
cString FirstCommand = "";
|
||||
cString LastCommand = "";
|
||||
bool Delayed = false;
|
||||
bool Repeat = false;
|
||||
|
||||
while (Running()) {
|
||||
while (Running()) {
|
||||
cMutexLock MutexLock(&mutex);
|
||||
|
||||
if (keyReceived.TimedWait(mutex, Setup.RcRepeatDelta * 3 / 2) && **Command) {
|
||||
if (strcmp(Command, LastCommand) == 0) {
|
||||
// If two keyboard events with the same command come in without an intermediate
|
||||
// timeout, this is a long key press that caused the repeat function to kick in:
|
||||
Delayed = false;
|
||||
FirstCommand = "";
|
||||
if (FirstTime.Elapsed() < (uint)Setup.RcRepeatDelay)
|
||||
continue; // repeat function kicks in after a short delay
|
||||
if (LastTime.Elapsed() < (uint)Setup.RcRepeatDelta)
|
||||
continue; // skip same keys coming in too fast
|
||||
cRemote::Put(Command, true);
|
||||
Repeat = true;
|
||||
LastTime.Set();
|
||||
}
|
||||
else if (strcmp(Command, FirstCommand) == 0) {
|
||||
// If the same command comes in twice with an intermediate timeout, we
|
||||
// need to delay the second command to see whether it is going to be
|
||||
// a repeat function or a separate key press:
|
||||
Delayed = true;
|
||||
}
|
||||
else {
|
||||
// This is a totally new key press, so we accept it immediately:
|
||||
cRemote::Put(Command);
|
||||
Delayed = false;
|
||||
FirstCommand = Command;
|
||||
FirstTime.Set();
|
||||
}
|
||||
}
|
||||
else if (Repeat) {
|
||||
// Timeout after a repeat function, so we generate a 'release':
|
||||
cRemote::Put(LastCommand, false, true);
|
||||
Repeat = false;
|
||||
}
|
||||
else if (Delayed && *FirstCommand) {
|
||||
// Timeout after two normal key presses of the same key, so accept the
|
||||
// delayed key:
|
||||
cRemote::Put(FirstCommand);
|
||||
Delayed = false;
|
||||
FirstCommand = "";
|
||||
FirstTime.Set();
|
||||
}
|
||||
else if (**FirstCommand && FirstTime.Elapsed() > (uint)Setup.RcRepeatDelay) {
|
||||
Delayed = false;
|
||||
FirstCommand = "";
|
||||
FirstTime.Set();
|
||||
}
|
||||
if (strcmp(Command, LastCommand) == 0) {
|
||||
// If two keyboard events with the same command come in without an intermediate
|
||||
// timeout, this is a long key press that caused the repeat function to kick in:
|
||||
Delayed = false;
|
||||
FirstCommand = "";
|
||||
if (FirstTime.Elapsed() < (uint) Setup.RcRepeatDelay)
|
||||
continue; // repeat function kicks in after a short delay
|
||||
if (LastTime.Elapsed() < (uint) Setup.RcRepeatDelta)
|
||||
continue; // skip same keys coming in too fast
|
||||
cRemote::Put(Command, true);
|
||||
Repeat = true;
|
||||
LastTime.Set();
|
||||
} else if (strcmp(Command, FirstCommand) == 0) {
|
||||
// If the same command comes in twice with an intermediate timeout, we
|
||||
// need to delay the second command to see whether it is going to be
|
||||
// a repeat function or a separate key press:
|
||||
Delayed = true;
|
||||
} else {
|
||||
// This is a totally new key press, so we accept it immediately:
|
||||
cRemote::Put(Command);
|
||||
Delayed = false;
|
||||
FirstCommand = Command;
|
||||
FirstTime.Set();
|
||||
}
|
||||
} else if (Repeat) {
|
||||
// Timeout after a repeat function, so we generate a 'release':
|
||||
cRemote::Put(LastCommand, false, true);
|
||||
Repeat = false;
|
||||
} else if (Delayed && *FirstCommand) {
|
||||
// Timeout after two normal key presses of the same key, so accept the
|
||||
// delayed key:
|
||||
cRemote::Put(FirstCommand);
|
||||
Delayed = false;
|
||||
FirstCommand = "";
|
||||
FirstTime.Set();
|
||||
} else if (**FirstCommand && FirstTime.Elapsed() > (uint) Setup.RcRepeatDelay) {
|
||||
Delayed = false;
|
||||
FirstCommand = "";
|
||||
FirstTime.Set();
|
||||
}
|
||||
LastCommand = Command;
|
||||
Command = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static cSoftRemote *csoft = NULL;
|
||||
|
||||
/**
|
||||
** Feed key press as remote input (called from C part).
|
||||
** Feed key press as remote input (called from C part).
|
||||
**
|
||||
** @param keymap target keymap "XKeymap" name (obsolete, ignored)
|
||||
** @param key pressed/released key name
|
||||
** @param repeat repeated key flag (obsolete, ignored)
|
||||
** @param release released key flag (obsolete, ignored)
|
||||
** @param letter x11 character string (system setting locale)
|
||||
** @param keymap target keymap "XKeymap" name (obsolete, ignored)
|
||||
** @param key pressed/released key name
|
||||
** @param repeat repeated key flag (obsolete, ignored)
|
||||
** @param release released key flag (obsolete, ignored)
|
||||
** @param letter x11 character string (system setting locale)
|
||||
*/
|
||||
extern "C" void FeedKeyPress(const char *keymap, const char *key, int repeat, int release, const char *letter)
|
||||
{
|
||||
if (!csoft || !keymap || !key) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
csoft->Receive(key);
|
||||
@@ -1134,7 +1133,7 @@ void cMenuSetupSoft::Create(void)
|
||||
static char *scalingtest[100];
|
||||
|
||||
if (scalers == 0) {
|
||||
scalingtest[0] = "Off";
|
||||
scalingtest[0] = (char *) "Off";
|
||||
for (scalers = 0; pl_named_filters[scalers].filter != NULL; scalers++) {
|
||||
scaling[scalers] = (char *)pl_named_filters[scalers].name;
|
||||
scalingtest[scalers + 1] = (char *)pl_named_filters[scalers].name;
|
||||
@@ -2154,6 +2153,10 @@ void cSoftHdMenu::Create(void)
|
||||
int dropped;
|
||||
int counter;
|
||||
float frametime;
|
||||
int width,height;
|
||||
int color;
|
||||
int eotf;
|
||||
char *colorstr, *eotfstr;
|
||||
|
||||
current = Current(); // get current menu item index
|
||||
Clear(); // clear the menu
|
||||
@@ -2188,10 +2191,30 @@ void cSoftHdMenu::Create(void)
|
||||
#endif
|
||||
Add(new cOsdItem(NULL, osUnknown, false));
|
||||
Add(new cOsdItem(NULL, osUnknown, false));
|
||||
GetStats(&missed, &duped, &dropped, &counter, &frametime);
|
||||
GetStats(&missed, &duped, &dropped, &counter, &frametime, &width, &height, &color,&eotf);
|
||||
switch (color) {
|
||||
case AVCOL_SPC_RGB:
|
||||
colorstr = strdup("BT 601");
|
||||
eotfstr = strdup("BT 1886");
|
||||
break;
|
||||
case AVCOL_SPC_BT709:
|
||||
case AVCOL_SPC_UNSPECIFIED: // comes with UHD
|
||||
colorstr = strdup("BT 709");
|
||||
eotfstr = strdup("BT 1886");
|
||||
break;
|
||||
case AVCOL_SPC_BT2020_NCL:
|
||||
colorstr = strdup("BT 2020");
|
||||
eotfstr = strdup("HDR-HLG");
|
||||
break;
|
||||
default: // fallback
|
||||
colorstr = strdup("Fallback BT 709");
|
||||
eotfstr = strdup("BT 1886");
|
||||
break;
|
||||
}
|
||||
Add(new cOsdItem(cString::sprintf(tr(" Frames missed(%d) duped(%d) dropped(%d) total(%d)"), missed, duped, dropped,
|
||||
counter), osUnknown, false));
|
||||
Add(new cOsdItem(cString::sprintf(tr(" Frame Process time %2.2fms"), frametime), osUnknown, false));
|
||||
Add(new cOsdItem(cString::sprintf(tr(" Video %dx%d Color: %s Gamma: %s"), width, height, colorstr, eotfstr), osUnknown, false));
|
||||
// Add(new cOsdItem(cString::sprintf(tr(" Frame Process time %2.2fms"), frametime), osUnknown, false));
|
||||
SetCurrent(Get(current)); // restore selected menu entry
|
||||
Display(); // display build menu
|
||||
}
|
||||
@@ -2473,11 +2496,17 @@ class cSoftHdDevice:public cDevice
|
||||
return "softhdcuvid";
|
||||
}
|
||||
#endif
|
||||
#ifdef VAAPI
|
||||
#if defined (VAAPI) && !defined (USE_DRM)
|
||||
virtual cString DeviceName(void) const
|
||||
{
|
||||
return "softhdvaapi";
|
||||
}
|
||||
#endif
|
||||
#if defined (VAAPI) && defined (USE_DRM)
|
||||
virtual cString DeviceName(void) const
|
||||
{
|
||||
return "softhddrm";
|
||||
}
|
||||
#endif
|
||||
virtual bool HasDecoder(void) const;
|
||||
virtual bool CanReplay(void) const;
|
||||
@@ -3115,7 +3144,7 @@ bool cPluginSoftHdDevice::Start(void)
|
||||
}
|
||||
}
|
||||
|
||||
csoft = new cSoftRemote;
|
||||
csoft = new cSoftRemote;
|
||||
|
||||
switch (::Start()) {
|
||||
case 1:
|
||||
@@ -3144,7 +3173,8 @@ void cPluginSoftHdDevice::Stop(void)
|
||||
// dsyslog("[softhddev]%s:\n", __FUNCTION__);
|
||||
|
||||
::Stop();
|
||||
delete csoft;
|
||||
delete csoft;
|
||||
|
||||
csoft = NULL;
|
||||
}
|
||||
|
||||
@@ -3429,11 +3459,11 @@ bool cPluginSoftHdDevice::SetupParse(const char *name, const char *value)
|
||||
return true;
|
||||
}
|
||||
if (!strcasecmp(name, "AudioPassthrough")) {
|
||||
int i;
|
||||
int ii;
|
||||
|
||||
i = atoi(value);
|
||||
AudioPassthroughState = i > 0;
|
||||
ConfigAudioPassthrough = abs(i);
|
||||
ii = atoi(value);
|
||||
AudioPassthroughState = ii > 0;
|
||||
ConfigAudioPassthrough = abs(ii);
|
||||
if (AudioPassthroughState) {
|
||||
CodecSetAudioPassthrough(ConfigAudioPassthrough);
|
||||
} else {
|
||||
|
440
softhddev.c
440
softhddev.c
@@ -515,7 +515,7 @@ enum
|
||||
#define PES_START_CODE_SIZE 6 ///< size of pes start code with length
|
||||
#define PES_HEADER_SIZE 9 ///< size of pes header
|
||||
#define PES_MAX_HEADER_SIZE (PES_HEADER_SIZE + 256) ///< maximal header size
|
||||
#define PES_MAX_PAYLOAD (512 * 1024) ///< max pay load size
|
||||
#define PES_MAX_PAYLOAD (512 * 1024) ///< max pay load size
|
||||
|
||||
///
|
||||
/// PES demuxer.
|
||||
@@ -645,7 +645,7 @@ static void PesParse(PesDemux * pesdx, const uint8_t * data, int size, int is_st
|
||||
q = pesdx->Buffer + pesdx->Skip;
|
||||
n = pesdx->Index - pesdx->Skip;
|
||||
while (n >= 5) {
|
||||
int r;
|
||||
int r=0;
|
||||
unsigned codec_id = AV_CODEC_ID_NONE;
|
||||
|
||||
// 4 bytes 0xFFExxxxx Mpeg audio
|
||||
@@ -655,8 +655,7 @@ static void PesParse(PesDemux * pesdx, const uint8_t * data, int size, int is_st
|
||||
// 7/9 bytes 0xFFFxxxxxxxxxxx ADTS audio
|
||||
// PCM audio can't be found
|
||||
// FIXME: simple+faster detection, if codec already known
|
||||
r = 0;
|
||||
if (!r && FastMpegCheck(q)) {
|
||||
if (FastMpegCheck(q)) {
|
||||
r = MpegCheck(q, n);
|
||||
codec_id = AV_CODEC_ID_MP2;
|
||||
}
|
||||
@@ -885,9 +884,9 @@ static void PesParse(PesDemux * pesdx, const uint8_t * data, int size, int is_st
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// Transport stream packet size
|
||||
#define TS_PACKET_SIZE 188
|
||||
#define TS_PACKET_SIZE 188
|
||||
/// Transport stream packet sync byte
|
||||
#define TS_PACKET_SYNC 0x47
|
||||
#define TS_PACKET_SYNC 0x47
|
||||
|
||||
///
|
||||
/// transport stream demuxer typedef.
|
||||
@@ -982,11 +981,11 @@ static int TsDemuxer(TsDemux * tsdx, const uint8_t * data, int size)
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Play audio packet.
|
||||
** Play audio packet.
|
||||
**
|
||||
** @param data data of exactly one complete PES packet
|
||||
** @param size size of PES packet
|
||||
** @param id PES packet type
|
||||
** @param data data of exactly one complete PES packet
|
||||
** @param size size of PES packet
|
||||
** @param id PES packet type
|
||||
*/
|
||||
int PlayAudio(const uint8_t * data, int size, uint8_t id)
|
||||
{
|
||||
@@ -1211,14 +1210,14 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id)
|
||||
#ifndef NO_TS_AUDIO
|
||||
|
||||
/**
|
||||
** Play transport stream audio packet.
|
||||
** Play transport stream audio packet.
|
||||
**
|
||||
** VDR can have buffered data belonging to previous channel!
|
||||
** VDR can have buffered data belonging to previous channel!
|
||||
**
|
||||
** @param data data of exactly one complete TS packet
|
||||
** @param size size of TS packet (always TS_PACKET_SIZE)
|
||||
** @param data data of exactly one complete TS packet
|
||||
** @param size size of TS packet (always TS_PACKET_SIZE)
|
||||
**
|
||||
** @returns number of bytes consumed;
|
||||
** @returns number of bytes consumed;
|
||||
*/
|
||||
int PlayTsAudio(const uint8_t * data, int size)
|
||||
{
|
||||
@@ -1265,9 +1264,9 @@ int PlayTsAudio(const uint8_t * data, int size)
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Set volume of audio device.
|
||||
** Set volume of audio device.
|
||||
**
|
||||
** @param volume VDR volume (0 .. 255)
|
||||
** @param volume VDR volume (0 .. 255)
|
||||
*/
|
||||
void SetVolumeDevice(int volume)
|
||||
{
|
||||
@@ -1275,7 +1274,7 @@ void SetVolumeDevice(int volume)
|
||||
}
|
||||
|
||||
/**
|
||||
*** Resets channel ID (restarts audio).
|
||||
*** Resets channel ID (restarts audio).
|
||||
**/
|
||||
void ResetChannelId(void)
|
||||
{
|
||||
@@ -1291,7 +1290,7 @@ void ResetChannelId(void)
|
||||
#define VIDEO_PACKET_MAX 256 ///< max number of video packets 192
|
||||
|
||||
/**
|
||||
** Video output stream device structure. Parser, decoder, display.
|
||||
** Video output stream device structure. Parser, decoder, display.
|
||||
*/
|
||||
struct __video_stream__
|
||||
{
|
||||
@@ -1344,9 +1343,9 @@ static volatile char Usr1Signal; ///< true got usr1 signal
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
** Initialize video packet ringbuffer.
|
||||
** Initialize video packet ringbuffer.
|
||||
**
|
||||
** @param stream video stream
|
||||
** @param stream video stream
|
||||
*/
|
||||
static void VideoPacketInit(VideoStream * stream)
|
||||
{
|
||||
@@ -1367,9 +1366,9 @@ static void VideoPacketInit(VideoStream * stream)
|
||||
}
|
||||
|
||||
/**
|
||||
** Cleanup video packet ringbuffer.
|
||||
** Cleanup video packet ringbuffer.
|
||||
**
|
||||
** @param stream video stream
|
||||
** @param stream video stream
|
||||
*/
|
||||
static void VideoPacketExit(VideoStream * stream)
|
||||
{
|
||||
@@ -1383,12 +1382,12 @@ static void VideoPacketExit(VideoStream * stream)
|
||||
}
|
||||
|
||||
/**
|
||||
** Place video data in packet ringbuffer.
|
||||
** Place video data in packet ringbuffer.
|
||||
**
|
||||
** @param stream video stream
|
||||
** @param pts presentation timestamp of pes packet
|
||||
** @param data data of pes packet
|
||||
** @param size size of pes packet
|
||||
** @param stream video stream
|
||||
** @param pts presentation timestamp of pes packet
|
||||
** @param data data of pes packet
|
||||
** @param size size of pes packet
|
||||
*/
|
||||
static void VideoEnqueue(VideoStream * stream, int64_t pts, int64_t dts, const void *data, int size)
|
||||
{
|
||||
@@ -1431,9 +1430,9 @@ static void VideoEnqueue(VideoStream * stream, int64_t pts, int64_t dts, const v
|
||||
}
|
||||
|
||||
/**
|
||||
** Reset current packet.
|
||||
** Reset current packet.
|
||||
**
|
||||
** @param stream video stream
|
||||
** @param stream video stream
|
||||
*/
|
||||
static void VideoResetPacket(VideoStream * stream)
|
||||
{
|
||||
@@ -1449,10 +1448,10 @@ static void VideoResetPacket(VideoStream * stream)
|
||||
}
|
||||
|
||||
/**
|
||||
** Finish current packet advance to next.
|
||||
** Finish current packet advance to next.
|
||||
**
|
||||
** @param stream video stream
|
||||
** @param codec_id codec id of packet (MPEG/H264)
|
||||
** @param stream video stream
|
||||
** @param codec_id codec id of packet (MPEG/H264)
|
||||
*/
|
||||
static void VideoNextPacket(VideoStream * stream, int codec_id)
|
||||
{
|
||||
@@ -1493,18 +1492,18 @@ static void VideoNextPacket(VideoStream * stream, int codec_id)
|
||||
#ifdef USE_PIP
|
||||
|
||||
/**
|
||||
** Place mpeg video data in packet ringbuffer.
|
||||
** Place mpeg video data in packet ringbuffer.
|
||||
**
|
||||
** Some tv-stations sends mulitple pictures in a single PES packet.
|
||||
** Split the packet into single picture packets.
|
||||
** Nick/CC, Viva, MediaShop, Deutsches Music Fernsehen
|
||||
** Some tv-stations sends mulitple pictures in a single PES packet.
|
||||
** Split the packet into single picture packets.
|
||||
** Nick/CC, Viva, MediaShop, Deutsches Music Fernsehen
|
||||
**
|
||||
** FIXME: this code can be written much faster
|
||||
** FIXME: this code can be written much faster
|
||||
**
|
||||
** @param stream video stream
|
||||
** @param pts presentation timestamp of pes packet
|
||||
** @param data data of pes packet
|
||||
** @param size size of pes packet
|
||||
** @param stream video stream
|
||||
** @param pts presentation timestamp of pes packet
|
||||
** @param data data of pes packet
|
||||
** @param size size of pes packet
|
||||
*/
|
||||
static void VideoMpegEnqueue(VideoStream * stream, int64_t pts, int64_t dts, const uint8_t * data, int size)
|
||||
{
|
||||
@@ -1533,7 +1532,7 @@ static void VideoMpegEnqueue(VideoStream * stream, int64_t pts, int64_t dts, con
|
||||
#endif
|
||||
if (!p[0] || p[0] == 0xb3) {
|
||||
#ifdef DEBUG
|
||||
printf("last: %d start aspect %02x\n", stream->StartCodeState, p[4]);
|
||||
printf("last: %d start aspect %02x\n", stream->StartCodeState, p[4]);
|
||||
#endif
|
||||
stream->PacketRb[stream->PacketWrite].stream_index -= 3;
|
||||
VideoNextPacket(stream, AV_CODEC_ID_MPEG2VIDEO);
|
||||
@@ -1551,7 +1550,7 @@ static void VideoMpegEnqueue(VideoStream * stream, int64_t pts, int64_t dts, con
|
||||
#endif
|
||||
if (p[0] == 0x01 && (!p[1] || p[1] == 0xb3)) {
|
||||
#ifdef DEBUG
|
||||
printf("last: %d start aspect %02x\n", stream->StartCodeState, p[5]);
|
||||
printf("last: %d start aspect %02x\n", stream->StartCodeState, p[5]);
|
||||
#endif
|
||||
stream->PacketRb[stream->PacketWrite].stream_index -= 2;
|
||||
VideoNextPacket(stream, AV_CODEC_ID_MPEG2VIDEO);
|
||||
@@ -1568,7 +1567,7 @@ static void VideoMpegEnqueue(VideoStream * stream, int64_t pts, int64_t dts, con
|
||||
#endif
|
||||
if (!p[0] && p[1] == 0x01 && (!p[2] || p[2] == 0xb3)) {
|
||||
#ifdef DEBUG
|
||||
printf("last: %d start aspect %02x\n", stream->StartCodeState, p[6]);
|
||||
printf("last: %d start aspect %02x\n", stream->StartCodeState, p[6]);
|
||||
#endif
|
||||
stream->PacketRb[stream->PacketWrite].stream_index -= 1;
|
||||
VideoNextPacket(stream, AV_CODEC_ID_MPEG2VIDEO);
|
||||
@@ -1650,19 +1649,19 @@ static void VideoMpegEnqueue(VideoStream * stream, int64_t pts, int64_t dts, con
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Fix packet for FFMpeg.
|
||||
** Fix packet for FFMpeg.
|
||||
**
|
||||
** Some tv-stations sends mulitple pictures in a single PES packet.
|
||||
** Current ffmpeg 0.10 and libav-0.8 has problems with this.
|
||||
** Split the packet into single picture packets.
|
||||
** Some tv-stations sends mulitple pictures in a single PES packet.
|
||||
** Current ffmpeg 0.10 and libav-0.8 has problems with this.
|
||||
** Split the packet into single picture packets.
|
||||
**
|
||||
** FIXME: there are stations which have multiple pictures and
|
||||
** the last picture incomplete in the PES packet.
|
||||
** FIXME: there are stations which have multiple pictures and
|
||||
** the last picture incomplete in the PES packet.
|
||||
**
|
||||
** FIXME: move function call into PlayVideo, than the hardware
|
||||
** decoder didn't need to support multiple frames decoding.
|
||||
** FIXME: move function call into PlayVideo, than the hardware
|
||||
** decoder didn't need to support multiple frames decoding.
|
||||
**
|
||||
** @param avpkt ffmpeg a/v packet
|
||||
** @param avpkt ffmpeg a/v packet
|
||||
*/
|
||||
|
||||
#ifndef USE_PIP
|
||||
@@ -1728,9 +1727,9 @@ static void FixPacketForFFMpeg(VideoDecoder * vdecoder, AVPacket * avpkt)
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Open video stream.
|
||||
** Open video stream.
|
||||
**
|
||||
** @param stream video stream
|
||||
** @param stream video stream
|
||||
*/
|
||||
static void VideoStreamOpen(VideoStream * stream)
|
||||
{
|
||||
@@ -1745,13 +1744,13 @@ static void VideoStreamOpen(VideoStream * stream)
|
||||
}
|
||||
|
||||
/**
|
||||
** Close video stream.
|
||||
** Close video stream.
|
||||
**
|
||||
** @param stream video stream
|
||||
** @param delhw flag delete hardware decoder
|
||||
** @param stream video stream
|
||||
** @param delhw flag delete hardware decoder
|
||||
**
|
||||
** @note must be called from the video thread, otherwise xcb has a
|
||||
** deadlock.
|
||||
** @note must be called from the video thread, otherwise xcb has a
|
||||
** deadlock.
|
||||
*/
|
||||
static void VideoStreamClose(VideoStream * stream, int delhw)
|
||||
{
|
||||
@@ -1782,14 +1781,14 @@ static void VideoStreamClose(VideoStream * stream, int delhw)
|
||||
}
|
||||
|
||||
/**
|
||||
** Poll PES packet ringbuffer.
|
||||
** Poll PES packet ringbuffer.
|
||||
**
|
||||
** Called if video frame buffers are full.
|
||||
** Called if video frame buffers are full.
|
||||
**
|
||||
** @param stream video stream
|
||||
** @param stream video stream
|
||||
**
|
||||
** @retval 1 something todo
|
||||
** @retval -1 empty stream
|
||||
** @retval 1 something todo
|
||||
** @retval -1 empty stream
|
||||
*/
|
||||
int VideoPollInput(VideoStream * stream)
|
||||
{
|
||||
@@ -1824,13 +1823,13 @@ int VideoPollInput(VideoStream * stream)
|
||||
}
|
||||
|
||||
/**
|
||||
** Decode from PES packet ringbuffer.
|
||||
** Decode from PES packet ringbuffer.
|
||||
**
|
||||
** @param stream video stream
|
||||
** @param stream video stream
|
||||
**
|
||||
** @retval 0 packet decoded
|
||||
** @retval 1 stream paused
|
||||
** @retval -1 empty stream
|
||||
** @retval 0 packet decoded
|
||||
** @retval 1 stream paused
|
||||
** @retval -1 empty stream
|
||||
*/
|
||||
int VideoDecodeInput(VideoStream * stream)
|
||||
{
|
||||
@@ -1975,9 +1974,9 @@ int VideoDecodeInput(VideoStream * stream)
|
||||
}
|
||||
|
||||
/**
|
||||
** Get number of video buffers.
|
||||
** Get number of video buffers.
|
||||
**
|
||||
** @param stream video stream
|
||||
** @param stream video stream
|
||||
*/
|
||||
int VideoGetBuffers(const VideoStream * stream)
|
||||
{
|
||||
@@ -1985,9 +1984,9 @@ int VideoGetBuffers(const VideoStream * stream)
|
||||
}
|
||||
|
||||
/**
|
||||
** Try video start.
|
||||
** Try video start.
|
||||
**
|
||||
** NOT TRUE: Could be called, when already started.
|
||||
** NOT TRUE: Could be called, when already started.
|
||||
*/
|
||||
static void StartVideo(void)
|
||||
{
|
||||
@@ -2005,7 +2004,7 @@ static void StartVideo(void)
|
||||
}
|
||||
|
||||
/**
|
||||
** Stop video.
|
||||
** Stop video.
|
||||
*/
|
||||
static void StopVideo(void)
|
||||
{
|
||||
@@ -2043,9 +2042,9 @@ static void StopVideo(void)
|
||||
#ifdef DEBUG
|
||||
|
||||
/**
|
||||
** Dump mpeg video packet.
|
||||
** Dump mpeg video packet.
|
||||
**
|
||||
** Function to dump a mpeg packet, not needed.
|
||||
** Function to dump a mpeg packet, not needed.
|
||||
*/
|
||||
static void DumpMpeg(const uint8_t * data, int size)
|
||||
{
|
||||
@@ -2067,9 +2066,9 @@ static void DumpMpeg(const uint8_t * data, int size)
|
||||
}
|
||||
|
||||
/**
|
||||
** Dump h264 video packet.
|
||||
** Dump h264 video packet.
|
||||
**
|
||||
** Function to Dump a h264 packet, not needed.
|
||||
** Function to Dump a h264 packet, not needed.
|
||||
*/
|
||||
static int DumpH264(const uint8_t * data, int size)
|
||||
{
|
||||
@@ -2091,9 +2090,9 @@ static int DumpH264(const uint8_t * data, int size)
|
||||
}
|
||||
|
||||
/**
|
||||
** Validate mpeg video packet.
|
||||
** Validate mpeg video packet.
|
||||
**
|
||||
** Function to validate a mpeg packet, not needed.
|
||||
** Function to validate a mpeg packet, not needed.
|
||||
*/
|
||||
static int ValidateMpeg(const uint8_t * data, int size)
|
||||
{
|
||||
@@ -2126,13 +2125,13 @@ static int ValidateMpeg(const uint8_t * data, int size)
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Play video packet.
|
||||
** Play video packet.
|
||||
**
|
||||
** @param stream video stream
|
||||
** @param data data of exactly one complete PES packet
|
||||
** @param size size of PES packet
|
||||
** @param stream video stream
|
||||
** @param data data of exactly one complete PES packet
|
||||
** @param size size of PES packet
|
||||
**
|
||||
** @return number of bytes used, 0 if internal buffer are full.
|
||||
** @return number of bytes used, 0 if internal buffer are full.
|
||||
**
|
||||
*/
|
||||
int PlayVideo3(VideoStream * stream, const uint8_t * data, int size)
|
||||
@@ -2352,20 +2351,20 @@ int PlayVideo3(VideoStream * stream, const uint8_t * data, int size)
|
||||
}
|
||||
|
||||
/**
|
||||
** Play video packet.
|
||||
** Play video packet.
|
||||
**
|
||||
** @param data data of exactly one complete PES packet
|
||||
** @param size size of PES packet
|
||||
** @param data data of exactly one complete PES packet
|
||||
** @param size size of PES packet
|
||||
**
|
||||
** @return number of bytes used, 0 if internal buffer are full.
|
||||
** @return number of bytes used, 0 if internal buffer are full.
|
||||
**
|
||||
** @note vdr sends incomplete packets, va-api h264 decoder only
|
||||
** supports complete packets.
|
||||
** We buffer here until we receive an complete PES Packet, which
|
||||
** is no problem, the audio is always far behind us.
|
||||
** cTsToPes::GetPes splits the packets.
|
||||
** @note vdr sends incomplete packets, va-api h264 decoder only
|
||||
** supports complete packets.
|
||||
** We buffer here until we receive an complete PES Packet, which
|
||||
** is no problem, the audio is always far behind us.
|
||||
** cTsToPes::GetPes splits the packets.
|
||||
**
|
||||
** @todo FIXME: combine the 5 ifs at start of the function
|
||||
** @todo FIXME: combine the 5 ifs at start of the function
|
||||
*/
|
||||
int PlayVideo(const uint8_t * data, int size)
|
||||
{
|
||||
@@ -2378,16 +2377,16 @@ extern uint8_t *CreateJpeg(uint8_t *, int *, int, int, int);
|
||||
#if defined(USE_JPEG) && JPEG_LIB_VERSION >= 80
|
||||
|
||||
/**
|
||||
** Create a jpeg image in memory.
|
||||
** Create a jpeg image in memory.
|
||||
**
|
||||
** @param image raw RGB image
|
||||
** @param raw_size size of raw image
|
||||
** @param size[out] size of jpeg image
|
||||
** @param quality jpeg quality
|
||||
** @param width number of horizontal pixels in image
|
||||
** @param height number of vertical pixels in image
|
||||
** @param image raw RGB image
|
||||
** @param raw_size size of raw image
|
||||
** @param size[out] size of jpeg image
|
||||
** @param quality jpeg quality
|
||||
** @param width number of horizontal pixels in image
|
||||
** @param height number of vertical pixels in image
|
||||
**
|
||||
** @returns allocated jpeg image.
|
||||
** @returns allocated jpeg image.
|
||||
*/
|
||||
uint8_t *CreateJpeg(uint8_t * image, int raw_size, int *size, int quality, int width, int height)
|
||||
{
|
||||
@@ -2429,13 +2428,13 @@ uint8_t *CreateJpeg(uint8_t * image, int raw_size, int *size, int quality, int w
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Grabs the currently visible screen image.
|
||||
** Grabs the currently visible screen image.
|
||||
**
|
||||
** @param size size of the returned data
|
||||
** @param jpeg flag true, create JPEG data
|
||||
** @param quality JPEG quality
|
||||
** @param width number of horizontal pixels in the frame
|
||||
** @param height number of vertical pixels in the frame
|
||||
** @param size size of the returned data
|
||||
** @param jpeg flag true, create JPEG data
|
||||
** @param quality JPEG quality
|
||||
** @param width number of horizontal pixels in the frame
|
||||
** @param height number of vertical pixels in the frame
|
||||
*/
|
||||
uint8_t *GrabImage(int *size, int jpeg, int quality, int width, int height)
|
||||
{
|
||||
@@ -2461,9 +2460,9 @@ uint8_t *GrabImage(int *size, int jpeg, int quality, int width, int height)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
** Set play mode, called on channel switch.
|
||||
** Set play mode, called on channel switch.
|
||||
**
|
||||
** @param play_mode play mode (none, video+audio, audio-only, ...)
|
||||
** @param play_mode play mode (none, video+audio, audio-only, ...)
|
||||
*/
|
||||
int SetPlayMode(int play_mode)
|
||||
{
|
||||
@@ -2514,8 +2513,8 @@ int SetPlayMode(int play_mode)
|
||||
}
|
||||
|
||||
/**
|
||||
** Gets the current System Time Counter, which can be used to
|
||||
** synchronize audio, video and subtitles.
|
||||
** Gets the current System Time Counter, which can be used to
|
||||
** synchronize audio, video and subtitles.
|
||||
*/
|
||||
int64_t GetSTC(void)
|
||||
{
|
||||
@@ -2528,11 +2527,11 @@ int64_t GetSTC(void)
|
||||
}
|
||||
|
||||
/**
|
||||
** Get video stream size and aspect.
|
||||
** Get video stream size and aspect.
|
||||
**
|
||||
** @param width[OUT] width of video stream
|
||||
** @param height[OUT] height of video stream
|
||||
** @param aspect[OUT] aspect ratio (4/3, 16/9, ...) of video stream
|
||||
** @param width[OUT] width of video stream
|
||||
** @param height[OUT] height of video stream
|
||||
** @param aspect[OUT] aspect ratio (4/3, 16/9, ...) of video stream
|
||||
*/
|
||||
void GetVideoSize(int *width, int *height, double *aspect)
|
||||
{
|
||||
@@ -2562,12 +2561,12 @@ void GetVideoSize(int *width, int *height, double *aspect)
|
||||
}
|
||||
|
||||
/**
|
||||
** Set trick play speed.
|
||||
** Set trick play speed.
|
||||
**
|
||||
** Every single frame shall then be displayed the given number of
|
||||
** times.
|
||||
** Every single frame shall then be displayed the given number of
|
||||
** times.
|
||||
**
|
||||
** @param speed trick speed
|
||||
** @param speed trick speed
|
||||
*/
|
||||
void TrickSpeed(int speed)
|
||||
{
|
||||
@@ -2583,7 +2582,7 @@ void TrickSpeed(int speed)
|
||||
}
|
||||
|
||||
/**
|
||||
** Clears all video and audio data from the device.
|
||||
** Clears all video and audio data from the device.
|
||||
*/
|
||||
void Clear(void)
|
||||
{
|
||||
@@ -2606,7 +2605,7 @@ void Clear(void)
|
||||
}
|
||||
|
||||
/**
|
||||
** Sets the device into play mode.
|
||||
** Sets the device into play mode.
|
||||
*/
|
||||
void Play(void)
|
||||
{
|
||||
@@ -2616,7 +2615,7 @@ void Play(void)
|
||||
}
|
||||
|
||||
/**
|
||||
** Sets the device into "freeze frame" mode.
|
||||
** Sets the device into "freeze frame" mode.
|
||||
*/
|
||||
void Freeze(void)
|
||||
{
|
||||
@@ -2626,7 +2625,7 @@ void Freeze(void)
|
||||
}
|
||||
|
||||
/**
|
||||
** Turns off audio while replaying.
|
||||
** Turns off audio while replaying.
|
||||
*/
|
||||
void Mute(void)
|
||||
{
|
||||
@@ -2636,10 +2635,10 @@ void Mute(void)
|
||||
}
|
||||
|
||||
/**
|
||||
** Display the given I-frame as a still picture.
|
||||
** Display the given I-frame as a still picture.
|
||||
**
|
||||
** @param data pes frame data
|
||||
** @param size number of bytes in frame
|
||||
** @param data pes frame data
|
||||
** @param size number of bytes in frame
|
||||
*/
|
||||
void StillPicture(const uint8_t * data, int size)
|
||||
{
|
||||
@@ -2746,17 +2745,17 @@ void StillPicture(const uint8_t * data, int size)
|
||||
}
|
||||
|
||||
/**
|
||||
** Poll if device is ready. Called by replay.
|
||||
** Poll if device is ready. Called by replay.
|
||||
**
|
||||
** This function is useless, the return value is ignored and
|
||||
** all buffers are overrun by vdr.
|
||||
** This function is useless, the return value is ignored and
|
||||
** all buffers are overrun by vdr.
|
||||
**
|
||||
** The dvd plugin is using this correct.
|
||||
** The dvd plugin is using this correct.
|
||||
**
|
||||
** @param timeout timeout to become ready in ms
|
||||
** @param timeout timeout to become ready in ms
|
||||
**
|
||||
** @retval true if ready
|
||||
** @retval false if busy
|
||||
** @retval true if ready
|
||||
** @retval false if busy
|
||||
*/
|
||||
int Poll(int timeout)
|
||||
{
|
||||
@@ -2789,9 +2788,9 @@ int Poll(int timeout)
|
||||
}
|
||||
|
||||
/**
|
||||
** Flush the device output buffers.
|
||||
** Flush the device output buffers.
|
||||
**
|
||||
** @param timeout timeout to flush in ms
|
||||
** @param timeout timeout to flush in ms
|
||||
*/
|
||||
int Flush(int timeout)
|
||||
{
|
||||
@@ -2809,11 +2808,11 @@ int Flush(int timeout)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
** Get OSD size and aspect.
|
||||
** Get OSD size and aspect.
|
||||
**
|
||||
** @param width[OUT] width of OSD
|
||||
** @param height[OUT] height of OSD
|
||||
** @param aspect[OUT] aspect ratio (4/3, 16/9, ...) of OSD
|
||||
** @param width[OUT] width of OSD
|
||||
** @param height[OUT] height of OSD
|
||||
** @param aspect[OUT] aspect ratio (4/3, 16/9, ...) of OSD
|
||||
*/
|
||||
void GetOsdSize(int *width, int *height, double *aspect)
|
||||
{
|
||||
@@ -2835,7 +2834,7 @@ void GetOsdSize(int *width, int *height, double *aspect)
|
||||
}
|
||||
|
||||
/**
|
||||
** Close OSD.
|
||||
** Close OSD.
|
||||
*/
|
||||
void OsdClose(void)
|
||||
{
|
||||
@@ -2843,16 +2842,16 @@ void OsdClose(void)
|
||||
}
|
||||
|
||||
/**
|
||||
** Draw an OSD pixmap.
|
||||
** Draw an OSD pixmap.
|
||||
**
|
||||
** @param xi x-coordinate in argb image
|
||||
** @param yi y-coordinate in argb image
|
||||
** @paran height height in pixel in argb image
|
||||
** @paran width width in pixel in argb image
|
||||
** @param pitch pitch of argb image
|
||||
** @param argb 32bit ARGB image data
|
||||
** @param x x-coordinate on screen of argb image
|
||||
** @param y y-coordinate on screen of argb image
|
||||
** @param xi x-coordinate in argb image
|
||||
** @param yi y-coordinate in argb image
|
||||
** @paran height height in pixel in argb image
|
||||
** @paran width width in pixel in argb image
|
||||
** @param pitch pitch of argb image
|
||||
** @param argb 32bit ARGB image data
|
||||
** @param x x-coordinate on screen of argb image
|
||||
** @param y y-coordinate on screen of argb image
|
||||
*/
|
||||
void OsdDrawARGB(int xi, int yi, int height, int width, int pitch, const uint8_t * argb, int x, int y)
|
||||
{
|
||||
@@ -2864,17 +2863,20 @@ void OsdDrawARGB(int xi, int yi, int height, int width, int pitch, const uint8_t
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
** Return command line help string.
|
||||
** Return command line help string.
|
||||
*/
|
||||
const char *CommandLineHelp(void)
|
||||
{
|
||||
return " -a device\taudio device (fe. alsa: hw:0,0 oss: /dev/dsp)\n"
|
||||
" -p device\taudio device for pass-through (hw:0,1 or /dev/dsp1)\n"
|
||||
" -c channel\taudio mixer channel name (fe. PCM)\n" " -d display\tdisplay of x11 server (fe. :0.0)\n"
|
||||
" -c channel\taudio mixer channel name (fe. PCM)\n" " -d display\tdisplay of x11 server (fe. :0.0)\n"
|
||||
" -f\t\tstart with fullscreen window (only with window manager)\n"
|
||||
" -g geometry\tx11 window geometry wxh+x+y\n" " -v device\tvideo driver device (cuvid)\n"
|
||||
" -g geometry\tx11 window geometry wxh+x+y\n"
|
||||
" -r Refresh\tRefreshrate for DRM (default is 50 Hz)\n"
|
||||
" -C Connector\tConnector for DRM (default is current Connector)\n"
|
||||
" -v device\tvideo driver device (cuvid)\n"
|
||||
" -s\t\tstart in suspended mode\n" " -x\t\tstart x11 server, with -xx try to connect, if this fails\n"
|
||||
" -X args\tX11 server arguments (f.e. -nocursor)\n" " -w workaround\tenable/disable workarounds\n"
|
||||
" -X args\tX11 server arguments (f.e. -nocursor)\n" " -w workaround\tenable/disable workarounds\n"
|
||||
"\tno-hw-decoder\t\tdisable hw decoder, use software decoder only\n"
|
||||
"\tno-mpeg-hw-decoder\tdisable hw decoder for mpeg only\n"
|
||||
"\tstill-hw-decoder\tenable hardware decoder for still-pictures\n"
|
||||
@@ -2883,14 +2885,14 @@ const char *CommandLineHelp(void)
|
||||
"\talsa-no-close-open\tdisable close open to fix alsa no sound bug\n"
|
||||
"\talsa-close-open-delay\tenable close open delay to fix no sound bug\n"
|
||||
"\tignore-repeat-pict\tdisable repeat pict message\n"
|
||||
"\tuse-possible-defect-frames prefer faster channel switch\n" " -D\t\tstart in detached mode\n";
|
||||
"\tuse-possible-defect-frames prefer faster channel switch\n" " -D\t\tstart in detached mode\n";
|
||||
}
|
||||
|
||||
/**
|
||||
** Process the command line arguments.
|
||||
** Process the command line arguments.
|
||||
**
|
||||
** @param argc number of arguments
|
||||
** @param argv arguments vector
|
||||
** @param argc number of arguments
|
||||
** @param argv arguments vector
|
||||
*/
|
||||
int ProcessArgs(int argc, char *const argv[])
|
||||
{
|
||||
@@ -2905,13 +2907,19 @@ int ProcessArgs(int argc, char *const argv[])
|
||||
#endif
|
||||
|
||||
for (;;) {
|
||||
switch (getopt(argc, argv, "-a:c:d:fg:p:sv:w:xDX:")) {
|
||||
switch (getopt(argc, argv, "-a:c:C:r:d:fg:p:sv:w:xDX:")) {
|
||||
case 'a': // audio device for pcm
|
||||
AudioSetDevice(optarg);
|
||||
continue;
|
||||
case 'c': // channel of audio mixer
|
||||
AudioSetChannel(optarg);
|
||||
continue;
|
||||
case 'C': // Connector for DRM
|
||||
VideoSetConnector(optarg);
|
||||
continue;
|
||||
case 'r': // Connector for DRM
|
||||
VideoSetRefresh(optarg);
|
||||
continue;
|
||||
case 'p': // pass-through audio device
|
||||
AudioSetPassthroughDevice(optarg);
|
||||
continue;
|
||||
@@ -3008,9 +3016,9 @@ static const char *X11Server = LOCALBASE "/bin/X"; ///< default x11 server
|
||||
static pid_t X11ServerPid; ///< x11 server pid
|
||||
|
||||
/**
|
||||
** USR1 signal handler.
|
||||
** USR1 signal handler.
|
||||
**
|
||||
** @param sig signal number
|
||||
** @param sig signal number
|
||||
*/
|
||||
static void Usr1Handler(int __attribute__((unused)) sig)
|
||||
{
|
||||
@@ -3020,7 +3028,7 @@ static void Usr1Handler(int __attribute__((unused)) sig)
|
||||
}
|
||||
|
||||
/**
|
||||
** Start the X server
|
||||
** Start the X server
|
||||
*/
|
||||
static void StartXServer(void)
|
||||
{
|
||||
@@ -3104,7 +3112,7 @@ static void StartXServer(void)
|
||||
}
|
||||
|
||||
/**
|
||||
** Exit + cleanup.
|
||||
** Exit + cleanup.
|
||||
*/
|
||||
void SoftHdDeviceExit(void)
|
||||
{
|
||||
@@ -3164,11 +3172,11 @@ void SoftHdDeviceExit(void)
|
||||
}
|
||||
|
||||
/**
|
||||
** Prepare plugin.
|
||||
** Prepare plugin.
|
||||
**
|
||||
** @retval 0 normal start
|
||||
** @retval 1 suspended start
|
||||
** @retval -1 detached start
|
||||
** @retval 0 normal start
|
||||
** @retval 1 suspended start
|
||||
** @retval -1 detached start
|
||||
*/
|
||||
int Start(void)
|
||||
{
|
||||
@@ -3210,9 +3218,9 @@ int Start(void)
|
||||
}
|
||||
|
||||
/**
|
||||
** Stop plugin.
|
||||
** Stop plugin.
|
||||
**
|
||||
** @note stop everything, but don't cleanup, module is still called.
|
||||
** @note stop everything, but don't cleanup, module is still called.
|
||||
*/
|
||||
void Stop(void)
|
||||
{
|
||||
@@ -3222,7 +3230,7 @@ void Stop(void)
|
||||
}
|
||||
|
||||
/**
|
||||
** Perform any cleanup or other regular tasks.
|
||||
** Perform any cleanup or other regular tasks.
|
||||
*/
|
||||
void Housekeeping(void)
|
||||
{
|
||||
@@ -3252,7 +3260,7 @@ void Housekeeping(void)
|
||||
}
|
||||
|
||||
/**
|
||||
** Main thread hook, periodic called from main thread.
|
||||
** Main thread hook, periodic called from main thread.
|
||||
*/
|
||||
void MainThreadHook(void)
|
||||
{
|
||||
@@ -3273,11 +3281,11 @@ void MainThreadHook(void)
|
||||
extern void DelPip(void);
|
||||
|
||||
/**
|
||||
** Suspend plugin.
|
||||
** Suspend plugin.
|
||||
**
|
||||
** @param video suspend closes video
|
||||
** @param audio suspend closes audio
|
||||
** @param dox11 suspend closes x11 server
|
||||
** @param video suspend closes video
|
||||
** @param audio suspend closes audio
|
||||
** @param dox11 suspend closes x11 server
|
||||
*/
|
||||
void Suspend(int video, int audio, int dox11)
|
||||
{
|
||||
@@ -3320,7 +3328,7 @@ void Suspend(int video, int audio, int dox11)
|
||||
}
|
||||
|
||||
/**
|
||||
** Resume plugin.
|
||||
** Resume plugin.
|
||||
*/
|
||||
void Resume(void)
|
||||
{
|
||||
@@ -3354,32 +3362,36 @@ void Resume(void)
|
||||
}
|
||||
|
||||
/*
|
||||
** Get decoder statistics.
|
||||
** Get decoder statistics.
|
||||
**
|
||||
** @param[out] missed missed frames
|
||||
** @param[out] duped duped frames
|
||||
** @param[out] dropped dropped frames
|
||||
** @param[out] count number of decoded frames
|
||||
** @param[out] missed missed frames
|
||||
** @param[out] duped duped frames
|
||||
** @param[out] dropped dropped frames
|
||||
** @param[out] count number of decoded frames
|
||||
*/
|
||||
void GetStats(int *missed, int *duped, int *dropped, int *counter, float *frametime)
|
||||
void GetStats(int *missed, int *duped, int *dropped, int *counter, float *frametime, int *width, int *height, int *color, int *eotf)
|
||||
{
|
||||
*missed = 0;
|
||||
*duped = 0;
|
||||
*dropped = 0;
|
||||
*counter = 0;
|
||||
*frametime = 0.0f;
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
*color = NULL;
|
||||
*eotf = NULL;
|
||||
if (MyVideoStream->HwDecoder) {
|
||||
VideoGetStats(MyVideoStream->HwDecoder, missed, duped, dropped, counter, frametime);
|
||||
VideoGetStats(MyVideoStream->HwDecoder, missed, duped, dropped, counter, frametime, width, height, color, eotf);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Scale the currently shown video.
|
||||
** Scale the currently shown video.
|
||||
**
|
||||
** @param x video window x coordinate OSD relative
|
||||
** @param y video window y coordinate OSD relative
|
||||
** @param width video window width OSD relative
|
||||
** @param height video window height OSD relative
|
||||
** @param x video window x coordinate OSD relative
|
||||
** @param y video window y coordinate OSD relative
|
||||
** @param width video window width OSD relative
|
||||
** @param height video window height OSD relative
|
||||
*/
|
||||
void ScaleVideo(int x, int y, int width, int height)
|
||||
{
|
||||
@@ -3395,16 +3407,16 @@ void ScaleVideo(int x, int y, int width, int height)
|
||||
#ifdef USE_PIP
|
||||
|
||||
/**
|
||||
** Set PIP position.
|
||||
** Set PIP position.
|
||||
**
|
||||
** @param x video window x coordinate OSD relative
|
||||
** @param y video window y coordinate OSD relative
|
||||
** @param width video window width OSD relative
|
||||
** @param height video window height OSD relative
|
||||
** @param pip_x pip window x coordinate OSD relative
|
||||
** @param pip_y pip window y coordinate OSD relative
|
||||
** @param pip_width pip window width OSD relative
|
||||
** @param pip_height pip window height OSD relative
|
||||
** @param x video window x coordinate OSD relative
|
||||
** @param y video window y coordinate OSD relative
|
||||
** @param width video window width OSD relative
|
||||
** @param height video window height OSD relative
|
||||
** @param pip_x pip window x coordinate OSD relative
|
||||
** @param pip_y pip window y coordinate OSD relative
|
||||
** @param pip_width pip window width OSD relative
|
||||
** @param pip_height pip window height OSD relative
|
||||
*/
|
||||
void PipSetPosition(int x, int y, int width, int height, int pip_x, int pip_y, int pip_width, int pip_height)
|
||||
{
|
||||
@@ -3420,16 +3432,16 @@ void PipSetPosition(int x, int y, int width, int height, int pip_x, int pip_y, i
|
||||
}
|
||||
|
||||
/**
|
||||
** Start PIP stream.
|
||||
** Start PIP stream.
|
||||
**
|
||||
** @param x video window x coordinate OSD relative
|
||||
** @param y video window y coordinate OSD relative
|
||||
** @param width video window width OSD relative
|
||||
** @param height video window height OSD relative
|
||||
** @param pip_x pip window x coordinate OSD relative
|
||||
** @param pip_y pip window y coordinate OSD relative
|
||||
** @param pip_width pip window width OSD relative
|
||||
** @param pip_height pip window height OSD relative
|
||||
** @param x video window x coordinate OSD relative
|
||||
** @param y video window y coordinate OSD relative
|
||||
** @param width video window width OSD relative
|
||||
** @param height video window height OSD relative
|
||||
** @param pip_x pip window x coordinate OSD relative
|
||||
** @param pip_y pip window y coordinate OSD relative
|
||||
** @param pip_width pip window width OSD relative
|
||||
** @param pip_height pip window height OSD relative
|
||||
*/
|
||||
void PipStart(int x, int y, int width, int height, int pip_x, int pip_y, int pip_width, int pip_height)
|
||||
{
|
||||
@@ -3444,7 +3456,7 @@ void PipStart(int x, int y, int width, int height, int pip_x, int pip_y, int pip
|
||||
}
|
||||
|
||||
/**
|
||||
** Stop PIP.
|
||||
** Stop PIP.
|
||||
*/
|
||||
void PipStop(void)
|
||||
{
|
||||
@@ -3464,12 +3476,12 @@ void PipStop(void)
|
||||
}
|
||||
|
||||
/**
|
||||
** PIP play video packet.
|
||||
** PIP play video packet.
|
||||
**
|
||||
** @param data data of exactly one complete PES packet
|
||||
** @param size size of PES packet
|
||||
** @param data data of exactly one complete PES packet
|
||||
** @param size size of PES packet
|
||||
**
|
||||
** @return number of bytes used, 0 if internal buffer are full.
|
||||
** @return number of bytes used, 0 if internal buffer are full.
|
||||
*/
|
||||
int PipPlayVideo(const uint8_t * data, int size)
|
||||
{
|
||||
|
@@ -96,7 +96,7 @@ extern "C"
|
||||
extern void Resume(void);
|
||||
|
||||
/// Get decoder statistics
|
||||
extern void GetStats(int *, int *, int *, int *, float *);
|
||||
extern void GetStats(int *, int *, int *, int *, float *, int *, int *, int *, int *);
|
||||
/// C plugin scale video
|
||||
extern void ScaleVideo(int, int, int, int);
|
||||
|
||||
|
10
video.h
10
video.h
@@ -219,7 +219,7 @@ extern uint8_t *VideoGrab(int *, int *, int *, int);
|
||||
extern uint8_t *VideoGrabService(int *, int *, int *);
|
||||
|
||||
/// Get decoder statistics.
|
||||
extern void VideoGetStats(VideoHwDecoder *, int *, int *, int *, int *, float *);
|
||||
extern void VideoGetStats(VideoHwDecoder *, int *, int *, int *, int *, float *, int *, int *, int *, int *);
|
||||
|
||||
/// Get video stream size
|
||||
extern void VideoGetVideoSize(VideoHwDecoder *, int *, int *, int *, int *);
|
||||
@@ -248,6 +248,14 @@ extern int VideoRaiseWindow(void);
|
||||
#ifdef USE_OPENGLOSD
|
||||
extern void ActivateOsd(GLuint, int, int, int, int);
|
||||
#endif
|
||||
|
||||
#ifdef GAMMA
|
||||
extern void Init_Gamma();
|
||||
extern void Exit_Gamma();
|
||||
extern void Set_Gamma(float, int);
|
||||
extern void Get_Gamma();
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
long int gettid()
|
||||
{
|
||||
|
Reference in New Issue
Block a user