Skip to content

Commit

Permalink
Merge pull request #40 from TechSmith/feature/ffmpeg-for-cloud--libjp…
Browse files Browse the repository at this point in the history
…eg-turbo

Add ffmpeg build for cloud team, with mjpeg & png decoding support
  • Loading branch information
mike-malburg authored Oct 2, 2024
2 parents b19d3e1 + db4cfe5 commit 8e20adb
Show file tree
Hide file tree
Showing 27 changed files with 2,766 additions and 44 deletions.
1 change: 1 addition & 0 deletions .pipelines/build-package-preconfigured.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ parameters:
type: string
values:
- ffmpeg
- ffmpeg-cloud
- hunspell
- hunspell-debug
- libpng
Expand Down
2 changes: 1 addition & 1 deletion build-package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Write-Banner -Level 1 -Title "Installing preconfigured package: `"$PackageName`"
$pkg = Get-PackageInfo -PackageName $PackageName

Write-Message "$(NL)Running invoke-build.ps1...$(NL)"
./invoke-build.ps1 -PackageName $PackageName -PackageAndFeatures $pkg.package -LinkType $pkg.linkType -BuildType $pkg.buildType -StagedArtifactsPath $StagedArtifactsPath -VcpkgHash $pkg.vcpkgHash -ShowDebug:$ShowDebug
./invoke-build.ps1 -PackageName $PackageName -PackageAndFeatures $pkg.package -LinkType $pkg.linkType -BuildType $pkg.buildType -StagedArtifactsPath $StagedArtifactsPath -VcpkgHash $pkg.vcpkgHash -Publish $pkg.publish -ShowDebug:$ShowDebug
27 changes: 27 additions & 0 deletions custom-ports/ffmpeg-cloud/0001-create-lib-libraries.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff --git a/configure b/configure
index 1f0b9497cb..3243e23021 100644
--- a/configure
+++ b/configure
@@ -5697,17 +5697,19 @@ 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 small && test_cmd $windres --version && enable gnu_windres
enabled x86_32 && check_ldflags -LARGEADDRESSAWARE
add_cppflags -DWIN32_LEAN_AND_MEAN
shlibdir_default="$bindir_default"
+ LIBPREF=""
+ LIBSUF=".lib"
SLIBPREF=""
SLIBSUF=".dll"
SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
11 changes: 11 additions & 0 deletions custom-ports/ffmpeg-cloud/0002-fix-msvc-link.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -6162,6 +6162,7 @@ EOF
test -n "$extern_prefix" && append X86ASMFLAGS "-DPREFIX"
case "$objformat" in
elf*) enabled debug && append X86ASMFLAGS $x86asm_debug ;;
+ win*) enabled debug && append X86ASMFLAGS "-g" ;;
esac

enabled avx512 && check_x86asm avx512_external "vmovdqa32 [eax]{k1}{z}, zmm0"
13 changes: 13 additions & 0 deletions custom-ports/ffmpeg-cloud/0003-fix-windowsinclude.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -51,6 +51,8 @@
#include "fopen_utf8.h"
#include "opt_common.h"
#ifdef _WIN32
+#define _WIN32_WINNT 0x0502
+#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "compat/w32dlfcn.h"
#endif

54 changes: 54 additions & 0 deletions custom-ports/ffmpeg-cloud/0004-dependencies.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
diff --git a/configure b/configure
index 3243e23021..6d3f31fc95 100755
@@ -6630,7 +6630,7 @@ 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
+enabled bzlib && require_pkg_config bzlib bzip2 bzlib.h BZ2_bzlibVersion
enabled lzma && check_lib lzma lzma.h lzma_version_number -llzma

enabled zlib && test_exec $zlib_extralibs <<EOF && enable zlib_gzip
@@ -6757,7 +6757,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 -lnppif ||
@@ -6793,8 +6794,8 @@ enabled libshaderc && require_pkg_config spirv_compiler "shaderc >= 2019.
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++
-enabled libsoxr && require libsoxr soxr.h soxr_create -lsoxr
+enabled libsnappy && require_pkg_config libsnappy snappy snappy-c.h snappy_compress
+enabled libsoxr && require libsoxr soxr.h soxr_create -lsoxr $libm_extralibs
enabled libssh && require_pkg_config libssh "libssh >= 0.6.0" 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
@@ -6884,6 +6885,8 @@ enabled openal && { check_pkg_config openal "openal >= 1.1" "AL/al.h"
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)" ||
@@ -7208,10 +7211,10 @@ enabled amf &&
"(AMF_VERSION_MAJOR << 48 | AMF_VERSION_MINOR << 32 | AMF_VERSION_RELEASE << 16 | AMF_VERSION_BUILD_NUM) >= 0x00010004001d0000"

# Funny iconv installations are not unusual, so check it after all flags have been set
-if enabled libc_iconv; then
+if enabled libc_iconv && disabled 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 -lcharset
fi

enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
55 changes: 55 additions & 0 deletions custom-ports/ffmpeg-cloud/0005-fix-nasm.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
--- a/libavcodec/x86/Makefile
+++ b/libavcodec/x86/Makefile
@@ -158,6 +158,8 @@ X86ASM-OBJS-$(CONFIG_ALAC_DECODER) += x86/alacdsp.o
X86ASM-OBJS-$(CONFIG_APNG_DECODER) += x86/pngdsp.o
X86ASM-OBJS-$(CONFIG_CAVS_DECODER) += x86/cavsidct.o
+ifdef ARCH_X86_64
X86ASM-OBJS-$(CONFIG_CFHD_ENCODER) += x86/cfhdencdsp.o
+endif
X86ASM-OBJS-$(CONFIG_CFHD_DECODER) += x86/cfhddsp.o
X86ASM-OBJS-$(CONFIG_DCA_DECODER) += x86/dcadsp.o x86/synth_filter.o
X86ASM-OBJS-$(CONFIG_DIRAC_DECODER) += x86/diracdsp.o \
@@ -175,15 +177,21 @@ x86/hevc_sao_10bit.o
X86ASM-OBJS-$(CONFIG_JPEG2000_DECODER) += x86/jpeg2000dsp.o
X86ASM-OBJS-$(CONFIG_LSCR_DECODER) += x86/pngdsp.o
+ifdef ARCH_X86_64
X86ASM-OBJS-$(CONFIG_MLP_DECODER) += x86/mlpdsp.o
+endif
X86ASM-OBJS-$(CONFIG_MPEG4_DECODER) += x86/xvididct.o
X86ASM-OBJS-$(CONFIG_PNG_DECODER) += x86/pngdsp.o
+ifdef ARCH_X86_64
X86ASM-OBJS-$(CONFIG_PRORES_DECODER) += x86/proresdsp.o
X86ASM-OBJS-$(CONFIG_PRORES_LGPL_DECODER) += x86/proresdsp.o
+endif
X86ASM-OBJS-$(CONFIG_RV40_DECODER) += x86/rv40dsp.o
X86ASM-OBJS-$(CONFIG_SBC_ENCODER) += x86/sbcdsp.o
X86ASM-OBJS-$(CONFIG_SVQ1_ENCODER) += x86/svq1enc.o
X86ASM-OBJS-$(CONFIG_TAK_DECODER) += x86/takdsp.o
+ifdef ARCH_X86_64
X86ASM-OBJS-$(CONFIG_TRUEHD_DECODER) += x86/mlpdsp.o
+endif
X86ASM-OBJS-$(CONFIG_TTA_DECODER) += x86/ttadsp.o
X86ASM-OBJS-$(CONFIG_TTA_ENCODER) += x86/ttaencdsp.o
X86ASM-OBJS-$(CONFIG_UTVIDEO_DECODER) += x86/utvideodsp.o
diff --git a/libavfilter/x86/Makefile b/libavfilter/x86/Makefile
--- a/libavfilter/x86/Makefile
+++ b/libavfilter/x86/Makefile
@@ -44,6 +44,8 @@
X86ASM-OBJS-$(CONFIG_AFIR_FILTER) += x86/af_afir.o
X86ASM-OBJS-$(CONFIG_ANLMDN_FILTER) += x86/af_anlmdn.o
+ifdef ARCH_X86_64
X86ASM-OBJS-$(CONFIG_ATADENOISE_FILTER) += x86/vf_atadenoise.o
+endif
X86ASM-OBJS-$(CONFIG_BLEND_FILTER) += x86/vf_blend.o
X86ASM-OBJS-$(CONFIG_BWDIF_FILTER) += x86/vf_bwdif.o
X86ASM-OBJS-$(CONFIG_COLORSPACE_FILTER) += x86/colorspacedsp.o
@@ -62,6 +62,8 @@ X86ASM-OBJS-$(CONFIG_LUT3D_FILTER) += x86/vf_lut3d.o
X86ASM-OBJS-$(CONFIG_MASKEDCLAMP_FILTER) += x86/vf_maskedclamp.o
X86ASM-OBJS-$(CONFIG_MASKEDMERGE_FILTER) += x86/vf_maskedmerge.o
+ifdef ARCH_X86_64
X86ASM-OBJS-$(CONFIG_NLMEANS_FILTER) += x86/vf_nlmeans.o
+endif
X86ASM-OBJS-$(CONFIG_OVERLAY_FILTER) += x86/vf_overlay.o
X86ASM-OBJS-$(CONFIG_PP7_FILTER) += x86/vf_pp7.o
X86ASM-OBJS-$(CONFIG_PSNR_FILTER) += x86/vf_psnr.o
12 changes: 12 additions & 0 deletions custom-ports/ffmpeg-cloud/0007-fix-lib-naming.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/configure b/configure
index d6c4388..75b96c3 100644
--- a/configure
+++ b/configure
@@ -4378,6 +4378,7 @@ msvc_common_flags(){
-march=*) ;;
-lz) echo zlib.lib ;;
-lx264) echo libx264.lib ;;
+ -lmp3lame) echo libmp3lame.lib ;;
-lstdc++) ;;
-l*) echo ${flag#-l}.lib ;;
-LARGEADDRESSAWARE) echo $flag ;;
14 changes: 14 additions & 0 deletions custom-ports/ffmpeg-cloud/0012-Fix-ssl-110-detection.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/configure b/configure
index 2be953f7e7..e075949ffc 100755
--- a/configure
+++ b/configure
@@ -6497,6 +6497,7 @@ enabled openssl && { { check_pkg_config openssl "openssl >= 3.0.0
{ enabled gplv3 || ! enabled gpl || enabled nonfree || die "ERROR: OpenSSL >=3.0.0 requires --enable-version3"; }; } ||
{ enabled gpl && ! enabled nonfree && die "ERROR: OpenSSL <3.0.0 is incompatible with the gpl"; } ||
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 ||

15 changes: 15 additions & 0 deletions custom-ports/ffmpeg-cloud/0013-define-WINVER.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --color -Naur src_old/libavcodec/mf_utils.c src/libavcodec/mf_utils.c
--- src_old/libavcodec/mf_utils.c 2020-07-11 05:26:17.000000000 +0700
+++ src/libavcodec/mf_utils.c 2020-11-13 12:55:57.226976400 +0700
@@ -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"

28 changes: 28 additions & 0 deletions custom-ports/ffmpeg-cloud/0020-fix-aarch64-libswscale.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/libswscale/aarch64/yuv2rgb_neon.S b/libswscale/aarch64/yuv2rgb_neon.S
index 89d69e7f6c..4bc1607a7a 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

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index cd7b0d941c..b4a6dce885 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1010,7 +1010,11 @@ struct AVCodecParserContext *av_stream_get_parser(const AVStream *s);
attribute_deprecated
int64_t av_stream_get_end_pts(const AVStream *st);
#endif

+// Chromium: We use the internal field first_dts vvv
+int64_t av_stream_get_first_dts(const AVStream *st);
+// Chromium: We use the internal field first_dts ^^^
+
#define AV_PROGRAM_RUNNING 1

/**
diff --git a/libavformat/mux_utils.c b/libavformat/mux_utils.c
index de7580c32d..0ef0fe530e 100644
--- a/libavformat/mux_utils.c
+++ b/libavformat/mux_utils.c
@@ -33,7 +33,14 @@ int64_t av_stream_get_end_pts(const AVStream *st)
return AV_NOPTS_VALUE;
}
#endif

+// Chromium: We use the internal field first_dts vvv
+int64_t av_stream_get_first_dts(const AVStream *st)
+{
+ return cffstream(st)->first_dts;
+}
+// Chromium: We use the internal field first_dts ^^^
+
int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id,
int std_compliance)
{
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/libavdevice/opengl_enc.c b/libavdevice/opengl_enc.c
index b2ac6eb..6351614 100644
--- a/libavdevice/opengl_enc.c
+++ b/libavdevice/opengl_enc.c
@@ -116,7 +116,7 @@ typedef void (APIENTRY *FF_PFNGLATTACHSHADERPROC) (GLuint program, GLuint shad
typedef GLuint (APIENTRY *FF_PFNGLCREATESHADERPROC) (GLenum type);
typedef void (APIENTRY *FF_PFNGLDELETESHADERPROC) (GLuint shader);
typedef void (APIENTRY *FF_PFNGLCOMPILESHADERPROC) (GLuint shader);
-typedef void (APIENTRY *FF_PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const char* *string, const GLint *length);
+typedef void (APIENTRY *FF_PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const char* const *string, const GLint *length);
typedef void (APIENTRY *FF_PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);
typedef void (APIENTRY *FF_PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, char *infoLog);

9 changes: 9 additions & 0 deletions custom-ports/ffmpeg-cloud/0042-fix-arm64-linux.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
diff --git a/ffbuild/libversion.sh b/ffbuild/libversion.sh
index a94ab58..ecaa90c 100644
--- a/ffbuild/libversion.sh
+++ b/ffbuild/libversion.sh
@@ -1,3 +1,4 @@
+#!/bin/sh
toupper(){
echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
}
Loading

0 comments on commit 8e20adb

Please sign in to comment.