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
73 patchShebangs --build \
81 outputs = [ "bin" "dev" "out" ];
82 setOutputFlags = false;
84 configurePlatforms = [];
86 (enableFeature (vp8EncoderSupport || vp8DecoderSupport) "vp8")
87 (enableFeature vp8EncoderSupport "vp8-encoder")
88 (enableFeature vp8DecoderSupport "vp8-decoder")
89 (enableFeature (vp9EncoderSupport || vp9DecoderSupport) "vp9")
90 (enableFeature vp9EncoderSupport "vp9-encoder")
91 (enableFeature vp9DecoderSupport "vp9-decoder")
92 (enableFeature extraWarningsSupport "extra-warnings")
93 (enableFeature werrorSupport "werror")
94 "--disable-install-docs"
95 (enableFeature examplesSupport "install-bins")
96 "--enable-install-libs"
97 "--disable-install-srcs"
98 (enableFeature debugSupport "debug")
99 (enableFeature gprofSupport "gprof")
100 (enableFeature gcovSupport "gcov")
101 # Required to build shared libraries
102 (enableFeature (!isCygwin) "pic")
103 (enableFeature optimizationsSupport "optimizations")
104 (enableFeature runtimeCpuDetectSupport "runtime-cpu-detect")
105 (enableFeature thumbSupport "thumb")
107 (enableFeature examplesSupport "examples")
110 # Limit default decoder max to WHXGA
111 (if sizeLimitSupport then "--size-limit=5120x3200" else null)
112 "--disable-codec-srcs"
113 (enableFeature debugLibsSupport "debug-libs")
114 (enableFeature isMips "dequant-tokens")
115 (enableFeature isMips "dc-recon")
116 (enableFeature postprocSupport "postproc")
117 (enableFeature (postprocSupport && (vp9DecoderSupport || vp9EncoderSupport)) "vp9-postproc")
118 (enableFeature multithreadSupport "multithread")
119 (enableFeature internalStatsSupport "internal-stats")
120 (enableFeature spatialResamplingSupport "spatial-resampling")
121 (enableFeature realtimeOnlySupport "realtime-only")
122 (enableFeature ontheflyBitpackingSupport "onthefly-bitpacking")
123 (enableFeature errorConcealmentSupport "error-concealment")
124 # Shared libraries are only supported on ELF platforms
125 (if isDarwin || isCygwin then
126 "--enable-static --disable-shared"
129 (enableFeature smallSupport "small")
130 (enableFeature postprocVisualizerSupport "postproc-visualizer")
131 (enableFeature unitTestsSupport "unit-tests")
132 (enableFeature webmIOSupport "webm-io")
133 (enableFeature libyuvSupport "libyuv")
134 (enableFeature decodePerfTestsSupport "decode-perf-tests")
135 (enableFeature encodePerfTestsSupport "encode-perf-tests")
136 (enableFeature multiResEncodingSupport "multi-res-encoding")
137 (enableFeature temporalDenoisingSupport "temporal-denoising")
138 (enableFeature (temporalDenoisingSupport && (vp9DecoderSupport || vp9EncoderSupport)) "vp9-temporal-denoising")
139 (enableFeature coefficientRangeCheckingSupport "coefficient-range-checking")
140 (enableFeature (vp9HighbitdepthSupport && is64bit) "vp9-highbitdepth")
141 (enableFeature (experimentalSpatialSvcSupport ||
142 experimentalFpMbStatsSupport ||
143 experimentalEmulateHardwareSupport) "experimental")
144 ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
145 "--enable-external-build"
146 # libvpx darwin targets include darwin version (ie. ARCH-darwinXX-gcc, XX being the darwin version)
147 # See all_platforms: https://github.com/webmproject/libvpx/blob/master/configure
148 # Darwin versions: 10.4=8, 10.5=9, 10.6=10, 10.7=11, 10.8=12, 10.9=13, 10.10=14
149 "--force-target=${stdenv.hostPlatform.config}${
150 if stdenv.hostPlatform.isDarwin then
151 if stdenv.hostPlatform.osxMinVersion == "10.10" then "14"
152 else if stdenv.hostPlatform.osxMinVersion == "10.9" then "13"
153 else if stdenv.hostPlatform.osxMinVersion == "10.8" then "12"
154 else if stdenv.hostPlatform.osxMinVersion == "10.7" then "11"
155 else if stdenv.hostPlatform.osxMinVersion == "10.6" then "10"
156 else if stdenv.hostPlatform.osxMinVersion == "10.5" then "9"
159 (if stdenv.hostPlatform.isCygwin then "--enable-static-msvcrt" else "")
160 ] # Experimental features
161 ++ optional experimentalSpatialSvcSupport "--enable-spatial-svc"
162 ++ optional experimentalFpMbStatsSupport "--enable-fp-mb-stats"
163 ++ optional experimentalEmulateHardwareSupport "--enable-emulate-hardware";
165 nativeBuildInputs = [ perl yasm ];
168 ++ optionals unitTestsSupport [ coreutils curl ];
171 "-lpthread" # fixes linker errors
174 enableParallelBuilding = true;
176 postInstall = ''moveToOutput bin "$bin" '';
179 description = "WebM VP8/VP9 codec SDK";
180 homepage = "https://www.webmproject.org/";
181 license = licenses.bsd3;
182 maintainers = with maintainers; [ codyopel ];
183 platforms = platforms.all;