diff --git a/build-win.sh b/build-win.sh new file mode 100644 index 0000000..ae362b4 --- /dev/null +++ b/build-win.sh @@ -0,0 +1,4 @@ +export FFBUILD_FLAGS="--enable-ffnvcodec --enable-dxva2 --enable-amf" +export FFBUILD_PLATFORM="win" + +FFMPEG_OS=mingw32 OPENH264_ARCH=i686 OPENH264_OS=mingw_nt CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ AR=i686-w64-mingw32-gcc-ar bash build.sh --arch i686 diff --git a/build-win32.sh b/build-win32.sh deleted file mode 100644 index d484353..0000000 --- a/build-win32.sh +++ /dev/null @@ -1,3 +0,0 @@ -source win-env.sh - -FFMPEG_OS=win32 FFMPEG_MSBUILD=1 OPENH264_ARCH=i686 OPENH264_OS=msvc CC=cl CXX=cl AR=lib bash build.sh --arch i686 diff --git a/build-win64.sh b/build-win64.sh deleted file mode 100755 index ddda346..0000000 --- a/build-win64.sh +++ /dev/null @@ -1,3 +0,0 @@ -source win-env.sh - -FFMPEG_OS=win64 FFMPEG_MSBUILD=1 OPENH264_ARCH=x86_64 OPENH264_OS=msvc CC=cl CXX=cl AR=lib bash build.sh --arch x86_64 diff --git a/build.sh b/build.sh index bdb13b7..48983fc 100755 --- a/build.sh +++ b/build.sh @@ -28,10 +28,11 @@ mkdir -p $PREFIX mkdir -p $workDir mkdir -p $outDir +bash scripts/build-iconv.sh + case $FFBUILD_PLATFORM in win) bash scripts/build-ffnvcodec.sh - # disabled due to build error # bash scripts/build-libmfx.sh ;; esac diff --git a/patches/mfx.patch b/patches/mfx.patch deleted file mode 100644 index 622f7bd..0000000 --- a/patches/mfx.patch +++ /dev/null @@ -1,99 +0,0 @@ -Subject: [PATCH] fix for vcpkg -fix missing mfx_driver_store_loader related symbols ---- -Index: CMakeLists.txt -IDEA additional info: -Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP -<+>UTF-8 -=================================================================== -diff --git a/CMakeLists.txt b/CMakeLists.txt ---- a/CMakeLists.txt (revision 7e4d221c36c630c1250b23a5dfa15657bc04c10c) -+++ b/CMakeLists.txt (revision 5ebef171699530ca01594a5cef10a68811f4d105) -@@ -40,6 +39,7 @@ - src/mfx_load_plugin.cpp - src/mfx_plugin_hive.cpp - src/mfx_win_reg_key.cpp -+ src/mfx_driver_store_loader.cpp - ) - endif (CMAKE_SYSTEM_NAME MATCHES "Windows") - -@@ -56,6 +56,12 @@ - configure_file (${CMAKE_SOURCE_DIR}/libmfx.pc.cmake ${CMAKE_BINARY_DIR}/libmfx.pc @ONLY) - - add_library( mfx STATIC ${SOURCES} ) -+ -+if (CMAKE_SYSTEM_NAME MATCHES "Windows") -+ set_target_properties(mfx -+ PROPERTIES PREFIX lib) -+endif (CMAKE_SYSTEM_NAME MATCHES "Windows") -+ - install (DIRECTORY ${CMAKE_SOURCE_DIR}/mfx DESTINATION ${CMAKE_INSTALL_PREFIX}/include FILES_MATCHING PATTERN "*.h") - install (FILES ${CMAKE_BINARY_DIR}/libmfx.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) - install (TARGETS mfx ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) -Index: libmfx.pc.cmake -IDEA additional info: -Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP -<+>UTF-8 -=================================================================== -diff --git a/libmfx.pc.cmake b/libmfx.pc.cmake ---- a/libmfx.pc.cmake (revision 7e4d221c36c630c1250b23a5dfa15657bc04c10c) -+++ b/libmfx.pc.cmake (revision 388559e9e8234eb0989e1598a9beea4035a04132) -@@ -9,6 +9,6 @@ - Requires: - Requires.private: - Conflicts: --Libs: -L${libdir} -lsupc++ ${libdir}/libmfx.a -+Libs: -L${libdir} -lsupc++ ${libdir}/libmfx.lib - Libs.private: - Cflags: -I${includedir} -I@INTELMEDIASDK_PATH@ -Index: src/mfx_driver_store_loader.cpp -IDEA additional info: -Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP -<+>UTF-8 -=================================================================== -diff --git a/src/mfx_driver_store_loader.cpp b/src/mfx_driver_store_loader.cpp ---- a/src/mfx_driver_store_loader.cpp (revision 388559e9e8234eb0989e1598a9beea4035a04132) -+++ b/src/mfx_driver_store_loader.cpp (revision 5ebef171699530ca01594a5cef10a68811f4d105) -@@ -24,6 +24,8 @@ - #include "mfx_dispatcher_log.h" - #include "mfx_load_dll.h" - -+#pragma comment(lib, "Ole32.lib") -+ - namespace MFX - { - - -=================================================================== -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 9446bc4..a8a3288 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -3,16 +3,7 @@ cmake_minimum_required(VERSION 2.6) - project( libmfx ) - - # FIXME Adds support for using system/other install of intel media sdk --find_path ( INTELMEDIASDK_PATH mfx/mfxvideo.h -- HINTS "${CMAKE_SOURCE_DIR}" --) -- --if (INTELMEDIASDK_PATH_NOTFOUND) -- message( FATAL_ERROR "Intel MEDIA SDK include not found" ) --else (INTELMEDIASDK_PATH_NOTFOUND) -- message(STATUS "Intel Media SDK is here: ${INTELMEDIASDK_PATH}") --endif (INTELMEDIASDK_PATH_NOTFOUND) -- -+set(INTELMEDIASDK_PATH "${CMAKE_CURRENT_LIST_DIR}") - - set(SOURCES - src/main.cpp -diff --git a/libmfx.pc.cmake b/libmfx.pc.cmake -index fabb541..5d248fe 100644 ---- a/libmfx.pc.cmake -+++ b/libmfx.pc.cmake -@@ -11,4 +11,4 @@ Requires.private: - Conflicts: - Libs: -L${libdir} -lsupc++ ${libdir}/libmfx.lib - Libs.private: --Cflags: -I${includedir} -I@INTELMEDIASDK_PATH@ -+Cflags: -I${includedir} diff --git a/patches/mfx/0001-fix-version.patch b/patches/mfx/0001-fix-version.patch new file mode 100644 index 0000000..564eac5 --- /dev/null +++ b/patches/mfx/0001-fix-version.patch @@ -0,0 +1,25 @@ +From 38977f2aae092fd155a15d24318efb1532d5321b Mon Sep 17 00:00:00 2001 +From: paring +Date: Mon, 22 May 2023 15:20:08 +0900 +Subject: [PATCH] fix: version + +--- + libmfx.pc.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libmfx.pc.cmake b/libmfx.pc.cmake +index 1a22c98..5730b72 100644 +--- a/libmfx.pc.cmake ++++ b/libmfx.pc.cmake +@@ -5,7 +5,7 @@ includedir=${prefix}/include + + Name: libmfx + Description: Intel Media SDK Dispatched static library +-Version: 2013 ++Version: 1.35.1 + Requires: + Requires.private: + Conflicts: +-- +2.40.0 + diff --git a/scripts/build-ffmpeg.sh b/scripts/build-ffmpeg.sh index bf2413a..36b6159 100644 --- a/scripts/build-ffmpeg.sh +++ b/scripts/build-ffmpeg.sh @@ -1,6 +1,7 @@ +set -x + export ffmpegPath=$workDir/ffmpeg export amfPath=$workDir/amf -# export CFLAGS=-L$PREFIX/lib git clone https://github.com/FFmpeg/FFmpeg -b release/6.0 $ffmpegPath --depth 1 @@ -8,23 +9,22 @@ git clone https://github.com/GPUOpen-LibrariesAndSDKs/AMF -b v1.4.29 $amfPath -- cd $ffmpegPath +# git am ../../patches/ffmpeg/* + cp -r $amfPath/amf/public/include $PREFIX/include/AMF make distclean flags="--cc=$CC --cxx=$CXX" -if [[ -z $FFMPEG_MSVC ]]; then - flags="--toolchain=msvc" -fi - -./configure --disable-gpl --disable-nonfree --disable-doc --disable-network \ - --disable-ffprobe --disable-ffplay --enable-static --disable-shared \ +CFLAGS="-static-libgcc -static-libstdc++ -static -I$PREFIX/include/mfx" \ +CXXCLAGS="-static-libgcc -static-libstdc++ -static -I$PREFIX/include/mfx" \ +LDFLAGS="-static-libgcc -static-libstdc++ -static" \ + ./configure --disable-gpl --disable-nonfree --disable-doc \ + --disable-ffprobe --disable-ffplay --enable-ffmpeg --enable-static --disable-shared \ --enable-libopenh264 \ --prefix=$PREFIX --enable-cross-compile --arch=$ARCH \ --pkg-config-flags="--static" --target-os=$FFMPEG_OS \ - --extra-ldflags="-libpath:$PREFIX/lib" \ - --extra-cflags="-I$PREFIX/include/mfx" \ ${flags} ${FFBUILD_FLAGS} make -j$JOBS diff --git a/scripts/build-iconv.sh b/scripts/build-iconv.sh new file mode 100644 index 0000000..3b48c30 --- /dev/null +++ b/scripts/build-iconv.sh @@ -0,0 +1,21 @@ +export iconvPath=$workDir/iconv + +rm -rf $iconvPath + +cd $workDir + +wget -O iconv.tar.gz https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.17.tar.gz + +tar zxvf iconv.tar.gz + +mv libiconv* $iconvPath + +rm iconv.tar.gz + +cd $iconvPath + +./configure --prefix=$PREFIX --arch=$ARCH --enable-static --disable-shared --with-pic --enable-extra-encodings --disable-doc + +make -j$JOBS + +make install diff --git a/scripts/build-libmfx.sh b/scripts/build-libmfx.sh index 40c5406..f9f1b7f 100644 --- a/scripts/build-libmfx.sh +++ b/scripts/build-libmfx.sh @@ -9,17 +9,21 @@ cd $projectDir git init git remote add origin https://github.com/lu-zero/mfx_dispatch -git fetch --depth 1 origin 5a3f178be7f406cec920b9f52f46c1ae29f29bb2 +git fetch --depth 1 origin "1.35.1" git checkout FETCH_HEAD -git apply ../../patches/mfx.patch +git am ../../patches/mfx/* rm -rf build mkdir build cd build -cmake -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-m32 -DCMAKE_C_FLAGS=-m32 -DCMAKE_GENERATOR_PLATFORM=x86 .. +export CFLAGS="$CFLAGS -static-libgcc -static-libstdc++ -static" +export CXXFLAGS="$CXXFLAGS -static-libgcc -static-libstdc++ -static" +export LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++" + +cmake -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE=Release .. cmake --build . --config Release diff --git a/scripts/build-openh264.sh b/scripts/build-openh264.sh index baf231d..829ed8b 100644 --- a/scripts/build-openh264.sh +++ b/scripts/build-openh264.sh @@ -2,6 +2,9 @@ set -x export OPENH264_VERSION=2.3.1 +CFLAGS+="-static -static-libgcc -static-libstdc++" +LDFLAGS+="-static-libgcc -static-libstdc++ -static" + # TODO: detect platform # export CISCO_BINARY_PLATFORM=mac # export CISCO_BINARY_ARCH=x64 diff --git a/win-env.sh b/win-env.sh deleted file mode 100644 index d680716..0000000 --- a/win-env.sh +++ /dev/null @@ -1,2 +0,0 @@ -export FFBUILD_FLAGS="--enable-ffnvcodec --enable-dxva2 --enable-amf" -export FFBUILD_PLATFORM="win"