From dc9ccdbc26e121c62dd7cf2281f4cb1816432e32 Mon Sep 17 00:00:00 2001 From: Klaas de Waal Date: Sat, 26 Nov 2022 21:12:01 +0100 Subject: [PATCH 1/9] Add dependencies for mythffmpeg etc. Add dependency in makefile for mythffmpeg so that it gets updated whenever there is a new ffmpeg_g. Same for the other mythff* applications. This bug surfaced when investigating the failure of the mytharchivehelper, fixed now in commit 987da09e83ca80181afdd24a1b457faadd1f2c9f. N.B. The fix is in the mythtv-specific part of an ffmpeg makefile so possibly the mechanism that is used to update the ffmpeg makefile also needs to be updated or regenerated. From https://github.com/MythTV/mythtv/commit/4e5edb7780217fecc35c2b8ef0e3b4ce045cde3d --- fftools/Makefile | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fftools/Makefile b/fftools/Makefile index 86650a7c94e7e..928e08b858f11 100644 --- a/fftools/Makefile +++ b/fftools/Makefile @@ -36,16 +36,13 @@ fftools/ffprobe.o fftools/cmdutils.o: libavutil/ffversion.h | fftools OUTDIRS += fftools # ${MYTHPROGS}: -mythffmpeg: +mythffmpeg: ffmpeg_g cp ffmpeg_g mythffmpeg -mythffprobe: +mythffprobe: ffprobe_g cp ffprobe_g mythffprobe -mythffserver: - cp ffserver_g mythffserver - -mythffplay: +mythffplay: ffplay_g cp ffplay_g mythffplay ifdef AVPROGS From d27213c6f008ac457e5982542478faec5d3062ac Mon Sep 17 00:00:00 2001 From: David Hampton Date: Tue, 28 Feb 2023 16:49:51 -0500 Subject: [PATCH 2/9] ffmpeg: Add required cast to w32dlfcn.h From https://github.com/MythTV/mythtv/commit/5f9b27cffdcd8169e5159db040d00e7094b689ec --- compat/w32dlfcn.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/w32dlfcn.h b/compat/w32dlfcn.h index fb1aa1b72eb9a..a4515c78213f5 100644 --- a/compat/w32dlfcn.h +++ b/compat/w32dlfcn.h @@ -35,7 +35,7 @@ static inline wchar_t *get_module_filename(HMODULE module) do { path_size = path_size ? FFMIN(2 * path_size, INT16_MAX + 1) : MAX_PATH; - new_path = av_realloc_array(path, path_size, sizeof *path); + new_path = (wchar_t *)av_realloc_array(path, path_size, sizeof *path); if (!new_path) { av_free(path); return NULL; From 20c21635d881dfb46ecef703301680d015ee7a57 Mon Sep 17 00:00:00 2001 From: David Hampton Date: Mon, 13 Feb 2023 21:58:29 -0500 Subject: [PATCH 3/9] ffmpeg: Don't install mingw64 static FFmpeg library. From https://github.com/MythTV/mythtv/commit/fa7a63247847b9b5e4d488ac5da9ab12d1d53e5e --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 2feb2ba127bea..0657190ec6cc7 100755 --- a/configure +++ b/configure @@ -5582,7 +5582,7 @@ case $target_os in fi SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)' SLIB_INSTALL_LINKS= - SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)' + #SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)' SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)' SLIB_CREATE_DEF_CMD='EXTERN_PREFIX="$(EXTERN_PREFIX)" AR="$(AR_CMD)" NM="$(NM_CMD)" $(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)' SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--disable-auto-image-base $$(@:$(SLIBSUF)=.def)' From dd09265a1400f2c2b3c53fc7dc548c3fa744c036 Mon Sep 17 00:00:00 2001 From: David Hampton Date: Tue, 14 Feb 2023 15:01:44 -0500 Subject: [PATCH 4/9] ffmpeg: Update mythtv specific executable rules to use the EXESUF variable. Make these rules work on windows compiles in addition to linux/android compiles. On windows builds, EXESUF is set to ".exe". From https://github.com/MythTV/mythtv/commit/40fa54626861ef8871aa8c39b386179756564346 --- fftools/Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fftools/Makefile b/fftools/Makefile index 928e08b858f11..fc898ce9020b7 100644 --- a/fftools/Makefile +++ b/fftools/Makefile @@ -36,14 +36,14 @@ fftools/ffprobe.o fftools/cmdutils.o: libavutil/ffversion.h | fftools OUTDIRS += fftools # ${MYTHPROGS}: -mythffmpeg: ffmpeg_g - cp ffmpeg_g mythffmpeg +mythffmpeg$(EXESUF): ffmpeg_g$(EXESUF) + cp ffmpeg_g$(EXESUF) mythffmpeg$(EXESUF) -mythffprobe: ffprobe_g - cp ffprobe_g mythffprobe +mythffprobe$(EXESUF): ffprobe_g$(EXESUF) + cp ffprobe_g$(EXESUF) mythffprobe$(EXESUF) -mythffplay: ffplay_g - cp ffplay_g mythffplay +mythffplay$(EXESUF): ffplay_g$(EXESUF) + cp ffplay_g$(EXESUF) mythffplay$(EXESUF) ifdef AVPROGS install: install-mythprogs From 0a2fb5825a33388ad0995f2e4aa266b98b6a0bc3 Mon Sep 17 00:00:00 2001 From: David Hampton Date: Mon, 7 Mar 2022 15:16:21 -0500 Subject: [PATCH 5/9] ffmpeg: Update rules to create/install pkgconfig files. 1) Change the library name in the pkgconfig files to match the changes in the following commits. I.E. libavcodec -> libmythavcodec. 9563786648 Decouple MythTV configure from FFmpeg configure. e1be225768 FFmpeg configure: Update SLIBPREF on windows 2) Add new target to install the pkgconfig files. This was formerly part of the target to install the header files. A new separate target is being added so that cmake builds can install these files without changing the set of files created/installed by traditional make builds. From https://github.com/MythTV/mythtv/commit/05bd2599918f091de80ce8832a7c4b7137629359 --- ffbuild/library.mak | 11 ++++++----- ffbuild/pkgconfig_generate.sh | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ffbuild/library.mak b/ffbuild/library.mak index b7602dd938356..2750c5848cfd7 100644 --- a/ffbuild/library.mak +++ b/ffbuild/library.mak @@ -11,8 +11,8 @@ INCINSTDIR := $(INCDIR)/lib$(NAME) INSTHEADERS := $(INSTHEADERS) $(HEADERS:%=$(SUBDIR)%) -all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME) $(SUBDIR)lib$(FULLNAME).pc -all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME) $(SUBDIR)lib$(FULLNAME).pc +all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME) $(SUBDIR)libmyth$(FULLNAME).pc +all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME) $(SUBDIR)libmyth$(FULLNAME).pc LIBOBJS := $(OBJS) $(SHLIBOBJS) $(STLIBOBJS) $(SUBDIR)%.h.o $(TESTOBJS) $(LIBOBJS) $(LIBOBJS:.o=.s) $(LIBOBJS:.o=.i): CPPFLAGS += -DHAVE_AV_CONFIG_H @@ -40,6 +40,7 @@ $(SUBDIR)$(LIBNAME): $(OBJS) $(STLIBOBJS) #install-headers: install-lib$(NAME)-headers install-lib$(NAME)-pkgconfig install-headers: install-lib$(NAME)-headers +install-pkgconfig: install-libmyth$(NAME)-pkgconfig install-libs-$(CONFIG_STATIC): install-lib$(NAME)-static install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared @@ -56,7 +57,7 @@ $(TESTPROGS) $(TOOLS): %$(EXESUF): %.o $(SUBDIR)lib$(NAME).version: $(SUBDIR)version.h $(SUBDIR)version_major.h | $(SUBDIR) $$(M) $$(SRC_PATH)/ffbuild/libversion.sh $(NAME) $$^ > $$@ -$(SUBDIR)lib$(FULLNAME).pc: $(SUBDIR)version.h ffbuild/config.sh | $(SUBDIR) +$(SUBDIR)libmyth$(FULLNAME).pc: $(SUBDIR)version.h ffbuild/config.sh | $(SUBDIR) $$(M) $$(SRC_PATH)/ffbuild/pkgconfig_generate.sh $(NAME) "$(DESC)" $(SUBDIR)lib$(NAME).ver: $(SUBDIR)lib$(NAME).v $(OBJS) @@ -96,7 +97,7 @@ install-lib$(NAME)-headers: $(addprefix $(SUBDIR),$(HEADERS) $(BUILT_HEADERS)) $(Q)mkdir -p "$(INCINSTDIR)" $$(INSTALL) -m 644 $$^ "$(INCINSTDIR)" -install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(FULLNAME).pc +install-libmyth$(NAME)-pkgconfig: $(SUBDIR)libmyth$(FULLNAME).pc $(Q)mkdir -p "$(PKGCONFIGDIR)" $$(INSTALL) -m 644 $$^ "$(PKGCONFIGDIR)" @@ -113,7 +114,7 @@ uninstall-headers:: -rmdir "$(INCINSTDIR)" uninstall-pkgconfig:: - $(RM) "$(PKGCONFIGDIR)/lib$(FULLNAME).pc" + $(RM) "$(PKGCONFIGDIR)/libmyth$(FULLNAME).pc" endef $(eval $(RULES)) diff --git a/ffbuild/pkgconfig_generate.sh b/ffbuild/pkgconfig_generate.sh index e5de6716d28b5..1c64e891e1d4c 100755 --- a/ffbuild/pkgconfig_generate.sh +++ b/ffbuild/pkgconfig_generate.sh @@ -10,14 +10,14 @@ fi shortname=$1 name=lib${shortname} -fullname=${name}${build_suffix} +fullname=libmyth${shortname}${build_suffix} comment=$2 libs=$(eval echo \$extralibs_${shortname}) deps=$(eval echo \$${shortname}_deps) for dep in $deps; do depname=lib${dep} - fulldepname=${depname}${build_suffix} + fulldepname=libmyth${dep}${build_suffix} . ${depname}/${depname}.version depversion=$(eval echo \$${depname}_VERSION) requires="$requires ${fulldepname} >= ${depversion}, " From 2e37cb36fb10b94d7458b9464b0353a60600248d Mon Sep 17 00:00:00 2001 From: David Hampton Date: Sun, 2 Apr 2023 11:24:12 -0400 Subject: [PATCH 6/9] ffmpeg: Tweak win32 build to drop major version number from name. From https://github.com/MythTV/mythtv/commit/f6bb460d8f49d6a894dfafe888b48731c23fa232 --- configure | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 0657190ec6cc7..6ca909c49c353 100755 --- a/configure +++ b/configure @@ -5571,7 +5571,8 @@ case $target_os in SLIBPREF="libmyth" SLIBSUF=".dll" SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)' - SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)' + #SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)' + SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)' if test_cmd lib.exe -list; then SLIB_EXTRA_CMD=-'lib.exe -nologo -machine:$(LIBTARGET) -def:$$(@:$(SLIBSUF)=.def) -out:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)' if enabled x86_64; then From 8d39c1a4009950a9fb5f8196390076f4413e2768 Mon Sep 17 00:00:00 2001 From: David Engel Date: Thu, 27 Jul 2023 20:49:56 -0500 Subject: [PATCH 7/9] Fix FFmpeg compilation with binutils >= 2.41. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is from FFmpeg commit effadce6c756247ea8bae32dc13bb3e6f464f0eb . Author: RĂ©mi Denis-Courmont Date: Sun Jul 16 18:18:02 2023 +0300 avcodec/x86/mathops: clip constants used with shift instructions within inline assembly Fixes assembling with binutil as >= 2.41 Signed-off-by: James Almer Fixes #765 From https://github.com/MythTV/mythtv/commit/f9f9bba62ee2743c816cb2b9634b6b4397e5e2e3 --- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h index 6298f5ed1983b..ca7e2dffc1076 100644 --- a/libavcodec/x86/mathops.h +++ b/libavcodec/x86/mathops.h @@ -35,12 +35,20 @@ static av_always_inline av_const int MULL(int a, int b, unsigned shift) { int rt, dummy; + if (__builtin_constant_p(shift)) __asm__ ( "imull %3 \n\t" "shrdl %4, %%edx, %%eax \n\t" :"=a"(rt), "=d"(dummy) - :"a"(a), "rm"(b), "ci"((uint8_t)shift) + :"a"(a), "rm"(b), "i"(shift & 0x1F) ); + else + __asm__ ( + "imull %3 \n\t" + "shrdl %4, %%edx, %%eax \n\t" + :"=a"(rt), "=d"(dummy) + :"a"(a), "rm"(b), "c"((uint8_t)shift) + ); return rt; } @@ -113,19 +121,31 @@ __asm__ volatile(\ // avoid +32 for shift optimization (gcc should do that ...) #define NEG_SSR32 NEG_SSR32 static inline int32_t NEG_SSR32( int32_t a, int8_t s){ + if (__builtin_constant_p(s)) __asm__ ("sarl %1, %0\n\t" : "+r" (a) - : "ic" ((uint8_t)(-s)) + : "i" (-s & 0x1F) ); + else + __asm__ ("sarl %1, %0\n\t" + : "+r" (a) + : "c" ((uint8_t)(-s)) + ); return a; } #define NEG_USR32 NEG_USR32 static inline uint32_t NEG_USR32(uint32_t a, int8_t s){ + if (__builtin_constant_p(s)) __asm__ ("shrl %1, %0\n\t" : "+r" (a) - : "ic" ((uint8_t)(-s)) + : "i" (-s & 0x1F) ); + else + __asm__ ("shrl %1, %0\n\t" + : "+r" (a) + : "c" ((uint8_t)(-s)) + ); return a; } From f5753fa6c1bd6b3a839abcb0da7200fc72078284 Mon Sep 17 00:00:00 2001 From: Klaas de Waal Date: Sun, 13 Aug 2023 14:52:09 +0200 Subject: [PATCH 8/9] Scan streams again after PMT change When there is a change detected in the number of streams or in the type of streams after a new PMT has been received then scan the streams again. It is possible that the streams change during a recording. For instance, a commercial can have one audio stream and then in the following program there can be an audio stream added. This is what the Finnish broadcaster YLE is doing. It is completely standards-conforming but it is as far as I am aware the only broadcaster that does this. The original FFmpeg demuxer looks only at the streams as present in the beginning of the recording and therefore it does not detect changes later in the recording. Detecting stream changes while a recording is playing is a MythTV extension and it requires changes to FFmpeg. This is one reason why there is a copy of FFmpeg included as part of MythTV, instead of using the standard FFmpeg libraries that are part of the Linux system. Initially the streams_changed callback was needed for correct video playback of YLE streams; see commit ebeea33 from 2021. This did fix the problem of the screen sometimes showing only a 640x480 part of the 1920x1080 area. There has been a significant rewrite of the MythTV changes in file mpegts-mythtv.c in 2022 and one result is that the video playback of YLE streams is now correct without rescanning the streams. However, there is still the problem of audio stream changes not being picked up. In commit ad9fb22 from 2022 it is mentioned that: "The streams_changed callback has been disabled as it is now unnecessary in my samples from the Finnish YLE that used to trigger it. It could be re-enabled if necessary." As it appears to be still necessary this commit does exactly that. Note that when the streams_changed callback is called there is a pause of about one second, caused by the SeekReset that is done before the ScanStreams. It is possible that the SeekReset can be omitted. From https://github.com/MythTV/mythtv/commit/4c49293a5b8a531603a348fccbf90816c9d939cb --- libavformat/mpegts-mythtv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mpegts-mythtv.c b/libavformat/mpegts-mythtv.c index a0d5897be1755..9deac5a119e2d 100644 --- a/libavformat/mpegts-mythtv.c +++ b/libavformat/mpegts-mythtv.c @@ -2981,7 +2981,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len * create new ones, and notify any listener. */ equal_streams = pmt_equal_streams(ts, items, last_item); - if (0 && (equal_streams != last_item || ts->pid_cnt != last_item)) + if (equal_streams != last_item || ts->pid_cnt != last_item) { AVFormatContext *avctx = ts->stream; From 43c84c715b9361a0554331cc10db98fd4f8c0db6 Mon Sep 17 00:00:00 2001 From: Peter Bennett Date: Mon, 18 Sep 2023 12:40:57 -0400 Subject: [PATCH 9/9] ffmpeg: libavformat: Remove wrong entries from visibility file Some functions were removed from the source code in ffmpeg but are still in the linker visibility file. They cause a linker error with the --no-undefined-version option Fixes #798 From https://github.com/MythTV/mythtv/commit/bd9b6e1e3bc26c3bcf636ab4d94f70a1d13555f7 --- libavformat/libavformat.v | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavformat/libavformat.v b/libavformat/libavformat.v index 7c9cf19317a00..9fd391df197a7 100644 --- a/libavformat/libavformat.v +++ b/libavformat/libavformat.v @@ -2,11 +2,8 @@ LIBAVFORMAT_MAJOR { global: av*; ffurl_read; - ffurl_read_complete; ffurl_seek; ffurl_size; - ffurl_protocol_next; - ffurl_open; ffurl_open_whitelist; ffurl_close; ffurl_write;