diff options
author | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2012-10-25 11:31:41 +0200 |
---|---|---|
committer | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2012-10-25 17:07:18 +0200 |
commit | 821c8519e0d17728d9d80447e22e9d7db5222cea (patch) | |
tree | 4b71beea8ba618468fdde0f7f64089a6525b88a1 | |
parent | ac420ff0de3a996b3380fd10007879957d014669 (diff) |
videoparsers: preserve upstream fps and par
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=660866
-rw-r--r-- | gst/videoparsers/gsth264parse.c | 15 | ||||
-rw-r--r-- | gst/videoparsers/gstmpegvideoparse.c | 10 |
2 files changed, 18 insertions, 7 deletions
diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index bb9ada9dd..af32a7205 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -1102,6 +1102,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_has_current_caps (GST_BASE_PARSE_SRC_PAD (h264parse)))) @@ -1119,6 +1120,8 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps) /* carry over input caps as much as possible; override with our own stuff */ if (!sink_caps) sink_caps = gst_caps_new_empty_simple ("video/x-h264"); + else + s = gst_caps_get_structure (caps, 0); sps = h264parse->nalparser->last_sps; GST_DEBUG_OBJECT (h264parse, "sps: %p", sps); @@ -1165,8 +1168,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; } } @@ -1198,9 +1199,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); + } } } @@ -1214,7 +1220,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 bb111b0d1..e3e6fa630 100644 --- a/gst/videoparsers/gstmpegvideoparse.c +++ b/gst/videoparsers/gstmpegvideoparse.c @@ -626,6 +626,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_has_current_caps (GST_BASE_PARSE_SRC_PAD (mpvparse)) && @@ -636,6 +637,7 @@ gst_mpegv_parse_update_src_caps (GstMpegvParse * mpvparse) caps = gst_pad_get_current_caps (GST_BASE_PARSE_SINK_PAD (mpvparse)); if (caps) { caps = gst_caps_make_writable (caps); + s = gst_caps_get_structure (caps, 0); } else { caps = gst_caps_new_empty_simple ("video/mpeg"); } @@ -656,8 +658,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); @@ -670,7 +673,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); } |