summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2013-05-09 19:40:49 -0400
committerOlivier CrĂȘte <olivier.crete@collabora.com>2013-05-09 19:52:39 -0400
commit3c732fe657f2768014e3ef9bfd352e5da95e26e4 (patch)
tree14e5c3f4039cc32165713c124a122bf8c0fc8cad
parent603dd1c612db58c9ccb763077e4e0b2e92804803 (diff)
lamemp3enc: Tell GstAudioEncoder about the number of incoming samples
lame does internal resampling, but the base class only cares about the number of raw samples, so tell finish frames about that, not the number of samples in the outgoing frame.:
-rw-r--r--ext/lame/gstlamemp3enc.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/ext/lame/gstlamemp3enc.c b/ext/lame/gstlamemp3enc.c
index 4955495a..69512a48 100644
--- a/ext/lame/gstlamemp3enc.c
+++ b/ext/lame/gstlamemp3enc.c
@@ -653,6 +653,7 @@ gst_lamemp3enc_finish_frames (GstLameMP3Enc * lame)
guint rate, version, layer, size;
GstBuffer *mp3_buf;
const guint8 *data;
+ guint samples_per_frame;
data = gst_adapter_map (lame->adapter, 4);
header = GST_READ_UINT32_BE (data);
@@ -677,11 +678,18 @@ gst_lamemp3enc_finish_frames (GstLameMP3Enc * lame)
break;
}
+ /* Account for the internal resampling, finish frame really wants to
+ * know about the number of incoming samples
+ */
+ samples_per_frame = (version == 1) ? 1152 : 576;
+ samples_per_frame *= lame->samplerate;
+ samples_per_frame /= lame->out_samplerate;
+
/* should be ok now */
mp3_buf = gst_adapter_take_buffer (lame->adapter, size);
/* number of samples for MPEG-1, layer 3 */
result = gst_audio_encoder_finish_frame (GST_AUDIO_ENCODER (lame),
- mp3_buf, version == 1 ? 1152 : 576);
+ mp3_buf, samples_per_frame);
}
exit: