Summary of the invention
The object of the invention is the defect for prior art this respect, propose a kind of raising method and implement device thereof of video quality, to solve the problem that improves video image quality under low code check.
The object of video quality raising method of the present invention, will be achieved by the following technical programs: a kind of raising method of video quality, is characterized in that comprising the steps:
S1: statistics cost function;
S11, obtains macroblock frame inter mode and cost function thereof by motion estimation module, is designated as InterCost (mv, mode), the motion vector that wherein mv is macro block, the pattern that mode is macro block;
S12, calculates the cost function of 16 * 16 patterns in frame, is designated as Intra16x16Cost (I16), and I16 is the sequence number of 16 * 16 patterns in frame;
S13, calculates the cost function of intra-frame 4 * 4 pattern, is designated as Intra4x4Cost (I4x4), and I4 is the sequence number of all patterns of 4x4 in frame;
S2: bit rate mode determining step, if current code check/frame per second is greater than 6kbps, enter high bit rate mode judging process, if current code check/frame per second is less than or equal to 6kbps, the computation schema weight punishment factor, is designated as Bsp=4* λ * BSPCost (mode), and wherein λ is generally constant, mode is the inter-frame mode of this macro block, and enters low bit rate mode judging process;
S3: high bit rate mode judging process: compare InterCost, Intra16x16Cost, Intra4x4Cost, the decision pattern result of decision is the corresponding pattern of reckling;
S4: low bit rate mode judging process: compare InterCost+Bsp, Intra16x16Cost, Intra4x4Cost, the decision pattern result of decision is the corresponding pattern of reckling.
Further, in step S12, frame interior 16 * 16 has four kinds of patterns, and I16 is 0,1,2,3; Calculate the cost function of 16 * 16 each pattern of macro block in frame, getting wherein minimum cost function is the least cost function of intra-frame 4 * 4 pattern.
Further, the method that calculates the least cost function of intra-frame 4 * 4 pattern in step S13 is: 16 * 16 macro block is divided into the piece of 16 4 * 4, each 4 * 4 is one of nine kinds of patterns, I
4 * 4for arbitrary integer in 0-8; And calculate optimal mode and the cost function of 4 * 4, then by each cost function of 4 * 4 summation.
Video quality of the present invention improves the object of implement device, to be achieved by following system schema, it comprises: the first computing unit, by motion estimation module, obtain macroblock frame inter mode and cost function thereof, be designated as InterCost (mv, mode), the motion vector that wherein mv is macro block, the pattern that mode is macro block;
The second computing unit, for calculating the cost function of 16 * 16 patterns in frame, is designated as Intra16x16Cost (I16), and I16 is the sequence number of 16 * 16 patterns in frame;
The 3rd computing unit, for calculating the cost function of intra-frame 4 * 4 pattern, is designated as Intra4x4Cost (I4x4), I
4 * 4sequence number for all patterns of 4x4 in frame;
Further, bit rate mode judge module, for when current code check/frame per second is greater than 6kbps, enter high bit rate mode judging process, and when current code check/frame per second is less than or equal to 6kbps, the computation schema weight punishment factor, be designated as Bsp=4* λ * BSPCost (mode), wherein λ is generally constant, the inter-frame mode that mode is this macro block, and enter low bit rate mode judging process;
High bit rate mode judging module: for comparing InterCost, Intra16x16Cost, the reckling in Intra4x4Cost, the decision pattern result of decision is the corresponding pattern of reckling;
Low bit rate mode judging module: for comparing InterCost+Bsp, Intra16x16Cost, the reckling in Intra4x4Cost, the decision pattern result of decision is the corresponding pattern of reckling.
Further, in frame, 16 * 16 have four kinds of patterns, and I16 is 0,1,2,3; Described the second computing unit is used for calculating the cost function of 16 * 16 each pattern of macro block in frame, and getting wherein minimum cost function is the least cost function of intra-frame 4 * 4 pattern.
Further, described the 3rd computing unit is for being divided into the piece of 16 4 * 4 by 16 * 16 macro block, and each 4 * 4 is one of nine kinds of patterns, I
4 * 4for arbitrary integer in 0-8; And calculate optimal mode and the cost function of 4 * 4, then by each cost function of 4 * 4 summation.
Contrast the video quality of current video communication system, application technical solution of the present invention can keep higher picture quality, and under low code check condition, can effectively eliminate smear, the subjective video quality that improved under high code check condition.
Embodiment
In order to make the object, technical solutions and advantages of the present invention clearer, below in conjunction with the drawings and specific embodiments, describe the present invention.
As described in Figure 1, in embodiment of the present invention, the raising method of described video quality, comprises step S1: statistics cost function, comprises the most preferably interior cost function of 16 * 16 patterns of cost function, frame and the cost function of intra-frame 4 * 4 pattern of inter-frame mode.
S11, obtains best macroblock frame inter mode and cost function thereof by motion estimation module, is designated as InterCost (mv, mod e), the motion vector that wherein mv is macro block, the pattern that mode is macro block, may be 16 * 16,16 * 8,8 * 16,8 * 4,4 * 8 etc.
S12, calculates the cost function of 16 * 16 patterns in frame, is designated as Intra16x16Cost (I16), and I16 is the sequence number of 16 * 16 patterns in frame.
S13, calculates the cost function of intra-frame 4 * 4 pattern, is designated as Intra4x4Cost (I4x4), and I4 is the sequence number of all patterns of 4x4 in frame.
BSP calculates, and the computation schema weight punishment factor, is designated as Bsp=4* λ * BSPCost (mode), and wherein λ is generally constant, the inter-frame mode that mode is this macro block.
S2: bit rate mode determining step, if current code check/frame per second is greater than a standard value, enter high bit rate mode judging process, if current code check/frame per second is less than or equal to standard value, enter low bit rate mode judging process;
S3: high bit rate mode judging process: compare InterCost, Intra16x16Cost, Intra4x4Cost, the decision pattern result of decision is the corresponding pattern of reckling;
S4: low bit rate mode judging process: compare InterCost+Bsp, Intra16x16Cost, Intra4x4Cost, the decision pattern result of decision is the corresponding pattern of reckling.
As shown in Figure 2, in embodiment of the present invention, the implement device of described raising video quality, comprise the first computing unit, by motion estimation module, obtain macroblock frame inter mode and cost function thereof, be designated as InterCost (mv, mode), the motion vector that wherein mv is macro block, the pattern that mode is macro block.
The second computing unit, for calculating the cost function of 16 * 16 patterns in frame, is designated as Intra16x16Cost (I16), and I16 is the sequence number of 16 * 16 patterns in frame.
The 3rd computing unit, for calculating the cost function of intra-frame 4 * 4 pattern, is designated as Intra4x4Cost (I4x4), and I4 is the sequence number of all patterns of 4x4 in frame.
Bit rate mode judge module, for when current code check/frame per second is greater than a standard value, enter high bit rate mode judging process, and when current code check/frame per second is less than or equal to standard value, the computation schema weight punishment factor, is designated as Bsp=4* λ * BSPCost (mode), and wherein λ is generally constant, mode is the inter-frame mode of this macro block, and enters low bit rate mode judging process.
High bit rate mode judging module: for comparing InterCost, Intra16x16Cost, the reckling in Intra4x4Cost, the decision pattern result of decision is the corresponding pattern of reckling.
Low bit rate mode judging module: for comparing InterCost+Bsp, Intra16x16Cost, the reckling in Intra4x4Cost, the decision pattern result of decision is the corresponding pattern of reckling.
Preferably, in frame, 16 * 16 have four kinds of patterns, and I16 is 0,1,2,3; This second computing unit is used for calculating the cost function of 16 * 16 each pattern of macro block in frame, and getting wherein minimum cost function is the least cost function of intra-frame 4 * 4 pattern.In addition, the 3rd computing unit is for being divided into the piece of 16 4 * 4 by 16 * 16 macro block, and each 4 * 4 is one of nine kinds of patterns, I
4 * 4for arbitrary integer in 0-8; And calculate optimal mode and the cost function of 4 * 4, then by each cost function of 4 * 4 summation.
The organic assembling of above-mentioned those modules, has opened up new application prospect in field of video encoding, can effectively improve the picture quality under the low code check condition of video.
As shown in Fig. 3 to Fig. 7, the concrete implementing procedure figure of video quality raising method of the present invention and high and low bit rate mode judgement flow chart thereof.Following according to those accompanying drawings, how the raising method that is described in further detail video quality of the present invention realizes.
1, calculate the cost function of inter-frame mode.Generally, before encoding, carry out estimation, before and after motion estimation techniques utilization, the picture element movement track of two frames carries out the estimation of kinematic parameter, to realize, use the information of a frame image and predict and express present frame image, remove the redundancy in time-domain.
Definition: mv=(mvx, mvy);
InterCost(mv,mode)=InterSAD(mv)+λ*MVCost(mv,mode);
The absolute difference that wherein InterSAD (mv) is corresponding mv, λ * MVCost (mv, mode) is compensation motion vector, λ is constant conventionally, MVCost (mv, mode) is general cost function in the industry, according to different patterns, W/H can be following value 16,8,4.
2, the cost function that calculates 16 * 16 patterns in frame, is designated as Intra16x16Cost (I16), and I16 is the sequence number of 16 * 16 patterns in frame.The value of I16 can be 0-3, respectively corresponding four kinds of intra prediction modes.
Wherein, f
c(mbx, mby) is current macro data, and Pred (mbx, mby, I16) is that current macro is according to the data of 16 * 16 model predictions in frame.Conventionally λ is constant, and Mode16x16Cost (I16) is pattern cost function, adopts general in the industry algorithm.
3, the cost function that calculates intra-frame 4 * 4 pattern, is designated as Intra4x4Cost (I4x4), and I4 is the sequence number of all patterns of intra-frame 4 * 4.
; Wherein, f
c(mbx, mby) is current macro data, and Pred (mbx, mby, I4x4) is that current macro is according to the data of intra-frame 4 * 4 model prediction.Conventionally λ is constant, and Mode4x4Cost (4x4) is pattern cost function, adopts general in the industry algorithm.The piece that 16 * 16 macro block is divided into 16 4x4, may select a kind of in 9 kinds of patterns for each 4 * 4.Be respectively 0:vertical, 1:horizontal, 2:dc, 3:diagonal down-left, 4:diagonal down-right, 5:vertical-right, 6:horizontal-down, 7:vertical-left, 8:horizontal-up.Calculate intra-frame 4 * 4 pattern least cost function process: for each 4 * 4, carry out optimal mode decision-making, obtain this optimal mode of 4 * 4 and cost function, each cost function of 4 * 4 is added to the least cost function that obtains whole 16 * 16 macro blocks.
4, after omitting narration code check mode decision process, what next will do is to calculate BSP (Block sizepenalty), is designated as Bsp=4* λ * BSPCost (mode); Wherein when mode=0, BSPCost (mode)=0; When mode=1/2, BSPCost (mode)=1; When mode=3, BSPCost (mode)=2; λ is generally constant, the inter-frame mode that mode is this macro block.
5, as shown in Figure 6, if applied environment need to arrange higher code check, compare InterCost, Intra16x16Cost, Intra4x4Cost, obtains the reckling in three.And corresponding mode decision result is the pattern that this reckling is corresponding.For example, if InterCost is minimum, decision-making is inter-frame mode, if Intra16x16Cost is minimum, is 16 * 16 patterns in frame, if Intra4x4Cost is minimum, is intra-frame 4 * 4 pattern.
6, as shown in Figure 7, if applied environment need to arrange low code check, compare InterCost+Bsp, Intra16x16Cost, Intra4x4Cost, obtains the minimum result in three, and corresponding mode decision result is pattern corresponding to this minimum result.For example, if InterCost+Bsp is minimum, decision-making is inter-frame mode, if Intra16x16Cost is minimum, is 16 * 16 patterns in frame, if Intra4x4Cost is minimum, is intra-frame 4 * 4 pattern.
Contrast the video quality of current video communication system, in high code check situation, the utility model algorithm can keep high picture quality under high code check, supervisor's quality that can effectively improve image when low code check (under the condition due to Network Packet Loss or limit bandwidth), reaches the good effect of video communication system.In the application scenarios of low code check, lower owing to being assigned to the relatively high code check of code check of each frame, make most macro block in frame to be chosen 16 * 16 patterns between framing by mode decision algorithm, in the edge of object part, can be chosen between framing 16 * 8 according to the shape of object, 8 * 16,8 * 8 pattern.Like this in low code check condition, because the rebuilt picture quality of former frame is poor or reconstruction error (difference between real image and reconstruction image) is larger, causing at the edge of object along with the direction of motion produces corresponding error, from visual effect, is exactly the effect of smear.This method is intended to improve picture quality whole under this condition, removes smear.In low bit rate mode judgement, employing is carried out block mode weight punishment (BSP) compensation factors to image block pattern, in the stage of pattern choice, make macro block in object edge have more chance to be chosen into frame mode (in frame 16 * 16 or intra-frame 4 * 4) like this, like this with regard to the effective problem that solves smear, the subjective video quality that improved.
In sum, the raising method of video quality of the present invention and innovation essence and the remarkable result of implement device are shown comprehensively.