From: Michael Smith Date: Mon, 13 Nov 2006 17:01:15 +0000 (+0000) Subject: gst/mpegaudioparse/gstmpegaudioparse.*: Make timestamp handling in mp3parse saner... X-Git-Tag: 1.19.3~505^2~1847 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3b792adbec999f46d92432e7de3dce6c861edd68;p=platform%2Fupstream%2Fgstreamer.git gst/mpegaudioparse/gstmpegaudioparse.*: Make timestamp handling in mp3parse saner; now works for at least simple cases. Original commit message from CVS: * gst/mpegaudioparse/gstmpegaudioparse.c: (mp3_type_frame_length_from_header), (gst_mp3parse_reset), (gst_mp3parse_init), (gst_mp3parse_dispose), (gst_mp3parse_sink_event), (gst_mp3parse_chain), (head_check), (gst_mp3parse_change_state): * gst/mpegaudioparse/gstmpegaudioparse.h: Make timestamp handling in mp3parse saner; now works for at least simple cases. --- diff --git a/ChangeLog b/ChangeLog index b776ef9..41df37f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2006-11-13 Michael Smith + * gst/mpegaudioparse/gstmpegaudioparse.c: + (mp3_type_frame_length_from_header), (gst_mp3parse_reset), + (gst_mp3parse_init), (gst_mp3parse_dispose), + (gst_mp3parse_sink_event), (gst_mp3parse_chain), (head_check), + (gst_mp3parse_change_state): + * gst/mpegaudioparse/gstmpegaudioparse.h: + Make timestamp handling in mp3parse saner; now works for at least + simple cases. + +2006-11-13 Michael Smith + * gst/mpegaudioparse/Makefile.am: * gst/mpegaudioparse/gstmpegaudioparse.c: (mp3_type_frame_length_from_header), (gst_mp3parse_class_init), diff --git a/gst/mpegaudioparse/gstmpegaudioparse.c b/gst/mpegaudioparse/gstmpegaudioparse.c index 5616bf1..c75662c 100644 --- a/gst/mpegaudioparse/gstmpegaudioparse.c +++ b/gst/mpegaudioparse/gstmpegaudioparse.c @@ -109,13 +109,17 @@ gst_mp3parse_get_type (void) return mp3parse_type; } -static guint mp3types_bitrates[2][3][16] = - { {{0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448,}, - {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384,}, - {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320,}}, -{{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256,}, - {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,}, - {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,}}, +static guint mp3types_bitrates[2][3][16] = { + { + {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448,}, + {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384,}, + {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320,} + }, + { + {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256,}, + {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,}, + {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,} + }, }; static guint mp3types_freqs[3][3] = { {44100, 48000, 32000}, @@ -240,6 +244,8 @@ gst_mp3parse_reset (GstMPEGAudioParse * mp3parse) { mp3parse->skip = 0; mp3parse->resyncing = TRUE; + mp3parse->next_ts = -1; + mp3parse->last_ts = -1; gst_adapter_clear (mp3parse->adapter); @@ -296,11 +302,8 @@ gst_mp3parse_sink_event (GstPad * pad, GstEvent * event) gst_event_parse_new_segment (event, NULL, NULL, &format, NULL, NULL, NULL); - if (format != GST_FORMAT_TIME) - mp3parse->next_ts = 0; - else - /* we will be receiving timestamps */ - mp3parse->next_ts = -1; + mp3parse->next_ts = -1; + mp3parse->last_ts = -1; break; } default: @@ -331,11 +334,10 @@ gst_mp3parse_chain (GstPad * pad, GstBuffer * buf) timestamp = GST_BUFFER_TIMESTAMP (buf); - if (GST_CLOCK_TIME_IS_VALID (timestamp)) { - GST_DEBUG_OBJECT (mp3parse, "Using incoming timestamp of %" GST_TIME_FORMAT, - GST_TIME_ARGS (timestamp)); + /* If we don't yet have a next timestamp, and this is valid, use it */ + if (!GST_CLOCK_TIME_IS_VALID (mp3parse->next_ts) && + GST_CLOCK_TIME_IS_VALID (timestamp)) mp3parse->next_ts = timestamp; - } gst_adapter_push (mp3parse->adapter, buf); @@ -441,8 +443,6 @@ gst_mp3parse_chain (GstPad * pad, GstBuffer * buf) GST_DEBUG_OBJECT (mp3parse, "pushing buffer of %d bytes", GST_BUFFER_SIZE (outbuf)); - GST_BUFFER_TIMESTAMP (outbuf) = mp3parse->next_ts; - /* see http://www.codeproject.com/audio/MPEGAudioInfo.asp */ if (mp3parse->layer == 1) spf = 384; @@ -456,7 +456,17 @@ gst_mp3parse_chain (GstPad * pad, GstBuffer * buf) } GST_BUFFER_DURATION (outbuf) = spf * GST_SECOND / mp3parse->rate; - mp3parse->next_ts += GST_BUFFER_DURATION (outbuf); + if (GST_CLOCK_TIME_IS_VALID (mp3parse->next_ts)) { + GST_BUFFER_TIMESTAMP (outbuf) = mp3parse->next_ts; + mp3parse->next_ts = GST_CLOCK_TIME_NONE; + } else if (GST_CLOCK_TIME_IS_VALID (mp3parse->last_ts)) { + GST_BUFFER_TIMESTAMP (outbuf) = mp3parse->last_ts + + GST_BUFFER_DURATION (outbuf); + } else { + GST_BUFFER_TIMESTAMP (outbuf) = 0; + } + + mp3parse->last_ts = GST_BUFFER_TIMESTAMP (outbuf); gst_buffer_set_caps (outbuf, GST_PAD_CAPS (mp3parse->srcpad)); diff --git a/gst/mpegaudioparse/gstmpegaudioparse.h b/gst/mpegaudioparse/gstmpegaudioparse.h index fae6e63..6c13e8a 100644 --- a/gst/mpegaudioparse/gstmpegaudioparse.h +++ b/gst/mpegaudioparse/gstmpegaudioparse.h @@ -46,6 +46,7 @@ struct _GstMPEGAudioParse { GstPad *sinkpad,*srcpad; + GstClockTime last_ts; GstClockTime next_ts; GstAdapter *adapter;