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