48 Commits

Author SHA1 Message Date
jojo61
ad99776be8 Fix too small OSD Buffer 2025-02-09 13:15:40 +01:00
jojo61
f3ae69042f Prepare for adaptive streams 2025-01-11 12:16:22 +01:00
jojo61
6768bc5b18 Clarify use of LIBPLACEBO_GL 2024-10-22 09:39:51 +02:00
jojo61
e624e9c83d Fix compiling for softhddrm 2024-10-20 10:38:39 +02:00
jojo61
c907239bb5 better wording 2024-10-17 13:17:24 +02:00
jojo61
2c8e75e3ff Clarify RGB Level Setting 2024-10-17 13:12:22 +02:00
jojo61
e3fe68d7e6 Update Readme 2024-10-17 12:50:08 +02:00
jojo61
41da5ca526 Cleanup some Compiler Warnings 2024-10-15 09:59:20 +02:00
jojo61
68fc7e4511 No deinterlacing for HVEC 2024-09-26 16:27:17 +02:00
jojo61
46df18afe0 Fix Makefile for VDR*Elec thanks to rell 2024-09-24 17:23:30 +02:00
jojo61
0ff83f0e31 No DMA handling for CUVID with placebo 2024-09-04 07:57:46 +02:00
jojo61
230bb5ca11 Fix dma handling for cuvid with placebo 2024-09-03 09:16:45 +02:00
jojo61
f026e8e86d Silence some compiler warnings 2024-08-05 23:13:05 +02:00
jojo61
9dd936df86 Support for ffmpeg 7.0.x 2024-08-05 17:00:56 +02:00
jojo61
4e5529efcf Make compiler happy 2024-06-04 06:32:44 +02:00
jojo61
20f1bd45e6 Update Version 2024-03-12 09:11:40 +01:00
jojo61
7a7e09ff7a For drm try card1 if card0 fails. 2024-03-12 09:09:51 +01:00
jojo61
c4a660ede2 Update Version 2024-02-15 09:24:30 +01:00
jojo61
8e495266e2 Changes for egl exit 2024-02-15 09:23:09 +01:00
jojo61
f27e4fb35f Set Deinterlace Table for vaapi
Clean up exit on softhddrm
2024-02-05 10:50:19 +01:00
jojo61
e14ea73a00 Fix typo 2024-02-04 17:45:54 +01:00
jojo61
72cb77f771 Simplify Stereo Downmix 2024-02-04 10:32:33 +01:00
jojo61
c679d812d1 Fix flicker after mpv plugin use 2024-02-03 12:09:17 +01:00
jojo61
47b461ab46 Ffmeg does no Stereo Downmix for Codec AAV LATM
Do Downmix after decoding
2024-02-02 15:27:39 +01:00
jojo61
8629946041 Reverse pkg-config for glu glew and glut 2024-02-02 00:19:43 +01:00
jojo61
a222f6a1d5 Fix Makefile 2024-01-30 17:11:16 +01:00
jojo61
b51589aaa9 Fix Makefile (remove placebo default) 2024-01-30 17:07:53 +01:00
jojo61
c3af54aae0 Merge pull request #69 from tmn505/pkg-config
Use pkg-config for most configuration
2024-01-30 16:59:50 +01:00
Joachim König
7e387fa3f1 Enable Fastscale for vdr 2.6.6 2024-01-25 13:00:58 +01:00
Joachim König
f3e5a14fdf Move flush for libplacebo for PIP 2024-01-20 11:01:39 +01:00
Joachim König
aa0c2f80e4 Fix Renderproblem with libplacebo 2024-01-20 10:32:24 +01:00
Joachim König
215f251572 Update README 2024-01-20 09:04:17 +01:00
Joachim König
a425ec94e0 too much ) 2024-01-20 08:44:38 +01:00
Joachim König
91961bdffe Update for libplacebo API Version 342 2024-01-19 11:45:54 +01:00
Joachim König
f741dff042 Cleanup of broken mpeg fix 2024-01-19 09:45:14 +01:00
Joachim König
7a31761c89 Fix broken mpeg2 streams 2024-01-17 11:52:05 +01:00
Joachim König
d5ca73c22f Fix handling of vaapi filehandles 2024-01-11 10:59:09 +01:00
jojo61
6704b2ca5a Fix channelswitch with YADIF deinterlacer 2023-09-22 12:00:08 +02:00
jojo61
e0bbaceec0 Enable Yadif in Makefile
Reverse Bob for mpeg2
2023-09-20 12:43:52 +02:00
jojo61
45043b9ffc Changes for NVIDIA 535 and more for PIP with placebo 2023-09-18 11:52:03 +02:00
jojo61
a56b3737c7 Small Fix for PIP 2023-08-22 11:40:04 +02:00
jojo61
e59eeba0d2 Fix for Layer0 Pixmap alpha 2023-08-07 13:46:33 +02:00
jojo61
838dfab45b Fix PIP for cuvid (unstable) 2023-08-07 13:12:22 +02:00
jojo61
ddd44e6f62 Update README 2023-07-16 12:04:00 +02:00
jojo61
1390139cbd Disable Alsa Test with -w alsa-no-test 2023-07-16 10:07:21 +02:00
jojo61
f72653c3c1 Enable ALSA Test on start for Multi PCM. 2023-07-15 17:11:48 +02:00
Tomasz Maciej Nowak
4e96489e35 Query pkg-config for libplacebo library location
The location of libplacebo could vary between systems, as it's
fast-changing library with very dynamic API. This could force having
various versions on the system for different applications. Use
pkg-config to provide location of targeted libplacebo version, by
providing custom PKG_CONFIG_PATH environmet variable.
2023-02-18 17:08:58 +01:00
Tomasz Maciej Nowak
65017da5ac Provide linked libs by querying pkg-config 2023-02-18 17:08:58 +01:00
14 changed files with 667 additions and 429 deletions

View File

@@ -23,19 +23,18 @@ CUVID ?= 0
DRM ?= 0 DRM ?= 0
# use libplacebo - # use libplacebo -
# available for all decoders but for DRM you need LIBPLACEBO_GL # available for all decoders but for DRM and VAAPI you need LIBPLACEBO_GL
LIBPLACEBO ?= 1 LIBPLACEBO ?= 0
LIBPLACEBO_GL ?= 0 LIBPLACEBO_GL ?= 0
# use YADIF deint - only available with cuvid # use YADIF deint - only available with cuvid
#YADIF = 1 YADIF = 1
# use gamma correction # use gamma correction
#GAMMA ?= 0 #GAMMA ?= 0
CONFIG := -DDEBUG # remove '#' to enable debug output CONFIG := -DDEBUG # remove '#' to enable debug output
#--------------------- no more config needed past this point-------------------------------- #--------------------- no more config needed past this point--------------------------------
# sanitize selections -------- # sanitize selections --------
@@ -114,8 +113,8 @@ TMPDIR ?= /tmp
### The compiler options: ### The compiler options:
export CFLAGS = $(call PKGCFG,cflags) export CFLAGS = $(call PKGCFG,cflags) -fpermissive
export CXXFLAGS = $(call PKGCFG,cxxflags) export CXXFLAGS = $(call PKGCFG,cxxflags) -fpermissive
ifeq ($(CFLAGS),) ifeq ($(CFLAGS),)
$(warning CFLAGS not set) $(warning CFLAGS not set)
@@ -159,29 +158,29 @@ endif
ifeq ($(LIBPLACEBO_GL),1) ifeq ($(LIBPLACEBO_GL),1)
CONFIG += -DPLACEBO_GL -DPLACEBO CONFIG += -DPLACEBO_GL -DPLACEBO
LIBS += -lepoxy _CFLAGS += $(shell pkg-config --cflags libplacebo)
LIBS += -lplacebo LIBS += $(shell pkg-config --libs epoxy libplacebo)
else else
LIBS += -lEGL LIBS += $(shell pkg-config --libs egl)
endif endif
ifeq ($(LIBPLACEBO),1) ifeq ($(LIBPLACEBO),1)
CONFIG += -DPLACEBO CONFIG += -DPLACEBO
LIBS += -lEGL _CFLAGS += $(shell pkg-config --cflags libplacebo)
LIBS += -lplacebo LIBS += $(shell pkg-config --libs egl libplacebo)
endif endif
ifeq ($(DRM),1) ifeq ($(DRM),1)
PLUGIN = softhddrm PLUGIN = softhddrm
CONFIG += -DUSE_DRM -DVAAPI CONFIG += -DUSE_DRM -DVAAPI
_CFLAGS += $(shell pkg-config --cflags libdrm) _CFLAGS += $(shell pkg-config --cflags libdrm)
LIBS += -lgbm -ldrm -lEGL LIBS += $(shell pkg-config --libs egl gbm libdrm)
endif endif
ifeq ($(CUVID),1) ifeq ($(CUVID),1)
#CONFIG += -DUSE_PIP # PIP support #CONFIG += -DUSE_PIP # PIP support
CONFIG += -DCUVID # enable CUVID decoder CONFIG += -DCUVID # enable CUVID decoder
LIBS += -lEGL -lGL LIBS += $(shell pkg-config --libs egl gl)
ifeq ($(YADIF),1) ifeq ($(YADIF),1)
CONFIG += -DYADIF # Yadif only with CUVID CONFIG += -DYADIF # Yadif only with CUVID
endif endif
@@ -274,6 +273,7 @@ LIBS += -lcuda -lnvcuvid
endif endif
LIBS += -lGLEW -lGLU -ldl -lglut LIBS += -lGLEW -lGLU -ldl -lglut
#LIBS += -ldl $(shell pkg-config --libs glew glu glut)
### Includes and Defines (add further entries here): ### Includes and Defines (add further entries here):

View File

@@ -82,9 +82,6 @@ You have to adapt the Makefile. There are 3 possible Version that you can build:
runs without X Server. There are several commandline options to select the resolution and refresh rate. runs without X Server. There are several commandline options to select the resolution and refresh rate.
I recommend to use libplacebo and set LIBPLACEBO_GL=1 in the Makefile. I recommend to use libplacebo and set LIBPLACEBO_GL=1 in the Makefile.
You should use the following libplacebo Version:
https://github.com/haasn/libplacebo/archive/f2c4da9d6121bb330c9fff640aad40e98c081190.zip
Newer Versions may not work.
Install: Install:
@@ -123,6 +120,9 @@ Beginners Guide for libplacebo:
All other settings can be in their default state. All other settings can be in their default state.
Note for NUC11/12 Users:
Provide paramete -w alsa-no-test to get Audio working.
Beginning with libplacebo API 58 user shaders from mpv are supported. Use -S parameter to set the shader. Beginning with libplacebo API 58 user shaders from mpv are supported. Use -S parameter to set the shader.
The plugins searches the shaders in $ConfigDir/plugins/shaders for the shaders. One example shader is The plugins searches the shaders in $ConfigDir/plugins/shaders for the shaders. One example shader is
provided in the shader subdirectory. Copy it to e.g.: /etc/vdr/plugins/shaders and then start provided in the shader subdirectory. Copy it to e.g.: /etc/vdr/plugins/shaders and then start
@@ -251,8 +251,8 @@ Setup: /etc/vdr/setup.conf
(Red * 65536 + Green * 256 + Blue) (Red * 65536 + Green * 256 + Blue)
softhddevice.StudioLevels = 0 softhddevice.StudioLevels = 0
0 use PC levels (0-255) with vdpau. 0 use limited RGB (16-235) with placebo.
1 use studio levels (16-235) with vdpau. 1 use full RGB (0-255) with placebo.
softhddevice.Suspend.Close = 0 softhddevice.Suspend.Close = 0
1 suspend closes x11 window, connection and audio device. 1 suspend closes x11 window, connection and audio device.

258
audio.c
View File

