Summary of the invention
The purpose of the embodiment of the invention is to propose a kind of quantification method of adjustment of picture quality saltus step, is intended to solve prior art when the picture quality saltus step occurs, and can produce saltus step, the flickering problem of picture quality.
The embodiment of the invention is achieved in that a kind of quantification method of adjustment of picture quality saltus step, and described method comprises:
Step1: judge whether that current encoded frame is that P frame and next coded frame are the I frame, if then enter Step2;
Step2: judge that whether occurrence scene switches next coded frame with respect to current encoded frame, if not, then makes scene switching mark variable flag=0, if then make flag=1;
Step3: the first correction value (QP that calculates the current encoded frame quantization parameter
t M1);
Step4: utilize the first correction value of described quantization parameter that current encoded frame is encoded;
Step5: next coded frame is set to current encoded frame;
Step6: judge whether flag=0, if then enter Step7;
Step7: the second correction value (QP that calculates the current encoded frame quantization parameter
t M2), then utilize the second correction value of quantization parameter that current encoded frame is encoded, enter Step8;
Step8: judge whether next coded frame frame exists, if there is no, then finish; Otherwise next coded frame is set to current encoded frame, then reenters Step1.
Further, among the described step Step1, judge whether that current encoded frame is that P frame and next coded frame are the I frame, if not, then: at first, current encoded frame is encoded;
Then, judge whether next coded frame exists, if there is no, then finish, otherwise,
Make that current encoded frame is next coded frame, reenter again Step1.
Further, among the described step Step6, judge whether flag=0, if not, then enter Step9,
Step9: judge that whether next coded frame frame exists, if do not exist, then enters step Step10;
Step10: the 3rd correction value (QP that calculates the current encoded frame quantization parameter
t M3), then utilize the 3rd correction value of quantization parameter that current encoded frame is encoded, then finish.
4, the quantification method of adjustment of picture quality saltus step as claimed in claim 3 is characterized in that, among the described step Step9, judges whether next coded frame frame exists, and then enters Step11 if exist;
Step11; Utilize current encoded frame and next coded frame to calculate the 4th correction value of current encoded frame quantization parameter;
Step12: utilize the 4th correction value of quantization parameter that current encoded frame is encoded, then next coded frame is set to current encoded frame, then reenters Step1.
Another purpose of the embodiment of the invention is to propose a kind of quantification Adjustment System of picture quality saltus step, described system comprises: the first judge module, the first coding processing module, the second judge module, the first correction value computing module, the second coding processing module, the 3rd judge module, the second correction value computing module, the 3rd coding processing module
The first judge module is used for judging whether that current encoded frame is that P frame and next coded frame are the I frame, then enters if not the first coding processing module, if then enter the second judge module;
The first coding processing module is used for current encoded frame is encoded; Then, judge whether next coded frame exists, if there is no, then finish; Otherwise, make that current encoded frame is next coded frame, reenter again the first judge module;
The second judge module is used for judging whether occurrence scene switches next coded frame with respect to current encoded frame, and if not, scene switching mark variable flag=0 then is if then flag=1 enters the first correction value computing module;
The first correction value computing module is for the first correction value of calculating the current encoded frame quantization parameter;
The second coding processing module is used for utilizing the first correction value of described quantization parameter that current encoded frame is encoded, and then next coded frame is set to current encoded frame;
The 3rd judge module is used for judging whether scene switching mark variable flag=0, if then enter the second correction value computing module;
The second correction value computing module is for the second correction value (QP that calculates the current encoded frame quantization parameter
t M2), enter the 3rd coding processing module;
The 3rd coding processing module is used for utilizing the second correction value of quantization parameter that current encoded frame is encoded, and judges then whether next coded frame frame exists, and if there is no, then finishes; Otherwise next coded frame is set to current encoded frame, then reenters the first judge module.
Further, described system also comprises: the 4th judge module, the 3rd correction value computing module, the 4th coding processing module,
The 3rd judge module is used for judging whether scene switching mark variable flag=0, then enters if not the 4th judge module;
The 4th judge module is used for judging whether next coded frame frame exists, if do not exist, then enters the 3rd correction value computing module;
The 3rd correction value computing module for three correction values of calculating the current encoded frame quantization parameter, enters the 4th coding processing module;
The 4th coding processing module is used for utilizing three correction values of quantization parameter that current encoded frame is encoded, and then finishes.
Further, described system also comprises: the 4th correction value computing module, the 5th coding processing module,
The 4th judge module is used for judging whether next coded frame frame exists, and then enters the 4th correction value computing module if exist,
The 4th correction value computing module is used for utilizing current encoded frame and next coded frame to calculate the 4th correction value of current encoded frame quantization parameter, enters the 5th coding processing module;
The 5th coding processing module is used for utilizing the 4th correction value of quantization parameter that current encoded frame is encoded, and then next coded frame is set to current encoded frame, then reenters the first judge module.
Beneficial effect of the present invention
In order to address the above problem, the embodiment of the invention proposes a kind of quantification method of adjustment and system of picture quality saltus step.Embodiment of the invention method on the one hand, only result from default I frame quantization parameter and last P frame quantization parameter differs greatly and both belong to the phenomenon of a scene together according to picture quality saltus step problem, designed at the image that might produce the picture quality saltus step, reduce both poor methods of quantization parameter, thereby reduce the flickering that produces owing to the picture quality saltus step, promote the subjective effect of encoder.On the other hand, when default I frame and last P frame did not belong to a scene together, image can not produce scintillation yet even quantization parameter differs greatly, and then default I frame will be as the initial reference frame of new scene.Embodiment of the invention method utilizes exercise intensity to adjust quantization parameter, makes encoder further adjust quantization parameter according to the complexity of coding film source, thereby reaches the optimization of the objective performance of coding.
Embodiment
In order to make purpose of the present invention, technical scheme and advantage clearer, below in conjunction with drawings and Examples, the present invention is further elaborated, for convenience of explanation, only show the part relevant with the embodiment of the invention.Should be appreciated that the specific embodiment that this place is described, only be used for explaining the present invention, not in order to limit the present invention.
Embodiment of the invention method on the one hand, only result from default I frame quantization parameter and last P frame quantization parameter differs greatly and both belong to the phenomenon of a scene together according to picture quality saltus step problem, designed at the image that might produce the picture quality saltus step, reduce both poor methods of quantization parameter, thereby reduce the flickering that produces owing to the picture quality saltus step, promote the subjective effect of encoder.On the other hand, when default I frame and last P frame did not belong to a scene together, image can not produce scintillation yet even quantization parameter differs greatly, and then default I frame will be as the initial reference frame of new scene.Embodiment of the invention method utilizes exercise intensity to adjust quantization parameter, makes encoder further adjust quantization parameter according to the complexity of coding film source, thereby reaches the optimization of the objective performance of coding.
Embodiment one
Fig. 1 is the quantification method of adjustment flow chart of a kind of picture quality saltus step of the preferred embodiment of the present invention; Said method comprising the steps of:
Step1: be the I frame if current encoded frame is P frame and next coded frame, then enter Step2; Otherwise, { at first, current encoded frame is encoded; Then, judge whether next coded frame exists, if there is no, then finish; Otherwise, make that current encoded frame is next coded frame, reenter again Step1.}
Step2: judge next coded frame with respect to current encoded frame whether occurrence scene switch (judging namely whether next coded frame is the scene switch frame) if not, flag=0 then, if, flag=1 then.
In full, flag is scene switching mark variable; The scene change detection method can adopt disclosed any method in the industry.
Step3: the first correction value of calculating the current encoded frame quantization parameter.
QP
t m1=clip(QP
t+temp,QP
min,QP
max),
Wherein temp is intermediate variable, and its computational methods are as follows:
If flag=0, then
Otherwise, then
In full,
QP
MinThe presentation code device is set the minimum quantization parameter; QP
MaxThe maximum quantization parameter that the presentation code device is set; Thres1 represents the first decision threshold, general Thres1 〉=3; Thres2 represents the second decision threshold, general Thres2〉38; QP
tThe quantization parameter of expression current encoded frame; QP
t M1The first correction value of expression present frame quantization parameter; QP
T-1The quantization parameter that represents previous coded frame; Frame
jRepresent j coded frame; QP
jRepresent j coded frame quantization parameter; GOP
tThe GOP at expression current encoded frame place is also referred to as current GOP;
Represent current GOP quantization parameter;
Expression is averaged to the variable that satisfies condition; Weight
1Represent the first weight factor; Weight
2Represent the second weight factor, general 0<weight
1<weight
2≤ 0.5.
Step4: utilize the first correction value of described quantization parameter that current encoded frame is encoded.
Step5: next coded frame is set to current encoded frame.
Step6: if flag=0 then enters Step7; If not, then enter Step9.
Step7: the second correction value QP that calculates the current encoded frame quantization parameter
t M2, then utilize the second correction value of quantization parameter that current encoded frame is encoded, enter Step8.
QP
t M2=clip (QP
t+ Thres1-2+temp, QP
Min, QP
Max), wherein temp is intermediate variable, has been calculated by Step3 and has obtained.
Step8: judge whether next coded frame frame exists, if there is no, then finish; Otherwise next coded frame is set to current encoded frame, then reenters Step1.
Step9: judge that whether next coded frame frame exists, if do not exist, then enters step Step10; Then enter Step11 if exist;
Step10: the 3rd correction value QP that calculates the current encoded frame quantization parameter
t M3, then utilize the 3rd correction value of quantization parameter that current encoded frame is encoded, then finish.
QP
t M3=clip (QP
t-temp, QP
Min, QP
Max), wherein temp is intermediate variable, has been calculated by Step3 and has obtained.
Step11: utilize current encoded frame and next coded frame to calculate the 4th correction value of current encoded frame quantization parameter.
(Fig. 2 is the method flow diagram that step Step11 comprises in Fig. 1 flow chart specifically to comprise following steps; ):
The first step is carried out down-sampling to the monochrome information frame of current encoded frame and is processed, and obtains current processed frame; Again the monochrome information frame of next coded frame carried out the down-sampling processing, obtain next processed frame (Downsapling method can adopt known nearest neighbor algorithm, bilinear interpolation, cubic convolution etc.).
Second step is divided into piece with current processed frame, more next processed frame also is divided into piece; And calculate the piece statistical variable of each piece.
Wherein, block size can determine as required, and is commonly used such as 16x16,8x8 etc.; When block size is 16x16, then be called macro block; When the macro block Further Division is that size is n
1Xn
2Piece then the smaller piece of these sizes be called sub-block (n
1≤ 16
Perhapsn
2≤ 16, but both can not equal 16 simultaneously); N piece of current processed frame is designated as
N piece of next processed frame is designated as
With
The palpus in the same size;
Pixel value for the capable j row of current processed frame i;
Pixel value for the capable j row of next processed frame i; Ti_block
T, nExpression piece statistical variable;
Represent next processed frame;
It is right to represent
With
Carry out subtraction, wherein requirement
Belong to
And
Belong to
Then all are asked for
Ask mean square deviation.
The 3rd step, calculate the frame variable, be designated as TI_frame
t
Wherein
In full, Thres3 represents the 3rd decision threshold, and it is the decreasing function of fps, general desirable Thres3=8* (1+24/fps); The frame per second of fps presentation code film source;
Expression all variable summations to satisfying condition; Number
BlockRepresent the piece sum that a two field picture comprises.
The 4th step, the 4th correction value QP of calculating current encoded frame quantization parameter
t M4
QP
t m4=clip(QP
t-clip(const-(TI_frame
t>>bit),ΔQP
min,ΔQP
max),QP
min,QP
max)
In full,〉〉 the right displacement computing of expression; Δ QP
MinThe expression quantization parameter is adjusted lower limit, and is general-10<Δ QP
Min<Δ QP
MaxΔ QP
MaxExpression expression quantization parameter is adjusted the upper limit, general 0<Δ QP
Max<10; Const represents quantization parameter adjustment constant, general const=(ceil (number
Block* weight
3) bit)+1; Weight
3Represent the 3rd weight factor, general 0.6≤weight
3<1; Ceil (x) expression is greater than the smallest positive integral of x; Bit represents the displacement constant, general 1<bit≤log
2Number
Block-1.
Step12: utilize the 4th correction value of quantization parameter that current encoded frame is encoded, then next coded frame is set to current encoded frame, then reenters Step1.
Embodiment two
Fig. 3 is the quantification Adjustment System structure chart of a kind of picture quality saltus step of the preferred embodiment of the present invention; Described system comprises: the first judge module, the first coding processing module, the second judge module, the first correction value computing module, the second coding processing module, the 3rd judge module, the second correction value computing module, the 3rd coding processing module,
The first judge module is used for judging whether that current encoded frame is that P frame and next coded frame are the I frame, then enters if not the first coding processing module, if then enter the second judge module;
The first coding processing module is used for current encoded frame is encoded; Then, judge whether next coded frame exists, if there is no, then finish; Otherwise, make that current encoded frame is next coded frame, reenter again the first judge module;
The second judge module is used for judging whether occurrence scene switches next coded frame with respect to current encoded frame, and if not, scene switching mark variable flag=0 then is if then flag=1 enters the first correction value computing module;
The first correction value computing module is for the first correction value of calculating the current encoded frame quantization parameter;
The second coding processing module is used for utilizing the first correction value of described quantization parameter that current encoded frame is encoded, and then next coded frame is set to current encoded frame;
The 3rd judge module is used for judging whether scene switching mark variable flag=0, if then enter the second correction value computing module;
The second correction value computing module is for the second correction value QP that calculates the current encoded frame quantization parameter
t M2, enter the 3rd coding processing module;
The 3rd coding processing module is used for utilizing the second correction value of quantization parameter that current encoded frame is encoded, and judges then whether next coded frame frame exists, and if there is no, then finishes; Otherwise next coded frame is set to current encoded frame, then reenters the first judge module.
Further, described system also comprises: the 4th judge module, the 3rd correction value computing module, the 4th coding processing module,
The 3rd judge module is used for judging whether scene switching mark variable flag=0, then enters if not the 4th judge module;
The 4th judge module is used for judging whether next coded frame frame exists, if do not exist, then enters the 3rd correction value computing module;
The 3rd correction value computing module for three correction values of calculating the current encoded frame quantization parameter, enters the 4th coding processing module;
The 4th coding processing module is used for utilizing three correction values of quantization parameter that current encoded frame is encoded, and then finishes.
Further, described system also comprises: the 4th correction value computing module, the 5th coding processing module,
The 4th judge module is used for judging whether next coded frame frame exists, and then enters the 4th correction value computing module if exist,
The 4th correction value computing module is used for utilizing current encoded frame and next coded frame to calculate the 4th correction value of current encoded frame quantization parameter, enters the 5th coding processing module;
The 5th coding processing module is used for utilizing the 4th correction value of quantization parameter that current encoded frame is encoded, and then next coded frame is set to current encoded frame, then reenters the first judge module.
Further, in the first correction value computing module, the first correction value of described calculating current encoded frame quantization parameter is specially:
QP
t m1=clip(QP
t+temp,QP
min,QP
max),
Wherein temp is intermediate variable, and its computational methods are as follows:
If flag=0, then
Otherwise, then
In full,
QP
MinThe presentation code device is set the minimum quantization parameter; QP
MaxThe maximum quantization parameter that the presentation code device is set; Thres1 represents the first decision threshold, general Thres1 〉=3; Thres2 represents the second decision threshold, general Thres2〉38; QP
tThe quantization parameter of expression current encoded frame; QP
t M1The first correction value of expression present frame quantization parameter; QP
T-1The quantization parameter that represents previous coded frame; Frame
jRepresent j coded frame; QP
jRepresent j coded frame quantization parameter; GOP
tThe GOP at expression current encoded frame place is also referred to as current GOP;
Represent current GOP quantization parameter;
Expression is averaged to the variable that satisfies condition; Weight
1Represent the first weight factor; Weight
2Represent the second weight factor, general 0<weight
1<weight
2≤ 0.5.
Further, in the second correction value computing module, the second correction value QP of described calculating current encoded frame quantization parameter
t M2Be specially: QP
t M2=clip (QP
t+ Thres1-2+temp, QP
Min, QP
Max);
Further, in the 3rd correction value computing module, calculate the 3rd correction value QP of current encoded frame quantization parameter
t M3Be specially: QP
t M3=clip (QP
t-temp, QP
Min, QP
Max);
Further, the 4th correction value computing module also comprises down-sampling processing module, piece statistical variable computing module, frame variable computing module, the 4th correction value calculating sub module (Fig. 4 is the 4th correction value computing module modular structure figure in Fig. 3 structure chart),
The down-sampling processing module is used for the monochrome information frame of current encoded frame is carried out the down-sampling processing, obtains current processed frame; Again the down-sampling processing is carried out in the monochrome information frame of next coded frame, obtain next processed frame;
Piece statistical variable computing module is used for current processed frame is divided into piece, more next processed frame also is divided into piece; And calculate the piece statistical variable of each piece.
Frame variable computing module is used for calculating the frame variable, is designated as TI_frame
t
The 4th correction value calculating sub module is for the 4th correction value of calculating the current encoded frame quantization parameter.
Further, in the piece statistical variable computing module, the piece statistical variable that calculates each piece is specially:
Wherein, block size can determine as required, and is commonly used such as 16x16,8x8 etc.; When block size is 16x16, then be called macro block; When the macro block Further Division is that size is n
1Xn
2Piece then the smaller piece of these sizes be called sub-block (n
1≤ 16
Perhapsn
2≤ 16, but both can not equal 16 simultaneously); N piece of current processed frame is designated as
N piece of next processed frame is designated as
With
The palpus in the same size;
Pixel value for the capable j row of current processed frame i;
Pixel value for the capable j row of next processed frame i; Ti_block
T, nExpression piece statistical variable;
Represent next processed frame;
It is right to represent
With
Carry out subtraction, wherein requirement
Belong to
And
Belong to
Then all are asked for
Ask mean square deviation.
Further, frame variable computing module, calculate frame variable TI_framet and be specially:
Wherein
In full, Thres3 represents the 3rd decision threshold, and it is the decreasing function of fps, general desirable Thres3=8* (1+24/fps); The frame per second of fps presentation code film source;
Expression all variable summations to satisfying condition; Number
BlockRepresent the piece sum that a two field picture comprises.
Further, in the 4th correction value calculating sub module, calculate the 4th correction value of current encoded frame quantization parameter
Be specially: QP
t M4=clip (QP
t-clip (const-(TI_frame
tBit), Δ QP
Min, Δ QP
Max), QP
Min, QP
Max)
In full,〉〉 the right displacement computing of expression; Δ QP
MinThe expression quantization parameter is adjusted lower limit, and is general-10<Δ QP
Min<Δ QP
MaxΔ QP
MaxExpression expression quantization parameter is adjusted the upper limit, general 0<Δ QP
Max<10; Const represents quantization parameter adjustment constant, general const=(ceil (number
Block* weight
3) bit)+1; Weight
3Represent the 3rd weight factor, general 0.6≤weight
3<1; Ceil (x) expression is greater than the smallest positive integral of x; Bit represents the displacement constant, general 1<bit≤log
2Number
Block-1.
Those having ordinary skill in the art will appreciate that, all or part of step in realization above-described embodiment method can be finished by the program command related hardware, described program can be stored in the computer read/write memory medium, and described storage medium can be ROM, RAM, disk, CD etc.
The above only is preferred embodiment of the present invention, not in order to limiting the present invention, all any modifications of doing within the spirit and principles in the present invention, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.