Explorar el Código

add wasm support for x264 and x265 (#2009)

* feat: support wasm for x264

* feat: add wasm support for x264

* feat: add more options for x265

* fix: disable x264 for Windows

* feat(x265): add more versions

* feat(x265): support wasm
冰雪殇璃陌梦 hace 2 años
padre
commit
864a57fff6
Se han modificado 2 ficheros con 63 adiciones y 9 borrados
  1. 47 5
      packages/x/x264/xmake.lua
  2. 16 4
      packages/x/x265/xmake.lua

+ 47 - 5
packages/x/x264/xmake.lua

@@ -3,19 +3,61 @@ package("x264")
     set_homepage("https://www.videolan.org/developers/x264.html")
     set_description("A free software library and application for encoding video streams into the H.264/MPEG-4 AVC compression format.")
 
-    add_urls("http://git.videolan.org/git/x264.git")
+    add_urls("https://code.videolan.org/videolan/x264.git")
+    add_urls("https://github.com/mirror/x264.git")
+    add_versions("v2023.04.04", "eaa68fad9e5d201d42fde51665f2d137ae96baf0")
     add_versions("v2021.09.29", "66a5bc1bd1563d8227d5d18440b525a09bcf17ca")
     add_versions("v2018.09.25", "545de2ffec6ae9a80738de1b2c8cf820249a2530")
 
     add_deps("nasm")
+
+    add_configs("cli",            {description = "enable cli", default = false, type = "boolean"})
+    add_configs("bashcompletion", {description = "enable installation of bash-completion script", default = false, type = "boolean"})
+    add_configs("opencl",         {description = "enable OpenCL features", default = true, type = "boolean"})
+    add_configs("gpl",            {description = "enable GPL-only features", default = false, type = "boolean"})
+    add_configs("thread",         {description = "enable multithreaded encoding", default = true, type = "boolean"})
+    add_configs("interlaced",     {description = "enable interlaced encoding support", default = true, type = "boolean"})
+    add_configs("bit-depth",      {description = "set output bit depth", default = "all", value = {8, 10, "all"}})
+    add_configs("chroma-format",  {description = "output chroma format", default = "all", value = {400, 420, 422, 444, "all"}})
+
+    -- Advanced options
+    add_configs("asm", {description = "enable platform-specific assembly optimizations", default = true, type = "boolean"})
+    add_configs("lto", {description = "enable link-time optimization", default = false, type = "boolean"})
+    add_configs("pic", {description = "build position-independent code", default = false, type = "boolean"})
+
+    -- External library support
+    add_configs("avs",     {description = "enable avisynth support", default = false, type = "boolean"})
+    add_configs("swscale", {description = "enable swscale support", default = false, type = "boolean"})
+    add_configs("lavf",    {description = "enable libavformat support", default = false, type = "boolean"})
+    add_configs("ffms",    {description = "enable ffmpegsource support", default = false, type = "boolean"})
+    add_configs("gpac",    {description = "enable gpac support", default = false, type = "boolean"})
+    add_configs("lsmash",  {description = "enable lsmash support", default = false, type = "boolean"})
+
     add_configs("toolchains", {readonly = true, description = "Set package toolchains only for cross-compilation."})
 
     add_syslinks("pthread", "dl")
-    on_install("linux", "macosx", function (package)
-        local configs = {"--disable-avs", "--disable-lsmash", "--disable-lavf", "--disable-bashcompletion"}
+
+    if is_plat("wasm") then
+        add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
+    end
+
+    on_install("linux", "macosx", "wasm", function (package)
+        local configs = {}
         table.insert(configs, "--enable-" .. (package:config("shared") and "shared" or "static"))
-        if package:config("pic") ~= false then
-            table.insert(configs, "--enable-pic")
+        if package:is_plat("wasm") then
+            table.insert(configs, "--host=i686-gnu")
+            package:config_set("asm", false)
+            package:config_set("cli", false)
+        end
+
+        for name, value in pairs(package:configs()) do
+            if not package:extraconf("configs", name, "builtin") then
+                if type(value) == "boolean" then
+                    table.insert(configs, "--" .. (value and "enable" or "disable") .. "-" .. name)
+                else
+                    table.insert(configs, "--" .. name .. "=" .. value)
+                end
+            end
         end
         import("package.tools.autoconf").install(package, configs)
     end)

+ 16 - 4
packages/x/x265/xmake.lua

@@ -4,14 +4,23 @@ package("x265")
     set_license("GPL-2.0")
 
     add_urls("https://github.com/videolan/x265/archive/$(version).tar.gz",
-             "https://github.com/videolan/x265.git")
+             "https://github.com/videolan/x265.git",
+             "https://bitbucket.org/multicoreware/x265_git")
 
+    add_versions("3.2", "4dd707648ea90b96bf1f8ea6a36ed21c11fe3a9048923909c5b629755ca8d8f3")
+    add_versions("3.2.1", "b5ee7ea796a664d6e2763f9c0ae281fac5d25892fc2cb134698547103466a06a")
+    add_versions("3.3", "ca25a38772fc6b49e5f1aa88733bc1dc92da7dc18f02a85cc3e99d76ba85b0a9")
     add_versions("3.4", "544d147bf146f8994a7bf8521ed878c93067ea1c7c6e93ab602389be3117eaaf")
-
+    
     add_configs("hdr10_plus", {description = "Enable dynamic HDR10 compilation", default = false, type = "boolean"})
     add_configs("svt_hevc", {description = "Enable SVT HEVC Encoder", default = false, type = "boolean"})
 
-    add_deps("cmake", "nasm >=2.13")
+    add_deps("cmake")
+    if is_plat("wasm") then
+        add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
+    else
+        add_deps("nasm >=2.13")
+    end
 
     if is_plat("macosx") then
         add_syslinks("c++")
@@ -19,11 +28,14 @@ package("x265")
         add_syslinks("pthread", "dl")
     end
 
-    on_install("windows|x86", "windows|x64", "mingw", "linux", "bsd", "macosx", "cross", function (package)
+    on_install("windows|x86", "windows|x64", "mingw", "linux", "bsd", "macosx", "wasm", "cross", function (package)
         os.cd("source")
         if package:is_plat("android") then
             io.replace("CMakeLists.txt", "list(APPEND PLATFORM_LIBS pthread)", "", { plain = true })
         end
+        if package:is_plat("wasm") then
+            io.replace("CMakeLists.txt", "X86 AND NOT X64", "FALSE")
+        end
         local configs = {}
         table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
         table.insert(configs, "-DENABLE_HDR10_PLUS=" .. (package:config("hdr10_plus") and "ON" or "OFF"))