@@ -93,6 +93,7 @@ static const AudioModule NoopModule; ///< forward definition of noop module
// Variables // Variables
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
char AudioAlsaNotest; ///< disable Audio capbility test
char AudioAlsaDriverBroken; ///< disable broken driver message char AudioAlsaDriverBroken; ///< disable broken driver message
char AudioAlsaNoCloseOpen; ///< disable alsa close/open fix char AudioAlsaNoCloseOpen; ///< disable alsa close/open fix
char AudioAlsaCloseOpenDelay; ///< enable alsa close/open delay fix char AudioAlsaCloseOpenDelay; ///< enable alsa close/open delay fix
@@ -2187,143 +2188,150 @@ found:
AudioRingInit(); AudioRingInit();
AudioUsedModule->Init(); AudioUsedModule->Init();
#if 1 if (AudioAlsaNotest) {
for (u = 0; u < AudioRatesMax; ++u) { for (u = 0; u < AudioRatesMax; ++u) {
AudioChannelMatrix[u][1]=AudioChannelMatrix[u][2]=AudioChannelMatrix[u][3]=AudioChannelMatrix[u][4]=\ AudioChannelMatrix[u][1]=AudioChannelMatrix[u][2]=2;
AudioChannelMatrix[u][5]=AudioChannelMatrix[u][6]=AudioChannelMatrix[u][7]=AudioChannelMatrix[u][8]=2; AudioChannelMatrix[u][3]=AudioChannelMatrix[u][4]=4;
//printf("audio: %6dHz supports %d %d %d %d %d %d %d %d channels\n", AudioRatesTable[u], AudioChannelMatrix[u][5]=AudioChannelMatrix[u][6]=6;
// AudioChannelMatrix[u][1], AudioChannelMatrix[u][2], AudioChannelMatrix[u][3], AudioChannelMatrix[u][4], AudioChannelMatrix[u][7]=AudioChannelMatrix[u][8]=8;
// AudioChannelMatrix[u][5], AudioChannelMatrix[u][6], AudioChannelMatrix[u][7], AudioChannelMatrix[u][8]); printf("audio: %6dHz supports %d %d %d %d %d %d %d %d channels\n", AudioRatesTable[u],
AudioChannelMatrix[u][1], AudioChannelMatrix[u][2], AudioChannelMatrix[u][3], AudioChannelMatrix[u][4],
AudioChannelMatrix[u][5], AudioChannelMatrix[u][6], AudioChannelMatrix[u][7], AudioChannelMatrix[u][8]);
}
AudioChannelsInHw[1]=AudioChannelsInHw[3]=AudioChannelsInHw[4]=AudioChannelsInHw[5]=AudioChannelsInHw[6]=AudioChannelsInHw[7]=AudioChannelsInHw[8]=0;
AudioChannelsInHw[2]=2;
} }
else {
AudioChannelsInHw[1]=AudioChannelsInHw[3]=AudioChannelsInHw[4]=AudioChannelsInHw[5]=AudioChannelsInHw[6]=AudioChannelsInHw[7]=AudioChannelsInHw[8]=0; //
AudioChannelsInHw[2]=2; // Check which channels/rates/formats are supported
// FIXME: we force 44.1Khz and 48Khz must be supported equal
#else // FIXME: should use bitmap of channels supported in RatesInHw
// // FIXME: use loop over sample-rates
// Check which channels/rates/formats are supported freq = 44100;
// FIXME: we force 44.1Khz and 48Khz must be supported equal AudioRatesInHw[Audio44100] = 0;
// FIXME: should use bitmap of channels supported in RatesInHw
// FIXME: use loop over sample-rates
freq = 44100;
AudioRatesInHw[Audio44100] = 0;
for (chan = 1; chan < 9; ++chan) {
int tchan;
int tfreq;
tchan = chan;
tfreq = freq;
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
AudioChannelsInHw[chan] = 0;
} else {
AudioChannelsInHw[chan] = chan;
AudioRatesInHw[Audio44100] |= (1 << chan);
}
}
freq = 48000;
AudioRatesInHw[Audio48000] = 0;
for (chan = 1; chan < 9; ++chan) {
int tchan;
int tfreq;
if (!AudioChannelsInHw[chan]) {
continue;
}
tchan = chan;
tfreq = freq;
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
// AudioChannelsInHw[chan] = 0;
} else {
AudioChannelsInHw[chan] = chan;
AudioRatesInHw[Audio48000] |= (1 << chan);
}
}
freq = 192000;
AudioRatesInHw[Audio192000] = 0;
for (chan = 1; chan < 9; ++chan) {
int tchan;
int tfreq;
if (!AudioChannelsInHw[chan]) {
continue;
}
tchan = chan;
tfreq = freq;
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
// AudioChannelsInHw[chan] = 0;
} else {
AudioChannelsInHw[chan] = chan;
AudioRatesInHw[Audio192000] |= (1 << chan);
}
}
// build channel support and conversion table
for (u = 0; u < AudioRatesMax; ++u) {
for (chan = 1; chan < 9; ++chan) { for (chan = 1; chan < 9; ++chan) {
AudioChannelMatrix[u][chan] = 0; int tchan;
if (!AudioRatesInHw[u]) { // rate unsupported int tfreq;
tchan = chan;
tfreq = freq;
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
AudioChannelsInHw[chan] = 0;
} else {
AudioChannelsInHw[chan] = chan;
AudioRatesInHw[Audio44100] |= (1 << chan);
}
}
freq = 48000;
AudioRatesInHw[Audio48000] = 0;
for (chan = 1; chan < 9; ++chan) {
int tchan;
int tfreq;
if (!AudioChannelsInHw[chan]) {
continue; continue;
} }
if (AudioChannelsInHw[chan]) { tchan = chan;
AudioChannelMatrix[u][chan] = chan; tfreq = freq;
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
// AudioChannelsInHw[chan] = 0;
} else { } else {
switch (chan) { AudioChannelsInHw[chan] = chan;
case 1: AudioRatesInHw[Audio48000] |= (1 << chan);
if (AudioChannelsInHw[2]) { }
AudioChannelMatrix[u][chan] = 2; }
} freq = 192000;
break; AudioRatesInHw[Audio192000] = 0;
case 2: for (chan = 1; chan < 9; ++chan) {
case 3: int tchan;
if (AudioChannelsInHw[4]) { int tfreq;
AudioChannelMatrix[u][chan] = 4;
if (!AudioChannelsInHw[chan]) {
continue;
}
tchan = chan;
tfreq = freq;
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
// AudioChannelsInHw[chan] = 0;
} else {
AudioChannelsInHw[chan] = chan;
AudioRatesInHw[Audio192000] |= (1 << chan);
}
}
// build channel support and conversion table
for (u = 0; u < AudioRatesMax; ++u) {
for (chan = 1; chan < 9; ++chan) {
AudioChannelMatrix[u][chan] = 0;
if (!AudioRatesInHw[u]) { // rate unsupported
continue;
}
if (AudioChannelsInHw[chan]) {
AudioChannelMatrix[u][chan] = chan;
} else {
switch (chan) {
case 1:
if (AudioChannelsInHw[2]) {
AudioChannelMatrix[u][chan] = 2;
}
break; break;
} case 2:
case 4: case 3:
if (AudioChannelsInHw[5]) { if (AudioChannelsInHw[4]) {
AudioChannelMatrix[u][chan] = 5; AudioChannelMatrix[u][chan] = 4;
break;
}
__attribute__ ((fallthrough));
case 4:
if (AudioChannelsInHw[5]) {
AudioChannelMatrix[u][chan] = 5;
break;
}
__attribute__ ((fallthrough));
case 5:
if (AudioChannelsInHw[6]) {
AudioChannelMatrix[u][chan] = 6;
break;
}
__attribute__ ((fallthrough));
case 6:
if (AudioChannelsInHw[7]) {
AudioChannelMatrix[u][chan] = 7;
break;
}
__attribute__ ((fallthrough));
case 7:
if (AudioChannelsInHw[8]) {
AudioChannelMatrix[u][chan] = 8;
break;
}
__attribute__ ((fallthrough));
case 8:
if (AudioChannelsInHw[6]) {
AudioChannelMatrix[u][chan] = 6;
break;
}
if (AudioChannelsInHw[2]) {
AudioChannelMatrix[u][chan] = 2;
break;
}
if (AudioChannelsInHw[1]) {
AudioChannelMatrix[u][chan] = 1;
break;
}
break; break;
} }
case 5:
if (AudioChannelsInHw[6]) {
AudioChannelMatrix[u][chan] = 6;
break;
}
case 6:
if (AudioChannelsInHw[7]) {
AudioChannelMatrix[u][chan] = 7;
break;
}
case 7:
if (AudioChannelsInHw[8]) {
AudioChannelMatrix[u][chan] = 8;
break;
}
case 8:
if (AudioChannelsInHw[6]) {
AudioChannelMatrix[u][chan] = 6;
break;
}
if (AudioChannelsInHw[2]) {
AudioChannelMatrix[u][chan] = 2;
break;
}
if (AudioChannelsInHw[1]) {
AudioChannelMatrix[u][chan] = 1;
break;
}
break;
} }
} }
} }
for (u = 0; u < AudioRatesMax; ++u) {
Debug(3,"audio: %6dHz supports %d %d %d %d %d %d %d %d channels\n", AudioRatesTable[u],
AudioChannelMatrix[u][1], AudioChannelMatrix[u][2], AudioChannelMatrix[u][3], AudioChannelMatrix[u][4],
AudioChannelMatrix[u][5], AudioChannelMatrix[u][6], AudioChannelMatrix[u][7], AudioChannelMatrix[u][8]);
}
} }
for (u = 0; u < AudioRatesMax; ++u) {
Info(_("audio: %6dHz supports %d %d %d %d %d %d %d %d channels\n"), AudioRatesTable[u],
AudioChannelMatrix[u][1], AudioChannelMatrix[u][2], AudioChannelMatrix[u][3], AudioChannelMatrix[u][4],
AudioChannelMatrix[u][5], AudioChannelMatrix[u][6], AudioChannelMatrix[u][7], AudioChannelMatrix[u][8]);
}
#endif
#ifdef USE_AUDIO_THREAD #ifdef USE_AUDIO_THREAD
if (AudioUsedModule->Thread) { // supports threads if (AudioUsedModule->Thread) { // supports threads
AudioInitThread(); AudioInitThread();

View File

@@ -60,6 +60,7 @@ extern void AudioExit(void); ///< cleanup and exit audio module
// Variables // Variables
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
extern char AudioAlsaNotest; ///< disable Alsa capability test
extern char AudioAlsaDriverBroken; ///< disable broken driver message extern char AudioAlsaDriverBroken; ///< disable broken driver message
extern char AudioAlsaNoCloseOpen; ///< disable alsa close/open fix extern char AudioAlsaNoCloseOpen; ///< disable alsa close/open fix
extern char AudioAlsaCloseOpenDelay; ///< enable alsa close/open delay fix extern char AudioAlsaCloseOpenDelay; ///< enable alsa close/open delay fix

159
codec.c
View File

@@ -125,7 +125,7 @@ struct _video_decoder_
*/ */
static enum AVPixelFormat Codec_get_format(AVCodecContext *video_ctx, const enum AVPixelFormat *fmt) { static enum AVPixelFormat Codec_get_format(AVCodecContext *video_ctx, const enum AVPixelFormat *fmt) {
VideoDecoder *decoder; VideoDecoder *decoder;
enum AVPixelFormat fmt1;
decoder = video_ctx->opaque; decoder = video_ctx->opaque;
// bug in ffmpeg 1.1.1, called with zero width or height // bug in ffmpeg 1.1.1, called with zero width or height
@@ -208,9 +208,13 @@ void CodecVideoDelDecoder(VideoDecoder *decoder) { free(decoder); }
** @param codec_id video codec id ** @param codec_id video codec id
*/ */
void CodecVideoOpen(VideoDecoder *decoder, int codec_id) { void CodecVideoOpen(VideoDecoder *decoder, int codec_id) {
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,0,100)
AVCodec *video_codec; AVCodec *video_codec;
#else
const AVCodec *video_codec;
#endif
const char *name; const char *name;
int ret, deint = 2; int ret;
Debug(3, "***************codec: Video Open using video codec ID %#06x (%s)\n", codec_id, Debug(3, "***************codec: Video Open using video codec ID %#06x (%s)\n", codec_id,
avcodec_get_name(codec_id)); avcodec_get_name(codec_id));
@@ -260,14 +264,12 @@ void CodecVideoOpen(VideoDecoder *decoder, int codec_id) {
decoder->VideoCtx->pkt_timebase.num = 1; decoder->VideoCtx->pkt_timebase.num = 1;
decoder->VideoCtx->pkt_timebase.den = 90000; decoder->VideoCtx->pkt_timebase.den = 90000;
decoder->VideoCtx->framerate.num = 50; //decoder->VideoCtx->framerate.num = 50;
decoder->VideoCtx->framerate.den = 1; //decoder->VideoCtx->framerate.den = 1;
pthread_mutex_lock(&CodecLockMutex); pthread_mutex_lock(&CodecLockMutex);
// open codec // open codec
#ifdef YADIF
deint = 2;
#endif
#if defined VAAPI #if defined VAAPI
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,8,100) #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,8,100)
@@ -305,18 +307,19 @@ void CodecVideoOpen(VideoDecoder *decoder, int codec_id) {
#endif #endif
#ifdef CUVID #ifdef CUVID
int deint = 2;
if (strcmp(decoder->VideoCodec->long_name, if (strcmp(decoder->VideoCodec->long_name,
"Nvidia CUVID MPEG2VIDEO decoder") == 0) { // deinterlace for mpeg2 is somehow broken "Nvidia CUVID MPEG2VIDEO decoder") == 0) { // deinterlace for mpeg2 is somehow broken
if (av_opt_set_int(decoder->VideoCtx->priv_data, "deint", deint, 0) < 0) { // adaptive if (av_opt_set_int(decoder->VideoCtx->priv_data, "deint", deint, 0) < 0) { // adaptive
pthread_mutex_unlock(&CodecLockMutex); pthread_mutex_unlock(&CodecLockMutex);
Fatal(_("codec: can't set option deint to video codec!\n")); Fatal(_("codec: can't set option deint to video codec!\n"));
} }
#if 1
if (av_opt_set_int(decoder->VideoCtx->priv_data, "surfaces", 9, 0) < 0) { if (av_opt_set_int(decoder->VideoCtx->priv_data, "surfaces", 10, 0) < 0) {
pthread_mutex_unlock(&CodecLockMutex); pthread_mutex_unlock(&CodecLockMutex);
Fatal(_("codec: can't set option surfces to video codec!\n")); Fatal(_("codec: can't set option surfces to video codec!\n"));
} }
#endif
if (av_opt_set(decoder->VideoCtx->priv_data, "drop_second_field", "false", 0) < 0) { if (av_opt_set(decoder->VideoCtx->priv_data, "drop_second_field", "false", 0) < 0) {
pthread_mutex_unlock(&CodecLockMutex); pthread_mutex_unlock(&CodecLockMutex);
Fatal(_("codec: can't set option drop 2.field to video codec!\n")); Fatal(_("codec: can't set option drop 2.field to video codec!\n"));
@@ -326,12 +329,10 @@ void CodecVideoOpen(VideoDecoder *decoder, int codec_id) {
pthread_mutex_unlock(&CodecLockMutex); pthread_mutex_unlock(&CodecLockMutex);
Fatal(_("codec: can't set option deint to video codec!\n")); Fatal(_("codec: can't set option deint to video codec!\n"));
} }
#if 1
if (av_opt_set_int(decoder->VideoCtx->priv_data, "surfaces", 13, 0) < 0) { if (av_opt_set_int(decoder->VideoCtx->priv_data, "surfaces", 13, 0) < 0) {
pthread_mutex_unlock(&CodecLockMutex); pthread_mutex_unlock(&CodecLockMutex);
Fatal(_("codec: can't set option surfces to video codec!\n")); Fatal(_("codec: can't set option surfces to video codec!\n"));
} }
#endif
if (av_opt_set(decoder->VideoCtx->priv_data, "drop_second_field", "false", 0) < 0) { if (av_opt_set(decoder->VideoCtx->priv_data, "drop_second_field", "false", 0) < 0) {
pthread_mutex_unlock(&CodecLockMutex); pthread_mutex_unlock(&CodecLockMutex);
Fatal(_("codec: can't set option drop 2.field to video codec!\n")); Fatal(_("codec: can't set option drop 2.field to video codec!\n"));
@@ -391,15 +392,19 @@ void CodecVideoClose(VideoDecoder *video_decoder) {
Debug(3, "CodecVideoClose\n"); Debug(3, "CodecVideoClose\n");
if (video_decoder->VideoCtx) { if (video_decoder->VideoCtx) {
pthread_mutex_lock(&CodecLockMutex); pthread_mutex_lock(&CodecLockMutex);
#if 1
frame = av_frame_alloc(); frame = av_frame_alloc();
avcodec_send_packet(video_decoder->VideoCtx, NULL); avcodec_send_packet(video_decoder->VideoCtx, NULL);
while (avcodec_receive_frame(video_decoder->VideoCtx, frame) >= 0) while (avcodec_receive_frame(video_decoder->VideoCtx, frame) >= 0)
; ;
av_frame_free(&frame); av_frame_free(&frame);
#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(55,63,100)
avcodec_close(video_decoder->VideoCtx);
av_freep(&video_decoder->VideoCtx);
#else
avcodec_free_context(&video_decoder->VideoCtx);
#endif #endif
avcodec_close(video_decoder->VideoCtx);
av_freep(&video_decoder->VideoCtx);
pthread_mutex_unlock(&CodecLockMutex); pthread_mutex_unlock(&CodecLockMutex);
} }
} }
@@ -464,6 +469,7 @@ void CodecVideoDecode(VideoDecoder *decoder, const AVPacket *avpkt) {
*pkt = *avpkt; // use copy *pkt = *avpkt; // use copy
ret = avcodec_send_packet(video_ctx, pkt); ret = avcodec_send_packet(video_ctx, pkt);
//printf("send packet %x\n",ret);
if (ret < 0) { if (ret < 0) {
return; return;
} }
@@ -482,7 +488,8 @@ void CodecVideoDecode(VideoDecoder *decoder, const AVPacket *avpkt) {
return; return;
} }
if (ret >= 0) { if (ret >= 0) {
if (decoder->filter) { //printf("Videosize %d:%d ttf %d\n",frame->width,frame->height,frame->interlaced_frame);
if ((frame->flags & AV_FRAME_FLAG_INTERLACED) && decoder->filter) {
if (decoder->filter == 1) { if (decoder->filter == 1) {
if (init_filters(video_ctx, decoder->HwDecoder, frame) < 0) { if (init_filters(video_ctx, decoder->HwDecoder, frame) < 0) {
Debug(3, "video: Init of VAAPI deint Filter failed\n"); Debug(3, "video: Init of VAAPI deint Filter failed\n");
@@ -492,8 +499,7 @@ void CodecVideoDecode(VideoDecoder *decoder, const AVPacket *avpkt) {
decoder->filter = 2; decoder->filter = 2;
} }
} }
if (frame->interlaced_frame && decoder->filter == 2 && if (decoder->filter == 2) {
(frame->height != 720)) { // broken ZDF sends Interlaced flag
push_filters(video_ctx, decoder->HwDecoder, frame); push_filters(video_ctx, decoder->HwDecoder, frame);
continue; continue;
} }
@@ -516,7 +522,7 @@ void CodecVideoDecode(VideoDecoder *decoder, const AVPacket *avpkt) {
int ret, ret1; int ret, ret1;
int got_frame; int got_frame;
int consumed = 0; int consumed = 0;
static uint64_t first_time = 0; //static uint64_t first_time = 0;
const AVPacket *pkt; const AVPacket *pkt;
next_part: next_part:
@@ -525,7 +531,6 @@ next_part:
pkt = avpkt; // use copy pkt = avpkt; // use copy
got_frame = 0; got_frame = 0;
// printf("decode packet %d\n",(GetusTicks()-first_time)/1000000);
ret1 = avcodec_send_packet(video_ctx, pkt); ret1 = avcodec_send_packet(video_ctx, pkt);
// first_time = GetusTicks(); // first_time = GetusTicks();
@@ -545,28 +550,27 @@ next_part:
frame = av_frame_alloc(); frame = av_frame_alloc();
ret = avcodec_receive_frame(video_ctx, frame); // get new frame ret = avcodec_receive_frame(video_ctx, frame); // get new frame
if (ret >= 0) { // one is avail. if (ret >= 0) { // one is avail.
//first_time = frame->pts;
got_frame = 1; got_frame = 1;
} else { } else {
got_frame = 0; got_frame = 0;
} }
// printf("got %s packet from //printf("got %s packet from decoder\n",got_frame?"1":"no");
// decoder\n",got_frame?"1":"no");
if (got_frame) { // frame completed if (got_frame) { // frame completed
// printf("video frame pts %#012" PRIx64 " // printf("video frame pts %#012" PRIx64 "
//%dms\n",frame->pts,(int)(apts - frame->pts) / 90); //%dms\n",frame->pts,(int)(apts - frame->pts) / 90);
#ifdef YADIF #ifdef YADIF
if (decoder->filter) { if ((frame->flags & AV_FRAME_FLAG_INTERLACED) && decoder->filter) {
if (decoder->filter == 1) { if (decoder->filter == 1) {
if (init_filters(video_ctx, decoder->HwDecoder, frame) < 0) { if (init_filters(video_ctx, decoder->HwDecoder, frame) < 0) {
Fatal(_("video: Init of YADIF Filter failed\n")); Debug(3,"video: Init of YADIF Filter failed\n");
decoder->filter = 0; decoder->filter = 0;
} else { } else {
Debug(3, "Init YADIF ok\n"); Debug(3, "Init YADIF ok\n");
decoder->filter = 2; decoder->filter = 2;
} }
} }
if (frame->interlaced_frame && decoder->filter == 2 && if (decoder->filter == 2) {
(frame->height != 720)) { // broken ZDF sends Interlaced flag
ret = push_filters(video_ctx, decoder->HwDecoder, frame); ret = push_filters(video_ctx, decoder->HwDecoder, frame);
// av_frame_unref(frame); // av_frame_unref(frame);
continue; continue;
@@ -620,7 +624,11 @@ typedef struct _audio_decoder_ AudioDecoder;
/// Audio decoder structure. /// Audio decoder structure.
/// ///
struct _audio_decoder_ { struct _audio_decoder_ {
AVCodec *AudioCodec; ///< audio codec #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,0,100)
AVCodec *AudioCodec; ///< audio codec
#else
const AVCodec *AudioCodec; ///< audio codec
#endif
AVCodecContext *AudioCtx; ///< audio codec context AVCodecContext *AudioCtx; ///< audio codec context
char Passthrough; ///< current pass-through flags char Passthrough; ///< current pass-through flags
@@ -707,8 +715,11 @@ void CodecAudioDelDecoder(AudioDecoder *decoder) {
** @param codec_id audio codec id ** @param codec_id audio codec id
*/ */
void CodecAudioOpen(AudioDecoder *audio_decoder, int codec_id) { void CodecAudioOpen(AudioDecoder *audio_decoder, int codec_id) {
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,0,100)
AVCodec *audio_codec; AVCodec *audio_codec;
#else
const AVCodec *audio_codec;
#endif
Debug(3, "codec: using audio codec ID %#06x (%s)\n", codec_id, avcodec_get_name(codec_id)); Debug(3, "codec: using audio codec ID %#06x (%s)\n", codec_id, avcodec_get_name(codec_id));
if (!(audio_codec = avcodec_find_decoder(codec_id))) { if (!(audio_codec = avcodec_find_decoder(codec_id))) {
// if (!(audio_codec = avcodec_find_decoder(codec_id))) { // if (!(audio_codec = avcodec_find_decoder(codec_id))) {
@@ -721,9 +732,6 @@ void CodecAudioOpen(AudioDecoder *audio_decoder, int codec_id) {
Fatal(_("codec: can't allocate audio codec context\n")); Fatal(_("codec: can't allocate audio codec context\n"));
} }
if (CodecDownmix) {
audio_decoder->AudioCtx->request_channel_layout = AV_CH_LAYOUT_STEREO;
}
pthread_mutex_lock(&CodecLockMutex); pthread_mutex_lock(&CodecLockMutex);
// open codec // open codec
if (1) { if (1) {
@@ -763,8 +771,12 @@ void CodecAudioClose(AudioDecoder *audio_decoder) {
} }
if (audio_decoder->AudioCtx) { if (audio_decoder->AudioCtx) {
pthread_mutex_lock(&CodecLockMutex); pthread_mutex_lock(&CodecLockMutex);
avcodec_close(audio_decoder->AudioCtx); #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(55,63,100)
av_freep(&audio_decoder->AudioCtx); avcodec_close(audio_decoder->AudioCtx);
av_freep(&audio_decoder->AudioCtx);
#else
avcodec_free_context(&audio_decoder->AudioCtx);
#endif
pthread_mutex_unlock(&CodecLockMutex); pthread_mutex_unlock(&CodecLockMutex);
} }
} }
@@ -876,19 +888,35 @@ static int CodecAudioUpdateHelper(AudioDecoder *audio_decoder, int *passthrough)
int err; int err;
audio_ctx = audio_decoder->AudioCtx; audio_ctx = audio_decoder->AudioCtx;
Debug(3, "codec/audio: format change %s %dHz *%d channels%s%s%s%s%s\n",
av_get_sample_fmt_name(audio_ctx->sample_fmt), audio_ctx->sample_rate, audio_ctx->channels,
CodecPassthrough & CodecPCM ? " PCM" : "", CodecPassthrough & CodecMPA ? " MPA" : "", Debug(3, "codec/audio: format change %s %dHz *%d channels%s%s%s%s%s%s\n",
CodecPassthrough & CodecAC3 ? " AC-3" : "", CodecPassthrough & CodecEAC3 ? " E-AC-3" : "", av_get_sample_fmt_name(audio_ctx->sample_fmt), audio_ctx->sample_rate,
CodecPassthrough ? " pass-through" : ""); #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100)
audio_ctx->channels, CodecPassthrough & CodecPCM ? " PCM" : "",
#else
audio_ctx->ch_layout.nb_channels, CodecPassthrough & CodecPCM ? " PCM" : "",
#endif
CodecPassthrough & CodecMPA ? " MPA" : "",
CodecPassthrough & CodecAC3 ? " AC-3" : "",
CodecPassthrough & CodecEAC3 ? " E-AC-3" : "",
CodecPassthrough & CodecDTS ? " DTS" : "",
CodecPassthrough ? " pass-through" : "");
*passthrough = 0; *passthrough = 0;
audio_decoder->SampleRate = audio_ctx->sample_rate; audio_decoder->SampleRate = audio_ctx->sample_rate;
audio_decoder->HwSampleRate = audio_ctx->sample_rate; audio_decoder->HwSampleRate = audio_ctx->sample_rate;
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100)
audio_decoder->Channels = audio_ctx->channels; audio_decoder->Channels = audio_ctx->channels;
audio_decoder->HwChannels = audio_ctx->channels; audio_decoder->HwChannels = audio_ctx->channels;
audio_decoder->Passthrough = CodecPassthrough; #else
audio_decoder->Channels = audio_ctx->ch_layout.nb_channels;
audio_decoder->HwChannels = audio_ctx->ch_layout.nb_channels;
#endif
if (CodecDownmix && !CodecPassthrough) audio_decoder->HwChannels = 2;
audio_decoder->Passthrough = CodecPassthrough;
// SPDIF/HDMI pass-through // SPDIF/HDMI pass-through
if ((CodecPassthrough & CodecAC3 && audio_ctx->codec_id == AV_CODEC_ID_AC3) || if ((CodecPassthrough & CodecAC3 && audio_ctx->codec_id == AV_CODEC_ID_AC3) ||
(CodecPassthrough & CodecEAC3 && audio_ctx->codec_id == AV_CODEC_ID_EAC3)) { (CodecPassthrough & CodecEAC3 && audio_ctx->codec_id == AV_CODEC_ID_EAC3)) {
@@ -917,9 +945,15 @@ static int CodecAudioUpdateHelper(AudioDecoder *audio_decoder, int *passthrough)
} }
} }
Debug(3, "codec/audio: resample %s %dHz *%d -> %s %dHz *%d\n", av_get_sample_fmt_name(audio_ctx->sample_fmt), Debug(3, "codec/audio: resample %s %dHz *%d -> %s %dHz *%d\n",
audio_ctx->sample_rate, audio_ctx->channels, av_get_sample_fmt_name(AV_SAMPLE_FMT_S16), av_get_sample_fmt_name(audio_ctx->sample_fmt), audio_ctx->sample_rate,
audio_decoder->HwSampleRate, audio_decoder->HwChannels); #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100)
audio_ctx->channels, av_get_sample_fmt_name(AV_SAMPLE_FMT_S16),
#else
audio_ctx->ch_layout.nb_channels, av_get_sample_fmt_name(AV_SAMPLE_FMT_S16),
#endif
audio_decoder->HwSampleRate, audio_decoder->HwChannels);
return 0; return 0;
} }
@@ -1148,6 +1182,12 @@ static void CodecAudioUpdateFormat(AudioDecoder *audio_decoder) {
int passthrough; int passthrough;
const AVCodecContext *audio_ctx; const AVCodecContext *audio_ctx;
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100)
int64_t dmlayout = AV_CH_LAYOUT_STEREO;
#else
AVChannelLayout dmlayout = AV_CHANNEL_LAYOUT_STEREO;
#endif
if (CodecAudioUpdateHelper(audio_decoder, &passthrough)) { if (CodecAudioUpdateHelper(audio_decoder, &passthrough)) {
// FIXME: handle swresample format conversions. // FIXME: handle swresample format conversions.
return; return;
@@ -1158,6 +1198,12 @@ static void CodecAudioUpdateFormat(AudioDecoder *audio_decoder) {
audio_ctx = audio_decoder->AudioCtx; audio_ctx = audio_decoder->AudioCtx;
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100)
if (!CodecDownmix || CodecPassthrough) dmlayout = audio_ctx->channel_layout;
#else
if (!CodecDownmix || CodecPassthrough) dmlayout = audio_ctx->ch_layout;
#endif
#ifdef DEBUG #ifdef DEBUG
if (audio_ctx->sample_fmt == AV_SAMPLE_FMT_S16 && audio_ctx->sample_rate == audio_decoder->HwSampleRate && if (audio_ctx->sample_fmt == AV_SAMPLE_FMT_S16 && audio_ctx->sample_rate == audio_decoder->HwSampleRate &&
!CodecAudioDrift) { !CodecAudioDrift) {
@@ -1165,15 +1211,26 @@ static void CodecAudioUpdateFormat(AudioDecoder *audio_decoder) {
fprintf(stderr, "no resample needed\n"); fprintf(stderr, "no resample needed\n");
} }
#endif #endif
#if LIBSWRESAMPLE_VERSION_INT < AV_VERSION_INT(4,5,100)
audio_decoder->Resample =
swr_alloc_set_opts(audio_decoder->Resample, dmlayout,
AV_SAMPLE_FMT_S16, audio_decoder->HwSampleRate,
audio_ctx->channel_layout, audio_ctx->sample_fmt,
#else
swr_alloc_set_opts2(&audio_decoder->Resample, &dmlayout,
AV_SAMPLE_FMT_S16, audio_decoder->HwSampleRate,
&audio_ctx->ch_layout, audio_ctx->sample_fmt,
#endif
audio_ctx->sample_rate, 0, NULL);
audio_decoder->Resample = swr_alloc_set_opts(audio_decoder->Resample, audio_ctx->channel_layout, AV_SAMPLE_FMT_S16,
audio_decoder->HwSampleRate, audio_ctx->channel_layout,
audio_ctx->sample_fmt, audio_ctx->sample_rate, 0, NULL);
if (audio_decoder->Resample) { if (audio_decoder->Resample) {
swr_init(audio_decoder->Resample); swr_init(audio_decoder->Resample);
} else { } else {
Error(_("codec/audio: can't setup resample\n")); Error(_("codec/audio: can't setup resample\n"));
} }
} }
/** /**
@@ -1216,7 +1273,11 @@ void CodecAudioDecode(AudioDecoder *audio_decoder, const AVPacket *avpkt) {
// format change // format change
if (audio_decoder->Passthrough != CodecPassthrough || if (audio_decoder->Passthrough != CodecPassthrough ||
audio_decoder->SampleRate != audio_ctx->sample_rate || audio_decoder->SampleRate != audio_ctx->sample_rate ||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100)
audio_decoder->Channels != audio_ctx->channels) { audio_decoder->Channels != audio_ctx->channels) {
#else
audio_decoder->Channels != audio_ctx->ch_layout.nb_channels) {
#endif
CodecAudioUpdateFormat(audio_decoder); CodecAudioUpdateFormat(audio_decoder);
} }
if (!audio_decoder->HwSampleRate || !audio_decoder->HwChannels) { if (!audio_decoder->HwSampleRate || !audio_decoder->HwChannels) {
@@ -1225,13 +1286,15 @@ void CodecAudioDecode(AudioDecoder *audio_decoder, const AVPacket *avpkt) {
if (CodecAudioPassthroughHelper(audio_decoder, avpkt)) { if (CodecAudioPassthroughHelper(audio_decoder, avpkt)) {
return; return;
} }
if (audio_decoder->Resample) { if (audio_decoder->Resample) {
uint8_t outbuf[8192 * 2 * 8]; uint8_t outbuf[8192 * 2 * 8];
uint8_t *out[1]; uint8_t *out[1];
out[0] = outbuf; out[0] = outbuf;
ret = swr_convert(audio_decoder->Resample, out, sizeof(outbuf) / (2 * audio_decoder->HwChannels), ret = swr_convert(audio_decoder->Resample, out, sizeof(outbuf) / (2 * audio_decoder->HwChannels),
(const uint8_t **)frame->extended_data, frame->nb_samples); (const uint8_t **)frame->extended_data, frame->nb_samples);
if (ret > 0) { if (ret > 0) {
if (!(audio_decoder->Passthrough & CodecPCM)) { if (!(audio_decoder->Passthrough & CodecPCM)) {
CodecReorderAudioFrame((int16_t *)outbuf, ret * 2 * audio_decoder->HwChannels, CodecReorderAudioFrame((int16_t *)outbuf, ret * 2 * audio_decoder->HwChannels,

View File

@@ -56,7 +56,11 @@ struct _video_decoder_ {
VideoHwDecoder *HwDecoder; ///< video hardware decoder VideoHwDecoder *HwDecoder; ///< video hardware decoder
int GetFormatDone; ///< flag get format called! int GetFormatDone; ///< flag get format called!
AVCodec *VideoCodec; ///< video codec #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,0,100)
AVCodec *VideoCodec; ///< video codec
#else
const AVCodec *VideoCodec; ///< video codec
#endif
AVCodecContext *VideoCtx; ///< video codec context AVCodecContext *VideoCtx; ///< video codec context
// #ifdef FFMPEG_WORKAROUND_ARTIFACTS // #ifdef FFMPEG_WORKAROUND_ARTIFACTS
int FirstKeyFrame; ///< flag first frame int FirstKeyFrame; ///< flag first frame

38
drm.c
View File

@@ -209,8 +209,11 @@ static int FindDevice(VideoRender *render) {
int found = 0; int found = 0;
render->fd_drm = open("/dev/dri/card0", O_RDWR); render->fd_drm = open("/dev/dri/card0", O_RDWR);
if (render->fd_drm < 0) { if (render->fd_drm < 0) {
fprintf(stderr, "FindDevice: cannot open /dev/dri/card0: %m\n"); render->fd_drm = open("/dev/dri/card1", O_RDWR);
return -errno; if (render->fd_drm < 0) {
fprintf(stderr, "FindDevice: cannot open /dev/dri/card0 or card1: %m\n");
return -errno;
}
} }
int ret = drmSetMaster(render->fd_drm); int ret = drmSetMaster(render->fd_drm);
@@ -545,6 +548,7 @@ static void drm_swap_buffers() {
m_need_modeset = 0; m_need_modeset = 0;
has_modeset = 1; has_modeset = 1;
} }
drmModeSetCrtc(render->fd_drm, render->crtc_id, fb, 0, 0, &render->connector_id, 1, &render->mode); drmModeSetCrtc(render->fd_drm, render->crtc_id, fb, 0, 0, &render->connector_id, 1, &render->mode);
if (previous_bo) { if (previous_bo) {
@@ -562,15 +566,16 @@ static void drm_clean_up() {
return; return;
Debug(3, "drm clean up\n"); Debug(3, "drm clean up\n");
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 (previous_bo) { if (previous_bo) {
drmModeRmFB(render->fd_drm, previous_fb); drmModeRmFB(render->fd_drm, previous_fb);
gbm_surface_release_buffer(gbm.surface, previous_bo); 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 (has_modeset) { if (has_modeset) {
drmModeAtomicReqPtr ModeReq; drmModeAtomicReqPtr ModeReq;
const uint32_t flags = DRM_MODE_ATOMIC_ALLOW_MODESET; const uint32_t flags = DRM_MODE_ATOMIC_ALLOW_MODESET;
@@ -613,22 +618,29 @@ static void drm_clean_up() {
if (render->hdr_blob_id) if (render->hdr_blob_id)
drmModeDestroyPropertyBlob(render->fd_drm, render->hdr_blob_id); drmModeDestroyPropertyBlob(render->fd_drm, render->hdr_blob_id);
render->hdr_blob_id = 0; render->hdr_blob_id = 0;
#if 0
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroySurface(eglDisplay, eglSurface); eglDestroySurface(eglDisplay, eglSurface);
EglCheck(); EglCheck();
gbm_surface_destroy(gbm.surface);
eglDestroyContext(eglDisplay, eglContext);
EglCheck();
eglDestroyContext(eglDisplay, eglSharedContext); eglDestroyContext(eglDisplay, eglSharedContext);
EglCheck(); EglCheck();
eglDestroyContext(eglDisplay, eglContext);
EglCheck();
eglSharedContext = NULL; eglSharedContext = NULL;
eglContext = NULL;
eglTerminate(eglDisplay); eglTerminate(eglDisplay);
EglCheck(); EglCheck();
eglDisplay = NULL;
#endif
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroySurface(eglDisplay, eglSurface);
EglCheck();
eglSurface = NULL;
gbm_surface_destroy(gbm.surface);
gbm_device_destroy(gbm.dev); gbm_device_destroy(gbm.dev);
drmDropMaster(render->fd_drm); drmDropMaster(render->fd_drm);
close(render->fd_drm); close(render->fd_drm);
eglDisplay = NULL;
free(render); free(render);
render = NULL;
Debug(3, "nach drm clean up\n");
} }

View File

@@ -726,14 +726,15 @@ bool cOglCmdDeleteFb::Execute(void) {
//------------------ cOglCmdRenderFbToBufferFb -------------------- //------------------ cOglCmdRenderFbToBufferFb --------------------
cOglCmdRenderFbToBufferFb::cOglCmdRenderFbToBufferFb(cOglFb *fb, cOglFb *buffer, GLint x, GLint y, GLint transparency, cOglCmdRenderFbToBufferFb::cOglCmdRenderFbToBufferFb(cOglFb *fb, cOglFb *buffer, GLint x, GLint y, GLint transparency,
GLint drawPortX, GLint drawPortY) GLint drawPortX, GLint drawPortY, bool alphablending)
: cOglCmd(fb) { : cOglCmd(fb) {
this->buffer = buffer; this->buffer = buffer;
this->x = (GLfloat)x; this->x = (GLfloat)x;
this->y = (GLfloat)y; this->y = (GLfloat)y;
this->drawPortX = (GLfloat)drawPortX; this->drawPortX = (GLfloat)drawPortX;
this->drawPortY = (GLfloat)drawPortY; this->drawPortY = (GLfloat)drawPortY;
this->transparency = transparency; this->transparency = (alphablending ? transparency : ALPHA_OPAQUE);
this->alphablending = alphablending;
} }
bool cOglCmdRenderFbToBufferFb::Execute(void) { bool cOglCmdRenderFbToBufferFb::Execute(void) {
@@ -773,11 +774,14 @@ bool cOglCmdRenderFbToBufferFb::Execute(void) {
if (!fb->BindTexture()) if (!fb->BindTexture())
return false; return false;
if (!alphablending)
VertexBuffers[vbTexture]->DisableBlending();
VertexBuffers[vbTexture]->Bind(); VertexBuffers[vbTexture]->Bind();
VertexBuffers[vbTexture]->SetVertexData(quadVertices); VertexBuffers[vbTexture]->SetVertexData(quadVertices);
VertexBuffers[vbTexture]->DrawArrays(); VertexBuffers[vbTexture]->DrawArrays();
VertexBuffers[vbTexture]->Unbind(); VertexBuffers[vbTexture]->Unbind();
if (!alphablending)
VertexBuffers[vbTexture]->EnableBlending();
buffer->Unbind(); buffer->Unbind();
return true; return true;
@@ -1283,10 +1287,10 @@ bool cOglCmdDrawImage::Execute(void) {
pthread_mutex_unlock(&OSDMutex); pthread_mutex_unlock(&OSDMutex);
#endif #endif
GLfloat x1 = x; // left GLfloat x1 = x; // left
GLfloat y1 = y; // top GLfloat y1 = y; // top
GLfloat x2 = x + width; // right GLfloat x2 = x + width * scaleX; // right
GLfloat y2 = y + height; // bottom GLfloat y2 = y + height * scaleY; // bottom
GLfloat quadVertices[] = { GLfloat quadVertices[] = {
x1, y2, 0.0, 1.0, // left bottom x1, y2, 0.0, 1.0, // left bottom
@@ -1320,19 +1324,21 @@ bool cOglCmdDrawImage::Execute(void) {
} }
//------------------ cOglCmdDrawTexture -------------------- //------------------ cOglCmdDrawTexture --------------------
cOglCmdDrawTexture::cOglCmdDrawTexture(cOglFb *fb, sOglImage *imageRef, GLint x, GLint y) : cOglCmd(fb) { cOglCmdDrawTexture::cOglCmdDrawTexture(cOglFb *fb, sOglImage *imageRef, GLint x, GLint y, double scaleX, double scaleY) : cOglCmd(fb) {
this->imageRef = imageRef; this->imageRef = imageRef;
this->x = x; this->x = x;
this->y = y; this->y = y;
this->scaleX = scaleX;
this->scaleY = scaleY;
} }
bool cOglCmdDrawTexture::Execute(void) { bool cOglCmdDrawTexture::Execute(void) {
if (imageRef->width <= 0 || imageRef->height <= 0) if (imageRef->width <= 0 || imageRef->height <= 0)
return false; return false;
GLfloat x1 = x; // top GLfloat x1 = x; // top
GLfloat y1 = y; // left GLfloat y1 = y; // left
GLfloat x2 = x + imageRef->width; // right GLfloat x2 = x + imageRef->width * scaleX; // right
GLfloat y2 = y + imageRef->height; // bottom GLfloat y2 = y + imageRef->height * scaleY; // bottom
GLfloat quadVertices[] = { GLfloat quadVertices[] = {
// Pos // TexCoords // Pos // TexCoords
@@ -1826,6 +1832,10 @@ void cOglPixmap::Fill(tColor Color) {
} }
void cOglPixmap::DrawImage(const cPoint &Point, const cImage &Image) { void cOglPixmap::DrawImage(const cPoint &Point, const cImage &Image) {
DrawScaledImage(Point, Image);
}
void cOglPixmap::DrawScaledImage(const cPoint &Point, const cImage &Image, double FactorX, double FactorY, bool AntiAlias) {
if (!oglThread->Active()) if (!oglThread->Active())
return; return;
tColor *argb = MALLOC(tColor, Image.Width() * Image.Height()); tColor *argb = MALLOC(tColor, Image.Width() * Image.Height());
@@ -1834,19 +1844,25 @@ void cOglPixmap::DrawImage(const cPoint &Point, const cImage &Image) {
return; return;
memcpy(argb, Image.Data(), sizeof(tColor) * Image.Width() * Image.Height()); memcpy(argb, Image.Data(), sizeof(tColor) * Image.Width() * Image.Height());
oglThread->DoCmd(new cOglCmdDrawImage(fb, argb, Image.Width(), Image.Height(), Point.X(), Point.Y())); oglThread->DoCmd(new cOglCmdDrawImage(fb, argb, Image.Width(), Image.Height(), Point.X(), Point.Y(), true, FactorX, FactorY));
SetDirty(); SetDirty();
MarkDrawPortDirty(cRect(Point, cSize(Image.Width(), Image.Height())).Intersected(DrawPort().Size())); MarkDrawPortDirty(cRect(Point, cSize(Image.Width() * FactorX, Image.Height() * FactorY)).Intersected(DrawPort().Size()));
} }
void cOglPixmap::DrawImage(const cPoint &Point, int ImageHandle) { void cOglPixmap::DrawImage(const cPoint &Point, int ImageHandle) {
DrawScaledImage(Point, ImageHandle);
}
void cOglPixmap::DrawScaledImage(const cPoint &Point, int ImageHandle, double FactorX, double FactorY, bool AntiAlias) {
if (!oglThread->Active()) if (!oglThread->Active())
return; return;
if (ImageHandle < 0 && oglThread->GetImageRef(ImageHandle)) { if (ImageHandle < 0 && oglThread->GetImageRef(ImageHandle)) {
sOglImage *img = oglThread->GetImageRef(ImageHandle); sOglImage *img = oglThread->GetImageRef(ImageHandle);
oglThread->DoCmd(new cOglCmdDrawTexture(fb, img, Point.X(), Point.Y())); oglThread->DoCmd(new cOglCmdDrawTexture(fb, img, Point.X(), Point.Y(), FactorX, FactorY));
SetDirty();
MarkDrawPortDirty(cRect(Point, cSize(img->width * FactorX, img->height * FactorY)).Intersected(DrawPort().Size()));
} }
/* /*
Fallback to VDR implementation, needs to separate cSoftOsdProvider from Fallback to VDR implementation, needs to separate cSoftOsdProvider from
@@ -1854,8 +1870,6 @@ void cOglPixmap::DrawImage(const cPoint &Point, int ImageHandle) {
DrawImage(Point, *cSoftOsdProvider::GetImageData(ImageHandle)); DrawImage(Point, *cSoftOsdProvider::GetImageData(ImageHandle));
} }
*/ */
SetDirty();
MarkDrawPortDirty(DrawPort());
} }
void cOglPixmap::DrawPixel(const cPoint &Point, tColor Color) { void cOglPixmap::DrawPixel(const cPoint &Point, tColor Color) {
@@ -2096,6 +2110,14 @@ cPixmap *cOglOsd::CreatePixmap(int Layer, const cRect &ViewPort, const cRect &Dr
return NULL; return NULL;
} }
extern "C" {void VideoSetOsdSize(int, int ) ;}
void SetOsdPosition(int Left, int Top, int Width, int Height) {
printf("Set OSD Position %d %d\n",Width,Height);
VideoSetOsdSize( Width, Height) ;
}
void cOglOsd::DestroyPixmap(cPixmap *Pixmap) { void cOglOsd::DestroyPixmap(cPixmap *Pixmap) {
if (!oglThread->Active()) if (!oglThread->Active())
return; return;
@@ -2141,10 +2163,16 @@ void cOglOsd::Flush(void) {
for (int i = 0; i < oglPixmaps.Size(); i++) { for (int i = 0; i < oglPixmaps.Size(); i++) {
if (oglPixmaps[i]) { if (oglPixmaps[i]) {
if (oglPixmaps[i]->Layer() == layer) { if (oglPixmaps[i]->Layer() == layer) {
oglThread->DoCmd(new cOglCmdRenderFbToBufferFb( bool alphablending = layer == 0 ? false : true; // Decide wether to render (with alpha) or copy a pixmap
oglPixmaps[i]->Fb(), bFb, oglPixmaps[i]->ViewPort().X(), oglThread->DoCmd(new cOglCmdRenderFbToBufferFb( oglPixmaps[i]->Fb(),
(!isSubtitleOsd) ? oglPixmaps[i]->ViewPort().Y() : 0, oglPixmaps[i]->Alpha(), bFb,
oglPixmaps[i]->DrawPort().X(), oglPixmaps[i]->DrawPort().Y())); oglPixmaps[i]->ViewPort().X(),
(!isSubtitleOsd) ? oglPixmaps[i]->ViewPort().Y() : 0,
oglPixmaps[i]->Alpha(),
oglPixmaps[i]->DrawPort().X(),
oglPixmaps[i]->DrawPort().Y(),
alphablending
));
oglPixmaps[i]->SetDirty(false); oglPixmaps[i]->SetDirty(false);
} }
} }

View File

@@ -290,10 +290,11 @@ class cOglCmdRenderFbToBufferFb : public cOglCmd {
GLfloat x, y; GLfloat x, y;
GLfloat drawPortX, drawPortY; GLfloat drawPortX, drawPortY;
GLint transparency; GLint transparency;
GLint alphablending;
public: public:
cOglCmdRenderFbToBufferFb(cOglFb *fb, cOglFb *buffer, GLint x, GLint y, GLint transparency, GLint drawPortX, cOglCmdRenderFbToBufferFb(cOglFb *fb, cOglFb *buffer, GLint x, GLint y, GLint transparency, GLint drawPortX,
GLint drawPortY); GLint drawPortY, bool alphablending);
virtual ~cOglCmdRenderFbToBufferFb(void){}; virtual ~cOglCmdRenderFbToBufferFb(void){};
virtual const char *Description(void) { return "Render Framebuffer to Buffer"; } virtual const char *Description(void) { return "Render Framebuffer to Buffer"; }
virtual bool Execute(void); virtual bool Execute(void);
@@ -402,9 +403,10 @@ class cOglCmdDrawTexture : public cOglCmd {
private: private:
sOglImage *imageRef; sOglImage *imageRef;
GLint x, y; GLint x, y;
GLfloat scaleX, scaleY;
public: public:
cOglCmdDrawTexture(cOglFb *fb, sOglImage *imageRef, GLint x, GLint y); cOglCmdDrawTexture(cOglFb *fb, sOglImage *imageRef, GLint x, GLint y, double scaleX = 1.0f, double scaleY = 1.0f);
virtual ~cOglCmdDrawTexture(void){}; virtual ~cOglCmdDrawTexture(void){};
virtual const char *Description(void) { return "Draw Texture"; } virtual const char *Description(void) { return "Draw Texture"; }
virtual bool Execute(void); virtual bool Execute(void);
@@ -500,6 +502,8 @@ class cOglPixmap : public cPixmap {
virtual void Fill(tColor Color); virtual void Fill(tColor Color);
virtual void DrawImage(const cPoint &Point, const cImage &Image); virtual void DrawImage(const cPoint &Point, const cImage &Image);
virtual void DrawImage(const cPoint &Point, int ImageHandle); virtual void DrawImage(const cPoint &Point, int ImageHandle);
virtual void DrawScaledImage(const cPoint &Point, const cImage &Image, double FactorX = 1.0f, double FactorY = 1.0f, bool AntiAlias = false);
virtual void DrawScaledImage(const cPoint &Point, int ImageHandle, double FactorX = 1.0f, double FactorY = 1.0f, bool AntiAlias = false);
virtual void DrawPixel(const cPoint &Point, tColor Color); virtual void DrawPixel(const cPoint &Point, tColor Color);
virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0, virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0,
bool Overlay = false); bool Overlay = false);
@@ -528,6 +532,7 @@ class cOglOsd : public cOsd {
public: public:
cOglOsd(int Left, int Top, uint Level, std::shared_ptr<cOglThread> oglThread); cOglOsd(int Left, int Top, uint Level, std::shared_ptr<cOglThread> oglThread);
virtual ~cOglOsd(); virtual ~cOglOsd();
static void SetOsdPosition(int Left, int Top, int Width, int Height);
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas); virtual eOsdError SetAreas(const tArea *Areas, int NumAreas);
virtual cPixmap *CreatePixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null); virtual cPixmap *CreatePixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null);
virtual void DestroyPixmap(cPixmap *Pixmap); virtual void DestroyPixmap(cPixmap *Pixmap);

View File

@@ -126,7 +126,7 @@ void pl_shader_append_v(const char *fmt, ...) {
Fatal(_("Shaderlenght fault\n")); Fatal(_("Shaderlenght fault\n"));
strcat(shv, temp); strcat(shv, temp);
} }
#ifndef PLACEBO
static void compile_attach_shader(GLuint program, GLenum type, const char *source) { static void compile_attach_shader(GLuint program, GLenum type, const char *source) {
GLuint shader; GLuint shader;
GLint status = 1234, log_length; GLint status = 1234, log_length;
@@ -159,6 +159,7 @@ static void link_shader(GLuint program) {
Debug(3, "Link Status %d loglen %d\n", status, log_length); Debug(3, "Link Status %d loglen %d\n", status, log_length);
} }
static GLuint sc_generate_osd(GLuint gl_prog) { static GLuint sc_generate_osd(GLuint gl_prog) {
Debug(3, "vor create osd\n"); Debug(3, "vor create osd\n");
@@ -209,7 +210,7 @@ static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace) {
int n; int n;
GLint cmsLoc; GLint cmsLoc;
float *m, *c, *cms; float *m, *c, *cms;
char *frag; //char *frag;
GL_init(); GL_init();
GLSL("%s\n", gl_version); GLSL("%s\n", gl_version);
@@ -446,3 +447,4 @@ static void render_pass_quad(int flip, float xcrop, float ycrop) {
for (n = 0; vertex_vao[n].name; n++) for (n = 0; vertex_vao[n].name; n++)
glDisableVertexAttribArray(n); glDisableVertexAttribArray(n);
} }
#endif

View File

@@ -61,7 +61,7 @@ extern void ToggleLUT();
/// vdr-plugin version number. /// vdr-plugin version number.
/// Makefile extracts the version number for generating the file name /// Makefile extracts the version number for generating the file name
/// for the distribution archive. /// for the distribution archive.
static const char *const VERSION = "3.12" static const char *const VERSION = "3.29"
#ifdef GIT_REV #ifdef GIT_REV
"-GIT" GIT_REV "-GIT" GIT_REV
#endif #endif
@@ -658,6 +658,20 @@ class cDummyPixmap : public cPixmap {
(void)Point; (void)Point;
(void)ImageHandle; (void)ImageHandle;
} }
virtual void DrawScaledImage(const cPoint &Point, const cImage &Image, double FactorX, double FactorY, bool AntiAlias) {
(void)Point;
(void)Image;
(void)FactorX;
(void)FactorY;
(void)AntiAlias;
}
virtual void DrawScaledImage(const cPoint &Point, int ImageHandle, double FactorX, double FactorY, bool AntiAlias) {
(void)Point;
(void)ImageHandle;
(void)FactorX;
(void)FactorY;
(void)AntiAlias;
}
virtual void DrawPixel(const cPoint &Point, tColor Color) { virtual void DrawPixel(const cPoint &Point, tColor Color) {
(void)Point; (void)Point;
(void)Color; (void)Color;
@@ -723,6 +737,12 @@ class cDummyOsd : public cOsd {
public: public:
cDummyOsd(int Left, int Top, uint Level) : cOsd(Left, Top, Level) {} cDummyOsd(int Left, int Top, uint Level) : cOsd(Left, Top, Level) {}
virtual ~cDummyOsd() {} virtual ~cDummyOsd() {}
static void SetOsdPosition(int Left, int Top, int Width, int Height) {
(void) Left;
(void) Top;
(void) Width;
(void) Height;
}
virtual cPixmap *CreatePixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null) { virtual cPixmap *CreatePixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null) {
p = new cDummyPixmap(Layer, ViewPort, DrawPort); p = new cDummyPixmap(Layer, ViewPort, DrawPort);
return p; return p;
@@ -1147,9 +1167,9 @@ void cMenuSetupSoft::Create(void) {
if (scalers == 0) { if (scalers == 0) {
scalingtest[0] = (char *)"Off"; scalingtest[0] = (char *)"Off";
for (scalers = 0; pl_named_filters[scalers].name != NULL; scalers++) { for (scalers = 0; pl_filter_presets[scalers].name != NULL; scalers++) {
scaling[scalers] = (char *)pl_named_filters[scalers].name; scaling[scalers] = (char *)pl_filter_presets[scalers].name;
scalingtest[scalers + 1] = (char *)pl_named_filters[scalers].name; scalingtest[scalers + 1] = (char *)pl_filter_presets[scalers].name;
// printf("Scaler %s\n",pl_named_filters[scalers].name); // printf("Scaler %s\n",pl_named_filters[scalers].name);
} }
// scalers -= 2; // scalers -= 2;
@@ -1206,7 +1226,7 @@ void cMenuSetupSoft::Create(void) {
Add(new cMenuEditIntItem(tr("Video background color (Alpha)"), (int *)&BackgroundAlpha, 0, 0xFF)); Add(new cMenuEditIntItem(tr("Video background color (Alpha)"), (int *)&BackgroundAlpha, 0, 0xFF));
#endif #endif
#ifdef PLACEBO #ifdef PLACEBO
Add(new cMenuEditBoolItem(tr("Use studio levels"), &StudioLevels, trVDR("no"), trVDR("yes"))); Add(new cMenuEditBoolItem(tr("Color Range"), &StudioLevels, trVDR("limited RGB"), trVDR("Full RGB")));
#endif #endif
Add(new cMenuEditBoolItem(tr("60hz display mode"), &_60HzMode, trVDR("no"), trVDR("yes"))); Add(new cMenuEditBoolItem(tr("60hz display mode"), &_60HzMode, trVDR("no"), trVDR("yes")));
Add(new cMenuEditBoolItem(tr("Soft start a/v sync"), &SoftStartSync, trVDR("no"), trVDR("yes"))); Add(new cMenuEditBoolItem(tr("Soft start a/v sync"), &SoftStartSync, trVDR("no"), trVDR("yes")));
@@ -1506,8 +1526,8 @@ void cMenuSetupSoft::Store(void) {
SetupStore("DetachFromMainMenu", ConfigDetachFromMainMenu = DetachFromMainMenu); SetupStore("DetachFromMainMenu", ConfigDetachFromMainMenu = DetachFromMainMenu);
switch (OsdSize) { switch (OsdSize) {
case 0: case 0:
OsdWidth = 0; OsdWidth = 1920;
OsdHeight = 0; OsdHeight = 1080;
break; break;
case 1: case 1:
OsdWidth = 1920; OsdWidth = 1920;

View File

@@ -60,7 +60,7 @@
#include "codec.h" #include "codec.h"
// clang-format on // clang-format on
#ifdef DEBUG #if 0
static int DumpH264(const uint8_t *data, int size); static int DumpH264(const uint8_t *data, int size);
static void DumpMpeg(const uint8_t *data, int size); static void DumpMpeg(const uint8_t *data, int size);
#endif #endif
@@ -662,7 +662,13 @@ static void PesParse(PesDemux *pesdx, const uint8_t *data, int size, int is_star
break; break;
} }
if (r > 0) { if (r > 0) {
AVPacket avpkt[1]; #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,33,100)
AVPacket avpkt[1];
av_init_packet(avpkt);
#else
AVPacket * avpkt;
avpkt = av_packet_alloc();
#endif
// new codec id, close and open new // new codec id, close and open new
if (AudioCodecID != codec_id) { if (AudioCodecID != codec_id) {
@@ -671,13 +677,15 @@ static void PesParse(PesDemux *pesdx, const uint8_t *data, int size, int is_star
CodecAudioOpen(MyAudioDecoder, codec_id); CodecAudioOpen(MyAudioDecoder, codec_id);
AudioCodecID = codec_id; AudioCodecID = codec_id;
} }
av_init_packet(avpkt);
avpkt->data = (void *)q; avpkt->data = (void *)q;
avpkt->size = r; avpkt->size = r;
avpkt->pts = pesdx->PTS; avpkt->pts = pesdx->PTS;
avpkt->dts = pesdx->DTS; avpkt->dts = pesdx->DTS;
// FIXME: not aligned for ffmpeg // FIXME: not aligned for ffmpeg
CodecAudioDecode(MyAudioDecoder, avpkt); CodecAudioDecode(MyAudioDecoder, avpkt);
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58,33,100)
av_packet_free(&avpkt);
#endif
pesdx->PTS = AV_NOPTS_VALUE; pesdx->PTS = AV_NOPTS_VALUE;
pesdx->DTS = AV_NOPTS_VALUE; pesdx->DTS = AV_NOPTS_VALUE;
pesdx->Skip += r; pesdx->Skip += r;
@@ -1147,21 +1155,28 @@ int PlayAudio(const uint8_t *data, int size, uint8_t id) {
break; break;
} }
if (r > 0) { if (r > 0) {
AVPacket avpkt[1]; #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,33,100)
AVPacket avpkt[1];
av_init_packet(avpkt);
#else
AVPacket * avpkt;
avpkt = av_packet_alloc();
#endif
// new codec id, close and open new // new codec id, close and open new
if (AudioCodecID != codec_id) { if (AudioCodecID != codec_id) {
CodecAudioClose(MyAudioDecoder); CodecAudioClose(MyAudioDecoder);
CodecAudioOpen(MyAudioDecoder, codec_id); CodecAudioOpen(MyAudioDecoder, codec_id);
AudioCodecID = codec_id; AudioCodecID = codec_id;
} }
av_init_packet(avpkt);
avpkt->data = (void *)p; avpkt->data = (void *)p;
avpkt->size = r; avpkt->size = r;
avpkt->pts = AudioAvPkt->pts; avpkt->pts = AudioAvPkt->pts;
avpkt->dts = AudioAvPkt->dts; avpkt->dts = AudioAvPkt->dts;
// FIXME: not aligned for ffmpeg // FIXME: not aligned for ffmpeg
CodecAudioDecode(MyAudioDecoder, avpkt); CodecAudioDecode(MyAudioDecoder, avpkt);
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58,33,100)
av_packet_free(&avpkt);
#endif
AudioAvPkt->pts = AV_NOPTS_VALUE; AudioAvPkt->pts = AV_NOPTS_VALUE;
AudioAvPkt->dts = AV_NOPTS_VALUE; AudioAvPkt->dts = AV_NOPTS_VALUE;
p += r; p += r;
@@ -1625,7 +1640,7 @@ static void VideoMpegEnqueue(VideoStream *stream, int64_t pts, int64_t dts, cons
** @param avpkt ffmpeg a/v packet ** @param avpkt ffmpeg a/v packet
*/ */
#ifndef USE_PIP #if !defined USE_PIP && !defined VAAPI
static void FixPacketForFFMpeg(VideoDecoder *vdecoder, AVPacket *avpkt) { static void FixPacketForFFMpeg(VideoDecoder *vdecoder, AVPacket *avpkt) {
uint8_t *p; uint8_t *p;
int n; int n;
@@ -1993,7 +2008,7 @@ static void StopVideo(void) {
#endif #endif
} }
#ifdef DEBUG #if 0
/** /**
** Dump mpeg video packet. ** Dump mpeg video packet.
@@ -2817,8 +2832,8 @@ const char *CommandLineHelp(void) {
"\tstill-h264-hw-decoder\tenable h264 hw decoder for still-pictures\n" "\tstill-h264-hw-decoder\tenable h264 hw decoder for still-pictures\n"
"\talsa-driver-broken\tdisable broken alsa driver message\n" "\talsa-driver-broken\tdisable broken alsa driver message\n"
"\talsa-no-close-open\tdisable close open to fix alsa no sound bug\n" "\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 " "\talsa-no-test\tdisable Alsa Capability test on start for NUC11/12\n"
"bug\n" "\talsa-close-open-delay\tenable close open delay to fix no sound bug\n"
"\tignore-repeat-pict\tdisable repeat pict message\n" "\tignore-repeat-pict\tdisable repeat pict message\n"
"\tuse-possible-defect-frames prefer faster channel switch\n" "\tuse-possible-defect-frames prefer faster channel switch\n"
" -D\t\tstart in detached mode\n"; " -D\t\tstart in detached mode\n";
@@ -2908,6 +2923,8 @@ int ProcessArgs(int argc, char *const argv[]) {
AudioAlsaDriverBroken = 1; AudioAlsaDriverBroken = 1;
} else if (!strcasecmp("alsa-no-close-open", optarg)) { } else if (!strcasecmp("alsa-no-close-open", optarg)) {
AudioAlsaNoCloseOpen = 1; AudioAlsaNoCloseOpen = 1;
} else if (!strcasecmp("alsa-no-test", optarg)) {
AudioAlsaNotest = 1;
} else if (!strcasecmp("alsa-close-open-delay", optarg)) { } else if (!strcasecmp("alsa-close-open-delay", optarg)) {
AudioAlsaCloseOpenDelay = 1; AudioAlsaCloseOpenDelay = 1;
} else if (!strcasecmp("ignore-repeat-pict", optarg)) { } else if (!strcasecmp("ignore-repeat-pict", optarg)) {

438
video.c

File diff suppressed because it is too large Load Diff

View File

@@ -249,6 +249,10 @@ extern int VideoRaiseWindow(void);
/// Set Shaders /// Set Shaders
extern int VideoSetShader(char *); extern int VideoSetShader(char *);
extern void VideoSetRefresh(char *);
extern void VideoSetConnector(char *);
#ifdef USE_OPENGLOSD #ifdef USE_OPENGLOSD
extern void ActivateOsd(GLuint, int, int, int, int); extern void ActivateOsd(GLuint, int, int, int, int);
#endif #endif