Creating a Codec Server
2-12
2.2.3.2 Specifying "Scratch Group" and DMA Resources for a
Codec
When you put together several codecs into a single DSP server, you may
need to make them share memory and DMA resources.
Two codecs can share what is called a "scratch" memory. This is a
working memory area, typically in fast internal memory, that is initialized
before one frame of data is processed and discarded afterwards. The
codecs can share this memory only if they run at the same priority. That
is, one cannot preempt another and thus destroy the other codec's
scratch area in the middle of its work.
Scratch area sharing is managed by the DSP algorithm memory manager
called DSKT2, but you can affect how it manages the scratch areas by
defining the optional groupId field for each algorithm in the array of
Server.algs[] configuration.
If you do not set the groupId field, no sharing will take place. This is fine
if you have enough internal/external memory. Otherwise, you can set it
per algorithm, as is the case in the video_copy server example:
/* The array of algorithms this server can serve up.
* This array also configures details about the threads
* that will be created to run the algorithms
* (e.g. stack sizes, priorities, etc.). */
Server.algs = [
{
name: "viddec_copy", // C name for the of codec
mod: VIDDEC_COPY, // VIDDEC_COPY defined above
threadAttrs: {
stackMemId: 0, // BIOS MEM seg ID for task stack
priority: Server.MINPRI + 1 // task priority
},
groupId: 0, // scratch group ID (see DSKT2 below)
},
{
name: "videnc_copy",
mod: VIDENC_COPY,
threadAttrs: {
stackMemId: 0,
priority: Server.MINPRI + 1
},
groupId: 0,
},
];