From 65017da5ac610241b7ba5432f0ed9b38c210886a Mon Sep 17 00:00:00 2001 From: Tomasz Maciej Nowak Date: Sat, 18 Feb 2023 16:45:08 +0100 Subject: [PATCH 1/6] Provide linked libs by querying pkg-config --- Makefile | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index f5d2491..4c69980 100644 --- a/Makefile +++ b/Makefile @@ -159,29 +159,27 @@ endif ifeq ($(LIBPLACEBO_GL),1) CONFIG += -DPLACEBO_GL -DPLACEBO -LIBS += -lepoxy -LIBS += -lplacebo +LIBS += $(shell pkg-config --libs epoxy libplacebo) else -LIBS += -lEGL +LIBS += $(shell pkg-config --libs egl) endif ifeq ($(LIBPLACEBO),1) CONFIG += -DPLACEBO -LIBS += -lEGL -LIBS += -lplacebo +LIBS += $(shell pkg-config --libs egl libplacebo) endif ifeq ($(DRM),1) PLUGIN = softhddrm CONFIG += -DUSE_DRM -DVAAPI _CFLAGS += $(shell pkg-config --cflags libdrm) -LIBS += -lgbm -ldrm -lEGL +LIBS += $(shell pkg-config --libs egl gbm libdrm) endif ifeq ($(CUVID),1) #CONFIG += -DUSE_PIP # PIP support CONFIG += -DCUVID # enable CUVID decoder -LIBS += -lEGL -lGL +LIBS += $(shell pkg-config --libs egl gl) ifeq ($(YADIF),1) CONFIG += -DYADIF # Yadif only with CUVID endif @@ -273,7 +271,7 @@ ifeq ($(CUVID),1) LIBS += -lcuda -lnvcuvid endif -LIBS += -lGLEW -lGLU -ldl -lglut +LIBS += -ldl $(shell pkg-config --libs glew glu glut) ### Includes and Defines (add further entries here): From 4e96489e35413181a95a85fac2d595454bd0e926 Mon Sep 17 00:00:00 2001 From: Tomasz Maciej Nowak Date: Sat, 18 Feb 2023 16:59:45 +0100 Subject: [PATCH 2/6] 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. --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 4c69980..7d3e733 100644 --- a/Makefile +++ b/Makefile @@ -159,6 +159,7 @@ endif ifeq ($(LIBPLACEBO_GL),1) CONFIG += -DPLACEBO_GL -DPLACEBO +_CFLAGS += $(shell pkg-config --cflags libplacebo) LIBS += $(shell pkg-config --libs epoxy libplacebo) else LIBS += $(shell pkg-config --libs egl) @@ -166,6 +167,7 @@ endif ifeq ($(LIBPLACEBO),1) CONFIG += -DPLACEBO +_CFLAGS += $(shell pkg-config --cflags libplacebo) LIBS += $(shell pkg-config --libs egl libplacebo) endif From b51589aaa94d68f3a541239e9f37d776fc545916 Mon Sep 17 00:00:00 2001 From: jojo61 Date: Tue, 30 Jan 2024 17:07:53 +0100 Subject: [PATCH 3/6] Fix Makefile (remove placebo default) --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 83c8325..ceb82d1 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ DRM ?= 0 # use libplacebo - # available for all decoders but for DRM you need LIBPLACEBO_GL -LIBPLACEBO ?= 1 +LIBPLACEBO ?= 0 LIBPLACEBO_GL ?= 0 # use YADIF deint - only available with cuvid From a222f6a1d5fa2d88a20eea65b1725aaebbc055aa Mon Sep 17 00:00:00 2001 From: jojo61 Date: Tue, 30 Jan 2024 17:11:16 +0100 Subject: [PATCH 4/6] Fix Makefile --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index ceb82d1..b9dc20e 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,6 @@ YADIF = 1 CONFIG := -DDEBUG # remove '#' to enable debug output - #--------------------- no more config needed past this point-------------------------------- # sanitize selections -------- From 8629946041b5b901fd16941fd5f9110c333a2512 Mon Sep 17 00:00:00 2001 From: jojo61 Date: Fri, 2 Feb 2024 00:19:43 +0100 Subject: [PATCH 5/6] Reverse pkg-config for glu glew and glut --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b9dc20e..7cfea18 100644 --- a/Makefile +++ b/Makefile @@ -272,7 +272,8 @@ ifeq ($(CUVID),1) LIBS += -lcuda -lnvcuvid endif -LIBS += -ldl $(shell pkg-config --libs glew glu glut) +LIBS += -lGLEW -lGLU -ldl -lglut +#LIBS += -ldl $(shell pkg-config --libs glew glu glut) ### Includes and Defines (add further entries here): From 47b461ab465ec4ff919060cb96ba2961c1647df9 Mon Sep 17 00:00:00 2001 From: jojo61 Date: Fri, 2 Feb 2024 15:27:39 +0100 Subject: [PATCH 6/6] Ffmeg does no Stereo Downmix for Codec AAV LATM Do Downmix after decoding --- codec.c | 59 ++++++++++++++++++++++++++++++++++++++++++------- softhdcuvid.cpp | 2 +- 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/codec.c b/codec.c index 8e6ecfe..5dc4287 100644 --- a/codec.c +++ b/codec.c @@ -717,7 +717,15 @@ void CodecAudioOpen(AudioDecoder *audio_decoder, int codec_id) { } if (CodecDownmix) { - audio_decoder->AudioCtx->request_channel_layout = AV_CH_LAYOUT_STEREO; +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53,61,100) + audio_decoder->AudioCtx->request_channels = 2; +#endif +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100) + audio_decoder->AudioCtx->request_channel_layout = AV_CH_LAYOUT_STEREO; +#else + AVChannelLayout dmlayout = AV_CHANNEL_LAYOUT_STEREO; + av_opt_set_chlayout(audio_decoder->AudioCtx->priv_data, "downmix", &dmlayout, 0); +#endif } pthread_mutex_lock(&CodecLockMutex); // open codec @@ -896,6 +904,10 @@ static int CodecAudioUpdateHelper(AudioDecoder *audio_decoder, int *passthrough) audio_decoder->SpdifCount = 0; *passthrough = 1; } + + if (audio_decoder->HwChannels > 2 && CodecDownmix) { + audio_decoder->HwChannels = 2; + } // channels/sample-rate not support? if ((err = AudioSetup(&audio_decoder->HwSampleRate, &audio_decoder->HwChannels, *passthrough))) { @@ -1161,14 +1173,43 @@ static void CodecAudioUpdateFormat(AudioDecoder *audio_decoder) { } #endif - 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) { - swr_init(audio_decoder->Resample); +#if LIBSWRESAMPLE_VERSION_INT < AV_VERSION_INT(4,5,100) + if (audio_decoder->Channels > 2 && CodecDownmix) { + audio_decoder->Resample = swr_alloc_set_opts(audio_decoder->Resample, + AV_CH_LAYOUT_STEREO, AV_SAMPLE_FMT_S16, audio_decoder->HwSampleRate, + audio_ctx->channel_layout, audio_ctx->sample_fmt,audio_ctx->sample_rate, + 0, NULL); } else { - Error(_("codec/audio: can't setup resample\n")); + 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); } +#else + if (audio_decoder->Channels > 2 && CodecDownmix) { // Codec does not Support Downmix + //printf("last ressort downmix Layout in %lx Lyout out: %llx \n",audio_ctx->channel_layout,AV_CH_LAYOUT_STEREO); + audio_decoder->Resample = swr_alloc(); + av_opt_set_channel_layout(audio_decoder->Resample, "in_channel_layout",audio_ctx->channel_layout, 0); + av_opt_set_channel_layout(audio_decoder->Resample, "out_channel_layout", AV_CH_LAYOUT_STEREO, 0); + av_opt_set_int(audio_decoder->Resample, "in_sample_rate", audio_ctx->sample_rate, 0); + av_opt_set_int(audio_decoder->Resample, "out_sample_rate", audio_ctx->sample_rate, 0); + av_opt_set_sample_fmt(audio_decoder->Resample, "in_sample_fmt", audio_ctx->sample_fmt, 0); + av_opt_set_sample_fmt(audio_decoder->Resample, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); + } + else { + swr_alloc_set_opts2(&audio_decoder->Resample, &audio_ctx->ch_layout, + AV_SAMPLE_FMT_S16, audio_decoder->HwSampleRate, + &audio_ctx->ch_layout, audio_ctx->sample_fmt, + audio_ctx->sample_rate, 0, NULL); + } +#endif + if (audio_decoder->Resample) { + swr_init(audio_decoder->Resample); + } else { + Error(_("codec/audio: can't setup resample\n")); + } + + } /** @@ -1220,13 +1261,15 @@ void CodecAudioDecode(AudioDecoder *audio_decoder, const AVPacket *avpkt) { if (CodecAudioPassthroughHelper(audio_decoder, avpkt)) { return; } + if (audio_decoder->Resample) { - uint8_t outbuf[8192 * 2 * 8]; + uint8_t outbuf[8192 * 2 * 8]; uint8_t *out[1]; out[0] = outbuf; ret = swr_convert(audio_decoder->Resample, out, sizeof(outbuf) / (2 * audio_decoder->HwChannels), (const uint8_t **)frame->extended_data, frame->nb_samples); + if (ret > 0) { if (!(audio_decoder->Passthrough & CodecPCM)) { CodecReorderAudioFrame((int16_t *)outbuf, ret * 2 * audio_decoder->HwChannels, diff --git a/softhdcuvid.cpp b/softhdcuvid.cpp index 36df3a3..b980e98 100644 --- a/softhdcuvid.cpp +++ b/softhdcuvid.cpp @@ -61,7 +61,7 @@ extern void ToggleLUT(); /// vdr-plugin version number. /// Makefile extracts the version number for generating the file name /// for the distribution archive. -static const char *const VERSION = "3.16" +static const char *const VERSION = "3.17" #ifdef GIT_REV "-GIT" GIT_REV #endif