From 4f961e6d95f85120d6e30d06515bfd4c76321cb3 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Wed, 28 Jan 2015 05:20:19 +1100 Subject: [PATCH] audiodecoder: Where possible, skip decode for GST_SEGMENT_FLAG_TRICKMODE_NO_AUDIO If we have timestamps on input buffers and are in trickmode no-audio mode, then don't pass anything to the subclass for decode and simply send gap events downstream Only for forward playback for now - reverse requires accumulating GAP events and pushing out in reverse order. https://bugzilla.gnome.org/show_bug.cgi?id=735666 --- gst-libs/gst/audio/gstaudiodecoder.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/gst-libs/gst/audio/gstaudiodecoder.c b/gst-libs/gst/audio/gstaudiodecoder.c index c97883c2a5..991371ed70 100644 --- a/gst-libs/gst/audio/gstaudiodecoder.c +++ b/gst-libs/gst/audio/gstaudiodecoder.c @@ -378,6 +378,8 @@ static gboolean gst_audio_decoder_propose_allocation_default (GstAudioDecoder * dec, GstQuery * query); static gboolean gst_audio_decoder_negotiate_default (GstAudioDecoder * dec); static gboolean gst_audio_decoder_negotiate_unlocked (GstAudioDecoder * dec); +static gboolean gst_audio_decoder_handle_gap (GstAudioDecoder * dec, + GstEvent * event); static GstElementClass *parent_class = NULL; @@ -1302,6 +1304,27 @@ static GstFlowReturn gst_audio_decoder_handle_frame (GstAudioDecoder * dec, GstAudioDecoderClass * klass, GstBuffer * buffer) { + /* Skip decoding and send a GAP instead if + * GST_SEGMENT_FLAG_TRICKMODE_NO_AUDIO is set and we have timestamps + * FIXME: We only do this for forward playback atm, because reverse + * playback would require accumulating GAP events and pushing them + * out in reverse order as for normal audio samples + */ + if (G_UNLIKELY (dec->input_segment.rate > 0.0 + && dec->input_segment.flags & GST_SEGMENT_FLAG_TRICKMODE_NO_AUDIO)) { + if (buffer) { + GstClockTime ts = GST_BUFFER_PTS (buffer); + if (GST_CLOCK_TIME_IS_VALID (ts)) { + GstEvent *event = gst_event_new_gap (ts, GST_BUFFER_DURATION (buffer)); + + gst_buffer_unref (buffer); + GST_LOG_OBJECT (dec, "Skipping decode in trickmode and sending gap"); + gst_audio_decoder_handle_gap (dec, event); + return GST_FLOW_OK; + } + } + } + if (G_LIKELY (buffer)) { gsize size = gst_buffer_get_size (buffer); /* keep around for admin */ -- 2.34.1