]> granicus.if.org Git - libvpx/commitdiff
Enable more split modes for animated content.
authorPaul Wilkins <paulwilkins@google.com>
Fri, 29 May 2015 23:56:19 +0000 (00:56 +0100)
committerpaulwilkins <paulwilkins@google.com>
Tue, 9 Jun 2015 13:50:44 +0000 (14:50 +0100)
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

vp9/encoder/vp9_encoder.c
vp9/encoder/vp9_firstpass.c
vp9/encoder/vp9_firstpass.h
vp9/encoder/vp9_speed_features.c

index b79bc00d23720b0a33fd2b6f156a102344c7a220..ba38d640d03cee661f6f46ead9c1a77f79f873b7 100644 (file)
@@ -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);
 
index 802fb849aec66ca198c9254143cc2cd23268ff00..f80185183bae1fb3554ca89fa521be3f0d33bdb5 100644 (file)
@@ -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;
index ac2ce13a0827cdad597e0024c2eb91e8abe0d72a..45f11329b1c18f32122764c2b4759274aca780a7 100644 (file)
@@ -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;
index 39a4c818f2355c0f83d435962cd44d92487a22c0..6c6c4ed302299414046f7d7c085e7eb0b037185a 100644 (file)
@@ -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) {