5 ms·
The only options I could think of that're mature enough are OCaml and Haskell. I'm aware of video transcoders in both, though nothing with anything like the for
by lmm 13y ago
The only options I could think of that're mature enough are OCaml and Haskell. I'm aware of video transcoders in both, though nothing with anything like the format support of ffmpeg.
- colanderman 13y agoOCaml I know doesn't support SIMD acceleration. Not sure about Haskell. You need SIMD support to get anything decently fast in the field of video/audio manipulation.
- pjmlp 13y agoThat is a compiler issue, not language. ISO/ANSI C also don't support SIMD, you have to go down to Assembly when writing portable code across C compilers.
- x0x0 13y agoif we're willing to posit the existence of unwritten software that makes simd work from ocaml or haskell, we could also just assume the existence of C that checks memory accesses for zero cost also, I think you may be able to do reasonably well with icc and not much assembly
- colanderman 13y agoYa, it's definitely a language issue; barring super-intelligent compilers that can vectorize things on their own (which GCC does for certain cases), you need a means to express vectorizable operations. You don't need to work at the assembly level for this; you just need a language that can express vector operations in a way that doesn't require a compiler to solve the halting problem, and you need a compiler that knows how to compile such operations to SIMD. Yes, ANSI C doesn't have such a construct, but GNU C (which I'd bet 95% of open-source code uses anyway) does.
- astrange 13y agoNearly all SIMD in ffmpeg/libav/x264 is just written in assembly. Back in the day, gcc's code generation for even x86 SIMD intrinsic functions was too poor to consider using it. (Plus x86's intrinsics are just plain ugly. It's easier to read asm.) As for the architecture-independent SIMD in GNU C, it's something, but not quite flexible enough. Even C is really not a good enough language to consider implementing this in, because it has an overly-conservative memory model when it comes to char *, which aliases all other memory. For a library dedicated to parsing things which come in the form of bytestreams and 8-bit pixels, this means that most compiler optimizations are defeated right in the inner loops where you'd need them.
- nitrogen 13y agoIsn't that what the restrict keyword is for?
- panzi 13y agoYes, but how long does this exist? My guess would be that it isn't really used (yet) in ffmpeg.
- anon1385 13y agoSince C99 so 15 years, which is older than ffmpeg.
- panzi 13y agoWhat I meant is how long is it supported by compilers. I know its by GCC, but I think it's not by MSCV. Is it possible to compile ffmpeg with MSVC? But ok, one could use it and just #define it away for crappy compilers.
- jasomill 13y agoAccording to MSDN, Visual C++ has supported the equivalent __restrict keyword since at least 2005 [1], and according to the ffmpeg documentation [2], "FFmpeg can be built with MSVC 2012 or earlier using a C99-to-C89 conversion utility and wrapper, or with MSVC 2013 and ICL natively." [1] http://msdn.microsoft.com/en-us/library/5ft82fed(v=vs.80).aspx http://msdn.microsoft.com/en-us/library/5ft82fed(v=vs.80).as... [2] http://www.ffmpeg.org/platform.html http://www.ffmpeg.org/platform.html
- trobertson 13y agoHaskell's GHC is working on it [1]. It's not primetime (not even close, really), but it does work with modified libraries and compiling to llvm. There is also Intel Lab's HRC (Haskell Research Compiler) that does have SIMD capabilities [2]. Unfortunately, there isn't a public release of HRC yet. --- [1]: https://ghc.haskell.org/trac/ghc/wiki/SIMD https://ghc.haskell.org/trac/ghc/wiki/SIMD [2]: http://dorchard.wordpress.com/2013/10/14/automatic-simd-vectorization-for-haskell-and-icfp-2013/ http://dorchard.wordpress.com/2013/10/14/automatic-simd-vect...