diff options
author | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2012-10-25 11:31:41 +0200 |
---|---|---|
committer | Josep Torra <n770galaxy@gmail.com> | 2013-03-05 10:49:38 +0100 |
commit | 41ecfcd429d45f47378f8e9e3c201dd2af6abb9d (patch) | |
tree | df76a7de14a801d99a9ca923bcd73bcf708ae581 | |
parent | fdd406b6e906b0e0fb7d5370bab8cada22448c83 (diff) | |
download | gstreamer-plugins-bad-41ecfcd429d45f47378f8e9e3c201dd2af6abb9d.tar.gz |
videoparsers: preserve upstream fps and par
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=660866
Conflicts:
gst/videoparsers/gsth264parse.c
gst/videoparsers/gstmpegvideoparse.c
-rw-r--r-- | gst/videoparsers/gsth264parse.c | 19 | ||||
-rw-r--r-- | gst/videoparsers/gstmpegvideoparse.c | 12 |
2 files changed, 21 insertions, 10 deletions
diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index 04f09aa8e..c0f2b4216 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -1016,6 +1016,7 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps) GstCaps *sink_caps; gboolean modified = FALSE; GstBuffer *buf = NULL; + GstStructure *s = NULL; if (G_UNLIKELY (!GST_PAD_CAPS (GST_BASE_PARSE_SRC_PAD (h264parse)))) modified = TRUE; @@ -1030,10 +1031,12 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps) sink_caps = GST_PAD_CAPS (GST_BASE_PARSE_SINK_PAD (h264parse)); /* carry over input caps as much as possible; override with our own stuff */ - if (sink_caps) + if (sink_caps) { gst_caps_ref (sink_caps); - else + s = gst_caps_get_structure (sink_caps, 0); + } else { sink_caps = gst_caps_new_simple ("video/x-h264", NULL); + } sps = h264parse->nalparser->last_sps; GST_DEBUG_OBJECT (h264parse, "sps: %p", sps); @@ -1076,8 +1079,6 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps) sps->fps_num, sps->fps_den); h264parse->fps_num = sps->fps_num; h264parse->fps_den = sps->fps_den; - gst_base_parse_set_frame_rate (GST_BASE_PARSE (h264parse), - h264parse->fps_num, h264parse->fps_den, 0, 0); modified = TRUE; } } @@ -1109,9 +1110,14 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps) gst_caps_set_simple (caps, "width", G_TYPE_INT, sps->width, "height", G_TYPE_INT, sps->height, NULL); /* but not necessarily or reliably this */ - if (h264parse->fps_num > 0 && h264parse->fps_den > 0) + if (h264parse->fps_num > 0 && h264parse->fps_den > 0 && + (!s || !gst_structure_has_field (s, "framerate"))) { + GST_INFO_OBJECT (h264parse, "setting framerate in caps"); gst_caps_set_simple (caps, "framerate", GST_TYPE_FRACTION, h264parse->fps_num, h264parse->fps_den, NULL); + gst_base_parse_set_frame_rate (GST_BASE_PARSE (h264parse), + h264parse->fps_num, h264parse->fps_den, 0, 0); + } } } @@ -1125,7 +1131,8 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps) gst_h264_parse_get_string (h264parse, FALSE, h264parse->align), NULL); gst_h264_parse_get_par (h264parse, &par_n, &par_d); - if (par_n != 0 && par_d != 0) { + if (par_n != 0 && par_d != 0 && + (!s || !gst_structure_has_field (s, "pixel-aspect-ratio"))) { GST_INFO_OBJECT (h264parse, "PAR %d/%d", par_n, par_d); gst_caps_set_simple (caps, "pixel-aspect-ratio", GST_TYPE_FRACTION, par_n, par_d, NULL); diff --git a/gst/videoparsers/gstmpegvideoparse.c b/gst/videoparsers/gstmpegvideoparse.c index 80b90b238..826218db2 100644 --- a/gst/videoparsers/gstmpegvideoparse.c +++ b/gst/videoparsers/gstmpegvideoparse.c @@ -584,6 +584,7 @@ static void gst_mpegv_parse_update_src_caps (GstMpegvParse * mpvparse) { GstCaps *caps = NULL; + GstStructure *s = NULL; /* only update if no src caps yet or explicitly triggered */ if (G_LIKELY (GST_PAD_CAPS (GST_BASE_PARSE_SRC_PAD (mpvparse)) && @@ -593,7 +594,8 @@ gst_mpegv_parse_update_src_caps (GstMpegvParse * mpvparse) /* carry over input caps as much as possible; override with our own stuff */ caps = GST_PAD_CAPS (GST_BASE_PARSE_SINK_PAD (mpvparse)); if (caps) { - caps = gst_caps_copy (caps); + caps = gst_caps_make_writable (caps); + s = gst_caps_get_structure (caps, 0); } else { caps = gst_caps_new_simple ("video/mpeg", NULL); } @@ -615,8 +617,9 @@ gst_mpegv_parse_update_src_caps (GstMpegvParse * mpvparse) "height", G_TYPE_INT, mpvparse->sequencehdr.height, NULL); } - /* perhaps we have a framerate */ - if (mpvparse->fps_num > 0 && mpvparse->fps_den > 0) { + /* perhaps we have a framerate */ + if (mpvparse->fps_num > 0 && mpvparse->fps_den > 0 && + (!s || !gst_structure_has_field (s, "framerate"))) { gint fps_num = mpvparse->fps_num; gint fps_den = mpvparse->fps_den; GstClockTime latency = gst_util_uint64_scale (GST_SECOND, fps_den, fps_num); @@ -629,7 +632,8 @@ gst_mpegv_parse_update_src_caps (GstMpegvParse * mpvparse) } /* or pixel-aspect-ratio */ - if (mpvparse->sequencehdr.par_w && mpvparse->sequencehdr.par_h > 0) { + if (mpvparse->sequencehdr.par_w && mpvparse->sequencehdr.par_h > 0 && + (!s || !gst_structure_has_field (s, "pixel-aspect-ratio"))) { gst_caps_set_simple (caps, "pixel-aspect-ratio", GST_TYPE_FRACTION, mpvparse->sequencehdr.par_w, mpvparse->sequencehdr.par_h, NULL); } |