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