7 vp8DecoderSupport ? true, # VP8 decoder
8 vp8EncoderSupport ? true, # VP8 encoder
9 vp9DecoderSupport ? true, # VP9 decoder
10 vp9EncoderSupport ? true, # VP9 encoder
11 extraWarningsSupport ? false, # emit non-fatal warnings
12 werrorSupport ? false, # treat warnings as errors (not available with all compilers)
13 debugSupport ? false, # debug mode
14 gprofSupport ? false, # gprof profiling instrumentation
15 gcovSupport ? false, # gcov coverage instrumentation
16 sizeLimitSupport ? true, # limit max size to allow in the decoder
17 optimizationsSupport ? true, # compiler optimization flags
18 runtimeCpuDetectSupport ? true, # detect cpu capabilities at runtime
19 thumbSupport ? false, # build arm assembly in thumb mode
20 examplesSupport ? true, # build examples (vpxdec & vpxenc are part of examples)
21 debugLibsSupport ? false, # include debug version of each library
22 postprocSupport ? true, # postprocessing
23 multithreadSupport ? true, # multithreaded decoding & encoding
24 internalStatsSupport ? false, # output of encoder internal stats for debug, if supported (encoders)
25 spatialResamplingSupport ? true, # spatial sampling (scaling)
26 realtimeOnlySupport ? false, # build for real-time encoding
27 ontheflyBitpackingSupport ? false, # on-the-fly bitpacking in real-time encoding
28 errorConcealmentSupport ? false, # decoder conceals losses
29 smallSupport ? false, # favor smaller binary over speed
30 postprocVisualizerSupport ? false, # macro block/block level visualizers
31 unitTestsSupport ? false,
33 coreutils ? null, # unit tests
34 webmIOSupport ? true, # input from and output to webm container
35 libyuvSupport ? true, # libyuv
36 decodePerfTestsSupport ? false, # build decoder perf tests with unit tests
37 encodePerfTestsSupport ? false, # build encoder perf tests with unit tests
38 multiResEncodingSupport ? false, # multiple-resolution encoding
39 temporalDenoisingSupport ? true, # use temporal denoising instead of spatial denoising
40 coefficientRangeCheckingSupport ? false, # decoder checks if intermediate transform coefficients are in valid range
41 vp9HighbitdepthSupport ? true, # 10/12 bit color support in VP9
42 # Experimental features
43 experimentalSpatialSvcSupport ? false, # Spatial scalable video coding
44 experimentalFpMbStatsSupport ? false,
45 experimentalEmulateHardwareSupport ? false,
53 inherit (stdenv.hostPlatform)
59 inherit (lib) enableFeature optional optionals;
61 # libvpx darwin targets include darwin version (ie. ARCH-darwinXX-gcc, XX being the darwin version)
62 # See all_platforms: https://github.com/webmproject/libvpx/blob/master/configure
63 # Darwin versions: 10.4=8, 10.5=9, 10.6=10, 10.7=11, 10.8=12, 10.9=13, 10.10=14
65 if stdenv.hostPlatform.osxMinVersion == "10.10" then
67 else if stdenv.hostPlatform.osxMinVersion == "10.9" then
69 else if stdenv.hostPlatform.osxMinVersion == "10.8" then
71 else if stdenv.hostPlatform.osxMinVersion == "10.7" then
73 else if stdenv.hostPlatform.osxMinVersion == "10.6" then
75 else if stdenv.hostPlatform.osxMinVersion == "10.5" then
81 if stdenv.hostPlatform.isArmv7 then
83 else if stdenv.hostPlatform.isAarch64 then
85 else if stdenv.hostPlatform.isx86_32 then
88 stdenv.hostPlatform.parsed.cpu.name;
91 # Build system doesn't understand BSD, so pretend to be Linux.
92 if stdenv.hostPlatform.isBSD then
94 else if stdenv.hostPlatform.isDarwin then
95 "darwin${darwinVersion}"
97 stdenv.hostPlatform.parsed.kernel.name;
100 (stdenv.hostPlatform.isPower && stdenv.hostPlatform.isLittleEndian)
101 || stdenv.hostPlatform.parsed.cpu.name == "armv6l"
102 || stdenv.hostPlatform.isRiscV;
105 if (stdenv.hostPlatform.isBSD || stdenv.hostPlatform != stdenv.buildPlatform) then
106 (if isGeneric then "generic-gnu" else "${cpu}-${kernel}-gcc")
111 assert vp8DecoderSupport || vp8EncoderSupport || vp9DecoderSupport || vp9EncoderSupport;
112 assert internalStatsSupport && (vp9DecoderSupport || vp9EncoderSupport) -> postprocSupport;
114 If spatialResamplingSupport not enabled, build will fail with undeclared variable errors.
115 Variables called in vpx_scale/generic/vpx_scale.c are declared by vpx_scale/vpx_scale_rtcd.pl,
116 but is only executed if spatialResamplingSupport is enabled
118 assert spatialResamplingSupport;
119 assert postprocVisualizerSupport -> postprocSupport;
120 assert unitTestsSupport -> curl != null && coreutils != null;
121 assert vp9HighbitdepthSupport -> (vp9DecoderSupport || vp9EncoderSupport);
122 assert isCygwin -> unitTestsSupport && webmIOSupport && libyuvSupport;
124 stdenv.mkDerivation rec {
128 src = fetchFromGitHub {
129 owner = "webmproject";
132 hash = "sha256-ewkx1okhpa05jn4DyN8pkl6UJoz4Ymw4jRe6GN1lWuA=";
136 patchShebangs --build \
143 # When cross-compiling (for aarch64-multiplatform), the compiler errors out on these flags.
144 # Since they're 'just' warnings, it's fine to just remove them.
145 substituteInPlace configure \
146 --replace "check_add_cflags -Wparentheses-equality" "" \
147 --replace "check_add_cflags -Wunreachable-code-loop-increment" "" \
148 --replace "check_cflags -Wshorten-64-to-32 && add_cflags_only -Wshorten-64-to-32" ""
156 setOutputFlags = false;
158 configurePlatforms = [ ];
161 (enableFeature (vp8EncoderSupport || vp8DecoderSupport) "vp8")
162 (enableFeature vp8EncoderSupport "vp8-encoder")
163 (enableFeature vp8DecoderSupport "vp8-decoder")
164 (enableFeature (vp9EncoderSupport || vp9DecoderSupport) "vp9")
165 (enableFeature vp9EncoderSupport "vp9-encoder")
166 (enableFeature vp9DecoderSupport "vp9-decoder")
167 (enableFeature extraWarningsSupport "extra-warnings")
168 (enableFeature werrorSupport "werror")
169 "--disable-install-docs"
170 (enableFeature examplesSupport "install-bins")
171 "--enable-install-libs"
172 "--disable-install-srcs"
173 (enableFeature debugSupport "debug")
174 (enableFeature gprofSupport "gprof")
175 (enableFeature gcovSupport "gcov")
176 # Required to build shared libraries
177 (enableFeature (!isCygwin) "pic")
178 (enableFeature optimizationsSupport "optimizations")
179 (enableFeature runtimeCpuDetectSupport "runtime-cpu-detect")
180 (enableFeature thumbSupport "thumb")
182 (enableFeature examplesSupport "examples")
185 # Limit default decoder max to WHXGA
186 (if sizeLimitSupport then "--size-limit=5120x3200" else null)
187 "--disable-codec-srcs"
188 (enableFeature debugLibsSupport "debug-libs")
189 (enableFeature isMips "dequant-tokens")
190 (enableFeature isMips "dc-recon")
191 (enableFeature postprocSupport "postproc")
192 (enableFeature (postprocSupport && (vp9DecoderSupport || vp9EncoderSupport)) "vp9-postproc")
193 (enableFeature multithreadSupport "multithread")
194 (enableFeature internalStatsSupport "internal-stats")
195 (enableFeature spatialResamplingSupport "spatial-resampling")
196 (enableFeature realtimeOnlySupport "realtime-only")
197 (enableFeature ontheflyBitpackingSupport "onthefly-bitpacking")
198 (enableFeature errorConcealmentSupport "error-concealment")
199 # Shared libraries are only supported on ELF platforms
200 (if isDarwin || isCygwin then "--enable-static --disable-shared" else "--enable-shared")
201 (enableFeature smallSupport "small")
202 (enableFeature postprocVisualizerSupport "postproc-visualizer")
203 (enableFeature unitTestsSupport "unit-tests")
204 (enableFeature webmIOSupport "webm-io")
205 (enableFeature libyuvSupport "libyuv")
206 (enableFeature decodePerfTestsSupport "decode-perf-tests")
207 (enableFeature encodePerfTestsSupport "encode-perf-tests")
208 (enableFeature multiResEncodingSupport "multi-res-encoding")
209 (enableFeature temporalDenoisingSupport "temporal-denoising")
211 temporalDenoisingSupport && (vp9DecoderSupport || vp9EncoderSupport)
212 ) "vp9-temporal-denoising")
213 (enableFeature coefficientRangeCheckingSupport "coefficient-range-checking")
214 (enableFeature (vp9HighbitdepthSupport && is64bit) "vp9-highbitdepth")
216 experimentalSpatialSvcSupport || experimentalFpMbStatsSupport || experimentalEmulateHardwareSupport
219 ++ optionals (target != null) [
221 (lib.optionalString stdenv.hostPlatform.isCygwin "--enable-static-msvcrt")
223 # Experimental features
224 ++ optional experimentalSpatialSvcSupport "--enable-spatial-svc"
225 ++ optional experimentalFpMbStatsSupport "--enable-fp-mb-stats"
226 ++ optional experimentalEmulateHardwareSupport "--enable-emulate-hardware";
228 nativeBuildInputs = [
235 ++ optionals unitTestsSupport [
241 "-lpthread" # fixes linker errors
244 enableParallelBuilding = true;
246 postInstall = ''moveToOutput bin "$bin" '';
249 inherit (gst_all_1) gst-plugins-good;
250 ffmpeg = ffmpeg.override { withVpx = true; };
254 description = "WebM VP8/VP9 codec SDK";
255 homepage = "https://www.webmproject.org/";
256 changelog = "https://github.com/webmproject/libvpx/raw/v${version}/CHANGELOG";
257 license = licenses.bsd3;
258 maintainers = with maintainers; [ codyopel ];
259 platforms = platforms.all;