-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Desktop: Add dav1d library for AV1 software decoding #99
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
[submodule "gdx-video-desktop/FFmpeg"] | ||
path = gdx-video-desktop/FFmpeg | ||
path = gdx-video-desktop/FFmpeg/src/FFmpeg | ||
url = https://github.com/FFmpeg/FFmpeg.git | ||
branch = release/4.3 | ||
[submodule "gdx-video-desktop/dependencies/dav1d"] | ||
path = gdx-video-desktop/FFmpeg/src/dav1d | ||
url = https://code.videolan.org/videolan/dav1d.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule FFmpeg
deleted from
25cd95
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
tasks.register('cleanFFmpeg') | ||
tasks.register('cleanAV1') | ||
clean.configure { | ||
dependsOn 'cleanFFmpeg' | ||
dependsOn 'cleanAV1' | ||
} | ||
|
||
String checkCrossPrefix(String crossToolchain) { | ||
def tc = crossToolchain | ||
if (tc == null || System.getProperty("os.name").startsWith("Win")) return "" | ||
def result = project.exec { | ||
ignoreExitValue = true | ||
commandLine "bash", "-l", "-c", | ||
"(command -v $tc-g++ && command -v $tc-ar && command -v $tc-ld)>/dev/null" | ||
} | ||
if (result.getExitValue() == 0) { | ||
return "$tc-" | ||
} | ||
return "" | ||
} | ||
|
||
String checkCrossFile(String buildName, String crossToolchain) { | ||
String prefix = checkCrossPrefix(crossToolchain) | ||
if (prefix.isEmpty()) { | ||
return "" | ||
} | ||
def options = [ | ||
"Windows32" : "i686-w64-mingw32", | ||
"Windows64" : "x86_64-w64-mingw32", | ||
"LinuxARM64": "aarch64-linux" | ||
] | ||
def name = options[buildName] | ||
if(name == null) return "" | ||
return "src/dav1d/package/crossfiles/${name}.meson" | ||
} | ||
|
||
|
||
void registerBuild(String buildName, String crossToolchain, String... extraArgs) { | ||
String outDir = file("build/${buildName.toLowerCase()}").absolutePath | ||
String av1Dir = "$outDir/src/dav1d" | ||
String ffDir = "$outDir/src/FFmpeg" | ||
|
||
def crossPrefix = checkCrossPrefix(crossToolchain) | ||
def crossFile = checkCrossFile(buildName, crossToolchain) | ||
|
||
tasks.register("cleanAV1$buildName", Delete) { | ||
delete av1Dir | ||
delete "$outDir/lib/libdav1d.a" | ||
} | ||
cleanAV1.configure { | ||
dependsOn "cleanAV1$buildName" | ||
} | ||
tasks.register("buildAV1$buildName") { | ||
doFirst { | ||
mkdir av1Dir | ||
String[] crossArgs = [] | ||
String crossPath = "" | ||
if (!crossFile.isEmpty()) { | ||
crossPath = file(crossFile).absolutePath | ||
} else if(buildName == "Macos64") { | ||
crossPath = file("src/x86_64-macos.meson").absolutePath | ||
} else if(buildName == "MacosARM64") { | ||
crossPath = file("src/arm64-macos.meson").absolutePath | ||
} else if(buildName == "Linux64" && System.getProperty("os.name") != "Linux") { | ||
crossPath = file("src/x86_64-linux.meson").absolutePath | ||
} else if(buildName == "LinuxARM32") { | ||
crossPath = file("src/arm32-linux.meson").absolutePath | ||
} | ||
if (!crossPath.isEmpty()) { | ||
crossArgs = ["--cross-file=$crossPath"] | ||
} | ||
project.exec { | ||
workingDir av1Dir | ||
executable 'meson' | ||
args 'setup', '-Denable_tools=false', '-Denable_tests=false' | ||
args crossArgs | ||
args '../../../../src/dav1d', '--default-library=static' | ||
args '--prefix', "$outDir" | ||
args "--libdir=$outDir/lib" | ||
} | ||
project.exec { | ||
workingDir av1Dir | ||
commandLine 'ninja' | ||
} | ||
project.exec { | ||
workingDir av1Dir | ||
commandLine 'ninja', 'install' | ||
} | ||
} | ||
outputs.upToDateWhen { file("$outDir/lib/libdav1d.a").exists() } | ||
} | ||
|
||
tasks.register("cleanFFmpeg$buildName", Delete) { | ||
delete ffDir | ||
delete "$outDir/lib/libavformat.a" | ||
} | ||
cleanFFmpeg.configure { | ||
dependsOn "cleanFFmpeg$buildName" | ||
} | ||
tasks.register("buildFFmpeg$buildName") { | ||
dependsOn "buildAV1$buildName" | ||
doFirst { | ||
mkdir ffDir | ||
String[] crossArgs = [] | ||
if (!crossPrefix.isEmpty()) { | ||
crossArgs = ["--enable-cross-compile", "--cross-prefix=$crossPrefix"] | ||
} | ||
project.exec { | ||
workingDir ffDir | ||
environment["PKG_CONFIG_PATH"] = "$outDir/lib/pkgconfig" | ||
executable '../../../../src/FFmpeg/configure' | ||
args '--pkg-config=pkg-config', '--pkg-config-flags=--static' | ||
args '--disable-autodetect' | ||
args '--enable-pic', '--disable-symver', '--disable-doc', '--disable-shared', '--enable-static' | ||
args crossArgs | ||
args '--disable-everything' | ||
args '--enable-protocol=file', '--enable-filter=aresample', '--enable-filter=deshake' | ||
args '--enable-demuxer=ogg', '--enable-demuxer=matroska', '--enable-demuxer=mov' | ||
args '--enable-decoder=vorbis', '--enable-decoder=opus', '--enable-decoder=aac' | ||
args '--enable-decoder=vp8', '--enable-decoder=vp9', '--enable-decoder=theora', '--enable-decoder=av1' | ||
args '--enable-libdav1d', '--enable-decoder=libdav1d' | ||
args "--extra-cflags=-I$outDir/include" | ||
args "--extra-ldflags=-L$outDir/lib" | ||
args "--prefix=$outDir" | ||
// Uncomment the following line for MP4 video support: | ||
//args '--enable-decoder=h264', '--enable-decoder=hevc' | ||
args extraArgs | ||
} | ||
project.exec { | ||
workingDir ffDir | ||
commandLine 'make', '-j16' | ||
} | ||
project.exec { | ||
workingDir ffDir | ||
commandLine 'make', 'install' | ||
} | ||
} | ||
outputs.upToDateWhen { file("$outDir/lib/libavformat.a").exists() } | ||
} | ||
} | ||
|
||
registerBuild 'Windows32', 'i686-w64-mingw32', '--arch=x86', '--target-os=mingw32' | ||
registerBuild 'Windows64', 'x86_64-w64-mingw32', '--arch=x86_64', '--target-os=mingw32' | ||
|
||
registerBuild 'Linux64', 'x86_64-linux-gnu', '--arch=x86_64', '--target-os=linux', '--disable-cuda', '--disable-cuvid' | ||
|
||
registerBuild 'LinuxARM32', 'arm-linux-gnueabihf', '--arch=arm', '--target-os=linux' | ||
registerBuild 'LinuxARM64', 'aarch64-linux-gnu', '--arch=aarch64', '--target-os=linux' | ||
|
||
registerBuild 'Macos64', null, '--enable-cross-compile',// '--enable-hwaccel=h264_videotoolbox', '--enable-hwaccel=hevc_videotoolbox', | ||
'--arch=x86_64', '--target-os=darwin', '--cc=clang', '--cxx=clang++', '--dep-cc=clang', | ||
'--extra-cflags=-mmacosx-version-min=10.11 -arch x86_64', '--extra-cxxflags=-mmacosx-version-min=10.11 -arch x86_64', '--extra-ldflags=-mmacosx-version-min=10.11 -arch x86_64' | ||
registerBuild 'MacosARM64', null, '--enable-cross-compile',// '--enable-hwaccel=h264_videotoolbox', '--enable-hwaccel=hevc_videotoolbox', | ||
'--arch=arm64', '--target-os=darwin', '--cc=clang', '--cxx=clang++', '--dep-cc=clang', | ||
'--extra-cflags=-mmacosx-version-min=10.11 -arch arm64', '--extra-cxxflags=-mmacosx-version-min=10.11 -arch arm64', '--extra-ldflags=-mmacosx-version-min=10.11 -arch arm64' | ||
|
||
tasks.register('buildFFmpegWindowsAll') { | ||
dependsOn buildFFmpegWindows32, buildFFmpegWindows64 | ||
} | ||
|
||
tasks.register('buildFFmpegLinuxAll') { | ||
dependsOn buildFFmpegLinux64, buildFFmpegLinuxARM32, buildFFmpegLinuxARM64 | ||
} | ||
|
||
tasks.register('buildFFmpegMacosAll') { | ||
dependsOn buildFFmpegMacos64, buildFFmpegMacosARM64 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[binaries] | ||
c = 'arm-linux-gnueabihf-gcc' | ||
cpp = 'arm-linux-gnueabihf-gcc' | ||
ar = 'arm-linux-gnueabihf-ar' | ||
strip = 'arm-linux-gnueabihf-strip' | ||
|
||
[host_machine] | ||
system = 'linux' | ||
cpu_family = 'arm' | ||
cpu = 'arm' | ||
endian = 'little' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[binaries] | ||
c = ['clang', '-arch', 'arm64'] | ||
cpp = ['clang++', '-arch', 'arm64'] | ||
objc = ['clang', '-arch', 'arm64'] | ||
objcpp = ['clang++', '-arch', 'arm64'] | ||
ar = 'ar' | ||
strip = 'strip' | ||
|
||
[built-in options] | ||
c_args = ['-mmacos-version-min=10.11'] | ||
cpp_args = ['-mmacos-version-min=10.11'] | ||
c_link_args = ['-mmacos-version-min=10.11'] | ||
cpp_link_args = ['-mmacos-version-min=10.11'] | ||
objc_args = ['-mmacos-version-min=10.11'] | ||
objcpp_args = ['-mmacos-version-min=10.11'] | ||
|
||
[host_machine] | ||
system = 'darwin' | ||
subsystem = 'macos' | ||
kernel = 'xnu' | ||
cpu_family = 'aarch64' | ||
cpu = 'aarch64' | ||
endian = 'little' |
Submodule dav1d
added at
2ba57a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[binaries] | ||
c = 'x86_64-linux-gnu-gcc' | ||
cpp = 'x86_64-linux-gnu-g++' | ||
ar = 'x86_64-linux-gnu-ar' | ||
strip = 'x86_64-linux-gnu-strip' | ||
|
||
[host_machine] | ||
system = 'linux' | ||
cpu_family = 'x86_64' | ||
cpu = 'x86_64' | ||
endian = 'little' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[binaries] | ||
c = ['clang', '-arch', 'x86_64'] | ||
cpp = ['clang++', '-arch', 'x86_64'] | ||
objc = ['clang', '-arch', 'x86_64'] | ||
objcpp = ['clang++', '-arch', 'x86_64'] | ||
ar = 'ar' | ||
strip = 'strip' | ||
|
||
[built-in options] | ||
c_args = ['-mmacos-version-min=10.11'] | ||
cpp_args = ['-mmacos-version-min=10.11'] | ||
c_link_args = ['-mmacos-version-min=10.11'] | ||
cpp_link_args = ['-mmacos-version-min=10.11'] | ||
objc_args = ['-mmacos-version-min=10.11'] | ||
objcpp_args = ['-mmacos-version-min=10.11'] | ||
|
||
[host_machine] | ||
system = 'darwin' | ||
subsystem = 'macos' | ||
kernel = 'xnu' | ||
cpu_family = 'x86_64' | ||
cpu = 'x86_64' | ||
endian = 'little' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this. The same holds true for web - I use H.264 there because older/low-spec hardware lacks hardware-based VP9 decoding and it has only recently been supported by Safari. Not that gdx-video works well on iOS (15) - it ends up opening the raw video full screen - but at least it's better than nothing.
It's a little annoying to ship VP9 for desktop and H.264 for GWT, since the GWT backend doesn't support multiple assets directories, but you can tell Gradle to exclude the web version from the desktop build.