The hierarchical processing method of frame of video in the video playback
Technical field
The present invention relates to video playing terminal, specially refer to the limited video playing terminal of multimedia processing capability.
Background technology
In video display process, run into such problem through regular meeting: the complexity difference of the scene of different phase in the video sequence, the scene more complicated in some stage, decoding complex degree is higher, and exceeded the disposal ability of terminal, after several frame video images of the intact a certain complex scene of decoder decode, the current time of system just lags behind the normal demonstration time of frame of video, decode frame by frame and show if proceed, then can further aggravate the hysteresis that video image shows, what cause that the user sees is the video of slow play; If the complexity of different scenes differs greatly in the whole video sequence, then cause broadcasting speed inhomogeneous, and whole playing progress rate lag behind.
The method of handling this problem at present is generally: the video sequence to input is decoded as possible, and the Presentation Time Stamp of reference video frames shows; If current system time has lagged behind the input video frame that will decode in the playing process, judge then whether incoming frame is reference frame, if not reference frame, then abandon this frame of video, do not decode, if reference frame then abandons the arrival up to next I frame of present frame and subsequent frame.This method can be alleviated decoding pressure to a certain extent, the demonstration that as far as possible keeps decoded video image is demonstration time of requiring of video image around, is applied in the middle of the player commonly used such as Windows Media Player, Real Player.But, this method is as broad as long treats the frame losing standard of reference frame and non-reference frame, and does not consider the independence that video decode and video show in the video playback, in the video display process of terminal, particularly when the terminal processing capacity wretched insufficiency, cause pause and discontinuous easily.So at the decoding complex degree of video sequence different phase dynamic adjustments decoding processing strategy how, the continuous smooth and easy broadcast that keeps video when terminal processing capacity is not enough just has actual application value as far as possible.
Summary of the invention
The objective of the invention is to: overcome prior art when running into high complexity video sequence or terminal processing capacity wretched insufficiency, the unfavorable drawback of video playback, the video decode pressure of dynamic equilibrium terminal, the fluency of raising video playback improves user's viewing effect; Thereby provide a kind of video playback hierarchical processing method.
To achieve these goals, the invention provides a kind of video playback hierarchical processing method, comprise following steps:
1), video terminal receiver, video frame, calculate the difference between the Presentation Time Stamp of the present frame that current system time and video terminal received of video terminal, and the zone at definite difference place;
2), resolve the frame head of present frame, determine the type of frame of video;
3), the difference between the Presentation Time Stamp of the system time that obtains according to step 1 and present frame, and the type of the frame of video that obtains of step 2 is the present frame classification;
4), according to the rank of frame of video, current video frame is decoded and is shown processing;
5), to all received frame of video of video terminal, repeating step 1) to the operation of step 4).
In the technique scheme, in described step 1), the zone at described definite difference place is at first to set several threshold values, will the time be divided into the zone according to threshold values, then difference and each zone is compared, and determines which zone is difference specifically be in.
Described threshold values has two, represents with x millisecond and y millisecond respectively, will be divided into 3 zones the time according to this threshold values, uses S1, and S2 and S3 represent, represent difference with D, then:
S1:D<x
S2:x<=D<y
S3:D>=y。
In described step 2) in, the type of described frame of video comprises I frame, P frame and B frame, described I frame and P frame are reference frames, described B frame is a non-reference frame, in reference frame, the I frame is a key frame, does not need other reference frame that reference is provided when decoding, the P frame is common reference frame, needs other reference frame that reference is provided when decoding.
In described step 3), described when being the present frame classification, can be divided into four ranks, use L1 respectively, L2, L3, L4 represent, and when described D value belongs to S1, incoming frame is the arbitrary frame type, and rank is L1; When described D value belongs to S2, incoming frame is I frame or P frame, and rank is L2; When described D value belongs to S2, incoming frame is the B frame, and rank is L3; When described D value belongs to S3, incoming frame is the B frame, and rank is L3; When described D value belongs to S3, incoming frame is I frame or P frame, and rank is L4.
In described step 4), to the frame of video of different stage, different handling processes is arranged when show handling in decoding, when the rank of present frame is L1, decodes and show this present frame; When the rank of present frame is L2, the decoding present frame, but do not show; When the rank of present frame is L3, abandon present frame, do not decode and show; When the rank of present frame is L4, abandon current incoming frame and follow-up non-key frame, when receiving next I frame, the rank of this I frame is changed to L1.
Compared with prior art, the present invention has following advantage:
(1) according to the decoding pressure of video playback situation dynamic equilibrium terminal;
(2) take into full account the amplitude of decode time and the difference that shows the time, handle according to the grading of difference;
(3) take into full account the decoding characteristics of dissimilar frame of video, classification alleviates video playback pressure under the prerequisite of the independence of correctness that guarantees decoding and processing;
(4) fluency of raising video playback keeps visual effect as far as possible.
Description of drawings
Fig. 1 is that video playback hierarchical processing method of the present invention is applied in the schematic diagram in the set-top box;
Fig. 2 is the difference of current system time and present frame Presentation Time Stamp;
Fig. 3 is the flow chart of video playback hierarchical processing method of the present invention.
Embodiment
The present invention will be further described below in conjunction with the drawings and specific embodiments.
Video playback hierarchical processing method of the present invention can be applicable in as shown in Figure 1 the scene.Set-top box is sent the Video service request by broadband network to streaming media server, and streaming media server responds this request, and sends video data by network to set-top box, and set-top box is decoded after receiving video data, delivers to television set then and shows.In this scene, the network bandwidth can satisfy the transmission demand of video flowing, and the network receiver module of set-top box also has enough abilities to carry out Data Receiving, but the video decoding capability deficiency of set-top box can't satisfy the total data of video flowing is carried out real-time decoding.Video playback hierarchical processing method of the present invention just is being applicable to the situation of this video terminal decoding capability deficiency.
As shown in Figure 3, utilize video playback hierarchical processing method of the present invention that a sequence of frames of video is handled, comprise following frame of video in this sequence of frames of video:
I、P、B、B、P、B、B、I、P、B。
The specific implementation step that frame of video in the above-mentioned sequence of frames of video is handled is as follows:
1, the difference between the Presentation Time Stamp of the current system time of computing set-top box and present frame is the zone that difference is determined the place according to pre-set threshold.As shown in Figure 2, in one embodiment, represent the difference of the Presentation Time Stamp of current system time and present frame with D, x and y are the thresholdings of difference, are set at 0 millisecond and 500 milliseconds respectively, and the then whole time period can be divided into three zones, use S1 respectively, S2 and S3 represent.Wherein:
The Presentation Time Stamp of the current system time-present frame of D=
S1:D<0
S2:0<=D<500
S3:D>=500。
In one embodiment, set-top box at first receives a frame of video, the difference between the current system time of computing set-top box and the Presentation Time Stamp of present frame, and the difference of supposing this frame of video is 10 milliseconds, the time difference of this frame of video is arranged in region S 2.
2, resolve the frame head of frame of video, determine the type of current input video frame.The type of frame of video can be divided into I frame, P frame and B frame, and wherein I frame and P frame are reference frames, and the B frame is a non-reference frame.In reference frame, the I frame is a key frame, and key frame does not need other reference frame that the reference frame of reference is provided when being meant decoding, and the P frame is common reference frame, and common reference frame needs other reference frame that the reference frame of reference is provided when being meant decoding.When frame of video being done decoding, the information that the dependence of I frame itself is comprised can realize decoding, the information of an I frame or other P frames that needs the P frame could realize the decoding to it, a B frame I frame of needs and a P frame, or two P frames could be realized the decoding to it.The frame head of parse for frame can be determined the type of present frame.
In the described embodiment of step 1, the frame head of the frame of video that set-top box is received is done parsing, and this frame of video is the I frame as can be known.
The type of the input video frame that 3, the difference between the Presentation Time Stamp of current system time that obtains according to
step 1 and present frame, and
step 2 obtains is classified to current frame of video as standard.In the present embodiment, for frame of video is provided with four ranks, use L1 respectively, L2, L3, L4 represent, make L represent other value of level, and then the value of L is determined by table 1
Temporal interpolation (D) | Frame type (T) | Handle rank (L) |
S1 | I/P/B | L1 |
S2 | I/P | L2 |
S2 | B | L3 |
S3 | B | L3 |
S3 | I/P | L4 |
Table 1
In the last table 5 kinds of situations of branch fraction of input video frame are discussed:
(I) the D value belongs to S1, and incoming frame is arbitrary frame type (I frame, P frame or a B frame), L value L1;
(II) the D value belongs to S2, and incoming frame is reference frame (I frame or a P frame), L value L2;
(III) the D value belongs to S2, and incoming frame is non-reference frame (a B frame), L value L3;
(IV) the D value belongs to S3, and incoming frame is non-reference frame (a B frame), L value L3;
(V) the D value belongs to S3, and incoming frame is reference frame (I frame or a P frame), L value L4.
In step 1 and the described embodiment of step 2, the time difference of I frame is in S2, and as shown in Table 1, the processing rank of this frame is L2.
4,, frame of video is decoded and shown processing according to the rank of frame of video.For the frame of video of different stage, different processing procedures is arranged, it is implemented as follows:
(A) L=L1, decoding also shows incoming frame;
(B) L=L2, the decoding incoming frame, but do not show;
(C) L=L3 abandons incoming frame, does not decode and shows
(D) L=L4 abandons incoming frame and follow-up non-key frame, when receiving next I frame the value of L is changed to L1.
The I frame that aforesaid processing rank is L2, this incoming frame of decoding, but do not show.
5,, repeat by the operation of step 1 to step 4 to all received input video frame of set-top box.
P in the sequence of frames of video, B, B, P, B, B, I, P, B are repeated above-mentioned step successively, and all frames in this sequence of frames of video are all finished decoding and display operation.