It could compete with ffmpeg on speed, sadly scaling requires a separate step.
Added preliminary support and packaging (Fedora only) in r11646, only for BGRX to YUV420P. That thing is seriously fast. It beats the current record holder (ffmpeg's swscale) by a huge margin on 256x256 and up (this sort of size is pretty common for video). On a somewhat old AMD FX 8150:
work in progress patch
r11647 adds support for scaling and improves the tests to measure the performance. Scaling costs us about 10 to 20%, and swscale is a lot more competitive when scaling is involved. I have also tested the size limits of this csc mode, and it can scale past 32kx32k which will be helpful for #969.
Encoding_info.exe) and video helper (
xpra/codecs/video_helper.py) test classes
--csc-modules=libyuv(we only use libyuv for RGB to yuv, so it only gets used on the server) and verify that it gets used:
xpra info | grep csc
XPRA_SCALING_HARDCODED=1:2 xpra start ..., or just make the scaling more aggressive:
xpra start --video-scaling=100 ...- the downscaling should be visible from
xpra info | grep csc.
example pkgconfig file for osx
I have figured out the win32 build, as as of r11874 you just do:
cd libyuv-r1446 mkdir out cd out cmake .. -G "Visual Studio 9 2008"
Then build the solution with the visual studio 9 GUI (or directly with nmake? should work too). Note: I changed from "debug" to "Release" build before building. If building for Python 3, we should probably use a new Visual Studio version... but the "Xpra-Build-Libs" directory structure is not version specific. Maybe it should be.
Talking about which, you have to place the files where our build system will find them, ie for me:
E:\Xpra-Build-Libs\ libyuv\ bin\ convert.exe lib\ yub.lib include\ libyuv.h libyuv\ *.h
The OSX build is more problematic, first you have to install cmake (that's easy), then it fails with:
libyuv-r1446/source/row_gcc.cc: In function 'void libyuv::ARGBToUVRow_SSSE3(const uint8*, int, uint8*, uint8*, int)': libyuv-r1446/source/row_gcc.cc:886: error: can't find a register in class 'GENERAL_REGS' while reloading 'asm' libyuv-r1446/source/row_gcc.cc:886: error: 'asm' operand has impossible constraints
Because of this gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11203.
LDFLAGS="-read_only_relocs suppress" \ CXXFLAGS="-march=i686 -O3 -fno-pic -fomit-frame-pointer -frename-registers -pipe" \ cmake -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX ..
It's ugly and uses
-fno-pic... but at least it builds. (this is not problem with 64-bit builds)
Then you need to generate and install the pkgconfig file attached to this ticket since libyuv does not provide a template. But it still fails because of the text relocs, and adding the flag to the compiler options does not help:
creating build/temp.macosx-10.5-i386-2.7/xpra/codecs/csc_libyuv /usr/bin/gcc-4.2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -I/Developer/SDKs/MacOSX10.5.sdk/usr/include \ -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -I/Users/osx/gtk/inst/include -arch i386 \ -I/Developer/SDKs/MacOSX10.5.sdk/usr/include -isysroot /Developer/SDKs/MacOSX10.5.sdk -I/Users/osx/gtk/inst/include/python2.7 \ -c xpra/codecs/csc_libyuv/colorspace_converter.cpp -o build/temp.macosx-10.5-i386-2.7/xpra/codecs/csc_libyuv/colorspace_converter.o \ -Wall -fPIC -read_only_relocs suppress cc1plus: warning: command line option "-Wstrict-prototypes" is valid for C/ObjC but not for C++ /Developer/usr/bin/g++-4.2 -bundle -undefined dynamic_lookup \ -L/Users/osx/gtk/inst/lib -L/Users/osx/gtk/inst/lib -arch i386 -L/Developer/SDKs/MacOSX10.5.sdk/usr/lib \ -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -Wl,-headerpad_max_install_names \ -L/Users/osx/gtk/inst/lib -L/Users/osx/gtk/inst/lib -arch i386 -L/Developer/SDKs/MacOSX10.5.sdk/usr/lib \ -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -Wl,-headerpad_max_install_names -arch i386 \ -I/Developer/SDKs/MacOSX10.5.sdk/usr/include -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 \ -I/Users/osx/gtk/inst/include -arch i386 -I/Developer/SDKs/MacOSX10.5.sdk/usr/include -isysroot /Developer/SDKs/MacOSX10.5.sdk \ build/temp.macosx-10.5-i386-2.7/xpra/codecs/csc_libyuv/colorspace_converter.o -L/Users/osx/gtk/inst/lib \ -lyuv -o build/lib.macosx-10.5-i386-2.7/xpra/codecs/csc_libyuv/colorspace_converter.so -Wall -read_only_relocs suppress ld: absolute addressing (perhaps -mdynamic-no-pic) used in _GetARGBBlend from /Users/osx/gtk/inst/lib/libyuv.a(planar_functions.cc.o) \ not allowed in slidable image. Use '-read_only_relocs suppress' to enable text relocs
And at this point I give up. We'll enable libyuv when we get 64-bit builds.
Not sure why I am only seeing this now, but I get reliable crashes with a different user over tcp with vp8 and d-feet as client app:
2016-03-13 11:13:46,179 libyuv.ColorspaceConverter.init_context(499, 316, 'BGRX', 499, 316, 'YUV420P', 48) 2016-03-13 11:13:46,180 buffer size=243712, scaling=0, filtermode=None 2016-03-13 11:13:46,183 libyuv.ARGBToI420 took 0.2ms 2016-03-13 11:13:46,188 YUVImageWrapper.free() cython_buffer=0x7fbc883ee220 2016-03-13 11:13:46,188 YUVImageWrapper.free() cython_buffer=0x0 2016-03-13 11:13:49,606 libyuv.ColorspaceConverter.init_context(499, 311, 'BGRX', 499, 311, 'YUV420P', 38) 2016-03-13 11:13:49,606 buffer size=239616, scaling=0, filtermode=None 2016-03-13 11:13:49,609 libyuv.ARGBToI420 took 0.3ms 2016-03-13 11:13:49,616 YUVImageWrapper.free() cython_buffer=0x7fbc887e6050 *** Error in `/bin/python': double free or corruption (!prev): 0x00007fbc887e6050 *** ======= Backtrace: ========= /lib64/libc.so.6(+0x77da5)[0x7fbcc256dda5] /lib64/libc.so.6(+0x804fa)[0x7fbcc25764fa] /lib64/libc.so.6(cfree+0x4c)[0x7fbcc2579cac] /usr/lib64/python2.7/site-packages/xpra/codecs/csc_libyuv/colorspace_converter.so(+0xdbaf)[0x7fbc92983baf]
The crash only occurs with the vpx codec (happens with both with vp8 and vp9)... h264, and mpeg4 are not affected when using the exact same csc (using
XPRA_FORCE_CSC_MODE=YUV420P for x264)
But the libyuv code looks fine, and temporarily removing all calls to free() the memory does not help!? Raising. This may require using valgrind (oh noes).
I cannot reproduce the problem on an Intel system, maybe it was a bad build somehow, or maybe this crashes on a different setup. (was on an AMD CPU system) valgrind didn't show anything even remotely suspicious.
@smo: back over to you, can you break it? if not, just record some performance stats.
Hit it again, on Intel this time :(
Turns out it's a trivial rounding error, fixed in r12303 - which I never hit because the tests used even dimensions, the bug only occurred with an odd input height. (not sure why this fired more with vpx than x264! The memory corruption would affect any buffer allocated after this one)
Ran some of these tests on my machine to confirm libyuv is much faster here are my results
Intel(R) Xeon(R) CPU E5-2620 0 @ 2.00GHz BGRX to YUV420P
I will do more testing like mentioned in comment:2 to make sure there are no crashes and update this ticket if there is.
It is quite obvious that libyuv is much faster than the alternatives.
I haven't run across any issues on the server end in linux with this but I haven't got to compiling and bundling libyuv on win32 yet. I will get to this shortly and update the ticket if I find any issues.
No issues building this on win32 following your instructions.
The command line way of building this is
msbuild Project.sln /p:Configuration=Release
this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/973