1 { lib, stdenv, fetchFromGitHub, perl, yasm
2 , vp8DecoderSupport ? true # VP8 decoder
3 , vp8EncoderSupport ? true # VP8 encoder
4 , vp9DecoderSupport ? true # VP9 decoder
5 , vp9EncoderSupport ? true # VP9 encoder
6 , extraWarningsSupport ? false # emit non-fatal warnings
7 , werrorSupport ? false # treat warnings as errors (not available with all compilers)
8 , debugSupport ? false # debug mode
9 , gprofSupport ? false # gprof profiling instrumentation
10 , gcovSupport ? false # gcov coverage instrumentation
11 , sizeLimitSupport ? true # limit max size to allow in the decoder
12 , optimizationsSupport ? true # compiler optimization flags
13 , runtimeCpuDetectSupport ? true # detect cpu capabilities at runtime
14 , thumbSupport ? false # build arm assembly in thumb mode
15 , examplesSupport ? true # build examples (vpxdec & vpxenc are part of examples)
16 , debugLibsSupport ? false # include debug version of each library
17 , postprocSupport ? true # postprocessing
18 , multithreadSupport ? true # multithreaded decoding & encoding
19 , internalStatsSupport ? false # output of encoder internal stats for debug, if supported (encoders)
20 , spatialResamplingSupport ? true # spatial sampling (scaling)
21 , realtimeOnlySupport ? false # build for real-time encoding
22 , ontheflyBitpackingSupport ? false # on-the-fly bitpacking in real-time encoding
23 , errorConcealmentSupport ? false # decoder conceals losses
24 , smallSupport ? false # favor smaller binary over speed
25 , postprocVisualizerSupport ? false # macro block/block level visualizers
26 , unitTestsSupport ? false, curl ? null, coreutils ? null # unit tests
27 , webmIOSupport ? true # input from and output to webm container
28 , libyuvSupport ? true # libyuv
29 , decodePerfTestsSupport ? false # build decoder perf tests with unit tests
30 , encodePerfTestsSupport ? false # build encoder perf tests with unit tests
31 , multiResEncodingSupport ? false # multiple-resolution encoding
32 , temporalDenoisingSupport ? true # use temporal denoising instead of spatial denoising
33 , coefficientRangeCheckingSupport ? false # decoder checks if intermediate transform coefficients are in valid range
34 , vp9HighbitdepthSupport ? true # 10/12 bit color support in VP9
35 # Experimental features
36 , experimentalSpatialSvcSupport ? false # Spatial scalable video coding
37 , experimentalFpMbStatsSupport ? false
38 , experimentalEmulateHardwareSupport ? false
42 inherit (stdenv) is64bit isMips isDarwin isCygwin;
43 inherit (lib) enableFeature optional optionals;
46 assert vp8DecoderSupport || vp8EncoderSupport || vp9DecoderSupport || vp9EncoderSupport;
47 assert internalStatsSupport && (vp9DecoderSupport || vp9EncoderSupport) -> postprocSupport;
48 /* If spatialResamplingSupport not enabled, build will fail with undeclared variable errors.
49 Variables called in vpx_scale/generic/vpx_scale.c are declared by vpx_scale/vpx_scale_rtcd.pl,
50 but is only executed if spatialResamplingSupport is enabled */
51 assert spatialResamplingSupport;
52 assert postprocVisualizerSupport -> postprocSupport;
53 assert unitTestsSupport -> curl != null && coreutils != null;
54 assert vp9HighbitdepthSupport -> (vp9DecoderSupport || vp9EncoderSupport);
55 assert isCygwin -> unitTestsSupport && webmIOSupport && libyuvSupport;
57 stdenv.mkDerivation rec {
61 src = fetchFromGitHub {
62 owner = "webmproject";
65 sha256 = "0gyq4fkbd2fv7m1mm9xrvn6rk6f4jsmbv8bnlhingmnrvyncnmnr";
69 # ./CVE-2019-9232.CVE-2019-9325.CVE-2019-9371.CVE-2019-9433.patch
72 postPatch = "patchShebangs .";
74 outputs = [ "bin" "dev" "out" ];
75 setOutputFlags = false;
77 configurePlatforms = [];
79 (enableFeature (vp8EncoderSupport || vp8DecoderSupport) "vp8")
80 (enableFeature vp8EncoderSupport "vp8-encoder")
81 (enableFeature vp8DecoderSupport "vp8-decoder")
82 (enableFeature (vp9EncoderSupport || vp9DecoderSupport) "vp9")
83 (enableFeature vp9EncoderSupport "vp9-encoder")
84 (enableFeature vp9DecoderSupport "vp9-decoder")
85 (enableFeature extraWarningsSupport "extra-warnings")
86 (enableFeature werrorSupport "werror")
87 "--disable-install-docs"
88 (enableFeature examplesSupport "install-bins")
89 "--enable-install-libs"
90 "--disable-install-srcs"
91 (enableFeature debugSupport "debug")
92 (enableFeature gprofSupport "gprof")
93 (enableFeature gcovSupport "gcov")
94 # Required to build shared libraries
95 (enableFeature (!isCygwin) "pic")
96 (enableFeature optimizationsSupport "optimizations")
97 (enableFeature runtimeCpuDetectSupport "runtime-cpu-detect")
98 (enableFeature thumbSupport "thumb")
100 (enableFeature examplesSupport "examples")
103 # Limit default decoder max to WHXGA
104 (if sizeLimitSupport then "--size-limit=5120x3200" else null)
105 "--disable-codec-srcs"
106 (enableFeature debugLibsSupport "debug-libs")
107 (enableFeature isMips "dequant-tokens")
108 (enableFeature isMips "dc-recon")
109 (enableFeature postprocSupport "postproc")
110 (enableFeature (postprocSupport && (vp9DecoderSupport || vp9EncoderSupport)) "vp9-postproc")
111 (enableFeature multithreadSupport "multithread")
112 (enableFeature internalStatsSupport "internal-stats")
113 (enableFeature spatialResamplingSupport "spatial-resampling")
114 (enableFeature realtimeOnlySupport "realtime-only")
115 (enableFeature ontheflyBitpackingSupport "onthefly-bitpacking")
116 (enableFeature errorConcealmentSupport "error-concealment")
117 # Shared libraries are only supported on ELF platforms
118 (if isDarwin || isCygwin then
119 "--enable-static --disable-shared"
122 (enableFeature smallSupport "small")
123 (enableFeature postprocVisualizerSupport "postproc-visualizer")
124 (enableFeature unitTestsSupport "unit-tests")
125 (enableFeature webmIOSupport "webm-io")
126 (enableFeature libyuvSupport "libyuv")
127 (enableFeature decodePerfTestsSupport "decode-perf-tests")
128 (enableFeature encodePerfTestsSupport "encode-perf-tests")
129 (enableFeature multiResEncodingSupport "multi-res-encoding")
130 (enableFeature temporalDenoisingSupport "temporal-denoising")
131 (enableFeature (temporalDenoisingSupport && (vp9DecoderSupport || vp9EncoderSupport)) "vp9-temporal-denoising")
132 (enableFeature coefficientRangeCheckingSupport "coefficient-range-checking")
133 (enableFeature (vp9HighbitdepthSupport && is64bit) "vp9-highbitdepth")
134 (enableFeature (experimentalSpatialSvcSupport ||
135 experimentalFpMbStatsSupport ||
136 experimentalEmulateHardwareSupport) "experimental")
137 ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
143 "--enable-external-build"
144 # libvpx darwin targets include darwin version (ie. ARCH-darwinXX-gcc, XX being the darwin version)
145 # See all_platforms: https://github.com/webmproject/libvpx/blob/master/configure
146 # Darwin versions: 10.4=8, 10.5=9, 10.6=10, 10.7=11, 10.8=12, 10.9=13, 10.10=14
147 "--force-target=${stdenv.hostPlatform.config}${
148 if stdenv.hostPlatform.isDarwin then
149 if stdenv.hostPlatform.osxMinVersion == "10.10" then "14"
150 else if stdenv.hostPlatform.osxMinVersion == "10.9" then "13"
151 else if stdenv.hostPlatform.osxMinVersion == "10.8" then "12"
152 else if stdenv.hostPlatform.osxMinVersion == "10.7" then "11"
153 else if stdenv.hostPlatform.osxMinVersion == "10.6" then "10"
154 else if stdenv.hostPlatform.osxMinVersion == "10.5" then "9"
157 (if stdenv.hostPlatform.isCygwin then "--enable-static-msvcrt" else "")
158 ] # Experimental features
159 ++ optional experimentalSpatialSvcSupport "--enable-spatial-svc"
160 ++ optional experimentalFpMbStatsSupport "--enable-fp-mb-stats"
161 ++ optional experimentalEmulateHardwareSupport "--enable-emulate-hardware";
163 nativeBuildInputs = [ perl yasm ];
166 ++ optionals unitTestsSupport [ coreutils curl ];
169 "-lpthread" # fixes linker errors
172 enableParallelBuilding = true;
174 postInstall = ''moveToOutput bin "$bin" '';
177 description = "WebM VP8/VP9 codec SDK";
178 homepage = "https://www.webmproject.org/";
179 license = licenses.bsd3;
180 maintainers = with maintainers; [ codyopel ];
181 platforms = platforms.all;