mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 19:42:26 +00:00
ext/mad/gstmad.c: Fix timestamping in mad by only activating a new timestamp when the previous frame has been decoded...
Original commit message from CVS: Patch by: Michal Benes <michal dot benes at itonis dot tv> * ext/mad/gstmad.c: (gst_mad_chain): Fix timestamping in mad by only activating a new timestamp when the previous frame has been decoded. Fixes #350723. Also clean up some of the non fatal warnings when the input buffer is too small to decode a header.
This commit is contained in:
parent
c51d6e5d45
commit
092e714778
2 changed files with 29 additions and 9 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2006-08-16 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
Patch by: Michal Benes <michal dot benes at itonis dot tv>
|
||||||
|
|
||||||
|
* ext/mad/gstmad.c: (gst_mad_chain):
|
||||||
|
Fix timestamping in mad by only activating a new timestamp when the
|
||||||
|
previous frame has been decoded. Fixes #350723.
|
||||||
|
Also clean up some of the non fatal warnings when the input buffer is
|
||||||
|
too small to decode a header.
|
||||||
|
|
||||||
=== release 0.10.4 ===
|
=== release 0.10.4 ===
|
||||||
|
|
||||||
2006-08-14 Thomas Vander Stichele <thomas at apestaart dot org>
|
2006-08-14 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
|
@ -1288,7 +1288,7 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstMad *mad;
|
GstMad *mad;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
glong size;
|
glong size, tempsize;
|
||||||
gboolean new_pts = FALSE;
|
gboolean new_pts = FALSE;
|
||||||
GstClockTime timestamp;
|
GstClockTime timestamp;
|
||||||
GstFlowReturn result = GST_FLOW_OK;
|
GstFlowReturn result = GST_FLOW_OK;
|
||||||
|
@ -1328,6 +1328,8 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
data = GST_BUFFER_DATA (buffer);
|
data = GST_BUFFER_DATA (buffer);
|
||||||
size = GST_BUFFER_SIZE (buffer);
|
size = GST_BUFFER_SIZE (buffer);
|
||||||
|
|
||||||
|
tempsize = mad->tempsize;
|
||||||
|
|
||||||
/* process the incoming buffer in chunks of maximum MAD_BUFFER_MDLEN bytes;
|
/* process the incoming buffer in chunks of maximum MAD_BUFFER_MDLEN bytes;
|
||||||
* this is the upper limit on processable chunk sizes set by mad */
|
* this is the upper limit on processable chunk sizes set by mad */
|
||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
|
@ -1358,7 +1360,7 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
mad_input_buffer = mad->tempbuffer;
|
mad_input_buffer = mad->tempbuffer;
|
||||||
|
|
||||||
/* while we have data we can consume it */
|
/* while we have data we can consume it */
|
||||||
while (mad->tempsize >= 0) {
|
while (mad->tempsize > 0) {
|
||||||
gint consumed = 0;
|
gint consumed = 0;
|
||||||
guint nsamples;
|
guint nsamples;
|
||||||
guint64 time_offset;
|
guint64 time_offset;
|
||||||
|
@ -1374,9 +1376,15 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
* some weird decoding errors... */
|
* some weird decoding errors... */
|
||||||
GST_LOG ("decoding the header now");
|
GST_LOG ("decoding the header now");
|
||||||
if (mad_header_decode (&mad->frame.header, &mad->stream) == -1) {
|
if (mad_header_decode (&mad->frame.header, &mad->stream) == -1) {
|
||||||
|
if (mad->stream.error == MAD_ERROR_BUFLEN) {
|
||||||
|
GST_LOG ("not enough data in tempbuffer (%d), breaking to get more",
|
||||||
|
mad->tempsize);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
GST_WARNING ("mad_header_decode had an error: %s",
|
GST_WARNING ("mad_header_decode had an error: %s",
|
||||||
mad_stream_errorstr (&mad->stream));
|
mad_stream_errorstr (&mad->stream));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GST_LOG ("decoding one frame now");
|
GST_LOG ("decoding one frame now");
|
||||||
|
|
||||||
|
@ -1468,6 +1476,8 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
GstTagList *list;
|
GstTagList *list;
|
||||||
int frame_len = mad->stream.next_frame - mad->stream.this_frame;
|
int frame_len = mad->stream.next_frame - mad->stream.this_frame;
|
||||||
|
|
||||||
|
mad->check_for_xing = FALSE;
|
||||||
|
|
||||||
/* Assume Xing headers can only be the first frame in a mp3 file */
|
/* Assume Xing headers can only be the first frame in a mp3 file */
|
||||||
if (mpg123_parse_xing_header (&mad->frame.header,
|
if (mpg123_parse_xing_header (&mad->frame.header,
|
||||||
mad->stream.this_frame, frame_len, &bitrate, &time)) {
|
mad->stream.this_frame, frame_len, &bitrate, &time)) {
|
||||||
|
@ -1479,11 +1489,10 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
gst_element_post_message (GST_ELEMENT (mad),
|
gst_element_post_message (GST_ELEMENT (mad),
|
||||||
gst_message_new_tag (GST_OBJECT (mad), gst_tag_list_copy (list)));
|
gst_message_new_tag (GST_OBJECT (mad), gst_tag_list_copy (list)));
|
||||||
gst_pad_push_event (mad->srcpad, gst_event_new_tag (list));
|
gst_pad_push_event (mad->srcpad, gst_event_new_tag (list));
|
||||||
}
|
|
||||||
|
|
||||||
mad->check_for_xing = FALSE;
|
|
||||||
goto next_no_samples;
|
goto next_no_samples;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* if we're not resyncing/in error, check if caps need to be set again */
|
/* if we're not resyncing/in error, check if caps need to be set again */
|
||||||
if (!mad->in_error)
|
if (!mad->in_error)
|
||||||
|
@ -1596,12 +1605,13 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
|
|
||||||
/* we have a queued timestamp on the incoming buffer that we should
|
/* we have a queued timestamp on the incoming buffer that we should
|
||||||
* use for the next frame */
|
* use for the next frame */
|
||||||
if (new_pts) {
|
if (new_pts && (mad->stream.next_frame - mad_input_buffer >= tempsize)) {
|
||||||
mad->last_ts = timestamp;
|
|
||||||
new_pts = FALSE;
|
new_pts = FALSE;
|
||||||
|
mad->last_ts = timestamp;
|
||||||
mad->base_byte_offset = GST_BUFFER_OFFSET (buffer);
|
mad->base_byte_offset = GST_BUFFER_OFFSET (buffer);
|
||||||
mad->bytes_consumed = 0;
|
mad->bytes_consumed = 0;
|
||||||
}
|
}
|
||||||
|
tempsize = 0;
|
||||||
|
|
||||||
if (gst_mad_check_restart (mad)) {
|
if (gst_mad_check_restart (mad)) {
|
||||||
goto end;
|
goto end;
|
||||||
|
|
Loading…
Reference in a new issue