From: Tim-Philipp Müller Date: Fri, 13 Oct 2006 14:45:11 +0000 (+0000) Subject: ext/lame/gstlame.c: Round up not allowed bitrates to the next higher allowed one... X-Git-Tag: 1.16.2~901^2~85 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fef9929a0649e682b250b78fde566d7617670cae;p=platform%2Fupstream%2Fgst-plugins-good.git 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). --- diff --git a/ext/lame/gstlame.c b/ext/lame/gstlame.c index c714e63..ea12fc0 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);