Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
BC
public
external
libvpx
Commits
e85bff25
Commit
e85bff25
authored
11 years ago
by
Dmitry Kovalev
Committed by
Gerrit Code Review
11 years ago
Browse files
Options
Download
Plain Diff
Merge "Cleaning up vp9_svc_layercontext.c"
parents
d1087752
2df69fef
v1.14.0-linphone
1.4.X
feature/update_to_v1.9.0-linphone
feature/uwp_nuget
frame_parallel
highbitdepth
indianrunnerduck
javanwhistlingduck
khakicampbell
linphone
linphone-android
linphone-old
longtailedduck
m49-2623
m52-2743
m54-2840
m56-2924
m66-3359
m68-3440
mandarinduck
nextgen
nextgenv2
playground
sandbox/Jingning/experimental
sandbox/Jingning/transcode
sandbox/Jingning/vpx
sandbox/aconverse@google.com/ansbench
sandbox/hkuang/frame_parallel
sandbox/hkuang@google.com/decode
sandbox/jimbankoski@google.com/proposed-aom
sandbox/jingning@google.com/decoder_test_suite
sandbox/jingning@google.com/experimental
sandbox/jzern@google.com/test
sandbox/wangch@google.com/vp9
sandbox/yaowu@google.com/mergeaom
v1.12.0-linphone
v1.6.1_linphone
v1.7.0-linphone
v1.9.0-linphone
v1.9.0
v1.9.0-rc1
v1.8.2
v1.8.1
v1.8.0
v1.7.0
v1.6.1
v1.6.0
v1.5.0
v1.4.0
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
vp9/encoder/vp9_svc_layercontext.c
+41
-36
vp9/encoder/vp9_svc_layercontext.c
with
41 additions
and
36 deletions
vp9/encoder/vp9_svc_layercontext.c
+
41
−
36
View file @
e85bff25
...
@@ -15,13 +15,14 @@
...
@@ -15,13 +15,14 @@
void
vp9_init_layer_context
(
VP9_COMP
*
const
cpi
)
{
void
vp9_init_layer_context
(
VP9_COMP
*
const
cpi
)
{
const
VP9_CONFIG
*
const
oxcf
=
&
cpi
->
oxcf
;
const
VP9_CONFIG
*
const
oxcf
=
&
cpi
->
oxcf
;
int
temporal_layer
=
0
;
int
layer
;
cpi
->
svc
.
spatial_layer_id
=
0
;
cpi
->
svc
.
spatial_layer_id
=
0
;
cpi
->
svc
.
temporal_layer_id
=
0
;
cpi
->
svc
.
temporal_layer_id
=
0
;
for
(
temporal_layer
=
0
;
temporal_layer
<
cpi
->
svc
.
number_temporal_layers
;
for
(
layer
=
0
;
layer
<
cpi
->
svc
.
number_temporal_layers
;
++
layer
)
{
++
temporal_layer
)
{
LAYER_CONTEXT
*
const
lc
=
&
cpi
->
svc
.
layer_context
[
layer
];
LAYER_CONTEXT
*
const
lc
=
&
cpi
->
svc
.
layer_context
[
temporal_layer
];
RATE_CONTROL
*
const
lrc
=
&
lc
->
rc
;
RATE_CONTROL
*
const
lrc
=
&
lc
->
rc
;
lrc
->
avg_frame_qindex
[
INTER_FRAME
]
=
q_trans
[
oxcf
->
worst_allowed_q
];
lrc
->
avg_frame_qindex
[
INTER_FRAME
]
=
q_trans
[
oxcf
->
worst_allowed_q
];
lrc
->
last_q
[
INTER_FRAME
]
=
q_trans
[
oxcf
->
worst_allowed_q
];
lrc
->
last_q
[
INTER_FRAME
]
=
q_trans
[
oxcf
->
worst_allowed_q
];
lrc
->
ni_av_qi
=
q_trans
[
oxcf
->
worst_allowed_q
];
lrc
->
ni_av_qi
=
q_trans
[
oxcf
->
worst_allowed_q
];
...
@@ -35,11 +36,9 @@ void vp9_init_layer_context(VP9_COMP *const cpi) {
...
@@ -35,11 +36,9 @@ void vp9_init_layer_context(VP9_COMP *const cpi) {
lrc
->
decimation_factor
=
0
;
lrc
->
decimation_factor
=
0
;
lrc
->
rate_correction_factor
=
1
.
0
;
lrc
->
rate_correction_factor
=
1
.
0
;
lrc
->
key_frame_rate_correction_factor
=
1
.
0
;
lrc
->
key_frame_rate_correction_factor
=
1
.
0
;
lc
->
target_bandwidth
=
oxcf
->
ts_target_bitrate
[
temporal_layer
]
*
lc
->
target_bandwidth
=
oxcf
->
ts_target_bitrate
[
layer
]
*
1000
;
1000
;
lrc
->
buffer_level
=
vp9_rescale
((
int
)(
oxcf
->
starting_buffer_level
),
lrc
->
buffer_level
=
lc
->
target_bandwidth
,
1000
);
vp9_rescale
((
int
)(
oxcf
->
starting_buffer_level
),
lc
->
target_bandwidth
,
1000
);
lrc
->
bits_off_target
=
lrc
->
buffer_level
;
lrc
->
bits_off_target
=
lrc
->
buffer_level
;
}
}
}
}
...
@@ -49,14 +48,14 @@ void vp9_update_layer_context_change_config(VP9_COMP *const cpi,
...
@@ -49,14 +48,14 @@ void vp9_update_layer_context_change_config(VP9_COMP *const cpi,
const
int
target_bandwidth
)
{
const
int
target_bandwidth
)
{
const
VP9_CONFIG
*
const
oxcf
=
&
cpi
->
oxcf
;
const
VP9_CONFIG
*
const
oxcf
=
&
cpi
->
oxcf
;
const
RATE_CONTROL
*
const
rc
=
&
cpi
->
rc
;
const
RATE_CONTROL
*
const
rc
=
&
cpi
->
rc
;
int
temporal_
layer
=
0
;
int
layer
;
float
bitrate_alloc
=
1
.
0
;
float
bitrate_alloc
=
1
.
0
;
for
(
temporal_layer
=
0
;
temporal_layer
<
cpi
->
svc
.
number_temporal_layers
;
++
temporal_
layer
)
{
for
(
layer
=
0
;
layer
<
cpi
->
svc
.
number_temporal_layers
;
++
layer
)
{
LAYER_CONTEXT
*
const
lc
=
&
cpi
->
svc
.
layer_context
[
temporal_
layer
];
LAYER_CONTEXT
*
const
lc
=
&
cpi
->
svc
.
layer_context
[
layer
];
RATE_CONTROL
*
const
lrc
=
&
lc
->
rc
;
RATE_CONTROL
*
const
lrc
=
&
lc
->
rc
;
lc
->
target_bandwidth
=
oxcf
->
ts_target_bitrate
[
temporal_
layer
]
*
1000
;
lc
->
target_bandwidth
=
oxcf
->
ts_target_bitrate
[
layer
]
*
1000
;
bitrate_alloc
=
(
float
)
lc
->
target_bandwidth
/
(
float
)
target_bandwidth
;
bitrate_alloc
=
(
float
)
lc
->
target_bandwidth
/
target_bandwidth
;
// Update buffer-related quantities.
// Update buffer-related quantities.
lc
->
starting_buffer_level
=
lc
->
starting_buffer_level
=
(
int64_t
)(
oxcf
->
starting_buffer_level
*
bitrate_alloc
);
(
int64_t
)(
oxcf
->
starting_buffer_level
*
bitrate_alloc
);
...
@@ -67,7 +66,7 @@ void vp9_update_layer_context_change_config(VP9_COMP *const cpi,
...
@@ -67,7 +66,7 @@ void vp9_update_layer_context_change_config(VP9_COMP *const cpi,
lrc
->
bits_off_target
=
MIN
(
lrc
->
bits_off_target
,
lc
->
maximum_buffer_size
);
lrc
->
bits_off_target
=
MIN
(
lrc
->
bits_off_target
,
lc
->
maximum_buffer_size
);
lrc
->
buffer_level
=
MIN
(
lrc
->
buffer_level
,
lc
->
maximum_buffer_size
);
lrc
->
buffer_level
=
MIN
(
lrc
->
buffer_level
,
lc
->
maximum_buffer_size
);
// Update framerate-related quantities.
// Update framerate-related quantities.
lc
->
framerate
=
oxcf
->
framerate
/
oxcf
->
ts_rate_decimator
[
temporal_
layer
];
lc
->
framerate
=
oxcf
->
framerate
/
oxcf
->
ts_rate_decimator
[
layer
];
lrc
->
av_per_frame_bandwidth
=
(
int
)(
lc
->
target_bandwidth
/
lc
->
framerate
);
lrc
->
av_per_frame_bandwidth
=
(
int
)(
lc
->
target_bandwidth
/
lc
->
framerate
);
lrc
->
max_frame_bandwidth
=
rc
->
max_frame_bandwidth
;
lrc
->
max_frame_bandwidth
=
rc
->
max_frame_bandwidth
;
// Update qp-related quantities.
// Update qp-related quantities.
...
@@ -76,22 +75,27 @@ void vp9_update_layer_context_change_config(VP9_COMP *const cpi,
...
@@ -76,22 +75,27 @@ void vp9_update_layer_context_change_config(VP9_COMP *const cpi,
}
}
}
}
static
LAYER_CONTEXT
*
get_temporal_layer_context
(
SVC
*
svc
)
{
return
&
svc
->
layer_context
[
svc
->
temporal_layer_id
];
}
void
vp9_update_layer_framerate
(
VP9_COMP
*
const
cpi
)
{
void
vp9_update_layer_framerate
(
VP9_COMP
*
const
cpi
)
{
int
temporal_
layer
=
cpi
->
svc
.
temporal_layer_id
;
const
int
layer
=
cpi
->
svc
.
temporal_layer_id
;
const
VP9_CONFIG
*
const
oxcf
=
&
cpi
->
oxcf
;
const
VP9_CONFIG
*
const
oxcf
=
&
cpi
->
oxcf
;
LAYER_CONTEXT
*
const
lc
=
&
cpi
->
svc
.
layer_context
[
temporal_layer
]
;
LAYER_CONTEXT
*
const
lc
=
get_temporal_layer_context
(
&
cpi
->
svc
)
;
RATE_CONTROL
*
const
lrc
=
&
lc
->
rc
;
RATE_CONTROL
*
const
lrc
=
&
lc
->
rc
;
lc
->
framerate
=
oxcf
->
framerate
/
oxcf
->
ts_rate_decimator
[
temporal_layer
];
lc
->
framerate
=
oxcf
->
framerate
/
oxcf
->
ts_rate_decimator
[
layer
];
lrc
->
av_per_frame_bandwidth
=
(
int
)(
lc
->
target_bandwidth
/
lc
->
framerate
);
lrc
->
av_per_frame_bandwidth
=
(
int
)(
lc
->
target_bandwidth
/
lc
->
framerate
);
lrc
->
max_frame_bandwidth
=
cpi
->
rc
.
max_frame_bandwidth
;
lrc
->
max_frame_bandwidth
=
cpi
->
rc
.
max_frame_bandwidth
;
// Update the average layer frame size (non-cumulative per-frame-bw).
// Update the average layer frame size (non-cumulative per-frame-bw).
if
(
temporal_
layer
==
0
)
{
if
(
layer
==
0
)
{
lc
->
avg_frame_size
=
lrc
->
av_per_frame_bandwidth
;
lc
->
avg_frame_size
=
lrc
->
av_per_frame_bandwidth
;
}
else
{
}
else
{
double
prev_layer_framerate
=
oxcf
->
framerate
/
const
double
prev_layer_framerate
=
oxcf
->
ts_rate_decimator
[
temporal_
layer
-
1
];
oxcf
->
framerate
/
oxcf
->
ts_rate_decimator
[
layer
-
1
];
int
prev_layer_target_bandwidth
=
const
int
prev_layer_target_bandwidth
=
oxcf
->
ts_target_bitrate
[
temporal_
layer
-
1
]
*
1000
;
oxcf
->
ts_target_bitrate
[
layer
-
1
]
*
1000
;
lc
->
avg_frame_size
=
lc
->
avg_frame_size
=
(
int
)((
lc
->
target_bandwidth
-
prev_layer_target_bandwidth
)
/
(
int
)((
lc
->
target_bandwidth
-
prev_layer_target_bandwidth
)
/
(
lc
->
framerate
-
prev_layer_framerate
));
(
lc
->
framerate
-
prev_layer_framerate
));
...
@@ -99,10 +103,10 @@ void vp9_update_layer_framerate(VP9_COMP *const cpi) {
...
@@ -99,10 +103,10 @@ void vp9_update_layer_framerate(VP9_COMP *const cpi) {
}
}
void
vp9_restore_layer_context
(
VP9_COMP
*
const
cpi
)
{
void
vp9_restore_layer_context
(
VP9_COMP
*
const
cpi
)
{
int
temporal_layer
=
cpi
->
svc
.
temporal_layer_id
;
LAYER_CONTEXT
*
const
lc
=
get_temporal_layer_context
(
&
cpi
->
svc
)
;
LAYER_CONTEXT
*
lc
=
&
cpi
->
svc
.
layer_context
[
temporal_layer
]
;
const
int
old_frame_since_key
=
cpi
->
rc
.
frames_since_key
;
int
frame_
since
_key
=
cpi
->
rc
.
frames_
since
_key
;
const
int
old_
frame_
to
_key
=
cpi
->
rc
.
frames_
to
_key
;
int
frame_to_key
=
cpi
->
rc
.
frames_to_key
;
cpi
->
rc
=
lc
->
rc
;
cpi
->
rc
=
lc
->
rc
;
cpi
->
oxcf
.
target_bandwidth
=
lc
->
target_bandwidth
;
cpi
->
oxcf
.
target_bandwidth
=
lc
->
target_bandwidth
;
cpi
->
oxcf
.
starting_buffer_level
=
lc
->
starting_buffer_level
;
cpi
->
oxcf
.
starting_buffer_level
=
lc
->
starting_buffer_level
;
...
@@ -111,17 +115,18 @@ void vp9_restore_layer_context(VP9_COMP *const cpi) {
...
@@ -111,17 +115,18 @@ void vp9_restore_layer_context(VP9_COMP *const cpi) {
cpi
->
output_framerate
=
lc
->
framerate
;
cpi
->
output_framerate
=
lc
->
framerate
;
// Reset the frames_since_key and frames_to_key counters to their values
// Reset the frames_since_key and frames_to_key counters to their values
// before the layer restore. Keep these defined for the stream (not layer).
// before the layer restore. Keep these defined for the stream (not layer).
cpi
->
rc
.
frames_since_key
=
frame_since_key
;
cpi
->
rc
.
frames_since_key
=
old_
frame_since_key
;
cpi
->
rc
.
frames_to_key
=
frame_to_key
;
cpi
->
rc
.
frames_to_key
=
old_
frame_to_key
;
}
}
void
vp9_save_layer_context
(
VP9_COMP
*
const
cpi
)
{
void
vp9_save_layer_context
(
VP9_COMP
*
const
cpi
)
{
int
temporal_layer
=
cpi
->
svc
.
temporal_layer_id
;
const
VP9_CONFIG
*
const
oxcf
=
&
cpi
->
oxcf
;
LAYER_CONTEXT
*
lc
=
&
cpi
->
svc
.
layer_context
[
temporal_layer
];
LAYER_CONTEXT
*
const
lc
=
get_temporal_layer_context
(
&
cpi
->
svc
);
lc
->
rc
=
cpi
->
rc
;
lc
->
rc
=
cpi
->
rc
;
lc
->
target_bandwidth
=
(
int
)
cpi
->
oxcf
.
target_bandwidth
;
lc
->
target_bandwidth
=
(
int
)
oxcf
->
target_bandwidth
;
lc
->
starting_buffer_level
=
cpi
->
oxcf
.
starting_buffer_level
;
lc
->
starting_buffer_level
=
oxcf
->
starting_buffer_level
;
lc
->
optimal_buffer_level
=
cpi
->
oxcf
.
optimal_buffer_level
;
lc
->
optimal_buffer_level
=
oxcf
->
optimal_buffer_level
;
lc
->
maximum_buffer_size
=
cpi
->
oxcf
.
maximum_buffer_size
;
lc
->
maximum_buffer_size
=
oxcf
->
maximum_buffer_size
;
lc
->
framerate
=
cpi
->
output_framerate
;
lc
->
framerate
=
cpi
->
output_framerate
;
}
}
This diff is collapsed.
Click to expand it.
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets