Grayscale compression with libx264


In a video analysis software we are using the Up Board based on the Intel Z8350. The primary task is real-time analysis and there is no need for video recording but during testing it would be useful to integrate such feature. Unfortunately, this chipset is not Intel Quick Sync capable meaning that it is not offering hardware video encoding, a feature that is easily found in cheaper boards such as RPi.

The sensor is natively grayscale in Full HD and I was looking for a good compressor capable of working directly in grayscale. I looked into libx264, the fastest compressor around, but it is not natively offering mono input. This means that the solution is to provide a planar YUV with zero-ed U and V. This is clearly a waste of memory transfer and processing.

The h.264 specification supports this case as chroma format 4:0:0 but libx264 is not implementing it. For this reason I have patched it for supporting this capability, updating also the testing tool provided with libx264. The outcome is quite fast for this scenario and the resulting videos are readable by VLC and other tools.

I have tested the patch on an Intel i7 and on the UpBoard. With the former there is a gain of 17% in terms of speed with respect to the zero-ed YUV, measured over a FullHD 10 seconds video.

The instructions for testing and some results can be found on the project's github: https://github.com/eruffaldi/x264/issues/1

The patch is on the github fork of x264: https://github.com/eruffaldi/x264/tree/grayscale

The libx264 project is not on github so I have created a self pull request to review the changes: https://github.com/eruffaldi/x264/pull/2

Enjoy grayscale encoding

-E

Comments

Popular Posts