CN102300096A - Frame type detection method and frame type detection system - Google Patents
Frame type detection method and frame type detection system Download PDFInfo
- Publication number
- CN102300096A CN102300096A CN 201110278580 CN201110278580A CN102300096A CN 102300096 A CN102300096 A CN 102300096A CN 201110278580 CN201110278580 CN 201110278580 CN 201110278580 A CN201110278580 A CN 201110278580A CN 102300096 A CN102300096 A CN 102300096A
- Authority
- CN
- China
- Prior art keywords
- frame
- length
- continuous
- type sequence
- current detection
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Landscapes
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
The invention provides a frame type detection method and a frame type detection system. The length of a detected frame type sequence is gradually increased, the length of a continuous frame B in the frame type sequence is continuously increased, the coding cost of the frame type sequence is calculated and an optimal frame type sequence is finally output, so frames P and B can be rapidly positioned, the variations of the frame type sequence can be well reflected, and the compression rate of a video coder can be ensured; moreover, the coding cost of the frame type sequence is calculated, so the frame P can be nicely selected and the image quality of the video coder can be ensured.
Description
Technical field
The present invention relates to field of video processing, relate in particular to a kind of frame type detection method and frame type detection system.
Background technology
In the video encoder, have three kinds of frame types: I frame, P frame and B frame.Wherein, the I frame is an intracoded frame, does not need other frames as coded reference, and image quality is kept but compression ratio after encoding is lower; The P frame is a forward-predictive-coded frames, and it needs one or more forward reference frame, and its compression ratio is than I vertical frame dimension, but image quality is not as the I frame; The B frame is the bi-directional predictive coding frame, and it needs forward direction and back forecast coded frame, and B frame compression ratio is the highest, and image quality is the poorest.
By the characteristics of frame type as can be seen, the final compression ratio of the selection of frame type and encoder has bigger relation.The B frame is many more, and compression ratio will be high more, otherwise I, P frame are many more, and compression ratio will be low more.Along with increasing of compression ratio, the quality of video just has tangible influence.Because the ratio of I frame in the entire frame sequence be generally less than 3%,, the compression ratio and the video quality of video encoder there is important relationship so how just right frame in the decision frame sequence still be the B frame for the P frame.
Therefore need a kind of frame type detection method and frame type detection system, reasonably orient P frame and B frame fast, guarantee the compression ratio and the video quality of video encoder.
Summary of the invention
The object of the present invention is to provide a kind of frame type detection method and frame type detection system, reasonably orient P frame and B frame fast, guarantee the compression ratio and the video quality of video encoder.
For addressing the above problem, the invention provides a kind of frame type detection method, comprising:
Know the length to be detected and the minimum code cost value of frame sequence according to the parameter of video encoder;
The current detection length of setting frame sequence increases to described length to be detected from an initial length, and determines the maximum length of the continuous B frame under the described current detection length;
Calculate described current detection length and the continuous optimal frames type sequence under the maximum length of B frame thereof according to described minimum code cost value;
Export described length to be detected and the continuous optimal frames type sequence under the maximum length of B frame thereof.
Further, the step of determining the maximum length of the continuous B frame under the described current detection length comprises:
Know the B frame value at most continuously of regulation according to the parameter of video encoder;
In described current detection length and described at most continuous B frame value, get the maximum length of minimum value as the continuous B frame under the described current detection length.
Further, according to described minimum code cost value calculate described current detection length and continuously the step of the optimal frames type sequence under the maximum length of B frame comprise:
At first, the current length of setting the continuous B frame in the described frame sequence increases to the maximum length of described continuous B frame from an initial length;
Then, calculate frame type sequence and encoding and decoding cost thereof under the current length of each continuous B frame;
Then, the output encoder cost is described current detection length and the optimal frames type sequence under the maximum length of B frame continuously thereof less than the frame type sequence of coding cost minimum in all frame type sequences of described minimum code cost value.
Further, when calculating frame type sequence under the current length of each continuous B frame and encoding and decoding cost thereof, it is after last frame that current length that described current detection length deducts described continuous B frame subtracts 1 o'clock optimal frames type sequence again is changed to the P frame, as the frame type sequence under the current length of described continuous B frame that frame sequence is detected length;
Calculate the coding cost of the frame type sequence under the current length of described continuous B frame according to the SAD between frame and the frame (sum of absolute differences, absolute difference and) value.
Accordingly, the present invention also provides a kind of frame type detection system, comprising: parameter initialization unit, continuous B frame length determining unit, optimal frames type sequence computing unit and output unit, wherein,
The parameter initialization unit is used for knowing according to the parameter of video encoder the length to be detected and the minimum code cost value of frame sequence;
Continuous B frame length determining unit, the current detection length that is used to set frame sequence increases to described length to be detected from an initial length, and determines the maximum length of the continuous B frame under the described current detection length;
Optimal frames type sequence computing unit is used for calculating described current detection length and the continuous optimal frames type sequence under the maximum length of B frame thereof according to described minimum code cost value;
Output unit is used for exporting described length to be detected and the continuous optimal frames type sequence under the maximum length of B frame thereof according to the result of calculation of described continuous B frame length determining unit and optimal frames type sequence computing unit.
Compared with prior art, frame type detection method of the present invention and frame type detection system, by progressively increasing the frame type sequence length that detects, and progressively increase in the frame sequence length of B frame continuously, calculate the coding cost of frame sequence, the optimal frames type sequence of final output, can orient P frame and B frame fast, the variation of reaction frame sequence well, guarantee the compression ratio of video encoder, and by the coding cost of calculating frame sequence can be just right select the P frame, make the picture quality of video encoder be guaranteed.
Description of drawings
Fig. 1 is the frame type detection method flow chart of the embodiment of the invention one;
Fig. 2 is the maximum length flow chart of the continuous B frame of determining of the embodiment of the invention one;
Fig. 3 is the flow chart of the calculating optimal frames type sequence of the embodiment of the invention one;
Fig. 4 is the structural representation of the frame type detection system of the embodiment of the invention two.
Embodiment
Below in conjunction with the drawings and specific embodiments frame type detection method and the frame type detection system that the present invention proposes is described in further detail.
Embodiment one
As shown in Figure 1, present embodiment provides a kind of frame type detection method, may further comprise the steps:
S1 is known the length to be detected and the minimum code cost value of frame sequence according to the parameter of video encoder;
S2, the current detection length of setting frame sequence increases to described length to be detected from an initial length, and determines the maximum length of the continuous B frame under the described current detection length;
S3 calculates described current detection length and the continuous optimal frames type sequence under the maximum length of B frame thereof according to described minimum code cost value;
S4 exports described length to be detected and the continuous optimal frames type sequence under the maximum length of B frame thereof.
In the present embodiment, know length num_frames to be detected for needing the length of the frame sequence of detection altogether in step S1, value not necessarily can obtain from the parameter of video encoder.For video encoding standard H.264, the value of num_frames is no more than the value 250 of length m ax_lhead of maximum detectable frame sequences of video encoder regulation.In step S1, can also define the data structure of this method, comprise the P frame that three variablees record detects and the sequence information of B frame: character string aray variable best_paths, string variable temp_path and temp_path2, wherein, best_paths[i]={ x
0, x
1... x
Num_frames-1, 0≤i≤b_frame+2, x
k=0 or 1, best_paths[i] optimal frames type sequence when expression detects length and is i, element x
kRepresented that the k frame was the B frame in the optimal frames type sequence at=0 o'clock, element x
kRepresented that the k frame was the P frame in the optimal frames type sequence at=1 o'clock.For video encoding standard H.264, in step S1, can also know the B frame value b_frame=16 at most continuously that stipulates in the video encoder simultaneously, character string array best_paths this moment total [b_frame+2] OK, every row has [max_lhead/8+1] individual character), " 1 " represents the P frame in the optimal frames type sequence under the maximum length of the length of exporting in step S4 described to be detected and its continuous B frame thus, " 0 " expression B frame, not only can orient P frame and B frame, the variation of reaction frame sequence well fast.
Need to prove, step S2 and step S3 recursive call process in fact time the in the present embodiment, best_paths[i among the step S2], temp_path and temp_path2 initialization, set the initial length j=2 of the current detection length of frame sequence, progressively increase to described length to be detected, determine the maximum length of the continuous B frame under the described current detection length, and invocation step S3, calculate the optimal frames type sequence under the maximum length of each current detection length and its continuous B frame, when current detection length is described length to be detected, finish.
As shown in Figure 2, step S2 specifically comprises:
S21, initializing variable best_paths, temp_path, temp_path2 in the present embodiment, empty best_paths, temp_path, temp_path2, and best_paths[1]=" 01 ", the initial length j=2 of the current detection length of setting frame sequence;
Whether S22, the initial length j that judges current detection length be smaller or equal to num_frames, if execution S23 if not, carries out S26;
S23, determine the maximum length max_add_len of the continuous B frame under the described current detection length j, in the present embodiment, the maximum length max_add_len of B frame gets minimum value in described current detection length and described at most continuous B frame value continuously, be max_add_len=Min (b_frame, j);
S24, the initial length j of current detection length, best_paths, max_add_len, best_cpst are come invocation step S3 as parameter, obtain described current detection length j and the continuous optimal frames type sequence under the maximum length max_add_len of B frame, be saved in best_paths[j] in;
S25, j=j+1, redirect S22;
S26, length is that the optimal frames type sequence of num frames is best_paths[num_frames], finish.
What as shown in Figure 3, step S3 was concrete comprises:
S30, initialization makes the current length add_len=0 of continuous B frame, minimum code cost value best_cost=0x20000000;
Whether S31 judges add_len less than max_add_len, if, carry out S32, if not, jump to step S39;
S32 empties temp_path;
S33, copy best_paths[j-add_len-1] in temp_path;
S34 makes the element x in the temp_path
J-1=1, promptly this frame of frame sequence is the P frame;
S35 calculates the encoding and decoding cost cost of this frame sequence temp_path;
Whether S36 judges encoding and decoding cost cost less than minimum code cost value best_cost, if, carrying out S37:best_cost=cost, copy temp_path is in temp_path2; If not, directly carry out S38;
S38, add_len=add_len+1 jumps to S31;
S39,best_paths[j]=temp_path2。
Need to prove, execute S30 to S38 after, temp_path2 is exactly described current detection length j and the continuous optimal frames type sequence under the maximum length max_add_len of B frame, in step S39, temp_path2 is saved in best_paths[j] in.
Concrete, in the present embodiment, b_frame=16, given num_frames=250; Then variable is defined as best_paths[18 respectively] [32], temp_path[32], temp_path2[32], type all is a character.
The flow process and the result of the concrete execution during current detection length j=2 are as follows:
At first, the S21 to S23 of execution in step S2, then max_add_len=2;
Then, the S30 to S35 of execution in step S3, then temp_path=" 11 ", carry out S36, S37 again, best_cost=cost, copy temp_path is in temp_path2;
Then, behind the S38:add_len=1 of execution in step S3, jump to S31 and carry out S31 to S35, then temp_path=" 01 ", carry out S36, S37 again, detect the optimal frames type sequence;
Then, behind the S38:add_len=2 of execution in step S3, judge ineligible among the S31, jump to S39, output temp_path2, and temp_path2 is copied in second row of best_paths, continue the S25:j=3 of execution in step S2, circulation is gone down, and finishes up to j=num_frames.
Need to prove that the concrete operation of carrying out of step S3 also can be described as:
At first, the current length of setting the continuous B frame in the described frame sequence increases to the maximum length of described continuous B frame from an initial length;
Then, calculate frame type sequence and encoding and decoding cost thereof under the current length of each continuous B frame, when frame type sequence under the current length of calculating each continuous B frame and encoding and decoding cost thereof, after earlier frame sequence being detected length and be last frame that current length that described current detection length deducts described continuous B frame subtracts 1 o'clock optimal frames type sequence again and being changed to the P frame, as the frame type sequence under the current length of described continuous B frame; The coding cost of the frame type sequence under the current length of calculating described continuous B frame according to the SAD between frame and the frame (sum of absolute differences, absolute difference and) value.;
Then, the output encoder cost is described current detection length and the optimal frames type sequence under the maximum length of B frame continuously thereof less than the frame type sequence of coding cost minimum in all frame type sequences of described minimum code cost value.
Wherein, the SAD between frame and the frame (sum of absolute differences, absolute difference and) value defined is as follows:
If I
i(x y) is on the i two field picture, coordinate is (x, the gray value of pixel y), I
j(x, y) be on the j two field picture, coordinate for (then the SAD computing formula of i frame and j interframe is for x, the gray value of pixel y):
Wherein, H and W are the height and the width of image
From top formula as can be seen: SAD is more little, and the block of pixels similarity that comprises in two frame windows is high more, but because Effect of Environmental such as scene light, shooting angle, and under many circumstances, sad value is the variation between reaction frame and the frame accurately.
The frame type detection method of present embodiment, by progressively increasing the frame type sequence length that detects, and progressively increase in the frame sequence length of B frame continuously, calculate the coding cost of frame sequence, the optimal frames type sequence of final output can be oriented P frame and B frame fast, the variation of reaction frame sequence well, guarantee the compression ratio of video encoder, and by the coding cost of calculating frame sequence can be just right select the P frame, make the picture quality of video encoder be guaranteed.
Embodiment two
As shown in Figure 4, present embodiment provides a kind of frame type detection system, comprising: parameter initialization unit 41, continuous B frame length determining unit 42, optimal frames type sequence computing unit 43 and output unit 44, wherein,
Continuous B frame length determining unit 42, the current detection length that is used to set frame sequence increases to described length to be detected from an initial length, and determines the maximum length of the continuous B frame under the described current detection length;
Optimal frames type sequence computing unit 43 is used for calculating described current detection length and the continuous optimal frames type sequence under the maximum length of B frame thereof according to described minimum code cost value;
In the present embodiment, described continuous B frame length determining unit 42 determines that the step of the maximum length of the continuous B frame under the described current detection length comprises:
Know the B frame value at most continuously of regulation according to the parameter of video encoder;
In described current detection length and described at most continuous B frame value, get the maximum length of minimum value as the continuous B frame under the described current detection length.
In the present embodiment, described optimal frames type sequence computing unit 43 according to described minimum code cost value calculate described current detection length and continuously the step of the optimal frames type sequence under the maximum length of B frame comprise:
At first, the current length of setting the continuous B frame in the described frame sequence increases to the maximum length of described continuous B frame from an initial length;
Then, calculate frame type sequence and encoding and decoding cost thereof under the current length of each continuous B frame;
Then, the output encoder cost is described current detection length and the optimal frames type sequence under the maximum length of B frame continuously thereof less than the frame type sequence of coding cost minimum in all frame type sequences of described minimum code cost value.
Wherein, when frame type sequence under the current length of described optimal frames type sequence computing unit 43 each continuous B frame of calculating and encoding and decoding cost thereof, it is after last frame that current length that described current detection length deducts described continuous B frame subtracts 1 o'clock optimal frames type sequence again is changed to the P frame, as the frame type sequence under the current length of described continuous B frame that frame sequence is detected length;
Calculate the coding cost of the frame type sequence under the current length of described continuous B frame according to the SAD between frame and the frame (sum of absolute differences, absolute difference and) value.
In sum, frame type detection method of the present invention and system, by progressively increasing the frame type sequence length that detects, and progressively increase in the frame sequence length of B frame continuously, calculate the coding cost of frame sequence, the optimal frames type sequence of final output, can orient P frame and B frame fast, the variation of reaction frame sequence well, guarantee the compression ratio of video encoder, and by the coding cost of calculating frame sequence can be just right select the P frame, make the picture quality of video encoder be guaranteed.
Obviously, those skilled in the art can carry out various changes and modification to invention and not break away from the spirit and scope of the present invention.Like this, if of the present invention these are revised and modification belongs within the scope of claim of the present invention and equivalent technologies thereof, then the present invention also is intended to comprise these changes and modification interior.
Claims (8)
1. a frame type detection method is characterized in that, comprising:
Know the length to be detected and the minimum code cost value of frame sequence according to the parameter of video encoder;
The current detection length of setting frame sequence increases to described length to be detected from an initial length, and determines the maximum length of the continuous B frame under the described current detection length;
Calculate described current detection length and the continuous optimal frames type sequence under the maximum length of B frame thereof according to described minimum code cost value;
Export described length to be detected and the continuous optimal frames type sequence under the maximum length of B frame thereof.
2. frame type detection method as claimed in claim 1 is characterized in that, determines that the step of the maximum length of the continuous B frame under the described current detection length comprises:
Know the B frame value at most continuously of regulation according to the parameter of video encoder;
In described current detection length and described at most continuous B frame value, get the maximum length of minimum value as the continuous B frame under the described current detection length.
3. frame type detection method as claimed in claim 1 is characterized in that, according to described minimum code cost value calculate described current detection length and continuously the step of the optimal frames type sequence under the maximum length of B frame comprise:
At first, the current length of setting the continuous B frame in the described frame sequence increases to the maximum length of described continuous B frame from an initial length;
Then, calculate frame type sequence and encoding and decoding cost thereof under the current length of each continuous B frame;
Then, the output encoder cost is described current detection length and the optimal frames type sequence under the maximum length of B frame continuously thereof less than the frame type sequence of coding cost minimum in all frame type sequences of described minimum code cost value.
4. frame type detection method as claimed in claim 3, it is characterized in that, when calculating frame type sequence under the current length of each continuous B frame and encoding and decoding cost thereof, it is after last frame that current length that described current detection length deducts described continuous B frame subtracts 1 o'clock optimal frames type sequence again is changed to the P frame, as the frame type sequence under the current length of described continuous B frame that frame sequence is detected length; And calculate the coding cost of the frame type sequence under the current length of described continuous B frame according to the sad value between frame and the frame.
5. a frame type detection system is characterized in that, comprising: parameter initialization unit, continuous B frame length determining unit, optimal frames type sequence computing unit and output unit, wherein,
The parameter initialization unit is used for knowing according to the parameter of video encoder the length to be detected and the minimum code cost value of frame sequence;
Continuous B frame length determining unit, the current detection length that is used to set frame sequence increases to described length to be detected from an initial length, and determines the maximum length of the continuous B frame under the described current detection length;
Optimal frames type sequence computing unit is used for calculating described current detection length and the continuous optimal frames type sequence under the maximum length of B frame thereof according to described minimum code cost value;
Output unit is used for exporting described length to be detected and the continuous optimal frames type sequence under the maximum length of B frame thereof according to the result of calculation of described continuous B frame length determining unit and optimal frames type sequence computing unit.
6. frame type detection system as claimed in claim 5 is characterized in that, described continuous B frame length determining unit determines that the step of the maximum length of the continuous B frame under the described current detection length comprises:
Know the B frame value at most continuously of regulation according to the parameter of video encoder;
In described current detection length and described at most continuous B frame value, get the maximum length of minimum value as the continuous B frame under the described current detection length.
7. frame type detection system as claimed in claim 5, it is characterized in that, described optimal frames type sequence computing unit according to described minimum code cost value calculate described current detection length and continuously the step of the optimal frames type sequence under the maximum length of B frame comprise:
At first, the current length of setting the continuous B frame in the described frame sequence increases to the maximum length of described continuous B frame from an initial length;
Then, calculate frame type sequence and encoding and decoding cost thereof under the current length of each continuous B frame;
Then, the output encoder cost is described current detection length and the optimal frames type sequence under the maximum length of B frame continuously thereof less than the frame type sequence of coding cost minimum in all frame type sequences of described minimum code cost value.
8. frame type detection system as claimed in claim 7, it is characterized in that, when described optimal frames type sequence computing unit calculates frame type sequence under the current length of each continuous B frame and encoding and decoding cost thereof, it is after last frame that current length that described current detection length deducts described continuous B frame subtracts 1 o'clock optimal frames type sequence again is changed to the P frame, as the frame type sequence under the current length of described continuous B frame that frame sequence is detected length; And calculate the coding cost of the frame type sequence under the current length of described continuous B frame according to the sad value between frame and the frame.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN 201110278580 CN102300096A (en) | 2011-09-19 | 2011-09-19 | Frame type detection method and frame type detection system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN 201110278580 CN102300096A (en) | 2011-09-19 | 2011-09-19 | Frame type detection method and frame type detection system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN102300096A true CN102300096A (en) | 2011-12-28 |
Family
ID=45360220
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN 201110278580 Pending CN102300096A (en) | 2011-09-19 | 2011-09-19 | Frame type detection method and frame type detection system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN102300096A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108024111A (en) * | 2016-10-28 | 2018-05-11 | 北京金山云网络技术有限公司 | A kind of frame type decision method and device |
WO2019001072A1 (en) * | 2017-06-30 | 2019-01-03 | 武汉斗鱼网络科技有限公司 | Method for determining type of video frame and electronic device |
CN111901605A (en) * | 2019-05-06 | 2020-11-06 | 阿里巴巴集团控股有限公司 | Video processing method and device, electronic equipment and storage medium |
-
2011
- 2011-09-19 CN CN 201110278580 patent/CN102300096A/en active Pending
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108024111A (en) * | 2016-10-28 | 2018-05-11 | 北京金山云网络技术有限公司 | A kind of frame type decision method and device |
CN108024111B (en) * | 2016-10-28 | 2019-12-06 | 北京金山云网络技术有限公司 | Frame type judgment method and device |
WO2019001072A1 (en) * | 2017-06-30 | 2019-01-03 | 武汉斗鱼网络科技有限公司 | Method for determining type of video frame and electronic device |
CN111901605A (en) * | 2019-05-06 | 2020-11-06 | 阿里巴巴集团控股有限公司 | Video processing method and device, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101346719B (en) | Key frame is selected from frame of video | |
JP5969389B2 (en) | Object recognition video coding strategy | |
KR101339566B1 (en) | Motion vector selection | |
RU2014123342A (en) | METHOD FOR CODING AND DECODING IMAGES, DEVICE FOR CODING AND DECODING, AND RELATED COMPUTER PROGRAMS | |
CN104427337A (en) | Region of interest (ROI) video coding method and apparatus based on object detection | |
JP2008504750A5 (en) | ||
US10440384B2 (en) | Encoding method and equipment for implementing the method | |
JP2009188996A (en) | Video image codec apparatus, and method thereof | |
CN1703097A (en) | Apparatus and method for encoding motion vector, and program and medium therefor | |
US10536696B2 (en) | Image encoding device and image encoding method | |
CN102300096A (en) | Frame type detection method and frame type detection system | |
CN112437301A (en) | Code rate control method and device for visual analysis, storage medium and terminal | |
KR101167645B1 (en) | Method for detecting scene change and apparatus therof | |
US10616585B2 (en) | Encoding data arrays | |
JP5199196B2 (en) | Moving picture decoding method, moving picture decoding apparatus, and moving picture decoding program | |
CN113301349B (en) | Motion vector selection method, motion vector selection device, electronic equipment and storage medium | |
CN102804783B (en) | Picture coding device and camera system | |
US7991050B2 (en) | Moving picture decoding apparatus and moving picture decoding method | |
CN101902642B (en) | Quick decision method for H.264 interframe SKIP modes | |
CN104581155A (en) | Scenario-analysis-based coding method and system | |
CN103430543A (en) | Method for reconstructing and coding image block | |
MX2021000351A (en) | Video encoder, video decoder, and corresponding method. | |
CN106534850B (en) | Image processing apparatus, image interpolation method, and image encoding method | |
CN104717511A (en) | Video coding or decoding method and device | |
US10674174B2 (en) | Coding apparatus, coding method, and recording medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C02 | Deemed withdrawal of patent application after publication (patent law 2001) | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20111228 |