From 069ea9bbfc27c03ca4c2c737047f974310b7cab0 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Tue, 19 Nov 2024 19:28:27 +0800 Subject: [PATCH] enable drawtext filter in gpl build --- .github/workflows/build.yml | 2 +- avbuild.sh | 25 ++++++++++++---- config-gpl-lite.sh | 4 ++- ...32-textutils-include-time_internal.h.patch | 30 +++++++++++++++++++ ...vaapi-fix-undefined-close-on-windows.patch | 27 +++++++++++++++++ 5 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 patches/master/0032-textutils-include-time_internal.h.patch create mode 100644 patches/master/0033-hwcontext_vaapi-fix-undefined-close-on-windows.patch diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 305a28a..f6cd198 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -649,7 +649,7 @@ jobs: Upload: runs-on: ubuntu-latest - needs: [VS2022] + needs: [VS2022, VS2022LTL] steps: - name: Download vs2022 desktop uses: actions/download-artifact@v4 diff --git a/avbuild.sh b/avbuild.sh index 585ddc1..d65e57e 100755 --- a/avbuild.sh +++ b/avbuild.sh @@ -591,7 +591,7 @@ export LIB="$VC_LTL_LIB;$VCDIR_LIB;$WindowsSdkDir/Lib/$WindowsSDKVersion/ucrt/${ export AR=$LLVM_AR export NM=$LLVM_NM #export V=1 # FFmpeg BUG: AR is overriden in common.mak and becomes an invalid command in makedef(@printf works in makefiles but not sh scripts) -export PKG_CONFIG_PATH=${THIS_DIR}/tools/dep/windows-desktop/${MACHINE/86_/}/lib/pkgconfig:${THIS_DIR}/tools/dep_gpl/windows-desktop/${MACHINE/86_/}/lib/pkgconfig:${THIS_DIR}/tools/dep/windows-desktop/lib/pkgconfig:${THIS_DIR}/tools/dep_gpl/windows-desktop/lib/pkgconfig:$PKG_CONFIG_PATH +export PKG_CONFIG_PATH=${THIS_DIR}/tools/dep/windows/${MACHINE/86_/}/lib/pkgconfig:${THIS_DIR}/tools/dep_gpl/windows-desktop/${MACHINE/86_/}/lib/pkgconfig:${THIS_DIR}/tools/dep/windows/lib/pkgconfig:${THIS_DIR}/tools/dep_gpl/windows-desktop/lib/pkgconfig:$PKG_CONFIG_PATH EOF # [ expr1 ] && ... at end returns error if expr1 is false } @@ -692,7 +692,7 @@ setup_vc_env() { [ -n "$LIBPATH_arch" ] && echo "export LIBPATH=$LIBPATH_arch" >>"$BDIR/.env.sh" [ -n "$INCLUDE_arch" ] && echo "export INCLUDE=$INCLUDE_arch" >>"$BDIR/.env.sh" cat >> "$BDIR/.env.sh" < -I=/usr/include + } # probe compiler first setup_cc ${USE_TOOLCHAIN:=gcc} "--target=${CROSS_PREFIX%%-}" # clang on mac(apple or opensource) will use apple flags w/o --target= # t.S: x .dn 0 @@ -1425,9 +1432,16 @@ setup_linux_env() { add_elf_flags enable_opt v4l2-request libudev enable_opt vaapi vdpau libdrm + include_with_sysroot_compat /usr/include/libdrm + #FILTER_OPT+=" --enable-filter=drawtext" + #enable_opt libfreetype libfribidi libfontconfig libharfbuzz + echo $USER_OPT grep -q libfreetype && { + #enable_opt libfribidi libfontconfig +# pkg-config use aboslute paths, can not set PKG_CONFIG_SYSROOT_DIR because we have .pc outside sysroot, so manually add include dirs + include_with_sysroot_compat /usr/include/freetype2 /usr/include/fribidi /usr/include/harfbuzz + } $USE_VK && EXTRA_CFLAGS+=" -I\$THIS_DIR/tools/Vulkan-Headers/include" $IS_CLANG && enable_cuda_llvm - $IS_CLANG && EXTRA_CFLAGS+=" -I=/usr/include/libdrm" local CC_ARCH=`$USE_TOOLCHAIN -dumpmachine` CC_ARCH=${CC_ARCH%%-*} @@ -1495,6 +1509,7 @@ config1(){ local patch_clock_gettime=0 local enable_pic=true local enable_lto=true + #TOOLCHAIN_OPT+=" --pkg-config-flags=--define-prefix" # FIXME: wrong result for linux sysroot : ${VC_BUILD:=false} #global is fine because no parallel configure now add_librt(){ # clock_gettime in librt instead of glibc>=2.17 diff --git a/config-gpl-lite.sh b/config-gpl-lite.sh index 0340c90..aba0ab0 100644 --- a/config-gpl-lite.sh +++ b/config-gpl-lite.sh @@ -8,6 +8,7 @@ USER_OPT="--enable-small \ --disable-protocols \ --disable-parsers --enable-parser=*sub*,*jp*,aac*,ac3,cook,dnxhd,flac,h26[3-4],hevc,m*,opus,rv*,vc1,vorbis,vp[8-9] \ --pkg-config=pkg-config --pkg-config-flags=--static --enable-gpl --enable-libx265 --enable-libx264 \ +--enable-libfreetype --enable-libharfbuzz \ $USER_OPT " DEC_OPT_MOBILE="--enable-decoder=*sub*,movtext,*web*,aac*,ac3*,eac3*,alac*,ape,ass,av1*,ccaption,cfhd,cook,dca,dnxhd,exr,truehd,*yuv*,flv,flac,gif,h26[3-4]*,hevc*,hap,mp[1-3]*,prores,*[mj]peg*,mlp,mpl2,nellymoser,opus,pcm*,qtrle,*png*,tiff,rawvideo,sami,srt,ssa,v210*,vc1*,vorbis,vp[6-9]*,wm*,wrapped_avframe" @@ -15,7 +16,7 @@ DEMUX_OPT_MOBILE="--enable-demuxer=*sub*,*ac3,*ac,*avs*,*[mj]peg*,*vc*,*web*,au, ENC_OPT_MOBILE="--enable-encoder=libx26*,aac,cfhd,dnxhd,exr,ff*,*yuv*,gif,h26[3-4]*,av1*,hevc*,mjpeg*,*png,opus,pcm*,prores*,rawvideo,spdif,speedhq,*jpeg,*png,tiff,vp[8-9]*,wrapped_avframe" MUX_OPT_MOBILE="--enable-muxer=*jpeg,dnxhd,fifo,flv,gif,hls,h264,hevc,image2,mov,mp4,mpegts,matroska,null,og*,pcm*,rawvideo,spdif,*pipe,*segment,webm,wav" PROT_OPT_MOBILE="--enable-protocol=cache,concat*,crypto*,data,fd,*file,ftp,h*,i*,pipe,rt*,s*,t*,u*" -FILTER_OPT_MOBILE="--enable-filter=*null*,afade,*fifo,*format,*resample,aeval,atempo,pan,crop,eq*,framerate,hw*,scale,volume,yadif*" +FILTER_OPT_MOBILE="--enable-filter=drawtext,*null*,afade,*fifo,*format,*resample,aeval,atempo,pan,crop,eq*,framerate,hw*,scale,volume,yadif*" PROT_OPT="${PROT_OPT_MOBILE}" DEC_OPT="${DEC_OPT_MOBILE},rv*,ffv*" DEMUX_OPT="${DEMUX_OPT_MOBILE},mlv,nsv,nut" @@ -27,4 +28,5 @@ ios_OPT="--disable-avdevice" rpi_OPT="--disable-avdevice" raspberry_pi_OPT="--disable-avdevice" sunxi_OPT="--disable-avdevice" +linux_OPT="--enable-libfribidi --enable-fontconfig" LITE_BUILD=true diff --git a/patches/master/0032-textutils-include-time_internal.h.patch b/patches/master/0032-textutils-include-time_internal.h.patch new file mode 100644 index 0000000..6a3b69a --- /dev/null +++ b/patches/master/0032-textutils-include-time_internal.h.patch @@ -0,0 +1,30 @@ +From 3e8678a486b50da2c1c7dae32eeb93d32327feb4 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Tue, 19 Nov 2024 19:27:09 +0800 +Subject: [PATCH 32/32] textutils: include time_internal.h + +fix undefined localtime_r in msvc +--- + libavfilter/textutils.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libavfilter/textutils.c b/libavfilter/textutils.c +index e6b5239b20..471346cc51 100644 +--- a/libavfilter/textutils.c ++++ b/libavfilter/textutils.c +@@ -31,6 +31,7 @@ + #include "libavutil/file.h" + #include "libavutil/mem.h" + #include "libavutil/time.h" ++#include "libavutil/time_internal.h" + + static int ff_expand_text_function_internal(FFExpandTextContext *expand_text, AVBPrint *bp, + char *name, unsigned argc, char **argv) +@@ -380,4 +381,3 @@ int ff_load_textfile(void *log_ctx, const char *textfile, + + return 0; + } +- +-- +2.39.5 (Apple Git-154) + diff --git a/patches/master/0033-hwcontext_vaapi-fix-undefined-close-on-windows.patch b/patches/master/0033-hwcontext_vaapi-fix-undefined-close-on-windows.patch new file mode 100644 index 0000000..e9fc860 --- /dev/null +++ b/patches/master/0033-hwcontext_vaapi-fix-undefined-close-on-windows.patch @@ -0,0 +1,27 @@ +From 58a25729988efd3a61f3e1e9df97b8a3e0cf6130 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Tue, 19 Nov 2024 19:43:02 +0800 +Subject: [PATCH 33/33] hwcontext_vaapi: fix undefined close() on windows + +--- + libavutil/hwcontext_vaapi.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c +index 95aa38d9d2..95fbba514c 100644 +--- a/libavutil/hwcontext_vaapi.c ++++ b/libavutil/hwcontext_vaapi.c +@@ -1643,8 +1643,10 @@ static void vaapi_device_free(AVHWDeviceContext *ctx) + XCloseDisplay(priv->x11_display); + #endif + ++#if HAVE_VAAPI_DRM + if (priv->drm_fd >= 0) + close(priv->drm_fd); ++#endif + + av_freep(&priv); + } +-- +2.39.5 (Apple Git-154) +