summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com>2015-10-17 01:51:24 -0700
committerReynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com>2015-10-18 14:53:01 -0700
commitec5648763dd00b09ae2522372d453417ae8403f0 (patch)
tree600166f142f4bfc5f313eda3a2bb1859579f4b41
parent4b5e2f68a3767ddd66681c7a20c05bb2829c3234 (diff)
downloadgstreamer-plugins-bad-ec5648763dd00b09ae2522372d453417ae8403f0.tar.gz
pnmdec: propagate input state after parsing
Store and copy input state fields when setting the output state of the decoder. Avoids problems like the framerate set by an upstream element being ignored Related to: https://bugzilla.gnome.org/show_bug.cgi?id=756563
-rw-r--r--gst/pnm/gstpnmdec.c32
-rw-r--r--gst/pnm/gstpnmdec.h1
2 files changed, 32 insertions, 1 deletions
diff --git a/gst/pnm/gstpnmdec.c b/gst/pnm/gstpnmdec.c
index d99374a10..2f7e774fe 100644
--- a/gst/pnm/gstpnmdec.c
+++ b/gst/pnm/gstpnmdec.c
@@ -44,6 +44,9 @@
#include <stdio.h>
static gboolean gst_pnmdec_start (GstVideoDecoder * decoder);
+static gboolean gst_pnmdec_set_format (GstVideoDecoder * decoder,
+ GstVideoCodecState * state);
+static gboolean gst_pnmdec_stop (GstVideoDecoder * decoder);
static GstFlowReturn gst_pnmdec_parse (GstVideoDecoder * decoder,
GstVideoCodecFrame * frame, GstAdapter * adapter, gboolean at_eos);
static GstFlowReturn gst_pnmdec_handle_frame (GstVideoDecoder * decoder,
@@ -83,8 +86,10 @@ gst_pnmdec_class_init (GstPnmdecClass * klass)
"Lutz Mueller <lutz@users.sourceforge.net>");
vdec_class->start = gst_pnmdec_start;
+ vdec_class->stop = gst_pnmdec_stop;
vdec_class->parse = gst_pnmdec_parse;
vdec_class->handle_frame = gst_pnmdec_handle_frame;
+ vdec_class->set_format = gst_pnmdec_set_format;
}
static void
@@ -111,6 +116,31 @@ gst_pnmdec_init (GstPnmdec * s)
GST_PAD_SET_ACCEPT_TEMPLATE (GST_VIDEO_DECODER_SINK_PAD (s));
}
+static gboolean
+gst_pnmdec_set_format (GstVideoDecoder * decoder, GstVideoCodecState * state)
+{
+ GstPnmdec *pnmdec = (GstPnmdec *) decoder;
+
+ if (pnmdec->input_state)
+ gst_video_codec_state_unref (pnmdec->input_state);
+ pnmdec->input_state = gst_video_codec_state_ref (state);
+
+ return TRUE;
+}
+
+static gboolean
+gst_pnmdec_stop (GstVideoDecoder * decoder)
+{
+ GstPnmdec *pnmdec = (GstPnmdec *) decoder;
+
+ if (pnmdec->input_state) {
+ gst_video_codec_state_unref (pnmdec->input_state);
+ pnmdec->input_state = NULL;
+ }
+
+ return TRUE;
+}
+
static GstFlowReturn
gst_pnmdec_parse_ascii (GstPnmdec * s, const guint8 * b, guint bs)
{
@@ -330,7 +360,7 @@ gst_pnmdec_parse (GstVideoDecoder * decoder, GstVideoCodecFrame * frame,
}
output_state =
gst_video_decoder_set_output_state (GST_VIDEO_DECODER (s), format,
- s->mngr.info.width, s->mngr.info.height, NULL);
+ s->mngr.info.width, s->mngr.info.height, s->input_state);
gst_video_codec_state_unref (output_state);
if (gst_video_decoder_negotiate (GST_VIDEO_DECODER (s)) == FALSE) {
r = GST_FLOW_NOT_NEGOTIATED;
diff --git a/gst/pnm/gstpnmdec.h b/gst/pnm/gstpnmdec.h
index a148f72c9..28a3c5053 100644
--- a/gst/pnm/gstpnmdec.h
+++ b/gst/pnm/gstpnmdec.h
@@ -41,6 +41,7 @@ struct _GstPnmdec
GstElement element;
GstVideoDecoder decoder;
GstPnmInfoMngr mngr;
+ GstVideoCodecState *input_state;
guint size, last_byte, current_size ;
GstBuffer *buf;
};