Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
aom-rav1e
Commits
6769143c
Commit
6769143c
authored
Apr 07, 2014
by
Dmitry Kovalev
Committed by
Gerrit Code Review
Apr 07, 2014
Browse files
Merge "Moving compute_qdelta functions into vp9_ratectrl.{h, c}."
parents
b03e7757
91dbac17
Changes
7
Hide whitespace changes
Inline
Side-by-side
vp9/encoder/vp9_aq_complexity.c
View file @
6769143c
...
...
@@ -48,8 +48,7 @@ void vp9_setup_in_frame_q_adj(VP9_COMP *cpi) {
// Use some of the segments for in frame Q adjustment.
for
(
segment
=
1
;
segment
<
2
;
segment
++
)
{
const
int
qindex_delta
=
vp9_compute_qdelta_by_rate
(
cpi
,
cm
->
base_qindex
,
vp9_compute_qdelta_by_rate
(
&
cpi
->
rc
,
cm
->
frame_type
,
cm
->
base_qindex
,
in_frame_q_adj_ratio
[
segment
]);
vp9_enable_segfeature
(
seg
,
segment
,
SEG_LVL_ALT_Q
);
vp9_set_segdata
(
seg
,
segment
,
SEG_LVL_ALT_Q
,
qindex_delta
);
...
...
vp9/encoder/vp9_aq_cyclicrefresh.c
View file @
6769143c
...
...
@@ -241,7 +241,7 @@ void vp9_cyclic_refresh_setup(VP9_COMP *const cpi) {
vp9_enable_segfeature
(
seg
,
1
,
SEG_LVL_ALT_Q
);
// Set the q delta for segment 1.
qindex_delta
=
vp9_compute_qdelta_by_rate
(
cpi
,
qindex_delta
=
vp9_compute_qdelta_by_rate
(
rc
,
cm
->
frame_type
,
cm
->
base_qindex
,
rate_ratio_qdelta
);
// TODO(marpan): Incorporate the actual-vs-target rate over/undershoot from
...
...
vp9/encoder/vp9_aq_variance.c
View file @
6769143c
...
...
@@ -99,7 +99,7 @@ void vp9_vaq_frame_setup(VP9_COMP *cpi) {
continue
;
}
qindex_delta
=
vp9_compute_qdelta
(
cpi
,
base_q
,
base_q
*
Q_RATIO
(
i
));
qindex_delta
=
vp9_compute_qdelta
(
&
cpi
->
rc
,
base_q
,
base_q
*
Q_RATIO
(
i
));
vp9_set_segdata
(
seg
,
SEGMENT_ID
(
i
),
SEG_LVL_ALT_Q
,
qindex_delta
);
vp9_enable_segfeature
(
seg
,
SEGMENT_ID
(
i
),
SEG_LVL_ALT_Q
);
...
...
vp9/encoder/vp9_onyx_if.c
View file @
6769143c
...
...
@@ -255,56 +255,6 @@ static void restore_coding_context(VP9_COMP *cpi) {
cm
->
fc
=
cc
->
fc
;
}
// Computes a q delta (in "q index" terms) to get from a starting q value
// to a target q value
int
vp9_compute_qdelta
(
const
VP9_COMP
*
cpi
,
double
qstart
,
double
qtarget
)
{
const
RATE_CONTROL
*
const
rc
=
&
cpi
->
rc
;
int
start_index
=
rc
->
worst_quality
;
int
target_index
=
rc
->
worst_quality
;
int
i
;
// Convert the average q value to an index.
for
(
i
=
rc
->
best_quality
;
i
<
rc
->
worst_quality
;
++
i
)
{
start_index
=
i
;
if
(
vp9_convert_qindex_to_q
(
i
)
>=
qstart
)
break
;
}
// Convert the q target to an index
for
(
i
=
rc
->
best_quality
;
i
<
rc
->
worst_quality
;
++
i
)
{
target_index
=
i
;
if
(
vp9_convert_qindex_to_q
(
i
)
>=
qtarget
)
break
;
}
return
target_index
-
start_index
;
}
// Computes a q delta (in "q index" terms) to get from a starting q value
// to a value that should equate to the given rate ratio.
int
vp9_compute_qdelta_by_rate
(
VP9_COMP
*
cpi
,
int
qindex
,
double
rate_target_ratio
)
{
const
FRAME_TYPE
frame_type
=
cpi
->
common
.
frame_type
;
const
RATE_CONTROL
*
const
rc
=
&
cpi
->
rc
;
int
target_index
=
rc
->
worst_quality
;
int
i
;
// Look up the current projected bits per block for the base index
const
int
base_bits_per_mb
=
vp9_rc_bits_per_mb
(
frame_type
,
qindex
,
1
.
0
);
// Find the target bits per mb based on the base value and given ratio.
const
int
target_bits_per_mb
=
(
int
)(
rate_target_ratio
*
base_bits_per_mb
);
// Convert the q target to an index
for
(
i
=
rc
->
best_quality
;
i
<
rc
->
worst_quality
;
++
i
)
{
target_index
=
i
;
if
(
vp9_rc_bits_per_mb
(
frame_type
,
i
,
1
.
0
)
<=
target_bits_per_mb
)
break
;
}
return
target_index
-
qindex
;
}
static
void
configure_static_seg_features
(
VP9_COMP
*
cpi
)
{
VP9_COMMON
*
const
cm
=
&
cpi
->
common
;
const
RATE_CONTROL
*
const
rc
=
&
cpi
->
rc
;
...
...
@@ -348,7 +298,7 @@ static void configure_static_seg_features(VP9_COMP *cpi) {
seg
->
update_map
=
1
;
seg
->
update_data
=
1
;
qi_delta
=
vp9_compute_qdelta
(
c
pi
,
rc
->
avg_q
,
rc
->
avg_q
*
0
.
875
);
qi_delta
=
vp9_compute_qdelta
(
r
c
,
rc
->
avg_q
,
rc
->
avg_q
*
0
.
875
);
vp9_set_segdata
(
seg
,
1
,
SEG_LVL_ALT_Q
,
qi_delta
-
2
);
vp9_set_segdata
(
seg
,
1
,
SEG_LVL_ALT_LF
,
-
2
);
...
...
@@ -369,7 +319,7 @@ static void configure_static_seg_features(VP9_COMP *cpi) {
seg
->
update_data
=
1
;
seg
->
abs_delta
=
SEGMENT_DELTADATA
;
qi_delta
=
vp9_compute_qdelta
(
c
pi
,
rc
->
avg_q
,
rc
->
avg_q
*
1
.
125
);
qi_delta
=
vp9_compute_qdelta
(
r
c
,
rc
->
avg_q
,
rc
->
avg_q
*
1
.
125
);
vp9_set_segdata
(
seg
,
1
,
SEG_LVL_ALT_Q
,
qi_delta
+
2
);
vp9_enable_segfeature
(
seg
,
1
,
SEG_LVL_ALT_Q
);
...
...
vp9/encoder/vp9_onyx_int.h
View file @
6769143c
...
...
@@ -609,11 +609,6 @@ int vp9_get_y_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
void
vp9_alloc_compressor_data
(
VP9_COMP
*
cpi
);
int
vp9_compute_qdelta
(
const
VP9_COMP
*
cpi
,
double
qstart
,
double
qtarget
);
int
vp9_compute_qdelta_by_rate
(
VP9_COMP
*
cpi
,
int
base_q_index
,
double
rate_target_ratio
);
void
vp9_scale_references
(
VP9_COMP
*
cpi
);
void
vp9_update_reference_frames
(
VP9_COMP
*
cpi
);
...
...
vp9/encoder/vp9_ratectrl.c
View file @
6769143c
...
...
@@ -460,7 +460,7 @@ static int rc_pick_q_and_bounds_one_pass_cbr(const VP9_COMP *cpi,
if
(
rc
->
this_key_frame_forced
)
{
int
qindex
=
rc
->
last_boosted_qindex
;
double
last_boosted_q
=
vp9_convert_qindex_to_q
(
qindex
);
int
delta_qindex
=
vp9_compute_qdelta
(
c
pi
,
last_boosted_q
,
int
delta_qindex
=
vp9_compute_qdelta
(
r
c
,
last_boosted_q
,
(
last_boosted_q
*
0
.
75
));
active_best_quality
=
MAX
(
qindex
+
delta_qindex
,
rc
->
best_quality
);
}
else
if
(
cm
->
current_video_frame
>
0
)
{
...
...
@@ -482,8 +482,8 @@ static int rc_pick_q_and_bounds_one_pass_cbr(const VP9_COMP *cpi,
// Convert the adjustment factor to a qindex delta
// on active_best_quality.
q_val
=
vp9_convert_qindex_to_q
(
active_best_quality
);
active_best_quality
+=
vp9_compute_qdelta
(
c
pi
,
q_val
,
q_val
*
q_adj_factor
);
active_best_quality
+=
vp9_compute_qdelta
(
r
c
,
q_val
,
q_val
*
q_adj_factor
);
}
}
else
if
(
!
rc
->
is_src_frame_alt_ref
&&
!
cpi
->
use_svc
&&
...
...
@@ -572,8 +572,8 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi,
if
(
rc
->
this_key_frame_forced
)
{
int
qindex
=
rc
->
last_boosted_qindex
;
double
last_boosted_q
=
vp9_convert_qindex_to_q
(
qindex
);
int
delta_qindex
=
vp9_compute_qdelta
(
c
pi
,
last_boosted_q
,
(
last_boosted_q
*
0
.
75
)
)
;
int
delta_qindex
=
vp9_compute_qdelta
(
r
c
,
last_boosted_q
,
last_boosted_q
*
0
.
75
);
active_best_quality
=
MAX
(
qindex
+
delta_qindex
,
rc
->
best_quality
);
}
else
if
(
cm
->
current_video_frame
>
0
)
{
// not first frame of one pass and kf_boost is set
...
...
@@ -594,15 +594,15 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi,
// Convert the adjustment factor to a qindex delta
// on active_best_quality.
q_val
=
vp9_convert_qindex_to_q
(
active_best_quality
);
active_best_quality
+=
vp9_compute_qdelta
(
c
pi
,
q_val
,
q_val
*
q_adj_factor
);
active_best_quality
+=
vp9_compute_qdelta
(
r
c
,
q_val
,
q_val
*
q_adj_factor
);
}
#else
double
current_q
;
// Force the KF quantizer to be 30% of the active_worst_quality.
current_q
=
vp9_convert_qindex_to_q
(
active_worst_quality
);
active_best_quality
=
active_worst_quality
+
vp9_compute_qdelta
(
c
pi
,
current_q
,
current_q
*
0
.
3
);
+
vp9_compute_qdelta
(
r
c
,
current_q
,
current_q
*
0
.
3
);
#endif
}
else
if
(
!
rc
->
is_src_frame_alt_ref
&&
(
cpi
->
refresh_golden_frame
||
cpi
->
refresh_alt_ref_frame
))
{
...
...
@@ -721,7 +721,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi,
assert
(
level
>=
0
);
new_q
=
current_q
*
(
1
.
0
-
(
0
.
2
*
(
cpi
->
max_arf_level
-
level
)));
q
=
active_worst_quality
+
vp9_compute_qdelta
(
c
pi
,
current_q
,
new_q
);
vp9_compute_qdelta
(
r
c
,
current_q
,
new_q
);
*
bottom_index
=
q
;
*
top_index
=
q
;
...
...
@@ -754,8 +754,8 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi,
if
(
rc
->
this_key_frame_forced
)
{
int
qindex
=
rc
->
last_boosted_qindex
;
double
last_boosted_q
=
vp9_convert_qindex_to_q
(
qindex
);
int
delta_qindex
=
vp9_compute_qdelta
(
c
pi
,
last_boosted_q
,
(
last_boosted_q
*
0
.
75
)
)
;
int
delta_qindex
=
vp9_compute_qdelta
(
r
c
,
last_boosted_q
,
last_boosted_q
*
0
.
75
);
active_best_quality
=
MAX
(
qindex
+
delta_qindex
,
rc
->
best_quality
);
}
else
{
// Not forced keyframe.
...
...
@@ -779,15 +779,15 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi,
// Convert the adjustment factor to a qindex delta
// on active_best_quality.
q_val
=
vp9_convert_qindex_to_q
(
active_best_quality
);
active_best_quality
+=
vp9_compute_qdelta
(
c
pi
,
q_val
,
q_val
*
q_adj_factor
);
active_best_quality
+=
vp9_compute_qdelta
(
r
c
,
q_val
,
q_val
*
q_adj_factor
);
}
#else
double
current_q
;
// Force the KF quantizer to be 30% of the active_worst_quality.
current_q
=
vp9_convert_qindex_to_q
(
active_worst_quality
);
active_best_quality
=
active_worst_quality
+
vp9_compute_qdelta
(
c
pi
,
current_q
,
current_q
*
0
.
3
);
+
vp9_compute_qdelta
(
r
c
,
current_q
,
current_q
*
0
.
3
);
#endif
}
else
if
(
!
rc
->
is_src_frame_alt_ref
&&
(
cpi
->
refresh_golden_frame
||
cpi
->
refresh_alt_ref_frame
))
{
...
...
@@ -904,7 +904,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi,
assert
(
level
>=
0
);
new_q
=
current_q
*
(
1
.
0
-
(
0
.
2
*
(
cpi
->
max_arf_level
-
level
)));
q
=
active_worst_quality
+
vp9_compute_qdelta
(
c
pi
,
current_q
,
new_q
);
vp9_compute_qdelta
(
r
c
,
current_q
,
new_q
);
*
bottom_index
=
q
;
*
top_index
=
q
;
...
...
@@ -1282,3 +1282,46 @@ void vp9_rc_get_one_pass_cbr_params(VP9_COMP *cpi) {
rc
->
frames_till_gf_update_due
=
INT_MAX
;
rc
->
baseline_gf_interval
=
INT_MAX
;
}
int
vp9_compute_qdelta
(
const
RATE_CONTROL
*
rc
,
double
qstart
,
double
qtarget
)
{
int
start_index
=
rc
->
worst_quality
;
int
target_index
=
rc
->
worst_quality
;
int
i
;
// Convert the average q value to an index.
for
(
i
=
rc
->
best_quality
;
i
<
rc
->
worst_quality
;
++
i
)
{
start_index
=
i
;
if
(
vp9_convert_qindex_to_q
(
i
)
>=
qstart
)
break
;
}
// Convert the q target to an index
for
(
i
=
rc
->
best_quality
;
i
<
rc
->
worst_quality
;
++
i
)
{
target_index
=
i
;
if
(
vp9_convert_qindex_to_q
(
i
)
>=
qtarget
)
break
;
}
return
target_index
-
start_index
;
}
int
vp9_compute_qdelta_by_rate
(
const
RATE_CONTROL
*
rc
,
FRAME_TYPE
frame_type
,
int
qindex
,
double
rate_target_ratio
)
{
int
target_index
=
rc
->
worst_quality
;
int
i
;
// Look up the current projected bits per block for the base index
const
int
base_bits_per_mb
=
vp9_rc_bits_per_mb
(
frame_type
,
qindex
,
1
.
0
);
// Find the target bits per mb based on the base value and given ratio.
const
int
target_bits_per_mb
=
(
int
)(
rate_target_ratio
*
base_bits_per_mb
);
// Convert the q target to an index
for
(
i
=
rc
->
best_quality
;
i
<
rc
->
worst_quality
;
++
i
)
{
target_index
=
i
;
if
(
vp9_rc_bits_per_mb
(
frame_type
,
i
,
1
.
0
)
<=
target_bits_per_mb
)
break
;
}
return
target_index
-
qindex
;
}
vp9/encoder/vp9_ratectrl.h
View file @
6769143c
...
...
@@ -160,6 +160,15 @@ int vp9_rc_clamp_pframe_target_size(const struct VP9_COMP *const cpi,
// This function is called only from the vp9_rc_get_..._params() functions.
void
vp9_rc_set_frame_target
(
struct
VP9_COMP
*
cpi
,
int
target
);
// Computes a q delta (in "q index" terms) to get from a starting q value
// to a target q value
int
vp9_compute_qdelta
(
const
RATE_CONTROL
*
rc
,
double
qstart
,
double
qtarget
);
// Computes a q delta (in "q index" terms) to get from a starting q value
// to a value that should equate to the given rate ratio.
int
vp9_compute_qdelta_by_rate
(
const
RATE_CONTROL
*
rc
,
FRAME_TYPE
frame_type
,
int
qindex
,
double
rate_target_ratio
);
#ifdef __cplusplus
}
// extern "C"
#endif
...
...
Write
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!
Cancel
Please
register
or
sign in
to comment