lol
at 24.11-pre 185 lines 8.5 kB view raw
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 39}: 40 41let 42 inherit (stdenv) is64bit isMips isDarwin isCygwin; 43 inherit (lib) enableFeature optional optionals; 44in 45 46assert vp8DecoderSupport || vp8EncoderSupport || vp9DecoderSupport || vp9EncoderSupport; 47assert 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 */ 51assert spatialResamplingSupport; 52assert postprocVisualizerSupport -> postprocSupport; 53assert unitTestsSupport -> curl != null && coreutils != null; 54assert vp9HighbitdepthSupport -> (vp9DecoderSupport || vp9EncoderSupport); 55assert isCygwin -> unitTestsSupport && webmIOSupport && libyuvSupport; 56 57stdenv.mkDerivation rec { 58 pname = "libvpx"; 59 version = "1.8.2"; 60 61 src = fetchFromGitHub { 62 owner = "webmproject"; 63 repo = "libvpx"; 64 rev = "v${version}"; 65 sha256 = "0gyq4fkbd2fv7m1mm9xrvn6rk6f4jsmbv8bnlhingmnrvyncnmnr"; 66 }; 67 68 patches = [ 69# ./CVE-2019-9232.CVE-2019-9325.CVE-2019-9371.CVE-2019-9433.patch 70 ]; 71 72 postPatch = '' 73 patchShebangs --build \ 74 build/make/*.sh \ 75 build/make/*.pl \ 76 build/make/*.pm \ 77 test/*.sh \ 78 configure 79 ''; 80 81 outputs = [ "bin" "dev" "out" ]; 82 setOutputFlags = false; 83 84 configurePlatforms = []; 85 configureFlags = [ 86 (enableFeature (vp8EncoderSupport || vp8DecoderSupport) "vp8") 87 (enableFeature vp8EncoderSupport "vp8-encoder") 88 (enableFeature vp8DecoderSupport "vp8-decoder") 89 (enableFeature (vp9EncoderSupport || vp9DecoderSupport) "vp9") 90 (enableFeature vp9EncoderSupport "vp9-encoder") 91 (enableFeature vp9DecoderSupport "vp9-decoder") 92 (enableFeature extraWarningsSupport "extra-warnings") 93 (enableFeature werrorSupport "werror") 94 "--disable-install-docs" 95 (enableFeature examplesSupport "install-bins") 96 "--enable-install-libs" 97 "--disable-install-srcs" 98 (enableFeature debugSupport "debug") 99 (enableFeature gprofSupport "gprof") 100 (enableFeature gcovSupport "gcov") 101 # Required to build shared libraries 102 (enableFeature (!isCygwin) "pic") 103 (enableFeature optimizationsSupport "optimizations") 104 (enableFeature runtimeCpuDetectSupport "runtime-cpu-detect") 105 (enableFeature thumbSupport "thumb") 106 "--enable-libs" 107 (enableFeature examplesSupport "examples") 108 "--disable-docs" 109 "--as=yasm" 110 # Limit default decoder max to WHXGA 111 (if sizeLimitSupport then "--size-limit=5120x3200" else null) 112 "--disable-codec-srcs" 113 (enableFeature debugLibsSupport "debug-libs") 114 (enableFeature isMips "dequant-tokens") 115 (enableFeature isMips "dc-recon") 116 (enableFeature postprocSupport "postproc") 117 (enableFeature (postprocSupport && (vp9DecoderSupport || vp9EncoderSupport)) "vp9-postproc") 118 (enableFeature multithreadSupport "multithread") 119 (enableFeature internalStatsSupport "internal-stats") 120 (enableFeature spatialResamplingSupport "spatial-resampling") 121 (enableFeature realtimeOnlySupport "realtime-only") 122 (enableFeature ontheflyBitpackingSupport "onthefly-bitpacking") 123 (enableFeature errorConcealmentSupport "error-concealment") 124 # Shared libraries are only supported on ELF platforms 125 (if isDarwin || isCygwin then 126 "--enable-static --disable-shared" 127 else 128 "--enable-shared") 129 (enableFeature smallSupport "small") 130 (enableFeature postprocVisualizerSupport "postproc-visualizer") 131 (enableFeature unitTestsSupport "unit-tests") 132 (enableFeature webmIOSupport "webm-io") 133 (enableFeature libyuvSupport "libyuv") 134 (enableFeature decodePerfTestsSupport "decode-perf-tests") 135 (enableFeature encodePerfTestsSupport "encode-perf-tests") 136 (enableFeature multiResEncodingSupport "multi-res-encoding") 137 (enableFeature temporalDenoisingSupport "temporal-denoising") 138 (enableFeature (temporalDenoisingSupport && (vp9DecoderSupport || vp9EncoderSupport)) "vp9-temporal-denoising") 139 (enableFeature coefficientRangeCheckingSupport "coefficient-range-checking") 140 (enableFeature (vp9HighbitdepthSupport && is64bit) "vp9-highbitdepth") 141 (enableFeature (experimentalSpatialSvcSupport || 142 experimentalFpMbStatsSupport || 143 experimentalEmulateHardwareSupport) "experimental") 144 ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 145 "--enable-external-build" 146 # libvpx darwin targets include darwin version (ie. ARCH-darwinXX-gcc, XX being the darwin version) 147 # See all_platforms: https://github.com/webmproject/libvpx/blob/master/configure 148 # Darwin versions: 10.4=8, 10.5=9, 10.6=10, 10.7=11, 10.8=12, 10.9=13, 10.10=14 149 "--force-target=${stdenv.hostPlatform.config}${ 150 if stdenv.hostPlatform.isDarwin then 151 if stdenv.hostPlatform.osxMinVersion == "10.10" then "14" 152 else if stdenv.hostPlatform.osxMinVersion == "10.9" then "13" 153 else if stdenv.hostPlatform.osxMinVersion == "10.8" then "12" 154 else if stdenv.hostPlatform.osxMinVersion == "10.7" then "11" 155 else if stdenv.hostPlatform.osxMinVersion == "10.6" then "10" 156 else if stdenv.hostPlatform.osxMinVersion == "10.5" then "9" 157 else "8" 158 else ""}-gcc" 159 (lib.optionalString stdenv.hostPlatform.isCygwin "--enable-static-msvcrt") 160 ] # Experimental features 161 ++ optional experimentalSpatialSvcSupport "--enable-spatial-svc" 162 ++ optional experimentalFpMbStatsSupport "--enable-fp-mb-stats" 163 ++ optional experimentalEmulateHardwareSupport "--enable-emulate-hardware"; 164 165 nativeBuildInputs = [ perl yasm ]; 166 167 buildInputs = [ ] 168 ++ optionals unitTestsSupport [ coreutils curl ]; 169 170 NIX_LDFLAGS = [ 171 "-lpthread" # fixes linker errors 172 ]; 173 174 enableParallelBuilding = true; 175 176 postInstall = ''moveToOutput bin "$bin" ''; 177 178 meta = with lib; { 179 description = "WebM VP8/VP9 codec SDK"; 180 homepage = "https://www.webmproject.org/"; 181 license = licenses.bsd3; 182 maintainers = with maintainers; [ codyopel ]; 183 platforms = platforms.all; 184 }; 185}