Commit 4a28da58 authored by Paul Wilkins's avatar Paul Wilkins Committed by paulwilkins

Enable more split modes for animated content.

For content that is identified as likely to contain some
animation or graphics content, increase the availability
of split modes for good quality speeds 1-3.

On a problem test animation clip this improves metrics
results by about 0.25 db and makes a noticeable difference
visually. It also causes a small drop in file size (~0.5%) but
a rise in encode time of about 5-6% at speed  2.

For more normal content it should have no effect.

Change-Id: Ic4cd9a8de065af9f9402f4477a17442aebf0e439
parent b19b16cf
......@@ -2872,7 +2872,7 @@ static void output_frame_level_debug_stats(VP9_COMP *cpi) {
"%7.2lf %7.2lf %7.2lf %7.2lf %7.2lf"
"%6d %6d %5d %5d %5d "
"%10"PRId64" %10.3lf"
"%10lf %8u %10"PRId64" %10d %10d\n",
"%10lf %8u %10"PRId64" %10d %10d %10d\n",
cpi->common.current_video_frame,
cm->width, cm->height,
cpi->rc.source_alt_ref_pending,
......@@ -2901,7 +2901,8 @@ static void output_frame_level_debug_stats(VP9_COMP *cpi) {
cpi->twopass.bits_left /
(1 + cpi->twopass.total_left_stats.coded_error),
cpi->tot_recode_hits, recon_err, cpi->rc.kf_boost,
cpi->twopass.kf_zeromotion_pct);
cpi->twopass.kf_zeromotion_pct,
cpi->twopass.fr_content_type);
fclose(f);
......
......@@ -2603,6 +2603,12 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) {
if (EOF == input_stats(twopass, &this_frame))
return;
// Set the frame content type flag.
if (this_frame.ul_intra_pct >= FC_ANIMATION_THRESH)
twopass->fr_content_type = FC_GRAPHICS_ANIMATION;
else
twopass->fr_content_type = FC_NORMAL;
// Keyframe and section processing.
if (rc->frames_to_key == 0 || (cpi->frame_flags & FRAMEFLAGS_KEY)) {
FIRSTPASS_STATS this_frame_copy;
......
......@@ -75,6 +75,13 @@ typedef enum {
FRAME_UPDATE_TYPES = 5
} FRAME_UPDATE_TYPE;
#define FC_ANIMATION_THRESH 0.15
typedef enum {
FC_NORMAL = 0,
FC_GRAPHICS_ANIMATION = 1,
FRAME_CONTENT_TYPES = 2
} FRAME_CONTENT_TYPE;
typedef struct {
unsigned char index;
RATE_FACTOR_LEVEL rf_level[(MAX_LAG_BUFFERS * 2) + 1];
......@@ -105,6 +112,8 @@ typedef struct {
uint8_t *this_frame_mb_stats;
FIRSTPASS_MB_STATS firstpass_mb_stats;
#endif
// An indication of the content type of the current frame
FRAME_CONTENT_TYPE fr_content_type;
// Projected total bits available for a key frame group of frames
int64_t kf_group_bits;
......
......@@ -41,9 +41,11 @@ static BLOCK_SIZE set_partition_min_limit(VP9_COMMON *const cm) {
}
}
static void set_good_speed_feature_framesize_dependent(VP9_COMMON *cm,
static void set_good_speed_feature_framesize_dependent(VP9_COMP *cpi,
SPEED_FEATURES *sf,
int speed) {
VP9_COMMON *const cm = &cpi->common;
if (speed >= 1) {
if (MIN(cm->width, cm->height) >= 720) {
sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT
......@@ -85,6 +87,13 @@ static void set_good_speed_feature_framesize_dependent(VP9_COMMON *cm,
}
}
// If this is a two pass clip that fits the criteria for animated or
// graphics content then reset disable_split_mask for speeds 1-4.
if ((speed >= 1) && (cpi->oxcf.pass == 2) &&
(cpi->twopass.fr_content_type == FC_GRAPHICS_ANIMATION)) {
sf->disable_split_mask = DISABLE_COMPOUND_SPLIT;
}
if (speed >= 4) {
if (MIN(cm->width, cm->height) >= 720) {
sf->partition_search_breakout_dist_thr = (1 << 26);
......@@ -382,7 +391,6 @@ static void set_rt_speed_feature(VP9_COMP *cpi, SPEED_FEATURES *sf,
void vp9_set_speed_features_framesize_dependent(VP9_COMP *cpi) {
SPEED_FEATURES *const sf = &cpi->sf;
VP9_COMMON *const cm = &cpi->common;
const VP9EncoderConfig *const oxcf = &cpi->oxcf;
RD_OPT *const rd = &cpi->rd;
int i;
......@@ -390,7 +398,7 @@ void vp9_set_speed_features_framesize_dependent(VP9_COMP *cpi) {
if (oxcf->mode == REALTIME) {
set_rt_speed_feature_framesize_dependent(cpi, sf, oxcf->speed);
} else if (oxcf->mode == GOOD) {
set_good_speed_feature_framesize_dependent(cm, sf, oxcf->speed);
set_good_speed_feature_framesize_dependent(cpi, sf, oxcf->speed);
}
if (sf->disable_split_mask == DISABLE_ALL_SPLIT) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment