h264parse: Default framerate to 0/1 when no informations found

It is not perfect but it allows us to be sure that the mandatory 'framerate'
field is present in the caps.

As soon as some information is found in the stream, that will be
updated.

https://bugzilla.gnome.org/show_bug.cgi?id=723243
This commit is contained in:
Thibault Saunier 2014-01-29 16:32:30 +01:00
parent e9a253640e
commit 5fd9b42f29

View file

@ -1182,18 +1182,16 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps)
modified = TRUE; modified = TRUE;
} }
/* 0/1 is set as the default in the codec parser */ /* 0/1 is set as the default in the codec parser, we will set
if (sps->vui_parameters.timing_info_present_flag && * it in case we have no info */
!(sps->fps_num == 0 && sps->fps_den == 1)) {
if (G_UNLIKELY (h264parse->fps_num != sps->fps_num if (G_UNLIKELY (h264parse->fps_num != sps->fps_num
|| h264parse->fps_den != sps->fps_den)) { || h264parse->fps_den != sps->fps_den)) {
GST_INFO_OBJECT (h264parse, "framerate changed %d/%d", GST_DEBUG_OBJECT (h264parse, "framerate changed %d/%d",
sps->fps_num, sps->fps_den); sps->fps_num, sps->fps_den);
h264parse->fps_num = sps->fps_num; h264parse->fps_num = sps->fps_num;
h264parse->fps_den = sps->fps_den; h264parse->fps_den = sps->fps_den;
modified = TRUE; modified = TRUE;
} }
}
if (sps->vui_parameters.aspect_ratio_info_present_flag) { if (sps->vui_parameters.aspect_ratio_info_present_flag) {
if (G_UNLIKELY ((h264parse->parsed_par_n != sps->vui_parameters.par_n) if (G_UNLIKELY ((h264parse->parsed_par_n != sps->vui_parameters.par_n)
@ -1232,18 +1230,19 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps)
gst_structure_get_fraction (s, "framerate", &fps_num, &fps_den); gst_structure_get_fraction (s, "framerate", &fps_num, &fps_den);
/* but not necessarily or reliably this */ /* but not necessarily or reliably this */
if (fps_num > 0 && fps_den > 0) { if (fps_den > 0) {
GST_INFO_OBJECT (h264parse, "setting framerate in caps");
gst_caps_set_simple (caps, "framerate", gst_caps_set_simple (caps, "framerate",
GST_TYPE_FRACTION, fps_num, fps_den, NULL); GST_TYPE_FRACTION, fps_num, fps_den, NULL);
gst_base_parse_set_frame_rate (GST_BASE_PARSE (h264parse), gst_base_parse_set_frame_rate (GST_BASE_PARSE (h264parse),
fps_num, fps_den, 0, 0); fps_num, fps_den, 0, 0);
if (fps_num > 0) {
latency = gst_util_uint64_scale (GST_SECOND, fps_den, fps_num); latency = gst_util_uint64_scale (GST_SECOND, fps_den, fps_num);
gst_base_parse_set_latency (GST_BASE_PARSE (h264parse), latency, gst_base_parse_set_latency (GST_BASE_PARSE (h264parse), latency,
latency); latency);
} }
} }
} }
}
if (caps) { if (caps) {
gint par_n, par_d; gint par_n, par_d;