Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Yushin Cho
aom-rav1e
Commits
b5f3cb6e
Commit
b5f3cb6e
authored
Feb 22, 2013
by
Paul Wilkins
Committed by
Gerrit Code Review
Feb 22, 2013
Browse files
Merge "Experimental removal of over quant code" into experimental
parents
5a18106f
dbf49420
Changes
5
Hide whitespace changes
Inline
Side-by-side
vp9/encoder/vp9_onyx_if.c
View file @
b5f3cb6e
...
...
@@ -2551,8 +2551,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
int
q_low
;
int
q_high
;
int
zbin_oq_high
;
int
zbin_oq_low
=
0
;
int
top_index
;
int
bottom_index
;
...
...
@@ -2565,11 +2563,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
#if RESET_FOREACH_FILTER
int
q_low0
;
int
q_high0
;
int
zbin_oq_high0
;
int
zbin_oq_low0
=
0
;
int
Q0
;
int
last_zbin_oq
;
int
last_zbin_oq0
;
int
active_best_quality0
;
int
active_worst_quality0
;
double
rate_correction_factor0
;
...
...
@@ -2603,7 +2597,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
}
// Clear zbin over-quant value and mode boost values.
cpi
->
zbin_over_quant
=
0
;
cpi
->
zbin_mode_boost
=
0
;
// Enable or disable mode based tweaking of the zbin
...
...
@@ -2794,18 +2787,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
// Determine initial Q to try
Q
=
vp9_regulate_q
(
cpi
,
cpi
->
this_frame_target
);
}
#if RESET_FOREACH_FILTER
last_zbin_oq
=
cpi
->
zbin_over_quant
;
#endif
// Set highest allowed value for Zbin over quant
if
(
cm
->
frame_type
==
KEY_FRAME
)
zbin_oq_high
=
0
;
// ZBIN_OQ_MAX/16
else
if
(
cpi
->
refresh_alt_ref_frame
||
(
cpi
->
refresh_golden_frame
&&
!
cpi
->
source_alt_ref_active
))
zbin_oq_high
=
16
;
else
zbin_oq_high
=
ZBIN_OQ_MAX
;
vp9_compute_frame_size_bounds
(
cpi
,
&
frame_under_shoot_limit
,
&
frame_over_shoot_limit
);
...
...
@@ -2888,9 +2869,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
q_low0
=
q_low
;
q_high0
=
q_high
;
Q0
=
Q
;
zbin_oq_low0
=
zbin_oq_low
;
zbin_oq_high0
=
zbin_oq_high
;
last_zbin_oq0
=
last_zbin_oq
;
rate_correction_factor0
=
cpi
->
rate_correction_factor
;
gf_rate_correction_factor0
=
cpi
->
gf_rate_correction_factor
;
active_best_quality0
=
cpi
->
active_best_quality
;
...
...
@@ -3049,23 +3027,12 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
if
(
cpi
->
projected_frame_size
>
cpi
->
this_frame_target
)
{
q_low
=
(
Q
<
q_high
)
?
(
Q
+
1
)
:
q_high
;
// Raise Qlow as to at least the current value
if
(
cpi
->
zbin_over_quant
>
0
)
// If we are using over quant do the same for zbin_oq_low
zbin_oq_low
=
(
cpi
->
zbin_over_quant
<
zbin_oq_high
)
?
(
cpi
->
zbin_over_quant
+
1
)
:
zbin_oq_high
;
if
(
undershoot_seen
||
(
loop_count
>
1
))
{
// Update rate_correction_factor unless cpi->active_worst_quality has changed.
if
(
!
active_worst_qchanged
)
vp9_update_rate_correction_factors
(
cpi
,
1
);
Q
=
(
q_high
+
q_low
+
1
)
/
2
;
// Adjust cpi->zbin_over_quant (only allowed when Q is max)
if
(
Q
<
MAXQ
)
cpi
->
zbin_over_quant
=
0
;
else
{
zbin_oq_low
=
(
cpi
->
zbin_over_quant
<
zbin_oq_high
)
?
(
cpi
->
zbin_over_quant
+
1
)
:
zbin_oq_high
;
cpi
->
zbin_over_quant
=
(
zbin_oq_high
+
zbin_oq_low
)
/
2
;
}
}
else
{
// Update rate_correction_factor unless cpi->active_worst_quality has changed.
if
(
!
active_worst_qchanged
)
...
...
@@ -3073,7 +3040,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
Q
=
vp9_regulate_q
(
cpi
,
cpi
->
this_frame_target
);
while
((
(
Q
<
q_low
)
||
(
cpi
->
zbin_over_quant
<
zbin_oq_low
))
&&
(
Retries
<
10
))
{
while
((
Q
<
q_low
)
&&
(
Retries
<
10
))
{
vp9_update_rate_correction_factors
(
cpi
,
0
);
Q
=
vp9_regulate_q
(
cpi
,
cpi
->
this_frame_target
);
Retries
++
;
...
...
@@ -3084,10 +3051,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
}
// Frame is too small
else
{
if
(
cpi
->
zbin_over_quant
==
0
)
q_high
=
(
Q
>
q_low
)
?
(
Q
-
1
)
:
q_low
;
// Lower q_high if not using over quant
else
// else lower zbin_oq_high
zbin_oq_high
=
(
cpi
->
zbin_over_quant
>
zbin_oq_low
)
?
(
cpi
->
zbin_over_quant
-
1
)
:
zbin_oq_low
;
q_high
=
(
Q
>
q_low
)
?
(
Q
-
1
)
:
q_low
;
if
(
overshoot_seen
||
(
loop_count
>
1
))
{
// Update rate_correction_factor unless cpi->active_worst_quality has changed.
...
...
@@ -3095,12 +3059,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
vp9_update_rate_correction_factors
(
cpi
,
1
);
Q
=
(
q_high
+
q_low
)
/
2
;
// Adjust cpi->zbin_over_quant (only allowed when Q is max)
if
(
Q
<
MAXQ
)
cpi
->
zbin_over_quant
=
0
;
else
cpi
->
zbin_over_quant
=
(
zbin_oq_high
+
zbin_oq_low
)
/
2
;
}
else
{
// Update rate_correction_factor unless cpi->active_worst_quality has changed.
if
(
!
active_worst_qchanged
)
...
...
@@ -3117,7 +3075,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
q_low
=
Q
;
}
while
((
(
Q
>
q_high
)
||
(
cpi
->
zbin_over_quant
>
zbin_oq_high
))
&&
(
Retries
<
10
))
{
while
((
Q
>
q_high
)
&&
(
Retries
<
10
))
{
vp9_update_rate_correction_factors
(
cpi
,
0
);
Q
=
vp9_regulate_q
(
cpi
,
cpi
->
this_frame_target
);
Retries
++
;
...
...
@@ -3133,16 +3091,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
else
if
(
Q
<
q_low
)
Q
=
q_low
;
// Clamp cpi->zbin_over_quant
cpi
->
zbin_over_quant
=
(
cpi
->
zbin_over_quant
<
zbin_oq_low
)
?
zbin_oq_low
:
(
cpi
->
zbin_over_quant
>
zbin_oq_high
)
?
zbin_oq_high
:
cpi
->
zbin_over_quant
;
// Loop = ((Q != last_q) || (last_zbin_oq != cpi->zbin_over_quant)) ? TRUE : FALSE;
Loop
=
((
Q
!=
last_q
))
?
TRUE
:
FALSE
;
#if RESET_FOREACH_FILTER
last_zbin_oq
=
cpi
->
zbin_over_quant
;
#endif
}
else
Loop
=
FALSE
;
...
...
@@ -3186,12 +3135,9 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
if
(
Loop
==
TRUE
)
{
overshoot_seen
=
FALSE
;
undershoot_seen
=
FALSE
;
zbin_oq_low
=
zbin_oq_low0
;
zbin_oq_high
=
zbin_oq_high0
;
q_low
=
q_low0
;
q_high
=
q_high0
;
Q
=
Q0
;
cpi
->
zbin_over_quant
=
last_zbin_oq
=
last_zbin_oq0
;
cpi
->
rate_correction_factor
=
rate_correction_factor0
;
cpi
->
gf_rate_correction_factor
=
gf_rate_correction_factor0
;
cpi
->
active_best_quality
=
active_best_quality0
;
...
...
@@ -3440,8 +3386,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
cpi->avg_q,
vp9_convert_qindex_to_q(cpi->ni_av_qi),
vp9_convert_qindex_to_q(cpi->cq_target_quality),
cpi->zbin_over_quant,
// cpi->avg_frame_qindex, cpi->zbin_over_quant,
cpi->refresh_golden_frame, cpi->refresh_alt_ref_frame,
cm->frame_type, cpi->gfu_boost,
cpi->twopass.est_max_qcorrection_factor,
...
...
@@ -3454,7 +3398,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
else
fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d"
"%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f"
"
%6d %5d
%5d %5d %8d %8.2f %10d %10.3f"
"%5d %5d %8d %8.2f %10d %10.3f"
"%8d %10d %10d %10d\n",
cpi->common.current_video_frame,
cpi->this_frame_target, cpi->projected_frame_size,
...
...
@@ -3470,8 +3414,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
cpi->avg_q,
vp9_convert_qindex_to_q(cpi->ni_av_qi),
vp9_convert_qindex_to_q(cpi->cq_target_quality),
cpi->zbin_over_quant,
// cpi->avg_frame_qindex, cpi->zbin_over_quant,
cpi->refresh_golden_frame, cpi->refresh_alt_ref_frame,
cm->frame_type, cpi->gfu_boost,
cpi->twopass.est_max_qcorrection_factor,
...
...
vp9/encoder/vp9_onyx_int.h
View file @
b5f3cb6e
...
...
@@ -53,7 +53,6 @@
#define GF_ZEROMV_ZBIN_BOOST 12
#define LF_ZEROMV_ZBIN_BOOST 6
#define MV_ZBIN_BOOST 4
#define ZBIN_OQ_MAX 192
#define VP9_TEMPORAL_ALT_REF 1
...
...
@@ -421,7 +420,6 @@ typedef struct VP9_COMP {
double
tot_q
;
double
avg_q
;
int
zbin_over_quant
;
int
zbin_mode_boost
;
int
zbin_mode_boost_enabled
;
...
...
vp9/encoder/vp9_quantize.c
View file @
b5f3cb6e
...
...
@@ -484,8 +484,7 @@ void vp9_mb_init_quantizer(VP9_COMP *cpi, MACROBLOCK *x) {
// Y
zbin_extra
=
(
cpi
->
common
.
Y1dequant
[
QIndex
][
1
]
*
(
cpi
->
zbin_over_quant
+
cpi
->
zbin_mode_boost
+
(
cpi
->
zbin_mode_boost
+
x
->
act_zbin_adj
))
>>
7
;
for
(
i
=
0
;
i
<
16
;
i
++
)
{
...
...
@@ -504,8 +503,7 @@ void vp9_mb_init_quantizer(VP9_COMP *cpi, MACROBLOCK *x) {
// UV
zbin_extra
=
(
cpi
->
common
.
UVdequant
[
QIndex
][
1
]
*
(
cpi
->
zbin_over_quant
+
cpi
->
zbin_mode_boost
+
(
cpi
->
zbin_mode_boost
+
x
->
act_zbin_adj
))
>>
7
;
for
(
i
=
16
;
i
<
24
;
i
++
)
{
...
...
@@ -533,8 +531,7 @@ void vp9_update_zbin_extra(VP9_COMP *cpi, MACROBLOCK *x) {
// Y
zbin_extra
=
(
cpi
->
common
.
Y1dequant
[
QIndex
][
1
]
*
(
cpi
->
zbin_over_quant
+
cpi
->
zbin_mode_boost
+
(
cpi
->
zbin_mode_boost
+
x
->
act_zbin_adj
))
>>
7
;
for
(
i
=
0
;
i
<
16
;
i
++
)
{
x
->
block
[
i
].
zbin_extra
=
(
int16_t
)
zbin_extra
;
...
...
@@ -542,8 +539,7 @@ void vp9_update_zbin_extra(VP9_COMP *cpi, MACROBLOCK *x) {
// UV
zbin_extra
=
(
cpi
->
common
.
UVdequant
[
QIndex
][
1
]
*
(
cpi
->
zbin_over_quant
+
cpi
->
zbin_mode_boost
+
(
cpi
->
zbin_mode_boost
+
x
->
act_zbin_adj
))
>>
7
;
for
(
i
=
16
;
i
<
24
;
i
++
)
{
...
...
vp9/encoder/vp9_ratectrl.c
View file @
b5f3cb6e
...
...
@@ -410,23 +410,6 @@ void vp9_update_rate_correction_factors(VP9_COMP *cpi, int damp_var) {
vp9_bits_per_mb
(
cpi
->
common
.
frame_type
,
Q
))
*
cpi
->
common
.
MBs
)
/
(
1
<<
BPER_MB_NORMBITS
));
// Make some allowance for cpi->zbin_over_quant
if
(
cpi
->
zbin_over_quant
>
0
)
{
int
Z
=
cpi
->
zbin_over_quant
;
double
Factor
=
0
.
99
;
double
factor_adjustment
=
0
.
01
/
256
.
0
;
// (double)ZBIN_OQ_MAX;
while
(
Z
>
0
)
{
Z
--
;
projected_size_based_on_q
=
(
int
)(
Factor
*
projected_size_based_on_q
);
Factor
+=
factor_adjustment
;
if
(
Factor
>=
0
.
999
)
Factor
=
0
.
999
;
}
}
// Work out a size correction factor.
// if ( cpi->this_frame_target > 0 )
// correction_factor = (100 * cpi->projected_frame_size) / cpi->this_frame_target;
...
...
@@ -488,9 +471,6 @@ int vp9_regulate_q(VP9_COMP *cpi, int target_bits_per_frame) {
int
bits_per_mb_at_this_q
;
double
correction_factor
;
// Reset Zbin OQ value
cpi
->
zbin_over_quant
=
0
;
// Select the appropriate correction factor based upon type of frame.
if
(
cpi
->
common
.
frame_type
==
KEY_FRAME
)
correction_factor
=
cpi
->
key_frame_rate_correction_factor
;
...
...
@@ -525,46 +505,6 @@ int vp9_regulate_q(VP9_COMP *cpi, int target_bits_per_frame) {
last_error
=
bits_per_mb_at_this_q
-
target_bits_per_mb
;
}
while
(
++
i
<=
cpi
->
active_worst_quality
);
// If we are at MAXQ then enable Q over-run which seeks to claw back additional bits through things like
// the RD multiplier and zero bin size.
if
(
Q
>=
MAXQ
)
{
int
zbin_oqmax
;
double
Factor
=
0
.
99
;
double
factor_adjustment
=
0
.
01
/
256
.
0
;
// (double)ZBIN_OQ_MAX;
if
(
cpi
->
common
.
frame_type
==
KEY_FRAME
)
zbin_oqmax
=
0
;
// ZBIN_OQ_MAX/16
else
if
(
cpi
->
refresh_alt_ref_frame
||
(
cpi
->
refresh_golden_frame
&&
!
cpi
->
source_alt_ref_active
))
zbin_oqmax
=
16
;
else
zbin_oqmax
=
ZBIN_OQ_MAX
;
// Each incrment in the zbin is assumed to have a fixed effect on bitrate. This is not of course true.
// The effect will be highly clip dependent and may well have sudden steps.
// The idea here is to acheive higher effective quantizers than the normal maximum by expanding the zero
// bin and hence decreasing the number of low magnitude non zero coefficients.
while
(
cpi
->
zbin_over_quant
<
zbin_oqmax
)
{
cpi
->
zbin_over_quant
++
;
if
(
cpi
->
zbin_over_quant
>
zbin_oqmax
)
cpi
->
zbin_over_quant
=
zbin_oqmax
;
// Adjust bits_per_mb_at_this_q estimate
bits_per_mb_at_this_q
=
(
int
)(
Factor
*
bits_per_mb_at_this_q
);
Factor
+=
factor_adjustment
;
if
(
Factor
>=
0
.
999
)
Factor
=
0
.
999
;
if
(
bits_per_mb_at_this_q
<=
target_bits_per_mb
)
// Break out if we get down to the target rate
break
;
}
}
return
Q
;
}
...
...
vp9/encoder/vp9_rdopt.c
View file @
b5f3cb6e
...
...
@@ -217,16 +217,6 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi, int QIndex) {
cpi
->
RDMULT
=
compute_rd_mult
(
QIndex
);
// Extend rate multiplier along side quantizer zbin increases
if
(
cpi
->
zbin_over_quant
>
0
)
{
double
oq_factor
;
// Experimental code using the same basic equation as used for Q above
// The units of cpi->zbin_over_quant are 1/128 of Q bin size
oq_factor
=
1
.
0
+
((
double
)
0
.
0015625
*
cpi
->
zbin_over_quant
);
cpi
->
RDMULT
=
(
int
)((
double
)
cpi
->
RDMULT
*
oq_factor
*
oq_factor
);
}
if
(
cpi
->
pass
==
2
&&
(
cpi
->
common
.
frame_type
!=
KEY_FRAME
))
{
if
(
cpi
->
twopass
.
next_iiratio
>
31
)
cpi
->
RDMULT
+=
(
cpi
->
RDMULT
*
rd_iifactor
[
31
])
>>
4
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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