Animation compression and decompressing method based on radio hand-held equipment
Technical field
The present invention relates to a kind of figure compression and decompressing method, particularly a kind of animation compression and decompressing method based on radio hand-held equipment.
Background technology
Current, the scope that various portable electric appts use in everybody life is very extensive, for example mobile phone, PDA, palm PC or the like.Along with the continuous development of multimedia technology, because multiple acoustooptic effect that it possessed, playing these multimedia messagess on above-mentioned portable electric appts is that users institute is expected jointly.
Radio hand-held equipments such as present mobile phone, PDA also can't be mentioned in the same breath with PC, all can't compare with PC at aspects such as operational performance, reading speeds.And the basic demand of animation is to play some frames continuously, causes very big being not suitable for of animated content to be transmitted, so when preserving animated content, need compress.
Existing cartoon compressing method is divided into two classes:
1. each content frame is compressed respectively, decompressing frame by frame when playing then shows.These class methods realize simple, but compressibility is often very undesirable.
2. animated content is looked as a whole, color signal is separated with luminance signal and carrier chrominance signal, make lossy compression method then.
Method one is compressed the picture of animation data as a width of cloth width of cloth single frames, does not have the continuity that has between considered frame and the frame.Method two is for the radio hand-held equipment of low configuration, and operand is too big.
Common compression algorithm is the difference of utilizing between frame and the frame in the radio hand-held equipment at present, only preserve difference part with respect to former frame, like this in the process that animation generates, can produce many little rectangle pictures not of uniform size, when playing because the limitation of wireless device processes speed, cause the animation broadcasting speed slow excessively, and above-mentioned traditional cartoon compressing method need be a cost with the color depth of sacrificing animation, the play quality of sacrificing animation.But animation file is made of the similar figure of a series of contents, has very big correlativity between frame and the frame usually.How to find correlativity between frame and the frame is a difficult point in the animation compression always.
Summary of the invention
The present invention is the deficiency that overcomes above-mentioned prior art, and the technical problem to be solved in the present invention provides a kind of animation compression and decompressing method based on radio hand-held equipment, to solve the animation Fast Compression and the decompress(ion) of high compression ratio.
For solving the problems of the technologies described above, technical scheme of the present invention is:
A kind of cartoon compressing method based on radio hand-held equipment may further comprise the steps:
Step (1) is got first frame data stream of animation sequence, and compresses this frame data;
Step (2) comprises the following steps: again from the data compression of second frame
(2.1) get frame animation data;
(2.2) successively the preceding N frame data of these frame data and described animation sequence are done step-by-step XOR behaviour
Do, obtain the data D behind the step-by-step XOR
1, D
2..., D
N, wherein step-length N is a positive integer;
(2.3) described N data D of compression
1, D
2..., D
N, obtain N packed data
C
1、C
2、...、C
N;
(2.4) compress the animation raw data of this frame, obtain packed data P;
(2.5) more described N+1 packed data C1, C2 ..., the length of CN and P, get the animation packed data of the packed data of length minimum wherein as this frame;
(2.6) will be therewith the frame XOR frame number of making the step-by-step xor operation be stored in the internal memory, if the packed data of the length minimum described in the step 2.5 is the packed data P of animation raw data, then the numbering with this initial data frame is stored in the internal memory.
(2.7) judge that whether the animation data compression finishes, if finish, changes step 3; If not, change step 2.1, continue the compression of next frame data;
Step (3) is packaged into animation data file with each frame packed data, may further comprise the steps:
(3.1) write the header file of animation data;
(3.2) the storage first frame animation packed data;
(3.3) the storage first frame animation packed data length;
(3.4) take off data after the compression of a frame animation;
(3.5) store the animation packed data, data length of this frame, the XOR frame number related with this frame;
(3.6) if animation frame has been a last frame, then change step 3.7; Otherwise change step 3.4;
(3.7) finish.
What use in step 1, step 2.3 and the step 2.4 is the dictionary compression algorithm.
The compression algorithm of using in step 1, step 2.3 and the step 2.4 is LZ77, LZSS, LZW, LZA or LZH algorithm.
Step-length N in the step 2.2 radio hand-held equipment free memory quantity when decompressing determines that N is big more, and needed interim internal memory is also big more during decompress(ion).
Step-length N value in the step 2.2 is 1~4.
File header described in the step 3.1 mainly stores the essential information of animation, comprises the identifier of animation file, the height of animation, the width of animation, the step-length that the animation compression is used, the color depth of animation.
A kind of animation decompressing method based on radio hand-held equipment, corresponding to above-mentioned cartoon compressing method based on radio hand-held equipment, this animation decompressing method may further comprise the steps:
Step (A) reads the file header data of animation file, obtain the width of animation, highly, color depth and step-length N; According to the original length of step-length N and animation data, prepare N internal storage data piece, generating a length is the formation of N, and empties formation, N is a positive integer;
Step (B) is got the animation packed data of first frame, and the dictionary compression algorithm of using during according to compression is called the raw data that corresponding decompression algorithm obtains first frame, and this raw data is added formation according to first in first out;
Step (C) makes that the initial value of positive integer n is 2, comprises the following steps: again from the data decompression of second frame
(C1) get the packed data of n frame animation;
(C2) get the XOR frame number corresponding with the packed data of n frame animation;
(C3) obtain its corresponding XOR frame raw data by this XOR frame number, promptly relevant key frame data with this n frame animation, this XOR frame raw data finds from fifo queue;
(C4) to the packed data of this n frame animation, the dictionary compression algorithm of using during according to compression is called corresponding decompression algorithm decompress(ion) animation data;
(C5) if the key frame of this n frame animation is numbered itself, then change step (D), otherwise, the key frame data of gained among the decompressed data of this n frame and the step C3 is made xor operation, obtain the raw animation data of this n frame, the raw animation data of this n frame is joined in the formation.Step (D) judges whether the animation data decompress(ion) finishes, if finish, changes step e; If not, then n=n+1 changes step C1, continues the decompress(ion) of next frame data;
Step (E) finishes.
Decompressing method among described steps A, B and the C4 is the corresponding decompression algorithm of using with when compression of dictionary compression algorithm.
Compared with prior art, the invention has the beneficial effects as follows:
The inventive method adopts the local method of XOR in twos between frame and the frame, has fully excavated the relevance between each frame of animation, has improved ratio of compression.Another one advantage of the present invention is that this cartoon compressing method is not sacrificed the animation quality, does not change the original color depth of animation, and compression process also adopts lossless compression algorithm fully, has kept the original effect of animation to greatest extent.
Animation Compress softwares by flow implementation of the present invention, can obtain 20: 1~40: 1 animation compressibility to general animation, and the broadcast of animation is also faster than existing other compression methods, in frequency of operation is the ARM7TDMI processor platform of 39MHZ, resolution is that the color animation speed of playing on the QVGA LCD screen of 320 * 240 pixels can reach for 10 frame/seconds, and the animation that adopts traditional approach to play, its animation broadcasting speed can only reach for 5 frame/seconds.
The present invention had both considered the decompress(ion) efficiency that animation is play, and had taken into account the animation data size issue again, was the good solution that animation is play in the radio hand-held equipment.
Description of drawings
Fig. 1 is animation compression set figure of the present invention.
Fig. 2 is animation decompression device figure of the present invention.
Fig. 3 is the process flow diagram of cartoon compressing method of the present invention.
Fig. 4 is the packing data process flow diagram of animation file of the present invention.
Fig. 5 is the process flow diagram of animation decompressing method of the present invention.
Embodiment
Specific embodiments of the present invention are further described in detail below in conjunction with drawings and Examples, but should not limit protection scope of the present invention with this.
The present invention is based on the animation Compress softwares method of radio hand-held equipment, it may further comprise the steps:
(1) the animation compression set is responsible for raw animation data is become animation data and is packaged into animation file by specific compression algorithm.
(2) the animation compression set will compress good data by output device and be sent in the storer of radio hand-held equipment.
When (3) showing, radio hand-held equipment, is sent in the display device then and shows animation data decompress(ion), reduction according to certain decompression algorithm.
The hardware implementation platform that the present invention is based on the animation compression of radio hand-held equipment and decompressing method as depicted in figs. 1 and 2.Fig. 1 is animation compression set figure of the present invention.Animation compression set 01 is responsible for raw animation data is compressed into animation data, and is packaged into animation file.The animation compression set will compress good animation data by output device 02 and output in the radio hand-held equipment, and the animation data that radio hand-held equipment then will import into by input equipment 03 is deposited in the internal storage of radio hand-held equipment 04.The animation compression set of indication of the present invention can be general common PC equipment, and input-output device can adopt USB, serial communication interface etc.
Fig. 2 is animation decompression device figure of the present invention.Animation decompression device of the present invention adopts radio hand-held equipment 04, comprises keyboard 12, antenna 13, radio-frequency module 18, speech processor 20, and its central processing unit 10 is by being stored in all operations of the control program control radio hand-held equipment 04 in the storer 14.This control program has adopted animation compression of the present invention, decompressing method.The user will compress good animation data in advance and store in the storer 14 by external interface device, and external interface device can adopt USB, serial communication interface etc.When the user need show animation, the animation decompressing method unziped to animation in the internal memory 11 according to the present invention for central processing unit 10, animation data is sent in the display 16 to show then.
Fig. 3 is the process flow diagram of cartoon compressing method of the present invention.As shown in Figure 3, the present invention is based on the cartoon compressing method of radio hand-held equipment, may further comprise the steps:
Step (1) animation compression set is at first got first frame data stream of animation sequence, and compresses this frame data;
Step (2) comprises the following steps: again from the data compression of second frame
(2.1) get frame animation data;
(2.2) successively the preceding N frame data of these frame data and described animation sequence are made the step-by-step xor operation, obtain the data D behind the step-by-step XOR
1, D
2..., D
N, wherein step-length N is a positive integer;
(2.3) described N data D of compression
1, D
2..., D
N, obtain N packed data C
1, C
2..., C
N
(2.4) compress the animation raw data of this frame, obtain packed data P;
(2.5) more described N+1 packed data C1, C2 ..., the length of CN and P, get the animation packed data of the packed data of length minimum wherein as this frame;
(2.6) will be therewith the frame XOR frame number of making the step-by-step xor operation store in the interim memory headroom of animation compression set, final squeeze operation can be written to packed data in the animation file after finishing, and empties this internal memory.If that the length minimum is the packed data P of raw data, then store the numbering of initial data frame.For key frame is the processing of initial data frame, and the XOR frame that can go during decompress(ion) to seek this frame correspondence removes XOR, if the XOR frame is exactly itself, does not then need to handle.
(2.7) judge that whether the animation data compression finishes, if finish, changes step 3; If not, change step 2.1, continue the compression of next frame data;
Step (3) Fig. 4 is the packing data process flow diagram of animation file of the present invention.This animation file form is made of file header and data two parts.File header mainly stores the essential information of animation, comprises the identifier of animation file, the height of animation, the width of animation, the step-length that the animation compression is used, color depth of animation or the like.The data of each frame after the main store compressed of data division, data length, XOR frame number related or the like with this frame.
As shown in Figure 4, each frame packed data is packaged into animation data, may further comprise the steps:
(3.1) write the header file of animation data; Described file header mainly stores the essential information of animation, comprises the identifier of animation file, the height of animation, the width of animation, the step-length that the animation compression is used, the color depth of animation.
(3.2) the storage first frame animation packed data;
(3.3) the storage first frame animation packed data length;
(3.4) take off a frame animation packed data;
(3.5) store the animation packed data, data length of this frame, the XOR frame number related with this frame;
(3.6) step 3.7 is changeed in the end if animation frame has been packed; If no, change step 3.4;
(3.7) finish.
The selection N of related step-length among the present invention, radio hand-held equipment free memory quantity is decided in the time of need be according to decompress(ion).In general, N is big more, and needed interim internal memory is also big more during decompress(ion), and ratio of compression is also high more.Therefore, the selection of N need take into account the memory size of concrete radio hand-held equipment and the size of animation resolution.At little memory environment or high-resolution animation, N can select 1 or 2, and at the animation data of big memory environment or low resolution, N can select 3~4 or higher, temporarily being calculated as of computational space: N* animation length * animation width * animation color depth.With 10 frame resolution is 240*320, and color depth is the animation data of 2 bytes, and the needed interim computational space size of decompress(ion) animation is the N*240*320*2 byte.
What use in above-mentioned steps 1, step 2.3 and the step 2.4 all is the dictionary compression algorithm.Related among the present invention all is typical dictionary compression algorithm, comprises that LZ77, LZSS, LZW, LZA or LZH etc. are multiple.Above-mentioned algorithm all has a general character in compression during graphic documentation, and promptly the relation of the complexity of data and compressibility is very big, that is to say, the area that accounts for when the content of figure minority color is big more, and compressibility is also high more.At these characteristics, the present invention makes an XOR with a certain frame animation data and former frame, because XOR has following characteristics: if two binary digits are identical, then get 0; Otherwise, then get 1.Therefore, if the data similarity of two images is big more, it is many more then to contain 0 number, and compressibility is also high more; Otherwise it is quite different.Based on this, the present invention finds out the animation frame the most approaching with present frame by this algorithm, if can't find the most approaching animation frame that matches, illustrates that then this frame is an independent frame, uses raw data to compress.
Fig. 5 is the process flow diagram of animation decompressing method of the present invention.As shown in Figure 5,, the present invention is based on the animation decompressing method of radio hand-held equipment, may further comprise the steps corresponding to above-mentioned cartoon compressing method based on radio hand-held equipment:
Step (A) is read the file header data of animation file, obtain the width of animation, highly, color depth and step-length N; These contents are written in the file header data of animation file during compression, the file header data that read animation file can obtain these contents.
According to the original length of step-length N and animation data, prepare N internal storage data piece, generating a length is the formation of N, and empties formation;
Step (B) is got the animation packed data of the 1st frame, and the dictionary compression algorithm of using during according to compression is called the raw data that corresponding decompression algorithm obtains first frame, and this raw data is added formation according to first in first out;
Step (C) makes that the initial value of positive integer n is 2, comprises the following steps: again from the data decompression of second frame
(C1) get the packed data of n frame animation;
(C2) get the XOR frame number corresponding with the packed data of n frame animation;
(C3) obtain its corresponding XOR frame raw data by this XOR frame number, this raw data can find from fifo queue;
(C4) to the packed data of this n frame animation, the dictionary compression algorithm of using during according to compression is called corresponding decompression algorithm decompress(ion) animation data;
(C5) decompressed data of this n frame and the key frame data described in the step C3 are made xor operation, obtain the raw animation data of n frame;
Step (D) judges whether the animation data decompress(ion) finishes, if finish, changes step e; If not, then n=n+1 changes step C1, continues the decompress(ion) of next frame data;
Step (E) finishes.
In sum, embodiment of the present invention is based on hardware platform illustrated in figures 1 and 2 and realizes, both having considered the decompress(ion) efficiency that animation is play, and taken into account the animation data size issue again, is the good solution that animation is play in the radio hand-held equipment.
The above is preferred embodiment of the present invention only, is not to be used for limiting practical range of the present invention.Be that all equivalences of doing according to the content of the present patent application claim change and modification, all should be technology category of the present invention.