1{ stdenv, fetchgit, perl, yasm
2, hostPlatform
3, vp8DecoderSupport ? true # VP8 decoder
4, vp8EncoderSupport ? true # VP8 encoder
5, vp9DecoderSupport ? true # VP9 decoder
6, vp9EncoderSupport ? true # VP9 encoder
7, extraWarningsSupport ? false # emit non-fatal warnings
8, werrorSupport ? false # treat warnings as errors (not available with all compilers)
9, debugSupport ? false # debug mode
10, gprofSupport ? false # gprof profiling instrumentation
11, gcovSupport ? false # gcov coverage instrumentation
12, sizeLimitSupport ? true # limit max size to allow in the decoder
13, optimizationsSupport ? true # compiler optimization flags
14, runtimeCpuDetectSupport ? true # detect cpu capabilities at runtime
15, thumbSupport ? false # build arm assembly in thumb mode
16, examplesSupport ? true # build examples (vpxdec & vpxenc are part of examples)
17, fastUnalignedSupport ? true # use unaligned accesses if supported by hardware
18, debugLibsSupport ? false # include debug version of each library
19, postprocSupport ? true # postprocessing
20, multithreadSupport ? true # multithreaded decoding & encoding
21, internalStatsSupport ? false # output of encoder internal stats for debug, if supported (encoders)
22, memTrackerSupport ? false # track memory usage
23, spatialResamplingSupport ? true # spatial sampling (scaling)
24, realtimeOnlySupport ? false # build for real-time encoding
25, ontheflyBitpackingSupport ? false # on-the-fly bitpacking in real-time encoding
26, errorConcealmentSupport ? false # decoder conceals losses
27, smallSupport ? false # favor smaller binary over speed
28, postprocVisualizerSupport ? false # macro block/block level visualizers
29, unitTestsSupport ? false, curl ? null, coreutils ? null # unit tests
30, webmIOSupport ? true # input from and output to webm container
31, libyuvSupport ? true # libyuv
32, decodePerfTestsSupport ? false # build decoder perf tests with unit tests
33, encodePerfTestsSupport ? false # build encoder perf tests with unit tests
34, multiResEncodingSupport ? false # multiple-resolution encoding
35, temporalDenoisingSupport ? true # use temporal denoising instead of spatial denoising
36, coefficientRangeCheckingSupport ? false # decoder checks if intermediate transform coefficients are in valid range
37, vp9HighbitdepthSupport ? true # 10/12 bit color support in VP9
38, experimentalSupport ? false # experimental features
39# Experimental features
40, experimentalSpatialSvcSupport ? false # Spatial scalable video coding
41, experimentalFpMbStatsSupport ? false
42, experimentalEmulateHardwareSupport ? false
43}:
44
45let
46 inherit (stdenv) isi686 isx86_64 isArm is64bit isMips isDarwin isCygwin;
47 inherit (stdenv.lib) enableFeature optional optionals;
48in
49
50assert isi686 || isx86_64 || isArm || isMips; # Requires ARM with floating point support
51
52assert vp8DecoderSupport || vp8EncoderSupport || vp9DecoderSupport || vp9EncoderSupport;
53assert internalStatsSupport && (vp9DecoderSupport || vp9EncoderSupport) -> postprocSupport;
54/* If spatialResamplingSupport not enabled, build will fail with undeclared variable errors.
55 Variables called in vpx_scale/generic/vpx_scale.c are declared by vpx_scale/vpx_scale_rtcd.pl,
56 but is only executed if spatialResamplingSupport is enabled */
57assert spatialResamplingSupport;
58assert postprocVisualizerSupport -> postprocSupport;
59assert unitTestsSupport -> curl != null && coreutils != null;
60assert vp9HighbitdepthSupport -> (vp9DecoderSupport || vp9EncoderSupport);
61assert isCygwin -> unitTestsSupport && webmIOSupport && libyuvSupport;
62
63stdenv.mkDerivation rec {
64 name = "libvpx-git-${version}";
65 version = "2015-2-12";
66
67 src = fetchgit {
68 url = "https://chromium.googlesource.com/webm/libvpx";
69 /* DO NOT under any circumstance ever just bump the git commit without
70 confirming changes have not been made to the configure system */
71 rev = "f4c29ae9ea16c502c980a81ca9683327d5051929";
72 sha256 = "1w17vpcy44wlpr2icbwhcf3mrinybwy0bhif30p707hbxfxrj474";
73 };
74
75 patchPhase = ''patchShebangs .'';
76
77 outputs = [ "bin" "dev" "out" ];
78 setOutputFlags = false;
79
80 configureFlags = [
81 (enableFeature (vp8EncoderSupport || vp8DecoderSupport) "vp8")
82 (enableFeature vp8EncoderSupport "vp8-encoder")
83 (enableFeature vp8DecoderSupport "vp8-decoder")
84 (enableFeature (vp9EncoderSupport || vp9DecoderSupport) "vp9")
85 (enableFeature vp9EncoderSupport "vp9-encoder")
86 (enableFeature vp9DecoderSupport "vp9-decoder")
87 (enableFeature extraWarningsSupport "extra-warnings")
88 (enableFeature werrorSupport "werror")
89 "--disable-install-docs"
90 (enableFeature examplesSupport "install-bins")
91 "--enable-install-libs"
92 "--disable-install-srcs"
93 (enableFeature debugSupport "debug")
94 (enableFeature gprofSupport "gprof")
95 (enableFeature gcovSupport "gcov")
96 # Required to build shared libraries
97 (enableFeature (!isCygwin) "pic")
98 (enableFeature (isi686 || isx86_64) "use-x86inc")
99 (enableFeature optimizationsSupport "optimizations")
100 (enableFeature runtimeCpuDetectSupport "runtime-cpu-detect")
101 (enableFeature thumbSupport "thumb")
102 "--enable-libs"
103 (enableFeature examplesSupport "examples")
104 "--disable-docs"
105 "--as=yasm"
106 # Limit default decoder max to WHXGA
107 (if sizeLimitSupport then "--size-limit=5120x3200" else null)
108 (enableFeature fastUnalignedSupport "fast-unaligned")
109 "--disable-codec-srcs"
110 (enableFeature debugLibsSupport "debug-libs")
111 (enableFeature isMips "dequant-tokens")
112 (enableFeature isMips "dc-recon")
113 (enableFeature postprocSupport "postproc")
114 (enableFeature (postprocSupport && (vp9DecoderSupport || vp9EncoderSupport)) "vp9-postproc")
115 (enableFeature multithreadSupport "multithread")
116 (enableFeature internalStatsSupport "internal-stats")
117 (enableFeature memTrackerSupport "mem-tracker")
118 (enableFeature spatialResamplingSupport "spatial-resampling")
119 (enableFeature realtimeOnlySupport "realtime-only")
120 (enableFeature ontheflyBitpackingSupport "onthefly-bitpacking")
121 (enableFeature errorConcealmentSupport "error-concealment")
122 # Shared libraries are only supported on ELF platforms
123 (if isDarwin || isCygwin then
124 "--enable-static --disable-shared"
125 else
126 "--disable-static --enable-shared")
127 (enableFeature smallSupport "small")
128 (enableFeature postprocVisualizerSupport "postproc-visualizer")
129 (enableFeature unitTestsSupport "unit-tests")
130 (enableFeature webmIOSupport "webm-io")
131 (enableFeature libyuvSupport "libyuv")
132 (enableFeature decodePerfTestsSupport "decode-perf-tests")
133 (enableFeature encodePerfTestsSupport "encode-perf-tests")
134 (enableFeature multiResEncodingSupport "multi-res-encoding")
135 (enableFeature temporalDenoisingSupport "temporal-denoising")
136 (enableFeature (temporalDenoisingSupport && (vp9DecoderSupport || vp9EncoderSupport)) "vp9-temporal-denoising")
137 (enableFeature coefficientRangeCheckingSupport "coefficient-range-checking")
138 (enableFeature (vp9HighbitdepthSupport && is64bit) "vp9-highbitdepth")
139 (enableFeature (experimentalSpatialSvcSupport ||
140 experimentalFpMbStatsSupport ||
141 experimentalEmulateHardwareSupport) "experimental")
142 # Experimental features
143 ] ++ optional experimentalSpatialSvcSupport "--enable-spatial-svc"
144 ++ optional experimentalFpMbStatsSupport "--enable-fp-mb-stats"
145 ++ optional experimentalEmulateHardwareSupport "--enable-emulate-hardware";
146
147 nativeBuildInputs = [ perl yasm ];
148
149 buildInputs = [ ]
150 ++ optionals unitTestsSupport [ coreutils curl ];
151
152 enableParallelBuilding = true;
153
154 postInstall = ''moveToOutput bin "$bin" '';
155
156 crossAttrs = {
157 configurePlatforms = [];
158 configureFlags = configureFlags ++ [
159 #"--extra-cflags="
160 #"--prefix="
161 #"--libc="
162 #"--libdir="
163 "--enable-external-build"
164 # libvpx darwin targets include darwin version (ie. ARCH-darwinXX-gcc, XX being the darwin version)
165 # See all_platforms: https://github.com/webmproject/libvpx/blob/master/configure
166 # Darwin versions: 10.4=8, 10.5=9, 10.6=10, 10.7=11, 10.8=12, 10.9=13, 10.10=14
167 "--force-target=${hostPlatform.config}${
168 if hostPlatform.isDarwin then
169 if hostPlatform.osxMinVersion == "10.10" then "14"
170 else if hostPlatform.osxMinVersion == "10.9" then "13"
171 else if hostPlatform.osxMinVersion == "10.8" then "12"
172 else if hostPlatform.osxMinVersion == "10.7" then "11"
173 else if hostPlatform.osxMinVersion == "10.6" then "10"
174 else if hostPlatform.osxMinVersion == "10.5" then "9"
175 else "8"
176 else ""}-gcc"
177 (if hostPlatform.isCygwin then "--enable-static-msvcrt" else "")
178 ];
179 };
180
181 meta = with stdenv.lib; {
182 description = "WebM VP8/VP9 codec SDK";
183 homepage = http://www.webmproject.org/;
184 license = licenses.bsd3;
185 maintainers = with maintainers; [ codyopel ];
186 platforms = platforms.all;
187 };
188}