opusenc: bound the bitrate to more sensible values
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Tue, 22 Nov 2011 16:14:06 +0000 (16:14 +0000)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Tue, 22 Nov 2011 16:14:06 +0000 (16:14 +0000)
Go from the bounds mentioned in the spec, and allow some more
variation.
In particular, don't allow silly low bitrates, and allow reaching
the maximum useful bitrate.

ext/opus/gstopusenc.c

index 6a7d549..df11c5f 100644 (file)
 GST_DEBUG_CATEGORY_STATIC (opusenc_debug);
 #define GST_CAT_DEFAULT opusenc_debug
 
+/* Some arbitrary bounds beyond which it really doesn't make sense.
+   The spec mentions 6 kb/s to 510 kb/s, so 4000 and 650000 ought to be
+   safe as property bounds. */
+#define LOWEST_BITRATE 4000
+#define HIGHEST_BITRATE 650000
+
 #define GST_OPUS_ENC_TYPE_BANDWIDTH (gst_opus_enc_bandwidth_get_type())
 static GType
 gst_opus_enc_bandwidth_get_type (void)
@@ -234,7 +240,7 @@ gst_opus_enc_class_init (GstOpusEncClass * klass)
   g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BITRATE,
       g_param_spec_int ("bitrate", "Encoding Bit-rate",
           "Specify an encoding bit-rate (in bps).",
-          1, 320000, DEFAULT_BITRATE,
+          LOWEST_BITRATE, HIGHEST_BITRATE, DEFAULT_BITRATE,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
   g_object_class_install_property (gobject_class, PROP_BANDWIDTH,
       g_param_spec_enum ("bandwidth", "Band Width",