I am writing a de- and encoder for a custom video format (QTC). The decoding process consists of multiple stages, where the output of each stage is passed to the next stage:
- deserialize the input stream
- generate a sequence of symbols with a range coder
- generate a stream of images from the symbol stream
- serialize the image stream into an output format
Steps three and four take up almost all of the processing time, step three takes roughly 35% and step four takes about 60%, the first and the last step are rather trivial.
What is the recommend and ideomatic way to runs the four steps in parallel? I am mostly interested in how to handle the communication between the parts. I plan to use one Goroutine for step two and one for step three, the routines are connected with a buffered channel. Is this the right way?