mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-06-30 12:14:08 +03:00
Visualization - Enhance FFmpeg Compatibility Layer and Update Video Recorder (#582)
- Creation of Media_FFmpegCompatibility.pxx to wrap deprecated functions and API changes. - Refactoring of Media_FormatContext and Media_CodecContext to use the new compatibility layer. - Updates to Image_VideoRecorder and its tests to leverage the new compatibility functions and ensure proper codec context handling.
This commit is contained in:
parent
6b69f59803
commit
22d437b771
2
.github/actions/build-occt/action.yml
vendored
2
.github/actions/build-occt/action.yml
vendored
@ -191,7 +191,7 @@ runs:
|
|||||||
-D 3RDPARTY_RAPIDJSON_DIR=${{ github.workspace }}/rapidjson-858451e5b7d1c56cf8f6d58f88cf958351837e53 \
|
-D 3RDPARTY_RAPIDJSON_DIR=${{ github.workspace }}/rapidjson-858451e5b7d1c56cf8f6d58f88cf958351837e53 \
|
||||||
-D USE_FREETYPE=ON \
|
-D USE_FREETYPE=ON \
|
||||||
-D USE_DRACO=ON \
|
-D USE_DRACO=ON \
|
||||||
-D USE_FFMPEG=OFF \
|
-D USE_FFMPEG=ON \
|
||||||
-D USE_FREEIMAGE=ON \
|
-D USE_FREEIMAGE=ON \
|
||||||
-D USE_GLES2=ON \
|
-D USE_GLES2=ON \
|
||||||
-D USE_OPENVR=ON \
|
-D USE_OPENVR=ON \
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
diff --git a/configure b/configure
|
|
||||||
index 89af70d..405680e 100755
|
|
||||||
--- a/configure
|
|
||||||
+++ b/configure
|
|
||||||
@@ -5480,15 +5480,17 @@ case $target_os in
|
|
||||||
;;
|
|
||||||
win32|win64)
|
|
||||||
disable symver
|
|
||||||
- if enabled shared; then
|
|
||||||
+# if enabled shared; then
|
|
||||||
# Link to the import library instead of the normal static library
|
|
||||||
# for shared libs.
|
|
||||||
LD_LIB='%.lib'
|
|
||||||
# Cannot build both shared and static libs with MSVC or icl.
|
|
||||||
- disable static
|
|
||||||
- fi
|
|
||||||
+# disable static
|
|
||||||
+# fi
|
|
||||||
enabled x86_32 && check_ldflags -LARGEADDRESSAWARE
|
|
||||||
shlibdir_default="$bindir_default"
|
|
||||||
+ LIBPREF=""
|
|
||||||
+ LIBSUF=".lib"
|
|
||||||
SLIBPREF=""
|
|
||||||
SLIBSUF=".dll"
|
|
||||||
SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
|
|
@ -1,13 +0,0 @@
|
|||||||
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
|
|
||||||
index fe424b6..2df70df 100644
|
|
||||||
--- a/fftools/cmdutils.c
|
|
||||||
+++ b/fftools/cmdutils.c
|
|
||||||
@@ -60,6 +60,8 @@
|
|
||||||
#include <sys/resource.h>
|
|
||||||
#endif
|
|
||||||
#ifdef _WIN32
|
|
||||||
+#define _WIN32_WINNT 0x0502
|
|
||||||
+#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
|||||||
diff --git a/configure b/configure
|
|
||||||
index 405680e..cc5bf29 100755
|
|
||||||
--- a/configure
|
|
||||||
+++ b/configure
|
|
||||||
@@ -4111,6 +4111,9 @@ for opt do
|
|
||||||
--libfuzzer=*)
|
|
||||||
libfuzzer_path="$optval"
|
|
||||||
;;
|
|
||||||
+ --debug)
|
|
||||||
+ enable debug_configure
|
|
||||||
+ ;;
|
|
||||||
*)
|
|
||||||
optname="${opt%%=*}"
|
|
||||||
optname="${optname#--}"
|
|
||||||
@@ -6316,7 +6319,11 @@ fi
|
|
||||||
|
|
||||||
enabled zlib && { check_pkg_config zlib zlib "zlib.h" zlibVersion ||
|
|
||||||
check_lib zlib zlib.h zlibVersion -lz; }
|
|
||||||
-enabled bzlib && check_lib bzlib bzlib.h BZ2_bzlibVersion -lbz2
|
|
||||||
+if enabled debug_configure; then
|
|
||||||
+ enabled bzlib && check_lib bzlib bzlib.h BZ2_bzlibVersion -lbz2d
|
|
||||||
+else
|
|
||||||
+ enabled bzlib && check_lib bzlib bzlib.h BZ2_bzlibVersion -lbz2
|
|
||||||
+fi
|
|
||||||
enabled lzma && check_lib lzma lzma.h lzma_version_number -llzma
|
|
||||||
|
|
||||||
# On some systems dynamic loading requires no extra linker flags
|
|
||||||
@@ -6434,7 +6441,11 @@ enabled librubberband && require_pkg_config librubberband "rubberband >= 1.8
|
|
||||||
enabled libshine && require_pkg_config libshine shine shine/layer3.h shine_encode_buffer
|
|
||||||
enabled libsmbclient && { check_pkg_config libsmbclient smbclient libsmbclient.h smbc_init ||
|
|
||||||
require libsmbclient libsmbclient.h smbc_init -lsmbclient; }
|
|
||||||
-enabled libsnappy && require libsnappy snappy-c.h snappy_compress -lsnappy -lstdc++
|
|
||||||
+if enabled debug_configure; then
|
|
||||||
+ enabled libsnappy && require libsnappy snappy-c.h snappy_compress -lsnappy -lstdc++
|
|
||||||
+else
|
|
||||||
+ enabled libsnappy && require libsnappy snappy-c.h snappy_compress -lsnappy -lstdc++
|
|
||||||
+fi
|
|
||||||
enabled libsoxr && require libsoxr soxr.h soxr_create -lsoxr
|
|
||||||
enabled libssh && require_pkg_config libssh libssh libssh/sftp.h sftp_init
|
|
||||||
enabled libspeex && require_pkg_config libspeex speex speex/speex.h speex_decoder_init
|
|
@ -1,49 +0,0 @@
|
|||||||
diff --git a/configure b/configure
|
|
||||||
index cc5bf29..ee26559 100755
|
|
||||||
--- a/configure
|
|
||||||
+++ b/configure
|
|
||||||
@@ -6406,7 +6406,8 @@ if enabled libmfx; then
|
|
||||||
fi
|
|
||||||
|
|
||||||
enabled libmodplug && require_pkg_config libmodplug libmodplug libmodplug/modplug.h ModPlug_Load
|
|
||||||
-enabled libmp3lame && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame $libm_extralibs
|
|
||||||
+enabled libmp3lame && { check_lib libmp3lame lame/lame.h lame_set_VBR_quality -lmp3lame $libm_extralibs ||
|
|
||||||
+ require libmp3lame lame/lame.h lame_set_VBR_quality -llibmp3lame-static -llibmpghip-static $libm_extralibs; }
|
|
||||||
enabled libmysofa && { check_pkg_config libmysofa libmysofa mysofa.h mysofa_neighborhood_init_withstepdefine ||
|
|
||||||
require libmysofa mysofa.h mysofa_neighborhood_init_withstepdefine -lmysofa $zlib_extralibs; }
|
|
||||||
enabled libnpp && { check_lib libnpp npp.h nppGetLibVersion -lnppig -lnppicc -lnppc -lnppidei ||
|
|
||||||
@@ -6446,7 +6447,7 @@ if enabled debug_configure; then
|
|
||||||
else
|
|
||||||
enabled libsnappy && require libsnappy snappy-c.h snappy_compress -lsnappy -lstdc++
|
|
||||||
fi
|
|
||||||
-enabled libsoxr && require libsoxr soxr.h soxr_create -lsoxr
|
|
||||||
+enabled libsoxr && require libsoxr soxr.h soxr_create -lsoxr -lm
|
|
||||||
enabled libssh && require_pkg_config libssh libssh libssh/sftp.h sftp_init
|
|
||||||
enabled libspeex && require_pkg_config libspeex speex speex/speex.h speex_decoder_init
|
|
||||||
enabled libsrt && require_pkg_config libsrt "srt >= 1.3.0" srt/srt.h srt_socket
|
|
||||||
@@ -6527,6 +6528,8 @@ enabled openal && { { for al_extralibs in "${OPENAL_LIBS}" "-lopenal"
|
|
||||||
enabled opencl && { check_pkg_config opencl OpenCL CL/cl.h clEnqueueNDRangeKernel ||
|
|
||||||
check_lib opencl OpenCL/cl.h clEnqueueNDRangeKernel -Wl,-framework,OpenCL ||
|
|
||||||
check_lib opencl CL/cl.h clEnqueueNDRangeKernel -lOpenCL ||
|
|
||||||
+ check_lib opencl CL/cl.h clEnqueueNDRangeKernel -lOpenCL -lAdvapi32 -lOle32 -lCfgmgr32||
|
|
||||||
+ check_lib opencl CL/cl.h clEnqueueNDRangeKernel -lOpenCL -pthread -ldl ||
|
|
||||||
die "ERROR: opencl not found"; } &&
|
|
||||||
{ test_cpp_condition "OpenCL/cl.h" "defined(CL_VERSION_1_2)" ||
|
|
||||||
test_cpp_condition "CL/cl.h" "defined(CL_VERSION_1_2)" ||
|
|
||||||
@@ -6550,6 +6553,7 @@ enabled openssl && { check_pkg_config openssl openssl openssl/ssl.h OP
|
|
||||||
check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto ||
|
|
||||||
check_lib openssl openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
|
|
||||||
check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
|
|
||||||
+ check_lib openssl openssl/ssl.h OPENSSL_init_ssl -llibssl -llibcrypto -lws2_32 -lgdi32 -lcrypt32 -lAdvapi32 -lUser32||
|
|
||||||
die "ERROR: openssl not found"; }
|
|
||||||
enabled pocketsphinx && require_pkg_config pocketsphinx pocketsphinx pocketsphinx/pocketsphinx.h ps_init
|
|
||||||
enabled rkmpp && { require_pkg_config rkmpp rockchip_mpp rockchip/rk_mpi.h mpp_create &&
|
|
||||||
@@ -6811,7 +6815,7 @@ enabled amf &&
|
|
||||||
if enabled libc_iconv; then
|
|
||||||
check_func_headers iconv.h iconv
|
|
||||||
elif enabled iconv; then
|
|
||||||
- check_func_headers iconv.h iconv || check_lib iconv iconv.h iconv -liconv
|
|
||||||
+ check_func_headers iconv.h iconv || check_lib iconv iconv.h iconv -liconv || check_lib iconv iconv.h iconv -liconv -llibcharset
|
|
||||||
fi
|
|
||||||
|
|
||||||
enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
|
|
@ -1,15 +0,0 @@
|
|||||||
diff --git a/configure b/configure
|
|
||||||
index ee26559..f2c83b7 100755
|
|
||||||
--- a/configure
|
|
||||||
+++ b/configure
|
|
||||||
@@ -4496,6 +4496,10 @@ msvc_common_flags(){
|
|
||||||
-march=*) ;;
|
|
||||||
-lz) echo zlib.lib ;;
|
|
||||||
-lx264) echo libx264.lib ;;
|
|
||||||
+ -lx265) echo libx265.lib ;;
|
|
||||||
+ -lmp3lame) echo libmp3lame.lib ;;
|
|
||||||
+ -liconv) echo iconv.lib ;;
|
|
||||||
+ -lm) ;;
|
|
||||||
-lstdc++) ;;
|
|
||||||
-l*) echo ${flag#-l}.lib ;;
|
|
||||||
-LARGEADDRESSAWARE) echo $flag ;;
|
|
@ -1,13 +0,0 @@
|
|||||||
diff --git a/configure b/configure
|
|
||||||
index f2c83b7..5e42b12 100755
|
|
||||||
--- a/configure
|
|
||||||
+++ b/configure
|
|
||||||
@@ -6379,7 +6379,7 @@ enabled libdavs2 && require_pkg_config libdavs2 "davs2 >= 1.6.0" davs2.
|
|
||||||
enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new
|
|
||||||
enabled libdrm && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion
|
|
||||||
enabled libfdk_aac && { check_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen ||
|
|
||||||
- { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac &&
|
|
||||||
+ { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac -lm -lstdc++ &&
|
|
||||||
warn "using libfdk without pkg-config"; } }
|
|
||||||
flite_extralibs="-lflite_cmu_time_awb -lflite_cmu_us_awb -lflite_cmu_us_kal -lflite_cmu_us_kal16 -lflite_cmu_us_rms -lflite_cmu_us_slt -lflite_usenglish -lflite_cmulex -lflite"
|
|
||||||
enabled libflite && require libflite "flite/flite.h" flite_init $flite_extralibs
|
|
@ -1,13 +0,0 @@
|
|||||||
diff --git a/configure b/configure
|
|
||||||
index 5e42b12..d8f059f 100755
|
|
||||||
--- a/configure
|
|
||||||
+++ b/configure
|
|
||||||
@@ -6497,7 +6497,7 @@ enabled libwebp && {
|
|
||||||
enabled libwebp_encoder && require_pkg_config libwebp "libwebp >= 0.2.0" webp/encode.h WebPGetEncoderVersion
|
|
||||||
enabled libwebp_anim_encoder && check_pkg_config libwebp_anim_encoder "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit; }
|
|
||||||
enabled libx264 && { check_pkg_config libx264 x264 "stdint.h x264.h" x264_encoder_encode ||
|
|
||||||
- { require libx264 "stdint.h x264.h" x264_encoder_encode "-lx264 $pthreads_extralibs $libm_extralibs" &&
|
|
||||||
+ { require libx264 "stdint.h x264.h" x264_encoder_encode "-lx264 $pthreads_extralibs $libm_extralibs -ldl" &&
|
|
||||||
warn "using libx264 without pkg-config"; } } &&
|
|
||||||
require_cpp_condition libx264 x264.h "X264_BUILD >= 118" &&
|
|
||||||
check_cpp_condition libx262 x264.h "X264_MPEG2"
|
|
@ -1,16 +0,0 @@
|
|||||||
diff --git a/configure b/configure
|
|
||||||
index d8f059f..f3688ad 100755
|
|
||||||
--- a/configure
|
|
||||||
+++ b/configure
|
|
||||||
@@ -6501,7 +6501,10 @@ enabled libx264 && { check_pkg_config libx264 x264 "stdint.h x264.h" x
|
|
||||||
warn "using libx264 without pkg-config"; } } &&
|
|
||||||
require_cpp_condition libx264 x264.h "X264_BUILD >= 118" &&
|
|
||||||
check_cpp_condition libx262 x264.h "X264_MPEG2"
|
|
||||||
-enabled libx265 && require_pkg_config libx265 x265 x265.h x265_api_get &&
|
|
||||||
+enabled libx265 && { check_pkg_config libx265 x265 x265.h x265_api_get ||
|
|
||||||
+ { { check_lib libx265 x265.h x265_api_get "-lx265 $pthreads_extralibs $libm_extralibs -ldl -lstdc++ -lgcc_s -lgcc -lrt -lnuma" ||
|
|
||||||
+ require libx265 x265.h x265_api_get "-lx265 $pthreads_extralibs $libm_extralibs -ldl -lstdc++"; } &&
|
|
||||||
+ warn "using libx265 without pkg-config"; } } &&
|
|
||||||
require_cpp_condition libx265 x265.h "X265_BUILD >= 70"
|
|
||||||
enabled libxavs && require libxavs "stdint.h xavs.h" xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs"
|
|
||||||
enabled libxavs2 && require_pkg_config libxavs2 "xavs2 >= 1.3.0" "stdint.h xavs2.h" xavs2_api_get
|
|
@ -1,12 +0,0 @@
|
|||||||
diff --git a/configure b/configure
|
|
||||||
index f3688ad..26e512e 100755
|
|
||||||
--- a/configure
|
|
||||||
+++ b/configure
|
|
||||||
@@ -6556,6 +6556,7 @@ enabled omx_rpi && { test_code cc OMX_Core.h OMX_IndexConfigBrcmVideoR
|
|
||||||
enabled omx && require_headers OMX_Core.h
|
|
||||||
enabled openssl && { check_pkg_config openssl openssl openssl/ssl.h OPENSSL_init_ssl ||
|
|
||||||
check_pkg_config openssl openssl openssl/ssl.h SSL_library_init ||
|
|
||||||
+ check_lib openssl openssl/ssl.h OPENSSL_init_ssl -lssl -lcrypto $pthreads_extralibs -ldl ||
|
|
||||||
check_lib openssl openssl/ssl.h OPENSSL_init_ssl -lssl -lcrypto ||
|
|
||||||
check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto ||
|
|
||||||
check_lib openssl openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
|
|
@ -1,16 +0,0 @@
|
|||||||
diff --git a/libavcodec/mf_utils.c b/libavcodec/mf_utils.c
|
|
||||||
index eeabd0c..ea3a03b 100644
|
|
||||||
--- a/libavcodec/mf_utils.c
|
|
||||||
+++ b/libavcodec/mf_utils.c
|
|
||||||
@@ -22,6 +22,11 @@
|
|
||||||
#define _WIN32_WINNT 0x0602
|
|
||||||
#endif
|
|
||||||
|
|
||||||
+#if !defined(WINVER) || WINVER < 0x0602
|
|
||||||
+#undef WINVER
|
|
||||||
+#define WINVER 0x0602
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
#include "mf_utils.h"
|
|
||||||
#include "libavutil/pixdesc.h"
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
|||||||
diff --git a/configure b/configure
|
|
||||||
index 26e512e..c0377b6 100755
|
|
||||||
--- a/configure
|
|
||||||
+++ b/configure
|
|
||||||
@@ -3674,6 +3674,18 @@ vpp_qsv_filter_select="qsvvpp"
|
|
||||||
xfade_opencl_filter_deps="opencl"
|
|
||||||
yadif_cuda_filter_deps="ffnvcodec"
|
|
||||||
yadif_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
|
|
||||||
+ametadata_filter_deps="avformat"
|
|
||||||
+metadata_filter_deps="avformat"
|
|
||||||
+headphone_filter_deps="avcodec"
|
|
||||||
+headphone_filter_select="fft"
|
|
||||||
+showspatial_filter_deps="avcodec"
|
|
||||||
+showspatial_filter_select="fft"
|
|
||||||
+superequalizer_filter_deps="avcodec"
|
|
||||||
+superequalizer_filter_select="rdft"
|
|
||||||
+surround_filter_deps="avcodec"
|
|
||||||
+surround_filter_select="rdft"
|
|
||||||
+sinc_filter_deps="avcodec"
|
|
||||||
+sinc_filter_select="rdft"
|
|
||||||
|
|
||||||
# examples
|
|
||||||
avio_list_dir_deps="avformat avutil"
|
|
@ -1,13 +0,0 @@
|
|||||||
diff --git a/configure b/configure
|
|
||||||
index c0377b6..62753ef 100755
|
|
||||||
--- a/configure
|
|
||||||
+++ b/configure
|
|
||||||
@@ -6526,7 +6526,7 @@ enabled libzmq && require_pkg_config libzmq "libzmq >= 4.2.1" zmq.h z
|
|
||||||
enabled libzvbi && require_pkg_config libzvbi zvbi-0.2 libzvbi.h vbi_decoder_new &&
|
|
||||||
{ test_cpp_condition libzvbi.h "VBI_VERSION_MAJOR > 0 || VBI_VERSION_MINOR > 2 || VBI_VERSION_MINOR == 2 && VBI_VERSION_MICRO >= 28" ||
|
|
||||||
enabled gpl || die "ERROR: libzvbi requires version 0.2.28 or --enable-gpl."; }
|
|
||||||
-enabled libxml2 && require_pkg_config libxml2 libxml-2.0 libxml2/libxml/xmlversion.h xmlCheckVersion
|
|
||||||
+enabled libxml2 && require_pkg_config libxml2 libxml-2.0 libxml/xmlversion.h xmlCheckVersion
|
|
||||||
enabled mbedtls && { check_pkg_config mbedtls mbedtls mbedtls/x509_crt.h mbedtls_x509_crt_init ||
|
|
||||||
check_pkg_config mbedtls mbedtls mbedtls/ssl.h mbedtls_ssl_init ||
|
|
||||||
check_lib mbedtls mbedtls/ssl.h mbedtls_ssl_init -lmbedtls -lmbedx509 -lmbedcrypto ||
|
|
@ -1,30 +0,0 @@
|
|||||||
diff --git a/compat/cuda/ptx2c.sh b/compat/cuda/ptx2c.sh
|
|
||||||
index 48452379c2..1c486dc30e 100755
|
|
||||||
--- a/compat/cuda/ptx2c.sh
|
|
||||||
+++ b/compat/cuda/ptx2c.sh
|
|
||||||
@@ -26,9 +26,10 @@ OUT="$1"
|
|
||||||
IN="$2"
|
|
||||||
NAME="$(basename "$IN" | sed 's/\..*//')"
|
|
||||||
|
|
||||||
-printf "const char %s_ptx[] = \\" "$NAME" > "$OUT"
|
|
||||||
+printf "const char %s_ptx[] = {\\" "$NAME" > "$OUT"
|
|
||||||
echo >> "$OUT"
|
|
||||||
-sed -e "$(printf 's/\r//g')" -e 's/["\\]/\\&/g' -e "$(printf 's/^/\t"/')" -e 's/$/\\n"/' < "$IN" >> "$OUT"
|
|
||||||
-echo ";" >> "$OUT"
|
|
||||||
+xxd -i < "$IN" >> "$OUT"
|
|
||||||
+echo " ,0x00" >> "$OUT"
|
|
||||||
+echo "};" >> "$OUT"
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
diff --git a/configure b/configure
|
|
||||||
index 6190d06b0b..48fb73738e 100755
|
|
||||||
--- a/configure
|
|
||||||
+++ b/configure
|
|
||||||
@@ -1046,6 +1046,7 @@ test_nvcc(){
|
|
||||||
tmpo_=$TMPO
|
|
||||||
[ -x "$(command -v cygpath)" ] && tmpcu_=$(cygpath -m $tmpcu_) && tmpo_=$(cygpath -m $tmpo_)
|
|
||||||
test_cmd $nvcc $nvccflags "$@" $NVCC_C $(nvcc_o $tmpo_) $tmpcu_
|
|
||||||
+ test_cmd xxd
|
|
||||||
}
|
|
||||||
|
|
||||||
check_nvcc() {
|
|
@ -1,13 +0,0 @@
|
|||||||
diff --git a/libavcodec/libaomdec.c b/libavcodec/libaomdec.c
|
|
||||||
index 1fc0a00..06b2ff0 100644
|
|
||||||
--- a/libavcodec/libaomdec.c
|
|
||||||
+++ b/libavcodec/libaomdec.c
|
|
||||||
@@ -224,7 +224,7 @@ static av_cold int aom_free(AVCodecContext *avctx)
|
|
||||||
|
|
||||||
static av_cold int av1_init(AVCodecContext *avctx)
|
|
||||||
{
|
|
||||||
- return aom_init(avctx, &aom_codec_av1_dx_algo);
|
|
||||||
+ return aom_init(avctx, aom_codec_av1_dx());
|
|
||||||
}
|
|
||||||
|
|
||||||
AVCodec ff_libaom_av1_decoder = {
|
|
@ -1,33 +0,0 @@
|
|||||||
diff --git a/configure b/configure
|
|
||||||
index 62753ef..018764e 100755
|
|
||||||
--- a/configure
|
|
||||||
+++ b/configure
|
|
||||||
@@ -6508,11 +6508,8 @@ enabled libvpx && {
|
|
||||||
enabled libwebp && {
|
|
||||||
enabled libwebp_encoder && require_pkg_config libwebp "libwebp >= 0.2.0" webp/encode.h WebPGetEncoderVersion
|
|
||||||
enabled libwebp_anim_encoder && check_pkg_config libwebp_anim_encoder "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit; }
|
|
||||||
-enabled libx264 && { check_pkg_config libx264 x264 "stdint.h x264.h" x264_encoder_encode ||
|
|
||||||
- { require libx264 "stdint.h x264.h" x264_encoder_encode "-lx264 $pthreads_extralibs $libm_extralibs -ldl" &&
|
|
||||||
- warn "using libx264 without pkg-config"; } } &&
|
|
||||||
- require_cpp_condition libx264 x264.h "X264_BUILD >= 118" &&
|
|
||||||
- check_cpp_condition libx262 x264.h "X264_MPEG2"
|
|
||||||
+enabled libx264 && check_pkg_config libx264 x264 "stdint.h x264.h" x264_encoder_encode &&
|
|
||||||
+ require_cpp_condition libx264 x264.h "X264_BUILD >= 158"
|
|
||||||
enabled libx265 && { check_pkg_config libx265 x265 x265.h x265_api_get ||
|
|
||||||
{ { check_lib libx265 x265.h x265_api_get "-lx265 $pthreads_extralibs $libm_extralibs -ldl -lstdc++ -lgcc_s -lgcc -lrt -lnuma" ||
|
|
||||||
require libx265 x265.h x265_api_get "-lx265 $pthreads_extralibs $libm_extralibs -ldl -lstdc++"; } &&
|
|
||||||
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
|
|
||||||
index 4ddc497..0152d30 100644
|
|
||||||
--- a/libavcodec/libx264.c
|
|
||||||
+++ b/libavcodec/libx264.c
|
|
||||||
@@ -32,10 +32,6 @@
|
|
||||||
#include "packet_internal.h"
|
|
||||||
#include "atsc_a53.h"
|
|
||||||
|
|
||||||
-#if defined(_MSC_VER)
|
|
||||||
-#define X264_API_IMPORTS 1
|
|
||||||
-#endif
|
|
||||||
-
|
|
||||||
#include <x264.h>
|
|
||||||
#include <float.h>
|
|
||||||
#include <math.h>
|
|
@ -1,28 +0,0 @@
|
|||||||
diff --git a/libswscale/aarch64/yuv2rgb_neon.S b/libswscale/aarch64/yuv2rgb_neon.S
|
|
||||||
index f4b220f..af677af 100644
|
|
||||||
--- a/libswscale/aarch64/yuv2rgb_neon.S
|
|
||||||
+++ b/libswscale/aarch64/yuv2rgb_neon.S
|
|
||||||
@@ -169,19 +169,19 @@ function ff_\ifmt\()_to_\ofmt\()_neon, export=1
|
|
||||||
sqdmulh v26.8H, v26.8H, v0.8H // ((Y1*(1<<3) - y_offset) * y_coeff) >> 15
|
|
||||||
sqdmulh v27.8H, v27.8H, v0.8H // ((Y2*(1<<3) - y_offset) * y_coeff) >> 15
|
|
||||||
|
|
||||||
-.ifc \ofmt,argb // 1 2 3 0
|
|
||||||
+.ifc \ofmt,argb
|
|
||||||
compute_rgba v5.8B,v6.8B,v7.8B,v4.8B, v17.8B,v18.8B,v19.8B,v16.8B
|
|
||||||
.endif
|
|
||||||
|
|
||||||
-.ifc \ofmt,rgba // 0 1 2 3
|
|
||||||
+.ifc \ofmt,rgba
|
|
||||||
compute_rgba v4.8B,v5.8B,v6.8B,v7.8B, v16.8B,v17.8B,v18.8B,v19.8B
|
|
||||||
.endif
|
|
||||||
|
|
||||||
-.ifc \ofmt,abgr // 3 2 1 0
|
|
||||||
+.ifc \ofmt,abgr
|
|
||||||
compute_rgba v7.8B,v6.8B,v5.8B,v4.8B, v19.8B,v18.8B,v17.8B,v16.8B
|
|
||||||
.endif
|
|
||||||
|
|
||||||
-.ifc \ofmt,bgra // 2 1 0 3
|
|
||||||
+.ifc \ofmt,bgra
|
|
||||||
compute_rgba v6.8B,v5.8B,v4.8B,v7.8B, v18.8B,v17.8B,v16.8B,v19.8B
|
|
||||||
.endif
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
|||||||
From c534d9f72a89542ed639071b1ae15893aadf1f18 Mon Sep 17 00:00:00 2001
|
|
||||||
From: rcombs <rcombs@rcombs.me>
|
|
||||||
Date: Sat, 16 Apr 2022 03:41:29 -0500
|
|
||||||
Subject: [PATCH] lavc/h264_ps: always include the stop bit in [s|p]ps->data
|
|
||||||
|
|
||||||
The VideoToolbox hwaccel needs the entire NAL (including the stop bit),
|
|
||||||
but ff_h2645_packet_split may remove it. Detect this case by looking for
|
|
||||||
bit counts divisible by 8 and insert a stop-bit-only 0x80 byte.
|
|
||||||
|
|
||||||
Signed-off-by: rcombs <rcombs@rcombs.me>
|
|
||||||
---
|
|
||||||
libavcodec/h264_ps.c | 8 ++++++++
|
|
||||||
1 file changed, 8 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
|
|
||||||
index 051f06692c..e16da68dec 100644
|
|
||||||
--- a/libavcodec/h264_ps.c
|
|
||||||
+++ b/libavcodec/h264_ps.c
|
|
||||||
@@ -351,6 +351,10 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
|
|
||||||
}
|
|
||||||
memcpy(sps->data, gb->buffer, sps->data_size);
|
|
||||||
|
|
||||||
+ // Re-add the removed stop bit (may be used by hwaccels).
|
|
||||||
+ if (!(gb->size_in_bits & 7) && sps->data_size < sizeof(sps->data))
|
|
||||||
+ sps->data[sps->data_size++] = 0x80;
|
|
||||||
+
|
|
||||||
profile_idc = get_bits(gb, 8);
|
|
||||||
constraint_set_flags |= get_bits1(gb) << 0; // constraint_set0_flag
|
|
||||||
constraint_set_flags |= get_bits1(gb) << 1; // constraint_set1_flag
|
|
||||||
@@ -775,6 +779,10 @@ int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avct
|
|
||||||
}
|
|
||||||
memcpy(pps->data, gb->buffer, pps->data_size);
|
|
||||||
|
|
||||||
+ // Re-add the removed stop bit (may be used by hwaccels).
|
|
||||||
+ if (!(bit_length & 7) && pps->data_size < sizeof(pps->data))
|
|
||||||
+ pps->data[pps->data_size++] = 0x80;
|
|
||||||
+
|
|
||||||
pps->sps_id = get_ue_golomb_31(gb);
|
|
||||||
if ((unsigned)pps->sps_id >= MAX_SPS_COUNT ||
|
|
||||||
!ps->sps_list[pps->sps_id]) {
|
|
||||||
--
|
|
||||||
2.20.1
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
|||||||
Subject: [PATCH] fix d3d11
|
|
||||||
---
|
|
||||||
Index: qsv.c
|
|
||||||
IDEA additional info:
|
|
||||||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
|
||||||
<+>UTF-8
|
|
||||||
===================================================================
|
|
||||||
diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
|
|
||||||
--- a/libavcodec/qsv.c
|
|
||||||
+++ b/libavcodec/qsv.c
|
|
||||||
@@ -383,7 +383,11 @@
|
|
||||||
int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs,
|
|
||||||
const char *load_plugins, int gpu_copy)
|
|
||||||
{
|
|
||||||
+#if CONFIG_D3D11VA
|
|
||||||
+ mfxIMPL impl = MFX_IMPL_AUTO_ANY | MFX_IMPL_VIA_D3D11;
|
|
||||||
+#else
|
|
||||||
mfxIMPL impl = MFX_IMPL_AUTO_ANY;
|
|
||||||
+#endif
|
|
||||||
mfxVersion ver = { { QSV_VERSION_MINOR, QSV_VERSION_MAJOR } };
|
|
||||||
mfxInitParam init_par = { MFX_IMPL_AUTO_ANY };
|
|
||||||
|
|
@ -1,165 +0,0 @@
|
|||||||
# Distributed under the OSI-approved BSD 3-Clause License.
|
|
||||||
#
|
|
||||||
#.rst:
|
|
||||||
# FindFFMPEG
|
|
||||||
# --------
|
|
||||||
#
|
|
||||||
# Find the FFPMEG libraries
|
|
||||||
#
|
|
||||||
# Result Variables
|
|
||||||
# ^^^^^^^^^^^^^^^^
|
|
||||||
#
|
|
||||||
# The following variables will be defined:
|
|
||||||
#
|
|
||||||
# ``FFMPEG_FOUND``
|
|
||||||
# True if FFMPEG found on the local system
|
|
||||||
#
|
|
||||||
# ``FFMPEG_INCLUDE_DIRS``
|
|
||||||
# Location of FFMPEG header files
|
|
||||||
#
|
|
||||||
# ``FFMPEG_LIBRARY_DIRS``
|
|
||||||
# Location of FFMPEG libraries
|
|
||||||
#
|
|
||||||
# ``FFMPEG_LIBRARIES``
|
|
||||||
# List of the FFMPEG libraries found
|
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
include(SelectLibraryConfigurations)
|
|
||||||
include(CMakeFindDependencyMacro)
|
|
||||||
|
|
||||||
if(NOT FFMPEG_FOUND)
|
|
||||||
|
|
||||||
# Compute the installation path relative to this file.
|
|
||||||
get_filename_component(SEARCH_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
|
||||||
get_filename_component(SEARCH_PATH "${SEARCH_PATH}" PATH)
|
|
||||||
get_filename_component(SEARCH_PATH "${SEARCH_PATH}" PATH)
|
|
||||||
if(SEARCH_PATH STREQUAL "/")
|
|
||||||
set(SEARCH_PATH "")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(FFMPEG_VERSION "@FFMPEG_VERSION@")
|
|
||||||
|
|
||||||
function(append_dependencies out)
|
|
||||||
cmake_parse_arguments(PARSE_ARGV 1 "arg" "DEBUG" "NAMES" "")
|
|
||||||
if(${arg_DEBUG})
|
|
||||||
set(config DEBUG)
|
|
||||||
set(path "${CURRENT_INSTALLED_DIR}/debug/lib/")
|
|
||||||
else()
|
|
||||||
set(config RELEASE)
|
|
||||||
set(path "${CURRENT_INSTALLED_DIR}/lib/")
|
|
||||||
endif()
|
|
||||||
foreach(lib_name ${arg_NAMES})
|
|
||||||
if("${lib_name}" STREQUAL "-pthread")
|
|
||||||
list(APPEND ${out} "-pthread")
|
|
||||||
elseif("${lib_name}" STREQUAL "-pthreads")
|
|
||||||
list(APPEND ${out} "-pthreads")
|
|
||||||
elseif("${lib_name}" STREQUAL "gcc")
|
|
||||||
list(APPEND ${out} "-lgcc")
|
|
||||||
elseif("${lib_name}" STREQUAL "gcc_s")
|
|
||||||
list(APPEND ${out} "-lgcc_s")
|
|
||||||
elseif("${lib_name}" STREQUAL "stdc++")
|
|
||||||
list(APPEND ${out} "-lstdc++")
|
|
||||||
else()
|
|
||||||
# first look in ${path} specifically to ensure we find the right release/debug variant
|
|
||||||
find_library(FFMPEG_DEPENDENCY_${lib_name}_${config} NAMES "${lib_name}" PATHS "${path}" NO_DEFAULT_PATH)
|
|
||||||
# if not found there, must be a system dependency, so look elsewhere
|
|
||||||
find_library(FFMPEG_DEPENDENCY_${lib_name}_${config} NAMES "${lib_name}" REQUIRED)
|
|
||||||
list(APPEND ${out} "${FFMPEG_DEPENDENCY_${lib_name}_${config}}")
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
set("${out}" "${${out}}" PARENT_SCOPE)
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
macro(FFMPEG_FIND varname shortname headername)
|
|
||||||
if(NOT FFMPEG_${varname}_INCLUDE_DIRS)
|
|
||||||
find_path(FFMPEG_${varname}_INCLUDE_DIRS NAMES lib${shortname}/${headername} ${headername} PATHS ${SEARCH_PATH}/include NO_DEFAULT_PATH)
|
|
||||||
endif()
|
|
||||||
if(NOT FFMPEG_${varname}_LIBRARY)
|
|
||||||
find_library(FFMPEG_${varname}_LIBRARY_RELEASE NAMES ${shortname} PATHS ${SEARCH_PATH}/lib/ NO_DEFAULT_PATH)
|
|
||||||
find_library(FFMPEG_${varname}_LIBRARY_DEBUG NAMES ${shortname}d ${shortname} PATHS ${SEARCH_PATH}/debug/lib/ NO_DEFAULT_PATH)
|
|
||||||
get_filename_component(FFMPEG_${varname}_LIBRARY_RELEASE_DIR ${FFMPEG_${varname}_LIBRARY_RELEASE} DIRECTORY)
|
|
||||||
get_filename_component(FFMPEG_${varname}_LIBRARY_DEBUG_DIR ${FFMPEG_${varname}_LIBRARY_DEBUG} DIRECTORY)
|
|
||||||
select_library_configurations(FFMPEG_${varname})
|
|
||||||
set(FFMPEG_${varname}_LIBRARY ${FFMPEG_${varname}_LIBRARY} CACHE STRING "")
|
|
||||||
endif()
|
|
||||||
if (FFMPEG_${varname}_LIBRARY AND FFMPEG_${varname}_INCLUDE_DIRS)
|
|
||||||
set(FFMPEG_${varname}_FOUND TRUE BOOL)
|
|
||||||
list(APPEND FFMPEG_INCLUDE_DIRS ${FFMPEG_${varname}_INCLUDE_DIRS})
|
|
||||||
list(APPEND FFMPEG_LIBRARIES ${FFMPEG_${varname}_LIBRARY})
|
|
||||||
list(APPEND FFMPEG_LIBRARY_DIRS ${FFMPEG_${varname}_LIBRARY_RELEASE_DIR} ${FFMPEG_${varname}_LIBRARY_DEBUG_DIR})
|
|
||||||
endif()
|
|
||||||
endmacro(FFMPEG_FIND)
|
|
||||||
|
|
||||||
if(@ENABLE_AVDEVICE@)
|
|
||||||
FFMPEG_FIND(libavdevice avdevice avdevice.h)
|
|
||||||
endif()
|
|
||||||
if(@ENABLE_AVFILTER@)
|
|
||||||
FFMPEG_FIND(libavfilter avfilter avfilter.h)
|
|
||||||
endif()
|
|
||||||
if(@ENABLE_AVFORMAT@)
|
|
||||||
FFMPEG_FIND(libavformat avformat avformat.h)
|
|
||||||
endif()
|
|
||||||
if(@ENABLE_AVCODEC@)
|
|
||||||
FFMPEG_FIND(libavcodec avcodec avcodec.h)
|
|
||||||
endif()
|
|
||||||
if(@ENABLE_AVRESAMPLE@)
|
|
||||||
FFMPEG_FIND(libavresample avresample avresample.h)
|
|
||||||
endif()
|
|
||||||
if(@ENABLE_POSTPROC@)
|
|
||||||
FFMPEG_FIND(libpostproc postproc postprocess.h)
|
|
||||||
endif()
|
|
||||||
if(@ENABLE_SWRESAMPLE@)
|
|
||||||
FFMPEG_FIND(libswresample swresample swresample.h)
|
|
||||||
endif()
|
|
||||||
if(@ENABLE_SWSCALE@)
|
|
||||||
FFMPEG_FIND(libswscale swscale swscale.h)
|
|
||||||
endif()
|
|
||||||
FFMPEG_FIND(libavutil avutil avutil.h)
|
|
||||||
|
|
||||||
if (FFMPEG_libavutil_FOUND)
|
|
||||||
list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS)
|
|
||||||
list(REMOVE_DUPLICATES FFMPEG_LIBRARY_DIRS)
|
|
||||||
set(FFMPEG_libavutil_VERSION "@LIBAVUTIL_VERSION@" CACHE STRING "")
|
|
||||||
|
|
||||||
if(FFMPEG_libavcodec_FOUND)
|
|
||||||
set(FFMPEG_libavcodec_VERSION "@LIBAVCODEC_VERSION@" CACHE STRING "")
|
|
||||||
endif()
|
|
||||||
if(FFMPEG_libavdevice_FOUND)
|
|
||||||
set(FFMPEG_libavdevice_VERSION "@LIBAVDEVICE_VERSION@" CACHE STRING "")
|
|
||||||
endif()
|
|
||||||
if(FFMPEG_libavfilter_FOUND)
|
|
||||||
set(FFMPEG_libavfilter_VERSION "@LIBAVFILTER_VERSION@" CACHE STRING "")
|
|
||||||
endif()
|
|
||||||
if(FFMPEG_libavformat_FOUND)
|
|
||||||
set(FFMPEG_libavformat_VERSION "@LIBAVFORMAT_VERSION@" CACHE STRING "")
|
|
||||||
endif()
|
|
||||||
if(FFMPEG_libavresample_FOUND)
|
|
||||||
set(FFMPEG_libavresample_VERSION "@LIBAVRESAMPLE_VERSION@" CACHE STRING "")
|
|
||||||
endif()
|
|
||||||
if(FFMPEG_libswresample_FOUND)
|
|
||||||
set(FFMPEG_libswresample_VERSION "@LIBSWRESAMPLE_VERSION@" CACHE STRING "")
|
|
||||||
endif()
|
|
||||||
if(FFMPEG_libswscale_FOUND)
|
|
||||||
set(FFMPEG_libswscale_VERSION "@LIBSWSCALE_VERSION@" CACHE STRING "")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
append_dependencies(FFMPEG_DEPS_LIBRARY_RELEASE NAMES "@FFMPEG_DEPENDENCIES_RELEASE@")
|
|
||||||
append_dependencies(FFMPEG_DEPS_LIBRARY_DEBUG NAMES "@FFMPEG_DEPENDENCIES_DEBUG@" DEBUG)
|
|
||||||
if(FFMPEG_DEPS_LIBRARY_RELEASE OR FFMPEG_DEPS_LIBRARY_DEBUG)
|
|
||||||
select_library_configurations(FFMPEG_DEPS)
|
|
||||||
list(APPEND FFMPEG_LIBRARIES ${FFMPEG_DEPS_LIBRARY})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(FFMPEG_LIBRARY ${FFMPEG_LIBRARIES})
|
|
||||||
|
|
||||||
set(FFMPEG_FOUND TRUE CACHE BOOL "")
|
|
||||||
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "")
|
|
||||||
set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "")
|
|
||||||
set(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBRARY_DIRS} CACHE STRING "")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_package_handle_standard_args(FFMPEG REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_LIBRARY_DIRS FFMPEG_INCLUDE_DIRS)
|
|
||||||
|
|
||||||
endif()
|
|
@ -1,126 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
export PATH="/usr/bin:$PATH"
|
|
||||||
|
|
||||||
command -v cygpath >/dev/null && have_cygpath=1
|
|
||||||
|
|
||||||
cygpath() {
|
|
||||||
if [ -n "$have_cygpath" ]; then
|
|
||||||
command cygpath "$@"
|
|
||||||
else
|
|
||||||
eval _p='$'$#
|
|
||||||
printf '%s\n' "$_p"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
move_binary() {
|
|
||||||
SOURCE=$1
|
|
||||||
TARGET=$2
|
|
||||||
BINARY=$3
|
|
||||||
|
|
||||||
# run lipo over the command to check whether it really
|
|
||||||
# is a binary that we need to merge architectures
|
|
||||||
lipo $SOURCE/$BINARY -info &> /dev/null || return 0
|
|
||||||
|
|
||||||
# get the directory name the file is in
|
|
||||||
DIRNAME=$(dirname $BINARY)
|
|
||||||
|
|
||||||
# ensure the directory to move the binary to exists
|
|
||||||
mkdir -p $TARGET/$DIRNAME
|
|
||||||
|
|
||||||
# now finally move the binary
|
|
||||||
mv $SOURCE/$BINARY $TARGET/$BINARY
|
|
||||||
}
|
|
||||||
|
|
||||||
move_binaries() {
|
|
||||||
SOURCE=$1
|
|
||||||
TARGET=$2
|
|
||||||
|
|
||||||
[ ! -d $SOURCE ] && return 0
|
|
||||||
pushd $SOURCE
|
|
||||||
|
|
||||||
for BINARY in $(find . -type f); do
|
|
||||||
move_binary $SOURCE $TARGET $BINARY
|
|
||||||
done
|
|
||||||
|
|
||||||
popd
|
|
||||||
}
|
|
||||||
|
|
||||||
merge_binaries() {
|
|
||||||
TARGET=$1
|
|
||||||
SOURCE=$2
|
|
||||||
|
|
||||||
shift
|
|
||||||
shift
|
|
||||||
|
|
||||||
pushd $SOURCE/$1
|
|
||||||
BINARIES=$(find . -type f)
|
|
||||||
popd
|
|
||||||
|
|
||||||
for BINARY in $BINARIES; do
|
|
||||||
COMMAND="lipo -create -output $TARGET/$BINARY"
|
|
||||||
|
|
||||||
for ARCH in $@; do
|
|
||||||
COMMAND="$COMMAND -arch $ARCH $SOURCE/$ARCH/$BINARY"
|
|
||||||
done
|
|
||||||
|
|
||||||
$($COMMAND)
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
export PKG_CONFIG_PATH="$(cygpath -p "${PKG_CONFIG_PATH}")"
|
|
||||||
|
|
||||||
# Export HTTP(S)_PROXY as http(s)_proxy:
|
|
||||||
[ -n "$HTTP_PROXY" ] && export http_proxy="$HTTP_PROXY"
|
|
||||||
[ -n "$HTTPS_PROXY" ] && export https_proxy="$HTTPS_PROXY"
|
|
||||||
|
|
||||||
PATH_TO_BUILD_DIR=$( cygpath "@BUILD_DIR@")
|
|
||||||
PATH_TO_SRC_DIR=$( cygpath "@SOURCE_PATH@")
|
|
||||||
PATH_TO_PACKAGE_DIR=$(cygpath "@INST_PREFIX@")
|
|
||||||
|
|
||||||
JOBS=@VCPKG_CONCURRENCY@
|
|
||||||
|
|
||||||
OSX_ARCHS="@OSX_ARCHS@"
|
|
||||||
OSX_ARCH_COUNT=0@OSX_ARCH_COUNT@
|
|
||||||
|
|
||||||
# Default to hardware concurrency if unset.
|
|
||||||
: ${JOBS:=$(nproc)}
|
|
||||||
|
|
||||||
build_ffmpeg() {
|
|
||||||
echo "=== CONFIGURING ==="
|
|
||||||
|
|
||||||
sh "$PATH_TO_SRC_DIR/configure" "--prefix=$PATH_TO_PACKAGE_DIR" "--cc=$CC" @CONFIGURE_OPTIONS@ $@
|
|
||||||
|
|
||||||
echo "=== BUILDING ==="
|
|
||||||
|
|
||||||
make -j${JOBS} V=1
|
|
||||||
|
|
||||||
echo "=== INSTALLING ==="
|
|
||||||
|
|
||||||
make install
|
|
||||||
}
|
|
||||||
|
|
||||||
cd "$PATH_TO_BUILD_DIR"
|
|
||||||
|
|
||||||
if [ $OSX_ARCH_COUNT -gt 1 ]; then
|
|
||||||
for ARCH in $OSX_ARCHS; do
|
|
||||||
echo "=== CLEANING FOR $ARCH ==="
|
|
||||||
|
|
||||||
make clean && make distclean
|
|
||||||
|
|
||||||
build_ffmpeg --enable-cross-compile --arch=$ARCH --extra-cflags=-arch --extra-cflags=$ARCH --extra-ldflags=-arch --extra-ldflags=$ARCH
|
|
||||||
|
|
||||||
echo "=== COLLECTING BINARIES FOR $ARCH ==="
|
|
||||||
|
|
||||||
move_binaries $PATH_TO_PACKAGE_DIR/lib $PATH_TO_BUILD_DIR/stage/$ARCH/lib
|
|
||||||
move_binaries $PATH_TO_PACKAGE_DIR/bin $PATH_TO_BUILD_DIR/stage/$ARCH/bin
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "=== MERGING ARCHITECTURES ==="
|
|
||||||
|
|
||||||
merge_binaries $PATH_TO_PACKAGE_DIR $PATH_TO_BUILD_DIR/stage $OSX_ARCHS
|
|
||||||
else
|
|
||||||
build_ffmpeg
|
|
||||||
fi
|
|
@ -1,826 +0,0 @@
|
|||||||
if(VCPKG_TARGET_IS_WINDOWS)
|
|
||||||
set(PATCHES 0017-Patch-for-ticket-9019-CUDA-Compile-Broken-Using-MSVC.patch) # https://trac.ffmpeg.org/ticket/9019
|
|
||||||
endif()
|
|
||||||
vcpkg_from_github(
|
|
||||||
OUT_SOURCE_PATH SOURCE_PATH
|
|
||||||
REPO ffmpeg/ffmpeg
|
|
||||||
REF n4.4.5
|
|
||||||
SHA512 09338a10b31f0e551735b9aa57e2c22ceae15bbbca1ee04535587ff55f181e187a77ede4e70d8cd0e1e7c85fb27a7e513c93b91848013e997263d58780b8fa49
|
|
||||||
HEAD_REF master
|
|
||||||
PATCHES
|
|
||||||
0001-create-lib-libraries.patch
|
|
||||||
0003-fix-windowsinclude.patch
|
|
||||||
0004-fix-debug-build.patch
|
|
||||||
0006-fix-StaticFeatures.patch
|
|
||||||
0007-fix-lib-naming.patch
|
|
||||||
0009-Fix-fdk-detection.patch
|
|
||||||
0010-Fix-x264-detection.patch
|
|
||||||
0011-Fix-x265-detection.patch
|
|
||||||
#0012-Fix-ssl-110-detection.patch
|
|
||||||
0013-define-WINVER.patch
|
|
||||||
0014-avfilter-dependency-fix.patch # https://ffmpeg.org/pipermail/ffmpeg-devel/2021-February/275819.html
|
|
||||||
0015-Fix-xml2-detection.patch
|
|
||||||
${PATCHES}
|
|
||||||
0018-libaom-Dont-use-aom_codec_av1_dx_algo.patch
|
|
||||||
0019-libx264-Do-not-explicitly-set-X264_API_IMPORTS.patch
|
|
||||||
0020-fix-aarch64-libswscale.patch
|
|
||||||
0022-fix-m1-hardware-decode-nal-bits.patch # remove in next version
|
|
||||||
0023-fix-qsv-init.patch # remove in next version (5.x)
|
|
||||||
)
|
|
||||||
|
|
||||||
if (SOURCE_PATH MATCHES " ")
|
|
||||||
message(FATAL_ERROR "Error: ffmpeg will not build with spaces in the path. Please use a directory with no spaces")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
|
|
||||||
# ffmpeg nasm build gives link error on x86, so fall back to yasm
|
|
||||||
vcpkg_find_acquire_program(YASM)
|
|
||||||
get_filename_component(YASM_EXE_PATH "${YASM}" DIRECTORY)
|
|
||||||
vcpkg_add_to_path("${YASM_EXE_PATH}")
|
|
||||||
else()
|
|
||||||
vcpkg_find_acquire_program(NASM)
|
|
||||||
get_filename_component(NASM_EXE_PATH "${NASM}" DIRECTORY)
|
|
||||||
vcpkg_add_to_path("${NASM_EXE_PATH}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
|
|
||||||
#We're assuming that if we're building for Windows we're using MSVC
|
|
||||||
set(INCLUDE_VAR "INCLUDE")
|
|
||||||
set(LIB_PATH_VAR "LIB")
|
|
||||||
else()
|
|
||||||
set(INCLUDE_VAR "CPATH")
|
|
||||||
set(LIB_PATH_VAR "LIBRARY_PATH")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(OPTIONS "--enable-pic --disable-doc --enable-debug --enable-runtime-cpudetect")
|
|
||||||
|
|
||||||
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-asm --disable-x86asm")
|
|
||||||
endif()
|
|
||||||
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-asm --disable-x86asm")
|
|
||||||
endif()
|
|
||||||
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-asm --enable-x86asm")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(VCPKG_TARGET_IS_WINDOWS)
|
|
||||||
vcpkg_acquire_msys(MSYS_ROOT)
|
|
||||||
set(SHELL "${MSYS_ROOT}/usr/bin/bash.exe")
|
|
||||||
else()
|
|
||||||
set(SHELL /bin/sh)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(VCPKG_TARGET_IS_MINGW)
|
|
||||||
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
|
|
||||||
string(APPEND OPTIONS " --target-os=mingw32")
|
|
||||||
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
|
|
||||||
string(APPEND OPTIONS " --target-os=mingw64")
|
|
||||||
endif()
|
|
||||||
elseif(VCPKG_TARGET_IS_LINUX)
|
|
||||||
string(APPEND OPTIONS " --target-os=linux")
|
|
||||||
elseif(VCPKG_TARGET_IS_WINDOWS)
|
|
||||||
string(APPEND OPTIONS " --target-os=win32")
|
|
||||||
elseif(VCPKG_TARGET_IS_OSX)
|
|
||||||
string(APPEND OPTIONS " --target-os=darwin")
|
|
||||||
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Android")
|
|
||||||
string(APPEND OPTIONS " --target-os=android")
|
|
||||||
else()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
vcpkg_cmake_get_vars(cmake_vars_file)
|
|
||||||
include("${cmake_vars_file}")
|
|
||||||
|
|
||||||
if(VCPKG_DETECTED_MSVC)
|
|
||||||
set(OPTIONS "--toolchain=msvc ${OPTIONS}")
|
|
||||||
# This is required because ffmpeg depends upon optimizations to link correctly
|
|
||||||
string(APPEND VCPKG_COMBINED_C_FLAGS_DEBUG " -O2")
|
|
||||||
string(REGEX REPLACE "(^| )-RTC1( |$)" " " VCPKG_COMBINED_C_FLAGS_DEBUG "${VCPKG_COMBINED_C_FLAGS_DEBUG}")
|
|
||||||
string(REGEX REPLACE "(^| )-Od( |$)" " " VCPKG_COMBINED_C_FLAGS_DEBUG "${VCPKG_COMBINED_C_FLAGS_DEBUG}")
|
|
||||||
string(REGEX REPLACE "(^| )-Ob0( |$)" " " VCPKG_COMBINED_C_FLAGS_DEBUG "${VCPKG_COMBINED_C_FLAGS_DEBUG}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
string(APPEND VCPKG_COMBINED_C_FLAGS_DEBUG " -I \"${CURRENT_INSTALLED_DIR}/include\"")
|
|
||||||
string(APPEND VCPKG_COMBINED_C_FLAGS_RELEASE " -I \"${CURRENT_INSTALLED_DIR}/include\"")
|
|
||||||
|
|
||||||
set(_csc_PROJECT_PATH ffmpeg)
|
|
||||||
|
|
||||||
file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
|
|
||||||
|
|
||||||
set(FFMPEG_PKGCONFIG_MODULES libavutil)
|
|
||||||
|
|
||||||
if("nonfree" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-nonfree")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("gpl" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-gpl")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("version3" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-version3")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("amf" IN_LIST FEATURES)
|
|
||||||
# Do nothing
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-amf")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("ffmpeg" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-ffmpeg")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-ffmpeg")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("ffplay" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-ffplay")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-ffplay")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("ffprobe" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-ffprobe")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-ffprobe")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (NOT "alsa" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-alsa")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("avcodec" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-avcodec")
|
|
||||||
set(ENABLE_AVCODEC ON)
|
|
||||||
list(APPEND FFMPEG_PKGCONFIG_MODULES libavcodec)
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-avcodec")
|
|
||||||
set(ENABLE_AVCODEC OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("avdevice" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-avdevice")
|
|
||||||
set(ENABLE_AVDEVICE ON)
|
|
||||||
list(APPEND FFMPEG_PKGCONFIG_MODULES libavdevice)
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-avdevice")
|
|
||||||
set(ENABLE_AVDEVICE OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("avformat" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-avformat")
|
|
||||||
set(ENABLE_AVFORMAT ON)
|
|
||||||
list(APPEND FFMPEG_PKGCONFIG_MODULES libavformat)
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-avformat")
|
|
||||||
set(ENABLE_AVFORMAT OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("avfilter" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-avfilter")
|
|
||||||
set(ENABLE_AVFILTER ON)
|
|
||||||
list(APPEND FFMPEG_PKGCONFIG_MODULES libavfilter)
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-avfilter")
|
|
||||||
set(ENABLE_AVFILTER OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("postproc" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-postproc")
|
|
||||||
set(ENABLE_POSTPROC ON)
|
|
||||||
list(APPEND FFMPEG_PKGCONFIG_MODULES libpostproc)
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-postproc")
|
|
||||||
set(ENABLE_POSTPROC OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("swresample" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-swresample")
|
|
||||||
set(ENABLE_SWRESAMPLE ON)
|
|
||||||
list(APPEND FFMPEG_PKGCONFIG_MODULES libswresample)
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-swresample")
|
|
||||||
set(ENABLE_SWRESAMPLE OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("swscale" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-swscale")
|
|
||||||
set(ENABLE_SWSCALE ON)
|
|
||||||
list(APPEND FFMPEG_PKGCONFIG_MODULES libswscale)
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-swscale")
|
|
||||||
set(ENABLE_SWSCALE OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(ENABLE_AVRESAMPLE OFF)
|
|
||||||
if("avresample" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-avresample")
|
|
||||||
set(ENABLE_AVRESAMPLE ON)
|
|
||||||
list(APPEND FFMPEG_PKGCONFIG_MODULES libavresample)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(STATIC_LINKAGE OFF)
|
|
||||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
|
||||||
set(STATIC_LINKAGE ON)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("aom" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libaom")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libaom")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("ass" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libass")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libass")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("avisynthplus" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-avisynth")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-avisynth")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("bzip2" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-bzlib")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-bzlib")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("dav1d" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libdav1d")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libdav1d")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("fdk-aac" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libfdk-aac")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libfdk-aac")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("fontconfig" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libfontconfig")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libfontconfig")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("freetype" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libfreetype")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libfreetype")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("fribidi" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libfribidi")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libfribidi")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("iconv" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-iconv")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-iconv")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("ilbc" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libilbc")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libilbc")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("lzma" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-lzma")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-lzma")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("mp3lame" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libmp3lame")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libmp3lame")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("modplug" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libmodplug")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libmodplug")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("nvcodec" IN_LIST FEATURES)
|
|
||||||
#Note: the --enable-cuda option does not actually require the cuda sdk or toolset port dependency as ffmpeg uses runtime detection and dynamic loading
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-cuda --enable-nvenc --enable-nvdec --enable-cuvid --enable-ffnvcodec")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-cuda --disable-nvenc --disable-nvdec --disable-cuvid --disable-ffnvcodec")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("opencl" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-opencl")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-opencl")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("opengl" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-opengl")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-opengl")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("openh264" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libopenh264")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libopenh264")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("openjpeg" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libopenjpeg")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libopenjpeg")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("openmpt" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libopenmpt")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libopenmpt")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("openssl" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-openssl")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-openssl")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("opus" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libopus")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libopus")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("sdl2" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-sdl2")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-sdl2")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("snappy" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libsnappy")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libsnappy")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("soxr" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libsoxr")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libsoxr")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("speex" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libspeex")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libspeex")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("ssh" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libssh")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libssh")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("tensorflow" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libtensorflow")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libtensorflow")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("tesseract" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libtesseract")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libtesseract")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("theora" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libtheora")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libtheora")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("vorbis" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libvorbis")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libvorbis")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("vpx" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libvpx")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libvpx")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("webp" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libwebp")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libwebp")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("x264" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libx264")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libx264")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("x265" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libx265")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libx265")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("xml2" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libxml2")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libxml2")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("zlib" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-zlib")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-zlib")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if ("srt" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libsrt")
|
|
||||||
else()
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-libsrt")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if ("qsv" IN_LIST FEATURES)
|
|
||||||
set(OPTIONS "${OPTIONS} --enable-libmfx --enable-encoder=h264_qsv --enable-decoder=h264_qsv")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (VCPKG_TARGET_IS_OSX)
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-vdpau") # disable vdpau in OSX
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(VCPKG_TARGET_IS_IOS)
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-audiotoolbox") # disable AudioToolbox on iOS
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(OPTIONS_CROSS " --enable-cross-compile")
|
|
||||||
|
|
||||||
# ffmpeg needs --cross-prefix option to use appropriate tools for cross-compiling.
|
|
||||||
if(VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "([^\/]*-)gcc$")
|
|
||||||
string(APPEND OPTIONS_CROSS " --cross-prefix=${CMAKE_MATCH_1}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
|
|
||||||
string(APPEND OPTIONS_CROSS " --arch=x86_64")
|
|
||||||
else()
|
|
||||||
string(APPEND OPTIONS_CROSS " --arch=${VCPKG_TARGET_ARCHITECTURE}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
|
|
||||||
if(VCPKG_TARGET_IS_WINDOWS)
|
|
||||||
vcpkg_find_acquire_program(GASPREPROCESSOR)
|
|
||||||
foreach(GAS_PATH ${GASPREPROCESSOR})
|
|
||||||
get_filename_component(GAS_ITEM_PATH ${GAS_PATH} DIRECTORY)
|
|
||||||
set(ENV{PATH} "$ENV{PATH}${VCPKG_HOST_PATH_SEPARATOR}${GAS_ITEM_PATH}")
|
|
||||||
endforeach(GAS_PATH)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(VCPKG_TARGET_IS_UWP)
|
|
||||||
set(ENV{LIBPATH} "$ENV{LIBPATH};$ENV{_WKITS10}references\\windows.foundation.foundationcontract\\2.0.0.0\\;$ENV{_WKITS10}references\\windows.foundation.universalapicontract\\3.0.0.0\\")
|
|
||||||
string(APPEND OPTIONS " --disable-programs")
|
|
||||||
string(APPEND OPTIONS " --extra-cflags=-DWINAPI_FAMILY=WINAPI_FAMILY_APP --extra-cflags=-D_WIN32_WINNT=0x0A00")
|
|
||||||
string(APPEND OPTIONS " --extra-ldflags=-APPCONTAINER --extra-ldflags=WindowsApp.lib")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Note: --disable-optimizations can't be used due to https://ffmpeg.org/pipermail/libav-user/2013-March/003945.html
|
|
||||||
set(OPTIONS_DEBUG "--debug")
|
|
||||||
set(OPTIONS_RELEASE "")
|
|
||||||
|
|
||||||
set(OPTIONS "${OPTIONS} ${OPTIONS_CROSS}")
|
|
||||||
|
|
||||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
|
|
||||||
set(OPTIONS "${OPTIONS} --disable-static --enable-shared")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(VCPKG_TARGET_IS_MINGW)
|
|
||||||
set(OPTIONS "${OPTIONS} --extra_cflags=-D_WIN32_WINNT=0x0601")
|
|
||||||
elseif(VCPKG_TARGET_IS_WINDOWS)
|
|
||||||
set(OPTIONS "${OPTIONS} --extra-cflags=-DHAVE_UNISTD_H=0")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
|
||||||
set(OPTIONS "${OPTIONS} --pkg-config-flags=--static")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(ENV_LIB_PATH "$ENV{${LIB_PATH_VAR}}")
|
|
||||||
|
|
||||||
get_filename_component(CC_path "${VCPKG_DETECTED_CMAKE_C_COMPILER}" DIRECTORY)
|
|
||||||
get_filename_component(CC_filename "${VCPKG_DETECTED_CMAKE_C_COMPILER}" NAME)
|
|
||||||
set(ENV{CC} "${CC_filename}")
|
|
||||||
if(CC_path)
|
|
||||||
vcpkg_add_to_path(PREPEND "${CC_path}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
message(STATUS "Building Options: ${OPTIONS}")
|
|
||||||
|
|
||||||
# Release build
|
|
||||||
if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
|
|
||||||
message(STATUS "Building Release Options: ${OPTIONS_RELEASE}")
|
|
||||||
set(ENV{${LIB_PATH_VAR}} "${CURRENT_INSTALLED_DIR}/lib${VCPKG_HOST_PATH_SEPARATOR}${ENV_LIB_PATH}")
|
|
||||||
set(ENV{PKG_CONFIG_PATH} "${CURRENT_INSTALLED_DIR}/lib/pkgconfig")
|
|
||||||
message(STATUS "Building ${_csc_PROJECT_PATH} for Release")
|
|
||||||
file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")
|
|
||||||
# We use response files here as the only known way to handle spaces in paths
|
|
||||||
set(crsp "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/cflags.rsp")
|
|
||||||
file(WRITE "${crsp}" "${VCPKG_COMBINED_C_FLAGS_RELEASE}")
|
|
||||||
set(ldrsp "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/ldflags.rsp")
|
|
||||||
file(WRITE "${ldrsp}" "${VCPKG_COMBINED_SHARED_LINKER_FLAGS_RELEASE}")
|
|
||||||
set(ENV{CFLAGS} "@${crsp}")
|
|
||||||
# All tools except the msvc arm{,64} assembler accept @... as response file syntax.
|
|
||||||
# For that assembler, there is no known way to pass in flags. We must hope that not passing flags will work acceptably.
|
|
||||||
if(NOT VCPKG_DETECTED_MSVC OR NOT VCPKG_TARGET_ARCHITECTURE MATCHES "^arm")
|
|
||||||
set(ENV{ASFLAGS} "@${crsp}")
|
|
||||||
endif()
|
|
||||||
set(ENV{LDFLAGS} "@${ldrsp}")
|
|
||||||
|
|
||||||
set(BUILD_DIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")
|
|
||||||
set(CONFIGURE_OPTIONS "${OPTIONS} ${OPTIONS_RELEASE}")
|
|
||||||
set(INST_PREFIX "${CURRENT_PACKAGES_DIR}")
|
|
||||||
|
|
||||||
configure_file("${CMAKE_CURRENT_LIST_DIR}/build.sh.in" "${BUILD_DIR}/build.sh" @ONLY)
|
|
||||||
|
|
||||||
vcpkg_execute_required_process(
|
|
||||||
COMMAND "${SHELL}" ./build.sh
|
|
||||||
WORKING_DIRECTORY "${BUILD_DIR}"
|
|
||||||
LOGNAME "build-${TARGET_TRIPLET}-rel"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Debug build
|
|
||||||
if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
|
||||||
message(STATUS "Building Debug Options: ${OPTIONS_DEBUG}")
|
|
||||||
set(ENV{${LIB_PATH_VAR}} "${CURRENT_INSTALLED_DIR}/debug/lib${VCPKG_HOST_PATH_SEPARATOR}${ENV_LIB_PATH}")
|
|
||||||
set(ENV{LDFLAGS} "${VCPKG_COMBINED_SHARED_LINKER_FLAGS_DEBUG}")
|
|
||||||
set(ENV{PKG_CONFIG_PATH} "${CURRENT_INSTALLED_DIR}/debug/lib/pkgconfig")
|
|
||||||
message(STATUS "Building ${_csc_PROJECT_PATH} for Debug")
|
|
||||||
file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg")
|
|
||||||
set(crsp "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/cflags.rsp")
|
|
||||||
file(WRITE "${crsp}" "${VCPKG_COMBINED_C_FLAGS_DEBUG}")
|
|
||||||
set(ldrsp "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/ldflags.rsp")
|
|
||||||
file(WRITE "${ldrsp}" "${VCPKG_COMBINED_SHARED_LINKER_FLAGS_DEBUG}")
|
|
||||||
set(ENV{CFLAGS} "@${crsp}")
|
|
||||||
if(NOT VCPKG_DETECTED_MSVC OR NOT VCPKG_TARGET_ARCHITECTURE MATCHES "^arm")
|
|
||||||
set(ENV{ASFLAGS} "@${crsp}")
|
|
||||||
endif()
|
|
||||||
set(ENV{LDFLAGS} "@${ldrsp}")
|
|
||||||
|
|
||||||
set(BUILD_DIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg")
|
|
||||||
set(CONFIGURE_OPTIONS "${OPTIONS} ${OPTIONS_DEBUG}")
|
|
||||||
set(INST_PREFIX "${CURRENT_PACKAGES_DIR}/debug")
|
|
||||||
|
|
||||||
configure_file("${CMAKE_CURRENT_LIST_DIR}/build.sh.in" "${BUILD_DIR}/build.sh" @ONLY)
|
|
||||||
|
|
||||||
vcpkg_execute_required_process(
|
|
||||||
COMMAND "${SHELL}" ./build.sh
|
|
||||||
WORKING_DIRECTORY "${BUILD_DIR}"
|
|
||||||
LOGNAME "build-${TARGET_TRIPLET}-dbg"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(VCPKG_TARGET_IS_WINDOWS)
|
|
||||||
file(GLOB DEF_FILES "${CURRENT_PACKAGES_DIR}/lib/*.def" "${CURRENT_PACKAGES_DIR}/debug/lib/*.def")
|
|
||||||
|
|
||||||
if(NOT VCPKG_TARGET_IS_MINGW)
|
|
||||||
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
|
|
||||||
set(LIB_MACHINE_ARG /machine:ARM)
|
|
||||||
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
|
|
||||||
set(LIB_MACHINE_ARG /machine:ARM64)
|
|
||||||
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
|
|
||||||
set(LIB_MACHINE_ARG /machine:x86)
|
|
||||||
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
|
|
||||||
set(LIB_MACHINE_ARG /machine:x64)
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Unsupported target architecture")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
foreach(DEF_FILE ${DEF_FILES})
|
|
||||||
get_filename_component(DEF_FILE_DIR "${DEF_FILE}" DIRECTORY)
|
|
||||||
get_filename_component(DEF_FILE_NAME "${DEF_FILE}" NAME)
|
|
||||||
string(REGEX REPLACE "-[0-9]*\\.def" "${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}" OUT_FILE_NAME "${DEF_FILE_NAME}")
|
|
||||||
file(TO_NATIVE_PATH "${DEF_FILE}" DEF_FILE_NATIVE)
|
|
||||||
file(TO_NATIVE_PATH "${DEF_FILE_DIR}/${OUT_FILE_NAME}" OUT_FILE_NATIVE)
|
|
||||||
message(STATUS "Generating ${OUT_FILE_NATIVE}")
|
|
||||||
vcpkg_execute_required_process(
|
|
||||||
COMMAND lib.exe "/def:${DEF_FILE_NATIVE}" "/out:${OUT_FILE_NATIVE}" ${LIB_MACHINE_ARG}
|
|
||||||
WORKING_DIRECTORY "${CURRENT_PACKAGES_DIR}"
|
|
||||||
LOGNAME "libconvert-${TARGET_TRIPLET}"
|
|
||||||
)
|
|
||||||
endforeach()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
file(GLOB EXP_FILES "${CURRENT_PACKAGES_DIR}/lib/*.exp" "${CURRENT_PACKAGES_DIR}/debug/lib/*.exp")
|
|
||||||
file(GLOB LIB_FILES "${CURRENT_PACKAGES_DIR}/bin/*${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}" "${CURRENT_PACKAGES_DIR}/debug/bin/*${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}")
|
|
||||||
if(VCPKG_TARGET_IS_MINGW)
|
|
||||||
file(GLOB LIB_FILES_2 "${CURRENT_PACKAGES_DIR}/bin/*.lib" "${CURRENT_PACKAGES_DIR}/debug/bin/*.lib")
|
|
||||||
endif()
|
|
||||||
set(files_to_remove ${EXP_FILES} ${LIB_FILES} ${LIB_FILES_2} ${DEF_FILES})
|
|
||||||
if(files_to_remove)
|
|
||||||
file(REMOVE ${files_to_remove})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("ffmpeg" IN_LIST FEATURES)
|
|
||||||
vcpkg_copy_tools(TOOL_NAMES ffmpeg AUTO_CLEAN)
|
|
||||||
endif()
|
|
||||||
if("ffprobe" IN_LIST FEATURES)
|
|
||||||
vcpkg_copy_tools(TOOL_NAMES ffprobe AUTO_CLEAN)
|
|
||||||
endif()
|
|
||||||
if("ffplay" IN_LIST FEATURES)
|
|
||||||
vcpkg_copy_tools(TOOL_NAMES ffplay AUTO_CLEAN)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")
|
|
||||||
|
|
||||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
|
||||||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
vcpkg_copy_pdbs()
|
|
||||||
|
|
||||||
if (VCPKG_TARGET_IS_WINDOWS)
|
|
||||||
set(_dirs "/")
|
|
||||||
if(NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
|
||||||
list(APPEND _dirs "/debug/")
|
|
||||||
endif()
|
|
||||||
foreach(_debug IN LISTS _dirs)
|
|
||||||
foreach(PKGCONFIG_MODULE IN LISTS FFMPEG_PKGCONFIG_MODULES)
|
|
||||||
set(PKGCONFIG_FILE "${CURRENT_PACKAGES_DIR}${_debug}lib/pkgconfig/${PKGCONFIG_MODULE}.pc")
|
|
||||||
# remove redundant cygwin style -libpath entries
|
|
||||||
execute_process(
|
|
||||||
COMMAND "${MSYS_ROOT}/usr/bin/cygpath.exe" -u "${CURRENT_INSTALLED_DIR}"
|
|
||||||
OUTPUT_VARIABLE CYG_INSTALLED_DIR
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
)
|
|
||||||
vcpkg_replace_string("${PKGCONFIG_FILE}" "-libpath:${CYG_INSTALLED_DIR}${_debug}lib/pkgconfig/../../lib " "")
|
|
||||||
# transform libdir, includedir, and prefix paths from cygwin style to windows style
|
|
||||||
file(READ "${PKGCONFIG_FILE}" PKGCONFIG_CONTENT)
|
|
||||||
foreach(PATH_NAME prefix libdir includedir)
|
|
||||||
string(REGEX MATCH "${PATH_NAME}=[^\n]*" PATH_VALUE "${PKGCONFIG_CONTENT}")
|
|
||||||
string(REPLACE "${PATH_NAME}=" "" PATH_VALUE "${PATH_VALUE}")
|
|
||||||
if(NOT PATH_VALUE)
|
|
||||||
message(FATAL_ERROR "failed to find pkgconfig variable ${PATH_NAME}")
|
|
||||||
endif()
|
|
||||||
execute_process(
|
|
||||||
COMMAND "${MSYS_ROOT}/usr/bin/cygpath.exe" -w "${PATH_VALUE}"
|
|
||||||
OUTPUT_VARIABLE FIXED_PATH
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
)
|
|
||||||
file(TO_CMAKE_PATH "${FIXED_PATH}" FIXED_PATH)
|
|
||||||
vcpkg_replace_string("${PKGCONFIG_FILE}" "${PATH_NAME}=${PATH_VALUE}" "${PATH_NAME}=${FIXED_PATH}")
|
|
||||||
endforeach()
|
|
||||||
# list libraries with -l flag (so pkgconf knows they are libraries and not just linker flags)
|
|
||||||
foreach(LIBS_ENTRY Libs Libs.private)
|
|
||||||
string(REGEX MATCH "${LIBS_ENTRY}: [^\n]*" LIBS_VALUE "${PKGCONFIG_CONTENT}")
|
|
||||||
if(NOT LIBS_VALUE)
|
|
||||||
message(FATAL_ERROR "failed to find pkgconfig entry ${LIBS_ENTRY}")
|
|
||||||
endif()
|
|
||||||
string(REPLACE "${LIBS_ENTRY}: " "" LIBS_VALUE "${LIBS_VALUE}")
|
|
||||||
if(LIBS_VALUE)
|
|
||||||
set(LIBS_VALUE_OLD "${LIBS_VALUE}")
|
|
||||||
string(REGEX REPLACE "([^ ]+)[.]lib" "-l\\1" LIBS_VALUE "${LIBS_VALUE}")
|
|
||||||
set(LIBS_VALUE_NEW "${LIBS_VALUE}")
|
|
||||||
vcpkg_replace_string("${PKGCONFIG_FILE}" "${LIBS_ENTRY}: ${LIBS_VALUE_OLD}" "${LIBS_ENTRY}: ${LIBS_VALUE_NEW}")
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
endforeach()
|
|
||||||
endforeach()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
vcpkg_fixup_pkgconfig()
|
|
||||||
|
|
||||||
# Handle dependencies
|
|
||||||
|
|
||||||
x_vcpkg_pkgconfig_get_modules(PREFIX FFMPEG_PKGCONFIG MODULES ${FFMPEG_PKGCONFIG_MODULES} LIBS)
|
|
||||||
|
|
||||||
function(append_dependencies_from_libs out)
|
|
||||||
cmake_parse_arguments(PARSE_ARGV 1 "arg" "" "LIBS" "")
|
|
||||||
string(REGEX REPLACE "[ ]+" ";" contents "${arg_LIBS}")
|
|
||||||
list(FILTER contents EXCLUDE REGEX "^-framework$")
|
|
||||||
list(FILTER contents EXCLUDE REGEX "^-L.+")
|
|
||||||
list(FILTER contents EXCLUDE REGEX "^-libpath:.+")
|
|
||||||
list(TRANSFORM contents REPLACE "^-Wl,-framework," "-l")
|
|
||||||
list(FILTER contents EXCLUDE REGEX "^-Wl,.+")
|
|
||||||
list(TRANSFORM contents REPLACE "^-l" "")
|
|
||||||
list(FILTER contents EXCLUDE REGEX "^avresample$")
|
|
||||||
list(FILTER contents EXCLUDE REGEX "^avutil$")
|
|
||||||
list(FILTER contents EXCLUDE REGEX "^avcodec$")
|
|
||||||
list(FILTER contents EXCLUDE REGEX "^avdevice$")
|
|
||||||
list(FILTER contents EXCLUDE REGEX "^avfilter$")
|
|
||||||
list(FILTER contents EXCLUDE REGEX "^avformat$")
|
|
||||||
list(FILTER contents EXCLUDE REGEX "^postproc$")
|
|
||||||
list(FILTER contents EXCLUDE REGEX "^swresample$")
|
|
||||||
list(FILTER contents EXCLUDE REGEX "^swscale$")
|
|
||||||
list(FILTER contents EXCLUDE REGEX "^atomic$")
|
|
||||||
if(VCPKG_TARGET_IS_WINDOWS)
|
|
||||||
list(TRANSFORM contents TOLOWER)
|
|
||||||
endif()
|
|
||||||
if(contents)
|
|
||||||
list(APPEND "${out}" "${contents}")
|
|
||||||
set("${out}" "${${out}}" PARENT_SCOPE)
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
append_dependencies_from_libs(FFMPEG_DEPENDENCIES_RELEASE LIBS "${FFMPEG_PKGCONFIG_LIBS_RELEASE}")
|
|
||||||
append_dependencies_from_libs(FFMPEG_DEPENDENCIES_DEBUG LIBS "${FFMPEG_PKGCONFIG_LIBS_DEBUG}")
|
|
||||||
|
|
||||||
# must remove duplicates from the front to respect link order so reverse first
|
|
||||||
list(REVERSE FFMPEG_DEPENDENCIES_RELEASE)
|
|
||||||
list(REVERSE FFMPEG_DEPENDENCIES_DEBUG)
|
|
||||||
list(REMOVE_DUPLICATES FFMPEG_DEPENDENCIES_RELEASE)
|
|
||||||
list(REMOVE_DUPLICATES FFMPEG_DEPENDENCIES_DEBUG)
|
|
||||||
list(REVERSE FFMPEG_DEPENDENCIES_RELEASE)
|
|
||||||
list(REVERSE FFMPEG_DEPENDENCIES_DEBUG)
|
|
||||||
|
|
||||||
message(STATUS "Dependencies (release): ${FFMPEG_DEPENDENCIES_RELEASE}")
|
|
||||||
message(STATUS "Dependencies (debug): ${FFMPEG_DEPENDENCIES_DEBUG}")
|
|
||||||
|
|
||||||
# Handle version strings
|
|
||||||
|
|
||||||
function(extract_regex_from_file out)
|
|
||||||
cmake_parse_arguments(PARSE_ARGV 1 "arg" "" "FILE;REGEX" "")
|
|
||||||
file(READ "${arg_FILE}" contents)
|
|
||||||
if (contents MATCHES "${arg_REGEX}")
|
|
||||||
if(NOT CMAKE_MATCH_COUNT EQUAL 1)
|
|
||||||
message(FATAL_ERROR "Could not identify match group in regular expression \"${arg_REGEX}\"")
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Could not find line matching \"${arg_REGEX}\" in file \"${arg_FILE}\"")
|
|
||||||
endif()
|
|
||||||
set("${out}" "${CMAKE_MATCH_1}" PARENT_SCOPE)
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
function(extract_version_from_component out)
|
|
||||||
cmake_parse_arguments(PARSE_ARGV 1 "arg" "" "COMPONENT" "")
|
|
||||||
string(TOLOWER "${arg_COMPONENT}" component_lower)
|
|
||||||
string(TOUPPER "${arg_COMPONENT}" component_upper)
|
|
||||||
extract_regex_from_file(major_version
|
|
||||||
FILE "${SOURCE_PATH}/${component_lower}/version.h"
|
|
||||||
REGEX "#define ${component_upper}_VERSION_MAJOR[ ]+([0-9]+)"
|
|
||||||
)
|
|
||||||
extract_regex_from_file(minor_version
|
|
||||||
FILE "${SOURCE_PATH}/${component_lower}/version.h"
|
|
||||||
REGEX "#define ${component_upper}_VERSION_MINOR[ ]+([0-9]+)"
|
|
||||||
)
|
|
||||||
extract_regex_from_file(micro_version
|
|
||||||
FILE "${SOURCE_PATH}/${component_lower}/version.h"
|
|
||||||
REGEX "#define ${component_upper}_VERSION_MICRO[ ]+([0-9]+)"
|
|
||||||
)
|
|
||||||
set("${out}" "${major_version}.${minor_version}.${micro_version}" PARENT_SCOPE)
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
extract_regex_from_file(FFMPEG_VERSION
|
|
||||||
FILE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/libavutil/ffversion.h"
|
|
||||||
REGEX "#define FFMPEG_VERSION[ ]+\"(.+)\""
|
|
||||||
)
|
|
||||||
|
|
||||||
extract_version_from_component(LIBAVUTIL_VERSION
|
|
||||||
COMPONENT libavutil)
|
|
||||||
extract_version_from_component(LIBAVCODEC_VERSION
|
|
||||||
COMPONENT libavcodec)
|
|
||||||
extract_version_from_component(LIBAVDEVICE_VERSION
|
|
||||||
COMPONENT libavdevice)
|
|
||||||
extract_version_from_component(LIBAVFILTER_VERSION
|
|
||||||
COMPONENT libavfilter)
|
|
||||||
extract_version_from_component( LIBAVFORMAT_VERSION
|
|
||||||
COMPONENT libavformat)
|
|
||||||
extract_version_from_component(LIBAVRESAMPLE_VERSION
|
|
||||||
COMPONENT libavresample)
|
|
||||||
extract_version_from_component(LIBSWRESAMPLE_VERSION
|
|
||||||
COMPONENT libswresample)
|
|
||||||
extract_version_from_component(LIBSWSCALE_VERSION
|
|
||||||
COMPONENT libswscale)
|
|
||||||
|
|
||||||
# Handle copyright
|
|
||||||
file(STRINGS "${CURRENT_BUILDTREES_DIR}/build-${TARGET_TRIPLET}-rel-out.log" LICENSE_STRING REGEX "License: .*" LIMIT_COUNT 1)
|
|
||||||
if(LICENSE_STRING STREQUAL "License: LGPL version 2.1 or later")
|
|
||||||
set(LICENSE_FILE "COPYING.LGPLv2.1")
|
|
||||||
elseif(LICENSE_STRING STREQUAL "License: LGPL version 3 or later")
|
|
||||||
set(LICENSE_FILE "COPYING.LGPLv3")
|
|
||||||
elseif(LICENSE_STRING STREQUAL "License: GPL version 2 or later")
|
|
||||||
set(LICENSE_FILE "COPYING.GPLv2")
|
|
||||||
elseif(LICENSE_STRING STREQUAL "License: GPL version 3 or later")
|
|
||||||
set(LICENSE_FILE "COPYING.GPLv3")
|
|
||||||
elseif(LICENSE_STRING STREQUAL "License: nonfree and unredistributable")
|
|
||||||
set(LICENSE_FILE "COPYING.NONFREE")
|
|
||||||
file(WRITE "${SOURCE_PATH}/${LICENSE_FILE}" "${LICENSE_STRING}")
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Failed to identify license (${LICENSE_STRING})")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
configure_file("${CMAKE_CURRENT_LIST_DIR}/FindFFMPEG.cmake.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/FindFFMPEG.cmake" @ONLY)
|
|
||||||
file(COPY "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
|
|
||||||
file(INSTALL "${SOURCE_PATH}/${LICENSE_FILE}" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
|
|
@ -1,6 +0,0 @@
|
|||||||
To use ffmpeg add the following to your CMake project:
|
|
||||||
|
|
||||||
find_package(FFMPEG REQUIRED)
|
|
||||||
target_include_directories(main PRIVATE ${FFMPEG_INCLUDE_DIRS})
|
|
||||||
target_link_directories(main PRIVATE ${FFMPEG_LIBRARY_DIRS})
|
|
||||||
target_link_libraries(main PRIVATE ${FFMPEG_LIBRARIES})
|
|
@ -1,8 +0,0 @@
|
|||||||
set(FFMPEG_PREV_MODULE_PATH ${CMAKE_MODULE_PATH})
|
|
||||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
|
|
||||||
|
|
||||||
cmake_policy(SET CMP0012 NEW)
|
|
||||||
|
|
||||||
_find_package(${ARGS})
|
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${FFMPEG_PREV_MODULE_PATH})
|
|
@ -1,676 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"version": "4.4.5",
|
|
||||||
"port-version": 0,
|
|
||||||
"description": [
|
|
||||||
"a library to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created.",
|
|
||||||
"FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. It supports the most obscure ancient formats up to the cutting edge. No matter if they were designed by some standards committee, the community or a corporation. It is also highly portable: FFmpeg compiles, runs, and passes our testing infrastructure FATE across Linux, Mac OS X, Microsoft Windows, the BSDs, Solaris, etc. under a wide variety of build environments, machine architectures, and configurations."
|
|
||||||
],
|
|
||||||
"homepage": "https://ffmpeg.org",
|
|
||||||
"license": null,
|
|
||||||
"dependencies": [
|
|
||||||
{
|
|
||||||
"name": "vcpkg-cmake-get-vars",
|
|
||||||
"host": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "vcpkg-pkgconfig-get-modules",
|
|
||||||
"host": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"default-features": [
|
|
||||||
"avcodec",
|
|
||||||
"avdevice",
|
|
||||||
"avfilter",
|
|
||||||
"avformat",
|
|
||||||
"swresample",
|
|
||||||
"swscale"
|
|
||||||
],
|
|
||||||
"features": {
|
|
||||||
"all": {
|
|
||||||
"description": "Build with all allowed dependencies selected that are compatible with the lgpl license",
|
|
||||||
"dependencies": [
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"avcodec",
|
|
||||||
"avdevice",
|
|
||||||
"avfilter",
|
|
||||||
"avformat",
|
|
||||||
"avresample",
|
|
||||||
"bzip2",
|
|
||||||
"freetype",
|
|
||||||
"iconv",
|
|
||||||
"lzma",
|
|
||||||
"mp3lame",
|
|
||||||
"openjpeg",
|
|
||||||
"opus",
|
|
||||||
"snappy",
|
|
||||||
"soxr",
|
|
||||||
"speex",
|
|
||||||
"swresample",
|
|
||||||
"swscale",
|
|
||||||
"theora",
|
|
||||||
"vorbis",
|
|
||||||
"vpx",
|
|
||||||
"webp",
|
|
||||||
"xml2",
|
|
||||||
"zlib"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"alsa"
|
|
||||||
],
|
|
||||||
"platform": "linux"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"sdl2"
|
|
||||||
],
|
|
||||||
"platform": "!osx"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"ass"
|
|
||||||
],
|
|
||||||
"platform": "!uwp"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"fontconfig"
|
|
||||||
],
|
|
||||||
"platform": "!uwp"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"fribidi"
|
|
||||||
],
|
|
||||||
"platform": "!uwp"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"modplug"
|
|
||||||
],
|
|
||||||
"platform": "!uwp"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"opencl"
|
|
||||||
],
|
|
||||||
"platform": "!uwp"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"openh264"
|
|
||||||
],
|
|
||||||
"platform": "!uwp"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"srt"
|
|
||||||
],
|
|
||||||
"platform": "!uwp"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"ilbc"
|
|
||||||
],
|
|
||||||
"platform": "!(arm & uwp)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"ssh"
|
|
||||||
],
|
|
||||||
"platform": "!(uwp | arm)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"tensorflow"
|
|
||||||
],
|
|
||||||
"platform": "x64 & !static & !uwp"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"aom"
|
|
||||||
],
|
|
||||||
"platform": "!(windows & arm & !uwp)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"dav1d"
|
|
||||||
],
|
|
||||||
"platform": "!(uwp | arm | x86 | osx)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"opengl"
|
|
||||||
],
|
|
||||||
"platform": "!uwp & !(arm64 & windows)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"tesseract"
|
|
||||||
],
|
|
||||||
"platform": "!(windows & arm) & !static & !uwp"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"nvcodec"
|
|
||||||
],
|
|
||||||
"platform": "linux | (!osx & !uwp & !(arm64 & windows))"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"all-gpl": {
|
|
||||||
"description": "Build with all allowed dependencies selected that are compatible with the gpl license",
|
|
||||||
"dependencies": [
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"all",
|
|
||||||
"gpl",
|
|
||||||
"postproc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"x264"
|
|
||||||
],
|
|
||||||
"platform": "!(arm & windows)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"x265"
|
|
||||||
],
|
|
||||||
"platform": "!uwp & !(arm & windows)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"avisynthplus"
|
|
||||||
],
|
|
||||||
"platform": "windows & !arm & !uwp & !static"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"all-nonfree": {
|
|
||||||
"description": "Build with all allowed dependencies selected with a non-redistributable license",
|
|
||||||
"dependencies": [
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"all-gpl",
|
|
||||||
"fdk-aac",
|
|
||||||
"nonfree",
|
|
||||||
"openssl"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"alsa": {
|
|
||||||
"description": "Enable ALSA support",
|
|
||||||
"dependencies": [
|
|
||||||
"alsa"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"amf": {
|
|
||||||
"description": "AMD AMF codec support",
|
|
||||||
"dependencies": [
|
|
||||||
"amd-amf"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"aom": {
|
|
||||||
"description": "AV1 video encoding/decoding via libaom support in ffmpeg",
|
|
||||||
"dependencies": [
|
|
||||||
"aom"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ass": {
|
|
||||||
"description": "Libass subtitles rendering, needed for subtitles and ass filter support in ffmpeg",
|
|
||||||
"dependencies": [
|
|
||||||
"libass"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"avcodec": {
|
|
||||||
"description": "Build the avcodec library"
|
|
||||||
},
|
|
||||||
"avdevice": {
|
|
||||||
"description": "Build the avdevice library",
|
|
||||||
"dependencies": [
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"avcodec",
|
|
||||||
"avformat"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"avfilter": {
|
|
||||||
"description": "Build the avfilter library"
|
|
||||||
},
|
|
||||||
"avformat": {
|
|
||||||
"description": "Build the avformat library",
|
|
||||||
"dependencies": [
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"avcodec"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"avisynthplus": {
|
|
||||||
"description": "Reading of AviSynth script files",
|
|
||||||
"supports": "windows & !static",
|
|
||||||
"dependencies": [
|
|
||||||
"avisynthplus",
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"gpl"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"avresample": {
|
|
||||||
"description": "Build the avresample library"
|
|
||||||
},
|
|
||||||
"bzip2": {
|
|
||||||
"description": "Bzip2 support",
|
|
||||||
"dependencies": [
|
|
||||||
"bzip2"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"dav1d": {
|
|
||||||
"description": "AV1 decoding via libdav1d",
|
|
||||||
"supports": "!osx",
|
|
||||||
"dependencies": [
|
|
||||||
"dav1d"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"fdk-aac": {
|
|
||||||
"description": "AAC de/encoding via libfdk-aac, **including GPL-incompatible patent-encumbered HE-AAC**. If you do not require HE-AAC, use the built-in FFmpeg AAC codec.",
|
|
||||||
"dependencies": [
|
|
||||||
{
|
|
||||||
"name": "fdk-aac",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"he-aac"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"nonfree"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ffmpeg": {
|
|
||||||
"description": "Build the ffmpeg application",
|
|
||||||
"supports": "!uwp",
|
|
||||||
"dependencies": [
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"avcodec",
|
|
||||||
"avfilter",
|
|
||||||
"avformat"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ffplay": {
|
|
||||||
"description": "Build the ffplay application",
|
|
||||||
"supports": "!uwp",
|
|
||||||
"dependencies": [
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"avcodec",
|
|
||||||
"avfilter",
|
|
||||||
"avformat",
|
|
||||||
"sdl2",
|
|
||||||
"swresample",
|
|
||||||
"swscale"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ffprobe": {
|
|
||||||
"description": "Build the ffprobe application",
|
|
||||||
"supports": "!uwp",
|
|
||||||
"dependencies": [
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"avcodec",
|
|
||||||
"avformat"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"fontconfig": {
|
|
||||||
"description": "Useful for drawtext filter",
|
|
||||||
"dependencies": [
|
|
||||||
"fontconfig"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"freetype": {
|
|
||||||
"description": "Needed for drawtext filter",
|
|
||||||
"dependencies": [
|
|
||||||
"freetype"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"fribidi": {
|
|
||||||
"description": "Improves drawtext filter",
|
|
||||||
"dependencies": [
|
|
||||||
"fribidi"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"gpl": {
|
|
||||||
"description": "Allow use of GPL code, the resulting libs and binaries will be under GPL"
|
|
||||||
},
|
|
||||||
"iconv": {
|
|
||||||
"description": "Iconv support",
|
|
||||||
"dependencies": [
|
|
||||||
"libiconv"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ilbc": {
|
|
||||||
"description": "iLBC de/encoding via libilbc",
|
|
||||||
"dependencies": [
|
|
||||||
"libilbc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"lzma": {
|
|
||||||
"description": "lzma support",
|
|
||||||
"dependencies": [
|
|
||||||
"liblzma"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"modplug": {
|
|
||||||
"description": "ModPlug via libmodplug",
|
|
||||||
"dependencies": [
|
|
||||||
"libmodplug"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"mp3lame": {
|
|
||||||
"description": "MP3 encoding via libmp3lame",
|
|
||||||
"dependencies": [
|
|
||||||
"mp3lame"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"nonfree": {
|
|
||||||
"description": "Allow use of nonfree code, the resulting libs and binaries will be unredistributable"
|
|
||||||
},
|
|
||||||
"nvcodec": {
|
|
||||||
"description": "Nvidia video decoding/encoding acceleration",
|
|
||||||
"supports": "linux | (!osx & !uwp & !(arm64 & windows))",
|
|
||||||
"dependencies": [
|
|
||||||
"ffnvcodec"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"opencl": {
|
|
||||||
"description": "OpenCL processing",
|
|
||||||
"supports": "!uwp",
|
|
||||||
"dependencies": [
|
|
||||||
"opencl"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"opengl": {
|
|
||||||
"description": "OpenGL rendering",
|
|
||||||
"supports": "!uwp",
|
|
||||||
"dependencies": [
|
|
||||||
"opengl",
|
|
||||||
"opengl-registry"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"openh264": {
|
|
||||||
"description": "H.264 de/encoding via openh264",
|
|
||||||
"dependencies": [
|
|
||||||
"openh264"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"openjpeg": {
|
|
||||||
"description": "JPEG 2000 de/encoding via OpenJPEG",
|
|
||||||
"dependencies": [
|
|
||||||
"openjpeg"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"openmpt": {
|
|
||||||
"description": "Decoding tracked files via libopenmpt",
|
|
||||||
"dependencies": [
|
|
||||||
"libopenmpt"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"openssl": {
|
|
||||||
"description": "Needed for https support if gnutls, libtls or mbedtls is not used",
|
|
||||||
"dependencies": [
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"nonfree"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"openssl"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"opus": {
|
|
||||||
"description": "Opus de/encoding via libopus",
|
|
||||||
"dependencies": [
|
|
||||||
"opus"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"postproc": {
|
|
||||||
"description": "Build the postproc library",
|
|
||||||
"dependencies": [
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"gpl"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"qsv": {
|
|
||||||
"description": "Intel QSV Codec",
|
|
||||||
"dependencies": [
|
|
||||||
"mfx-dispatch"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"sdl2": {
|
|
||||||
"description": "Sdl2 support",
|
|
||||||
"dependencies": [
|
|
||||||
{
|
|
||||||
"name": "sdl2",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"x11"
|
|
||||||
],
|
|
||||||
"platform": "linux"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sdl2",
|
|
||||||
"platform": "!linux"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"snappy": {
|
|
||||||
"description": "Snappy compression, needed for hap encoding",
|
|
||||||
"dependencies": [
|
|
||||||
"snappy"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"soxr": {
|
|
||||||
"description": "Include libsoxr resampling",
|
|
||||||
"dependencies": [
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"swresample"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"soxr"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"speex": {
|
|
||||||
"description": "Speex de/encoding via libspeex",
|
|
||||||
"dependencies": [
|
|
||||||
"speex"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"srt": {
|
|
||||||
"description": "Haivision SRT protocol",
|
|
||||||
"supports": "!uwp",
|
|
||||||
"dependencies": [
|
|
||||||
"libsrt"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ssh": {
|
|
||||||
"description": "SFTP protocol via libssh",
|
|
||||||
"dependencies": [
|
|
||||||
"libssh"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"swresample": {
|
|
||||||
"description": "Build the swresample library"
|
|
||||||
},
|
|
||||||
"swscale": {
|
|
||||||
"description": "Build the swscale library"
|
|
||||||
},
|
|
||||||
"tensorflow": {
|
|
||||||
"description": "TensorFlow as a DNN module backend for DNN based filters like sr",
|
|
||||||
"supports": "!static",
|
|
||||||
"dependencies": [
|
|
||||||
"tensorflow"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"tesseract": {
|
|
||||||
"description": "Tesseract, needed for ocr filter",
|
|
||||||
"supports": "!static",
|
|
||||||
"dependencies": [
|
|
||||||
"tesseract"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"theora": {
|
|
||||||
"description": "Theora encoding via libtheora",
|
|
||||||
"dependencies": [
|
|
||||||
"libtheora"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"version3": {
|
|
||||||
"description": "Upgrade (L)GPL to version 3"
|
|
||||||
},
|
|
||||||
"vorbis": {
|
|
||||||
"description": "Vorbis en/decoding via libvorbis, native implementation exists",
|
|
||||||
"dependencies": [
|
|
||||||
"libvorbis"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"vpx": {
|
|
||||||
"description": "VP8 and VP9 de/encoding via libvpx",
|
|
||||||
"dependencies": [
|
|
||||||
"libvpx"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"webp": {
|
|
||||||
"description": "WebP encoding via libwebp",
|
|
||||||
"dependencies": [
|
|
||||||
"libwebp"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"x264": {
|
|
||||||
"description": "H.264 encoding via x264",
|
|
||||||
"dependencies": [
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"gpl"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"x264"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"x265": {
|
|
||||||
"description": "HEVC encoding via x265",
|
|
||||||
"dependencies": [
|
|
||||||
{
|
|
||||||
"name": "ffmpeg",
|
|
||||||
"default-features": false,
|
|
||||||
"features": [
|
|
||||||
"gpl"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"x265"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"xml2": {
|
|
||||||
"description": "XML parsing using the C library libxml2, needed for dash demuxing support",
|
|
||||||
"dependencies": [
|
|
||||||
"libxml2"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"zlib": {
|
|
||||||
"description": "zlib support",
|
|
||||||
"dependencies": [
|
|
||||||
"zlib"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,4 +2,5 @@
|
|||||||
set(OCCT_TKService_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
|
set(OCCT_TKService_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
|
||||||
|
|
||||||
set(OCCT_TKService_GTests_FILES
|
set(OCCT_TKService_GTests_FILES
|
||||||
|
Image_VideoRecorder_Test.cxx
|
||||||
)
|
)
|
||||||
|
156
src/Visualization/TKService/GTests/Image_VideoRecorder_Test.cxx
Normal file
156
src/Visualization/TKService/GTests/Image_VideoRecorder_Test.cxx
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
// Copyright (c) 2025 OPEN CASCADE SAS
|
||||||
|
//
|
||||||
|
// This file is part of Open CASCADE Technology software library.
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or modify it under
|
||||||
|
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||||
|
// by the Free Software Foundation, with special exception defined in the file
|
||||||
|
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||||
|
// distribution for complete text of the license and disclaimer of any warranty.
|
||||||
|
//
|
||||||
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||||
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
|
#include <Image_VideoRecorder.hxx>
|
||||||
|
#include <Image_PixMap.hxx>
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
class Image_VideoRecorderTest : public ::testing::Test
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
void SetUp() override { myRecorder = new Image_VideoRecorder(); }
|
||||||
|
|
||||||
|
void TearDown() override
|
||||||
|
{
|
||||||
|
if (!myRecorder.IsNull())
|
||||||
|
{
|
||||||
|
myRecorder->Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle(Image_VideoRecorder) myRecorder;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(Image_VideoRecorderTest, DefaultConstructor)
|
||||||
|
{
|
||||||
|
EXPECT_FALSE(myRecorder.IsNull());
|
||||||
|
EXPECT_EQ(0, myRecorder->FrameCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(Image_VideoRecorderTest, VideoParamsStructure)
|
||||||
|
{
|
||||||
|
Image_VideoParams params;
|
||||||
|
|
||||||
|
// Test default values
|
||||||
|
EXPECT_EQ(0, params.Width);
|
||||||
|
EXPECT_EQ(0, params.Height);
|
||||||
|
EXPECT_EQ(0, params.FpsNum);
|
||||||
|
EXPECT_EQ(1, params.FpsDen);
|
||||||
|
EXPECT_TRUE(params.Format.IsEmpty());
|
||||||
|
EXPECT_TRUE(params.VideoCodec.IsEmpty());
|
||||||
|
EXPECT_TRUE(params.PixelFormat.IsEmpty());
|
||||||
|
|
||||||
|
// Test setters
|
||||||
|
params.SetFramerate(30);
|
||||||
|
EXPECT_EQ(30, params.FpsNum);
|
||||||
|
EXPECT_EQ(1, params.FpsDen);
|
||||||
|
|
||||||
|
params.SetFramerate(25, 2);
|
||||||
|
EXPECT_EQ(25, params.FpsNum);
|
||||||
|
EXPECT_EQ(2, params.FpsDen);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(Image_VideoRecorderTest, OpenVideoFile)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_FFMPEG
|
||||||
|
Image_VideoParams params;
|
||||||
|
params.Width = 320;
|
||||||
|
params.Height = 240;
|
||||||
|
params.SetFramerate(15); // Low framerate for test
|
||||||
|
params.Format = "avi";
|
||||||
|
params.VideoCodec = "mpeg4"; // Use a commonly available codec
|
||||||
|
params.PixelFormat = "yuv420p";
|
||||||
|
|
||||||
|
// Test opening a valid video file
|
||||||
|
Standard_Boolean isOpened = myRecorder->Open("test_video.avi", params);
|
||||||
|
EXPECT_TRUE(isOpened);
|
||||||
|
|
||||||
|
if (isOpened)
|
||||||
|
{
|
||||||
|
// Test frame access
|
||||||
|
Image_PixMap& frame = myRecorder->ChangeFrame();
|
||||||
|
EXPECT_EQ(params.Width, frame.Width());
|
||||||
|
EXPECT_EQ(params.Height, frame.Height());
|
||||||
|
EXPECT_EQ(Image_Format_RGBA, frame.Format());
|
||||||
|
|
||||||
|
myRecorder->Close();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(Image_VideoRecorderTest, InvalidParameters)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_FFMPEG
|
||||||
|
Image_VideoParams params;
|
||||||
|
// Leave parameters invalid (width=0, height=0)
|
||||||
|
|
||||||
|
Standard_Boolean isOpened = myRecorder->Open("invalid_test.avi", params);
|
||||||
|
EXPECT_FALSE(isOpened);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(Image_VideoRecorderTest, WriteFrames)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_FFMPEG
|
||||||
|
Image_VideoParams params;
|
||||||
|
params.Width = 160; // Small size for fast test
|
||||||
|
params.Height = 120;
|
||||||
|
params.SetFramerate(10); // Low framerate
|
||||||
|
params.Format = "avi";
|
||||||
|
params.VideoCodec = "mpeg4";
|
||||||
|
params.PixelFormat = "yuv420p";
|
||||||
|
|
||||||
|
Standard_Boolean isOpened = myRecorder->Open("test_frames.avi", params);
|
||||||
|
|
||||||
|
if (isOpened)
|
||||||
|
{
|
||||||
|
// Fill frame with test pattern
|
||||||
|
Image_PixMap& frame = myRecorder->ChangeFrame();
|
||||||
|
|
||||||
|
// Create a simple red-to-blue gradient
|
||||||
|
for (Standard_Integer y = 0; y < params.Height; ++y)
|
||||||
|
{
|
||||||
|
for (Standard_Integer x = 0; x < params.Width; ++x)
|
||||||
|
{
|
||||||
|
Standard_Byte* pixel = frame.ChangeData() + (y * frame.SizeRowBytes()) + (x * 4);
|
||||||
|
pixel[0] = (Standard_Byte)(255 * x / params.Width); // Red gradient
|
||||||
|
pixel[1] = 0; // Green
|
||||||
|
pixel[2] = (Standard_Byte)(255 * y / params.Height); // Blue gradient
|
||||||
|
pixel[3] = 255; // Alpha
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test writing a few frames
|
||||||
|
EXPECT_EQ(0, myRecorder->FrameCount());
|
||||||
|
|
||||||
|
EXPECT_TRUE(myRecorder->PushFrame());
|
||||||
|
EXPECT_EQ(1, myRecorder->FrameCount());
|
||||||
|
|
||||||
|
EXPECT_TRUE(myRecorder->PushFrame());
|
||||||
|
EXPECT_EQ(2, myRecorder->FrameCount());
|
||||||
|
|
||||||
|
EXPECT_TRUE(myRecorder->PushFrame());
|
||||||
|
EXPECT_EQ(3, myRecorder->FrameCount());
|
||||||
|
|
||||||
|
myRecorder->Close();
|
||||||
|
}
|
||||||
|
#endif // HAVE_FFMPEG
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(Image_VideoRecorderTest, CloseWithoutOpen)
|
||||||
|
{
|
||||||
|
// Test that closing without opening doesn't crash
|
||||||
|
myRecorder->Close();
|
||||||
|
EXPECT_EQ(0, myRecorder->FrameCount());
|
||||||
|
}
|
@ -13,18 +13,13 @@
|
|||||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
// activate some C99 macros like UINT64_C in "stdint.h" which used by FFmpeg
|
|
||||||
#ifndef __STDC_CONSTANT_MACROS
|
|
||||||
#define __STDC_CONSTANT_MACROS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <Image_VideoRecorder.hxx>
|
#include <Image_VideoRecorder.hxx>
|
||||||
|
#include "../Media/Media_FFmpegCompatibility.pxx"
|
||||||
|
|
||||||
#include <Message.hxx>
|
#include <Message.hxx>
|
||||||
#include <Message_Messenger.hxx>
|
#include <Message_Messenger.hxx>
|
||||||
|
|
||||||
#ifdef HAVE_FFMPEG
|
#ifdef HAVE_FFMPEG
|
||||||
|
|
||||||
// Suppress deprecation warnings - it is difficult to provide compatibility with old and new API
|
// Suppress deprecation warnings - it is difficult to provide compatibility with old and new API
|
||||||
// at once since new APIs are introduced too often. Should be disabled from time to time to clean
|
// at once since new APIs are introduced too often. Should be disabled from time to time to clean
|
||||||
// up usage of old APIs.
|
// up usage of old APIs.
|
||||||
@ -34,22 +29,6 @@ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
|
|||||||
Standard_DISABLE_DEPRECATION_WARNINGS
|
Standard_DISABLE_DEPRECATION_WARNINGS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
// suppress some common warnings in FFmpeg headers
|
|
||||||
#pragma warning(disable : 4244)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
|
||||||
#include <libavformat/avformat.h>
|
|
||||||
#include <libswscale/swscale.h>
|
|
||||||
#include <libavutil/imgutils.h>
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(default : 4244)
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
// Undefine macro that clashes with name used by field of Image_VideoParams;
|
// Undefine macro that clashes with name used by field of Image_VideoParams;
|
||||||
// this macro is defined in headers of older versions of libavutil
|
// this macro is defined in headers of older versions of libavutil
|
||||||
// (see definition of macro FF_API_PIX_FMT in version.h)
|
// (see definition of macro FF_API_PIX_FMT in version.h)
|
||||||
@ -59,14 +38,15 @@ Standard_DISABLE_DEPRECATION_WARNINGS
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(Image_VideoRecorder, Standard_Transient)
|
IMPLEMENT_STANDARD_RTTIEXT(Image_VideoRecorder, Standard_Transient)
|
||||||
|
|
||||||
//=================================================================================================
|
//=================================================================================================
|
||||||
|
|
||||||
Image_VideoRecorder::Image_VideoRecorder()
|
Image_VideoRecorder::Image_VideoRecorder()
|
||||||
: myAVContext(NULL),
|
: myAVContext(NULL),
|
||||||
myVideoStream(NULL),
|
myVideoStream(NULL),
|
||||||
myVideoCodec(NULL),
|
myVideoCodec(NULL),
|
||||||
|
myCodecCtx(NULL),
|
||||||
myFrame(NULL),
|
myFrame(NULL),
|
||||||
myScaleCtx(NULL),
|
myScaleCtx(NULL),
|
||||||
myFrameCount(0)
|
myFrameCount(0)
|
||||||
@ -76,7 +56,7 @@ Image_VideoRecorder::Image_VideoRecorder()
|
|||||||
|
|
||||||
#ifdef HAVE_FFMPEG
|
#ifdef HAVE_FFMPEG
|
||||||
// initialize libavcodec, and register all codecs and formats, should be done once
|
// initialize libavcodec, and register all codecs and formats, should be done once
|
||||||
av_register_all();
|
ffmpeg_register_all();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,6 +82,21 @@ TCollection_AsciiString Image_VideoRecorder::formatAvError(const int theError) c
|
|||||||
|
|
||||||
//=================================================================================================
|
//=================================================================================================
|
||||||
|
|
||||||
|
AVCodecContext* Image_VideoRecorder::getCodecContext() const
|
||||||
|
{
|
||||||
|
#ifdef HAVE_FFMPEG
|
||||||
|
#if FFMPEG_HAVE_AVCODEC_PARAMETERS
|
||||||
|
return myCodecCtx;
|
||||||
|
#else
|
||||||
|
return myVideoStream != NULL ? myVideoStream->codec : NULL;
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================================
|
||||||
|
|
||||||
void Image_VideoRecorder::Close()
|
void Image_VideoRecorder::Close()
|
||||||
{
|
{
|
||||||
#ifdef HAVE_FFMPEG
|
#ifdef HAVE_FFMPEG
|
||||||
@ -129,7 +124,15 @@ void Image_VideoRecorder::Close()
|
|||||||
// close each codec
|
// close each codec
|
||||||
if (myVideoStream != NULL)
|
if (myVideoStream != NULL)
|
||||||
{
|
{
|
||||||
|
#if FFMPEG_HAVE_AVCODEC_PARAMETERS
|
||||||
|
if (myCodecCtx != NULL)
|
||||||
|
{
|
||||||
|
avcodec_free_context(&myCodecCtx);
|
||||||
|
myCodecCtx = NULL;
|
||||||
|
}
|
||||||
|
#else
|
||||||
avcodec_close(myVideoStream->codec);
|
avcodec_close(myVideoStream->codec);
|
||||||
|
#endif
|
||||||
myVideoStream = NULL;
|
myVideoStream = NULL;
|
||||||
}
|
}
|
||||||
if (myFrame != NULL)
|
if (myFrame != NULL)
|
||||||
@ -235,12 +238,12 @@ Standard_Boolean Image_VideoRecorder::addVideoStream(const Image_VideoParams& th
|
|||||||
TCollection_AsciiString aCodecName;
|
TCollection_AsciiString aCodecName;
|
||||||
if (!theParams.VideoCodec.IsEmpty())
|
if (!theParams.VideoCodec.IsEmpty())
|
||||||
{
|
{
|
||||||
myVideoCodec = avcodec_find_encoder_by_name(theParams.VideoCodec.ToCString());
|
myVideoCodec = ffmpeg_find_encoder_by_name(theParams.VideoCodec.ToCString());
|
||||||
aCodecName = theParams.VideoCodec;
|
aCodecName = theParams.VideoCodec;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
myVideoCodec = avcodec_find_encoder((AVCodecID)theDefCodecId);
|
myVideoCodec = ffmpeg_find_encoder((AVCodecID)theDefCodecId);
|
||||||
aCodecName = avcodec_get_name((AVCodecID)theDefCodecId);
|
aCodecName = avcodec_get_name((AVCodecID)theDefCodecId);
|
||||||
}
|
}
|
||||||
if (myVideoCodec == NULL)
|
if (myVideoCodec == NULL)
|
||||||
@ -258,7 +261,20 @@ Standard_Boolean Image_VideoRecorder::addVideoStream(const Image_VideoParams& th
|
|||||||
}
|
}
|
||||||
myVideoStream->id = myAVContext->nb_streams - 1;
|
myVideoStream->id = myAVContext->nb_streams - 1;
|
||||||
|
|
||||||
|
#if FFMPEG_HAVE_AVCODEC_PARAMETERS
|
||||||
|
// For FFmpeg 5.0+, allocate and use separate codec context
|
||||||
|
myCodecCtx = avcodec_alloc_context3(myVideoCodec);
|
||||||
|
if (myCodecCtx == NULL)
|
||||||
|
{
|
||||||
|
::Message::SendFail("Error: can not allocate codec context");
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
AVCodecContext* aCodecCtx = myCodecCtx;
|
||||||
|
#else
|
||||||
|
// For FFmpeg 4.x, use stream's codec context
|
||||||
AVCodecContext* aCodecCtx = myVideoStream->codec;
|
AVCodecContext* aCodecCtx = myVideoStream->codec;
|
||||||
|
#endif
|
||||||
|
|
||||||
aCodecCtx->codec_id = aCodecId;
|
aCodecCtx->codec_id = aCodecId;
|
||||||
// resolution must be a multiple of two
|
// resolution must be a multiple of two
|
||||||
aCodecCtx->width = theParams.Width;
|
aCodecCtx->width = theParams.Width;
|
||||||
@ -275,6 +291,15 @@ Standard_Boolean Image_VideoRecorder::addVideoStream(const Image_VideoParams& th
|
|||||||
{
|
{
|
||||||
aCodecCtx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
aCodecCtx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if FFMPEG_HAVE_AVCODEC_PARAMETERS
|
||||||
|
// Copy codec context parameters to stream
|
||||||
|
if (avcodec_parameters_from_context(myVideoStream->codecpar, aCodecCtx) < 0)
|
||||||
|
{
|
||||||
|
::Message::SendFail("Error: can not copy codec parameters to stream");
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
#else
|
#else
|
||||||
(void)theParams;
|
(void)theParams;
|
||||||
@ -289,37 +314,43 @@ Standard_Boolean Image_VideoRecorder::openVideoCodec(const Image_VideoParams& th
|
|||||||
{
|
{
|
||||||
#ifdef HAVE_FFMPEG
|
#ifdef HAVE_FFMPEG
|
||||||
AVDictionary* anOptions = NULL;
|
AVDictionary* anOptions = NULL;
|
||||||
AVCodecContext* aCodecCtx = myVideoStream->codec;
|
AVCodecContext* aCodecCtx = getCodecContext();
|
||||||
|
|
||||||
|
if (aCodecCtx == NULL)
|
||||||
|
{
|
||||||
|
::Message::SendFail("Error: codec context is not available");
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
// setup default values
|
// setup default values
|
||||||
aCodecCtx->pix_fmt = AV_PIX_FMT_YUV420P;
|
aCodecCtx->pix_fmt = AV_PIX_FMT_YUV420P;
|
||||||
// av_dict_set (&anOptions, "threads", "auto", 0);
|
// av_dict_set (&anOptions, "threads", "auto", 0);
|
||||||
if (aCodecCtx->codec == avcodec_find_encoder_by_name("mpeg2video"))
|
if (myVideoCodec == ffmpeg_find_encoder_by_name("mpeg2video"))
|
||||||
{
|
{
|
||||||
// just for testing, we also add B frames
|
// just for testing, we also add B frames
|
||||||
aCodecCtx->max_b_frames = 2;
|
aCodecCtx->max_b_frames = 2;
|
||||||
aCodecCtx->bit_rate = 6000000;
|
aCodecCtx->bit_rate = 6000000;
|
||||||
}
|
}
|
||||||
else if (aCodecCtx->codec == avcodec_find_encoder_by_name("mpeg4"))
|
else if (myVideoCodec == ffmpeg_find_encoder_by_name("mpeg4"))
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
else if (aCodecCtx->codec == avcodec_find_encoder_by_name("mjpeg"))
|
else if (myVideoCodec == ffmpeg_find_encoder_by_name("mjpeg"))
|
||||||
{
|
{
|
||||||
aCodecCtx->pix_fmt = AV_PIX_FMT_YUVJ420P;
|
aCodecCtx->pix_fmt = AV_PIX_FMT_YUVJ420P;
|
||||||
aCodecCtx->qmin = aCodecCtx->qmax = 5;
|
aCodecCtx->qmin = aCodecCtx->qmax = 5;
|
||||||
}
|
}
|
||||||
else if (aCodecCtx->codec == avcodec_find_encoder_by_name("huffyuv"))
|
else if (myVideoCodec == ffmpeg_find_encoder_by_name("huffyuv"))
|
||||||
{
|
{
|
||||||
aCodecCtx->pix_fmt = AV_PIX_FMT_RGB24;
|
aCodecCtx->pix_fmt = AV_PIX_FMT_RGB24;
|
||||||
}
|
}
|
||||||
else if (aCodecCtx->codec == avcodec_find_encoder_by_name("png"))
|
else if (myVideoCodec == ffmpeg_find_encoder_by_name("png"))
|
||||||
{
|
{
|
||||||
aCodecCtx->pix_fmt = AV_PIX_FMT_RGB24;
|
aCodecCtx->pix_fmt = AV_PIX_FMT_RGB24;
|
||||||
aCodecCtx->compression_level = 9; // 0..9
|
aCodecCtx->compression_level = 9; // 0..9
|
||||||
}
|
}
|
||||||
else if (aCodecCtx->codec == avcodec_find_encoder_by_name("h264")
|
else if (myVideoCodec == ffmpeg_find_encoder_by_name("h264")
|
||||||
|| aCodecCtx->codec == avcodec_find_encoder_by_name("libx264"))
|
|| myVideoCodec == ffmpeg_find_encoder_by_name("libx264"))
|
||||||
{
|
{
|
||||||
// use CRF (Constant Rate Factor) as best single-pass compressing method
|
// use CRF (Constant Rate Factor) as best single-pass compressing method
|
||||||
// clang-format off
|
// clang-format off
|
||||||
@ -335,8 +366,8 @@ Standard_Boolean Image_VideoRecorder::openVideoCodec(const Image_VideoParams& th
|
|||||||
// av_dict_set (&anOptions, "profile", "baseline", 0);
|
// av_dict_set (&anOptions, "profile", "baseline", 0);
|
||||||
// av_dict_set (&anOptions, "level", "3.0", 0);
|
// av_dict_set (&anOptions, "level", "3.0", 0);
|
||||||
}
|
}
|
||||||
else if (aCodecCtx->codec == avcodec_find_encoder_by_name("vp8")
|
else if (myVideoCodec == ffmpeg_find_encoder_by_name("vp8")
|
||||||
|| aCodecCtx->codec == avcodec_find_encoder_by_name("vp9"))
|
|| myVideoCodec == ffmpeg_find_encoder_by_name("vp9"))
|
||||||
{
|
{
|
||||||
av_dict_set(&anOptions, "crf", "20", 0); // quality 4-63, 10 is normal
|
av_dict_set(&anOptions, "crf", "20", 0); // quality 4-63, 10 is normal
|
||||||
}
|
}
|
||||||
@ -445,7 +476,7 @@ Standard_Boolean Image_VideoRecorder::writeVideoFrame(const Standard_Boolean the
|
|||||||
}
|
}
|
||||||
|
|
||||||
int aResAv = 0;
|
int aResAv = 0;
|
||||||
AVCodecContext* aCodecCtx = myVideoStream->codec;
|
AVCodecContext* aCodecCtx = getCodecContext();
|
||||||
if (!theToFlush)
|
if (!theToFlush)
|
||||||
{
|
{
|
||||||
uint8_t* aSrcData[4] = {(uint8_t*)myImgSrcRgba.ChangeData(), NULL, NULL, NULL};
|
uint8_t* aSrcData[4] = {(uint8_t*)myImgSrcRgba.ChangeData(), NULL, NULL, NULL};
|
||||||
@ -459,12 +490,77 @@ Standard_Boolean Image_VideoRecorder::writeVideoFrame(const Standard_Boolean the
|
|||||||
myFrame->linesize);
|
myFrame->linesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if FFMPEG_HAVE_NEW_DECODE_API
|
||||||
|
// New API: use avcodec_send_frame/avcodec_receive_packet
|
||||||
|
if (!theToFlush)
|
||||||
|
{
|
||||||
|
myFrame->pts = myFrameCount;
|
||||||
|
aResAv = avcodec_send_frame(aCodecCtx, myFrame);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aResAv = avcodec_send_frame(aCodecCtx, NULL); // flush
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aResAv < 0)
|
||||||
|
{
|
||||||
|
::Message::SendFail(TCollection_AsciiString("Error: can not send frame to encoder, ")
|
||||||
|
+ formatAvError(aResAv));
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (aResAv >= 0)
|
||||||
|
{
|
||||||
|
AVPacket* aPacket = av_packet_alloc();
|
||||||
|
aResAv = avcodec_receive_packet(aCodecCtx, aPacket);
|
||||||
|
if (aResAv == AVERROR(EAGAIN) || aResAv == AVERROR_EOF)
|
||||||
|
{
|
||||||
|
av_packet_free(&aPacket);
|
||||||
|
break; // need more input or end of stream
|
||||||
|
}
|
||||||
|
else if (aResAv < 0)
|
||||||
|
{
|
||||||
|
av_packet_free(&aPacket);
|
||||||
|
::Message::SendFail(TCollection_AsciiString("Error: can not encode video frame, ")
|
||||||
|
+ formatAvError(aResAv));
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
// rescale output packet timestamp values from codec to stream timebase
|
||||||
|
aPacket->pts = av_rescale_q_rnd(aPacket->pts,
|
||||||
|
aCodecCtx->time_base,
|
||||||
|
myVideoStream->time_base,
|
||||||
|
AVRounding(AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));
|
||||||
|
aPacket->dts = av_rescale_q_rnd(aPacket->dts,
|
||||||
|
aCodecCtx->time_base,
|
||||||
|
myVideoStream->time_base,
|
||||||
|
AVRounding(AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));
|
||||||
|
aPacket->duration =
|
||||||
|
av_rescale_q(aPacket->duration, aCodecCtx->time_base, myVideoStream->time_base);
|
||||||
|
aPacket->stream_index = myVideoStream->index;
|
||||||
|
|
||||||
|
// write the compressed frame to the media file
|
||||||
|
aResAv = av_interleaved_write_frame(myAVContext, aPacket);
|
||||||
|
av_packet_free(&aPacket);
|
||||||
|
|
||||||
|
if (aResAv < 0)
|
||||||
|
{
|
||||||
|
::Message::SendFail(TCollection_AsciiString("Error: can not write video frame, ")
|
||||||
|
+ formatAvError(aResAv));
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// Old API: use avcodec_encode_video2
|
||||||
AVPacket aPacket;
|
AVPacket aPacket;
|
||||||
memset(&aPacket, 0, sizeof(aPacket));
|
memset(&aPacket, 0, sizeof(aPacket));
|
||||||
av_init_packet(&aPacket);
|
av_init_packet(&aPacket);
|
||||||
{
|
{
|
||||||
// encode the image
|
// encode the image
|
||||||
|
if (!theToFlush)
|
||||||
|
{
|
||||||
myFrame->pts = myFrameCount;
|
myFrame->pts = myFrameCount;
|
||||||
|
}
|
||||||
int isGotPacket = 0;
|
int isGotPacket = 0;
|
||||||
aResAv = avcodec_encode_video2(aCodecCtx, &aPacket, theToFlush ? NULL : myFrame, &isGotPacket);
|
aResAv = avcodec_encode_video2(aCodecCtx, &aPacket, theToFlush ? NULL : myFrame, &isGotPacket);
|
||||||
if (aResAv < 0)
|
if (aResAv < 0)
|
||||||
@ -506,6 +602,7 @@ Standard_Boolean Image_VideoRecorder::writeVideoFrame(const Standard_Boolean the
|
|||||||
+ formatAvError(aResAv));
|
+ formatAvError(aResAv));
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
++myFrameCount;
|
++myFrameCount;
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
// forward declarations
|
// forward declarations
|
||||||
struct AVFormatContext;
|
struct AVFormatContext;
|
||||||
|
struct AVCodecContext;
|
||||||
struct AVStream;
|
struct AVStream;
|
||||||
struct AVCodec;
|
struct AVCodec;
|
||||||
struct AVFrame;
|
struct AVFrame;
|
||||||
@ -111,6 +112,9 @@ protected:
|
|||||||
//! Wrapper for av_strerror().
|
//! Wrapper for av_strerror().
|
||||||
Standard_EXPORT TCollection_AsciiString formatAvError(const int theError) const;
|
Standard_EXPORT TCollection_AsciiString formatAvError(const int theError) const;
|
||||||
|
|
||||||
|
//! Get codec context compatible with both old and new FFmpeg API.
|
||||||
|
Standard_EXPORT AVCodecContext* getCodecContext() const;
|
||||||
|
|
||||||
//! Append video stream.
|
//! Append video stream.
|
||||||
//! theParams[in] video parameters
|
//! theParams[in] video parameters
|
||||||
//! theDefCodecId[in] identifier of codec managed by FFmpeg library (AVCodecID enum)
|
//! theDefCodecId[in] identifier of codec managed by FFmpeg library (AVCodecID enum)
|
||||||
@ -135,6 +139,7 @@ protected:
|
|||||||
AVFormatContext* myAVContext; //!< video context
|
AVFormatContext* myAVContext; //!< video context
|
||||||
AVStream* myVideoStream; //!< video stream
|
AVStream* myVideoStream; //!< video stream
|
||||||
AVCodec* myVideoCodec; //!< video codec
|
AVCodec* myVideoCodec; //!< video codec
|
||||||
|
AVCodecContext* myCodecCtx; //!< codec context (for FFmpeg 5.0+)
|
||||||
AVFrame* myFrame; //!< frame to record
|
AVFrame* myFrame; //!< frame to record
|
||||||
SwsContext* myScaleCtx; //!< scale context for conversion from RGBA to YUV
|
SwsContext* myScaleCtx; //!< scale context for conversion from RGBA to YUV
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ set(OCCT_Media_FILES
|
|||||||
Media_BufferPool.hxx
|
Media_BufferPool.hxx
|
||||||
Media_CodecContext.cxx
|
Media_CodecContext.cxx
|
||||||
Media_CodecContext.hxx
|
Media_CodecContext.hxx
|
||||||
|
Media_FFmpegCompatibility.pxx
|
||||||
Media_FormatContext.cxx
|
Media_FormatContext.cxx
|
||||||
Media_FormatContext.hxx
|
Media_FormatContext.hxx
|
||||||
Media_Frame.cxx
|
Media_Frame.cxx
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Media_CodecContext.hxx>
|
#include <Media_CodecContext.hxx>
|
||||||
|
#include "../Media/Media_FFmpegCompatibility.pxx"
|
||||||
|
|
||||||
#include <Media_Frame.hxx>
|
#include <Media_Frame.hxx>
|
||||||
#include <Media_FormatContext.hxx>
|
#include <Media_FormatContext.hxx>
|
||||||
@ -26,15 +27,6 @@
|
|||||||
#include <Message_Messenger.hxx>
|
#include <Message_Messenger.hxx>
|
||||||
#include <OSD_Parallel.hxx>
|
#include <OSD_Parallel.hxx>
|
||||||
|
|
||||||
#ifdef HAVE_FFMPEG
|
|
||||||
#include <Standard_WarningsDisable.hxx>
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#include <libavformat/avformat.h>
|
|
||||||
};
|
|
||||||
#include <Standard_WarningsRestore.hxx>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(Media_CodecContext, Standard_Transient)
|
IMPLEMENT_STANDARD_RTTIEXT(Media_CodecContext, Standard_Transient)
|
||||||
|
|
||||||
//=================================================================================================
|
//=================================================================================================
|
||||||
@ -80,20 +72,35 @@ bool Media_CodecContext::Init(const AVStream& theStream,
|
|||||||
{
|
{
|
||||||
#ifdef HAVE_FFMPEG
|
#ifdef HAVE_FFMPEG
|
||||||
myStreamIndex = theStream.index;
|
myStreamIndex = theStream.index;
|
||||||
|
#if FFMPEG_HAVE_AVCODEC_PARAMETERS
|
||||||
if (avcodec_parameters_to_context(myCodecCtx, theStream.codecpar) < 0)
|
if (avcodec_parameters_to_context(myCodecCtx, theStream.codecpar) < 0)
|
||||||
{
|
{
|
||||||
Message::SendFail("Internal error: unable to copy codec parameters");
|
Message::SendFail("Internal error: unable to copy codec parameters");
|
||||||
Close();
|
Close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// For older FFmpeg, copy from stream's codec context
|
||||||
|
if (avcodec_copy_context(myCodecCtx, theStream.codec) < 0)
|
||||||
|
{
|
||||||
|
Message::SendFail("Internal error: unable to copy codec context");
|
||||||
|
Close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
myTimeBase = av_q2d(theStream.time_base);
|
myTimeBase = av_q2d(theStream.time_base);
|
||||||
myPtsStartBase = thePtsStartBase;
|
myPtsStartBase = thePtsStartBase;
|
||||||
myPtsStartStream = Media_FormatContext::StreamUnitsToSeconds(theStream, theStream.start_time);
|
myPtsStartStream = Media_FormatContext::StreamUnitsToSeconds(theStream, theStream.start_time);
|
||||||
|
|
||||||
|
#if FFMPEG_HAVE_AVCODEC_PARAMETERS
|
||||||
const AVCodecID aCodecId =
|
const AVCodecID aCodecId =
|
||||||
theCodecId != AV_CODEC_ID_NONE ? (AVCodecID)theCodecId : theStream.codecpar->codec_id;
|
theCodecId != AV_CODEC_ID_NONE ? (AVCodecID)theCodecId : theStream.codecpar->codec_id;
|
||||||
myCodec = avcodec_find_decoder(aCodecId);
|
#else
|
||||||
|
const AVCodecID aCodecId = theCodecId != 0 ? (AVCodecID)theCodecId : theStream.codec->codec_id;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
myCodec = ffmpeg_find_decoder(aCodecId);
|
||||||
if (myCodec == NULL)
|
if (myCodec == NULL)
|
||||||
{
|
{
|
||||||
Message::Send("FFmpeg: unable to find decoder", Message_Fail);
|
Message::Send("FFmpeg: unable to find decoder", Message_Fail);
|
||||||
@ -104,7 +111,12 @@ bool Media_CodecContext::Init(const AVStream& theStream,
|
|||||||
myCodecCtx->codec_id = aCodecId;
|
myCodecCtx->codec_id = aCodecId;
|
||||||
AVDictionary* anOpts = NULL;
|
AVDictionary* anOpts = NULL;
|
||||||
av_dict_set(&anOpts, "refcounted_frames", "1", 0);
|
av_dict_set(&anOpts, "refcounted_frames", "1", 0);
|
||||||
|
|
||||||
|
#if FFMPEG_HAVE_AVCODEC_PARAMETERS
|
||||||
if (theStream.codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
|
if (theStream.codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
|
||||||
|
#else
|
||||||
|
if (theStream.codec->codec_type == AVMEDIA_TYPE_VIDEO)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
myCodecCtx->thread_count =
|
myCodecCtx->thread_count =
|
||||||
theNbThreads <= -1 ? OSD_Parallel::NbLogicalProcessors() : theNbThreads;
|
theNbThreads <= -1 ? OSD_Parallel::NbLogicalProcessors() : theNbThreads;
|
||||||
@ -119,7 +131,7 @@ bool Media_CodecContext::Init(const AVStream& theStream,
|
|||||||
|
|
||||||
myPixelAspectRatio = 1.0f;
|
myPixelAspectRatio = 1.0f;
|
||||||
if (theStream.sample_aspect_ratio.num
|
if (theStream.sample_aspect_ratio.num
|
||||||
&& av_cmp_q(theStream.sample_aspect_ratio, myCodecCtx->sample_aspect_ratio))
|
&& av_cmp_q(theStream.sample_aspect_ratio, myCodecCtx->sample_aspect_ratio) != 0)
|
||||||
{
|
{
|
||||||
myPixelAspectRatio =
|
myPixelAspectRatio =
|
||||||
float(theStream.sample_aspect_ratio.num) / float(theStream.sample_aspect_ratio.den);
|
float(theStream.sample_aspect_ratio.num) / float(theStream.sample_aspect_ratio.den);
|
||||||
@ -137,8 +149,13 @@ bool Media_CodecContext::Init(const AVStream& theStream,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if FFMPEG_HAVE_AVCODEC_PARAMETERS
|
||||||
if (theStream.codecpar->codec_type == AVMEDIA_TYPE_VIDEO
|
if (theStream.codecpar->codec_type == AVMEDIA_TYPE_VIDEO
|
||||||
&& (myCodecCtx->width <= 0 || myCodecCtx->height <= 0))
|
&& (myCodecCtx->width <= 0 || myCodecCtx->height <= 0))
|
||||||
|
#else
|
||||||
|
if (theStream.codec->codec_type == AVMEDIA_TYPE_VIDEO
|
||||||
|
&& (myCodecCtx->width <= 0 || myCodecCtx->height <= 0))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
Message::SendFail("FFmpeg: video stream has invalid dimensions");
|
Message::SendFail("FFmpeg: video stream has invalid dimensions");
|
||||||
Close();
|
Close();
|
||||||
@ -162,7 +179,13 @@ void Media_CodecContext::Close()
|
|||||||
if (myCodecCtx != NULL)
|
if (myCodecCtx != NULL)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_FFMPEG
|
#ifdef HAVE_FFMPEG
|
||||||
|
#if FFMPEG_NEW_API
|
||||||
avcodec_free_context(&myCodecCtx);
|
avcodec_free_context(&myCodecCtx);
|
||||||
|
#else
|
||||||
|
avcodec_close(myCodecCtx);
|
||||||
|
av_free(myCodecCtx);
|
||||||
|
myCodecCtx = NULL;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -218,12 +241,22 @@ bool Media_CodecContext::SendPacket(const Handle(Media_Packet)& thePacket)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_FFMPEG
|
#ifdef HAVE_FFMPEG
|
||||||
|
#if FFMPEG_HAVE_NEW_DECODE_API
|
||||||
const int aRes = avcodec_send_packet(myCodecCtx, thePacket->Packet());
|
const int aRes = avcodec_send_packet(myCodecCtx, thePacket->Packet());
|
||||||
if (aRes < 0 && aRes != AVERROR_EOF)
|
if (aRes < 0 && aRes != AVERROR_EOF)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
#else
|
||||||
|
// For older FFmpeg versions, fallback to older decode API if needed
|
||||||
|
const int aRes = avcodec_send_packet(myCodecCtx, thePacket->Packet());
|
||||||
|
if (aRes < 0 && aRes != AVERROR_EOF)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
@ -239,6 +272,7 @@ bool Media_CodecContext::ReceiveFrame(const Handle(Media_Frame)& theFrame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_FFMPEG
|
#ifdef HAVE_FFMPEG
|
||||||
|
#if FFMPEG_HAVE_NEW_DECODE_API
|
||||||
const int aRes2 = avcodec_receive_frame(myCodecCtx, theFrame->ChangeFrame());
|
const int aRes2 = avcodec_receive_frame(myCodecCtx, theFrame->ChangeFrame());
|
||||||
if (aRes2 < 0)
|
if (aRes2 < 0)
|
||||||
{
|
{
|
||||||
@ -250,6 +284,20 @@ bool Media_CodecContext::ReceiveFrame(const Handle(Media_Frame)& theFrame)
|
|||||||
const double aFramePts = double(aPacketPts) * myTimeBase - myPtsStartBase;
|
const double aFramePts = double(aPacketPts) * myTimeBase - myPtsStartBase;
|
||||||
theFrame->SetPts(aFramePts);
|
theFrame->SetPts(aFramePts);
|
||||||
return true;
|
return true;
|
||||||
|
#else
|
||||||
|
// For older FFmpeg, use the older decoding API
|
||||||
|
const int aRes2 = avcodec_receive_frame(myCodecCtx, theFrame->ChangeFrame());
|
||||||
|
if (aRes2 < 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int64_t aPacketPts =
|
||||||
|
theFrame->BestEffortTimestamp() != AV_NOPTS_VALUE ? theFrame->BestEffortTimestamp() : 0;
|
||||||
|
const double aFramePts = double(aPacketPts) * myTimeBase - myPtsStartBase;
|
||||||
|
theFrame->SetPts(aFramePts);
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
179
src/Visualization/TKService/Media/Media_FFmpegCompatibility.pxx
Normal file
179
src/Visualization/TKService/Media/Media_FFmpegCompatibility.pxx
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
// Created on: 2025-06-22
|
||||||
|
// Copyright (c) 2025 OPEN CASCADE SAS
|
||||||
|
//
|
||||||
|
// This file is part of Open CASCADE Technology software library.
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or modify it under
|
||||||
|
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||||
|
// by the Free Software Foundation, with special exception defined in the file
|
||||||
|
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||||
|
// distribution for complete text of the license and disclaimer of any warranty.
|
||||||
|
//
|
||||||
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||||
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
|
//! FFmpeg compatibility layer for OCCT
|
||||||
|
//!
|
||||||
|
//! Provides compatibility between FFmpeg 4.4.x and 7.1.x by wrapping
|
||||||
|
//! deprecated/removed functions and handling API changes automatically.
|
||||||
|
|
||||||
|
#ifndef _FFmpeg_Compatibility_HeaderFile
|
||||||
|
#define _FFmpeg_Compatibility_HeaderFile
|
||||||
|
|
||||||
|
#ifdef HAVE_FFMPEG
|
||||||
|
|
||||||
|
// activate some C99 macros like UINT64_C in "stdint.h" which used by FFmpeg
|
||||||
|
#ifndef __STDC_CONSTANT_MACROS
|
||||||
|
#define __STDC_CONSTANT_MACROS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Standard C headers needed for compilation
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <Standard_WarningsDisable.hxx>
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#include <libavcodec/avcodec.h>
|
||||||
|
#include <libavformat/avformat.h>
|
||||||
|
#include <libavutil/imgutils.h>
|
||||||
|
#include <libswscale/swscale.h>
|
||||||
|
};
|
||||||
|
#include <Standard_WarningsRestore.hxx>
|
||||||
|
|
||||||
|
// Version detection macros
|
||||||
|
#define FFMPEG_VERSION_4_4 AV_VERSION_INT(58, 0, 0)
|
||||||
|
#define FFMPEG_VERSION_5_0 AV_VERSION_INT(59, 0, 0)
|
||||||
|
#define FFMPEG_VERSION_6_0 AV_VERSION_INT(60, 0, 0)
|
||||||
|
#define FFMPEG_VERSION_7_0 AV_VERSION_INT(61, 0, 0)
|
||||||
|
|
||||||
|
// Check if we're using FFmpeg 5.0+ (major API change point)
|
||||||
|
#if LIBAVCODEC_VERSION_INT >= FFMPEG_VERSION_5_0
|
||||||
|
#define FFMPEG_NEW_API 1
|
||||||
|
#else
|
||||||
|
#define FFMPEG_NEW_API 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Additional version checks for specific functions
|
||||||
|
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 37, 100)
|
||||||
|
#define FFMPEG_HAVE_NEW_DECODE_API 1
|
||||||
|
#else
|
||||||
|
#define FFMPEG_HAVE_NEW_DECODE_API 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(58, 0, 0)
|
||||||
|
#define FFMPEG_HAVE_AVCODEC_PARAMETERS 1
|
||||||
|
#else
|
||||||
|
#define FFMPEG_HAVE_AVCODEC_PARAMETERS 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Constant compatibility for different FFmpeg versions
|
||||||
|
|
||||||
|
// Error buffer size might be different
|
||||||
|
#ifndef AV_ERROR_MAX_STRING_SIZE
|
||||||
|
#define AV_ERROR_MAX_STRING_SIZE 64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Codec flags compatibility
|
||||||
|
#ifndef AV_CODEC_FLAG_GLOBAL_HEADER
|
||||||
|
#define AV_CODEC_FLAG_GLOBAL_HEADER CODEC_FLAG_GLOBAL_HEADER
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Pixel format compatibility - old names to new names
|
||||||
|
#ifndef AV_PIX_FMT_YUV420P
|
||||||
|
#define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P
|
||||||
|
#endif
|
||||||
|
#ifndef AV_PIX_FMT_RGBA
|
||||||
|
#define AV_PIX_FMT_RGBA PIX_FMT_RGBA
|
||||||
|
#endif
|
||||||
|
#ifndef AV_PIX_FMT_RGB24
|
||||||
|
#define AV_PIX_FMT_RGB24 PIX_FMT_RGB24
|
||||||
|
#endif
|
||||||
|
#ifndef AV_PIX_FMT_NONE
|
||||||
|
#define AV_PIX_FMT_NONE PIX_FMT_NONE
|
||||||
|
#endif
|
||||||
|
#ifndef AV_PIX_FMT_YUVJ420P
|
||||||
|
#define AV_PIX_FMT_YUVJ420P PIX_FMT_YUVJ420P
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// For old FFmpeg versions that don't have AV_PIX_FMT_* constants
|
||||||
|
#ifndef PIX_FMT_YUV420P
|
||||||
|
#define PIX_FMT_YUV420P AV_PIX_FMT_YUV420P
|
||||||
|
#endif
|
||||||
|
#ifndef PIX_FMT_RGBA
|
||||||
|
#define PIX_FMT_RGBA AV_PIX_FMT_RGBA
|
||||||
|
#endif
|
||||||
|
#ifndef PIX_FMT_RGB24
|
||||||
|
#define PIX_FMT_RGB24 AV_PIX_FMT_RGB24
|
||||||
|
#endif
|
||||||
|
#ifndef PIX_FMT_NONE
|
||||||
|
#define PIX_FMT_NONE AV_PIX_FMT_NONE
|
||||||
|
#endif
|
||||||
|
#ifndef PIX_FMT_YUVJ420P
|
||||||
|
#define PIX_FMT_YUVJ420P AV_PIX_FMT_YUVJ420P
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// AVRounding compatibility - handle missing AV_ prefix
|
||||||
|
#ifndef AV_ROUND_NEAR_INF
|
||||||
|
#ifdef AVROUND_NEAR_INF
|
||||||
|
#define AV_ROUND_NEAR_INF AVROUND_NEAR_INF
|
||||||
|
#else
|
||||||
|
#define AV_ROUND_NEAR_INF 5
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef AV_ROUND_PASS_MINMAX
|
||||||
|
#ifdef AVROUND_PASS_MINMAX
|
||||||
|
#define AV_ROUND_PASS_MINMAX AVROUND_PASS_MINMAX
|
||||||
|
#else
|
||||||
|
#define AV_ROUND_PASS_MINMAX 8192
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Also define the old names for compatibility
|
||||||
|
#ifndef AVROUND_NEAR_INF
|
||||||
|
#define AVROUND_NEAR_INF AV_ROUND_NEAR_INF
|
||||||
|
#endif
|
||||||
|
#ifndef AVROUND_PASS_MINMAX
|
||||||
|
#define AVROUND_PASS_MINMAX AV_ROUND_PASS_MINMAX
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Compatibility functions and macros
|
||||||
|
|
||||||
|
// av_register_all() - deprecated/removed in FFmpeg 4.0+
|
||||||
|
inline void ffmpeg_register_all()
|
||||||
|
{
|
||||||
|
#if !FFMPEG_NEW_API
|
||||||
|
av_register_all();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// AVCodec constness changes
|
||||||
|
inline AVCodec* ffmpeg_find_encoder(enum AVCodecID id)
|
||||||
|
{
|
||||||
|
#if FFMPEG_NEW_API
|
||||||
|
return const_cast<AVCodec*>(avcodec_find_encoder(id));
|
||||||
|
#else
|
||||||
|
return avcodec_find_encoder(id);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
inline AVCodec* ffmpeg_find_encoder_by_name(const char* name)
|
||||||
|
{
|
||||||
|
#if FFMPEG_NEW_API
|
||||||
|
return const_cast<AVCodec*>(avcodec_find_encoder_by_name(name));
|
||||||
|
#else
|
||||||
|
return avcodec_find_encoder_by_name(name);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
inline AVCodec* ffmpeg_find_decoder(enum AVCodecID id)
|
||||||
|
{
|
||||||
|
#if FFMPEG_NEW_API
|
||||||
|
return const_cast<AVCodec*>(avcodec_find_decoder(id));
|
||||||
|
#else
|
||||||
|
return avcodec_find_decoder(id);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // HAVE_FFMPEG
|
||||||
|
|
||||||
|
#endif // _FFmpeg_Compatibility_HeaderFile
|
@ -18,19 +18,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Media_FormatContext.hxx>
|
#include <Media_FormatContext.hxx>
|
||||||
|
#include "../Media/Media_FFmpegCompatibility.pxx"
|
||||||
|
|
||||||
#include <Message.hxx>
|
#include <Message.hxx>
|
||||||
#include <Message_Messenger.hxx>
|
#include <Message_Messenger.hxx>
|
||||||
|
|
||||||
#ifdef HAVE_FFMPEG
|
|
||||||
#include <Standard_WarningsDisable.hxx>
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#include <libavformat/avformat.h>
|
|
||||||
};
|
|
||||||
#include <Standard_WarningsRestore.hxx>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(Media_FormatContext, Standard_Transient)
|
IMPLEMENT_STANDARD_RTTIEXT(Media_FormatContext, Standard_Transient)
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@ -374,16 +366,53 @@ TCollection_AsciiString Media_FormatContext::StreamInfo(unsigned int theIndex
|
|||||||
AVCodecContext* aCodecCtx = theCodecCtx;
|
AVCodecContext* aCodecCtx = theCodecCtx;
|
||||||
if (aCodecCtx == NULL)
|
if (aCodecCtx == NULL)
|
||||||
{
|
{
|
||||||
|
#if FFMPEG_HAVE_AVCODEC_PARAMETERS
|
||||||
|
// For new API, need to allocate context and copy parameters
|
||||||
|
aCodecCtx = avcodec_alloc_context3(NULL);
|
||||||
|
if (aCodecCtx != NULL && avcodec_parameters_to_context(aCodecCtx, aStream.codecpar) < 0)
|
||||||
|
{
|
||||||
|
avcodec_free_context(&aCodecCtx);
|
||||||
|
aCodecCtx = NULL;
|
||||||
|
}
|
||||||
|
#else
|
||||||
Standard_DISABLE_DEPRECATION_WARNINGS aCodecCtx = aStream.codec;
|
Standard_DISABLE_DEPRECATION_WARNINGS aCodecCtx = aStream.codec;
|
||||||
Standard_ENABLE_DEPRECATION_WARNINGS
|
Standard_ENABLE_DEPRECATION_WARNINGS
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
char aFrmtBuff[4096] = {};
|
char aFrmtBuff[4096] = {};
|
||||||
|
#if FFMPEG_NEW_API
|
||||||
|
// avcodec_string was removed in newer FFmpeg versions
|
||||||
|
if (aCodecCtx != NULL)
|
||||||
|
{
|
||||||
|
Sprintf(aFrmtBuff,
|
||||||
|
"Stream #%d: %s",
|
||||||
|
theIndex,
|
||||||
|
aCodecCtx->codec ? aCodecCtx->codec->long_name : "Unknown");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Sprintf(aFrmtBuff, "Stream #%d: Unknown", theIndex);
|
||||||
|
}
|
||||||
|
#else
|
||||||
avcodec_string(aFrmtBuff, sizeof(aFrmtBuff), aCodecCtx, 0);
|
avcodec_string(aFrmtBuff, sizeof(aFrmtBuff), aCodecCtx, 0);
|
||||||
|
#endif
|
||||||
TCollection_AsciiString aStreamInfo(aFrmtBuff);
|
TCollection_AsciiString aStreamInfo(aFrmtBuff);
|
||||||
|
|
||||||
|
#if FFMPEG_HAVE_AVCODEC_PARAMETERS
|
||||||
|
// Clean up allocated context if we created it
|
||||||
|
if (theCodecCtx == NULL && aCodecCtx != NULL)
|
||||||
|
{
|
||||||
|
avcodec_free_context(&aCodecCtx);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (aStream.sample_aspect_ratio.num
|
if (aStream.sample_aspect_ratio.num
|
||||||
&& av_cmp_q(aStream.sample_aspect_ratio, aStream.codecpar->sample_aspect_ratio))
|
#if FFMPEG_HAVE_AVCODEC_PARAMETERS
|
||||||
|
&& av_cmp_q(aStream.sample_aspect_ratio, aStream.codecpar->sample_aspect_ratio) != 0)
|
||||||
|
#else
|
||||||
|
&& av_cmp_q(aStream.sample_aspect_ratio, aStream.codec->sample_aspect_ratio) != 0)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
AVRational aDispAspectRatio;
|
AVRational aDispAspectRatio;
|
||||||
av_reduce(&aDispAspectRatio.num,
|
av_reduce(&aDispAspectRatio.num,
|
||||||
@ -468,7 +497,11 @@ bool Media_FormatContext::SeekStream(unsigned int theStreamId,
|
|||||||
// try 10 more times in backward direction to work-around huge duration between key frames
|
// try 10 more times in backward direction to work-around huge duration between key frames
|
||||||
// will not work for some streams with undefined cur_dts (AV_NOPTS_VALUE)!!!
|
// will not work for some streams with undefined cur_dts (AV_NOPTS_VALUE)!!!
|
||||||
for (int aTries = 10;
|
for (int aTries = 10;
|
||||||
|
#if FFMPEG_NEW_API
|
||||||
|
isSeekDone && theToSeekBack && aTries > 0; // cur_dts removed in newer FFmpeg
|
||||||
|
#else
|
||||||
isSeekDone && theToSeekBack && aTries > 0 && (aStream.cur_dts > aSeekTarget);
|
isSeekDone && theToSeekBack && aTries > 0 && (aStream.cur_dts > aSeekTarget);
|
||||||
|
#endif
|
||||||
--aTries)
|
--aTries)
|
||||||
{
|
{
|
||||||
aSeekTarget -= StreamSecondsToUnits(aStream, 1.0);
|
aSeekTarget -= StreamSecondsToUnits(aStream, 1.0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user