Parallelizing video encoder with TBB?

Parallelizing video encoder with TBB?

Nick Chen's picture
Has anyone implemented video encoders with complex dependencies between frames (like MPEG-4 or H.264) with TBB?

The encoding algorithm has a pipeline structure:

Input (token = frame) -> Predict (uses reference frames) -> Residuals -> Quantization -> Encode -> Output (also copied to global buffer)

so we'd like to exploit this by using a TBB pipeline, however, dependencies between frames make this very difficult.

These encoders allow a frame to predict its type based on frames before and/or after itself. The referenced frames can be arbitrarily far away (though typically within the previous 5 or next 5 frames, say) and they must be encoded and stored in a global buffer before they can be used as a reference. In short, there's a dependency DAG for frames.

The problem is making sure reference frames are completed before some frame requires them in the prediction stage. Simply waiting on a condition variable is unsatisfactory because it shuts down the entire thread, meaning that most of the time only a few threads will actually be doing work.

Suggestions? Or sample code showing how to address similar complex dependencies in similar applications would also be helpful.


To provide more context, this is being done in a research setting. We are trying to see if we could use TBB to express the parallel patterns used in the PThreads versions of applications. In this case, the reference application is x264 which threads in a complex manner for parallelization.
2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Raf Schietekat's picture

This seems to duplicate the original posting in another thread. Please follow up there.

Login to leave a comment.