bg_codec_plugin_t
defined in gmerlin/plugin.h
. In addition to the common stuff (creation, destruction, setting parameters), there are a number of functions, which are specific to codec functionality. For decompression these are:gavl_audio_source_t * (*connect_decode_audio)(void * priv,
gavl_packet_source_t * src,
const gavl_compression_info_t * ci,
const gavl_audio_format_t * fmt,
gavl_metadata_t * m);
gavl_video_source_t * (*connect_decode_video)(void * priv,
gavl_packet_source_t * src,
const gavl_compression_info_t * ci,
const gavl_video_format_t * fmt,
gavl_metadata_t * m);
The decompressor will get the compressed packets from the packet source. Additional arguments are the compression info, the format (which might be incomplete) and the metadata of the A/V stream. They return an audio- or video source, from where you can read the uncompressed frames.
For opening a compressor, we need to call one of:
gavl_audio_sink_t * (*open_encode_audio)(void * priv,
gavl_compression_info_t * ci,
gavl_audio_format_t * fmt,
gavl_metadata_t * m);
gavl_video_sink_t * (*open_encode_video)(void * priv,
gavl_compression_info_t * ci,
gavl_video_format_t * fmt,
gavl_metadata_t * m);
gavl_video_sink_t * (*open_encode_overlay)(void * priv,
gavl_compression_info_t * ci,
gavl_video_format_t * fmt,
gavl_metadata_t * m);
It will return the sink where we can push the A/V frames. The other arguments are the same as if we open a decoder, but in this case they will be changed by the call. After opening the compressor and before passing the first frame, we need to set a packet sink where the compressed packets will be written:
void (*set_packet_sink)(void * priv, gavl_packet_sink_t * s);
The decompressors work in pull mode, the compressors work in push mode. These are the most suitable modes in typical usage scenarios.
The potential delay between compressed packets and uncompressed frames is handled internally. The decompressor simply reads enough packets to it can output one uncompressed frame. The compressor outputs compressed frame as they become available. When the compressor is destroyed, it might flush it's internal state resulting in one or more compressed packets to be written. This means that at the moment you destroy a compressor, the packet sink must still be able to accept packets.
There are decompressor plugins as part of gmerlin-avdecoder, which handle most formats. The gmerlin-encoders package contains compressor plugins for most formats as well.
No comments:
Post a Comment