Articles Technology Blog News Company
Multithreading: using VirtualDub filters on dual core and multiple CPUs

Parallelism becomes a very important issue now when hyperthreaded, dual and quad core CPUs and even multi-CPU systems are getting more and more popular, especially in video processing field. VirtualDub has grown to a very powerful video editing tool with more than hundred of available external filters (plugins). The problem is that its filters system is single-threaded. All filters work in one thread, utilizing only one core on multicore CPUs.

However, there is a way to really use several cores or CPUs when working with VD filters. Video Enhancer supports most VD filters, and it's multithreaded. Each filter, coder and decoder works in its own thread. The trick of parallelizing single-threaded filters is called conveyor. Let's see how it works internally and what benefits it brings.

Both VirtualDub and Video Enhancer allow you to build a sequence of filters that will be applied to the video one after another. In VirtualDub, all filters work in one thread: the first frame is processed by the first filter, then by second filter and so on, then the second frame processed by first filter, etc.

processing in one thread
You can see that at each moment only one filter is working. Note, that each filter requires different amount of time to process one frame.

In Video Enhancer filters work in separate threads. When first filter finished processing first frame, it can immediately start processing the second frame. Second filter will process first frame in parallel. When first frame reaches the last filter, all filters work simultaneously.

processing in one thread
Here you see that most of the time all filters are working, so overall speed is much greater. Of course, since each frame must be processed by each filter, the speed of all chain of filters is limited by the speed of the slowest one. In example above this is the second filter. Other filters are limited by its speed, so they have to spend some time waiting for the data. That's why it's almost impossible to use 100% of each core or processor. Usually only one core is 100% loaded, others spend some time waiting for the data.

A simple test was made on a Dual Core AMD Opteron 2.2GHz. A DV (dvsd) file containing 1505 frames 720x576 was processed with a chain of 3 filters (Asvzzz deinterlace, 2D Cleaner and MSU Smart Sharpen) and compressed with XviD codec. In VirtualDub it took 184 seconds and only one logical CPU was really active. In Video Enhancer absolutely the same process took 97 seconds and all logical CPUs were working. This is 1.9 times faster!

VirtualDub:
click to enlarge

VideoEnhancer:
click to enlarge

Another test was performed on a Hyper-Threading Pentium 4 3.0 GHz with a different DV file and same set of filters. VirtualDub completed the work in 53 seconds while Video Enhancer did it in 46 seconds. That's 15% faster.

Other articles...