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