From e1cc846edc7252797fb5caf26edb9fcd07e3a361 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Fri, 15 Jun 2007 11:15:28 +0000 Subject: [PATCH] tests/check/pipelines/oggmux.c: Add a test that ensures we set DELTA_UNIT on all non-header, non-video buffers, if we... Original commit message from CVS: * tests/check/pipelines/oggmux.c: (validate_ogg_page), (is_video), (eos_buffer_probe): Add a test that ensures we set DELTA_UNIT on all non-header, non-video buffers, if we have a video stream. * ext/ogg/gstoggmux.c: (gst_ogg_mux_queue_pads), (gst_ogg_mux_process_best_pad): Move setting delta_pad to earlier, where we inspect all pads, so that leading audio pages don't get DELTA_UNIT unset if they come before the first DELTA_UNIT from video pages. Fixes the newly-added test. Fixes #385527. --- ChangeLog | 13 +++++++++++++ ext/ogg/gstoggmux.c | 9 ++++----- tests/check/pipelines/oggmux.c | 30 ++++++++++++++++++++++++++++-- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index c60fd9e26e..09cf380a8d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2007-06-15 Michael Smith + + * tests/check/pipelines/oggmux.c: (validate_ogg_page), (is_video), + (eos_buffer_probe): + Add a test that ensures we set DELTA_UNIT on all non-header, + non-video buffers, if we have a video stream. + * ext/ogg/gstoggmux.c: (gst_ogg_mux_queue_pads), + (gst_ogg_mux_process_best_pad): + Move setting delta_pad to earlier, where we inspect all pads, so + that leading audio pages don't get DELTA_UNIT unset if they come + before the first DELTA_UNIT from video pages. Fixes the newly-added + test. Fixes #385527. + 2007-06-14 Tim-Philipp Müller * tests/check/pipelines/streamheader.c: (streamheader_suite): diff --git a/ext/ogg/gstoggmux.c b/ext/ogg/gstoggmux.c index df4dca2100..4ed8876158 100644 --- a/ext/ogg/gstoggmux.c +++ b/ext/ogg/gstoggmux.c @@ -795,6 +795,10 @@ gst_ogg_mux_queue_pads (GstOggMux * ogg_mux) /* On EOS we get a NULL buffer */ if (buf != NULL) { + if (ogg_mux->delta_pad == NULL && + GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT)) + ogg_mux->delta_pad = pad; + incaps = GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_IN_CAPS); /* if we need headers */ if (pad->state == GST_OGG_PAD_STATE_CONTROL) { @@ -1365,11 +1369,6 @@ gst_ogg_mux_process_best_pad (GstOggMux * ogg_mux, GstOggPad * best) /* if this is the first packet of a new page figure out the delta flag */ if (pad->new_page) { if (delta_unit) { - /* This page is a delta frame */ - if (ogg_mux->delta_pad == NULL) { - /* we got a delta unit on this pad */ - ogg_mux->delta_pad = pad; - } /* mark the page as delta */ pad->first_delta = TRUE; } else { diff --git a/tests/check/pipelines/oggmux.c b/tests/check/pipelines/oggmux.c index 5236972e9e..254f810dca 100644 --- a/tests/check/pipelines/oggmux.c +++ b/tests/check/pipelines/oggmux.c @@ -94,7 +94,7 @@ fail_if_audio (gpointer key, ChainState * state, gpointer data) fail_if (state->codec == CODEC_SPEEX, "speex BOS occurred before theora BOS"); } -static void +static ChainState * validate_ogg_page (ogg_page * page) { gulong serialno; @@ -146,8 +146,18 @@ validate_ogg_page (ogg_page * page) G_GINT64_FORMAT, serialno, state->last_granule, granule); state->last_granule = granule; } + + return state; } +static void +is_video (gpointer key, ChainState * state, gpointer data) +{ + if (state->codec == CODEC_THEORA) + *((gboolean *) data) = TRUE; +} + + static gboolean eos_buffer_probe (GstPad * pad, GstBuffer * buffer, gpointer unused) { @@ -155,6 +165,8 @@ eos_buffer_probe (GstPad * pad, GstBuffer * buffer, gpointer unused) gint size; guint8 *data; gchar *oggbuffer; + ChainState *state = NULL; + gboolean has_video = FALSE; size = GST_BUFFER_SIZE (buffer); data = GST_BUFFER_DATA (buffer); @@ -168,10 +180,24 @@ eos_buffer_probe (GstPad * pad, GstBuffer * buffer, gpointer unused) ret = ogg_sync_pageout (&oggsync, &page); if (ret > 0) - validate_ogg_page (&page); + state = validate_ogg_page (&page); } while (ret != 0); + if (state) { + /* Now, we can do buffer-level checks... + * If we have video somewhere, then we should have DELTA_UNIT set on all + * non-header (not IN_CAPS), non-video buffers + */ + g_hash_table_foreach (eos_chain_states, (GHFunc) is_video, &has_video); + if (has_video && state->codec != CODEC_THEORA) { + if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_IN_CAPS)) + fail_unless (GST_BUFFER_FLAG_IS_SET (buffer, + GST_BUFFER_FLAG_DELTA_UNIT), + "Non-video buffer doesn't have DELTA_UNIT in stream with video"); + } + } + return TRUE; }