Skip to content

Commit 15e746f

Browse files
committed
Update build_frei0r()
- frei0r-plugins-1.4 --> frei0r_git. - Strip and pack shared libraries. - Patch FFmpeg's libavcodec to load the Frei0r plugins dynamically. Credits go to Gianluigi Tiesi (https://github.com/sherpya/mplayer-be).
1 parent ee4dc9a commit 15e746f

File tree

2 files changed

+67
-5
lines changed

2 files changed

+67
-5
lines changed

cross_compile_ffmpeg.sh

+21-5
Original file line numberDiff line numberDiff line change
@@ -1423,11 +1423,26 @@ build_lua() {
14231423
}
14241424

14251425
build_frei0r() {
1426-
# theoretically we could get by with just copying a .h file in, but why not build the .dll's here anyway, for fun, and in case useful? :)
1427-
download_and_unpack_file https://files.dyne.org/frei0r/releases/frei0r-plugins-1.4.tar.gz
1428-
cd frei0r-plugins-1.4
1429-
sed -i.bak "s/find_package (Cairo)//g" CMakeLists.txt
1426+
do_git_checkout https://github.com/dyne/frei0r.git
1427+
cd frei0r_git
14301428
do_cmake_and_install
1429+
1430+
mkdir -p $cur_dir/redist # Strip and pack shared libraries.
1431+
if [ $bits_target = 32 ]; then
1432+
local arch=x86
1433+
else
1434+
local arch=x86_64
1435+
fi
1436+
archive="$cur_dir/redist/frei0r-plugins-${arch}-$(git describe --tags).7z"
1437+
if [[ ! -f $archive ]]; then
1438+
for sharedlib in $mingw_w64_x86_64_prefix/lib/frei0r-1/*.dll; do
1439+
${cross_prefix}strip $sharedlib
1440+
done
1441+
for doc in AUTHORS ChangeLog COPYING README.md; do
1442+
sed "s/$/\r/" $doc > $mingw_w64_x86_64_prefix/lib/frei0r-1/$doc.txt
1443+
done
1444+
7z a -mx=9 $archive $mingw_w64_x86_64_prefix/lib/frei0r-1 && rm -fr $mingw_w64_x86_64_prefix/lib/frei0r-1/*.txt
1445+
fi
14311446
cd ..
14321447
}
14331448

@@ -1655,6 +1670,7 @@ build_ffmpeg() {
16551670
cd $output_dir
16561671
apply_patch file://$patch_dir/libopenjpeg_support-v2.2.diff
16571672
apply_patch file://$patch_dir/libfdk-aac_load-shared-library-dynamically.diff
1673+
apply_patch file://$patch_dir/frei0r_load-shared-libraries-dynamically.diff
16581674
if [[ ! -f configure.bak ]]; then # Changes being made to 'configure' are done with 'sed', because 'configure' gets updated a lot.
16591675
sed -i.bak "/enabled libopenjpeg/s/{ check/{ check_lib libopenjpeg openjpeg-2.2\/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC \&\& add_cppflags -DOPJ_STATIC; } ||\n &/;/openjpeg_2_1_openjpeg_h/i\ openjpeg_2_2_openjpeg_h" configure # Add support for LibOpenJPEG v2.2.
16601676
sed -i "/enabled libfdk_aac/s/&.*/\&\& { check_header fdk-aac\/aacenc_lib.h || die \"ERROR: aacenc_lib.h not found\"; }/;/require libfdk_aac/,/without pkg-config/d;/ libfdk_aac/d;/ libflite/i\ libfdk_aac" configure # Load 'libfdk-aac-1.dll' dynamically.
@@ -1817,7 +1833,7 @@ build_dependencies() {
18171833
build_fftw # Uses dlfcn.
18181834
build_libsamplerate # Needs libsndfile >= 1.0.6 and fftw >= 0.15.0 for tests. Uses dlfcn.
18191835
build_librubberband # Needs libsamplerate, libsndfile, fftw and vamp_plugin. 'configure' will fail otherwise. Eventhough librubberband doesn't necessarily need them (libsndfile only for 'rubberband.exe' and vamp_plugin only for "Vamp audio analysis plugin"). How to use the bundled libraries '-DUSE_SPEEX' and '-DUSE_KISSFFT'?
1820-
build_frei0r
1836+
build_frei0r # Needs dlfcn.
18211837
build_wavpack
18221838
# build_libjpeg_turbo # mplayer can use this, VLC qt might need it? [replaces libjpeg]
18231839
build_libxvid
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
diff -ur libavfilter/vf_frei0r.c.bak libavfilter/vf_frei0r.c
2+
--- libavfilter/vf_frei0r.c.bak 2017-05-12 01:34:21.609375000 +0200
3+
+++ libavfilter/vf_frei0r.c 2017-05-18 19:14:46.515625000 +0200
4+
@@ -42,6 +42,10 @@
5+
#include "internal.h"
6+
#include "video.h"
7+
8+
+#ifdef _WIN32
9+
+#include <windows.h>
10+
+#endif
11+
+
12+
typedef f0r_instance_t (*f0r_construct_f)(unsigned int width, unsigned int height);
13+
typedef void (*f0r_destruct_f)(f0r_instance_t instance);
14+
typedef void (*f0r_deinit_f)(void);
15+
@@ -235,11 +239,31 @@
16+
if (ret < 0)
17+
return ret;
18+
}
19+
+#ifdef _WIN32
20+
+ if (!s->dl_handle) {
21+
+ char *ls, prefix[MAX_PATH + 1];
22+
+
23+
+ if (!GetModuleFileNameA(NULL, prefix, MAX_PATH))
24+
+ return AVERROR(EINVAL);
25+
+ prefix[MAX_PATH] = 0;
26+
+
27+
+ if (!(ls = strrchr(prefix, '\\')))
28+
+ return AVERROR(EINVAL);
29+
+
30+
+ *ls = 0;
31+
+ strncat(prefix, "\\frei0r-1\\", sizeof(prefix) - 1 - strlen(prefix));
32+
+
33+
+ ret = load_path(ctx, &s->dl_handle, prefix, dl_name);
34+
+ if (ret < 0)
35+
+ return ret;
36+
+ }
37+
+#else
38+
for (i = 0; !s->dl_handle && i < FF_ARRAY_ELEMS(frei0r_pathlist); i++) {
39+
ret = load_path(ctx, &s->dl_handle, frei0r_pathlist[i], dl_name);
40+
if (ret < 0)
41+
return ret;
42+
}
43+
+#endif
44+
if (!s->dl_handle) {
45+
av_log(ctx, AV_LOG_ERROR, "Could not find module '%s'.\n", dl_name);
46+
return AVERROR(EINVAL);

0 commit comments

Comments
 (0)