EMS memory management process in a kind of audio/video decoding course
Technical field
The present invention relates to a kind of memory management technology, especially relate to the EMS memory management process in a kind of audio/video decoding course.
Background technology
In data communication system, transport stream is made up of continuous transport stream packets, each transport stream packets has fixing length, length is 188 bytes, wherein the header packet information of transport stream packets is minimum occupies 4 bytes, and promptly the audio frequency and video PES information that comprises in the pay(useful) load of each transport stream packets is occupied 184 bytes at most.The decode procedure of audio frequency and video at first constitutes the transport stream decomposition and combination audio frequency and video PES grouping bag by demodulation multiplexer usually, audio frequency and video PES grouping bag is made of the audio frequency and video PES information in several transport stream packets, further parsing audio frequency and video from audio frequency and video PES grouping bag by demodulation multiplexer again flows substantially, the audio frequency and video that audio frequency and video PES information analysis in the transport stream packets in the audio frequency and video PES grouping bag obtains flow substantially at most also occupies 184 bytes, and the audio frequency and video that parse are flowed in the write memory zone substantially, audio/video decoder from region of memory, extract again audio frequency and video substantially stream further decode.But the memory size of the region of memory that uses in this audio/video decoding course is extremely limited, when the reading rate of audio/video decoder during greater than the writing rate of demodulation multiplexer, when being the write pointer of read pointer transcendental solution multiplexer of audio/video decoder, get the sky phenomenon with occurring, thereby cause the audio frequency and video of audio/video decoder read error to flow substantially; And when the writing rate of demodulation multiplexer during greater than the reading rate of audio/video decoder, be that the write pointer of demodulation multiplexer is when surmounting the read pointer of audio/video decoder, phenomenon to occur covering, and flow the audio frequency and video that newly stored into region of memory substantially and flow covering substantially thereby cause being stored in some useful audio frequency and video in the region of memory.In the above two kinds of cases, all will make whole audio/video decoding course produce serious problems, promptly audio frequency and video flow substantially misreads or loses.
For avoiding the appearance of the problems referred to above, the method that can adopt the write pointer of the read pointer of audio/video decoder or demodulation multiplexer to wait for, promptly or demodulation multiplexer stand by tone Video Decoder read audio frequency and video in the whole blocks region of memory and can not continue to write audio frequency and video before flowing substantially and flow substantially to region of memory, perhaps audio/video decoder is waited for that demodulation multiplexer is write and can not be read audio frequency and video before the whole blocks region of memory and flow substantially, but the method that this read pointer or write pointer are waited for will have a strong impact on the service efficiency of region of memory, cause the waste of memory source, also reduced decode rate simultaneously.
Summary of the invention
Technical problem to be solved by this invention provides a kind ofly can effectively be avoided audio frequency and video in the region of memory to flow substantially being got sky or be capped, and improves the EMS memory management process in the audio/video decoding course of service efficiency of region of memory.
The present invention solves the problems of the technologies described above the technical scheme that is adopted: the EMS memory management process in a kind of audio/video decoding course, in the audio/video decoding course of data communication system, utilize demodulation multiplexer that the transport stream decomposition and combination is constituted audio frequency and video PES grouping bag, and from audio frequency and video PES grouping bag, parse audio frequency and video and flow substantially, the audio frequency and video that parsing obtained by demodulation multiplexer flow in the write memory zone substantially then, utilize again audio/video decoder from region of memory, extract audio frequency and video substantially stream decode, utilize data structure to indicate audio frequency and video in audio/video decoding course and flow information in region of memory substantially, the CPU of data communication system is by setting up data structure, the service data structure, use data structure, process unified management audio frequency and video such as release data structure flow the storage in region of memory substantially and read.
Be provided with in the described data structure and be used for characterizing audio frequency and video and flow corresponding list item substantially in the information of region of memory.
Described EMS memory management process comprises following concrete steps:
A. set up data structure: region of memory is divided into a plurality of memory blocks, and to set up one be the memory block chained list of node with the memory block, each memory block correspondence in the memory block chained list establishes a data structure; When demodulation multiplexer will be resolved audio frequency and video PES grouping bag, judge that whether CPU allocates free space to the memory block of demodulation multiplexer in advance less than 184 bytes, if less than 184 bytes, then demodulation multiplexer is applied for next memory block to CPU, CPU satisfies the internal memory application of demodulation multiplexer, and the empty list information of the memory block of the firm application of foundation, demodulation multiplexer audio frequency and video that parsing is obtained flow in the memory block that successively writes pre-assigned memory block and application just substantially then, at this moment, the free space of pre-assigned memory block has been write full; Otherwise the audio frequency and video that parsing is obtained flow in the pre-assigned memory block of one-time write substantially; Whether the size of the free space by judging pre-assigned memory block meets the demands, and can effectively avoid resolving the spillover that may occur when the audio frequency and video that obtain flow the one-time write memory block substantially;
B. service data structure: when demodulation multiplexer was write the memory block of firm application, when the original position of the audio frequency and video PES grouping bag of just having resolved, demodulation multiplexer sent interrupt requests to CPU, and resolving information is provided; The resolving information that CPU gives by demodulation multiplexer is safeguarded the corresponding list item of the data structure of memory block correspondence to be written;
C. use data structure: having decoded when audio/video decoder is stored in after the audio frequency and video in the memory block flow substantially, stores the next memory block that audio frequency and video to be decoded flow substantially to the CPU application; Write full audio frequency and video and flow substantially if store in the memory block of application by demodulation multiplexer is complete, then CPU satisfies the application of audio/video decoder; Otherwise the memory block of audio/video decoder wait application is expired by complete writing; Satisfy the application of audio/video decoder as CPU after, the decode procedure that corresponding list item control store the audio frequency and video in this memory block of audio/video decoder by the data structure of this memory block correspondence flow substantially;
D. discharge data structure: when audio/video decoder to be stored in the audio frequency and video in the memory block flow substantially the decoding finish, and success to CPU application is complete when writing the next memory block that audio frequency and video completely to be decoded flow substantially, CPU regains the memory block that audio/video decoder has been decoded and finished, and discharges the corresponding list item of the data structure of this memory block correspondence.
Described resolving information comprises the initial address of audio frequency and video PES grouping bag and whether PTS (Presentation TimeStamp shows timestamp)/DTS (Decode Time Stamp, decoded time stamp) sign is arranged.
Whether the information of the corresponding list item of described data structure comprises PTS/DTS sign, the initial address of audio frequency and video PES grouping bag, whether be new audio frequency and video PES grouping bag or the continuation of previous audio frequency and video PES grouping bag, the initial address of memory block, length, the audio frequency and video type of memory block, the pointer that points to next node and indication memory block sky, full, demodulation multiplexer is write or decoder is read attribute.
Compared with prior art, the invention has the advantages that utilizing data structure to indicate audio frequency and video flows information in region of memory substantially in the audio/video decoding course of data communication system, the CPU of data communication system is by setting up data structure, the service data structure, use data structure, process unified management audio frequency and video such as release data structure flow the storage in region of memory substantially and read, avoided audio frequency and video in the region of memory to flow substantially effectively being got sky or be capped, thereby improved the service efficiency of region of memory, improved the decode rate of audio/video decoder.
Description of drawings
Fig. 1 is the schematic diagram of setting up of data structure of the present invention;
Fig. 2 is the schematic diagram of safeguarding of data structure of the present invention;
Fig. 3 is the use schematic diagram of data structure of the present invention;
Fig. 4 is the release schematic diagram of data structure of the present invention.
Embodiment
Embodiment describes in further detail the present invention below in conjunction with accompanying drawing.
For the synchronization mechanism that adopts in the transmission flow demultiplexing technology, the synchronization mechanism that some correlative study achievements mainly provide audio/video decoding and represented, mainly used demonstration timestamp (PTS in this synchronization mechanism, Presentation TimeStamp) and decoded time stamp synchronous information such as (DTS, Decode Time Stamp) be used to realize Voice ﹠ Video synchronously.Show that timestamp (PTS) is used for the Synchronization Control between video and the audio frequency, its indication is to the suitable moment of decoding rear video and voice playing.Decoded time stamp (DTS) is used for the Synchronization Control of video-frequency basic flow decoder and the basic stream decoder of audio frequency, and its indication is flowed the rate control information that suitable moment of decoding flows substantially substantially to video and audio frequency.Yet how to distribute in region of memory and manage for showing that timestamp (PTS) and the decoded time stamp corresponding audio frequency and video of synchronous information such as (DTS) flow substantially, the service efficiency and the decode rate of raising region of memory also are significant.
EMS memory management process in a kind of audio/video decoding course of the present invention, in the audio/video decoding course of data communication system, utilize demodulation multiplexer that the transport stream decomposition and combination is constituted audio frequency and video PES grouping bag, and from audio frequency and video PES grouping bag, parse audio frequency and video and flow substantially, the audio frequency and video that parsing obtained by demodulation multiplexer flow in the write memory zone substantially then, utilize again audio/video decoder from region of memory, extract audio frequency and video substantially stream decode, utilize data structure MemoryList to indicate audio frequency and video in audio/video decoding course and flow information in region of memory substantially, the CPU of data communication system is by setting up data structure, the service data structure, use data structure, process unified management audio frequency and video such as release data structure flow the storage in region of memory substantially and read.
Be provided with among the data structure MemoryList and be used for characterizing audio frequency and video and flow corresponding list item substantially in the information of region of memory, whether the information spinner of this corresponding list item will comprise the PTS/DTS sign, the initial address of audio frequency and video PES grouping bag, whether be new audio frequency and video PES grouping bag or the continuation of previous audio frequency and video PES grouping bag, the initial address of memory block, length, the audio frequency and video type of memory block, the pointer that points to next node and indication memory block sky, full, demodulation multiplexer is write or decoder is read attribute.The variable of corresponding list item correspondence is as shown in table 1.
Variable in table 1 data structure and corresponding list item table
Variable |
Describe |
haveptsordts[MAX_NUMBER_OF_PES] |
Whether the PTS/DTS sign is arranged |
pts[MAX_NUMBER_OF_PES] |
PTS |
dts[MAX_NUMBER_OF_PES] |
DTS |
pes_start_addr[MAX_NUMBER_OF_PES] |
The initial address of audio frequency and video PES grouping bag |
isfirstdatacontinuation |
Whether be the beginning that new audio frequency and video PES grouping is wrapped, the continuation of still previous audio frequency and video PES grouping bag |
buffer |
The initial address of memory block |
blocklength |
The length of memory block |
audiovideotype |
The audio frequency and video type |
nextvideobuffer |
Point to the pointer of next node |
blockattribution |
The sky of indication memory block, full, demodulation multiplexer is write, decoder is read this four kinds of attributes |
The code description of data structure MemoryList is as follows:
struct MemoryList
{
int2 haveptsordts;
int33 pts,dts;
long int pes_start_addr;
bool isfirstdatacontinuation;
lont int buffer;
int blocklength;
int13 audiovideotype;
MemoryList * nextvideobuffer;
int blockattribution;
};
This EMS memory management process mainly comprise data structure foundation, safeguard, use and discharge four steps, below will do concrete description.
A. set up data structure: as shown in Figure 1, audio frequency and video are flowed the region of memory of storing substantially logically be divided into 8 memory blocks in internal memory, and the memory block chained list that to establish be node with 8 memory blocks, each memory block correspondence in the memory block chained list establishes a data structure; When demodulation multiplexer will be resolved audio frequency and video PES grouping bag, judge that whether CPU allocates free space to the memory block of demodulation multiplexer in advance less than 184 bytes, if less than 184 bytes, then demodulation multiplexer is applied for next memory block to CPU, CPU satisfies the internal memory application of demodulation multiplexer, and the empty list information of the memory block of the firm application of foundation, demodulation multiplexer audio frequency and video that parsing is obtained flow in the memory block that successively writes pre-assigned memory block and application just substantially then, at this moment, the free space of pre-assigned memory block has been write full; Suppose that current pre-assigned memory block is the 4th memory block, if the free space of current the 4th memory block is less than 184 bytes, then demodulation multiplexer is applied for next memory block (i.e. the 5th memory block) to CPU, CPU satisfies the internal memory application of demodulation multiplexer, and the attribute of the 4th memory block (Demux) changed to " expiring " (FULL) by " demodulation multiplexer is write ", the attribute of the 5th memory block just having applied for (NULL) is changed to " demodulation multiplexer is write " (Demux) by " sky ", set up the empty list information of the 5th memory block of application just simultaneously, again audio frequency and video are flowed substantially priority and write the 4th memory block and the 5th memory block, make the 4th memory block be expired by complete writing; Otherwise the audio frequency and video that parsing is obtained flow in pre-assigned the 4th memory block of one-time write substantially; Whether the size of the free space by judging pre-assigned memory block meets the demands, and has avoided resolving the spillover that may occur when the audio frequency and video that obtain flow the one-time write memory block substantially;
B. service data structure: as shown in Figure 2, when audio frequency and video when stream writes the 5th memory block of firm application substantially, when the original position of the audio frequency and video PES grouping bag of just having resolved, demodulation multiplexer sends interrupt requests to CPU, and the initial address of audio frequency and video PES grouping bag is provided and whether a series of resolving informations such as PTS/DTS sign are arranged; The resolving information that CPU gives by demodulation multiplexer is safeguarded the corresponding list item of the data structure of the 5th memory block correspondence to be written;
C. use data structure: as shown in Figure 3, what suppose the current decoding of audio/video decoder is to be stored in the 1st audio frequency and video in the memory block to flow substantially, decoded when audio/video decoder and to be stored in after the 1st audio frequency and video in the memory block flow substantially, just store the next memory block that audio frequency and video to be decoded flow substantially, i.e. the 2nd memory block to the CPU application; Write full audio frequency and video and flow substantially if store in the 2nd memory block of application by demodulation multiplexer is complete, then CPU satisfies the application of audio/video decoder; Otherwise the memory block of audio/video decoder wait application is expired by complete writing; Satisfy the application of audio/video decoder as CPU after, audio/video decoder has the right of eminent domain completely to the 2nd memory block, the decode procedure that corresponding list item (mainly be the PTS and the DTS that characterize synchronizing information) control store the audio frequency and video in this memory block of audio/video decoder by the data structure of this memory block correspondence flow substantially; Also need whether to exist to cover and make pre-judgement to having stored memory block that audio frequency and video flow substantially in a period of time in future, if there be possibility that covers, the extraction efficiency that flows substantially of CPU control audio/video decoder raising audio frequency and video then;
D. discharge data structure: as shown in Figure 4, suppose audio/video decoder just to be stored in the 1st audio frequency and video in the memory block flow substantially the decoding finish, and success to CPU application is complete when writing the next memory block (the 2nd memory block) that audio frequency and video completely to be decoded flow substantially, CPU regains the memory block that audio/video decoder has been decoded and finished, from the memory block chained list, discharge the node of the 1st memory block correspondence, its attribute (Dec) is changed to " sky " (NULL) by " decoder is read ", and the attribute of the 2nd memory block (FULL) is changed to " decoder is read " (Dec) by " expiring ".