lol
1{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, 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-${version}";
64 version = "1.4.0";
65
66 src = fetchFromGitHub {
67 owner = "webmproject";
68 repo = "libvpx";
69 rev = "v${version}";
70 sha256 = "1y8cf2q5ij8z8ab5j36m18rbs62aah6sw6shzbs3jr70ja0z6n8s";
71 };
72
73 patchPhase = ''patchShebangs .'';
74
75 configureFlags = [
76 (enableFeature (vp8EncoderSupport || vp8DecoderSupport) "vp8")
77 (enableFeature vp8EncoderSupport "vp8-encoder")
78 (enableFeature vp8DecoderSupport "vp8-decoder")
79 (enableFeature (vp9EncoderSupport || vp9DecoderSupport) "vp9")
80 (enableFeature vp9EncoderSupport "vp9-encoder")
81 (enableFeature vp9DecoderSupport "vp9-decoder")
82 (enableFeature extraWarningsSupport "extra-warnings")
83 (enableFeature werrorSupport "werror")
84 "--disable-install-docs"
85 (enableFeature examplesSupport "install-bins")
86 "--enable-install-libs"
87 "--disable-install-srcs"
88 (enableFeature debugSupport "debug")
89 (enableFeature gprofSupport "gprof")
90 (enableFeature gcovSupport "gcov")
91 # Required to build shared libraries
92 (enableFeature (!isCygwin) "pic")
93 (enableFeature (isi686 || isx86_64) "use-x86inc")
94 (enableFeature optimizationsSupport "optimizations")
95 (enableFeature runtimeCpuDetectSupport "runtime-cpu-detect")
96 (enableFeature thumbSupport "thumb")
97 "--enable-libs"
98 (enableFeature examplesSupport "examples")
99 "--disable-docs"
100 "--as=yasm"
101 # Limit default decoder max to WHXGA
102 (if sizeLimitSupport then "--size-limit=5120x3200" else null)
103 (enableFeature fastUnalignedSupport "fast-unaligned")
104 "--disable-codec-srcs"
105 (enableFeature debugLibsSupport "debug-libs")
106 (enableFeature isMips "dequant-tokens")
107 (enableFeature isMips "dc-recon")
108 (enableFeature postprocSupport "postproc")
109 (enableFeature (postprocSupport && (vp9DecoderSupport || vp9EncoderSupport)) "vp9-postproc")
110 (enableFeature multithreadSupport "multithread")
111 (enableFeature internalStatsSupport "internal-stats")
112 (enableFeature memTrackerSupport "mem-tracker")
113 (enableFeature spatialResamplingSupport "spatial-resampling")
114 (enableFeature realtimeOnlySupport "realtime-only")
115 (enableFeature ontheflyBitpackingSupport "onthefly-bitpacking")
116 (enableFeature errorConcealmentSupport "error-concealment")
117 # Shared libraries are only supported on ELF platforms
118 (if isDarwin || isCygwin then
119 "--enable-static --disable-shared"
120 else
121 "--disable-static --enable-shared")
122 (enableFeature smallSupport "small")
123 (enableFeature postprocVisualizerSupport "postproc-visualizer")
124 (enableFeature unitTestsSupport "unit-tests")
125 (enableFeature webmIOSupport "webm-io")
126 (enableFeature libyuvSupport "libyuv")
127 (enableFeature decodePerfTestsSupport "decode-perf-tests")
128 (enableFeature encodePerfTestsSupport "encode-perf-tests")
129 (enableFeature multiResEncodingSupport "multi-res-encoding")
130 (enableFeature temporalDenoisingSupport "temporal-denoising")
131 (enableFeature (temporalDenoisingSupport && (vp9DecoderSupport || vp9EncoderSupport)) "vp9-temporal-denoising")
132 (enableFeature coefficientRangeCheckingSupport "coefficient-range-checking")
133 (enableFeature (vp9HighbitdepthSupport && is64bit) "vp9-highbitdepth")
134 (enableFeature (experimentalSpatialSvcSupport ||
135 experimentalFpMbStatsSupport ||
136 experimentalEmulateHardwareSupport) "experimental")
137 # Experimental features
138 ] ++ optional experimentalSpatialSvcSupport "--enable-spatial-svc"
139 ++ optional experimentalFpMbStatsSupport "--enable-fp-mb-stats"
140 ++ optional experimentalEmulateHardwareSupport "--enable-emulate-hardware";
141
142 nativeBuildInputs = [ perl yasm ];
143
144 buildInputs = [ ]
145 ++ optionals unitTestsSupport [ coreutils curl ];
146
147 enableParallelBuilding = true;
148
149 crossAttrs = let
150 isCygwin = stdenv.cross.libc == "msvcrt";
151 isDarwin = stdenv.cross.libc == "libSystem";
152 in {
153 dontSetConfigureCross = true;
154 configureFlags = configureFlags ++ [
155 #"--extra-cflags="
156 #"--prefix="
157 #"--libc="
158 #"--libdir="
159 "--enable-external-build"
160 # libvpx darwin targets include darwin version (ie. ARCH-darwinXX-gcc, XX being the darwin version)
161 # See all_platforms: https://github.com/webmproject/libvpx/blob/master/configure
162 # Darwin versions: 10.4=8, 10.5=9, 10.6=10, 10.7=11, 10.8=12, 10.9=13, 10.10=14
163 "--force-target=${stdenv.cross.config}${(
164 if isDarwin then (
165 if stdenv.cross.osxMinVersion == "10.10" then "14"
166 else if stdenv.cross.osxMinVersion == "10.9" then "13"
167 else if stdenv.cross.osxMinVersion == "10.8" then "12"
168 else if stdenv.cross.osxMinVersion == "10.7" then "11"
169 else if stdenv.cross.osxMinVersion == "10.6" then "10"
170 else if stdenv.cross.osxMinVersion == "10.5" then "9"
171 else "8")
172 else "")}-gcc"
173 (if isCygwin then "--enable-static-msvcrt" else "")
174 ];
175 };
176
177 meta = with stdenv.lib; {
178 description = "WebM VP8/VP9 codec SDK";
179 homepage = http://www.webmproject.org/;
180 license = licenses.bsd3;
181 maintainers = with maintainers; [ codyopel ];
182 platforms = platforms.all;
183 };
184}