Summary of the invention
The technical problem to be solved by the present invention is to be directed to continually changing network environment and video pictures content, need to carry out
Adaptive video coding is proposed a kind of based on the adaptive of video calling scene with realizing preferable video definition and fluency
Answer method for video coding and device.
In order to solve the above-mentioned technical problem, the invention discloses a kind of adaptive video codings based on video calling scene
Method, comprising:
Step 101, when establishing video calling, the initial network bandwidth under current network environment is detected, and is arranged and examines
The initial code resolution ratio and frame per second that the network bandwidth measured matches carry out Video coding;
Step 102, further updated under the network environment after detection variation when detecting change of network environment
Network bandwidth, the resolution ratio encoded according to the network bandwidth before updated network bandwidth, update and before updating and frame
Rate determines updated code distinguishability and frame per second, carries out subsequent video according to updated code distinguishability and frame per second and compiles
Code;
Step 103, according to detect video for the previous period mean error, carry out adaptive adjust at this time
Code distinguishability and frame per second, in which:
The mean error of the video for the previous period is that basis is being encoded based on current resolution with frame per second
When, the mean value for the quantization step in certain time interval that corresponding network bandwidth obtains;
The adaptive code distinguishability adjusted at this time and frame per second are to be greater than threshold value by error then to downgrade coding point
Resolution and frame per second, error are less than threshold value and then increase encoding rate and frame per second.
Preferably, generally 3-6 seconds in certain time interval.
Further, the step 101 includes:
Step 201, it is logical that video is set according to the CPU ability CPU_capacity of mobile device and used encoder
Talk about the classification grade level of coding, in which: the CPU_capacity includes dominant frequency and nucleus number;
Step 202, the ratio of width to height that network bandwidth and opposite end picture are detected when starting video calling, according to letter obtained
Breath setting is adapted to the initial code resolution ratio and frame per second of encoder, in which: information obtained includes network bandwidth and CPU energy
Power, and the CPU ability takes the value Vmin of ability reckling in each communication terminal;
Step 203, it according to the ratio of width to height of obtained recommendation resolution ratio and opposite end screen, cuts out and is connect with opposite end the ratio of width to height
Close resolution ratio is encoded.
Further, the step 201 includes:
The CPU ability of the intelligent terminal of apple IOS operating system and the H.264 coding of used process optimization will be run
The taxonomical hierarchy of device is configured by one mode of table,
The CPU ability for running the intelligent terminal of Google's Android operation system is mapped to corresponding model by one mode of table
Operation apple IOS operating system intelligent terminal CPU ability,
Table one
Further, the step 202 includes:
By two mode of table be arranged the CPU ability of network bandwidth and intelligent terminal with recommend it is corresponding between resolution ratio and frame per second
Relationship:
Table two
Further, the step 203 includes:
If parameters are as shown in Table 3:
Table three
Parameter |
Meaning |
target_aspect |
The ratio of width to height of opposite end picture |
recomm_width |
Width in the resolution ratio of recommendation |
recomm_height |
Height in the resolution ratio of recommendation |
new_width |
New coding is wide |
new_height |
New coding is high |
= |
Indicate the logic judgment being equal to |
> |
Indicate the logic judgment being greater than |
* |
Indicate the mathematical operation of product |
The method for determining the ratio of width to height is as follows:
If recomm_width > recomm_height*target_aspect
Then, new_width=recomm_height*target_aspect
New_height=recomm_height
Otherwise, new_width=recomm_width
New_height=recomm_width/target_aspect
If the above-mentioned wide height being calculated is not 16 integral multiple, it is cut to 16 multiple.
Further, the step 102 includes:
Step 204, when detecting that network bandwidth changes and is more than threshold range, to the resolution ratio and phase of coding
The coding layer grade of pass is updated, to adapt to new Network status.
Further, the step 204 includes:
Classify by table four to coding layer grade
Table four
Resolution ratio |
Frame per second |
Level |
640x480 |
15 |
10 |
480x320 |
15 |
9 |
320x240 |
15 |
8 |
240x160 |
15 |
7 |
160x120 |
15 |
6 |
160x120 |
9 |
5 |
160x120 |
5 |
4 |
160x120 |
3 |
3 |
120x80 |
3 |
2 |
80x60 |
3 |
1 |
80x60 |
1 |
0 |
If parameters are as shown in Table 5:
Table five
Parameter |
Meaning |
curr_bitrate |
Current bandwidth |
prev_bitrate |
Bandwidth before |
bitrate_change_level |
The variation level of bandwidth |
prev_encoding_level |
Coding level before |
curr_encoding_level |
New coding level |
log |
Expression takes the mathematical operation of logarithm |
= |
Indicate the logic judgment being equal to |
> |
Indicate the logic judgment being greater than |
/ |
Indicate divided by mathematical operation |
* |
Indicate the mathematical operation of product |
+ |
Indicate the mathematical operation of summation |
The method for determining the variation level of bandwidth is as follows:
Bitrate_change_level=log (curr_bitrate/prev_bitrate)/log (2.0)
If bitrate_change_level > 0
Then, bitrate_change_level=bitrate_change_level*0.8
Otherwise, bitrate_change_level=bitrate_change_level*2.0
The method for determining new coding level is as follows:
Curr_encoding_level=prev_encoding_level+bitrate_change_l evel
After obtaining new coding level, compiled according to resolution ratio corresponding to the coding level newly obtained and frame per second
Code.
Further, the step 103 includes:
Step 205, when not changing in Network status, or changing smaller, the level of Video coding is drawn still according to video
The continuous automatic adjusument of the case where face:
The average value of 3 seconds quantized value QP before Video coding is calculated in the encoded resolution ratio of current bandwidth and frame per second,
And it makes the following judgment:
When average value is less than 24, level curr_encoding_level=prev_encoding_level+1 is encoded;
When average value is greater than 32, level curr_encoding_level=prev_encoding_level-1 is encoded;
Wherein, when the coding level curr_encoding_level being calculated is greater than 10, curr_ is set
Encoding_level is 10;
When the coding level curr_encoding_level being calculated is less than 0, minimum setting curr_encoding_
Level is 0.
Preferably, Network status variation it is smaller generally refer to network bandwidth relative to current value variation below 10%.
In order to solve the above-mentioned technical problem, the invention also discloses a kind of, and the adaptive video based on video calling scene is compiled
Code device, comprising:
Detection module, control module and coding module, in which:
The detection module, for being detected to network condition and picture situation;
The control module, network condition and picture situation for being detected according to detection module to code distinguishability with
Frame per second is calculated;
The coding module encodes video according to the calculated code distinguishability of control module and frame per second;
Wherein:
For the video calling opened under particular network environment, the detection module detects initial bandwidth, the control
Initial an experience code distinguishability and frame per second is arranged according to the network bandwidth detected in molding root tuber,
When the detection module detects that network condition changes, the control module is new according to the detection module
Obtained bandwidth and before Video coding resolution ratio and frame per second used by bandwidth are detected, a new code distinguishability is calculated
And frame per second, the coding module carry out next coding according to new code distinguishability and frame per second,
The mean error of the video of what the detection module detected for the previous period, the control module are flat according to this
Equal error carrys out the adaptive code distinguishability and frame per second adjusted at this time, and error is greater than threshold value and then downgrades code distinguishability and frame
Rate, error are less than threshold value and then increase encoding rate and frame per second.
Further, the control module is further set according to the CPU ability of mobile device and used encoder
Determine the classification grade level of video calling coding;When starting video calling, the detection module detection network bandwidth and opposite end
The ratio of width to height of picture, the control module are adapted to the initial code resolution ratio and frame of encoder according to information obtained setting
Rate, in which: information obtained includes network bandwidth and CPU ability, and the CPU ability takes ability in each communication terminal minimum
The value Vmin of person;The control module is cut out according to the ratio of width to height of the terminal screen of obtained recommendation resolution ratio and opposite end
The close resolution ratio with opposite end the ratio of width to height, coding module are encoded according to the resolution ratio;When the detection module detects net
When network bandwidth changes and is more than threshold range, the control module is grading to the resolution ratio of coding and relevant coding layer
Row update, to adapt to new Network status, do not change in Network status, or variation it is smaller when, the control module according to
The case where video pictures, is to the continuous automatic adjusument of the level of Video coding.
Further, the control module includes: configuration parameter as shown in Table 1, and according to the configuration parameter of table one into
The following operation of row:
The CPU ability of the intelligent terminal of apple IOS operating system and the H.264 coding of used process optimization will be run
The taxonomical hierarchy of device is configured by one mode of table,
The CPU ability for running the intelligent terminal of Google's Android operation system is mapped to corresponding model by one mode of table
Operation apple IOS operating system intelligent terminal CPU ability,
Table one
Further, the control module includes: configuration parameter as shown in Table 2, and according to the configuration parameter of table two into
The following operation of row:
By two mode of table be arranged the CPU ability of network bandwidth and intelligent terminal with recommend it is corresponding between resolution ratio and frame per second
Relationship:
Table two
Further, the coding module includes: configuration parameter as shown in Table 3, and according to the configuration parameter of table three into
The following operation of row:
If parameters are as shown in Table 3:
Table three
Parameter |
Meaning |
target_aspect |
The ratio of width to height of opposite end picture |
recomm_width |
Width in the resolution ratio of recommendation |
recomm_height |
Height in the resolution ratio of recommendation |
new_width |
New coding is wide |
new_height |
New coding is high |
= |
Indicate the logic judgment being equal to |
> |
Indicate the logic judgment being greater than |
* |
Indicate the mathematical operation of product |
Determine that the operation of the ratio of width to height is as follows:
If recomm_width > recomm_height*target_aspect
Then, new_width=recomm_height*target_aspect
New_height=recomm_height
Otherwise, new_width=recomm_width
New_height=recomm_width/target_aspect
If the above-mentioned wide height being calculated is not 16 integral multiple, it is cut to 16 multiple.
Further, the control module is further used for:
Resolution ratio and relevant coding when detecting that network bandwidth changes and is more than threshold range, to coding
Level is updated, to adapt to new Network status.
Further, the coding module includes: the configuration parameter as shown in table four, table five, and according to table four, table five
Configuration parameter proceeds as follows:
Classify by table four to coding layer grade
Table four
Resolution ratio |
Frame per second |
Level |
640x480 |
15 |
10 |
480x320 |
15 |
9 |
320x240 |
15 |
8 |
240x160 |
15 |
7 |
160x120 |
15 |
6 |
160x120 |
9 |
5 |
160x120 |
5 |
4 |
160x120 |
3 |
3 |
120x80 |
3 |
2 |
80x60 |
3 |
1 |
80x60 |
1 |
0 |
If parameters are as shown in Table 5:
Table five
Parameter |
Meaning |
curr_bitrate |
Current bandwidth |
prev_bitrate |
Bandwidth before |
bitrate_change_level |
The variation level of bandwidth |
prev_encoding_level |
Coding level before |
curr_encoding_level |
New coding level |
log |
Expression takes the mathematical operation of logarithm |
= |
Indicate the logic judgment being equal to |
> |
Indicate the logic judgment being greater than |
/ |
Indicate divided by mathematical operation |
* |
Indicate the mathematical operation of product |
+ |
Indicate the mathematical operation of summation |
Determine that the operation of the variation level of bandwidth is as follows:
Bitrate_change_level=log (curr_bitrate/prev_bitrate)/log (2.0)
If bitrate_change_level > 0
Then, bitrate_change_level=bitrate_change_level*0.8
Otherwise, bitrate_change_level=bitrate_change_level*2.0
Determine that the operation of new coding level is as follows:
Curr_encoding_level=prev_encoding_level+bitrate_change_l evel
After obtaining new coding level, compiled according to resolution ratio corresponding to the coding level newly obtained and frame per second
Code.
Further, the control module is further used for:
Do not change in Network status, or when variation is smaller, the case where level of Video coding is still according to video pictures
Continuous automatic adjusument:
The average value of 3 seconds quantized value QP before Video coding is calculated in the encoded resolution ratio of current bandwidth and frame per second,
And it makes the following judgment:
When average value is less than 24, level curr_encoding_level=prev_encoding_level+1 is encoded;
When average value is greater than 32, level curr_encoding_level=prev_encoding_level-1 is encoded;
Wherein, when the coding level curr_encoding_level being calculated is greater than 10, maximum setting curr_
Encoding_level is 10;
When the coding level curr_encoding_level being calculated is less than 0, minimum setting curr_encoding_
Level is 0.
Adaptive video coding method and device provided by the invention based on video calling scene can constantly change
Network environment and video pictures content in the case of carry out adaptive video coding, and realize preferable video definition and smooth
Degree.
The additional aspect of the present invention and advantage will be set forth in part in the description, these will become from the following description
Obviously, or practice through the invention is recognized.
Specific embodiment
Embodiments of the present invention are described below in detail, the example of the embodiment is shown in the accompanying drawings, wherein from beginning
Same or similar element or element with the same or similar functions are indicated to same or similar label eventually.Below by ginseng
The embodiment for examining attached drawing description is exemplary, and for explaining only the invention, and is not construed as limiting the claims.
Those skilled in the art of the present technique are appreciated that unless expressly stated, singular " one " used herein, " one
It is a ", " described " and "the" may also comprise plural form.It is to be further understood that being arranged used in specification of the invention
Diction " comprising " refer to that there are the feature, integer, step, operation, element and/or component, but it is not excluded that in the presence of or addition
Other one or more features, integer, step, operation, element, component and/or their group.It should be understood that when we claim member
Part is " connected " or when " coupled " to another element, it can be directly connected or coupled to other elements, or there may also be
Intermediary element.In addition, " connection " used herein or " coupling " may include being wirelessly connected or coupling.Wording used herein
"and/or" includes one or more associated any cells for listing item and all combinations.
Those skilled in the art of the present technique are appreciated that unless otherwise defined, all terms used herein (including technology art
Language and scientific term) there is meaning identical with the general understanding of those of ordinary skill in fields of the present invention.Should also
Understand, those terms such as defined in the general dictionary, which should be understood that, to be had and the meaning in the context of the prior art
The consistent meaning of justice, and unless defined as here, it will not be explained in an idealized or overly formal meaning.
Fig. 1 shows a kind of overall structure signal of ipsec security alliance hardware searching device based on IPv6 of the invention
Figure.As shown in Figure 1, the invention discloses a kind of adaptive video coding methods based on video calling scene, comprising: step
101, when establishing video calling, detect the initial network bandwidth under current network environment, and the Netowrk tape for being arranged and detecting
The initial code resolution ratio and frame per second that width matches carry out Video coding;Step 102, when detecting change of network environment, into
The updated network bandwidth under network environment after the detection variation of one step, according to the net before updated network bandwidth, update
The network bandwidth and resolution ratio that is encoding and frame per second determine updated code distinguishability and frame per second before updating, then according to
Updated code distinguishability and frame per second carry out subsequent Video coding;Step 103, according to detect for the previous period
The mean error of video carrys out the adaptive code distinguishability and frame per second adjusted at this time.Wherein, the view for the previous period
The mean error of frequency is according to the timing that when being encoded based on current resolution and frame per second, corresponding network bandwidth is obtained
Between interval in quantization step mean value.Wherein, the adaptive code distinguishability adjusted at this time and frame per second are to pass through mistake
Difference is greater than threshold value and then downgrades code distinguishability and frame per second, and error is less than threshold value and then increases encoding rate and frame per second.As a kind of implementation
Mode, the detection of network bandwidth are one " key frames " by the last video from starting to receive data to completion reception number
It is calculated according to the time and received size of data of needs.Wherein, it is described be for the previous period according to different demands come
Fixed, when needing very fast adaptation network change, the shorter time can be set, but image quality variation can be very violent,
It is unstable;When thinking that frame stabilization is more important, the slightly long regular hour is needed;It is generally set to be spaced for 3-6 seconds.Wherein, institute
The mean error for stating video is according to the timing that when being encoded based on current resolution and frame per second, corresponding network bandwidth is obtained
Between interval in " quantization step " mean value.Wherein, the threshold value is an experience according to the acceptable degree setting to image quality
Value." quantization step " refers in video compress, for realize targeted compression code rate come the data to video come controlled one
A numerical value;Generally, the numerical value is bigger, video compress it is more serious, it is bigger with original video error.
Further, the step 101 includes: step 201, according to the CPU ability CPU_capacity of mobile device and
Used encoder come set video calling coding classification grade level, in which: the CPU_capacity includes dominant frequency
And nucleus number;Step 202, the ratio of width to height that network bandwidth and opposite end picture are detected when starting video calling, according to letter obtained
Breath setting is adapted to the initial code resolution ratio and frame per second of encoder, in which: information obtained includes network bandwidth and CPU energy
Power, and the CPU ability takes the value Vmin of ability reckling in each communication terminal;Step 203, according to obtained recommendation resolution ratio
And the ratio of width to height of opposite end screen, it cuts out the resolution ratio close with opposite end the ratio of width to height and is encoded.
As an implementation, the CPU ability CPU_capacity and used coding according to mobile device
Device come set video calling coding classification grade level (step 201), may include: will run apple IOS operating system
The CPU ability of intelligent terminal and the taxonomical hierarchy of the used H.264 encoder by optimization are configured by one mode of table.
Table one
As another embodiment, the CPU ability that will run the intelligent terminal of Google's Android operation system presses table one
Mode is mapped to the CPU ability of the intelligent terminal of the operation apple IOS operating system of corresponding model.
Step 201, it is logical that video is set according to the CPU ability of mobile device (dominant frequency and nucleus number) and used encoder
Talk about the classification grade level of coding;
For example, CPU ability and used process optimization for the different model terminal of apple IOS system are H.264
Encoder, taxonomical hierarchy are as follows:
CPU_Capacity >=IPHONE_5S
Resolution classification level: 640x480,480x320,320x240,240x160,160x120,120x80,80x60
Frame per second taxonomical hierarchy: 15,9,5,3,1
All taxonomical hierarchies open the estimation of 1/4 fraction pixel and all coding block structures of 16x16 to 4x4.
CPU_Capacity==IPHONE_5
Resolution classification level: 640x480,480x320,320x240,240x160,160x120,120x80,80x60
Frame per second taxonomical hierarchy: 15,9,5,3,1
For 640x480 resolution ratio, when frame per second is 15, the estimation of 1/2 pixel and the volume of 16x16 to 8x8 are only opened
Code block structure, 1/4 pixel and 8x4,4x8 are not turned on 4x4 coding block structure;
Other taxonomical hierarchies open the estimation of 1/4 fraction pixel and all coding block structures of 16x16 to 4x4.
CPU_Capacity==IPHONE_4S
Resolution classification level: 480x320,320x240,240x160,160x120,120x80,80x60
Frame per second taxonomical hierarchy: 15,9,5,3,1
For 480x320 resolution ratio, when frame per second is 15, the estimation of 1/2 pixel and the volume of 16x16 to 8x8 are only opened
Code block structure, 1/4 pixel and 8x4,4x8 are not turned on 4x4 coding block structure;
Other taxonomical hierarchies open the estimation of 1/4 fraction pixel and all coding block structures of 16x16 to 4x4.
CPU_Capacity≤IPHONE_4
Resolution classification level: 240x160,160x120,120x80,80x60
Frame per second taxonomical hierarchy: 15,9,5,3,1
All taxonomical hierarchies only open the estimation of 1/2 pixel and the coding block structure of 16x16 to 8x8,1/4 pixel
And 8x4,4x8 are not turned on 4x4 coding block structure.
For the different model terminal of each operation Google's Android system, mapped according to the CPU frequency of acquisition and nucleus number
To the correspondence model of corresponding IOS system, mapping relations are as follows:
Android CPU >=4 cores and dominant frequency > 1.2G " --- --- " IPHONE_5S
Android CPU >=4 cores and dominant frequency≤1.2G " --- --- " IPHONE_5
Android CPU>=2 cores,<4 cores and dominant frequency>1.2G " --- --- " IPHONE_4S
The core of Android CPU < 2 or dominant frequency≤1.2G " --- --- " IPHONE_4
Step 202, the ratio of width to height that network bandwidth and opposite end picture are detected when starting video calling, according to letter obtained
Breath setting is adapted to the initial code resolution ratio and frame per second of encoder, wherein information obtained includes network bandwidth and CPU energy
Power, and the CPU ability takes the value Vmin of ability reckling in each communication terminal.
Further, the initial code resolution ratio and frame per second that encoder is adapted to according to information obtained setting
(step 202) may include: that the CPU ability of network bandwidth and intelligent terminal is arranged by two mode of table and recommends resolution ratio and frame
Corresponding relationship between rate.
Table two
For example, the corresponding relationship between network bandwidth and terminal CPU ability and recommendation resolution ratio and frame per second are as follows:
Bandwidth >=128kbps, CPU_Capacity >=IPHONE_4S, code distinguishability 320x240, frame per second 15,
Encoding level is 8;
Bandwidth>=128kbps, CPU_Capacity<IPHONE_4S, code distinguishability 240x160, frame per second 15 are compiled
Code layer grade is 7;
128kbps > bandwidth >=64kbps, to all terminals, code distinguishability 240x160, frame per second 15, coding layer
Grade is 7;
64kbps > bandwidth >=32kbps, to all terminals, code distinguishability 160x120, frame per second 5 encodes level
It is 4;
Bandwidth < 32kbps, to all terminals, code distinguishability 80x60, frame per second 3, coding level is 1.
Further, the ratio of width to height of the basis obtains recommendation resolution ratio and opposite end screen, cuts out wide with opposite end
Height is encoded (step 203) than close resolution ratio, may include:
If parameters are as shown in Table 3:
Table three
Parameter |
Meaning |
target_aspect |
The ratio of width to height of opposite end picture |
recomm_width |
Width in the resolution ratio of recommendation |
recomm_height |
Height in the resolution ratio of recommendation |
new_width |
New coding is wide |
new_height |
New coding is high |
= |
Indicate the logic judgment being equal to |
> |
Indicate the logic judgment being greater than |
* |
Indicate the mathematical operation of product |
The method for determining the ratio of width to height is as follows:
If recomm_width > recomm_height*target_aspect
Then, new_width=recomm_height*target_aspect
New_height=recomm_height
Otherwise, new_width=recomm_width
New_height=recomm_width/target_aspect
If the above-mentioned wide height being calculated is not 16 integral multiple, it is cut to 16 multiple.
It is further, described that subsequent Video coding (step 102) is carried out according to updated code distinguishability and frame per second,
Can also include: step 204, when detecting that network bandwidth changes and is more than threshold range, to the resolution ratio of coding with
And relevant coding layer grade is updated, to adapt to new Network status.
As an implementation, the step 204 includes:
Classify by table four to coding layer grade
Table four
Resolution ratio |
Frame per second |
Level |
640x480 |
15 |
10 |
480x320 |
15 |
9 |
320x240 |
15 |
8 |
240x160 |
15 |
7 |
160x120 |
15 |
6 |
160x120 |
9 |
5 |
160x120 |
5 |
4 |
160x120 |
3 |
3 |
120x80 |
3 |
2 |
80x60 |
3 |
1 |
80x60 |
1 |
0 |
If parameters are as shown in Table 5:
Table five
Parameter |
Meaning |
curr_bitrate |
Current bandwidth |
prev_bitrate |
Bandwidth before |
bitrate_change_level |
The variation level of bandwidth |
prev_encoding_level |
Coding level before |
curr_encoding_level |
New coding level |
log |
Expression takes the mathematical operation of logarithm |
= |
Indicate the logic judgment being equal to |
> |
Indicate the logic judgment being greater than |
/ |
Indicate divided by mathematical operation |
* |
Indicate the mathematical operation of product |
+ |
Indicate the mathematical operation of summation |
The method for determining the variation level of bandwidth is as follows:
Bitrate_change_level=log (curr_bitrate/prev_bitrate)/log (2.0)
If bitrate_change_level > 0
Then, bitrate_change_level=bitrate_change_level*0.8
Otherwise, bitrate_change_level=bitrate_change_level*2.0
The method for determining new coding level is as follows:
Curr_encoding_level=prev_encoding_level+bitrate_change_l evel
After obtaining new coding level, compiled according to resolution ratio corresponding to the coding level newly obtained and frame per second
Code.
Further, the basis detect video for the previous period mean error, carry out adaptive adjusting
Code distinguishability and frame per second (step 103) at this time, may include: step 205, do not change in Network status, or variation
When smaller, the case where level of Video coding is still according to video pictures continuous automatic adjusument:
The average value of 3 seconds quantized value QP before Video coding is calculated in the encoded resolution ratio of current bandwidth and frame per second,
And it makes the following judgment:
When average value is less than 24, level curr_encoding_level=prev_encoding_level+1 is encoded;
When average value is greater than 32, level curr_encoding_level=prev_encoding_level-1 is encoded;
Wherein, when the coding level curr_encoding_level being calculated is greater than 10, curr_ is set
Encoding_level is 10;
When the coding level curr_encoding_level being calculated is less than 0, minimum setting curr_encoding_
Level is 0.
Preferably, Network status variation it is smaller generally refer to network bandwidth relative to current value variation below 10%.
For example, the interval range that user can be changed with customized Network status.In another example system can be according to Network status according to making by oneself
The interval range that Network status changes is arranged in right way of conduct formula.
Adaptive video coding method disclosed by the invention based on video calling scene can be in continually changing network
Video coding is carried out in the case of environment and video pictures content and realizes preferable video definition and fluency.
In order to solve the above-mentioned technical problem, the invention also discloses a kind of, and the adaptive video based on video calling scene is compiled
Code device, comprising:
Detection module, control module and coding module, in which:
The detection module, for being detected to network condition and picture situation;
The control module, network condition and picture situation for being detected according to detection module to code distinguishability with
Frame per second is calculated;
The coding module encodes video according to the calculated code distinguishability of control module and frame per second;
Wherein:
For the video calling opened under particular network environment, the detection module detects initial bandwidth, the control
Initial an experience code distinguishability and frame per second is arranged according to the network bandwidth detected in molding root tuber,
When the detection module detects that network condition changes, the control module is new according to the detection module
Obtained bandwidth and before Video coding resolution ratio and frame per second used by bandwidth are detected, a new code distinguishability is calculated
And frame per second, the coding module carry out next coding according to new code distinguishability and frame per second,
The mean error of the video of what the detection module detected for the previous period, the control module are flat according to this
Equal error carrys out the adaptive code distinguishability and frame per second adjusted at this time, and error is greater than threshold value and then downgrades code distinguishability and frame
Rate, error are less than threshold value and then increase encoding rate and frame per second.
Further, the control module is further set according to the CPU ability of mobile device and used encoder
Determine the classification grade level of video calling coding;When starting video calling, the detection module detection network bandwidth and opposite end
The ratio of width to height of picture, the control module are adapted to the initial code resolution ratio and frame of encoder according to information obtained setting
Rate, in which: information obtained includes network bandwidth and CPU ability, and the CPU ability takes ability in each communication terminal minimum
The value Vmin of person;The control module is cut out according to the ratio of width to height of the terminal screen of obtained recommendation resolution ratio and opposite end
The close resolution ratio with opposite end the ratio of width to height, coding module are encoded according to the resolution ratio;When the detection module detects net
When network bandwidth changes and is more than threshold range, the control module is grading to the resolution ratio of coding and relevant coding layer
Row update, to adapt to new Network status, do not change in Network status, or variation it is smaller when, the control module according to
The case where video pictures, is to the continuous automatic adjusument of the level of Video coding.
Further, the control module includes: configuration parameter as shown in Table 1, and according to the configuration parameter of table one into
The following operation of row:
The CPU ability of the intelligent terminal of apple IOS operating system and the H.264 coding of used process optimization will be run
The taxonomical hierarchy of device is configured by one mode of table,
The CPU ability for running the intelligent terminal of Google's Android operation system is mapped to corresponding model by one mode of table
Operation apple IOS operating system intelligent terminal CPU ability,
Table one
.As an implementation, control module is set according to the CPU ability of mobile device and used encoder
The classification grade level of video calling coding;
For example, CPU ability and used process optimization for the different model terminal of apple IOS system are H.264
Encoder, taxonomical hierarchy are as follows:
CPU_Capacity >=IPHONE_5S
Resolution classification level: 640x480,480x320,320x240,240x160,160x120,120x80,80x60
Frame per second taxonomical hierarchy: 15,9,5,3,1
All taxonomical hierarchies open the estimation of 1/4 fraction pixel and all coding block structures of 16x16 to 4x4.
CPU_Capacity==IPHONE_5
Resolution classification level: 640x480,480x320,320x240,240x160,160x120,120x80,80x60
Frame per second taxonomical hierarchy: 15,9,5,3,1
For 640x480 resolution ratio, when frame per second is 15, the estimation of 1/2 pixel and the volume of 16x16 to 8x8 are only opened
Code block structure, 1/4 pixel and 8x4,4x8 are not turned on 4x4 coding block structure;
Other taxonomical hierarchies open the estimation of 1/4 fraction pixel and all coding block structures of 16x16 to 4x4.
CPU_Capacity==IPHONE_4S
Resolution classification level: 480x320,320x240,240x160,160x120,120x80,80x60
Frame per second taxonomical hierarchy: 15,9,5,3,1
For 480x320 resolution ratio, when frame per second is 15, the estimation of 1/2 pixel and the volume of 16x16 to 8x8 are only opened
Code block structure, 1/4 pixel and 8x4,4x8 are not turned on 4x4 coding block structure;
Other taxonomical hierarchies open the estimation of 1/4 fraction pixel and all coding block structures of 16x16 to 4x4.
CPU_Capacity≤IPHONE_4
Resolution classification level: 240x160,160x120,120x80,80x60
Frame per second taxonomical hierarchy: 15,9,5,3,1
All taxonomical hierarchies only open the estimation of 1/2 pixel and the coding block structure of 16x16 to 8x8,1/4 pixel
And 8x4,4x8 are not turned on 4x4 coding block structure.
For the different model terminal of each operation Google's Android system, mapped according to the CPU frequency of acquisition and nucleus number
To the correspondence model of corresponding IOS system, mapping relations are as follows:
Android CPU >=4 cores and dominant frequency > 1.2G " --- --- " IPHONE_5S
Android CPU >=4 cores and dominant frequency≤1.2G " --- --- " IPHONE_5
Android CPU>=2 cores,<4 cores and dominant frequency>1.2G " --- --- " IPHONE_4S
The core of Android CPU < 2 or dominant frequency≤1.2G " --- --- " IPHONE_4
Further, the control module includes: configuration parameter as shown in Table 2, and according to the configuration parameter of table two into
The following operation of row:
By two mode of table be arranged the CPU ability of network bandwidth and intelligent terminal with recommend it is corresponding between resolution ratio and frame per second
Relationship:
Table two
As an implementation, when starting video calling, the width of detection module detection network bandwidth and opposite end picture is high
Than control module is adapted to the initial code resolution ratio and frame per second of encoder according to information obtained setting, wherein is obtained
Information include network bandwidth and CPU ability, and the CPU ability takes the value Vmin of ability reckling in each communication terminal.
Wherein, the corresponding relationship between network bandwidth and terminal CPU ability and recommendation resolution ratio and frame per second are as follows:
Bandwidth >=128kbps, CPU_Capacity >=IPHONE_4S, code distinguishability 320x240, frame per second 15,
Encoding level is 8;
Bandwidth>=128kbps, CPU_Capacity<IPHONE_4S, code distinguishability 240x160, frame per second 15 are compiled
Code layer grade is 7;
128kbps > bandwidth >=64kbps, to all terminals, code distinguishability 240x160, frame per second 15, coding layer
Grade is 7;
64kbps > bandwidth >=32kbps, to all terminals, code distinguishability 160x120, frame per second 5 encodes level
It is 4;
Bandwidth < 32kbps, to all terminals, code distinguishability 80x60, frame per second 3, coding level is 1.
Further, the coding module includes: configuration parameter as shown in Table 3, and according to the configuration parameter of table three into
The following operation of row:
If parameters are as shown in Table 3:
Table three
Parameter |
Meaning |
target_aspect |
The ratio of width to height of opposite end picture |
recomm_width |
Width in the resolution ratio of recommendation |
recomm_height |
Height in the resolution ratio of recommendation |
new_width |
New coding is wide |
new_height |
New coding is high |
= |
Indicate the logic judgment being equal to |
> |
Indicate the logic judgment being greater than |
* |
Indicate the mathematical operation of product |
Determine that the operation of the ratio of width to height is as follows:
If recomm_width > recomm_height*target_aspect
Then, new_width=recomm_height*target_aspect
New_height=recomm_height
Otherwise, new_width=recomm_width
New_height=recomm_width/target_aspect
If the above-mentioned wide height being calculated is not 16 integral multiple, it is cut to 16 multiple.
As an implementation, control module is high according to the width of the terminal screen of obtained recommendation resolution ratio and opposite end
Than cutting out the resolution ratio close with opposite end the ratio of width to height, coding module is encoded according to the resolution ratio.
Wherein it is determined that the method for the ratio of width to height is as follows:
If the ratio of width to height of opposite end picture is target_aspect, the high width in the resolution ratio of recommendation is respectively recomm_
Width, recomm_height, new coding width and a height of new_width, new_height,
If recomm_width > recomm_height*target_aspect
Then, new_width=recomm_height*target_aspect
New_height=recomm_height
Otherwise,
New_width=recomm_width
New_height=recomm_width/target_aspect
If the above-mentioned wide height being calculated is not 16 integral multiple, it is cut to 16 multiple.
Further, the control module is further used for:
Resolution ratio and relevant coding when detecting that network bandwidth changes and is more than threshold range, to coding
Level is updated, to adapt to new Network status.
Further, the coding module includes: the configuration parameter as shown in table four, table five, and according to table four, table five
Configuration parameter proceeds as follows:
Classify by table four to coding layer grade
Table four
Resolution ratio |
Frame per second |
Level |
640x480 |
15 |
10 |
480x320 |
15 |
9 |
320x240 |
15 |
8 |
240x160 |
15 |
7 |
160x120 |
15 |
6 |
160x120 |
9 |
5 |
160x120 |
5 |
4 |
160x120 |
3 |
3 |
120x80 |
3 |
2 |
80x60 |
3 |
1 |
80x60 |
1 |
0 |
If parameters are as shown in Table 5:
Table five
Parameter |
Meaning |
curr_bitrate |
Current bandwidth |
prev_bitrate |
Bandwidth before |
bitrate_change_level |
The variation level of bandwidth |
prev_encoding_level |
Coding level before |
curr_encoding_level |
New coding level |
log |
Expression takes the mathematical operation of logarithm |
= |
Indicate the logic judgment being equal to |
> |
Indicate the logic judgment being greater than |
/ |
Indicate divided by mathematical operation |
* |
Indicate the mathematical operation of product |
+ |
Indicate the mathematical operation of summation |
Determine that the operation of the variation level of bandwidth is as follows:
Bitrate_change_level=log (curr_bitrate/prev_bitrate)/log (2.0)
If bitrate_change_level > 0
Then, bitrate_change_level=bitrate_change_level*0.8
Otherwise, bitrate_change_level=bitrate_change_level*2.0
Determine that the operation of new coding level is as follows:
Curr_encoding_level=prev_encoding_level+bitrate_change_l evel
After obtaining new coding level, compiled according to resolution ratio corresponding to the coding level newly obtained and frame per second
Code.As an implementation, when detection module detects that network bandwidth changes and is more than threshold range, control module
Resolution ratio and relevant coding layer grade to coding are updated, to adapt to new Network status;
Wherein, hierarchical classification is encoded are as follows:
Resolution ratio |
Frame per second |
Level |
640x480 |
15 |
10 |
480x320 |
15 |
9 |
320x240 |
15 |
8 |
240x160 |
15 |
7 |
160x120 |
15 |
6 |
160x120 |
9 |
5 |
160x120 |
5 |
4 |
160x120 |
3 |
3 |
120x80 |
3 |
2 |
80x60 |
3 |
1 |
80x60 |
1 |
0 |
If current bandwidth is curr_bitrate, bandwidth before is prev_bitrate, then the change layer of computation bandwidth
The formula of grade are as follows:
Bitrate_change_level=log (curr_bitrate/prev_bitrate)/log (2.0)
if(bitrate_change_level>0)
Bitrate_change_level=bitrate_change_level*0.8
else
Bitrate_change_level=bitrate_change_level*2.0
If coding level before is prev_encoding_level, new coding level are as follows:
Curr_encoding_level=prev_encoding_level+bitrate_change_l evel
After obtaining new coding level, coding module resolution ratio according to corresponding to the coding level newly obtained and frame per second
To be encoded.
Further, the control module is further used for:
Do not change in Network status, or when variation is smaller, the case where level of Video coding is still according to video pictures
Continuous automatic adjusument:
The average value of 3 seconds quantized value QP before Video coding is calculated in the encoded resolution ratio of current bandwidth and frame per second,
And it makes the following judgment:
When average value is less than 24, level curr_encoding_level=prev_encoding_level+1 is encoded;
When average value is greater than 32, level curr_encoding_level=prev_encoding_level-1 is encoded;
Wherein, when the coding level curr_encoding_level being calculated is greater than 10, maximum setting curr_
Encoding_level is 10;
When the coding level curr_encoding_level being calculated is less than 0, minimum setting curr_encoding_
Level is 0.
As an implementation, when not changing in Network status, or changing smaller, control module is drawn according to video
The case where face, is to the continuous automatic adjusument of the level of Video coding: calculate H.264 Video coding at encoded point of current bandwidth
When resolution and frame per second, the average value of first 3 seconds quantized value QP encodes level curr_encoding_ when average value is less than 24
Level=prev_encoding_level+1;When average value is greater than 32, level curr_encoding_level=is encoded
Prev_encoding_level-1.
Wherein, when the coding level curr_encoding_level being calculated is greater than 10, curr_ is set
Encoding_level is 10;When the coding level curr_encoding_level being calculated is less than 0, minimum setting
Curr_encoding_level is 0.
Adaptive video coding device disclosed by the invention based on video calling scene can be in continually changing network
Video coding is carried out in the case of environment and video pictures content and realizes preferable video definition and fluency.