vp8enc: add min/maxsection-pct option
authorAlexey Fisher <bug-track@fisher-privat.net>
Sun, 19 Jun 2011 14:06:46 +0000 (16:06 +0200)
committerDavid Schleef <ds@schleef.org>
Wed, 3 Aug 2011 20:39:33 +0000 (13:39 -0700)
This options should be good to redeuce decode CPU load.
for lowend hardware:
minsection-pct=15 maxsection-pct=400

for hiend hw:
minsection-pct=5 maxsection-pct=800

see example:
http://www.webmproject.org/tools/encoder-parameters/#2-pass_vbr_encoding_for_smooth_playback_on_low-end_hardware

Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Signed-off-by: David Schleef <ds@schleef.org>
ext/vp8/gstvp8enc.c
ext/vp8/gstvp8enc.h

index f0fa5d147b808ce01ed95cab2c71f79e1347b084..855ce5b32b51491d1e4ac69abc1456ecb4bcd218 100644 (file)
@@ -85,6 +85,8 @@ gst_vp8_enc_coder_hook_free (GstVP8EncCoderHook * hook)
 
 #define DEFAULT_BITRATE 0
 #define DEFAULT_MODE VPX_VBR
+#define DEFAULT_MINSECTION_PCT 5
+#define DEFAULT_MAXSECTION_PCT 800
 #define DEFAULT_MIN_QUANTIZER 0
 #define DEFAULT_MAX_QUANTIZER 63
 #define DEFAULT_QUALITY 5
@@ -103,6 +105,8 @@ enum
   PROP_0,
   PROP_BITRATE,
   PROP_MODE,
+  PROP_MINSECTION_PCT,
+  PROP_MAXSECTION_PCT,
   PROP_MIN_QUANTIZER,
   PROP_MAX_QUANTIZER,
   PROP_QUALITY,
@@ -264,6 +268,20 @@ gst_vp8_enc_class_init (GstVP8EncClass * klass)
           GST_VP8_ENC_MODE_TYPE, DEFAULT_MODE,
           (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
 
+  g_object_class_install_property (gobject_class, PROP_MINSECTION_PCT,
+      g_param_spec_uint ("minsection-pct",
+          "minimum percentage allocation per section",
+          "The numbers represent a percentage of the average allocation per section (frame)",
+          0, 20, DEFAULT_MINSECTION_PCT,
+          (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+  g_object_class_install_property (gobject_class, PROP_MAXSECTION_PCT,
+      g_param_spec_uint ("maxsection-pct",
+          "maximum percentage allocation per section",
+          "The numbers represent a percentage of the average allocation per section (frame)",
+          200, 800, DEFAULT_MAXSECTION_PCT,
+          (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
   g_object_class_install_property (gobject_class, PROP_MIN_QUANTIZER,
       g_param_spec_int ("min-quantizer", "Minimum quantizer",
           "Minimum (best) quantizer",
@@ -347,6 +365,8 @@ gst_vp8_enc_init (GstVP8Enc * gst_vp8_enc, GstVP8EncClass * klass)
   GST_DEBUG_OBJECT (gst_vp8_enc, "init");
 
   gst_vp8_enc->bitrate = DEFAULT_BITRATE;
+  gst_vp8_enc->minsection_pct = DEFAULT_MINSECTION_PCT;
+  gst_vp8_enc->maxsection_pct = DEFAULT_MAXSECTION_PCT;
   gst_vp8_enc->min_quantizer = DEFAULT_MIN_QUANTIZER;
   gst_vp8_enc->max_quantizer = DEFAULT_MAX_QUANTIZER;
   gst_vp8_enc->mode = DEFAULT_MODE;
@@ -394,6 +414,12 @@ gst_vp8_enc_set_property (GObject * object, guint prop_id,
     case PROP_MODE:
       gst_vp8_enc->mode = g_value_get_enum (value);
       break;
+    case PROP_MINSECTION_PCT:
+      gst_vp8_enc->minsection_pct = g_value_get_uint (value);
+      break;
+    case PROP_MAXSECTION_PCT:
+      gst_vp8_enc->maxsection_pct = g_value_get_uint (value);
+      break;
     case PROP_MIN_QUANTIZER:
       gst_vp8_enc->min_quantizer = g_value_get_int (value);
       break;
@@ -453,6 +479,12 @@ gst_vp8_enc_get_property (GObject * object, guint prop_id, GValue * value,
     case PROP_MODE:
       g_value_set_enum (value, gst_vp8_enc->mode);
       break;
+    case PROP_MINSECTION_PCT:
+      g_value_set_uint (value, gst_vp8_enc->minsection_pct);
+      break;
+    case PROP_MAXSECTION_PCT:
+      g_value_set_uint (value, gst_vp8_enc->maxsection_pct);
+      break;
     case PROP_MIN_QUANTIZER:
       g_value_set_int (value, gst_vp8_enc->min_quantizer);
       break;
@@ -568,6 +600,8 @@ gst_vp8_enc_set_format (GstBaseVideoEncoder * base_video_encoder,
   cfg.g_lag_in_frames = encoder->max_latency;
   cfg.g_threads = encoder->threads;
   cfg.rc_end_usage = encoder->mode;
+  cfg.rc_2pass_vbr_minsection_pct = encoder->minsection_pct;
+  cfg.rc_2pass_vbr_maxsection_pct = encoder->maxsection_pct;
   /* Standalone qp-min do not make any sence, with bitrate=0 and qp-min=1
    * encoder will use only default qp-max=63. Also this will make
    * worst possbile quality.
index 6b1dee11c71b290592da709800f28f541a6df091..cbfddc29b97a7bfeb3e6718b5815bcd3411f85a5 100644 (file)
@@ -60,6 +60,8 @@ struct _GstVP8Enc
   /* properties */
   int bitrate;
   enum vpx_rc_mode mode;
+  unsigned int minsection_pct;
+  unsigned int maxsection_pct;
   int min_quantizer;
   int max_quantizer;
   double quality;