Embodiment
The present invention following embodiment provide a kind of method for video coding and device.
In order to make those skilled in the art person understand the technical scheme in the embodiment of the invention better; And make the above-mentioned purpose of the embodiment of the invention, feature and advantage can be more obviously understandable, below in conjunction with accompanying drawing technical scheme in the embodiment of the invention done further detailed explanation.
Referring to Figure 1A, be the first embodiment flow chart of the application's method for video coding:
Step 101: the initial candidate motion vector set of obtaining the present encoding piece.
Concrete; Peripheral encoding block according to the present encoding piece obtains the spatial domain candidate motion vector; Obtain the time domain candidate motion vector of present encoding piece according to reference frame, this reference frame can be the former frame of the present frame at present encoding piece place, or back one frame; Or former frame and back one frame, the spatial domain candidate motion vector is become the initial motion vectors set with the time domain set of candidate motion vectors.
Referring to Figure 1B, for the motion vector of encoding block in the B frame with bi directional motion compensation characteristic is selected sketch map.Suppose that the encoding block mv in the present frame is the present encoding piece, then the peripheral encoding block of present encoding piece mv is often referred to the left side encoding block mv of the mv shown in Figure 1B
a, top encoding block mv
b, upper right side encoding block mv
c, upper left side encoding block mv
d, according to above-mentioned encoding block mv
a, mv
b, mv
c, mv
dObtain the spatial domain candidate motion vector of present encoding piece mv; Suppose with the reference frame to be that former frame in the present frame is an example, then the encoding block of present encoding piece mv corresponding position in former frame is mv
Col, corresponding mv
ColNeighbours territory and eight neighborhood encoding blocks be respectively mv
0To mv
7, according to above-mentioned mv
ColAnd mv
0To mv
7Obtain the time domain candidate motion vector of mv, in like manner, also can be according to the encoding block mv of present encoding piece mv corresponding position in one frame of back
Col' and neighbours territory and eight neighborhood encoding block mv
0' to mv
7' acquisition time domain candidate motion vector.
Step 102: for each motion vector in the set of initial candidate motion vector adds a counter motion vector.
Concrete, can add a counter motion vector for each motion vector in the set of initial candidate motion vector according to the predetermined movement model.The predetermined movement model comprises uniform rectilinear motion model or accelerated motion model.
With the uniform rectilinear motion model is example, referring to Fig. 1 C, is the B frame model sketch map of linear movement at the uniform velocity.Suppose V
bBe backward motion vector, V
fBe forward motion vector, the distance between B frame and the forward reference frame is T
f, and the distance of back between reference frame is T
b, then for the uniform rectilinear motion model shown in Fig. 1 C, each concerns when satisfying as follows forward motion vector and backward motion vector: V
f/ T
f=-V
b/ T
b
In addition, except the uniform rectilinear motion model shown in above-mentioned Fig. 1 C, also can adopt the accelerated motion model, at this moment two motion vector V
fAnd V
bBetween can satisfy and concern V
f=-(V
b+ α), wherein α is a speed difference.
Step 103: generate new set of candidate motion vectors according to the motion vector in counter motion vector and the set of initial candidate motion vector and close.
After having added the counter motion vector for the motion vector in the set of initial candidate motion vector; All forward motion vector in the motion vector in counter motion vector that is added and the original initial candidate motion vector set are formed forward direction set of candidate motion vectors close, and close to set of candidate motion vectors behind all backward motion vector compositions.
Except the above-mentioned forward direction set of candidate motion vectors of setting up is respectively closed with back to the mode that set of candidate motion vectors is closed; Also can, a new set of candidate motion vectors comprise all forward motion vector and backward motion vector in closing; This new set of candidate motion vectors has comprised some groups of motion vectors in closing; In each group motion vector corresponding forward motion vector and backward motion vector are arranged, each organizes corresponding forward motion vector and backward motion vector can be distinguished through identification information.
Step 104: the motion vector of from new set of candidate motion vectors is closed, selecting to be used to encode is encoded.
Can be new set of candidate motion vectors each motion vector allocation index sign in closing; Adopt RDO (Rate Distortion Optimization; The rate-distortion optimization criterion) mode is selected the motion vector that is used to encode from new set of candidate motion vectors is closed; And with the index sign of the motion vector of said selection, and enroll code stream according to the information that the motion vector of said selection obtains.
Wherein, The motion vector of from new set of candidate motion vectors is closed, selecting is and the immediate motion vectors of the true encoding motion vector of encoding terminal; Because the amount of information of motion vector itself is bigger,, then will increase the data volume of encoding compression if therefore in code stream, directly transmit true encoding motion vector itself; Reduce the efficient of encoding compression and coding transmission; Therefore close through making up set of candidate motion vectors, and after therefrom selecting motion vectors, can obtain the difference of itself and true motion vector according to this motion vectors; This difference is very little compared to the data volume of true encoding motion vector own, and therefore this difference is enrolled code stream just can effectively improve encoding compression and coding transmission efficient.
In addition, encoding terminal also can utilize the motion vector of selection to accomplish other cataloged procedure, and this process is consistent with prior art, repeats no more at this.
Referring to Fig. 2, be the second embodiment flow chart of the application's method for video coding, this embodiment shows motion vector is unified to judge the process that generates the counter motion vector:
Step 201: the initial candidate motion vector set of obtaining the present encoding piece.
Peripheral encoding block according to the present encoding piece obtains the spatial domain candidate motion vector; Obtain the time domain candidate motion vector of present encoding piece according to reference frame; This reference frame can be the former frame of the present frame at present encoding piece place; Or back one frame, or former frame and back one frame, the spatial domain candidate motion vector is become the initial motion vectors set with the time domain set of candidate motion vectors.
Step 202: judge in the set of initial candidate motion vector whether only have unidirectional motion vector, if then execution in step 203; Otherwise, execution in step 204.
In the initial motion vectors set; Comprise peripheral encoding block according to the present encoding piece; The motion vector that each encoding block obtains in the reference frame; Judge whether only to exist unidirectional motion vector to refer to whether only comprise forward motion vector in the set of initial candidate motion vector, perhaps only comprise backward motion vector here.
Step 203: for unidirectional motion vector adds the counter motion vector respectively, execution in step 205.
In the initial motion vectors set, if only comprise forward motion vector, then add a backward motion vector for each forward motion vector, if only comprise backward motion vector, then add a forward motion vector for each backward motion vector.Can know that in conjunction with Fig. 1 C each when adopting uniform rectilinear motion model, should satisfy following relation: V to forward motion vector and backward motion vector
f/ T
f=-V
b/ T
b
Step 204: be respectively forward motion vector and add backward motion vector, and be respectively backward motion vector interpolation forward motion vector as its counter motion vector as its counter motion vector.
In the initial motion vectors set, if promptly comprise forward motion vector, comprise backward motion vector again, then be respectively forward motion vector and add backward motion vector, and be respectively backward motion vector interpolation forward motion vector.Can know that in conjunction with Fig. 1 C each when adopting uniform rectilinear motion model, should satisfy following relation: V to forward motion vector and backward motion vector
f/ T
f=-V
b/ T
b
Step 205: generate new set of candidate motion vectors according to the motion vector in counter motion vector and the set of initial candidate motion vector and close.
Step 206: be new set of candidate motion vectors each motion vector allocation index sign in closing.
Step 207: adopt the RDO mode from new set of candidate motion vectors is closed, to select the motion vector that is used to encode.
Step 208:, and enroll code stream according to the information that the motion vector of said selection obtains with the index sign of the motion vector of said selection.
Enroll index information in the code stream and be equivalent to the selection information of the selected motion vector of encoding terminal, when decoding terminal that code stream sends, can find corresponding motion vector according to selection information.
Need to prove; Carry out the selection of motion vector to the RDO mode shown in the step 208 except employing step 206 in the foregoing description; Also can be employed in the mode that coding side and decoding end derive simultaneously and obtain motion vector, this application embodiment is not limited.
Referring to Fig. 3, be the 3rd embodiment flow chart of the application's method for video coding, this embodiment shows motion vector is judged the process that generates the counter motion vector one by one:
Step 301: the initial candidate motion vector set of obtaining the present encoding piece.
Peripheral encoding block according to the present encoding piece obtains the spatial domain candidate motion vector; Obtain the time domain candidate motion vector of present encoding piece according to reference frame; This reference frame can be the former frame of the present frame at present encoding piece place; Or back one frame, or former frame and back one frame, the spatial domain candidate motion vector is become the initial motion vectors set with the time domain set of candidate motion vectors.
Step 302: order is extracted a motion vector from the set of initial candidate motion vector.
Step 303: for the motion vector that extracts adds a counter motion vector.
Wherein, If the motion vector that is extracted is a forward motion vector; The motion vector that then is said extraction adds a backward motion vector as its counter motion vector; If the motion vector that is extracted is a backward motion vector, then be that the motion vector of said extraction adds a forward motion vector as its counter motion vector.
In conjunction with Fig. 1 C, each behind the interpolation counter motion vector concerns when satisfying as follows forward motion vector and backward motion vector: V
f/ T
f=-V
b/ T
b
Step 304: judge whether to accomplish all motion vectors in the set of initial candidate motion vector are added the counter motion vector, if then execution in step 305; Otherwise, return step 302.
Step 305: generate new set of candidate motion vectors according to the motion vector in counter motion vector and the set of initial candidate motion vector and close.
Step 306: the motion vector of from new set of candidate motion vectors is closed, selecting to be used to encode is encoded.
In this step 306, can specifically adopt the RDO mode shown in Fig. 2 embodiment to carry out the selection of motion vector, repeat no more at this.
Method embodiment by above-mentioned video coding is visible; In the set of candidate motion vectors that generates is closed; Except comprising spatial domain candidate motion vector, intermediate value motion vector and the time domain candidate motion vector that generates according to mode of the prior art; Also comprise the counter motion vector that adds according to image theory according to the characteristics of motion, the motion vector that this counter motion vector is equivalent to predict, thus it is more complete to make set of candidate motion vectors close; The motion vector of therefrom selecting that is used to encode is more excellent, improves coding efficiency.
Corresponding with aforementioned the application's method for video coding embodiment, the application also provides the embodiment of video encoding/decoding method.The mode that the generation set of candidate motion vectors is closed in the application's video decoding process is consistent with video coding process; Video decoding process need be analyzed video code flow and obtain the selection information of coding side to motion vector, so that from set of candidate motion vectors is closed, select the motion vector consistent with coding side that current code block is decoded.
Referring to Fig. 4, be the embodiment flow chart of the application's video encoding/decoding method:
Step 401: the initial candidate motion vector set of obtaining the present encoding piece.
Concrete; Peripheral encoding block according to the present encoding piece obtains the spatial domain candidate motion vector; Obtain the time domain candidate motion vector of present encoding piece according to reference frame, this reference frame can be the former frame of the present frame at present encoding piece place, or back one frame; Or former frame and back one frame, the spatial domain candidate motion vector is become the initial motion vectors set with the time domain set of candidate motion vectors.
Step 402: for each motion vector in the set of initial candidate motion vector adds a counter motion vector.
Concrete, can add a counter motion vector for each motion vector in the set of initial candidate motion vector according to the predetermined movement model.The predetermined movement model comprises uniform rectilinear motion model or accelerated motion model.
Wherein, can judge whether only there is unidirectional motion vector in the said initial candidate motion vector; If only have unidirectional motion vector, then add the counter motion vector respectively for said unidirectional motion vector; If have forward motion vector and backward motion vector simultaneously, then be respectively said forward motion vector and add backward motion vector, and be respectively said backward motion vector interpolation forward motion vector as its counter motion vector as its counter motion vector.
Wherein, Also can add a counter motion vector for the motion vector of said extraction; Wherein, if the motion vector that is extracted is a forward motion vector, then be that the motion vector of said extraction adds a backward motion vector as its counter motion vector; If the motion vector that is extracted is a backward motion vector, then be that the motion vector of said extraction adds a forward motion vector as its counter motion vector; Judge whether to accomplish all motion vectors in the said initial candidate motion vector set are added the counter motion vector, if then trigger and carry out the step that the new set of candidate motion vectors of said generation is closed; Otherwise, return the said step of from said initial candidate motion vector set, extracting a motion vector in proper order.
Step 403: generate new set of candidate motion vectors according to the motion vector in counter motion vector and the set of initial candidate motion vector and close.
Concrete implementation in above-mentioned steps 401 to the step 403 is consistent with the description among aforementioned method for video coding first embodiment to the three embodiment, repeats no more at this.
Step 404: resolve the code stream that receives, obtain the information of the selected motion vector in video coding terminal.
The motion vector that is used to encode is selected in the video coding terminal from new set of candidate motion vectors is closed after; Code stream can be enrolled with the index sign for the distribution of this motion vector in the video coding terminal; And the motion vector that will select and the difference between the true motion vector enroll code stream, and code stream is transferred to the video decode terminal.Therefore behind this code stream of video decode terminal analysis; Can therefrom get access to the information of the selected motion vector of encoding terminal; For example, the index of this motion vector sign, and obtain the motion vector of selection and the difference between the true motion vector; New set of candidate motion vectors according to this index sign can generate from step 403 is closed the middle selected motion vector of encoding terminal of selecting, and motion vector and the difference addition selected can be obtained the true encoding motion vector of encoding terminal.
Step 405: from new set of candidate motion vectors is closed, select corresponding motion vector to decode according to the information of motion vector.
Corresponding with the embodiment of aforementioned the application's method for video coding and video encoding/decoding method, the application also provides the embodiment block diagram at video coding terminal and video decode terminal.
Referring to Fig. 5 A, be the embodiment block diagram at the application's video coding terminal.
This video coding terminal comprises: acquiring unit 510, adding device 520, generation unit 530 and coding unit 540.
Wherein, acquiring unit 510, the initial candidate motion vector set that is used to obtain the present encoding piece;
Adding device 520, each motion vector that is used in the said initial candidate motion vector set adds a counter motion vector;
Generation unit 530 is used for closing according to the new set of candidate motion vectors of motion vector generation of said counter motion vector and the set of said initial candidate motion vector;
Coding unit 540 is used for closing the motion vector of selecting to be used to encode from said new set of candidate motion vectors and encodes.
Referring to Fig. 5 B, be the embodiment block diagram of a kind of adding device among Fig. 5 A:
This adding device 520 can comprise:
Direction vector judging unit 521 is used for judging whether said initial candidate motion vector only exists unidirectional motion vector;
Motion vector adding device 522; Be used for judged result according to said direction vector judging unit; If only there is unidirectional motion vector; Then add the counter motion vector respectively for said unidirectional motion vector, said exists unidirectional motion vector to comprise only to have forward motion vector, perhaps only have backward motion vector; If have forward motion vector and backward motion vector simultaneously, then be respectively said forward motion vector and add backward motion vector, and be respectively said backward motion vector interpolation forward motion vector as its counter motion vector as its counter motion vector.
Referring to Fig. 5 C, be the embodiment block diagram of another kind of adding device among Fig. 5 A:
This adding device 520 can comprise:
Order extraction unit 523 is used for extracting a motion vector from said initial candidate motion vector set order;
Order adding device 524; The motion vector that is used to said extraction adds a counter motion vector; Wherein, if the motion vector that is extracted is a forward motion vector, then be that the motion vector of said extraction adds a backward motion vector as its counter motion vector; If the motion vector that is extracted is a backward motion vector, then be that the motion vector of said extraction adds a forward motion vector as its counter motion vector;
Add and accomplish judging unit 525, be used for judging whether accomplishing said all motion vectors of initial candidate motion vector set are added the counter motion vector;
Trigger performance element 526, the judged result that is used for accomplishing judging unit when said interpolation then triggers said generation unit and carries out corresponding function for being, the judged result of accomplishing judging unit when said interpolation is then returned said order extraction unit for not.
Referring to Fig. 5 D, be the embodiment block diagram of coding unit among Fig. 5 A:
This coding unit 540 comprises:
Index sign allocation units 541 are used to said new set of candidate motion vectors each motion vector allocation index sign in closing;
Motion vector selected cell 542 is used for adopting rate-distortion optimization criterion RDO to close the motion vector that selection is used to encode from said new set of candidate motion vectors;
Encoding operation unit 543 is used for the index sign with the motion vector of said selection, and enrolls code stream according to the information that the motion vector of said selection obtains.
Referring to Fig. 6, be the embodiment block diagram at the application's video decode terminal.
This video decode terminal comprises: acquiring unit 610, adding device 620, generation unit 639, resolution unit 640 and decoding unit 650.
Wherein, acquiring unit 610, the initial candidate motion vector set that is used to obtain the present encoding piece;
Adding device 620, each motion vector that is used in the said initial candidate motion vector set adds a counter motion vector;
Generation unit 630 is used for closing according to the new set of candidate motion vectors of motion vector generation of said counter motion vector and the set of said initial candidate motion vector;
Resolution unit 640 is used to resolve the code stream that receives, and obtains the information of the selected motion vector in video coding terminal;
Decoding unit 650 is used for closing the corresponding motion vector of selection according to the information of said motion vector from said new set of candidate motion vectors and decodes.
Concrete, adding device 620 can comprise: the direction vector judging unit is used for judging whether said initial candidate motion vector set only exists unidirectional motion vector; The motion vector adding device; Be used for judged result according to said direction vector judging unit; If only there is unidirectional motion vector; Then add the counter motion vector respectively for said unidirectional motion vector, said exists unidirectional motion vector to comprise only to have forward motion vector, perhaps only have backward motion vector; If have forward motion vector and backward motion vector simultaneously, then be respectively said forward motion vector and add backward motion vector, and be respectively said backward motion vector interpolation forward motion vector as its counter motion vector as its counter motion vector.
Concrete, adding device 620 also can comprise: the direction vector judging unit is used for judging whether said initial candidate motion vector set only exists unidirectional motion vector; The motion vector adding device; Be used for judged result according to said direction vector judging unit; If only there is unidirectional motion vector; Then add the counter motion vector respectively for said unidirectional motion vector, said exists unidirectional motion vector to comprise only to have forward motion vector, perhaps only have backward motion vector; If have forward motion vector and backward motion vector simultaneously, then be respectively said forward motion vector and add backward motion vector, and be respectively said backward motion vector interpolation forward motion vector as its counter motion vector as its counter motion vector.
Description through to above execution mode can be known; The application embodiment is fashionable in the set of candidate motion vectors that makes up video coding; Obtain the initial candidate motion vector set of present encoding piece; For each motion vector in the set of initial candidate motion vector adds a counter motion vector; Generate new set of candidate motion vectors according to the motion vector in counter motion vector and the set of initial candidate motion vector and close, the motion vector of from new set of candidate motion vectors is closed, selecting to be used to encode is encoded.During the set of candidate motion vectors that application the application embodiment generates is closed; Comprised the counter motion vector that generates for motion vector; The motion vector that this counter motion vector is equivalent to predict; Thereby it is more complete to make set of candidate motion vectors close, and the motion vector of therefrom selecting that is used to encode is more excellent, has improved coding efficiency.
The technology that those skilled in the art can be well understood in the embodiment of the invention can realize by the mode that software adds essential general hardware platform.Based on such understanding; The part that technical scheme in the embodiment of the invention contributes to prior art in essence in other words can be come out with the embodied of software product; This computer software product can be stored in the storage medium, like ROM/RAM, magnetic disc, CD etc., comprises that some instructions are with so that a computer equipment (can be a personal computer; Server, the perhaps network equipment etc.) carry out the described method of some part of each embodiment of the present invention or embodiment.
Each embodiment in this specification all adopts the mode of going forward one by one to describe, and identical similar part is mutually referring to getting final product between each embodiment, and each embodiment stresses all is the difference with other embodiment.Especially, for system embodiment, because it is basically similar in appearance to method embodiment, so description is fairly simple, relevant part gets final product referring to the part explanation of method embodiment.
Above-described embodiment of the present invention does not constitute the qualification to protection range of the present invention.Any modification of within spirit of the present invention and principle, being done, be equal to replacement and improvement etc., all should be included within protection scope of the present invention.