Method for video coding and video coding system
Technical field
The present invention relates to the digital processing field, relate in particular to the coding techniques in the video photograph album manufacturing process.
Background technology
Raising along with people's quality of life, increasing people wish to become VCD, DVD etc. can use the video file of family's video disc player broadcast the image makings such as digital photograph that digital camera is taken, so that do not watch under the computer situation having, so the video photograph album grows up gradually.Described video photograph album is exactly by a kind of video coding technique described photo to be made into the photograph album file of a video, is equipped with literal and voice for simultaneously every photo.
Described video coding technique is to utilize various mathematical measures that redundant informations a large amount of in the video is removed, and few data bit is represented video information with trying one's best.Utilize video coding technique mainly to remove the redundant information of three aspects in the original video:
1, faces the spatial redundancy that the correlation of pixel is brought mutually by every two field picture;
2, the time redundancy of bringing by the correlation of the relevant position pixel of facing two field picture mutually;
3, the coding redundancy that brings by the symbol correlation of coded representation method.
Video coding has two kinds of coding modes: intraframe coding and interframe encode.Intraframe coding only considers to remove the spatial redundancy that correlation that the every two field picture of video faces pixel is mutually brought, and does not consider to face mutually the time redundancy between two field picture.Interframe encode mainly adopts the predictive coding method to remove the time redundancy of facing mutually between two field picture.
In video coding process, the video coding technique that every two field picture adopted probably can be divided into three kinds: only adopt intraframe coding; Adopt the interframe encode of forward prediction; Adopt bi-directional predicted intraframe coding.The two field picture that the different video coding technique of sampling obtains after every two field picture is encoded also is different.
The two field picture that obtains after adopting first kind of intraframe coding technology that image is encoded is called I two field picture (Intra Pictures), and it is compression in the frame, does not rely on other frame, does not use motion compensation, and medium compression ratio is provided.Because the I frame do not rely on other frame,, be the reference frame in the decoding simultaneously so be random-accessly to go into a little.
The two field picture that obtains after the inter-frame coding of second kind of forward prediction of employing is encoded to image is called P two field picture (Predicted Pictures), its I frame or P frame according to the front is predicted, use movement compensating algorithm to compress, thereby compression ratio is than I vertical frame dimension, and data volume on average reaches about 1/3 of I frame.The P frame is the reference frame that the B frame of front and back and follow-up P frame are decoded.The P frame itself has error, if the previous reference frame of P frame also is the P frame, will cause error propagation.
The two field picture that obtains after adopting the third bi-directional predicted intraframe coding technology that image is encoded is called B two field picture (Bidirectional Pictures).Two I, P frame or P before and after it is based on, P frame interpolation are rebuild and the frame of formation, and the data volume that it compresses on average can reach about 1/9 of I frame.B frame itself is as benchmark, therefore can provide under the situation of higher compression ratio not propagated error.
In addition, when carrying out digital image compression,,, also can make use (Field) as unit for the video image of interlacing except using the above-mentioned frame unit.
The prior art relevant with the present invention provides a kind of method for video coding, and its main thought is: according to being to play the T demand in second in the file of V frame/second in frame per second, determine the coding number of times that need encode to a photo: V*T time; Read a photo then; Utilize existing coding techniques that described photo is encoded into I frame, P frame and B two field picture then, after the coding number of times is finished, read next photo again.
As can be seen, utilizing prior art that a photo is made in the process of video photograph album, is to play in the file of V frame/second T second in frame per second if desired, needs that then described photo is carried out V*T time and encodes.Making entire making process need expend a lot of times encodes.
Summary of the invention
The invention provides a kind of method for video coding and video coding system, it can shorten the shared time of coding in the video photograph album manufacturing process.
The present invention is achieved through the following technical solutions:
The invention provides a kind of method for video coding, it comprises:
Obtain the view data of an image correspondence;
The view data of being obtained is encoded, and behind coding, obtained at least one two field picture, but do not finish when encoding, utilize the frame data in the two field picture that has obtained to finish coding.
Wherein, describedly behind coding, obtained at least one two field picture, but do not finished when coding, utilized frame data in the two field picture that has obtained to finish the process of coding, specifically comprised:
Judge whether the quantity of the two field picture that has obtained arrives the quantity of the two field picture that need obtain, when confirming also no show, then the frame data in the described two field picture are copied to the back of the encoded two field picture that obtains, and calculating frame head, the frame head that calculates is filled into through duplicating the relevant position of the frame data that obtain, obtains corresponding two field picture; Otherwise, determine that cataloged procedure finishes.
Wherein, the described quantity that needs the two field picture of coding is that frame per second according to reproduction time and played file calculates.
Wherein, when the two field picture that obtained only is one behind the coding, described frame data in the described two field picture is copied to the back of the encoded two field picture that obtains, and calculate frame head, the frame head that calculates is filled into the process of the relevant position through duplicating the frame data that obtain, specifically comprises:
Frame data in the described two field picture are copied to the back of the encoded two field picture that obtains, and the frame head of the encoded two field picture that obtains is added 1, the frame head that calculates is filled into through duplicating the relevant position of the frame data that obtain.
Wherein, when the two field picture that obtained is a plurality of behind the coding, described frame data in the described two field picture is copied to the back of the encoded two field picture that obtains, and calculate frame head, the frame head that calculates is filled into the process of the relevant position through duplicating the frame data that obtain, specifically comprises:
Frame data in the described two field picture are copied to the back of the encoded two field picture that obtains, and the frame head of the encoded two field picture that obtains is added 1, the frame head that calculates is filled into through duplicating the relevant position of the frame data that obtain;
Or,
A plurality of frame data in the described two field picture are copied in groups the back of the encoded two field picture that obtains, and the frame head in the two field picture of the encoded frame head maximum that obtains added 1 successively, obtain respectively the frame head that calculates being filled into through duplicating the relevant position of the frame data that obtain through duplicating the frame head of a plurality of frame data correspondences that obtain.
The present invention also provides a kind of video coding system, and it comprises:
Data acquisition unit and coding unit;
Described data acquisition unit is used to obtain the view data of an image correspondence;
Described coding unit is used for the view data of being obtained is encoded, and has obtained at least one two field picture behind coding, but does not finish when encoding, and utilizes the frame data in the two field picture that has obtained to finish coding.
Wherein, described coding unit comprises:
Judging unit and two field picture processing unit;
Described judging unit is used to judge whether the two field picture quantity that has obtained arrives the quantity of the two field picture that need obtain, and the two field picture quantity that will obtain also the judged result of the quantity of the no show two field picture that need obtain send described two field picture processing unit to;
Described two field picture processing unit is used for when the two field picture quantity that has obtained also during the quantity of the no show two field picture that need obtain, frame data in the described two field picture are copied to the back of the encoded two field picture that obtains, and calculating frame head, the frame head that calculates is filled into through duplicating the relevant position of the frame data that obtain, obtains corresponding two field picture.
Wherein, described two field picture processing unit also is used for:
When the two field picture that has obtained behind the coding only is one, frame data in the described two field picture are copied to the back of the encoded two field picture that obtains, and the frame head of the encoded two field picture that obtains added 1, the frame head that calculates is filled into through duplicating the relevant position of the frame data that obtain.
Wherein, described two field picture processing unit also is used for:
When the two field picture that has obtained after encoding is a plurality of, frame data in the described two field picture are copied to the back of the encoded two field picture that obtains, and the frame head of the encoded two field picture that obtains added 1, the frame head that calculates is filled into through duplicating the relevant position of the frame data that obtain;
Wherein, described two field picture processing unit also is used for:
When the two field picture that has obtained after encoding is a plurality of, a plurality of frame data in the described two field picture are copied in groups the back of the encoded two field picture that obtains, and the frame head in the two field picture of the encoded frame head maximum that obtains added 1 successively, obtain respectively the frame head that calculates being filled into through duplicating the relevant position of the frame data that obtain through duplicating the frame head of a plurality of frame data correspondences that obtain.
Wherein, described system also comprises:
Computing unit is used for the quantity that frame per second according to reproduction time and played file calculates the two field picture of needs coding, and sends result of calculation to described judging unit.
The specific embodiments that is provided by the invention described above is obtained the view data of an image correspondence as can be seen, and the view data of being obtained is encoded; Obtain at least one two field picture when encoding, but when not finishing coding, utilize the frame data in the two field picture that has obtained to finish coding, so the present invention can shorten the shared time of coding in the manufacturing process of video photograph album.
Description of drawings
Fig. 1 is the flow chart of first embodiment provided by the invention;
Fig. 2 is the structure chart of second embodiment provided by the invention.
Embodiment
The present invention has obtained at least one two field picture for the view data of an image that gets access to behind coding, but does not finish when encoding, and utilizes the frame data in the two field picture that has obtained to finish coding.
Before implementing the present invention, need to calculate the quantity of the two field picture of needs coding according to the frame per second of reproduction time and played file.For example, be to play in the file of V frame/second T second in frame per second if desired, then need described photo is carried out coding V*T time, that is to say needs to encode obtain V*T two field picture.
The first embodiment of the present invention provides a kind of method for video coding, and its implementation process comprises as shown in Figure 1:
Step S101 obtains the view data of a photo.
Step S102 encodes to the view data of being obtained, and obtains the frame data and the frame head of at least one two field picture correspondence.
Step S103 preserves the frame data and the frame head of the two field picture correspondence that obtains behind the coding.
Step S104 judges the quantity that whether the two field picture quantity obtained arrives needs the two field picture that coding obtains, if arrive, determines that then coding finishes, and then changes step S101 over to, promptly continues to obtain the view data of next photo; Otherwise, change step S105 over to.
Step S105 extracts the frame data that need duplicate from described frame data, and it is copied to the two field picture back that obtains behind the coding, and calculates frame head, the frame head that calculates is filled into the relevant position of frame data; Return step S104 then.
Though frame data have obtained duplicating, because frame head is relevant with the order in the video, thus need recomputate frame head, and be put in the bit stream data of generation after will calculating resulting frame head and duplicating next frame data combination.
Among the step S105, the following several mode of can sampling realizes:
First kind, after coding obtains an I two field picture, duplicate the frame data of described I two field picture correspondence, and will and add 1 to your frame head of the I two field picture that obtains of coding, the frame head that calculates is filled into the original position of the frame data that duplicate, and cycling is finished until the coding number of times.Specific as follows:
Coding obtains the I two field picture, its frame head is the 0th frame, then the frame data of described I two field picture correspondence are copied to the back of described the 0th frame, and calculate the frame head of the frame data after duplicating, obtaining frame head is the 1st frame, and the frame head of described the 1st frame is filled into through duplicating the original position of first frame data that obtain.
Judge whether to reach the two field picture quantity that needs coding to obtain then, when determining no show, then continue the frame data of described I two field picture are copied to the back of described the 1st frame, calculate the frame head of the frame data that after duplicating, obtain then, obtaining frame head is the 2nd frame, and the frame head of described the 2nd frame is filled into the original position of the frame data that duplicate for the second time, and the like, form at last and finish the coded format that obtains behind the coding of 15 frame two field pictures, as shown in table 1:
Frame head |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
Type of coding |
I |
I |
I |
I |
I |
I |
I |
I |
I |
I |
I |
I |
I |
I |
I |
Data Source |
I_0 |
I_0 |
I_0 |
I_0 |
I_0 |
I_0 |
I_0 |
I_0 |
I_0 |
I_0 |
I_0 |
I_0 |
I_0 |
I_0 |
I_0 |
Table 1
Second kind, coding duplicates the frame data of P two field picture correspondence, then until finishing coding after generating I frame, P two field picture.Specific as follows:
Coding obtains I two field picture, P two field picture, its frame head is respectively the 0th frame and the 1st frame, then the frame data of described P two field picture correspondence are copied to the back of described the 1st frame, and calculate the frame head of the frame data after duplicating, obtain, obtaining frame head is the 2nd frame, and described frame head is filled into through duplicating the original position of first frame data that obtain; Judge whether to reach the two field picture quantity that needs coding to obtain then, when determining no show, then continue described P frame data are copied to the back of described the 2nd frame, calculate the frame head of the frame data that after duplicating, obtain then, obtaining frame head is the 3rd frame, and described frame head is filled into the original position of second frame data that obtains after duplicating, and the like, form at last and finish the coded format that obtains behind the coding of 15 frame two field pictures, as shown in table 2:
Frame head |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
Type of coding |
I |
P |
P |
P |
P |
P |
P |
P |
P |
P |
P |
P |
P |
P |
P |
Data Source |
I_0 |
P_1 |
P_1 |
P_1 |
P_1 |
P_1 |
P_1 |
P_1 |
P_1 |
P_1 |
P_1 |
P_1 |
P_1 |
P_1 |
P_1 |
Table 2
The third carries out the method that frame in groups duplicates according to 3 frame data of I frame, P frame, the combination of P frame and finishes coding.Be implemented as follows:
Coding obtains I two field picture, P two field picture, P two field picture, its frame head is respectively the 0th frame, the 1st frame, the 2nd frame, then I frame data, P frame data, the P frame data of the encoded two field picture correspondence that obtains are copied to the back of described the 2nd frame, and the frame head in the two field picture of the encoded frame head maximum that obtains added 1 successively, the frame head that obtains through duplicating the I frame data that obtain, P frame data, P frame data correspondence is respectively the 3rd frame, the 4th frame and the 5th frame, and the frame head that calculates is filled into through duplicating the relevant position of the frame data that obtain.
Judge whether to reach the two field picture quantity that needs coding to obtain then, when determining no show, then continue described I frame data, P frame data, P frame data are copied to the back of described the 5th frame, calculate the frame head of the frame data that after duplicating, obtain then, be respectively the 6th frame, the 7th frame and the 8th frame, and described frame head is filled into the original position of respective frame data, and the like, form at last and finish the coded format that obtains behind the coding of 15 frame two field pictures, as shown in table 3:
Frame head |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
Type of coding |
I |
P |
P |
I |
P |
P |
I |
P |
P |
I |
P |
P |
I |
P |
P |
Data Source |
I_0 |
P_1 |
P_2 |
I_0 |
P_1 |
P_2 |
I_0 |
P_1 |
P_2 |
I_0 |
P_1 |
P_2 |
I_0 |
P_1 |
P_2 |
Table 3
The 4th kind, carry out the method (IBBP) that frame in groups duplicates according to a plurality of frame data of inter-frame-combined in the frame and finish coding.Specific implementation process and the third situation are similar, are not described in detail here.Form coded format as shown in table 4 at last:
Frame head |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
Type of coding |
I |
B |
B |
P |
I |
B |
B |
P |
I |
B |
B |
P |
I |
B |
B |
Data Source |
I_0 |
B_1 |
B_2 |
P_3 |
I_0 |
B_1 |
B_2 |
P_3 |
I_0 |
B_1 |
B_2 |
P_3 |
I_0 |
B_1 |
B_2 |
Table 4
The second embodiment of the present invention provides a kind of video coding system, and its structure comprises as shown in Figure 2: computing unit, data acquisition unit and coding unit; Wherein said coding unit comprises judging unit, two field picture processing unit;
The function of each unit is as follows in the system:
Described computing unit is used for the quantity that frame per second according to reproduction time and played file calculates the two field picture of needs coding; And send the result of calculation that obtains to described coding unit.
Described data acquisition unit is used to obtain the view data of an image correspondence;
Described coding unit is used for the view data of being obtained is encoded, and has obtained at least one two field picture behind coding, but does not finish when encoding, and utilizes the frame data in the two field picture that has obtained to finish coding.Wherein whether be according to the result of calculation of described computing unit determine to cataloged procedure if finishing.
Signal transitive relation in the system between each unit is as follows:
Described computing unit calculates the quantity of the two field picture of needs coding according to the frame per second of reproduction time and played file; And send the result of calculation that obtains to described coding unit.
Described data acquisition unit obtains the view data of an image correspondence; And send accessed view data to described coding unit.
Described coding unit is encoded to the view data of being obtained, and after having obtained at least one two field picture behind the coding, whether the two field picture quantity that has obtained by described judgment unit judges arrives the quantity of the two field picture that need obtain, if and the quantity of the two field picture that no show need obtain, the judged result of the quantity of the two field picture that the two field picture quantity no show that then will obtain need obtain sends described two field picture processing unit to; Otherwise trigger the view data that described data acquisition unit obtains next image correspondence.After described two field picture processing unit receives the judged result of quantity of the two field picture that the two field picture quantity no show that obtained need obtain, frame data in the described two field picture are copied to the back of the encoded two field picture that obtains, and calculating frame head, the frame head that calculates is filled into through duplicating the relevant position of the frame data that obtain, obtain corresponding two field picture, the two field picture quantity that will obtain then sends described judging unit to.Described two field picture processing unit duplicated frame data, and the disposition of calculating the frame head of described frame data correspondence has three kinds:
First kind, when the two field picture that has obtained behind the coding only is one, frame data in the described two field picture are copied to the back of the encoded two field picture that obtains, and the frame head of the encoded two field picture that obtains added 1, the frame head that calculates is filled into through duplicating the relevant position of the frame data that obtain.First kind of situation among the specific implementation process and first embodiment is similar, is not described in detail here.
Second kind, when the two field picture that has obtained after encoding is a plurality of, frame data in the described two field picture are copied to the back of the encoded two field picture that obtains, and the frame head of the encoded two field picture that obtains added 1, the frame head that calculates is filled into through duplicating the relevant position of the frame data that obtain.Second kind of situation among the specific implementation process and first embodiment is similar, is not described in detail here.
The third, when the two field picture that has obtained after encoding is a plurality of, a plurality of frame data in the described two field picture are copied in groups the back of the encoded two field picture that obtains, and the frame head in the two field picture of the encoded frame head maximum that obtains added 1 successively, obtain respectively the frame head that calculates being filled into through duplicating the relevant position of the frame data that obtain through duplicating the frame head of a plurality of frame data correspondences that obtain.Among the specific implementation process and first embodiment the third and the 4th kind of situation are similar, are not described in detail here.
The specific embodiments that is provided by the invention described above is obtained the view data of an image correspondence as can be seen, and the view data of being obtained is encoded; Obtain at least one two field picture when encoding, but when not finishing coding, utilize the frame data in the two field picture that has obtained to finish coding, so the present invention can shorten the shared time of coding in the manufacturing process of video photograph album.
Obviously, those skilled in the art can carry out various changes and modification to the present invention and not break away from the spirit and scope of the present invention.Like this, if of the present invention these are revised and modification belongs within the scope of claim of the present invention and equivalent technologies thereof, then the present invention also is intended to comprise these changes and modification interior.