Video decoders translate from compressed bitstreams to streams of raw images. In video streaming applications, the decoder will typically receive bitstream data from the network, process that data, and send the raw images to be displayed. There are many different video codecs, each with its own decoding algorithm. For each codec, there may be multiple decoder implementations. Since all decoders have the same general purpose, it is possible to abstract the decoding layer with a common API. This generalization makes it easier to develop software that uses video decoders, and makes advanced features such as hardware video decoding more accessible.
Any video decoder will require memory resources in order to process encoded frames, so the API would include a method to allocate those resources (create()). Decoders generally require very little configuring because they are expected to adapt to whatever supported bitstream is sent to them, but there are usually some configuration parameters to set, so the API should have a configuration method (configure()). For example, some decoders have an error concealment option and will either attempt to conceal bitstream errors or not. After initialization, the decoder should be ready to receive bitstream data (decode()). Each video frame is usually divided into multiple pieces in the bitstream. The decode function should accept these pieces, and will not always return an image. It should be able to inform the application when a new image is ready. Then the application will call either the same function, or a different function to get the image data (get_image()). Decoders usually allocate image buffers themselves, so this function will likely return a pointer to the image data. When the decoder is no longer needed, its memory resources can be de-allocated (destroy()).