summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuild/make/configure.sh11
-rwxr-xr-xconfigure3
-rw-r--r--vp8/encoder/firstpass.c86
-rw-r--r--vp8/encoder/onyx_if.c4
4 files changed, 73 insertions, 31 deletions
diff --git a/build/make/configure.sh b/build/make/configure.sh
index b65f3b73a..75279b9b9 100755
--- a/build/make/configure.sh
+++ b/build/make/configure.sh
@@ -78,6 +78,7 @@ Build options:
--log=yes|no|FILE file configure log is written to [config.err]
--target=TARGET target platform tuple [generic-gnu]
--cpu=CPU optimize for a specific cpu rather than a family
+ --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]
${toggle_extra_warnings} emit harmless warnings (always non-fatal)
${toggle_werror} treat warnings as errors, if possible
(not available with all compilers)
@@ -442,6 +443,9 @@ process_common_cmdline() {
;;
--cpu=*) tune_cpu="$optval"
;;
+ --extra-cflags=*)
+ extra_cflags="${optval}"
+ ;;
--enable-?*|--disable-?*)
eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
echo "${CMDLINE_SELECT} ${ARCH_EXT_LIST}" | grep "^ *$option\$" >/dev/null || die_unknown $opt
@@ -665,7 +669,7 @@ process_common_toolchain() {
check_add_cflags -march=${tgt_isa}
check_add_asflags -march=${tgt_isa}
fi
-
+ enabled debug && add_asflags -g
asm_conversion_cmd="${source_path}/build/make/ads2gas.pl"
;;
rvct)
@@ -690,6 +694,7 @@ process_common_toolchain() {
arch_int=${tgt_isa##armv}
arch_int=${arch_int%%te}
check_add_asflags --pd "\"ARCHITECTURE SETA ${arch_int}\""
+ enabled debug && add_asflags -g
;;
esac
@@ -972,6 +977,10 @@ EOF
add_cflags -D_LARGEFILE_SOURCE
add_cflags -D_FILE_OFFSET_BITS=64
fi
+
+ # append any user defined extra cflags
+ check_add_cflags ${extra_cflags} || \
+ die "Requested extra CFLAGS '${extra_cflags}' not supported by compiler"
}
process_toolchain() {
diff --git a/configure b/configure
index 225ffa49c..4aef55166 100755
--- a/configure
+++ b/configure
@@ -319,10 +319,9 @@ process_cmdline() {
log_echo "Ignoring $opt -- not in experimental mode."
fi
else
- process_common_cmdline $opt
+ process_common_cmdline "$opt"
fi
;;
- *) process_common_cmdline $opt
;;
esac
done
diff --git a/vp8/encoder/firstpass.c b/vp8/encoder/firstpass.c
index 1554f3d30..348419c0b 100644
--- a/vp8/encoder/firstpass.c
+++ b/vp8/encoder/firstpass.c
@@ -1337,17 +1337,20 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
double decay_accumulator = 1.0;
double boost_factor = IIFACTOR;
- double loop_decay_rate = 1.00; // Starting decay rate
+ double loop_decay_rate = 1.00; // Starting decay rate
double this_frame_mv_in_out = 0.0;
double mv_in_out_accumulator = 0.0;
double abs_mv_in_out_accumulator = 0.0;
double mod_err_per_mb_accumulator = 0.0;
- int max_bits = frame_max_bits(cpi); // Max for a single frame
+ int max_bits = frame_max_bits(cpi); // Max for a single frame
unsigned char *fpmm_pos;
+ unsigned int allow_alt_ref =
+ cpi->oxcf.play_alternate && cpi->oxcf.lag_in_frames;
+
cpi->gf_group_bits = 0;
cpi->gf_decay_rate = 0;
@@ -1362,47 +1365,57 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
// Preload the stats for the next frame.
mod_frame_err = calculate_modified_err(cpi, this_frame);
- // Note the error of the frame at the start of the group (this will be the GF frame error if we code a normal gf
+ // Note the error of the frame at the start of the group (this will be
+ // the GF frame error if we code a normal gf
gf_first_frame_err = mod_frame_err;
- // Special treatment if the current frame is a key frame (which is also a gf).
- // If it is then its error score (and hence bit allocation) need to be subtracted out
- // from the calculation for the GF group
+ // Special treatment if the current frame is a key frame (which is also
+ // a gf). If it is then its error score (and hence bit allocation) need
+ // to be subtracted out from the calculation for the GF group
if (cpi->common.frame_type == KEY_FRAME)
gf_group_err -= gf_first_frame_err;
- // Scan forward to try and work out how many frames the next gf group should contain and
- // what level of boost is appropriate for the GF or ARF that will be coded with the group
+ // Scan forward to try and work out how many frames the next gf group
+ // should contain and what level of boost is appropriate for the GF
+ // or ARF that will be coded with the group
i = 0;
- while (((i < cpi->static_scene_max_gf_interval) || ((cpi->frames_to_key - i) < MIN_GF_INTERVAL)) && (i < cpi->frames_to_key))
+ while (((i < cpi->static_scene_max_gf_interval) ||
+ ((cpi->frames_to_key - i) < MIN_GF_INTERVAL)) &&
+ (i < cpi->frames_to_key))
{
double r;
double this_frame_mvr_ratio;
double this_frame_mvc_ratio;
double motion_decay;
- double motion_pct = next_frame.pcnt_motion;
+ //double motion_pct = next_frame.pcnt_motion;
+ double motion_pct;
- i++; // Increment the loop counter
+ i++; // Increment the loop counter
// Accumulate error score of frames in this gf group
mod_frame_err = calculate_modified_err(cpi, this_frame);
gf_group_err += mod_frame_err;
- mod_err_per_mb_accumulator += mod_frame_err / DOUBLE_DIVIDE_CHECK((double)cpi->common.MBs);
+ mod_err_per_mb_accumulator +=
+ mod_frame_err / DOUBLE_DIVIDE_CHECK((double)cpi->common.MBs);
if (EOF == vp8_input_stats(cpi, &next_frame))
break;
// Accumulate motion stats.
+ motion_pct = next_frame.pcnt_motion;
mv_accumulator_rabs += fabs(next_frame.mvr_abs * motion_pct);
mv_accumulator_cabs += fabs(next_frame.mvc_abs * motion_pct);
//Accumulate Motion In/Out of frame stats
- this_frame_mv_in_out = next_frame.mv_in_out_count * next_frame.pcnt_motion;
- mv_in_out_accumulator += next_frame.mv_in_out_count * next_frame.pcnt_motion;
- abs_mv_in_out_accumulator += fabs(next_frame.mv_in_out_count * next_frame.pcnt_motion);
+ this_frame_mv_in_out =
+ next_frame.mv_in_out_count * motion_pct;
+ mv_in_out_accumulator +=
+ next_frame.mv_in_out_count * motion_pct;
+ abs_mv_in_out_accumulator +=
+ fabs(next_frame.mv_in_out_count * motion_pct);
// If there is a significant amount of motion
if (motion_pct > 0.05)
@@ -1431,7 +1444,9 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
}
// Underlying boost factor is based on inter intra error ratio
- r = (boost_factor * (next_frame.intra_error / DOUBLE_DIVIDE_CHECK(next_frame.coded_error)));
+ r = ( boost_factor *
+ ( next_frame.intra_error /
+ DOUBLE_DIVIDE_CHECK(next_frame.coded_error)));
if (next_frame.intra_error > cpi->gf_intra_err_min)
r = (IIKFACTOR2 * next_frame.intra_error /
@@ -1440,13 +1455,15 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
r = (IIKFACTOR2 * cpi->gf_intra_err_min /
DOUBLE_DIVIDE_CHECK(next_frame.coded_error));
- // Increase boost for frames where new data coming into frame (eg zoom out)
- // Slightly reduce boost if there is a net balance of motion out of the frame (zoom in)
+ // Increase boost for frames where new data coming into frame
+ // (eg zoom out). Slightly reduce boost if there is a net balance
+ // of motion out of the frame (zoom in).
// The range for this_frame_mv_in_out is -1.0 to +1.0
if (this_frame_mv_in_out > 0.0)
r += r * (this_frame_mv_in_out * 2.0);
+ // In extreme case boost is halved
else
- r += r * (this_frame_mv_in_out / 2.0); // In extreme case boost is halved
+ r += r * (this_frame_mv_in_out / 2.0);
if (r > GF_RMAX)
r = GF_RMAX;
@@ -1484,10 +1501,24 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
boost_score += (decay_accumulator * r);
+ // Break clause to detect very still sections after motion
+ // For example a staic image after a fade or other transition
+ // instead of a clean key frame.
+ if ( (i > MIN_GF_INTERVAL) &&
+ (loop_decay_rate >= 0.999) &&
+ (decay_accumulator < 0.9) )
+ {
+ // Force GF not alt ref
+ allow_alt_ref = FALSE;
+
+ boost_score = old_boost_score;
+ break;
+ }
+
// Break out conditions.
if ( /* i>4 || */
// Break at cpi->max_gf_interval unless almost totally static
- (i >= cpi->max_gf_interval && (decay_accumulator < 0.99)) ||
+ (i >= cpi->max_gf_interval && (decay_accumulator < 0.995)) ||
(
// Dont break out with a very short interval
(i > MIN_GF_INTERVAL) &&
@@ -1509,7 +1540,8 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
old_boost_score = boost_score;
}
- cpi->gf_decay_rate = (i > 0) ? (int)(100.0 * (1.0 - decay_accumulator)) / i : 0;
+ cpi->gf_decay_rate =
+ (i > 0) ? (int)(100.0 * (1.0 - decay_accumulator)) / i : 0;
// When using CBR apply additional buffer related upper limits
if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER)
@@ -1519,7 +1551,8 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
// For cbr apply buffer related limits
if (cpi->drop_frames_allowed)
{
- int df_buffer_level = cpi->oxcf.drop_frames_water_mark * (cpi->oxcf.optimal_buffer_level / 100);
+ int df_buffer_level = cpi->oxcf.drop_frames_water_mark *
+ (cpi->oxcf.optimal_buffer_level / 100);
if (cpi->buffer_level > df_buffer_level)
max_boost = ((double)((cpi->buffer_level - df_buffer_level) * 2 / 3) * 16.0) / DOUBLE_DIVIDE_CHECK((double)cpi->av_per_frame_bandwidth);
@@ -1542,10 +1575,10 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
cpi->gfu_boost = (int)(boost_score * 100.0) >> 4;
// Should we use the alternate refernce frame
- if (cpi->oxcf.play_alternate &&
- cpi->oxcf.lag_in_frames &&
+ if (allow_alt_ref &&
(i >= MIN_GF_INTERVAL) &&
- (i <= (cpi->frames_to_key - MIN_GF_INTERVAL)) && // dont use ARF very near next kf
+ // dont use ARF very near next kf
+ (i <= (cpi->frames_to_key - MIN_GF_INTERVAL)) &&
(((next_frame.pcnt_inter > 0.75) &&
((mv_in_out_accumulator / (double)i > -0.2) || (mv_in_out_accumulator > -2.0)) &&
//(cpi->gfu_boost>150) &&
@@ -2451,7 +2484,7 @@ void vp8_find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
{
double r;
double motion_decay;
- double motion_pct = next_frame.pcnt_motion;
+ double motion_pct;
if (EOF == vp8_input_stats(cpi, &next_frame))
break;
@@ -2471,6 +2504,7 @@ void vp8_find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
loop_decay_rate = next_frame.pcnt_inter;
// High % motion -> somewhat higher decay rate
+ motion_pct = next_frame.pcnt_motion;
motion_decay = (1.0 - (motion_pct / 20.0));
if (motion_decay < loop_decay_rate)
loop_decay_rate = motion_decay;
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c
index 420a9e14a..74e173ab6 100644
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -3928,7 +3928,7 @@ static void encode_frame_to_data_rate
// One pass more conservative
else
cpi->active_best_quality = kf_high_motion_minq[Q];
- }
+ }
else if (cm->refresh_golden_frame || cpi->common.refresh_alt_ref_frame)
{
@@ -4273,7 +4273,7 @@ static void encode_frame_to_data_rate
IF_RTCD(&cpi->rtcd.variance));
// The key frame is not good enough
- if ( kf_err > ((cpi->ambient_err * 3) >> 2) )
+ if ( kf_err > ((cpi->ambient_err * 7) >> 3) )
{
// Lower q_high
q_high = (Q > q_low) ? (Q - 1) : q_low;