Summary of the invention
The purpose of the embodiment of the present invention is to propose a kind of Video coding exercise intensity quantization method, be intended to solve the prior art encoder when encoding, do not consider in film source the difference of the violent and image that motion is slow or static of motion, adopt universal coding side rate, can not reach the optimized problem of distortion performance, subjective effect.
The embodiment of the present invention is achieved in that a kind of Video coding exercise intensity quantization method, and described method comprises:
Judgement frame
tWhether be the I frame, if not,
Make n=1;
Select current coding macro block Mb
t,nCoding mode;
Calculate current coding macro block Mb
t,nExercise intensity and vague intensity;
According to different coding structures and different frame categories, computing macro block Mb
t,nThe correction quantization parameter
According to current coding macro block Mb
t,nCoding mode and revise quantization parameter
To macro block Mb
t,nAdvance
The row coding;
Judge whether n 〉=width*height/256 sets up, make if not n=n+1, return to and enter step " selection current coding macro block Mb
t,nCoding mode ", if,
Judgement min (FrameNum (frame
mm) | frame
mmDo not encode) whether exist, finish if do not exist, otherwise
Judgement FrameNum (frame
m_i)=min (FrameNum (frame
mm) | frame
mmDo not encode) whether set up, if, make t=m_i, reenter step " judgement frame
tWhether be the I frame ", finish if not;
Wherein, frame
tIt is t frame coded frame; T presentation code frame frame
tTime sequence number in current source sequence; N represents macro block Mb
t,nAt frame
tIn position number; Mb
t,nRepresent t frame coded frame frame
tN macro block: width, height represents respectively columns and the line number of a two field picture take whole pixel as unit;
Frame
m_iRepresent m_i frame coded frame; Frame
mmRepresent mm frame coded frame; M_i presentation code frame frame
m_iTime sequence number in current source sequence; Mm presentation code frame frame
mmTime sequence number in current source sequence; FrameNum (frame
mm) expression frame
mmThe coding sequence number; FrameNum (frame
m_i) expression frame
m_iThe coding sequence number; Min (variable | condition) represent satisfying condition
All variablees minimize.
Further, described step " judgement frame
tWhether be the I frame " also comprise before step
Make t=1.
Further, described step " judgement frame
tWhether be the I frame ", if, to frame
tThen coding enters step " judgement min (FrameNum (frame
mm) | frame
mmDo not encode) whether exist ".
The purpose of the embodiment of the present invention is to propose a kind of Video coding exercise intensity quantization device, and described device comprises:
The first initialization module, frame category judging treatmenting module, the first coding module, the second initialization module, coding mode are selected module, exercise intensity and vague intensity computing module, are revised quantification parameter calculating module, the second coding module, the first judging treatmenting module, the second judging treatmenting module, the 3rd judging treatmenting module
The first initialization module is used for initialization t=1; T presentation code frame frame
tTime sequence number in current source sequence;
The frame category judging treatmenting module is used for judgement frame
tWhether be the I frame, if enter the first coding module, otherwise enter the second initialization module;
The first coding module is used for frame
tEncode, enter the second judging treatmenting module;
The second initialization module is used for initialization and makes n=1; N represents macro block Mb
t,nAt frame
tIn position number;
Coding mode is selected module, is used for selecting current coding macro block Mb
t,nCoding mode;
Exercise intensity and vague intensity computing module are used for calculating Mb
t,nExercise intensity and vague intensity;
Revise the quantification parameter calculating module, be used for according to different coding structures and different frame categories, computing macro block Mb
t,nThe correction quantization parameter
The second coding module is used for according to current coding macro block Mb
t,nCoding mode and revise quantization parameter
, to macro block Mb
t,nEncode;
The first judging treatmenting module if be used for judgement n 〉=width*height/256, enters the second judging treatmenting module, otherwise, make n=n+1, reenter coding mode and select module; Width, height represent respectively columns and the line number of a two field picture take whole pixel as unit;
The second judging treatmenting module is if be used for judgement min (FrameNum (frame
mm) | frame
mmDo not encode) do not exist, finish, otherwise, enter the 3rd judging treatmenting module;
The 3rd judging treatmenting module is used for judgement
If FrameNum is (frame
m_i)=min (FrameNum (frame
mm) | frame
mmDo not encode),
, make t=m_i, reenter the frame category judging treatmenting module, otherwise, finish;
Wherein, frame
m_iRepresent m_i frame coded frame; Frame
mmRepresent mm frame coded frame; M_i presentation code frame frame
m_iTime sequence number in current source sequence; Mm presentation code frame frame
mmTime sequence number in current source sequence; FrameNum (frame
mm) expression frame
mmThe coding sequence number; FrameNum (frame
m_i) expression frame
m_iThe coding sequence number; Min (variable | condition) represent all variablees that satisfy condition are minimized.
Beneficial effect of the present invention
The embodiment of the present invention proposes a kind of Video coding exercise intensity quantization method and device.At first propose macro block exercise intensity, vague intensity securing mechanism, then according to exercise intensity and the vague intensity of each macro block, design quantizes to adjust strategy on different coding structure and different frame classification.Adjust the design of strategy by this subsequent quantizatiion, can realize that code check carries out the secondary adjustment according to exercise intensity, namely reach for the violent less code check of macroblock allocation of motion, the Data Rate Distribution that this part is saved arrives the part that video image subjective effect, distortion performance is promoted sensitivity, finally, reach encoder and acutely reach the distortion performance in the violent situation of non-motion, the optimization realization of subjective effect in motion.
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 to the embodiment of the present 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.
The embodiment of the present invention proposes a kind of Video coding exercise intensity quantization method and device.At first propose macro block exercise intensity, vague intensity securing mechanism, then according to exercise intensity and the vague intensity of each macro block, design quantizes to adjust strategy on different coding structure and different frame classification.Adjust the design of strategy by this subsequent quantizatiion, can realize that code check carries out the secondary adjustment according to exercise intensity, namely reach for the violent less code check of macroblock allocation of motion, the Data Rate Distribution that this part is saved arrives the part that video image subjective effect, distortion performance is promoted sensitivity, finally, reach encoder and acutely reach the distortion performance in the violent situation of non-motion, the optimization realization of subjective effect in motion.
Embodiment one
Fig. 1 is a kind of Video coding exercise intensity of preferred embodiment of the present invention quantization method flow chart, said method comprising the steps of:
S101 makes t=1.
T presentation code frame frame
tTime sequence number in current source sequence, being called for short t is coded frame frame
tThe time sequence number;
S102, judgement frame
tWhether be the I frame, if, to frame
tThen coding enters step S108; Otherwise enter step S103;
Frame
tBe called t frame coded frame, also referred to as current encoded frame;
S103 makes n=1;
S104 selects current coding macro block Mb
t,nCoding mode, calculate Mb
t,nExercise intensity and vague intensity.
S1041: calculate Mb
t,nExercise intensity, that is:
S1042: calculate Mb
t,nVague intensity, that is:
If Mb_intensity
t,n=max (width, height) * 4,
, wherein,
In the embodiment of the present invention, when block size is 16x16, be called macro block; The size that is when the macro block Further Division is n
1xn
2Piece (n
1≤ 16 or n
2≤ 16, but both can not equal 16 simultaneously), the smaller piece of these sizes is called sub-block;
Mb
t,nRepresent t frame coded frame frame
tN macro block (being current coding macro block); N represents macro block Mb
t,nAt frame
tIn position number; Mb_intensity
t,nBe Mb
t,nExercise intensity; Block
T, n, mRepresent t frame coded frame frame
tN macro block Mb
t,nM sub-block; M represents sub-block block
T, n, mAt Mb
t,nIn position number;
Expression macro block Mb
t,nMotion vector,
Expression sub-block block
T, n, mMotion vector, first representation in components motion vector of above-mentioned motion vector is at the component on the x direction of principal axis, the component of second representation in components motion vector on the y direction of principal axis; Abs represents to ask absolute value; Width, height represent respectively columns and the line number of a two field picture take whole pixel as unit;
Expression all variable maximizings to satisfying condition; Max (a, b) represents a, the b maximizing;
Fuzzy_intensity
t,nBe Mb
t,nVague intensity;
Expression is asked mean square deviation to all variablees that satisfy condition;
(y
t(i, j)) expression Mb
t,nThe brightness mean square deviation;
(u
t(i, j)) expression Mb
t,nU colourity mean square deviation;
(v
t(i, j)) expression Mb
t,nV colourity mean square deviation;
Expression Mb
t,nThe maximum of u colourity mean square deviation v colourity mean square deviation; y
t(i, j), u
t(i, j), v
t(i, j) represents respectively frame
tThe capable j row of i brightness value, frame
tThe capable j row of i colourity u component chromatic value, frame
tThe capable j row of i colourity v component chromatic value.
S105 is according to different coding structures and different frame categories, computing macro block Mb
t,nCorrection quantize
Parameter
, specific as follows:
Situation 1: when coding structure is IP ... P(is namely without the B frame) and frame
tFrame category when being the P frame
If
(Mb_intensity
t,nThres
1And Mb_intensity
T, n1≠ max (width, height) * 4 and Mb
t,nBe inter-frame forecast mode)
Or, (Mb_intensity
t,n=max (width, height) * 4 and Fuzzy_intensity
t,n<2.5 and
(y
t(i, j))<10)
Otherwise,
In full,
QP
minFor encoder is set the minimum quantization parameter;
QP
maxMaximum quantization parameter for the encoder setting; QP
t,nBe Mb
t,nInitial quantization parameters;
Be Mb
t,nCorrection quantize the parameter increase value;
Be Mb
t,nThe correction quantization parameter; Thres
1Decision threshold for
situation 1; Const
1, const
2, be respectively quantification and adjust
parameter 1, quantize to adjust parameter 2; General const
1=10, const
2=20, Thres
1=25* (1+24/fps), the frame per second of fps presentation code film source; Int (x) expression rounds calculating.
Situation 2: when coding structure is IB ... BPB ... BP(namely contains the B frame) and frame
tWhen frame category is the P frame
If
(Mb_intensity
t,nThres
2And Mb_intensity
t,n≠ max (width, height) * 4 and Mb
t,nBe inter-frame forecast mode)
Or
(Mb_intensity
t,n=max (width, height) * 4 and Fuzzy_intensity
t,n<2.5 and
(y (i, j))<10)
,
Otherwise,
Wherein, const
3For quantizing to adjust parameter 3, general, const
3=const
2+ 8* (1+bframe), the B frame period that bframe presentation code device is set; Thres
2Be the decision threshold of situation 2, general, Thres
2=Thres
1+ 25* (1+bframe).
Situation 3: when coding structure is IB ... BPB ... BP(namely contains the B frame) and frame
tWhen frame category is the B frame
If
(frame
tAs the reference frame)
And
(
(Mb_intensity
t,nThres
2And Mb_intensity
t,n≠ max (width, height) * 4 and Mb
t,nBe inter-frame forecast mode),
Or
(Mb_intensity
t,n=max (width, height) * 4 and Fuzzy_intensity
t,n<2.5 and
(y (i, j))<10)
)
,
Otherwise, if
(frame
tConduct is not with reference to frame)
And
(
(Mb_intensity
t,nThres
2And Mb_intensity
T, n1≠ max (width, height) * 4 and Mb
t,nBe inter-frame forecast mode)
Or
(Mb_intensity
t,n=max (width, height) * 4 and Fuzzy_intensity
t,n<2.5 and
(y (i, j))<10)
)
,
Otherwise,
S106: according to current coding macro block Mb
t,nCoding mode and revise quantization parameter
, to macro block Mb
t,nEncode;
S107: if n 〉=width*height/256 enters S108; Otherwise n=n+1, reenter S104.
S108: if min is (FrameNum (frame
mm) | frame
mmDo not encode) do not exist, finish; Otherwise, enter step S109;
S109: if FrameNum is (frame
m_i)=min (FrameNum (frame
mm) | frame
mmDo not encode),
, t=m_i reenters S102, otherwise, finish.
Wherein, frame
m_iRepresent m_i frame coded frame; Frame
mmRepresent mm frame coded frame; M_i presentation code frame frame
m_iTime sequence number in current source sequence, being called for short m_i is coded frame frame
m_iThe time sequence number; Mm presentation code frame frame
mmTime sequence number in current source sequence, being called for short mm is coded frame frame
mmThe time sequence number; FrameNum (frame
mm) expression frame
mmThe coding sequence number; FrameNum (frame
m_i) expression frame
m_iThe coding sequence number; Min (variable | condition) represent all variablees that satisfy condition are minimized.
Embodiment two
Fig. 2 is a kind of Video coding exercise intensity of preferred embodiment of the present invention quantization device structure chart, and described device comprises: the first initialization module, frame category judging treatmenting module, the first coding module, the second initialization module, coding mode are selected module, exercise intensity and vague intensity computing module, are revised quantification parameter calculating module, the second coding module, the first judging treatmenting module, the second judging treatmenting module, the 3rd judging treatmenting module.
The first initialization module is used for initialization t=1; T presentation code frame frame
tTime sequence number in current source sequence, being called for short t is coded frame frame
tThe time sequence number;
The frame category judging treatmenting module is used for judgement frame
tWhether be the I frame, if enter the first coding module, otherwise enter the second initialization module;
The first coding module is used for frame
tEncode, enter the second judging treatmenting module;
The second initialization module is used for initialization and makes n=1; N represents macro block Mb
t,nAt frame
tIn position number;
Coding mode is selected module, is used for selecting current coding macro block Mb
t,nCoding mode;
Exercise intensity and vague intensity computing module are used for calculating Mb
t,nExercise intensity and vague intensity;
Revise the quantification parameter calculating module, be used for according to different coding structures and different frame categories, computing macro block Mb
t,nThe correction quantization parameter
The second coding module is used for according to current coding macro block Mb
t,nCoding mode and revise quantization parameter
, to macro block Mb
t,nEncode;
The first judging treatmenting module if be used for judgement n 〉=width*height/256, enters the second judging treatmenting module, otherwise, make n=n+1, reenter coding mode and select module; Width, height represent respectively columns and the line number of a two field picture take whole pixel as unit;
The second judging treatmenting module is if be used for judgement min (FrameNum (frame
mm) | frame
mmDo not encode) do not exist, finish, otherwise, enter the 3rd judging treatmenting module;
The 3rd judging treatmenting module is used for judgement
If FrameNum is (frame
m_i)=min (FrameNum (frame
mm) | frame
mmDo not encode),
, make t=m_i, reenter the frame category judging treatmenting module, otherwise, finish.
Wherein, frame
m_iRepresent m_i frame coded frame; Frame
mmRepresent mm frame coded frame; M_i presentation code frame frame
m_iTime sequence number in current source sequence, being called for short m_i is coded frame frame
m_iThe time sequence number; Mm presentation code frame frame
mmTime sequence number in current source sequence, being called for short mm is coded frame frame
mmThe time sequence number; FrameNum (frame
mm) expression frame
mmThe coding sequence number; FrameNum (frame
m_i) expression frame
m_iThe coding sequence number; Min (variable | condition) represent all variablees that satisfy condition are minimized.
Described " calculating Mb
t,nExercise intensity and vague intensity " be specially:
Calculate Mb
t,nExercise intensity, that is:
Calculate Mb
t,nVague intensity, that is:
If Mb_intensity
t,n=max (width, height) * 4,
, wherein,
In the embodiment of the present invention, when block size is 16x16, be called macro block; The size that is when the macro block Further Division is n
1xn
2Piece (n
1≤ 16 or n
2≤ 16, but both can not equal 16 simultaneously), the smaller piece of these sizes is called sub-block;
Mb
t,nRepresent t frame coded frame frame
tN macro block (being current coding macro block); N represents macro block Mb
t,nAt frame
tIn position number; Mb_intensity
t,nBe Mb
t,nExercise intensity; Block
T, n, mRepresent t frame coded frame frame
tN macro block Mb
t,nM sub-block; M represents sub-block block
T, n, mAt Mb
t,nIn position number;
Expression macro block Mb
t,nMotion vector,
Expression sub-block block
T, n, mMotion vector, first representation in components motion vector of above-mentioned motion vector is at the component on the x direction of principal axis, the component of second representation in components motion vector on the y direction of principal axis; Abs represents to ask absolute value; Width, height represent respectively columns and the line number of a two field picture take whole pixel as unit;
Expression all variable maximizings to satisfying condition; Max (a, b) represents a, the b maximizing;
Fuzzy_intensity
t,nBe Mb
t,nVague intensity;
Expression is asked mean square deviation to all variablees that satisfy condition;
(y
t(i, j)) expression Mb
t,nThe brightness mean square deviation;
(u
t(i, j)) expression Mb
t,nU colourity mean square deviation;
(v
t(i, j)) expression Mb
t,nV colourity mean square deviation;
Expression Mb
t,nThe maximum of u colourity mean square deviation v colourity mean square deviation; y
t(i, j), u
t(i, j), v
t(i, j) represents respectively frame
tThe capable j row of i brightness value, frame
tThe capable j row of i colourity u component chromatic value, frame
tThe capable j row of i colourity v component chromatic value.
Described " according to different coding structures and different frame categories, computing macro block Mb
t,nCorrection quantize
Parameter
N ", specific as follows:
Situation 1: when coding structure is IP ... P(is namely without the B frame) and frame
tIf frame category when being the P frame
(Mb_intensity
t,nThres
1And Mb_intensity
T, n1≠ max (width, height) * 4 and Mb
t,nBe inter-frame forecast mode)
Or,
(Mb_intensity
t,n=max (width, height) * 4 and Fuzzy_intensity
t,n<2.5 and
(y
t(i, j))<10)
Otherwise,
In full,
QP
minFor encoder is set the minimum quantization parameter;
QP
maxMaximum quantization parameter for the encoder setting; QP
t,nBe Mb
t,nInitial quantization parameters;
Be Mb
t,nCorrection quantize the parameter increase value;
Be Mb
t,nThe correction quantization parameter; Thres
1Decision threshold for
situation 1; Const
1, const
2, be respectively quantification and adjust
parameter 1, quantize to adjust parameter 2; General const
1=10, const
2=20, Thres
1=25* (1+24/fps), the frame per second of fps presentation code film source; Int (x) expression rounds calculating.
Situation 2: when coding structure is IB ... BPB ... BP(namely contains the B frame) and frame
tWhen frame category is the P frame
If
(Mb_intensity
t,nThres
2And Mb_intensity
t,n≠ max (width, height) * 4 and Mb
t,nBe inter-frame forecast mode)
Or
(Mb_intensity
t,n=max (width, height) * 4 and Fuzzy_intensity
t,n<2.5 and
(y (i, j))<10)
,
Otherwise,
Wherein, const
3For quantizing to adjust parameter 3, general, const
3=const
2+ 8* (1+bframe), the B frame period that bframe presentation code device is set; Thres
2Be the decision threshold of situation 2, general, Thres
2=Thres
1+ 25* (1+bframe).
Situation 3: when coding structure is IB ... BPB ... BP(namely contains the B frame) and frame
tWhen frame category is the B frame
If
(frame
tAs the reference frame)
And
(
(Mb_intensity
t,nThres
2And Mb_intensity
t,n≠ max (width, height) * 4 and Mb
t,nBe inter-frame forecast mode),
Or
(Mb_intensity
t,n=max (width, height) * 4 and Fuzzy_intensity
t,n<2.5 and
(y (i, j))<10)
)
,
Otherwise, if
(frame
tConduct is not with reference to frame)
And
(
(Mb_intensity
t,nThres
2And Mb_intensity
T, n1≠ max (width, height) * 4 and Mb
t,nBe inter-frame forecast mode)
Or
(Mb_intensity
t,n=max (width, height) * 4 and Fuzzy_intensity
t,n<2.5 and
(y (i, j))<10)
)
,
Otherwise,
Those having ordinary skill in the art will appreciate that, realize that all or part of step in above-described embodiment method can complete by the program command related hardware, described program can be stored in a computer read/write memory medium, and described storage medium can be ROM, RAM, disk, CD etc.
The above is only 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., within all should being included in protection scope of the present invention.