Friday, February 22, 2013

MLT Adds GPU Image Processing

OpenGL logo
For a few months, we have been working on a set of image processing filters and transitions that utilize the OpenGL Shader Language (GLSL) of your video card/chip. This means that not only are they very fast but also cross-platform and widely supported. GLSL is generally faster and better supported than OpenCL and NVIDIA CUDA because those technologies are rather new or vendor-specific and designed for more general purpose computing. The new filters are also high quality by using 16-bit linear floating point per color component. All of this means that you can apply more effects without a huge reduction in frame rate.

This work has now been merged into the master code branch and will be available in the next release. They have already been integrated into the Shotcut daily builds for all 3 major OS platforms! However, a caveat - there is not much to see there yet because Shotcut does not yet have filters. :-) Nevertheless, it  has served as a feasibility exercise of the cross-platform integration. Meanwhile, one can open a clip, save as XML, edit the XML to put something like <filter mlt_service="movit.mirror"/> inside of the <producer></producer>, open the XML in Shotcut, and see the result. But first you will need to enable GPU Processing in the Settings menu.

What is currently available?

  • movit.blur
  • movit.convert (colorspace conversion)
  • movit.crop
  • movit.diffusion
  • movit.glow
  • movit.lift_gamma_gain (color correction)
  • movit.mirror
  • movit.opacity
  • movit.rect (position and scale)
  • movit.resample
  • movit.resize (pad)
  • movit.saturation
  • movit.sharpen
  • movit.vignette
  • movit.white_balance
  • movit.mix (transition)
  • movit.overlay (transition)
  • qglsl (a wrapper to multi consumer that uses Qt to abstract platform-specific OpenGL context)
More information can be found in the documentation section of the website.

What still needs to be done?

  • A new threading model to improve concurrency between CPU and GPU
  • More work on qglsl to support more multi-consumer use cases
  • Keyframable parameters throughout

Thanks

We thank Christophe Thommeret for providing the proof-of-concept which provided many ideas about how to integrate something like this with MLT.
We thank Steinar H. Gunderson for providing the new Movit library, which is an external dependency that provides all of the heavy lifting here.