Jetson TK1 freenect RGBx->BGRx


I am using Jetson TK1 with L4T 21.4
Currently I am using libfreenect2 with some difficulties.
The protonect sample coming with libfreenect2 seems to give wrong colors, B and R channels are swapped.
Same is happening when I am using libfreenect via Qt. For protonect, I can correct it by changing the line 56 from viewer.h from

typedef ImageFormat<4, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE> F8C4;


typedef ImageFormat<4, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE> F8C4;

In Qt side, the frame is initialized as a QImage with RGB32 format, unfortunately it shows it as BGR on the screen. Calling rgbSwapped resolves the problem but is really slow. Is there some way to change the B and R channels during decoding or something else?
There is R G and B offsets in jmoreconf.h, but I would need to compile the tegra jpeg library against that, but AFAIK the tegra libjpeg is closed source.

Thanks already

Hello, kassinen:
Maybe you can try GST plugin ‘nvvidconv’. It should be faster than software format conversion.