ref: 4a28da58434d364337d9a6724e9ae79e0e264bd7
parent: b19b16cfa1fe0275c82dadc78c4dcbb8a1f8da36
author: Paul Wilkins <[email protected]>
date: Fri May 29 20:56:19 EDT 2015
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
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -2872,7 +2872,7 @@
"%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 @@
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);
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -2603,6 +2603,12 @@
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;
--- a/vp9/encoder/vp9_firstpass.h
+++ b/vp9/encoder/vp9_firstpass.h
@@ -75,6 +75,13 @@
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 @@
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;
--- a/vp9/encoder/vp9_speed_features.c
+++ b/vp9/encoder/vp9_speed_features.c
@@ -41,9 +41,11 @@
}
}
-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 @@
}
}
+ // 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 @@
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 @@
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) {