2021-01-21 18:00:13 +01:00
|
|
|
{ lib, stdenv, fetchFromGitHub, perl, yasm
|
2015-02-10 13:37:36 +01:00
|
|
|
, vp8DecoderSupport ? true # VP8 decoder
|
|
|
|
, vp8EncoderSupport ? true # VP8 encoder
|
|
|
|
, vp9DecoderSupport ? true # VP9 decoder
|
|
|
|
, vp9EncoderSupport ? true # VP9 encoder
|
|
|
|
, extraWarningsSupport ? false # emit non-fatal warnings
|
|
|
|
, werrorSupport ? false # treat warnings as errors (not available with all compilers)
|
|
|
|
, debugSupport ? false # debug mode
|
|
|
|
, gprofSupport ? false # gprof profiling instrumentation
|
|
|
|
, gcovSupport ? false # gcov coverage instrumentation
|
2015-04-04 08:21:47 +02:00
|
|
|
, sizeLimitSupport ? true # limit max size to allow in the decoder
|
2015-02-10 13:37:36 +01:00
|
|
|
, optimizationsSupport ? true # compiler optimization flags
|
|
|
|
, runtimeCpuDetectSupport ? true # detect cpu capabilities at runtime
|
|
|
|
, thumbSupport ? false # build arm assembly in thumb mode
|
|
|
|
, examplesSupport ? true # build examples (vpxdec & vpxenc are part of examples)
|
|
|
|
, debugLibsSupport ? false # include debug version of each library
|
|
|
|
, postprocSupport ? true # postprocessing
|
|
|
|
, multithreadSupport ? true # multithreaded decoding & encoding
|
|
|
|
, internalStatsSupport ? false # output of encoder internal stats for debug, if supported (encoders)
|
2015-04-04 08:21:47 +02:00
|
|
|
, spatialResamplingSupport ? true # spatial sampling (scaling)
|
2015-02-10 13:37:36 +01:00
|
|
|
, realtimeOnlySupport ? false # build for real-time encoding
|
|
|
|
, ontheflyBitpackingSupport ? false # on-the-fly bitpacking in real-time encoding
|
|
|
|
, errorConcealmentSupport ? false # decoder conceals losses
|
|
|
|
, smallSupport ? false # favor smaller binary over speed
|
|
|
|
, postprocVisualizerSupport ? false # macro block/block level visualizers
|
|
|
|
, unitTestsSupport ? false, curl ? null, coreutils ? null # unit tests
|
2015-04-04 08:21:47 +02:00
|
|
|
, webmIOSupport ? true # input from and output to webm container
|
|
|
|
, libyuvSupport ? true # libyuv
|
|
|
|
, decodePerfTestsSupport ? false # build decoder perf tests with unit tests
|
|
|
|
, encodePerfTestsSupport ? false # build encoder perf tests with unit tests
|
2015-02-10 13:37:36 +01:00
|
|
|
, multiResEncodingSupport ? false # multiple-resolution encoding
|
|
|
|
, temporalDenoisingSupport ? true # use temporal denoising instead of spatial denoising
|
2015-04-04 08:21:47 +02:00
|
|
|
, coefficientRangeCheckingSupport ? false # decoder checks if intermediate transform coefficients are in valid range
|
|
|
|
, vp9HighbitdepthSupport ? true # 10/12 bit color support in VP9
|
2015-02-10 13:37:36 +01:00
|
|
|
# Experimental features
|
2015-04-04 08:21:47 +02:00
|
|
|
, experimentalSpatialSvcSupport ? false # Spatial scalable video coding
|
|
|
|
, experimentalFpMbStatsSupport ? false
|
|
|
|
, experimentalEmulateHardwareSupport ? false
|
2015-02-10 13:37:36 +01:00
|
|
|
}:
|
2010-05-24 23:57:45 +02:00
|
|
|
|
2015-02-10 13:37:36 +01:00
|
|
|
let
|
2018-07-20 21:36:12 +02:00
|
|
|
inherit (stdenv) is64bit isMips isDarwin isCygwin;
|
2021-01-21 18:00:13 +01:00
|
|
|
inherit (lib) enableFeature optional optionals;
|
2013-06-11 18:03:48 +02:00
|
|
|
in
|
2015-02-10 13:37:36 +01:00
|
|
|
|
2015-04-04 08:21:47 +02:00
|
|
|
assert vp8DecoderSupport || vp8EncoderSupport || vp9DecoderSupport || vp9EncoderSupport;
|
|
|
|
assert internalStatsSupport && (vp9DecoderSupport || vp9EncoderSupport) -> postprocSupport;
|
|
|
|
/* If spatialResamplingSupport not enabled, build will fail with undeclared variable errors.
|
|
|
|
Variables called in vpx_scale/generic/vpx_scale.c are declared by vpx_scale/vpx_scale_rtcd.pl,
|
|
|
|
but is only executed if spatialResamplingSupport is enabled */
|
|
|
|
assert spatialResamplingSupport;
|
|
|
|
assert postprocVisualizerSupport -> postprocSupport;
|
|
|
|
assert unitTestsSupport -> curl != null && coreutils != null;
|
|
|
|
assert vp9HighbitdepthSupport -> (vp9DecoderSupport || vp9EncoderSupport);
|
|
|
|
assert isCygwin -> unitTestsSupport && webmIOSupport && libyuvSupport;
|
|
|
|
|
2010-05-24 23:57:45 +02:00
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 14:41:18 +02:00
|
|
|
pname = "libvpx";
|
2021-04-08 09:26:58 +02:00
|
|
|
version = "1.10.0";
|
2013-06-11 18:03:48 +02:00
|
|
|
|
2015-04-04 08:21:47 +02:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "webmproject";
|
2020-10-25 22:17:24 +01:00
|
|
|
repo = pname;
|
2015-04-04 08:21:47 +02:00
|
|
|
rev = "v${version}";
|
2021-04-08 09:26:58 +02:00
|
|
|
sha256 = "sha256-EZP33U10fchyqy7Jr26vHgUUfWR6xtG3fcMWUII0m9w=";
|
2010-05-24 23:57:45 +02:00
|
|
|
};
|
|
|
|
|
2020-10-25 22:17:24 +01:00
|
|
|
postPatch = "patchShebangs .";
|
2010-05-24 23:57:45 +02:00
|
|
|
|
2016-08-29 02:30:01 +02:00
|
|
|
outputs = [ "bin" "dev" "out" ];
|
2015-10-05 22:47:22 +02:00
|
|
|
setOutputFlags = false;
|
|
|
|
|
2018-05-10 19:43:12 +02:00
|
|
|
configurePlatforms = [];
|
2015-02-10 13:37:36 +01:00
|
|
|
configureFlags = [
|
2015-04-04 08:21:47 +02:00
|
|
|
(enableFeature (vp8EncoderSupport || vp8DecoderSupport) "vp8")
|
|
|
|
(enableFeature vp8EncoderSupport "vp8-encoder")
|
|
|
|
(enableFeature vp8DecoderSupport "vp8-decoder")
|
|
|
|
(enableFeature (vp9EncoderSupport || vp9DecoderSupport) "vp9")
|
|
|
|
(enableFeature vp9EncoderSupport "vp9-encoder")
|
|
|
|
(enableFeature vp9DecoderSupport "vp9-decoder")
|
|
|
|
(enableFeature extraWarningsSupport "extra-warnings")
|
|
|
|
(enableFeature werrorSupport "werror")
|
2015-02-10 13:37:36 +01:00
|
|
|
"--disable-install-docs"
|
2015-04-04 08:21:47 +02:00
|
|
|
(enableFeature examplesSupport "install-bins")
|
|
|
|
"--enable-install-libs"
|
|
|
|
"--disable-install-srcs"
|
|
|
|
(enableFeature debugSupport "debug")
|
|
|
|
(enableFeature gprofSupport "gprof")
|
|
|
|
(enableFeature gcovSupport "gcov")
|
2015-02-10 13:37:36 +01:00
|
|
|
# Required to build shared libraries
|
2015-04-04 08:21:47 +02:00
|
|
|
(enableFeature (!isCygwin) "pic")
|
|
|
|
(enableFeature optimizationsSupport "optimizations")
|
|
|
|
(enableFeature runtimeCpuDetectSupport "runtime-cpu-detect")
|
|
|
|
(enableFeature thumbSupport "thumb")
|
|
|
|
"--enable-libs"
|
|
|
|
(enableFeature examplesSupport "examples")
|
2015-02-10 13:37:36 +01:00
|
|
|
"--disable-docs"
|
|
|
|
"--as=yasm"
|
2015-04-04 08:21:47 +02:00
|
|
|
# Limit default decoder max to WHXGA
|
|
|
|
(if sizeLimitSupport then "--size-limit=5120x3200" else null)
|
|
|
|
"--disable-codec-srcs"
|
|
|
|
(enableFeature debugLibsSupport "debug-libs")
|
|
|
|
(enableFeature isMips "dequant-tokens")
|
|
|
|
(enableFeature isMips "dc-recon")
|
|
|
|
(enableFeature postprocSupport "postproc")
|
|
|
|
(enableFeature (postprocSupport && (vp9DecoderSupport || vp9EncoderSupport)) "vp9-postproc")
|
|
|
|
(enableFeature multithreadSupport "multithread")
|
|
|
|
(enableFeature internalStatsSupport "internal-stats")
|
|
|
|
(enableFeature spatialResamplingSupport "spatial-resampling")
|
|
|
|
(enableFeature realtimeOnlySupport "realtime-only")
|
|
|
|
(enableFeature ontheflyBitpackingSupport "onthefly-bitpacking")
|
|
|
|
(enableFeature errorConcealmentSupport "error-concealment")
|
2015-02-10 13:37:36 +01:00
|
|
|
# Shared libraries are only supported on ELF platforms
|
2015-04-04 08:21:47 +02:00
|
|
|
(if isDarwin || isCygwin then
|
|
|
|
"--enable-static --disable-shared"
|
|
|
|
else
|
2019-08-31 14:10:53 +02:00
|
|
|
"--enable-shared")
|
2015-04-04 08:21:47 +02:00
|
|
|
(enableFeature smallSupport "small")
|
|
|
|
(enableFeature postprocVisualizerSupport "postproc-visualizer")
|
|
|
|
(enableFeature unitTestsSupport "unit-tests")
|
|
|
|
(enableFeature webmIOSupport "webm-io")
|
|
|
|
(enableFeature libyuvSupport "libyuv")
|
|
|
|
(enableFeature decodePerfTestsSupport "decode-perf-tests")
|
|
|
|
(enableFeature encodePerfTestsSupport "encode-perf-tests")
|
|
|
|
(enableFeature multiResEncodingSupport "multi-res-encoding")
|
|
|
|
(enableFeature temporalDenoisingSupport "temporal-denoising")
|
|
|
|
(enableFeature (temporalDenoisingSupport && (vp9DecoderSupport || vp9EncoderSupport)) "vp9-temporal-denoising")
|
|
|
|
(enableFeature coefficientRangeCheckingSupport "coefficient-range-checking")
|
|
|
|
(enableFeature (vp9HighbitdepthSupport && is64bit) "vp9-highbitdepth")
|
|
|
|
(enableFeature (experimentalSpatialSvcSupport ||
|
|
|
|
experimentalFpMbStatsSupport ||
|
|
|
|
experimentalEmulateHardwareSupport) "experimental")
|
2018-05-10 19:43:12 +02:00
|
|
|
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
2020-10-25 22:17:24 +01:00
|
|
|
#"--extra-cflags="
|
|
|
|
#"--extra-cxxflags="
|
|
|
|
#"--prefix="
|
|
|
|
#"--libc="
|
|
|
|
#"--libdir="
|
|
|
|
"--enable-external-build"
|
2018-05-10 19:43:12 +02:00
|
|
|
# libvpx darwin targets include darwin version (ie. ARCH-darwinXX-gcc, XX being the darwin version)
|
|
|
|
# See all_platforms: https://github.com/webmproject/libvpx/blob/master/configure
|
|
|
|
# Darwin versions: 10.4=8, 10.5=9, 10.6=10, 10.7=11, 10.8=12, 10.9=13, 10.10=14
|
2020-03-05 02:50:17 +01:00
|
|
|
"--force-target=${stdenv.hostPlatform.parsed.cpu.name}-${stdenv.hostPlatform.parsed.kernel.name}${
|
2018-08-20 20:43:41 +02:00
|
|
|
if stdenv.hostPlatform.isDarwin then
|
|
|
|
if stdenv.hostPlatform.osxMinVersion == "10.10" then "14"
|
|
|
|
else if stdenv.hostPlatform.osxMinVersion == "10.9" then "13"
|
|
|
|
else if stdenv.hostPlatform.osxMinVersion == "10.8" then "12"
|
|
|
|
else if stdenv.hostPlatform.osxMinVersion == "10.7" then "11"
|
|
|
|
else if stdenv.hostPlatform.osxMinVersion == "10.6" then "10"
|
|
|
|
else if stdenv.hostPlatform.osxMinVersion == "10.5" then "9"
|
2018-05-10 19:43:12 +02:00
|
|
|
else "8"
|
|
|
|
else ""}-gcc"
|
2018-08-20 20:43:41 +02:00
|
|
|
(if stdenv.hostPlatform.isCygwin then "--enable-static-msvcrt" else "")
|
2018-05-10 19:43:12 +02:00
|
|
|
] # Experimental features
|
|
|
|
++ optional experimentalSpatialSvcSupport "--enable-spatial-svc"
|
2015-04-04 08:21:47 +02:00
|
|
|
++ optional experimentalFpMbStatsSupport "--enable-fp-mb-stats"
|
|
|
|
++ optional experimentalEmulateHardwareSupport "--enable-emulate-hardware";
|
|
|
|
|
|
|
|
nativeBuildInputs = [ perl yasm ];
|
|
|
|
|
|
|
|
buildInputs = [ ]
|
|
|
|
++ optionals unitTestsSupport [ coreutils curl ];
|
2010-09-01 10:36:09 +02:00
|
|
|
|
2020-10-25 22:17:24 +01:00
|
|
|
NIX_LDFLAGS = [
|
|
|
|
"-lpthread" # fixes linker errors
|
|
|
|
];
|
|
|
|
|
2015-02-10 13:37:36 +01:00
|
|
|
enableParallelBuilding = true;
|
2010-05-24 23:57:45 +02:00
|
|
|
|
2015-12-02 10:03:23 +01:00
|
|
|
postInstall = ''moveToOutput bin "$bin" '';
|
2015-10-05 22:47:22 +02:00
|
|
|
|
2021-01-21 18:00:13 +01:00
|
|
|
meta = with lib; {
|
2015-02-10 13:37:36 +01:00
|
|
|
description = "WebM VP8/VP9 codec SDK";
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "https://www.webmproject.org/";
|
2013-07-13 21:54:39 +02:00
|
|
|
license = licenses.bsd3;
|
2015-04-04 08:21:47 +02:00
|
|
|
maintainers = with maintainers; [ codyopel ];
|
2015-02-10 13:37:36 +01:00
|
|
|
platforms = platforms.all;
|
2010-05-24 23:57:45 +02:00
|
|
|
};
|
|
|
|
}
|