Summary of the invention
Technical problem to be solved by this invention is, a kind of Apparatus and system that is used for the method for Discarded Packets compensation and realizes Discarded Packets compensation is provided.Can save the data space that needs in the Discarded Packets compensation.
For this reason, on the one hand, embodiments of the invention provide a kind of lost packet compensation method, and described method is used for the transmission of Frame, comprising:
Obtain the frame loss condition of Frame;
According to described frame loss condition and Discarded Packets compensation algorithm Frame is carried out the Discarded Packets compensation processing, and will carry out storing behind the compressed encoding through the described Frame that Discarded Packets compensation is handled, this step comprises:
When described frame loss condition is that current data frame is not frame losing, when the last data frame of described current data frame is frame losing, according to first processing policy described current data frame is carried out described Discarded Packets compensation and handle;
To carry out being stored in first buffering area behind the compressed encoding through the current data frame that Discarded Packets compensation is handled;
Wherein, describedly according to first processing policy described current data frame is carried out described Discarded Packets compensation and handles and comprise:
Described current data frame is decoded;
The Frame that is stored in described first buffering area is decoded;
According to decoded Frame in described first buffering area decoded Frame of described current data frame is carried out smoothly;
To delaying time through the Frame after level and smooth.
On the other hand, embodiments of the invention provide a kind of device of realizing Discarded Packets compensation, and described device is used for carrying out Discarded Packets compensation according to the packet drop of data frame transfer, and this device comprises:
Acquisition module is used to obtain the frame loss condition of Frame;
Processing module is used for according to described frame loss condition and Discarded Packets compensation algorithm Frame being carried out the Discarded Packets compensation processing, wherein, in the Discarded Packets compensation algorithm, when needing to use the Frame of storing behind the coding, described Frame is decoded;
The code storage module, the Frame that is used for handling through Discarded Packets compensation carries out storing behind the compressed encoding;
Wherein, described processing module comprises first processing module, and being used for described frame loss condition is that current data frame is not frame losing, when the last data frame of current data frame is frame losing, according to first processing policy described current data frame is carried out Discarded Packets compensation and handles;
Described code storage module comprises first coding module, is used for the current data frame of handling through described Discarded Packets compensation is carried out being stored in first buffering area behind the compressed encoding;
Wherein, described first processing policy comprises:
Current data frame is decoded;
The Frame that is stored in first buffering area is decoded;
According to decoded Frame in first buffering area decoded Frame of current data frame is carried out smoothly;
To delaying time through the Frame after level and smooth.
On the other hand, embodiments of the invention provide a kind of system that realizes Discarded Packets compensation, and described system is used for carrying out Discarded Packets compensation according to the packet drop of data frame transfer, and described system comprises:
Acquisition module is used to obtain the frame loss condition of Frame;
Coding/decoding module, be used for Frame being carried out the Discarded Packets compensation processing according to described frame loss condition and Discarded Packets compensation algorithm, and will carry out storing behind the compressed encoding through the Frame that Discarded Packets compensation is handled, wherein, in the Discarded Packets compensation algorithm, when needing to use the Frame of coding back storage, described Frame is decoded;
Wherein, described coding/decoding module comprises:
Processing module is used for according to described frame loss condition and Discarded Packets compensation algorithm Frame being carried out the Discarded Packets compensation processing, wherein, in the Discarded Packets compensation algorithm, when needing to use the Frame of storing behind the coding, described Frame is decoded;
The code storage module, the Frame that is used for handling through described Discarded Packets compensation carries out storing behind the compressed encoding;
Described processing module comprises first processing module, and being used for described frame loss condition is that current data frame is not frame losing, when the last data frame of current data frame is frame losing, according to first processing policy described current data frame is carried out Discarded Packets compensation and handles;
Described code storage module comprises first coding module, is used for the current data frame of handling through described Discarded Packets compensation is carried out being stored in first buffering area behind the compressed encoding;
Wherein, described first processing policy comprises:
Current data frame is decoded;
The Frame that is stored in first buffering area is decoded;
According to decoded Frame in first buffering area decoded Frame of current data frame is carried out smoothly;
To delaying time through the Frame after level and smooth.
The scheme that adopts the embodiment of the invention to provide owing to during in static space, increased an encoding-decoding process in storage, makes data quantity stored reduce, and has saved in this method the demand to static space.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the invention, the technical scheme in the embodiment of the invention is clearly and completely described, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that is obtained under the creative work prerequisite.
In order to reduce the static storage that corresponding buffering area takies in the Discarded Packets compensation algorithm, a kind of lost packet compensation method is provided in the embodiment of the invention, be used for the transmission of Frame, as shown in Figure 1, this method comprises:
101, obtain the frame loss condition of Frame.
102, according to described frame loss condition and Discarded Packets compensation algorithm Frame is carried out the Discarded Packets compensation processing; Wherein, in the Discarded Packets compensation algorithm, when needing to use the Frame of coding back storage, described Frame is decoded.
103, will carry out storing behind the compressed encoding through the described Frame that Discarded Packets compensation is handled.。
Based on appendix I G.711 the lost packet compensation method described in the embodiment of the invention is described further below.
In the present embodiment, the Frame of the storage of indication in above-mentioned 103, the data of storing among the buffering area history of definition and the pitchbuf in can being meant G.711.The needed static storage of decoding is 817*16bit in G.711, and the space that 390*2*16bit is wherein arranged is first buffering area (or being called history) and second buffering area (or being called pitchbuf), and all the other are the memory block of its dependent variable.The compressed encoding of indication specifically can be in this example the 16bit digital coding is converted to the 8bit data among the A.If original buffering area be with the digital signal of 16bit (Digital Signal Processor DSP) realizes, so can be by the mode of combination storage through the data behind the coding, with the 8bit storage in the DSP of 16bit.So just buffering area history and pitchbuf memory space respectively can be deducted half, reach the purpose of saving memory space.
As shown in Figure 2, be the realization flow figure of lost packet compensation method in the embodiment of the invention.In this flow process, according to the situation difference of frame losing, carry out different processing, the black curve with 6 band arrows among the figure illustrates 6 kinds of different handling processes.And be called for short the history buffering area with H.
0, when the former frame of judging present frame and present frame is not frame losing, handles by flow process 0.Specifically comprise: use the new Frame that receives to upgrade the data of storing among the history, and this Frame is carried out decoding output again after the time-delay of 3.75ms.
1,, but when previous frame is frame losing, handles by flow process 1 when judging that present frame is not frame losing.Specifically comprise: the Frame to current reception is decoded;
The Frame that is stored among the history is decoded;
According to the result after the data decode of storing among the history, the decoded Frame of current data frame is carried out smoothly, to obtain better voice quality;
Then the Frame after level and smooth is carried out the time-delay of 3.75ms, so that export;
Simultaneously, the Frame after level and smooth is carried out compressed encoding, as the 16bit Frame is encoded to the 8bit Frame;
Frame behind the coding is stored among the history.
2,, and when being frame losing for the first time, handle by flow process 2 when judging that present frame is frame losing.Specifically comprise:
According to the Frame among the Data Update pitchbuf among the history, i.e. the consistency of the Frame of storing among pitchbuf and the history during maintenance packet loss first time;
Next the Frame among the pitchbuf (or history) after upgrading is decoded, decoded Frame can be stored in the extra buffer, as defines a pitchbuf_tmp[390] extra buffer.
Utilize the Frame of storing in the extra buffer again, calculate the primitive period phase, and the Frame of last 1/4 primitive period phase length in the extra buffer is saved in buffering area lastq[30] in the middle of, and the Frame of this 1/4 primitive period phase length carried out smoothly;
The Frame of 1/4 primitive period phase length after level and smooth is covered corresponding position in the extra buffer, and the data computation in the extra buffer after the utilization covering goes out 10ms offset data frame;
The 10ms data of the compensation that obtained in the last step are carried out 3.75ms time-delay back output;
Frame in the extra buffer is carried out being saved among history and the pitchbuf behind the compressed encoding, be stored in as mode in the corresponding stored zone of DSP with assembly coding.
3, when judging that present frame is the second time or frame losing for the third time, handle by flow process 3.Specifically comprise:
The data of storing among the history are decoded,, therefore also the Frame of storing among the pitchbuf is decoded because the Frame among this moment history and the pitchbuf is identical;
Decoded providing stored in the extra buffer, carried out corresponding renewal then, its renewal process is slightly different with the mode in the flow process 2, the relevant regulations in specifically can participating in G.711;
The 10ms offset data frame that data computation in the extra buffer after utilize upgrading makes new advances, and after the Frame that decodes among this offset data frame and the history superposeed, do smoothing processing;
The above-mentioned Frame of doing after the smoothing processing is carried out 3.75ms time-delay back output;
To store among history and the pitchbuf behind the above-mentioned Frame compressed encoding of doing after the smoothing processing.
4, when judging that present frame is fourth, fifth or six frame losing, handle by flow process 4.Specifically comprise:
The Frame of storing among the history is decoded, and this decoded result can store in the extra buffer, because the data among this moment history and the pitchbuf are identical, therefore also the Frame of storing among the pitchbuf is decoded;
Calculate the corresponding compensation result according to decoded Frame, and the Frame of integral body is carried out smoothing processing according to this compensation result;
To carry out 3.75ms time-delay back output through the Frame after the smoothing processing;
To store among history and the pitchbuf behind the above-mentioned Frame compressed encoding of doing after the smoothing processing.
5, when judging that present frame is the 7th time even more during the frame losing of high order, handles by flow process 6.Promptly surpass 6 times for continuous packet loss, it is " 0 " that the current frame data frame is all replenished, but still need to export with behind this complete " 0 " Frame time-delay 3.75ms, and use this dateout frame update history and pitchbuf, because Frame is complete " 0 ", can not carry out smoothly this output data frame this moment.
Wherein, in a certain idiographic flow branch in above-mentioned compensation method, all Frames of storing among history and the pitchbuf are not to need to establish a capital, just can finish the Discarded Packets compensation of this time such as a part of Frame that may only need to store among history and the pitchbuf, therefore the Frame that also can only need this part carries out the encoding and decoding processing, handle and needn't need the Frame of history and pitchbuf storage all to carry out encoding and decoding all, this just need optionally carry out encoding and decoding and handle to the Frame of storage, such as judging before storage, whether this partial data frame needs coding.This optionally coding and decoding processing method can increase certain algorithm complex, but owing to do not need the Frame of all storages is all carried out the encoding and decoding processing, therefore carrying out efficient can make moderate progress.
Adopt above-mentioned lost packet compensation method,, make data quantity stored reduce, saved in this method demand static space owing to during in static space, increased an encoding-decoding process in storage.
On the other hand, corresponding with above-mentioned lost packet compensation method, the embodiment of the invention also provides a kind of device of realizing Discarded Packets compensation, and as shown in Figure 3, this device comprises: acquisition module 1 is used to obtain the frame loss condition of Frame; Processing module 2 is used for according to described frame loss condition and Discarded Packets compensation algorithm Frame being carried out the Discarded Packets compensation processing, wherein, in the Discarded Packets compensation algorithm, when needing to use the Frame of storing behind the coding, described data is decoded; Code storage module 3, the Frame that is used for handling through Discarded Packets compensation carries out storing behind the compressed encoding.
Wherein, described processing module 2 can comprise part or all of (being to comprise whole situations as shown in Figure 4) in the following module:
First processing module 20, be used for when described frame loss condition be that current data frame is not frame losing, and the last data frame of current data frame carries out Discarded Packets compensation according to first processing policy to current data frame and handles when being frame losing; First coding module is used for the current data frame of handling through Discarded Packets compensation is carried out being stored in first buffering area behind the compressed encoding.
First processing policy comprises: current data frame is decoded; The data that are stored in first buffering area are decoded; According to decoded data in first buffering area decoded data of current data frame are carried out smoothly; To delaying time through the data after level and smooth.
Second processing module 22, be used for when described frame loss condition be current data frame when being frame losing for the first time, according to second processing policy current data frame is carried out Discarded Packets compensation and handles;
Second processing policy comprises: according to Data Update second buffering area of described first buffering area; Frame to described first buffering area is decoded, and obtains the primitive period phase according to decoded Frame; The Frame of the last 1/4 primitive period phase length of the data in second buffering area after upgrading is carried out smoothly; Frame after level and smooth is replaced the Frame of corresponding last 1/4 primitive period phase length in described second buffering area; Go out the Frame of needs compensation according to the data computation after replacing; The described Frame of compensation that needs is delayed time.
The 3rd processing module 24, be used for when described frame loss condition be that current data frame is for the second time or during frame losing for the third time, according to the 3rd processing policy current data frame is carried out Discarded Packets compensation and handles;
The 3rd processing policy comprises: the Frame to described first buffering area or second buffering area is decoded; Decoded Frame is upgraded accordingly; Calculate the offset data frame according to the Frame after upgrading; Decoding in the described offset data frame and first buffering area is obtained to carry out smoothly the line delay of going forward side by side after the Frame stack.
The manages module 26 everywhere, be used for when described frame loss condition be current data frame when being fourth, fifth or six frame losing, according to the everywhere the reason strategy current data frame carried out Discarded Packets compensation handle;
The manages strategy everywhere comprises: the Frame to described first buffering area or second buffering is decoded; Calculate the corresponding compensation result according to decoded Frame, the overall data frame is carried out delaying time after the smoothing processing.
Accordingly, code storage module 3 comprised as one or more (Fig. 5 comprises whole situations) in the lower module:
Second coding module 30 is used for the current data frame of handling through Discarded Packets compensation is carried out being stored in first buffering area and second buffering area behind the compressed encoding;
The 3rd coding module 32 is used for the current data frame of handling through Discarded Packets compensation is carried out being stored in first buffering area and second buffering area behind the compressed encoding;
The 4th coding module 34 is used for the current data frame of handling through Discarded Packets compensation is carried out being stored in first buffering area and second buffering area behind the compressed encoding.
Wherein, above-mentioned processing module 2 and code storage module 3 can realize that this coding/decoding module 4 and acquisition module 1 can be physically separated devices, and can form a kind of system that realizes Discarded Packets compensation, as shown in Figure 6 by independent coding/decoding module 4.
Adopt above-mentioned Discarded Packets compensation device and system, owing to during in static space, increased an encoding-decoding process, because the Frame of storing in the static space has been carried out compressed encoding in storage, make the memory space of Frame reduce, reduced in this method demand static space.
Device embodiment described above only is schematically, and wherein said unit as the separating component explanation can or can not be physically to separate also, promptly can be positioned at a place, perhaps also can be distributed on a plurality of network element.Can select wherein some or all of module to realize the purpose of present embodiment scheme according to the actual needs.Those of ordinary skills promptly can understand and implement under the situation of not paying performing creative labour.
Through the above description of the embodiments, those skilled in the art can be well understood to each execution mode and can realize by the mode that software adds essential general hardware platform, can certainly pass through hardware.Based on such understanding, the part that technique scheme contributes to prior art in essence in other words can embody with the form of software product, this computer software product can be stored in the computer-readable recording medium, as ROM/RAM, magnetic disc, CD etc., comprise that some instructions are with so that a computer equipment (can be a personal computer, server, perhaps network equipment etc.) carry out the described method of some part of each embodiment or embodiment.
Above-described execution mode does not constitute the qualification to this technical scheme protection range.Any at above-mentioned execution mode spirit and principle within done modification, be equal to and replace and improvement etc., all should be included within the protection range of this technical scheme.