From 9bbff1d51a8950ff315da2796bf2e5b899112e38 Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Thu, 29 Oct 2015 15:02:38 +0200 Subject: ivfparse: Add vp9 support Differentiate the vp8/vp9 bitstream based on fourcc. https://bugzilla.gnome.org/show_bug.cgi?id=757251 --- gst/ivfparse/gstivfparse.c | 25 ++++++++++++++++++++++--- gst/ivfparse/gstivfparse.h | 1 + 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/gst/ivfparse/gstivfparse.c b/gst/ivfparse/gstivfparse.c index 6b5758159..4e3ea8bd4 100644 --- a/gst/ivfparse/gstivfparse.c +++ b/gst/ivfparse/gstivfparse.c @@ -193,18 +193,35 @@ gst_ivf_parse_set_framerate (GstIvfParse * ivf, guint fps_n, guint fps_d) } } +static const gchar * +fourcc_to_media_type (guint32 fourcc) +{ + switch (fourcc) { + case GST_MAKE_FOURCC ('V', 'P', '8', '0'): + return "video/x-vp8"; + break; + case GST_MAKE_FOURCC ('V', 'P', '9', '0'): + return "video/x-vp9"; + default: + return NULL; + } + return NULL; +} + static void gst_ivf_parse_update_src_caps (GstIvfParse * ivf) { GstCaps *caps; - + const gchar *media_type; if (!ivf->update_caps && G_LIKELY (gst_pad_has_current_caps (GST_BASE_PARSE_SRC_PAD (ivf)))) return; ivf->update_caps = FALSE; + media_type = fourcc_to_media_type (ivf->fourcc); + /* Create src pad caps */ - caps = gst_caps_new_simple ("video/x-vp8", "width", G_TYPE_INT, ivf->width, + caps = gst_caps_new_simple (media_type, "width", G_TYPE_INT, ivf->width, "height", G_TYPE_INT, ivf->height, NULL); if (ivf->fps_n > 0 && ivf->fps_d > 0) { @@ -242,12 +259,14 @@ gst_ivf_parse_handle_frame_start (GstIvfParse * ivf, GstBaseParseFrame * frame, if (magic != GST_MAKE_FOURCC ('D', 'K', 'I', 'F') || version != 0 || header_size != 32 || - fourcc != GST_MAKE_FOURCC ('V', 'P', '8', '0')) { + fourcc_to_media_type (fourcc) == NULL) { GST_ELEMENT_ERROR (ivf, STREAM, WRONG_TYPE, (NULL), (NULL)); ret = GST_FLOW_ERROR; goto end; } + ivf->fourcc = fourcc; + gst_ivf_parse_set_size (ivf, width, height); gst_ivf_parse_set_framerate (ivf, fps_n, fps_d); diff --git a/gst/ivfparse/gstivfparse.h b/gst/ivfparse/gstivfparse.h index ee0c50d97..1a72f35b1 100644 --- a/gst/ivfparse/gstivfparse.h +++ b/gst/ivfparse/gstivfparse.h @@ -56,6 +56,7 @@ struct _GstIvfParse guint height; guint fps_n; guint fps_d; + guint32 fourcc; gboolean update_caps; }; -- cgit v1.2.1