From 6385946841bc1cdfdcccd0c5968055c58340a0bb Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Mon, 19 May 2008 15:07:07 +0000 Subject: [PATCH] ext/mad/gstmad.c: Fix inconsistent use of rate and channels. Original commit message from CVS: * ext/mad/gstmad.c: (gst_mad_convert_src), (gst_mad_chain): Fix inconsistent use of rate and channels. Fixes #533581 --- ChangeLog | 6 ++++++ ext/mad/gstmad.c | 15 +++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1d3ab222ed..698cd78225 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-05-19 Edward Hervey + + * ext/mad/gstmad.c: (gst_mad_convert_src), (gst_mad_chain): + Fix inconsistent use of rate and channels. + Fixes #533581 + 2008-05-19 Wim Taymans * gst/realmedia/rmdemux.c: (gst_rmdemux_send_event): diff --git a/ext/mad/gstmad.c b/ext/mad/gstmad.c index 32126c0bba..d5379047c5 100644 --- a/ext/mad/gstmad.c +++ b/ext/mad/gstmad.c @@ -384,7 +384,7 @@ gst_mad_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value, mad = GST_MAD (GST_PAD_PARENT (pad)); - bytes_per_sample = MAD_NCHANNELS (&mad->frame.header) * 4; + bytes_per_sample = mad->channels * 4; switch (src_format) { case GST_FORMAT_BYTES: @@ -396,7 +396,7 @@ gst_mad_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value, break; case GST_FORMAT_TIME: { - gint byterate = bytes_per_sample * mad->frame.header.samplerate; + gint byterate = bytes_per_sample * mad->rate; if (byterate == 0) return FALSE; @@ -414,10 +414,10 @@ gst_mad_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value, *dest_value = src_value * bytes_per_sample; break; case GST_FORMAT_TIME: - if (mad->frame.header.samplerate == 0) + if (mad->rate == 0) return FALSE; *dest_value = gst_util_uint64_scale_int (src_value, GST_SECOND, - mad->frame.header.samplerate); + mad->rate); break; default: res = FALSE; @@ -430,7 +430,7 @@ gst_mad_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value, /* fallthrough */ case GST_FORMAT_DEFAULT: *dest_value = gst_util_uint64_scale_int (src_value, - scale * mad->frame.header.samplerate, GST_SECOND); + scale * mad->rate, GST_SECOND); break; default: res = FALSE; @@ -1482,9 +1482,8 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer) nsamples = MAD_NSBSAMPLES (&mad->frame.header) * (mad->stream.options & MAD_OPTION_HALFSAMPLERATE ? 16 : 32); - if (mad->frame.header.samplerate == 0) { - g_warning - ("mad->frame.header.samplerate is 0; timestamps cannot be calculated"); + if (mad->rate == 0) { + g_warning ("mad->rate is 0; timestamps cannot be calculated"); } else { /* if we have a pending timestamp, we can use it now to calculate the sample offset */ if (GST_CLOCK_TIME_IS_VALID (mad->last_ts)) {