mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
ext/vorbis/vorbisdec.c (vorbis_dec_push_forward, vorbis_handle_data_packet):
Original commit message from CVS: * ext/vorbis/vorbisdec.c (vorbis_dec_push_forward, vorbis_handle_data_packet): Correctly set DURATION to generate a timestamp-continuous stream. One bug left at the end; see ihttp://bugzilla.gnome.org/show_bug.cgi?id=423086 * tests/check/Makefile.am: * tests/check/pipelines/vorbisenc.c (GST_START_TEST): Add a test to check this. Without the above patch this test fails.
This commit is contained in:
parent
77683331e1
commit
ecab77b7e4
4 changed files with 41 additions and 5 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2007-03-26 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* ext/vorbis/vorbisdec.c (vorbis_dec_push_forward,
|
||||
vorbis_handle_data_packet):
|
||||
Correctly set DURATION to generate a timestamp-continuous stream.
|
||||
One bug left at the end; see
|
||||
ihttp://bugzilla.gnome.org/show_bug.cgi?id=423086
|
||||
* tests/check/Makefile.am:
|
||||
* tests/check/pipelines/vorbisenc.c (GST_START_TEST):
|
||||
Add a test to check this. Without the above patch this test fails.
|
||||
|
||||
2007-03-26 Jan Schmidt <thaytan@mad.scientist.com>
|
||||
|
||||
* gst-libs/gst/rtp/Makefile.am:
|
||||
|
|
|
@ -867,11 +867,15 @@ vorbis_dec_push_forward (GstVorbisDec * dec, GstBuffer * buf)
|
|||
} else {
|
||||
if (G_UNLIKELY (dec->queued)) {
|
||||
gint64 size;
|
||||
GstClockTime ts;
|
||||
GList *walk;
|
||||
|
||||
GST_DEBUG_OBJECT (dec, "first buffer with offset %lld", outoffset);
|
||||
ts = gst_util_uint64_scale_int (outoffset, GST_SECOND, dec->vi.rate);
|
||||
|
||||
size = g_list_length (dec->queued);
|
||||
/* we walk the queued up list in reverse, and set the buffer fields
|
||||
* calculating backwards */
|
||||
for (walk = g_list_last (dec->queued); walk;
|
||||
walk = g_list_previous (walk)) {
|
||||
GstBuffer *buffer = GST_BUFFER (walk->data);
|
||||
|
@ -882,8 +886,14 @@ vorbis_dec_push_forward (GstVorbisDec * dec, GstBuffer * buf)
|
|||
GST_BUFFER_OFFSET (buffer) = outoffset;
|
||||
GST_BUFFER_TIMESTAMP (buffer) =
|
||||
gst_util_uint64_scale_int (outoffset, GST_SECOND, dec->vi.rate);
|
||||
GST_BUFFER_DURATION (buffer) = GST_CLOCK_DIFF (GST_BUFFER_TIMESTAMP
|
||||
(buffer), ts);
|
||||
ts = GST_BUFFER_TIMESTAMP (buffer);
|
||||
GST_DEBUG_OBJECT (dec, "patch buffer %" G_GUINT64_FORMAT
|
||||
" offset %" G_GUINT64_FORMAT, size, outoffset);
|
||||
", offset %" G_GUINT64_FORMAT ", timestamp %" GST_TIME_FORMAT
|
||||
", duration %" GST_TIME_FORMAT, size, outoffset,
|
||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)),
|
||||
GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)));
|
||||
size--;
|
||||
}
|
||||
for (walk = dec->queued; walk; walk = g_list_next (walk)) {
|
||||
|
@ -970,6 +980,7 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet)
|
|||
if ((sample_count = vorbis_synthesis_pcmout (&vd->vd, NULL)) == 0)
|
||||
goto done;
|
||||
|
||||
GST_LOG_OBJECT (vd, "%d samples ready for reading", sample_count);
|
||||
size = sample_count * vd->vi.channels * sizeof (float);
|
||||
|
||||
/* alloc buffer for it */
|
||||
|
@ -996,7 +1007,7 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet)
|
|||
vd->granulepos = packet->granulepos - sample_count;
|
||||
|
||||
if (vd->cur_timestamp != GST_CLOCK_TIME_NONE) {
|
||||
/* we have incomming timestamps */
|
||||
/* we have incoming timestamps */
|
||||
timestamp = vd->cur_timestamp;
|
||||
GST_DEBUG_OBJECT (vd,
|
||||
"cur_timestamp: %" GST_TIME_FORMAT " + %" GST_TIME_FORMAT " = %"
|
||||
|
@ -1008,12 +1019,20 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet)
|
|||
vd->vi.rate);
|
||||
GST_BUFFER_OFFSET_END (out) = GST_BUFFER_OFFSET (out) + sample_count;
|
||||
} else {
|
||||
/* we have incomming granulepos */
|
||||
/* we have incoming granulepos */
|
||||
GST_BUFFER_OFFSET (out) = vd->granulepos;
|
||||
if (vd->granulepos != -1) {
|
||||
GST_DEBUG_OBJECT (vd, "granulepos: %" G_GINT64_FORMAT, vd->granulepos);
|
||||
GST_BUFFER_OFFSET_END (out) = vd->granulepos + sample_count;
|
||||
timestamp =
|
||||
gst_util_uint64_scale_int (vd->granulepos, GST_SECOND, vd->vi.rate);
|
||||
GST_DEBUG_OBJECT (vd, "corresponding timestamp %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (timestamp));
|
||||
/* calculate a nano-second accurate duration */
|
||||
GST_BUFFER_DURATION (out) = GST_CLOCK_DIFF (timestamp,
|
||||
(vd->granulepos + sample_count) * GST_SECOND / vd->vi.rate);
|
||||
GST_DEBUG_OBJECT (vd, "set duration %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (GST_BUFFER_DURATION (out)));
|
||||
} else {
|
||||
timestamp = -1;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,8 @@ check_pango =
|
|||
endif
|
||||
|
||||
if USE_VORBIS
|
||||
check_vorbis = elements/vorbisdec pipelines/vorbisenc elements/vorbistag
|
||||
check_vorbis = elements/vorbisdec pipelines/vorbisenc pipelines/vorbisdec \
|
||||
elements/vorbistag
|
||||
else
|
||||
check_vorbis =
|
||||
endif
|
||||
|
@ -217,6 +218,11 @@ libs_video_LDADD = \
|
|||
$(GST_BASE_LIBS) \
|
||||
$(LDADD)
|
||||
|
||||
# this seemingly useless CFLAGS line is here only to avoid
|
||||
# vorbisdec.$(OBJEXT) by triggering creation of pipelines_vorbisdec.$(OBJEXT)
|
||||
# instead
|
||||
pipelines_vorbisdec_CFLAGS = $(AM_CFLAGS)
|
||||
|
||||
pipelines_oggmux_LDADD = $(LDADD) $(OGG_LIBS)
|
||||
pipelines_oggmux_CFLAGS = $(AM_CFLAGS) $(OGG_CFLAGS)
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@ GST_START_TEST (test_timestamps)
|
|||
GError *error = NULL;
|
||||
|
||||
pipe_str = g_strdup_printf ("audiotestsrc"
|
||||
" ! audio/x-raw-int,rate=44100" " ! audioconvert ! vorbisenc ! fakesink");
|
||||
" ! audio/x-raw-int,rate=44100 ! audioconvert ! vorbisenc ! fakesink");
|
||||
|
||||
bin = gst_parse_launch (pipe_str, &error);
|
||||
fail_unless (bin != NULL, "Error parsing pipeline: %s",
|
||||
|
|
Loading…
Reference in a new issue