A kind of fast prediction mode selecting method and device
Technical field
The present invention relates to coding and decoding video field, more particularly, to a kind of fast prediction mode selecting method and device.
Background technology
Traversing operation on predictive mode for the conventional encoding techniques, although can seek to optimum prediction mode, carries therewith
The amount of calculation come is also huge.Especially preset under mechanism in coding structure, when classification and its of pre-set image frame are actual optimal
The maximum waste of amount of calculation when predictive mode is completely inconsistent, can be caused, and now the lifting to distortion performance is no at all helped
Help.
For this problem, a kind of present invention fast prediction model selection strategy.
Content of the invention
The purpose of the embodiment of the present invention is to propose a kind of fast prediction mode selecting method it is intended to solution prior art is normal
Rule traversing operation on predictive mode for the coding techniques, can cause the maximum waste of amount of calculation, and the lifting to distortion performance
The problem no at all helping.
The embodiment of the present invention is achieved in that a kind of fast prediction mode selecting method, and methods described includes following step
Suddenly:
Step B, judges whether t≤numframe, if so, then enter step C;
Step C, judges current encoded frame frametWhether it is I frame, if otherwise entering step D;
Step D, assigns initial value n=1, numI=0;
Step E, judges whether n≤numMb*Thres1, if so, then enter step F, if it is not, then entering step G;
Step F, to current coding macro block Mbt,nEncoded, and the predictive mode according to current coding macro block, calculated the
One mode statistical variable, then makes n=n+1, followed by return to step E;
Step G, judges whether numI>(n-1)*Thres2, if so, then enter step H;
Step H:First with fast prediction model selection strategy, delete impossible predictive mode, then to currently grand
Block is encoded, and finally, enters step J;
Step J:Determine whether n >=numMb, if so, then make t=t+1 first, subsequently into step L, if it is not, then first,
Make n=n+1, then reenter step H;
Step L:Determine whether t≤numframe, if it is not, then terminating;
Wherein, t presentation code frame number;frametRepresent current encoded frame;numframeThe picture frame of presentation code sequence
Number;N represents Mbt,nCoding sequence number in current encoded frame;Mbt,nRepresent current macro;numIRepresent that first mode statistics becomes
Amount;numMbRepresent the macro block sum in a two field picture;Thres1For the first decision threshold;Thres2For the second decision threshold.
Further, further comprising the steps of before step B:
Step A, assigns initial value t=1.
Further, in step C, judge current encoded frame frametWhether it is I frame, if then to current encoded frame
frametEncoded, then made t=t+1, followed by returning to step B.
Further, in step G, judge whether numI>(n-1)*Thres2, if it is not, then entering step I;
Step I:First current macro is encoded, subsequently into step K;
Step K:Determine whether n >=numMb, if so, then make t=t+1 first, then reenter step B;If it is not, it is then first
First, make n=n+1, then reenter step I.
Further, in step L, determine whether t≤numframe, if so, then enter step M;
Step M:Determine whether frametFor I frame, if it is not, then entering step N;
Step N:Assign initial value n=1, numpb=0;
Step O:Determine whether n≤numMb*Thres1, if so, then enter step P;If it is not, then entering step Q;
Step P:First to Mbt,nEncoded, then the predictive mode according to macro block calculates second mode statistical variable;
Then, make n=n+1, followed by reentering step O;
Step Q:Judge whether numpb>(n-1)*Thres2, if so, then enter step R;
Step R:First with fast prediction model selection strategy, delete impossible reference frame;Subsequently into step S;
Step S:First current macro is encoded, subsequently into step T;
Step T:Determine whether n >=numMb, if so, then make t=t+1 first, then reenter step B;If it is not, it is then first
First, make n=n+1, then reenter step S.
Further, in step M, determine whether frametFor I frame, if so, then first to frametEncoded, then
Make t=t+1, finally reenter step B.
Further, in step Q, judge whether numpb>(n-1)*Thres2, if it is not, then entering step S.The present invention is real
The another object applying example is to propose a kind of fast prediction mode selector, and described device includes:
First judging treatmenting module:For judging whether t≤numframe, if so, then enter the second judging treatmenting module;If
No, then terminate;
Second judging treatmenting module:For judging current encoded frame frametWhether it is I frame, be then to current encoded frame
frametEncoded, then made t=t+1, returned the first judging treatmenting module;Otherwise enter the second assignment module;
Second assignment module:It is connected with the 3rd judging treatmenting module, for assigning initial value n=1, numI=0;
3rd judging treatmenting module:For judging whether n≤numMb*Thres1, if so, then enter first processing module;
If it is not, then entering the 4th judging treatmenting module;
First processing module, for current coding macro block Mbt,nEncoded, and the prediction according to current coding macro block
Pattern, calculates first mode statistical variable, then makes n=n+1, executes the 3rd judging treatmenting module followed by returning;
4th judging treatmenting module, is used for judging whether numI>(n-1)*Thres2, if so, then enter second processing mould
Block;If it is not, then entering the first coding module;
Second processing module, for first with fast prediction model selection strategy, deleting impossible predictive mode;So
Afterwards current macro is encoded;Finally, enter the 6th judging treatmenting module;
First coding module, for encoding to current macro first, subsequently into the 5th judging treatmenting module;
5th judging treatmenting module, is used for determining whether n >=numMb, if so, then make t=t+1 first, then reenter
First judging treatmenting module;If it is not, then first, make n=n+1, then reenter the first coding module;
6th judging treatmenting module, is used for determining whether n >=numMb, if so, then make t=t+1 first, subsequently into the 7th
Judging treatmenting module;If it is not, then first, make n=n+1, then reenter Second processing module;
7th judging treatmenting module, is used for determining whether t≤numframe, if it is not, then terminating;
Wherein, frametRepresent current encoded frame;numframeThe number of image frames of presentation code sequence;N represents Mbt,nWorking as
Coding sequence number in front coded frame;Mbt,nRepresent current macro;T presentation code frame number;numMbRepresent grand in a two field picture
Block sum;numIRepresent first mode statistical variable;Thres1For the first decision threshold, Thres2For the second decision threshold.
Further, described device also includes:
First assignment module:It is connected with the first judging treatmenting module, for assigning initial value t=1.
Further, described device also includes:
Described 7th judging treatmenting module, is additionally operable to determine whether t≤numframe, if so, then enter the 8th judgement and process
Module;
8th judging treatmenting module, is connected with the 7th judging treatmenting module, is used for determining whether frametFor I frame, if so,
Then first to frametEncoded, then made t=t+1, finally reentered the first judging treatmenting module;If it is not, then entering
3rd assignment module;
3rd assignment module, is connected with the 9th judging treatmenting module, for assigning initial value n=1, numpb=0;
numpbRepresent second mode statistical variable;
9th judging treatmenting module, is used for determining whether n≤numMb*Thres1, if so, then enter the 3rd processing module;
If it is not, then entering the tenth judging treatmenting module;
3rd processing module, for first to Mbt,nEncoded, then the predictive mode according to macro block calculates the second mould
Formula statistical variable;Then, make n=n+1, followed by reentering the 9th judging treatmenting module;
Tenth judging treatmenting module, is used for judging whether numpb>(n-1)*Thres2, if so, then enter fourth process mould
Block;If it is not, then entering the second coding module;
Fourth processing module, for first with fast prediction model selection strategy, deleting impossible reference frame;Then
Enter the second coding module;
Second coding module, for encoding to current macro first, subsequently into the 11st judging treatmenting module;
11st judging treatmenting module, is used for determining whether n >=numMb, if so, then make t=t+1 first, then again enter
Enter the first judging treatmenting module;If it is not, then first, make n=n+1, then reenter the second coding module.
Beneficial effects of the present invention
The embodiment of the present invention passes through the statistical property of the macro-block skip mode in analyzed area, can quickly judge coding structure
The interference in default mechanism, predictive mode being selected;By, before optimum prediction mode determines, deleting impossible predictive mode
Or impossible reference frame, reach the stability requirement of distortion performance while reducing amount of calculation.
Brief description
Fig. 1 is a kind of preferred embodiment of the present invention fast prediction mode selecting method flow chart;
Fig. 2 is a kind of preferred embodiment of the present invention fast prediction mode selector structural representation.
Specific embodiment
In order that the objects, technical solutions and advantages of the present invention become more apparent, below in conjunction with drawings and Examples, right
The present invention is further elaborated, and for convenience of description, illustrate only the part related to the embodiment of the present invention.Should manage
Solution, the specific embodiment that this place is described, it is used only for explaining the present invention, not in order to limit the present invention.
The embodiment of the present invention passes through the statistical property of the macro-block skip mode in analyzed area, can quickly judge coding structure
The interference in default mechanism, predictive mode being selected;By, before optimum prediction mode determines, deleting impossible predictive mode
Or impossible reference frame, reach the stability requirement of distortion performance while reducing amount of calculation.
Embodiment one
Fig. 1 is a kind of preferred embodiment of the present invention fast prediction mode selecting method flow chart, and methods described includes following
Step:
S101, assigns initial value t=1.
T presentation code frame number;
S102, judges whether t≤numframe, if so, then enter step S103;If it is not, then terminating.
Wherein, frametRepresent current encoded frame;numframeThe number of image frames of presentation code sequence.
S103, judges current encoded frame frametWhether it is I frame, be then to current encoded frame frametEncoded, then
Make t=t+1, followed by returning to step S102;Otherwise enter step S104.
S104, assigns initial value n=1, numI=0.
N represents Mbt,nCoding sequence number in current encoded frame;Mbt,nRepresent n-th macro block of current encoded frame, also referred to as
For current macro;numIRepresent first mode statistical variable;
S105, judges whether n≤numMb*Thres1, if so, then enter step S106;If it is not, then entering step S107.
Wherein, numMbRepresent the macro block sum in a two field picture;Thres1For the first decision threshold, Thres1>0.05*
height/width;Width, height represent columns in units of pixel for the image, line number respectively;
S106, to current coding macro block Mbt,nEncoded, and the predictive mode according to current coding macro block, calculate first
Mode statistical variable, then makes n=n+1, followed by return to step S105;
Described " according to the predictive mode of current coding macro block, calculating first mode statistical variable " is specially:
Wherein, numIRepresent first mode statistical variable.
S107, judges whether numI>(n-1)*Thres2, if so, then enter S108;If it is not, then entering S109.
Wherein, Thres2For the second decision threshold, 0.7≤Thres2≤1.
S108:First with fast prediction model selection strategy, deleting impossible predictive mode is inter-frame forecast mode;
Then current macro is encoded;Finally, enter S110.Only current macro is carried out with infra-frame prediction, chooses optimal frame in
Predictive mode is the optimum prediction mode of current macro, and the macroblock coding subsequent processing steps then carrying out routine are converted quantity
Change, entropy code etc., finally enter back into S110.
S109:First current macro is encoded, subsequently into S111.
S110:Determine whether n >=numMb, if so, then make t=t+1 first, subsequently into S112;If it is not, then first, make n
=n+1, then reenters S108.
S111:Determine whether n >=numMb, if so, then make t=t+1 first, then reenter S102;If it is not, it is then first
First, make n=n+1, then reenter S109.
S112:Determine whether t≤numframe, if so, then enter S113;If it is not, then terminating.
S113:Determine whether frametFor I frame, if so, then first to frametEncoded, then made t=t+1, finally
Reenter S102;If it is not, then entering S114.
S114:Assign initial value n=1, numpb=0.
S115:Determine whether n≤numMb*Thres1, if so, then enter S116;If it is not, then entering S117.
S116:First to Mbt,nEncoded, then the predictive mode according to macro block calculates second mode statistical variable;So
Afterwards, make n=n+1, followed by reentering S115.
In in full, numpbRepresent second mode statistical variable.
S117:Judge whether numpb>(n-1)*Thres2, if so, then enter S118;If it is not, then entering S119.
S118:First with fast prediction model selection strategy, delete impossible reference frame;Subsequently into S119.I.e.
Delete in reference listing first and play the reference frame that sequence number is less than T, subsequently into S119.
Wherein T presentation code sequence number is equal to the broadcasting sequence number of the reference frame of t-1.
S119:First current macro is encoded, subsequently into S120.
S120:Determine whether n >=numMb, if so, then make t=t+1 first, then reenter S102;If it is not, it is then first
First, make n=n+1, then reenter S119.
The embodiment of the present invention passes through the statistical property of the macro-block skip mode in analyzed area, can quickly judge coding structure
The interference in default mechanism, predictive mode being selected;By, before optimum prediction mode determines, deleting impossible predictive mode
Or impossible reference frame, reach the stability of distortion performance while reducing amount of calculation.
Embodiment two
Fig. 2 is a kind of preferred embodiment of the present invention fast prediction mode selector structural representation.Described system includes:
First assignment module:It is connected with the first judging treatmenting module, for assigning initial value t=1;
T presentation code frame number;
First judging treatmenting module:For judging whether t≤numframe, if so, then enter the second judging treatmenting module;If
No, then terminate;
Wherein, frametRepresent current encoded frame;numframeThe number of image frames of presentation code sequence;
Second judging treatmenting module:For judging current encoded frame frametWhether it is I frame, be then to current encoded frame
frametEncoded, then made t=t+1, returned the first judging treatmenting module;Otherwise enter the second assignment module.
Second assignment module:It is connected with the 3rd judging treatmenting module, for assigning initial value n=1, numI=0.
N represents Mbt,nCoding sequence number in current encoded frame;Mbt,nRepresent n-th macro block of current encoded frame, also referred to as
For current macro;numIRepresent first mode statistical variable;
3rd judging treatmenting module:For judging whether n≤numMb*Thres1, if so, then enter first processing module;
If it is not, then entering the 4th judging treatmenting module.
Wherein, numMbRepresent the macro block sum in a two field picture;Thres1For the first decision threshold, Thres1>0.05*
height/width;Width, height represent columns in units of pixel for the image, line number respectively;
First processing module, for current coding macro block Mbt,nEncoded, and the prediction according to current coding macro block
Pattern, calculates first mode statistical variable, then makes n=n+1, executes the 3rd judging treatmenting module followed by returning;
Described " according to the predictive mode of current coding macro block, calculating first mode statistical variable " is specially:
Wherein, numIRepresent first mode statistical variable;
4th judging treatmenting module, is used for judging whether numI>(n-1)*Thres2, if so, then enter second processing mould
Block;If it is not, then entering the first coding module;
Wherein, Thres2For the second decision threshold, 0.7≤Thres2≤1;
Second processing module, for first with fast prediction model selection strategy, deleting impossible predictive mode be
Inter-frame forecast mode;Then current macro is encoded;Finally, enter the 6th judging treatmenting module.
It is specially:Current macro is carried out with infra-frame prediction, chooses optimal intra prediction mode and be the optimal of current macro
Predictive mode, the macroblock coding subsequent processing steps then carrying out routine are change quantization, entropy code etc., finally enter back into the 6th
Judging treatmenting module.
First coding module, for encoding to current macro first, subsequently into the 5th judging treatmenting module.
5th judging treatmenting module, is used for determining whether n >=numMb, if so, then make t=t+1 first, then reenter
First judging treatmenting module;If it is not, then first, make n=n+1, then reenter the first coding module.
6th judging treatmenting module, is used for determining whether n >=numMb, if so, then make t=t+1 first, subsequently into the 7th
Judging treatmenting module;If it is not, then first, make n=n+1, then reenter Second processing module.
7th judging treatmenting module, is used for determining whether t≤numframe, if so, then enter the 8th judging treatmenting module;If
No, then terminate.
8th judging treatmenting module, is used for determining whether frametFor I frame, if so, then first to frametEncoded,
Then make t=t+1, finally reenter the first judging treatmenting module;If it is not, then entering the 3rd assignment module.
3rd assignment module, is connected with the 9th judging treatmenting module, for assigning initial value n=1, numpb=0.
numpbRepresent second mode statistical variable;
9th judging treatmenting module, is used for determining whether n≤numMb*Thres1, if so, then enter the 3rd processing module;
If it is not, then entering the tenth judging treatmenting module.
3rd processing module, for first to Mbt,nEncoded, then the predictive mode according to macro block calculates the second mould
Formula statistical variable;Then, make n=n+1, followed by reentering the 9th judging treatmenting module.
In in full, numpbRepresent second mode statistical variable;
Tenth judging treatmenting module, is used for judging whether numpb>(n-1)*Thres2, if so, then enter fourth process mould
Block;If it is not, then entering the second coding module.
Fourth processing module, for first with fast prediction model selection strategy, deleting impossible reference frame;Then
Enter the second coding module.
It is specially:Delete in reference listing first and play the reference frame that sequence number is less than T, subsequently into the second coding module;
Wherein T presentation code sequence number is equal to the broadcasting sequence number of the reference frame of t-1.
Second coding module, for encoding to current macro first, subsequently into the 11st judging treatmenting module.
11st judging treatmenting module, is used for determining whether n >=numMb, if so, then make t=t+1 first, then again enter
Enter the first judging treatmenting module;If it is not, then first, make n=n+1, then reenter the second coding module.
The embodiment of the present invention passes through the statistical property of the macro-block skip mode in analyzed area, can quickly judge coding structure
The interference in default mechanism, predictive mode being selected;By, before optimum prediction mode determines, deleting impossible predictive mode
Or impossible reference frame, reach the stability of distortion performance while reducing amount of calculation.
It will be understood by those skilled in the art that realizing all or part of step in above-described embodiment method is can
With completed by programmed instruction related hardware, described program can be stored in a computer read/write memory medium,
Described storage medium can be ROM, RAM, disk, CD etc..
The foregoing is only presently preferred embodiments of the present invention, not in order to limit the present invention, all essences in the present invention
Any modification, equivalent and improvement made within god and principle etc., should be included within the scope of the present invention.