From fef9929a0649e682b250b78fde566d7617670cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 13 Oct 2006 14:45:11 +0000 Subject: [PATCH] ext/lame/gstlame.c: Round up not allowed bitrates to the next higher allowed one (Closes: #361140). Original commit message from CVS: * ext/lame/gstlame.c: (gst_lame_set_property): Round up not allowed bitrates to the next higher allowed one (Closes: #361140). --- ext/lame/gstlame.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ext/lame/gstlame.c b/ext/lame/gstlame.c index c714e63fe6..ea12fc050e 100644 --- a/ext/lame/gstlame.c +++ b/ext/lame/gstlame.c @@ -625,6 +625,25 @@ gst_lame_init (GstLame * lame) GST_DEBUG_OBJECT (lame, "done initializing"); } +#define CHECK_AND_FIXUP_BITRATE(obj,pspec,rate) \ +G_STMT_START { \ + gint ___rate = rate; \ + if (rate <= 64 && (rate % 8) != 0) { \ + ___rate = GST_ROUND_UP_8 (rate); \ + } else if (rate <= 128 && (rate % 16) != 0) { \ + ___rate = GST_ROUND_UP_16 (rate); \ + } else if (rate <= 256 && (rate % 32) != 0) { \ + ___rate = GST_ROUND_UP_32 (rate); \ + } else if (rate <= 320 && (rate % 64) != 0) { \ + ___rate = GST_ROUND_UP_64 (rate); \ + } \ + if (___rate != rate) { \ + GST_WARNING_OBJECT (obj, "Bitrate %d not allowed for property '%s', " \ + "changing to %d", rate, g_param_spec_get_name (pspec), ___rate); \ + rate = ___rate; \ + } \ +} G_STMT_END + static void gst_lame_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) @@ -636,6 +655,7 @@ gst_lame_set_property (GObject * object, guint prop_id, const GValue * value, switch (prop_id) { case ARG_BITRATE: lame->bitrate = g_value_get_int (value); + CHECK_AND_FIXUP_BITRATE (object, pspec, lame->bitrate); break; case ARG_COMPRESSION_RATIO: lame->compression_ratio = g_value_get_float (value); @@ -684,12 +704,15 @@ gst_lame_set_property (GObject * object, guint prop_id, const GValue * value, break; case ARG_VBR_MIN_BITRATE: lame->vbr_min_bitrate = g_value_get_int (value); + CHECK_AND_FIXUP_BITRATE (object, pspec, lame->vbr_min_bitrate); break; case ARG_VBR_MAX_BITRATE: lame->vbr_max_bitrate = g_value_get_int (value); + CHECK_AND_FIXUP_BITRATE (object, pspec, lame->vbr_max_bitrate); break; case ARG_VBR_HARD_MIN: lame->vbr_hard_min = g_value_get_int (value); + CHECK_AND_FIXUP_BITRATE (object, pspec, lame->vbr_hard_min); break; case ARG_LOWPASS_FREQ: lame->lowpass_freq = g_value_get_int (value);