videoparsers: use parsed or upstream fps to set some baseparse parameters

This commit is contained in:
Mark Nauwelaerts 2012-10-25 17:50:52 +02:00
parent 58441bf262
commit 0d1c7f6ea2
3 changed files with 43 additions and 20 deletions

View file

@ -1194,18 +1194,29 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps)
}
if (G_UNLIKELY (modified)) {
gint fps_num = h264parse->fps_num;
gint fps_den = h264parse->fps_den;
GstClockTime latency;
caps = gst_caps_copy (sink_caps);
/* sps should give this */
gst_caps_set_simple (caps, "width", G_TYPE_INT, sps->width,
"height", G_TYPE_INT, sps->height, NULL);
/* upstream overrides */
if (s && gst_structure_has_field (s, "framerate"))
gst_structure_get_fraction (s, "framerate", &fps_num, &fps_den);
/* but not necessarily or reliably this */
if (h264parse->fps_num > 0 && h264parse->fps_den > 0 &&
(!s || !gst_structure_has_field (s, "framerate"))) {
if (fps_num > 0 && fps_den > 0) {
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_TYPE_FRACTION, fps_num, fps_den, NULL);
gst_base_parse_set_frame_rate (GST_BASE_PARSE (h264parse),
h264parse->fps_num, h264parse->fps_den, 0, 0);
fps_num, fps_den, 0, 0);
latency = gst_util_uint64_scale (GST_SECOND, fps_den, fps_num);
gst_base_parse_set_latency (GST_BASE_PARSE (h264parse), latency,
latency);
}
}
}

View file

@ -589,17 +589,23 @@ gst_mpeg4vparse_update_src_caps (GstMpeg4VParse * mp4vparse)
}
/* perhaps we have a framerate */
if (mp4vparse->vol.fixed_vop_time_increment != 0 &&
(!s || !gst_structure_has_field (s, "framerate"))) {
{
gint fps_num = mp4vparse->vol.vop_time_increment_resolution;
gint fps_den = mp4vparse->vol.fixed_vop_time_increment;
GstClockTime latency = gst_util_uint64_scale (GST_SECOND, fps_den, fps_num);
GstClockTime latency;
gst_caps_set_simple (caps, "framerate",
GST_TYPE_FRACTION, fps_num, fps_den, NULL);
gst_base_parse_set_frame_rate (GST_BASE_PARSE (mp4vparse),
fps_num, fps_den, 0, 0);
gst_base_parse_set_latency (GST_BASE_PARSE (mp4vparse), latency, latency);
/* upstream overrides */
if (s && gst_structure_has_field (s, "framerate"))
gst_structure_get_fraction (s, "framerate", &fps_num, &fps_den);
if (fps_den > 0 && fps_num > 0) {
gst_caps_set_simple (caps, "framerate",
GST_TYPE_FRACTION, fps_num, fps_den, NULL);
gst_base_parse_set_frame_rate (GST_BASE_PARSE (mp4vparse),
fps_num, fps_den, 0, 0);
latency = gst_util_uint64_scale (GST_SECOND, fps_den, fps_num);
gst_base_parse_set_latency (GST_BASE_PARSE (mp4vparse), latency, latency);
}
}
/* or pixel-aspect-ratio */

View file

@ -659,17 +659,23 @@ gst_mpegv_parse_update_src_caps (GstMpegvParse * mpvparse)
}
/* 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);
GstClockTime latency;
gst_caps_set_simple (caps, "framerate",
GST_TYPE_FRACTION, fps_num, fps_den, NULL);
gst_base_parse_set_frame_rate (GST_BASE_PARSE (mpvparse),
fps_num, fps_den, 0, 0);
gst_base_parse_set_latency (GST_BASE_PARSE (mpvparse), latency, latency);
/* upstream overrides */
if (s && gst_structure_has_field (s, "framerate"))
gst_structure_get_fraction (s, "framerate", &fps_num, &fps_den);
if (fps_den > 0 && fps_num > 0) {
gst_caps_set_simple (caps, "framerate",
GST_TYPE_FRACTION, fps_num, fps_den, NULL);
gst_base_parse_set_frame_rate (GST_BASE_PARSE (mpvparse),
fps_num, fps_den, 0, 0);
latency = gst_util_uint64_scale (GST_SECOND, fps_den, fps_num);
gst_base_parse_set_latency (GST_BASE_PARSE (mpvparse), latency, latency);
}
}
/* or pixel-aspect-ratio */